Implement June PPC

This commit is contained in:
Sam 2018-05-28 17:23:50 +01:00 committed by Alexander Meech
parent 266336bc74
commit 1a36305586
9 changed files with 158 additions and 80 deletions

View File

@ -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.king.ParticleKing;
import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo;
import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt; 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.EasyModeTaunt;
import mineplex.core.gadget.gadgets.taunts.EmojiTaunt; import mineplex.core.gadget.gadgets.taunts.EmojiTaunt;
import mineplex.core.gadget.gadgets.taunts.EternalTaunt; import mineplex.core.gadget.gadgets.taunts.EternalTaunt;
@ -846,6 +847,7 @@ public class GadgetManager extends MiniPlugin
addGadget(new FrostBreathTaunt(this)); addGadget(new FrostBreathTaunt(this));
addGadget(new EmojiTaunt(this)); addGadget(new EmojiTaunt(this));
addGadget(new EasyModeTaunt(this)); addGadget(new EasyModeTaunt(this));
addGadget(new ChickenTaunt(this));
// Flags // Flags
addGadget(new FlagGadget(this, FlagType.CANADA)); addGadget(new FlagGadget(this, FlagType.CANADA));

View File

@ -38,6 +38,11 @@ public class TestTauntCommand extends CommandBase<GadgetManager>
return; return;
} }
if (!gadget.isActive(caller))
{
gadget.enable(caller);
}
gadget.start(caller); gadget.start(caller);
} }
} }

View File

@ -19,8 +19,7 @@ import mineplex.core.recharge.Recharge;
public class BlowAKissTaunt extends TauntGadget public class BlowAKissTaunt extends TauntGadget
{ {
private static final int COOLDOWN = 30000; private static final int COOLDOWN = 30000, PVP_COOLDOWN = 10000;
private static final int PVP_COOLDOWN = 10000;
public BlowAKissTaunt(GadgetManager manager) public BlowAKissTaunt(GadgetManager manager)
{ {

View File

@ -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<UUID, DisguiseBase> _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);
}
}
}

View File

@ -20,7 +20,6 @@ import mineplex.core.gadget.types.TauntGadget;
import mineplex.core.gadget.util.CostConstants; import mineplex.core.gadget.util.CostConstants;
import mineplex.core.particleeffects.TextEffect; import mineplex.core.particleeffects.TextEffect;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
public class EmojiTaunt extends TauntGadget public class EmojiTaunt extends TauntGadget
{ {
@ -52,8 +51,6 @@ public class EmojiTaunt extends TauntGadget
}, CostConstants.NO_LORE, Material.CAKE, (byte) 0); }, CostConstants.NO_LORE, Material.CAKE, (byte) 0);
setCanPlayWithPvp(true); setCanPlayWithPvp(true);
setShouldPlay(true);
setEventType(UpdateType.FASTER);
} }
@Override @Override
@ -73,16 +70,14 @@ public class EmojiTaunt extends TauntGadget
new TextEffect(TICKS, emoji, location, false, false, ParticleType.FLAME) new TextEffect(TICKS, emoji, location, false, false, ParticleType.FLAME)
.start(); .start();
Manager.runSyncLater(() -> finish(player), TICKS);
return true; return true;
} }
@Override @Override
public void onPlay(Player player) public void onPlay(Player player)
{ {
if (getPlayerTicks(player) >= TICKS)
{
finish(player);
}
} }
@Override @Override

View File

@ -1,8 +1,6 @@
package mineplex.core.gadget.gadgets.taunts; package mineplex.core.gadget.gadgets.taunts;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
@ -11,11 +9,11 @@ import org.bukkit.Color;
import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import mineplex.core.common.util.C; 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.LineFormat;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilText;
import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseSkeleton; import mineplex.core.disguise.disguises.DisguiseSkeleton;
import mineplex.core.events.EnableArcadeSpawnEvent;
import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.TauntGadget; import mineplex.core.gadget.types.TauntGadget;
import mineplex.core.game.GameDisplay; import mineplex.core.game.GameDisplay;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
public class EternalTaunt extends TauntGadget public class EternalTaunt extends TauntGadget
{ {
private static final int COOLDOWN = 30000;
private static final int PVP_COOLDOWN = 10000;
private final Map<UUID, List<Item>> _clocks = new HashMap<>(); private static final int COOLDOWN = 30000, PVP_COOLDOWN = 10000;
private final Map<UUID, DisguiseBase> _disguises = new HashMap<>(); private final Map<UUID, DisguiseBase> _disguises = new HashMap<>();
public EternalTaunt(GadgetManager manager) 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()); 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.")); Bukkit.broadcastMessage(F.main("Taunt", F.name(player.getName()) + " waited so long they turned to bones."));
if (!Manager.getDisguiseManager().isDisguised(player)) if (!Manager.getDisguiseManager().isDisguised(player))
@ -87,40 +81,15 @@ public class EternalTaunt extends TauntGadget
@Override @Override
public void onPlay(Player player) public void onPlay(Player player)
{ {
if (!_clocks.containsKey(player.getUniqueId())) 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);
return;
}
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); player.playSound(player.getLocation(), Sound.CLICK, 1f, ticks % 2 == 0 ? 1 : 0.5F);
Bukkit.getPluginManager().callEvent(enableArcadeSpawnEvent);
Item clock = player.getWorld().dropItem(player.getLocation().add(0.5, 1.5, 0.5), if (ticks >= 15)
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)
{ {
finish(player); finish(player);
} }
@ -135,12 +104,6 @@ public class EternalTaunt extends TauntGadget
{ {
Manager.getDisguiseManager().undisguise(disguise); Manager.getDisguiseManager().undisguise(disguise);
} }
if (_clocks.containsKey(player.getUniqueId()))
{
_clocks.get(player.getUniqueId()).forEach(Entity::remove);
_clocks.remove(player.getUniqueId());
}
} }
@EventHandler @EventHandler

