diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index d06f0527b..0bd054209 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -302,6 +302,7 @@ import mineplex.core.gadget.gadgets.particle.king.CastleManager; import mineplex.core.gadget.gadgets.particle.king.ParticleKing; import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt; +import mineplex.core.gadget.gadgets.taunts.ChickenTaunt; import mineplex.core.gadget.gadgets.taunts.EasyModeTaunt; import mineplex.core.gadget.gadgets.taunts.EmojiTaunt; import mineplex.core.gadget.gadgets.taunts.EternalTaunt; @@ -846,6 +847,7 @@ public class GadgetManager extends MiniPlugin addGadget(new FrostBreathTaunt(this)); addGadget(new EmojiTaunt(this)); addGadget(new EasyModeTaunt(this)); + addGadget(new ChickenTaunt(this)); // Flags addGadget(new FlagGadget(this, FlagType.CANADA)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/TestTauntCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/TestTauntCommand.java index 304c99468..7b62fbd5f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/TestTauntCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/TestTauntCommand.java @@ -38,6 +38,11 @@ public class TestTauntCommand extends CommandBase return; } + if (!gadget.isActive(caller)) + { + gadget.enable(caller); + } + gadget.start(caller); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java index bff6daafa..72ea48270 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java @@ -19,8 +19,7 @@ import mineplex.core.recharge.Recharge; public class BlowAKissTaunt extends TauntGadget { - private static final int COOLDOWN = 30000; - private static final int PVP_COOLDOWN = 10000; + private static final int COOLDOWN = 30000, PVP_COOLDOWN = 10000; public BlowAKissTaunt(GadgetManager manager) { 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 new file mode 100644 index 000000000..16b77dd78 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/ChickenTaunt.java @@ -0,0 +1,119 @@ +package mineplex.core.gadget.gadgets.taunts; + +import java.time.Month; +import java.time.YearMonth; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilItem; +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.gadget.GadgetManager; +import mineplex.core.gadget.types.TauntGadget; +import mineplex.core.gadget.util.CostConstants; +import mineplex.core.game.GameDisplay; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; + +public class ChickenTaunt extends TauntGadget +{ + + private static final int COOLDOWN = 3000, PVP_COOLDOWN = 10000; + + private final Map _disguises = new HashMap<>(); + + 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); + + setDisplayItem(new ItemBuilder(Material.SKULL_ITEM, (byte) 3) + .setPlayerHead("MHF_Chicken") + .build()); + setPPCYearMonth(YearMonth.of(2018, Month.JUNE)); + setCanPlayWithPvp(false); + setPvpCooldown(PVP_COOLDOWN); + setShouldPlay(true); + setEventType(UpdateType.FASTER); + addDisabledGames(GameDisplay.Smash, GameDisplay.SmashTeams, GameDisplay.SmashDomination, GameDisplay.SmashTraining); + } + + @Override + public boolean onStart(Player player) + { + if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics")) + { + return false; + } + + Location location = player.getLocation().add(0, 1, 0); + + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, location, 1, 0.9F, 1, 0.2F, 30, ViewDist.NORMAL); + player.getWorld().playSound(location, Sound.CHICKEN_IDLE, 3, (float) (0.1 + Math.random())); + Bukkit.broadcastMessage(F.main("Taunt", F.name(player.getName()) + " thinks that everyone is too much of a " + F.elem("Chicken") + " to fight them!")); + + 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); + } + + return true; + } + + @Override + public void onPlay(Player player) + { + Location location = player.getLocation().add((Math.random() - 0.5) * 2, Math.random(), (Math.random() - 0.5) * 2); + int ticks = getPlayerTicks(player); + + if (ticks % 8 == 0) + { + player.getWorld().playSound(location, Sound.CHICKEN_IDLE, 1, (float) (0.1 + Math.random())); + } + + player.getWorld().playSound(location, Sound.CHICKEN_EGG_POP, 1, (float) (0.1 + Math.random())); + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, location, 0.3F, 0.3F, 0.3F, 0.05F, 5, ViewDist.NORMAL); + UtilItem.dropItem(new ItemStack(Material.EGG), location, true, false, 50, false); + + if (ticks >= 24) + { + finish(player); + } + } + + @Override + public void onFinish(Player player) + { + DisguiseBase disguise = _disguises.remove(player.getUniqueId()); + + if (disguise != null) + { + Manager.getDisguiseManager().undisguise(disguise); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EmojiTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EmojiTaunt.java index ffe859865..5010bf2cb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EmojiTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EmojiTaunt.java @@ -20,7 +20,6 @@ import mineplex.core.gadget.types.TauntGadget; import mineplex.core.gadget.util.CostConstants; import mineplex.core.particleeffects.TextEffect; import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; public class EmojiTaunt extends TauntGadget { @@ -52,8 +51,6 @@ public class EmojiTaunt extends TauntGadget }, CostConstants.NO_LORE, Material.CAKE, (byte) 0); setCanPlayWithPvp(true); - setShouldPlay(true); - setEventType(UpdateType.FASTER); } @Override @@ -73,16 +70,14 @@ public class EmojiTaunt extends TauntGadget new TextEffect(TICKS, emoji, location, false, false, ParticleType.FLAME) .start(); + Manager.runSyncLater(() -> finish(player), TICKS); return true; } @Override public void onPlay(Player player) { - if (getPlayerTicks(player) >= TICKS) - { - finish(player); - } + } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java index e41f5ff49..cbc049e01 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java @@ -1,8 +1,6 @@ package mineplex.core.gadget.gadgets.taunts; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; @@ -11,11 +9,11 @@ import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; import mineplex.core.common.util.C; @@ -23,23 +21,21 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseSkeleton; -import mineplex.core.events.EnableArcadeSpawnEvent; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.TauntGadget; import mineplex.core.game.GameDisplay; -import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; public class EternalTaunt extends TauntGadget { - private static final int COOLDOWN = 30000; - private static final int PVP_COOLDOWN = 10000; - private final Map> _clocks = new HashMap<>(); + private static final int COOLDOWN = 30000, PVP_COOLDOWN = 10000; + private final Map _disguises = new HashMap<>(); public EternalTaunt(GadgetManager manager) @@ -67,8 +63,6 @@ public class EternalTaunt extends TauntGadget UtilFirework.playFirework(player.getLocation(), FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(Color.fromRGB(255, 175, 175)).withFade(Color.RED).build()); - _clocks.put(player.getUniqueId(), new ArrayList<>()); - Bukkit.broadcastMessage(F.main("Taunt", F.name(player.getName()) + " waited so long they turned to bones.")); if (!Manager.getDisguiseManager().isDisguised(player)) @@ -87,40 +81,15 @@ public class EternalTaunt extends TauntGadget @Override public void onPlay(Player player) { - if (!_clocks.containsKey(player.getUniqueId())) - { - return; - } + int ticks = getPlayerTicks(player); + Item clock = UtilItem.dropItem(new ItemStack(Material.WATCH), player.getLocation().add(0.5, 1.5, 0.5), false, false, 60, false); - int i = getPlayerTicks(player); + Vector vel = new Vector(Math.sin(ticks * 9/5d), 0, Math.cos(ticks * 9/5d)); + UtilAction.velocity(clock, vel, Math.abs(Math.sin(ticks * 12/3000d)), false, 0, 0.2 + Math.abs(Math.cos(ticks * 12/3000d))*0.6, 1, false); - EnableArcadeSpawnEvent enableArcadeSpawnEvent = new EnableArcadeSpawnEvent(true); - Bukkit.getPluginManager().callEvent(enableArcadeSpawnEvent); + player.playSound(player.getLocation(), Sound.CLICK, 1f, ticks % 2 == 0 ? 1 : 0.5F); - Item clock = player.getWorld().dropItem(player.getLocation().add(0.5, 1.5, 0.5), - ItemStackFactory.Instance.CreateStack(Material.WATCH, (byte) 0, 1, " " + i)); - clock.setPickupDelay(Integer.MAX_VALUE); - - enableArcadeSpawnEvent = new EnableArcadeSpawnEvent(false); - Bukkit.getPluginManager().callEvent(enableArcadeSpawnEvent); - - Vector vel = new Vector(Math.sin(i * 9/5d), 0, Math.cos(i * 9/5d)); - UtilAction.velocity(clock, vel, Math.abs(Math.sin(i * 12/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i * 12/3000d))*0.6, 1, false); - - _clocks.get(player.getUniqueId()).add(clock); - - if (_clocks.get(player.getUniqueId()).size() >= 5) - { - _clocks.get(player.getUniqueId()).get(0).remove(); - _clocks.get(player.getUniqueId()).remove(0); - } - - if (i % 2 == 0) - player.playSound(player.getLocation(), Sound.CLICK, 1f, 1f); - else - player.playSound(player.getLocation(), Sound.CLICK, 0.5f, 0.5f); - - if (i >= 15) + if (ticks >= 15) { finish(player); } @@ -135,12 +104,6 @@ public class EternalTaunt extends TauntGadget { Manager.getDisguiseManager().undisguise(disguise); } - - if (_clocks.containsKey(player.getUniqueId())) - { - _clocks.get(player.getUniqueId()).forEach(Entity::remove); - _clocks.remove(player.getUniqueId()); - } } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/InfernalTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/InfernalTaunt.java index f380a1d57..13615c271 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/InfernalTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/InfernalTaunt.java @@ -20,13 +20,11 @@ import mineplex.core.gadget.util.CostConstants; import mineplex.core.game.GameDisplay; import mineplex.core.particleeffects.TextEffect; import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; public class InfernalTaunt extends TauntGadget { - private static final int COOLDOWN = 60000; - private static final int PVP_COOLDOWN = 10000; + private static final int COOLDOWN = 60000, PVP_COOLDOWN = 10000, TICKS = 40; private final Map _disguises = new HashMap<>(); @@ -43,8 +41,6 @@ public class InfernalTaunt extends TauntGadget setCanPlayWithPvp(false); setPvpCooldown(PVP_COOLDOWN); - setShouldPlay(true); - setEventType(UpdateType.FASTER); addDisabledGames(GameDisplay.Smash, GameDisplay.SmashTeams, GameDisplay.SmashDomination, GameDisplay.SmashTraining); } @@ -70,18 +66,16 @@ public class InfernalTaunt extends TauntGadget _disguises.put(player.getUniqueId(), disguiseSkeleton); } - new TextEffect(40, player.getName(), player.getLocation().add(0, 5, 0), false, false, ParticleType.FLAME) + new TextEffect(TICKS, player.getName(), player.getLocation().add(0, 5, 0), false, false, ParticleType.FLAME) .start(); + Manager.runSyncLater(() -> finish(player), TICKS); return true; } @Override public void onPlay(Player player) { - if (getPlayerTicks(player) >= 40) - { - finish(player); - } + } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java index 829282b96..e016609f3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java @@ -5,7 +5,6 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.UUID; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -31,9 +30,9 @@ public abstract class TauntGadget extends Gadget /** Sets when the taunt will run, if set above */ private UpdateType _updateType = UpdateType.TICK; /** List of games where this item is disabled */ - private List _disabledGames = new ArrayList<>(); + private final List _disabledGames = new ArrayList<>(); /** The ticks that passed since the player started the effect */ - private Map _ticksPerPlayer = new HashMap<>(); + private final Map _ticksPerPlayer = new HashMap<>(); /** * @param manager The normal GadgetManager @@ -61,7 +60,7 @@ public abstract class TauntGadget extends Gadget { if (onStart(player)) { - _ticksPerPlayer.put(player.getUniqueId(), 0); + _ticksPerPlayer.put(player, 0); } } @@ -69,9 +68,9 @@ public abstract class TauntGadget extends Gadget public void play(Player player) { - onPlay(player); int ticks = getPlayerTicks(player) + 1; - _ticksPerPlayer.put(player.getUniqueId(), ticks); + _ticksPerPlayer.put(player, ticks); + onPlay(player); } public abstract void onPlay(Player player); @@ -79,7 +78,7 @@ public abstract class TauntGadget extends Gadget public void finish(Player player) { onFinish(player); - _ticksPerPlayer.remove(player.getUniqueId()); + _ticksPerPlayer.remove(player); } public abstract void onFinish(Player player); @@ -126,23 +125,23 @@ public abstract class TauntGadget extends Gadget protected int getPlayerTicks(Player player) { - return _ticksPerPlayer.getOrDefault(player.getUniqueId(), -1); + return _ticksPerPlayer.getOrDefault(player, -1); } @EventHandler public void onUpdate(UpdateEvent event) { - if (!_shouldPlay) - return; - - if (event.getType() != _updateType) + if (!_shouldPlay || event.getType() != _updateType) + { return; + } for (Player player : getActive()) { - if (_ticksPerPlayer.containsKey(player.getUniqueId())) + if (_ticksPerPlayer.containsKey(player)) + { play(player); + } } } - } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index 3cee9eaa3..9328d3896 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -1,6 +1,7 @@ package mineplex.core.powerplayclub; import java.time.Month; +import java.time.Year; import java.time.YearMonth; import java.util.List; import java.util.Map; @@ -50,6 +51,7 @@ public class PowerPlayClubRewards .put(YearMonth.of(2018, Month.MARCH), new UnknownSalesPackageItem("Connect 4")) .put(YearMonth.of(2018, Month.APRIL), new UnknownSalesPackageItem("Nanny's Umbrella")) .put(YearMonth.of(2018, Month.MAY), new UnknownSalesPackageItem("Windup")) + .put(YearMonth.of(2018, Month.JUNE), new UnknownSalesPackageItem("Chicken Taunt")) .build(); public interface PowerPlayClubItem