Something like this?
This commit is contained in:
parent
3681b189f6
commit
e10267d30f
@ -1,8 +1,9 @@
|
||||
package com.massivecraft.massivecore.adapter;
|
||||
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonElement;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonObject;
|
||||
|
||||
public class ItemStackAdapterInner19 extends ItemStackAdapterInner18
|
||||
@ -11,7 +12,8 @@ public class ItemStackAdapterInner19 extends ItemStackAdapterInner18
|
||||
// CONSTANTS: NAMES
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static final String POTION = "potion";
|
||||
// TODO: For now we keep erializing with the damage value.
|
||||
// public static final String POTION = "potion";
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
@ -27,7 +29,8 @@ public class ItemStackAdapterInner19 extends ItemStackAdapterInner18
|
||||
@Override
|
||||
public Object provoke()
|
||||
{
|
||||
return PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT;
|
||||
throw new RuntimeException("not done coding this yet");
|
||||
// return PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -39,8 +42,42 @@ public class ItemStackAdapterInner19 extends ItemStackAdapterInner18
|
||||
{
|
||||
super.transferPotion(stack, json, meta2json, meta);
|
||||
|
||||
// TODO: Handle new potions here.
|
||||
// TODO: Awaiting the pull request by t00thp1ck.
|
||||
if (meta2json)
|
||||
{
|
||||
int damage = getPotionDamage(stack, meta);
|
||||
if (damage == DEFAULT_DAMAGE)
|
||||
{
|
||||
json.remove(DAMAGE);
|
||||
}
|
||||
else
|
||||
{
|
||||
json.addProperty(DAMAGE, damage);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int damage = DEFAULT_DAMAGE;
|
||||
JsonElement element = json.get(DAMAGE);
|
||||
if (element != null) damage = element.getAsInt();
|
||||
setPotionDamage(stack, meta, damage);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// POTION DAMAGE
|
||||
// -------------------------------------------- //
|
||||
// Note that there might be potions with invalid damage values.
|
||||
// They might have been created by mcmmo and other plugins adding custom potions using custom damage.
|
||||
// We do not destroy these invalid potions, but rather keep them as is.
|
||||
|
||||
public static int getPotionDamage(ItemStack stack, PotionMeta meta)
|
||||
{
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
public static void setPotionDamage(ItemStack stack, PotionMeta meta, int damage)
|
||||
{
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user