Something like this?

This commit is contained in:
Olof Larsson 2016-03-10 16:45:32 +01:00
parent 3681b189f6
commit e10267d30f

View File

@ -1,8 +1,9 @@
package com.massivecraft.massivecore.adapter; package com.massivecraft.massivecore.adapter;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.inventory.meta.PotionMeta;
import com.massivecraft.massivecore.xlib.gson.JsonElement;
import com.massivecraft.massivecore.xlib.gson.JsonObject; import com.massivecraft.massivecore.xlib.gson.JsonObject;
public class ItemStackAdapterInner19 extends ItemStackAdapterInner18 public class ItemStackAdapterInner19 extends ItemStackAdapterInner18
@ -11,7 +12,8 @@ public class ItemStackAdapterInner19 extends ItemStackAdapterInner18
// CONSTANTS: NAMES // 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 // INSTANCE & CONSTRUCT
@ -27,7 +29,8 @@ public class ItemStackAdapterInner19 extends ItemStackAdapterInner18
@Override @Override
public Object provoke() 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); super.transferPotion(stack, json, meta2json, meta);
// TODO: Handle new potions here. if (meta2json)
// TODO: Awaiting the pull request by t00thp1ck. {
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();
} }
} }