SPIGOT-5753: Back PotionType by a minecraft registry

By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
Bukkit/Spigot
2023-10-09 20:22:49 +11:00
parent 199105c1d5
commit 5889c180cc
8 changed files with 192 additions and 35 deletions

View File

@@ -3,6 +3,10 @@ package org.bukkit.potion;
import com.google.common.base.Preconditions;
import org.jetbrains.annotations.NotNull;
/**
* @deprecated Upgraded / extended potions are now their own {@link PotionType} use them instead.
*/
@Deprecated
public final class PotionData {
private final PotionType type;
@@ -24,6 +28,8 @@ public final class PotionData {
Preconditions.checkArgument(!upgraded || type.isUpgradeable(), "Potion Type is not upgradable");
Preconditions.checkArgument(!extended || type.isExtendable(), "Potion Type is not extendable");
Preconditions.checkArgument(!upgraded || !extended, "Potion cannot be both extended and upgraded");
Preconditions.checkArgument(!type.getKey().getKey().startsWith("strong_"), "Strong potion type cannot be used directly, got %s", type.getKey());
Preconditions.checkArgument(!type.getKey().getKey().startsWith("long_"), "Extended potion type cannot be used directly, got %s", type.getKey());
this.type = type;
this.extended = extended;
this.upgraded = upgraded;