From ed35d2a992ab62e53a335c8ccce9b14935289bcd Mon Sep 17 00:00:00 2001 From: Cheese Date: Wed, 1 Apr 2015 16:56:13 +1100 Subject: [PATCH] April Fools update --- .../core/aprilfools/AprilFoolsManager.java | 196 ++++++++++++++++++ .../Mineplex.Hub/src/mineplex/hub/Hub.java | 9 +- .../src/mineplex/hub/HubManager.java | 22 +- .../hub/modules/ForcefieldManager.java | 2 +- .../src/nautilus/game/arcade/Arcade.java | 3 + .../nautilus/game/arcade/ArcadeManager.java | 17 +- .../games/champions/ChampionsDominate.java | 3 +- .../game/games/champions/ChampionsTDM.java | 3 +- .../game/arcade/managers/GameChatManager.java | 14 +- ...loweenManager.java => HolidayManager.java} | 24 +-- 10 files changed, 259 insertions(+), 34 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/{HalloweenManager.java => HolidayManager.java} (89%) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java new file mode 100644 index 000000000..fcbdecbbc --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java @@ -0,0 +1,196 @@ +package mineplex.core.aprilfools; + +import java.util.Calendar; +import java.util.HashSet; +import java.util.Iterator; + +import org.bukkit.Effect; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockDamageEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguiseCow; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class AprilFoolsManager extends MiniPlugin +{ + public static AprilFoolsManager Instance; + + private boolean _enabled; + private DisguiseManager _disguiseManager; + private CoreClientManager _clientManager; + + private HashSet _disguised = new HashSet(); + + protected AprilFoolsManager(JavaPlugin plugin, CoreClientManager clientManager, DisguiseManager disguiseManager) + { + super("April Fools", plugin); + + _disguiseManager = disguiseManager; + _clientManager = clientManager; + + Calendar c = Calendar.getInstance(); + _enabled = (c.get(Calendar.MONTH) == Calendar.APRIL && c.get(Calendar.DAY_OF_MONTH) == 1); + } + + public static void Initialize(JavaPlugin plugin, CoreClientManager clientManager, DisguiseManager disguiseManager) + { + Instance = new AprilFoolsManager(plugin, clientManager, disguiseManager); + } + + @EventHandler(priority = EventPriority.LOW) + public void chatAdd(AsyncPlayerChatEvent event) + { + if (!_enabled) + return; + + String[] words = event.getMessage().split(" "); + + String out = ""; + for (String word : words) + { + //Prefix + if (Math.random() > 0.9) + { + out += "moo"; + + for (int i=0 ; i 0.9) + { + out += word + " "; + + out += "moo"; + + for (int i=0 ; i 0.99) + { + out += "moo"; + + for (int i=3 ; i disguiseIter = _disguised.iterator(); + while (disguiseIter.hasNext()) + { + Player player = disguiseIter.next(); + + if (!player.isValid() || !player.isOnline() || + _disguiseManager.getDisguise(player) == null || + !(_disguiseManager.getDisguise(player) instanceof DisguiseCow)) + { + disguiseIter.remove(); + continue; + } + + if (Math.random() > 0.8) + { + player.getWorld().playSound(player.getLocation(), Sound.COW_IDLE, (float)Math.random() + 0.5f, (float)Math.random() + 0.5f); + } + } + } + + public boolean isActive() + { + return _enabled; + } + + public String getName(Player player) + { + //Name + int index = 0; + boolean hitVowel = false; + for (int i=0 ; i 16) + name = name.substring(0, 16); + + return name; + } + + public void setEnabled(boolean b) + { + _enabled = b; + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 97672e417..1ff7875a9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -8,6 +8,7 @@ import mineplex.core.TablistFix; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; +import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; @@ -113,13 +114,13 @@ public class Hub extends JavaPlugin implements IRelation StatsManager statsManager = new StatsManager(this, clientManager); AchievementManager achievementManager = new AchievementManager(statsManager, clientManager, donationManager); - + PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager); HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this)); QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager); - + new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager); new Chat(this, clientManager, preferenceManager, serverStatusManager.getCurrentServerName()); new MemoryFix(this); @@ -129,6 +130,8 @@ public class Hub extends JavaPlugin implements IRelation //new Replay(this, packetHandler); new PersonalServerManager(this, clientManager); + AprilFoolsManager.Initialize(this, clientManager, disguiseManager); + CombatManager combatManager = new CombatManager(this); ProjectileManager throwManager = new ProjectileManager(this); @@ -136,7 +139,7 @@ public class Hub extends JavaPlugin implements IRelation DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager); Fire fire = new Fire(this, conditionManager, damage); - Teleport teleport = new Teleport(this); + Teleport teleport = new Teleport(this); Energy energy = new Energy(this); energy.setEnabled(false); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 9c56daeab..ebff189d5 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -46,6 +46,7 @@ import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; +import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.Rank; import mineplex.core.common.util.C; @@ -514,11 +515,8 @@ public class HubManager extends MiniClientPlugin String playerName = player.getName(); // April Fools - Calendar c = Calendar.getInstance(); - if (c.get(Calendar.MONTH) == Calendar.APRIL && c.get(Calendar.DAY_OF_MONTH) == 1) - { - playerName = "Notch"; - } + if (AprilFoolsManager.Instance.isActive()) + playerName = AprilFoolsManager.Instance.getName(player); //Public Message if (_clientManager.Get(player).GetRank() != Rank.LEGEND) @@ -529,8 +527,7 @@ public class HubManager extends MiniClientPlugin UtilFirework.playFirework(player.getEyeLocation(), org.bukkit.FireworkEffect.Type.BALL_LARGE, Color.LIME, true, true); player.getWorld().playSound(player.getEyeLocation(), Sound.WITHER_SPAWN, 2f, 1f); } - - + //Teleport player.teleport(GetSpawn().add(0, 10, 0)); @@ -631,6 +628,11 @@ public class HubManager extends MiniClientPlugin } Player player = event.getPlayer(); + String playerName = player.getName(); + + // April Fools + if (AprilFoolsManager.Instance.isActive()) + playerName = AprilFoolsManager.Instance.getName(player); Rank rank = GetClients().Get(player).GetRank(); @@ -656,7 +658,7 @@ public class HubManager extends MiniClientPlugin event.getRecipients().clear(); event.setMessage(event.getMessage().substring(1, event.getMessage().length())); - event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + "%1$s " + C.cPurple + "%2$s"); + event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + playerName + " " + C.cPurple + "%2$s"); for (String name : party.GetPlayers()) { @@ -673,7 +675,7 @@ public class HubManager extends MiniClientPlugin } return; - } + } else { for (Player other : UtilServer.getPlayers()) @@ -685,7 +687,7 @@ public class HubManager extends MiniClientPlugin } event.setMessage(event.getMessage()); - event.setFormat(levelStr + rankStr + C.cYellow + "%1$s " + C.cWhite + "%2$s"); + event.setFormat(levelStr + rankStr + C.cYellow + playerName + " " + C.cWhite + "%2$s"); } } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java index 0683060e9..425ce1a0f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java @@ -42,7 +42,7 @@ public class ForcefieldManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { - if (Manager.getPreferences().Get(player).HubForcefield) + if (Manager.getPreferences().Get(player).HubForcefield && Manager.GetClients().Get(player).GetRank().Has(Rank.ADMIN)) { for (Player other : UtilServer.getPlayers()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index ae9ca9b08..b4e166f6b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -10,6 +10,7 @@ import mineplex.core.CustomTagFix; import mineplex.core.TablistFix; import mineplex.core.account.CoreClientManager; import mineplex.core.antihack.AntiHack; +import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; import mineplex.core.command.CommandCenter; @@ -135,6 +136,8 @@ public class Arcade extends JavaPlugin new CustomTagFix(this, packetHandler); new TablistFix(this); + AprilFoolsManager.Initialize(this, _clientManager, disguiseManager); + //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 761a2b7c9..043772964 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -33,6 +33,7 @@ import org.bukkit.util.Vector; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; +import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; import mineplex.core.chat.Chat; @@ -602,8 +603,14 @@ public class ArcadeManager extends MiniPlugin implements IRelation @EventHandler public void MessageJoin(PlayerJoinEvent event) { + String name = event.getPlayer().getName(); + + // April Fools + if (AprilFoolsManager.Instance.isActive()) + name = AprilFoolsManager.Instance.getName(event.getPlayer()); + if (_game != null && _game.AnnounceJoinQuit) - event.setJoinMessage(F.sys("Join", GetColor(event.getPlayer()) + event.getPlayer().getName())); + event.setJoinMessage(F.sys("Join", GetColor(event.getPlayer()) + name)); else event.setJoinMessage(null); @@ -612,8 +619,14 @@ public class ArcadeManager extends MiniPlugin implements IRelation @EventHandler public void MessageQuit(PlayerQuitEvent event) { + String name = event.getPlayer().getName(); + + // April Fools + if (AprilFoolsManager.Instance.isActive()) + name = AprilFoolsManager.Instance.getName(event.getPlayer()); + if (_game == null || _game.AnnounceJoinQuit) - event.setQuitMessage(F.sys("Quit", GetColor(event.getPlayer()) + event.getPlayer().getName())); + event.setQuitMessage(F.sys("Quit", GetColor(event.getPlayer()) + name)); else event.setQuitMessage(null); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java index 59f2f34d4..3aa158ad0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.champions; +import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.core.combat.DeathMessageType; @@ -65,7 +66,7 @@ public class ChampionsDominate extends Domination EloStart = 1000; this.DisableKillCommand = false; - + registerStatTrackers( new KillReasonStatTracker(this, "Backstab", "Assassination", false), new ElectrocutionStatTracker(this), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java index 9af73ce5c..e7999d18f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java @@ -6,6 +6,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.inventory.InventoryType; +import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.core.combat.DeathMessageType; @@ -63,7 +64,7 @@ public class ChampionsTDM extends TeamDeathmatch InventoryOpenChest = true; this.DisableKillCommand = false; - + registerStatTrackers( new WinWithoutLosingTeammateStatTracker(this, "FlawlessVictory"), new KillAllOpposingStatTracker(this), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java index b05e9c7e6..0bebbb2c1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.managers; import java.util.Iterator; +import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -46,6 +47,11 @@ public class GameChatManager implements Listener return; Player sender = event.getPlayer(); + String senderName = sender.getName(); + + // April Fools + if (AprilFoolsManager.Instance.isActive()) + senderName = AprilFoolsManager.Instance.getName(sender); //Dead Prefix String dead = ""; @@ -100,7 +106,7 @@ public class GameChatManager implements Listener event.getRecipients().clear(); event.setMessage(event.getMessage().substring(1, event.getMessage().length())); - event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + "%1$s " + C.cPurple + "%2$s"); + event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + senderName + " " + C.cPurple + "%2$s"); event.getRecipients().addAll(party.GetPlayersOnline()); @@ -109,7 +115,7 @@ public class GameChatManager implements Listener } //Base Format - event.setFormat(dead + levelStr + rankStr + Manager.GetColor(sender) + "%1$s " + ChatColor.WHITE + "%2$s"); + event.setFormat(dead + levelStr + rankStr + Manager.GetColor(sender) + senderName + " " + ChatColor.WHITE + "%2$s"); //Public/Private (Not If Player Dead) if (Manager.GetGame() != null && Manager.GetGame().GetState() == GameState.Live) @@ -125,13 +131,13 @@ public class GameChatManager implements Listener if (event.getMessage().charAt(0) == '@') { event.setMessage(event.getMessage().substring(1, event.getMessage().length())); - event.setFormat(C.cWhite + C.Bold + "Team" + " " + dead + levelStr + rankStr + team.GetColor() + "%1$s " + C.cWhite + "%2$s"); + event.setFormat(C.cWhite + C.Bold + "Team" + " " + dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s"); } //All Chat else { globalMessage = true; - event.setFormat(dead + levelStr + rankStr + team.GetColor() + "%1$s " + C.cWhite + "%2$s"); + event.setFormat(dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s"); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HalloweenManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java similarity index 89% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HalloweenManager.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java index fd45a05a8..0def76fa3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HalloweenManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java @@ -30,7 +30,7 @@ import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -public class HalloweenManager implements Listener +public class HolidayManager implements Listener { ArcadeManager Manager; @@ -40,7 +40,7 @@ public class HalloweenManager implements Listener public long _lastSpawn = System.currentTimeMillis(); - public HalloweenManager(ArcadeManager manager) + public HolidayManager(ArcadeManager manager) { Manager = manager; @@ -61,29 +61,29 @@ public class HalloweenManager implements Listener if (event.getType() == UpdateType.TICK) return; - Iterator pumpkinIterator = _active.iterator(); + Iterator blockIterator = _active.iterator(); - while (pumpkinIterator.hasNext()) + while (blockIterator.hasNext()) { - Block pumpkin = pumpkinIterator.next(); + Block block = blockIterator.next(); - if (pumpkin.getType() != Material.PUMPKIN && pumpkin.getType() != Material.JACK_O_LANTERN) + if (block.getType() != Material.PUMPKIN && block.getType() != Material.JACK_O_LANTERN) { - pumpkinBreak(pumpkin); - pumpkinIterator.remove(); + pumpkinBreak(block); + blockIterator.remove(); continue; } - UtilParticle.PlayParticle(ParticleType.FLAME, pumpkin.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0.06f, 4); + UtilParticle.PlayParticle(ParticleType.FLAME, block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0.06f, 4); if (Math.random() > 0.90) { - if (pumpkin.getType() == Material.PUMPKIN) + if (block.getType() == Material.PUMPKIN) { - pumpkin.setType(Material.JACK_O_LANTERN); + block.setType(Material.JACK_O_LANTERN); } else { - pumpkin.setType(Material.PUMPKIN); + block.setType(Material.PUMPKIN); } } }