View File

@ -20,13 +20,11 @@ import mineplex.core.gadget.util.CostConstants;
import mineplex.core.game.GameDisplay; import mineplex.core.game.GameDisplay;
import mineplex.core.particleeffects.TextEffect; import mineplex.core.particleeffects.TextEffect;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
public class InfernalTaunt extends TauntGadget public class InfernalTaunt extends TauntGadget
{ {
private static final int COOLDOWN = 60000; private static final int COOLDOWN = 60000, PVP_COOLDOWN = 10000, TICKS = 40;
private static final int PVP_COOLDOWN = 10000;
private final Map<UUID, DisguiseBase> _disguises = new HashMap<>(); private final Map<UUID, DisguiseBase> _disguises = new HashMap<>();
@ -43,8 +41,6 @@ public class InfernalTaunt extends TauntGadget
setCanPlayWithPvp(false); setCanPlayWithPvp(false);
setPvpCooldown(PVP_COOLDOWN); setPvpCooldown(PVP_COOLDOWN);
setShouldPlay(true);
setEventType(UpdateType.FASTER);
addDisabledGames(GameDisplay.Smash, GameDisplay.SmashTeams, GameDisplay.SmashDomination, GameDisplay.SmashTraining); addDisabledGames(GameDisplay.Smash, GameDisplay.SmashTeams, GameDisplay.SmashDomination, GameDisplay.SmashTraining);
} }
@ -70,18 +66,16 @@ public class InfernalTaunt extends TauntGadget
_disguises.put(player.getUniqueId(), disguiseSkeleton); _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(); .start();
Manager.runSyncLater(() -> finish(player), TICKS);
return true; return true;
} }
@Override @Override
public void onPlay(Player player) public void onPlay(Player player)
{ {
if (getPlayerTicks(player) >= 40)
{
finish(player);
}
} }
@Override @Override

View File

@ -5,7 +5,6 @@ import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -31,9 +30,9 @@ public abstract class TauntGadget extends Gadget
/** Sets when the taunt will run, if set above */ /** Sets when the taunt will run, if set above */
private UpdateType _updateType = UpdateType.TICK; private UpdateType _updateType = UpdateType.TICK;
/** List of games where this item is disabled */ /** List of games where this item is disabled */
private List<GameDisplay> _disabledGames = new ArrayList<>(); private final List<GameDisplay> _disabledGames = new ArrayList<>();
/** The ticks that passed since the player started the effect */ /** The ticks that passed since the player started the effect */
private Map<UUID, Integer> _ticksPerPlayer = new HashMap<>(); private final Map<Player, Integer> _ticksPerPlayer = new HashMap<>();
/** /**
* @param manager The normal GadgetManager * @param manager The normal GadgetManager
@ -61,7 +60,7 @@ public abstract class TauntGadget extends Gadget
{ {
if (onStart(player)) 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) public void play(Player player)
{ {
onPlay(player);
int ticks = getPlayerTicks(player) + 1; int ticks = getPlayerTicks(player) + 1;
_ticksPerPlayer.put(player.getUniqueId(), ticks); _ticksPerPlayer.put(player, ticks);
onPlay(player);
} }
public abstract void onPlay(Player player); public abstract void onPlay(Player player);
@ -79,7 +78,7 @@ public abstract class TauntGadget extends Gadget
public void finish(Player player) public void finish(Player player)
{ {
onFinish(player); onFinish(player);
_ticksPerPlayer.remove(player.getUniqueId()); _ticksPerPlayer.remove(player);
} }
public abstract void onFinish(Player player); public abstract void onFinish(Player player);
@ -126,23 +125,23 @@ public abstract class TauntGadget extends Gadget
protected int getPlayerTicks(Player player) protected int getPlayerTicks(Player player)
{ {
return _ticksPerPlayer.getOrDefault(player.getUniqueId(), -1); return _ticksPerPlayer.getOrDefault(player, -1);
} }
@EventHandler @EventHandler
public void onUpdate(UpdateEvent event) public void onUpdate(UpdateEvent event)
{ {
if (!_shouldPlay) if (!_shouldPlay || event.getType() != _updateType)
return; {
if (event.getType() != _updateType)
return; return;
}
for (Player player : getActive()) for (Player player : getActive())
{ {
if (_ticksPerPlayer.containsKey(player.getUniqueId())) if (_ticksPerPlayer.containsKey(player))
{
play(player); play(player);
}
} }
} }
} }

View File

@ -1,6 +1,7 @@
package mineplex.core.powerplayclub; package mineplex.core.powerplayclub;
import java.time.Month; import java.time.Month;
import java.time.Year;
import java.time.YearMonth; import java.time.YearMonth;
import java.util.List; import java.util.List;
import java.util.Map; 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.MARCH), new UnknownSalesPackageItem("Connect 4"))
.put(YearMonth.of(2018, Month.APRIL), new UnknownSalesPackageItem("Nanny's Umbrella")) .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.MAY), new UnknownSalesPackageItem("Windup"))
.put(YearMonth.of(2018, Month.JUNE), new UnknownSalesPackageItem("Chicken Taunt"))
.build(); .build();
public interface PowerPlayClubItem public interface PowerPlayClubItem