From 0f8765d0c547de3a802ea80d797fbf881befb9c6 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 1 Jun 2018 01:23:57 +0100 Subject: [PATCH] Finish ChickenTaunt --- .../gadget/gadgets/taunts/ChickenTaunt.java | 52 +++++++++++++------ 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/ChickenTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/ChickenTaunt.java index 16b77dd78..a736400ff 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/ChickenTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/ChickenTaunt.java @@ -13,6 +13,8 @@ import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import com.mojang.authlib.GameProfile; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilItem; @@ -20,7 +22,7 @@ import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseBase; -import mineplex.core.disguise.disguises.DisguiseChicken; +import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.TauntGadget; import mineplex.core.gadget.util.CostConstants; @@ -32,24 +34,27 @@ import mineplex.core.updater.UpdateType; public class ChickenTaunt extends TauntGadget { - private static final int COOLDOWN = 3000, PVP_COOLDOWN = 10000; + private static final int COOLDOWN = 30000, PVP_COOLDOWN = 10000; + private static final String CHICKEN_SKIN = "MHF_Chicken"; private final Map _disguises = new HashMap<>(); + private GameProfile _cachedProfile; + public ChickenTaunt(GadgetManager manager) { super(manager, "Chicken Taunt", new String[] - { - C.cGray + "Baw Baw Bawk! It seems that", - C.cGray + "everyone is too afraid to fight you", - C.cGray + "what a shame.", - "", - C.cWhite + "Use /taunt in game to use this taunt.", - C.cRed + "Cannot be used while in PvP!" - }, CostConstants.POWERPLAY_BONUS, Material.GLASS, (byte) 0); + { + C.cGray + "Baw Baw Bawk! It seems that", + C.cGray + "everyone is too afraid to fight you", + C.cGray + "what a shame.", + "", + C.cWhite + "Use /taunt in game to use this taunt.", + C.cRed + "Cannot be used while in PvP!" + }, CostConstants.POWERPLAY_BONUS, Material.GLASS, (byte) 0); setDisplayItem(new ItemBuilder(Material.SKULL_ITEM, (byte) 3) - .setPlayerHead("MHF_Chicken") + .setPlayerHead(CHICKEN_SKIN) .build()); setPPCYearMonth(YearMonth.of(2018, Month.JUNE)); setCanPlayWithPvp(false); @@ -75,11 +80,26 @@ public class ChickenTaunt extends TauntGadget if (!Manager.getDisguiseManager().isDisguised(player)) { - DisguiseChicken disguise = new DisguiseChicken(player); - disguise.setName(player.getName()); - disguise.setCustomNameVisible(true); - Manager.getDisguiseManager().disguise(disguise); - _disguises.put(player.getUniqueId(), disguise); + DisguisePlayer disguise; + + if (_cachedProfile == null) + { + disguise = new DisguisePlayer(player, player.getName(), CHICKEN_SKIN); + disguise.showInTabList(true, 0); + disguise.initialize(() -> + { + _cachedProfile = disguise.getProfile(); + Manager.getDisguiseManager().disguise(disguise); + _disguises.put(player.getUniqueId(), disguise); + }); + } + else + { + disguise = new DisguisePlayer(player, _cachedProfile); + disguise.showInTabList(true, 0); + Manager.getDisguiseManager().disguise(disguise); + _disguises.put(player.getUniqueId(), disguise); + } } return true;