From f57304764c1bb37d5936c1475577a858e029c7ac Mon Sep 17 00:00:00 2001 From: William Burns Date: Fri, 18 Dec 2015 15:16:00 +0000 Subject: [PATCH 01/48] Added a hotbar layout editor --- .../mineplex/core/common/util/UtilMath.java | 10 ++ .../game/games/gladiators/Gladiators.java | 17 +- .../games/gladiators/hotbar/HotbarEditor.java | 163 ++++++++++++++++++ .../gladiators/hotbar/HotbarInventory.java | 49 ++++++ .../games/gladiators/hotbar/HotbarLayout.java | 60 +++++++ .../gladiators/hotbar/HotbarPageListener.java | 70 ++++++++ 6 files changed, 364 insertions(+), 5 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarInventory.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java index 3d48c098f..4fac287c2 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java @@ -2,6 +2,7 @@ package mineplex.core.common.util; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; +import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Random; @@ -116,4 +117,13 @@ public class UtilMath { return num < min ? min : (num > max ? max : num); } + + public static List digits(int i) { + List digits = new ArrayList(); + while(i > 0) { + digits.add(i % 10); + i /= 10; + } + return digits; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index a9fcae09a..458e7ea83 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -22,7 +22,6 @@ import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -57,6 +56,8 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.gladiators.events.PlayerChangeArenaEvent; import nautilus.game.arcade.game.games.gladiators.events.RoundStartEvent; +import nautilus.game.arcade.game.games.gladiators.hotbar.HotbarEditor; +import nautilus.game.arcade.game.games.gladiators.hotbar.HotbarLayout; import nautilus.game.arcade.game.games.gladiators.kits.KitGladiator; import nautilus.game.arcade.game.games.gladiators.trackers.BrawlerTracker; import nautilus.game.arcade.game.games.gladiators.trackers.FlawlessTracker; @@ -85,6 +86,8 @@ public class Gladiators extends SoloGame private boolean _firstRound; + private HotbarEditor _hotbarEditor; + public Gladiators(ArcadeManager manager) { super(manager, GameType.Gladiators, @@ -124,6 +127,8 @@ public class Gladiators extends SoloGame _roundState = RoundState.WAITING; _firstRound = true; + + _hotbarEditor = new HotbarEditor(manager.getPlugin(), this); } @EventHandler @@ -739,13 +744,15 @@ public class Gladiators extends SoloGame if (!GetPlayers(true).contains(p)) return; + HotbarLayout layout = _hotbarEditor.getLayout(p); + p.getInventory().clear(); p.getInventory().setArmorContents(null); - p.getInventory().setItem(0, UtilItem.makeUnbreakable(type.getLoadout().getSword())); - p.getInventory().setItem(1, UtilItem.makeUnbreakable(type.getLoadout().getRod())); - p.getInventory().setItem(2, type.getLoadout().getBow()); - p.getInventory().setItem(8, type.getLoadout().getArrows()); + p.getInventory().setItem(layout.getSword() - 1, UtilItem.makeUnbreakable(type.getLoadout().getSword())); + p.getInventory().setItem(layout.getRod() - 1, UtilItem.makeUnbreakable(type.getLoadout().getRod())); + p.getInventory().setItem(layout.getBow() - 1, type.getLoadout().getBow()); + p.getInventory().setItem(layout.getArrows() - 1, type.getLoadout().getArrows()); p.getInventory().setHelmet(type.getLoadout().getHelmet()); p.getInventory().setChestplate(type.getLoadout().getChestplate()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java new file mode 100644 index 000000000..119e4d436 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java @@ -0,0 +1,163 @@ +package nautilus.game.arcade.game.games.gladiators.hotbar; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.common.collect.Lists; +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.gladiators.Gladiators; + +/** + * Created by William (WilliamTiger). + * 18/12/15 + */ +public class HotbarEditor extends MiniPlugin +{ + private Gladiators _host; + private ItemStack _item; + + public HotbarEditor(JavaPlugin plugin, Gladiators gladiators) + { + super("Hotbar Editor", plugin); + + _host = gladiators; + _item = new ItemBuilder(Material.NAME_TAG).setTitle(C.cGold + "Hotbar Editor") + .addLore(C.cGray + "Right click to edit your Gladiators hotbar").build(); + + getPluginManager().registerEvents(new HotbarPageListener(this), getPlugin()); + } + + @EventHandler + public void onJoin(PlayerJoinEvent event) + { + if (_host.GetState() == Game.GameState.Recruit || _host.GetState() == Game.GameState.Live) + { + event.getPlayer().getInventory().setItem(0, _item); + } + } + + @EventHandler + public void onDeath(final PlayerDeathEvent event) + { + Bukkit.getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable() + { + public void run() + { + if (_host.IsLive()) + { + event.getEntity().getInventory().setItem(0, _item); + } + } + }); + } + + @EventHandler(priority = EventPriority.HIGH) + public void Observer(PlayerCommandPreprocessEvent event) + { + if (event.getMessage().equalsIgnoreCase("/spec")) + { + if (!_host.IsAlive(event.getPlayer()) + && !UtilInv.contains(event.getPlayer(), _item.getType(), (byte) 0, 1)) + { + event.getPlayer().getInventory().setItem(0, _item); + } + } + } + + @EventHandler + public void onJoin(GameStateChangeEvent event) + { + if (event.GetState() == Game.GameState.Recruit) + { + for (Player player : Bukkit.getOnlinePlayers()) + { + player.getInventory().setItem(0, _item); + } + } + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (event.getAction() != Action.PHYSICAL && event.getAction().name().contains("RIGHT")) + { + ItemStack item = event.getItem(); + + if (item != null && item.isSimilar(_item)) + { + + HotbarInventory.open(event.getPlayer(), this); + } + } + } + + public Gladiators getHost() + { + return _host; + } + + public HotbarLayout getLayout(Player player) + { + int data = _host.Manager.getArcadePlayer(player).get("hotbar"); + data = (data == -1 ? 1239 : data); + + List ints = new ArrayList<>(); + for (int i : UtilMath.digits(data)) + ints.add(i - 1); + ints = Lists.reverse(ints); + + return new HotbarLayout(ints.get(0), ints.get(1), ints.get(2), ints.get(3)); + } + + public void saveLayout(Player player, Inventory inv) + { + List items = Arrays.asList(inv.getContents()); + ItemStack sword = null, rod = null, bow = null, arrows = null; + for (ItemStack i : items) + { + if (i == null || i.getType() == null) + continue; + + if (i.getType().equals(Material.DIAMOND_SWORD)) + sword = i; + else if (i.getType().equals(Material.FISHING_ROD)) + rod = i; + else if (i.getType().equals(Material.BOW)) + bow = i; + else if (i.getType().equals(Material.ARROW)) + arrows = i; + } + + HotbarLayout save = new HotbarLayout( + items.indexOf(sword) - 9, + items.indexOf(rod) - 9, + items.indexOf(bow) - 9, + items.indexOf(arrows) - 9 + ); + + _host.Manager.getArcadePlayer(player).put("hotbar", save.toDataSaveNumber()); + player.sendMessage(F.main("Game", "Saved new hotbar layout!")); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarInventory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarInventory.java new file mode 100644 index 000000000..9ffc569ae --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarInventory.java @@ -0,0 +1,49 @@ +package nautilus.game.arcade.game.games.gladiators.hotbar; + +import java.util.Arrays; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemBuilder; + +/** + * Created by William (WilliamTiger). + * 18/12/15 + */ +public class HotbarInventory +{ + public static void open(Player player, HotbarEditor editor) + { + Inventory inv = UtilServer.getServer().createInventory(null, 36, "Hotbar Editor"); + + for (int slot : Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 18, 19, 20, 21, 22, 23, 24, 25, 26)) + { + inv.setItem(slot, getGlass(slot)); + } + + HotbarLayout layout = editor.getLayout(player); + + inv.setItem(layout.getSword() + 9, new ItemStack(Material.DIAMOND_SWORD, 1)); + inv.setItem(layout.getRod() + 9, new ItemStack(Material.FISHING_ROD, 1)); + inv.setItem(layout.getBow() + 9, new ItemStack(Material.BOW, 1)); + inv.setItem(layout.getArrows() + 9, new ItemStack(Material.ARROW, 1)); + + inv.setItem(30, new ItemBuilder(Material.EMERALD_BLOCK).setTitle(C.cGreen + C.Bold + "Save").setLore(C.cGray + "Click to save layout.").build()); + inv.setItem(32, new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(C.cRed + C.Bold + "Cancel").setLore(C.cGray + "Click to cancel layout.").build()); + + player.openInventory(inv); + } + + private static ItemStack getGlass(int slot) + { + return new ItemBuilder(Material.STAINED_GLASS_PANE) + .setData((short) 15) + .setTitle((slot < 10 ? C.cAquaB + "⬇ Arrange Your Hotbar ⬇" : C.cAquaB + "⬆ Arrange Your Hotbar ⬆")) + .build(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java new file mode 100644 index 000000000..459f70411 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java @@ -0,0 +1,60 @@ +package nautilus.game.arcade.game.games.gladiators.hotbar; + +/** + * Created by William (WilliamTiger). + * 18/12/15 + */ +public class HotbarLayout +{ + private int sword; + private int rod; + private int bow; + private int arrows; + + public HotbarLayout(int sword, int rod, int bow, int arrows) + { + this.sword = sword; + this.rod = rod; + this.bow = bow; + this.arrows = arrows; + } + + public int getSword() + { + return sword; + } + + public int getRod() + { + return rod; + } + + public int getBow() + { + return bow; + } + + public int getArrows() + { + return arrows; + } + + public int toDataSaveNumber() + { + String str = ""; + str += (getSword() + 1); + str += (getRod() + 1); + str += (getBow() + 1); + str += (getArrows() + 1); + + System.out.println("sword = " + sword); + System.out.println("rod = " + rod); + System.out.println("bow = " + bow); + System.out.println("arrows = " + arrows); + System.out.println("string = " + str); + System.out.println("integer = " + Integer.parseInt(str)); + + + return Integer.parseInt(str); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java new file mode 100644 index 000000000..d778f7643 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java @@ -0,0 +1,70 @@ +package nautilus.game.arcade.game.games.gladiators.hotbar; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryAction; +import org.bukkit.event.inventory.InventoryClickEvent; + +/** + * Created by William (WilliamTiger). + * 18/12/15 + */ +public class HotbarPageListener implements Listener +{ + private HotbarEditor _editor; + + public HotbarPageListener(HotbarEditor editor) + { + _editor = editor; + } + + @EventHandler + public void onClick(InventoryClickEvent e) + { + if (!e.getInventory().getName().equals("Hotbar Editor")) + return; + + if (e.getCurrentItem() == null) + return; + + if (e.getClick().isShiftClick()) + { + e.setCancelled(true); + return; + } + + if (e.getCurrentItem().getType().equals(Material.REDSTONE_BLOCK)) + { + e.setCancelled(true); + e.getWhoClicked().closeInventory(); + return; + } + + if (e.getCurrentItem().getType().equals(Material.EMERALD_BLOCK)) + { + e.setCancelled(true); + e.getWhoClicked().closeInventory(); + _editor.saveLayout(((Player)e.getWhoClicked()), e.getClickedInventory()); + return; + } + + if (e.getCurrentItem().getType().equals(Material.STAINED_GLASS_PANE)) + { + e.setCancelled(true); + return; + } + + if (e.getAction().equals(InventoryAction.PLACE_ALL) + || e.getAction().equals(InventoryAction.PLACE_ONE) + || e.getAction().equals(InventoryAction.PLACE_SOME)) + { + if (!(e.getSlot() > 8 && e.getSlot() < 18)) + { + e.setCancelled(true); + return; + } + } + } +} From 1726aa253063ba2bd863f5e0630041f5cb1ccfdc Mon Sep 17 00:00:00 2001 From: Morten Date: Mon, 21 Dec 2015 12:58:19 +0100 Subject: [PATCH 02/48] Added a feature to unban clients across the network But there still a bug when you type a username of a none registered member. Will fix ASAP - likely after Mineware --- .../src/mineplex/core/stats/StatsManager.java | 90 ++++++++++++++++++- .../mineplex/core/stats/StatsRepository.java | 27 +++++- .../stats/command/MasterBuilderUnban.java | 58 ++++++++++++ 3 files changed, 168 insertions(+), 7 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index 1aa921c2d..ae88b6cb1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -15,6 +15,7 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilServer; import mineplex.core.stats.command.GiveStatCommand; +import mineplex.core.stats.command.MasterBuilderUnban; import mineplex.core.stats.command.TimeCommand; import mineplex.core.stats.event.StatChangeEvent; @@ -26,6 +27,8 @@ public class StatsManager extends MiniDbClientPlugin private NautHashMap _stats = new NautHashMap(); private NautHashMap> _statUploadQueue = new NautHashMap>(); + private NautHashMap> _statUploadQueueOverRidable = new NautHashMap>(); + private Runnable _saveRunnable; public StatsManager(JavaPlugin plugin, CoreClientManager clientManager) @@ -41,6 +44,7 @@ public class StatsManager extends MiniDbClientPlugin public void run() { saveStats(); + overRidableSaveStats(); } }; @@ -81,6 +85,11 @@ public class StatsManager extends MiniDbClientPlugin } public void incrementStat(final Player player, final String statName, final long value) + { + incrementStat(player, statName, value, false); + } + + public void incrementStat(final Player player, final String statName, final long value, boolean overRide) { if (value <= 0) return; @@ -96,11 +105,80 @@ public class StatsManager extends MiniDbClientPlugin @Override public void run() { - addToQueue(statName, player, value); + if(overRide) + { + addToOverRidableQueue(statName, player, value); + } + else + { + addToQueue(statName, player, value); + } } }); } + private void addToOverRidableQueue(String statName, Player player, long value) + { + synchronized (_statSync) + { + if (!_statUploadQueueOverRidable.containsKey(player)) + _statUploadQueueOverRidable.put(player, new NautHashMap()); + + if (!_statUploadQueueOverRidable.get(player).containsKey(statName)) + _statUploadQueueOverRidable.get(player).put(statName, 0L); + + _statUploadQueueOverRidable.get(player).put(statName, _statUploadQueueOverRidable.get(player).get(statName) + value); + } + } + + protected void overRidableSaveStats() + { + if (_statUploadQueueOverRidable.isEmpty()) + return; + + try + { + NautHashMap> uploadQueue = new NautHashMap>(); + + synchronized (_statSync) + { + for (Iterator statIterator = _statUploadQueueOverRidable.keySet().iterator(); statIterator.hasNext();) + { + Player player = statIterator.next(); + + if (player.isOnline()) + continue; + + try + { + int uploadKey = PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId(); + + uploadQueue.put(uploadKey, new NautHashMap()); + + for (String statName : _statUploadQueueOverRidable.get(player).keySet()) + { + int statId = _stats.get(statName); + uploadQueue.get(uploadKey).put(statId, _statUploadQueueOverRidable.get(player).get(statName)); + System.out.println(player.getName() + " saving stat : " + statName + " overriding " + _statUploadQueueOverRidable.get(player).get(statName)); + } + + statIterator.remove(); + } + catch (Exception e) + { + //System.out.println("[StatsManager] AccountId was not set for " + player.getName()); + } + } + } + + _repository.saveStats(uploadQueue, true); + } + catch (Exception exception) + { + exception.printStackTrace(); + } + } + private void addToQueue(String statName, Player player, long value) { synchronized (_statSync) @@ -162,8 +240,13 @@ public class StatsManager extends MiniDbClientPlugin exception.printStackTrace(); } } - + public boolean incrementStat(final int accountId, final String statName, final long value) + { + return incrementStat(accountId, statName, value, false); + } + + public boolean incrementStat(final int accountId, final String statName, final long value, boolean overRide) { // This will register a new stat if we don't have one, otherwise it will just run the callback registerNewStat(statName, new Runnable() @@ -175,7 +258,7 @@ public class StatsManager extends MiniDbClientPlugin uploadQueue.put(accountId, new NautHashMap()); uploadQueue.get(accountId).put(_stats.get(statName), value); - _repository.saveStats(uploadQueue); + _repository.saveStats(uploadQueue, overRide); } }); @@ -237,6 +320,7 @@ public class StatsManager extends MiniDbClientPlugin { addCommand(new TimeCommand(this)); addCommand(new GiveStatCommand(this)); + addCommand(new MasterBuilderUnban(this)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java index 12deca990..726f75a99 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java @@ -29,6 +29,8 @@ public class StatsRepository extends RepositoryBase { private static String RETRIEVE_STATS = "SELECT id, name FROM stats;"; private static String INSERT_STAT = "INSERT INTO stats (name) VALUES (?);"; + private static String UPDATE_ACCOUNT_STAT_VALUE= "UPDATE accounts SET rank=?, rankPerm=true WHERE uuid = ?;"; + public StatsRepository(JavaPlugin plugin) { @@ -68,9 +70,15 @@ public class StatsRepository extends RepositoryBase { executeUpdate(INSERT_STAT, new ColumnVarChar("name", 100, name)); } + + public void saveStats(NautHashMap> uploadQueue) + { + saveStats(uploadQueue, false); + } + @SuppressWarnings("rawtypes") - public void saveStats(NautHashMap> uploadQueue) + public void saveStats(NautHashMap> uploadQueue, boolean overRideStat) { try { @@ -83,13 +91,24 @@ public class StatsRepository extends RepositoryBase { for (Integer statId : uploadQueue.get(accountId).keySet()) { - Update update = context + if(overRideStat) + { + Update update = context + .update(Tables.accountStat) + .set(Tables.accountStat.value, ULong.valueOf(uploadQueue.get(accountId).get(statId))) + .where(Tables.accountStat.accountId.eq(accountId)) + .and(Tables.accountStat.statId.eq(statId)); + updates.add(update); + } + else + { + Update update = context .update(Tables.accountStat) .set(Tables.accountStat.value, Tables.accountStat.value.plus(uploadQueue.get(accountId).get(statId))) .where(Tables.accountStat.accountId.eq(accountId)) .and(Tables.accountStat.statId.eq(statId)); - - updates.add(update); + updates.add(update); + } Insert insert = context .insertInto(Tables.accountStat) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java new file mode 100644 index 000000000..9ec2656c0 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java @@ -0,0 +1,58 @@ +package mineplex.core.stats.command; + +import mineplex.core.account.CoreClient; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.stats.StatsManager; + +import org.bukkit.entity.Player; + +public class MasterBuilderUnban extends CommandBase +{ + + public MasterBuilderUnban(StatsManager plugin) + { + super(plugin, Rank.ADMIN, "buildunban"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if(args.length != 1) + { + UtilPlayer.message(caller, F.main("MasterBuilder Unban", "/buildunban ")); + return; + } + + try + { + Plugin.getClientManager().loadClientByName(args[0], new Runnable() + { + + @Override + public void run() + { + CoreClient theClient = Plugin.getClientManager().Get(args[0]); + + if(theClient != null) + { + Plugin.incrementStat(theClient.getAccountId(), "Global.Build Draw Abuse", 0, true); + caller.sendMessage(F.main("MasterBuilder Unban", "The user " + args[0] + " has been unbanned for Master Builders")); + } + else + { + caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + args[0] + "'s account!")); + return; + } + } + }); + } + catch(Exception e) + { + caller.sendMessage(F.main("MasterBuilder Unban", "Exception caught! Please contact Morten and explain what happened.")); + } + } + +} From 9336eb19fa5fcf450c1831300d816a0ee57e60bf Mon Sep 17 00:00:00 2001 From: Morten Date: Tue, 22 Dec 2015 21:31:57 +0100 Subject: [PATCH 03/48] Finished up the Unban feature... --- .../stats/command/MasterBuilderUnban.java | 70 +++++++++++++++---- .../password/PasswordRepository.java | 2 +- 2 files changed, 59 insertions(+), 13 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java index 9ec2656c0..a8075985a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java @@ -1,8 +1,12 @@ package mineplex.core.stats.command; +import java.util.Iterator; +import java.util.List; + import mineplex.core.account.CoreClient; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; +import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.stats.StatsManager; @@ -28,29 +32,71 @@ public class MasterBuilderUnban extends CommandBase try { - Plugin.getClientManager().loadClientByName(args[0], new Runnable() + Plugin.getClientManager().getRepository().matchPlayerName(new Callback>() { - + @Override - public void run() + public void run(List matches) { - CoreClient theClient = Plugin.getClientManager().Get(args[0]); - - if(theClient != null) + boolean matchedExact = false; + + for (String match : matches) { - Plugin.incrementStat(theClient.getAccountId(), "Global.Build Draw Abuse", 0, true); - caller.sendMessage(F.main("MasterBuilder Unban", "The user " + args[0] + " has been unbanned for Master Builders")); + if (match.equalsIgnoreCase(args[0])) + { + matchedExact = true; + } } - else + + if (matchedExact) { - caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + args[0] + "'s account!")); - return; + for (Iterator matchIterator = matches.iterator(); matchIterator.hasNext();) + { + if (!matchIterator.next().equalsIgnoreCase(args[0])) + { + matchIterator.remove(); + } + } } + UtilPlayer.searchOffline(matches, new Callback() + { + @Override + public void run(String target) + { + if(target == null) + { + caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + args[0] + "'s account!")); + return; + } + Plugin.getClientManager().loadClientByName(target, new Runnable() + { + @Override + public void run() + { + CoreClient theClient = Plugin.getClientManager().Get(target); + + if(theClient != null) + { + Plugin.incrementStat(theClient.getAccountId(), "Global.Build Draw Abuse", 0, true); // True = Resets the stat + caller.sendMessage(F.main("MasterBuilder Unban", "The user " + target + " has been unbanned from Master Builders")); + } + else + { + caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + target + "'s client!")); + return; + } + } + }); + } + }, caller, args[0], false); } - }); + + }, args[0]); + } catch(Exception e) { + e.printStackTrace(); caller.sendMessage(F.main("MasterBuilder Unban", "Exception caught! Please contact Morten and explain what happened.")); } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java index f0cf867d4..33b63e8a5 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java @@ -24,7 +24,7 @@ public class PasswordRepository extends RepositoryBase public PasswordRepository(JavaPlugin plugin, String serverName) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _serverName = serverName; } From 8c399f03da46a923ff0819b62656452628163374 Mon Sep 17 00:00:00 2001 From: Morten Date: Tue, 22 Dec 2015 21:36:19 +0100 Subject: [PATCH 04/48] Removed a weird query :/ Status: Finished --- .../src/mineplex/core/stats/StatsRepository.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java index 726f75a99..e8ac03479 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java @@ -6,16 +6,14 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.common.util.NautHashMap; import mineplex.core.database.DBPool; import mineplex.core.database.RepositoryBase; import mineplex.core.database.ResultSetCallable; import mineplex.core.database.column.ColumnVarChar; import mineplex.database.Tables; -import net.md_5.bungee.chat.TranslatableComponentSerializer; +import org.bukkit.plugin.java.JavaPlugin; import org.jooq.DSLContext; import org.jooq.Insert; import org.jooq.Record2; @@ -29,7 +27,6 @@ public class StatsRepository extends RepositoryBase { private static String RETRIEVE_STATS = "SELECT id, name FROM stats;"; private static String INSERT_STAT = "INSERT INTO stats (name) VALUES (?);"; - private static String UPDATE_ACCOUNT_STAT_VALUE= "UPDATE accounts SET rank=?, rankPerm=true WHERE uuid = ?;"; public StatsRepository(JavaPlugin plugin) From f83016e0074ce810f727276a0feb127ecd69098f Mon Sep 17 00:00:00 2001 From: Morten Date: Wed, 23 Dec 2015 00:39:16 +0100 Subject: [PATCH 05/48] Also really quickly fixed the Invisibility in lobby bug (hopefully) --- .../src/mineplex/hub/modules/HubVisibilityManager.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java index 1733a2fcc..b7167cf07 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java @@ -70,13 +70,14 @@ public class HubVisibilityManager extends MiniPlugin for (Player other : UtilServer.getPlayers()) { + boolean localHideMe = hideMe; if (player.equals(other)) continue; if(Manager.GetClients().Get(other).GetRank().has(Rank.MODERATOR)) - hideMe = false; + localHideMe = false; - if (hideMe || + if (localHideMe || !Manager.getPreferences().Get(other).ShowPlayers || Manager.GetTutorial().InTutorial(other)) { From 08b5e7b4db1668ed570070a0c008576445a2bfc5 Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 23 Dec 2015 09:21:43 +0000 Subject: [PATCH 06/48] Working loadouts. --- .../game/arcade/game/games/gladiators/Gladiators.java | 11 +++++++---- .../game/games/gladiators/hotbar/HotbarEditor.java | 6 ++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index 458e7ea83..66701b54a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -186,6 +186,9 @@ public class Gladiators extends SoloGame if (e.getType() != UpdateType.FASTEST) return; + if (!IsLive()) + return; + if (GetState() != GameState.Prepare) return; @@ -749,10 +752,10 @@ public class Gladiators extends SoloGame p.getInventory().clear(); p.getInventory().setArmorContents(null); - p.getInventory().setItem(layout.getSword() - 1, UtilItem.makeUnbreakable(type.getLoadout().getSword())); - p.getInventory().setItem(layout.getRod() - 1, UtilItem.makeUnbreakable(type.getLoadout().getRod())); - p.getInventory().setItem(layout.getBow() - 1, type.getLoadout().getBow()); - p.getInventory().setItem(layout.getArrows() - 1, type.getLoadout().getArrows()); + p.getInventory().setItem(layout.getSword(), UtilItem.makeUnbreakable(type.getLoadout().getSword())); + p.getInventory().setItem(layout.getRod(), UtilItem.makeUnbreakable(type.getLoadout().getRod())); + p.getInventory().setItem(layout.getBow(), type.getLoadout().getBow()); + p.getInventory().setItem(layout.getArrows(), type.getLoadout().getArrows()); p.getInventory().setHelmet(type.getLoadout().getHelmet()); p.getInventory().setChestplate(type.getLoadout().getChestplate()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java index 119e4d436..518b86d96 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java @@ -52,6 +52,9 @@ public class HotbarEditor extends MiniPlugin @EventHandler public void onJoin(PlayerJoinEvent event) { + if (_host.Manager.GetGame() != _host) + return; + if (_host.GetState() == Game.GameState.Recruit || _host.GetState() == Game.GameState.Live) { event.getPlayer().getInventory().setItem(0, _item); @@ -89,6 +92,9 @@ public class HotbarEditor extends MiniPlugin @EventHandler public void onJoin(GameStateChangeEvent event) { + if (event.GetGame() != _host) + return; + if (event.GetState() == Game.GameState.Recruit) { for (Player player : Bukkit.getOnlinePlayers()) From f1c74249397e38b5e7dcf1de2dc6f79c12c43c12 Mon Sep 17 00:00:00 2001 From: William Burns Date: Tue, 29 Dec 2015 15:19:09 +0000 Subject: [PATCH 07/48] Fixing hotbar --- .../gladiators/hotbar/HotbarPageListener.java | 83 +++++++++++++++++-- 1 file changed, 78 insertions(+), 5 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java index d778f7643..249983dd7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java @@ -1,11 +1,19 @@ package nautilus.game.arcade.game.games.gladiators.hotbar; import org.bukkit.Material; +import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.PlayerInventory; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; /** * Created by William (WilliamTiger). @@ -29,12 +37,25 @@ public class HotbarPageListener implements Listener if (e.getCurrentItem() == null) return; + if (e.getAction().equals(InventoryAction.HOTBAR_SWAP) || e.getAction().equals(InventoryAction.HOTBAR_MOVE_AND_READD)){ + e.setCancelled(true); + return; + } + if (e.getClick().isShiftClick()) { e.setCancelled(true); return; } + System.out.println(e.getClickedInventory().getName() + " : " + e.getInventory().getName()); + +// if ((e.getSlot() > 8 && e.getSlot() < 18)) +// { +// e.setCancelled(false); +// return; +// } + if (e.getCurrentItem().getType().equals(Material.REDSTONE_BLOCK)) { e.setCancelled(true); @@ -42,11 +63,21 @@ public class HotbarPageListener implements Listener return; } + if (e.getClickedInventory() instanceof PlayerInventory || e.getInventory() instanceof PlayerInventory){ + e.setCancelled(true); + return; + } + if (e.getCurrentItem().getType().equals(Material.EMERALD_BLOCK)) { + if (e.getAction().equals(InventoryAction.SWAP_WITH_CURSOR)){ + e.setCancelled(true); + return; + } + e.setCancelled(true); e.getWhoClicked().closeInventory(); - _editor.saveLayout(((Player)e.getWhoClicked()), e.getClickedInventory()); + _editor.saveLayout(((Player) e.getWhoClicked()), e.getClickedInventory()); return; } @@ -56,15 +87,57 @@ public class HotbarPageListener implements Listener return; } - if (e.getAction().equals(InventoryAction.PLACE_ALL) - || e.getAction().equals(InventoryAction.PLACE_ONE) - || e.getAction().equals(InventoryAction.PLACE_SOME)) - { + if (!(e.getAction().equals(InventoryAction.PICKUP_ONE) || e.getAction().equals(InventoryAction.PLACE_ONE))){ + if (!(e.getSlot() > 8 && e.getSlot() < 18)) { e.setCancelled(true); return; } + + return; } + +// if (e.getAction().equals(InventoryAction.PLACE_ALL) +// || e.getAction().equals(InventoryAction.PLACE_ONE) +// || e.getAction().equals(InventoryAction.PLACE_SOME)) +// { +// if (!(e.getSlot() > 8 && e.getSlot() < 18)) +// { +// e.setCancelled(true); +// return; +// } +// } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onDrop(PlayerDropItemEvent e){ + if (e.getPlayer().getOpenInventory() == null) + return; + + if (e.getPlayer().getOpenInventory().getTopInventory() == null) + return; + + if (!e.getPlayer().getOpenInventory().getTopInventory().getName().equals("Hotbar Editor")) + return; + + if (!e.isCancelled()) + return; + + e.setCancelled(false); + Item i = e.getItemDrop(); + Inventory inv = e.getPlayer().getOpenInventory().getTopInventory(); + + if (i.getItemStack().getType().equals(Material.EMERALD_BLOCK)) + inv.setItem(30, new ItemBuilder(Material.EMERALD_BLOCK).setTitle(C.cGreen + C.Bold + "Save").setLore(C.cGray + "Click to save layout.").build()); + else if (i.getItemStack().getType().equals(Material.REDSTONE_BLOCK)) + inv.setItem(32, new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(C.cRed + C.Bold + "Cancel").setLore(C.cGray + "Click to cancel layout.").build()); + else + inv.addItem(i.getItemStack()); + + e.getPlayer().updateInventory(); + e.getPlayer().setItemOnCursor(null); + + i.remove(); } } From 1b40cece80ce52a3b9ef86f0d9fdc308cdccf713 Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 30 Dec 2015 20:04:01 +0000 Subject: [PATCH 08/48] Added a new years countdown to the hub. --- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 3 + .../mineplex/hub/commands/NewYearCommand.java | 50 ++++ .../hub/modules/NewYearCountdown.java | 249 ++++++++++++++++++ 3 files changed, 302 insertions(+) create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index bfac5e555..7cc8e7def 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -54,6 +54,7 @@ import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.core.velocity.VelocityFix; import mineplex.core.visibility.VisibilityManager; +import mineplex.hub.modules.NewYearCountdown; import mineplex.hub.modules.StackerManager; import mineplex.hub.queue.QueueManager; import mineplex.hub.server.ServerManager; @@ -183,6 +184,8 @@ public class Hub extends JavaPlugin implements IRelation //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); + + new NewYearCountdown(this); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java new file mode 100644 index 000000000..55e64903d --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java @@ -0,0 +1,50 @@ +package mineplex.hub.commands; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.hub.modules.NewYearCountdown; + +/** + * Created by William (WilliamTiger). + * 29/12/15 + */ +public class NewYearCommand extends CommandBase +{ + public NewYearCommand(NewYearCountdown plugin) + { + super(plugin, Rank.JNR_DEV, "newyear", "nycountdown", "nyc"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (Plugin.isInProgress()) + { + caller.sendMessage(ChatColor.RED + "A new year countdown event is already in progress!"); + return; + } + + if (args.length != 1) + { + caller.sendMessage(ChatColor.RED + "/newyear "); + return; + } + + int mins = 0; + try + { + mins = Integer.parseInt(args[0]); + } + catch (Exception e) + { + caller.sendMessage(ChatColor.RED + "That is not a valid amount of minutes!"); + return; + } + + + Plugin.start(caller, mins); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java new file mode 100644 index 000000000..027b1c89e --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java @@ -0,0 +1,249 @@ +package mineplex.hub.modules; + +import java.awt.*; +import java.awt.font.FontRenderContext; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.util.*; +import java.util.List; + +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.Location; +import org.bukkit.entity.Firework; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.inventory.meta.FireworkMeta; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; + +import mineplex.core.MiniPlugin; +import mineplex.core.command.CommandCenter; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.commands.NewYearCommand; + +/** + * Created by William (WilliamTiger). + * 29/12/15 + */ +public class NewYearCountdown extends MiniPlugin +{ + private boolean _inProgress; + private Location _center; + private int _stage; + private BufferedImage _currentFrame; + + public NewYearCountdown(JavaPlugin plugin) + { + super("New Year Countdown", plugin); + + _inProgress = false; + } + + @Override + public void addCommands() + { + CommandCenter.Instance.AddCommand(new NewYearCommand(this)); + } + + public boolean isInProgress() + { + return _inProgress; + } + + public void start(Player player, int mins) + { + _inProgress = true; + _center = player.getLocation(); + _stage = mins * 60; + UtilServer.broadcast(C.cGreenB + player.getName() + " has started a " + C.cAquaB + "New Year's Countdown"); + UtilWorld.getWorld("world").setTime(18000); + + _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 36), formatTimer(_stage)); + } + + @EventHandler + public void cmd(PlayerCommandPreprocessEvent e) + { + if (e.getMessage().equalsIgnoreCase("/lmao")) + { + e.setCancelled(true); + start(e.getPlayer(), 3); + } + } + + @EventHandler + public void stageUpdate(UpdateEvent e) + { + if (e.getType() != UpdateType.SEC) + return; + + if (!_inProgress) + return; + + _stage--; + + if (_stage <= 0) + return; + + _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 36), formatTimer(_stage)); + } + + @EventHandler + public void update(UpdateEvent e) + { + if (e.getType() != UpdateType.FASTER) + return; + + if (!_inProgress) + return; + + if (_stage == 0) + { + _currentFrame = null; + UtilTextMiddle.display(C.cGoldB + "2016", C.cYellowB + "Happy New Year!", UtilServer.getPlayers()); + } + + if (_stage <= -120) + { + //End of event. + _inProgress = false; + UtilWorld.getWorld("world").setTime(0); + return; + } + + if (_stage <= 0) + { + randomFirework(offsetLoc(_center)); + randomFirework(offsetLoc(_center)); + randomFirework(offsetLoc(_center)); + } + + new BukkitRunnable(){ + ArrayList line = UtilShapes.getLinesDistancedPoints(offsetLoc(_center), offsetLoc(_center), 0.2); + UtilParticle.ParticleType type = getRandomParticle(); + @Override + public void run() + { + UtilParticle.PlayParticle(type, line.get(0), 0, 0, 0, 0, 1, UtilParticle.ViewDist.MAX); + line.remove(0); + + if (line.isEmpty()) + this.cancel(); + } + }.runTaskTimer(getPlugin(), 0L, 1L); + + if (_currentFrame == null) + return; + + for (int y = 0; y < _currentFrame.getHeight(); y++) + for (int x = 0; x < _currentFrame.getWidth(); x++) + { + if (java.awt.Color.black.getRGB() != _currentFrame.getRGB(x, y)) + continue; + + Vector v = new Vector((float) _currentFrame.getWidth() / 2 - x, (float) _currentFrame.getHeight() / 2 - y, 0).multiply(0.5); + UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, _center.add(v), 0, 0, 0, 0, 1, UtilParticle.ViewDist.MAX); + _center.subtract(v); + } + } + + private BufferedImage stringToBufferedImage(Font font, String s) + { + BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR); + Graphics g = img.getGraphics(); + g.setFont(font); + + FontRenderContext frc = g.getFontMetrics().getFontRenderContext(); + Rectangle2D rect = font.getStringBounds(s, frc); + g.dispose(); + + img = new BufferedImage((int) Math.ceil(rect.getWidth()), (int) Math.ceil(rect.getHeight()), BufferedImage.TYPE_4BYTE_ABGR); + g = img.getGraphics(); + g.setColor(java.awt.Color.black); + g.setFont(font); + + FontMetrics fm = g.getFontMetrics(); + int x = 0; + int y = fm.getAscent(); + + g.drawString(s, x, y); + g.dispose(); + + return img; + } + + private String formatTimer(int seconds) + { + if (seconds <= 60) + return "" + seconds; + + int mins = seconds / 60; + int secs = seconds % 60; + String s = String.valueOf(secs); + + if (s.length() == 1) + s = "0" + s; + + return mins + ":" + s; + } + + private Location offsetLoc(Location loc) + { + Random random = new Random(); + return loc.clone().add((random.nextInt(100) - 50) + random.nextDouble() - 0.5, random.nextInt(20) + random.nextDouble() - 0.5, (random.nextInt(100) - 50) + random.nextDouble() - 0.5); + } + + public static void randomFirework(Location l) + { + Color c = Color.RED; + int r = new Random().nextInt(4); + if (r == 0) + { + c = Color.AQUA; + } + else if (r == 1) + { + c = Color.YELLOW; + } + else if (r == 2) + { + c = Color.RED; + } else if (r == 3) + { + c = Color.LIME; + } + FireworkEffect.Type t = FireworkEffect.Type.BALL; + int rType = new Random().nextInt(4); + if (rType == 0) { + t = FireworkEffect.Type.BALL_LARGE; + } else if (rType == 1) { + t = FireworkEffect.Type.BURST; + } else if (rType == 2) { + t = FireworkEffect.Type.STAR; + } else if (rType == 3) { + t = FireworkEffect.Type.CREEPER; + } + Firework f = l.getWorld().spawn(l, Firework.class); + FireworkMeta fm = f.getFireworkMeta(); + fm.addEffect(FireworkEffect.builder().with(t).withColor(c).build()); + fm.setPower(0 + new Random().nextInt(2)); + f.setFireworkMeta(fm); + } + + public UtilParticle.ParticleType getRandomParticle() + { + List types = Arrays.asList(UtilParticle.ParticleType.FLAME, UtilParticle.ParticleType.FIREWORKS_SPARK, UtilParticle.ParticleType.RED_DUST); + return types.get(new Random().nextInt(types.size())); + } + +} From a64dc6a8d4ac8b39f0bd955a84d539c4227d1a71 Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 31 Dec 2015 00:46:31 +0000 Subject: [PATCH 09/48] Made it activate in all lobbies via command. --- .../mineplex/hub/commands/NewYearCommand.java | 37 +++++++--- .../hub/modules/NewYearCountdown.java | 69 +++++++++++++------ .../hub/modules/newyear/NewYearHandler.java | 28 ++++++++ .../hub/modules/newyear/NewYearMessage.java | 29 ++++++++ 4 files changed, 131 insertions(+), 32 deletions(-) create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearHandler.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearMessage.java diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java index 55e64903d..2e1ec8432 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java @@ -5,7 +5,10 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import mineplex.hub.modules.NewYearCountdown; +import mineplex.hub.modules.newyear.NewYearMessage; /** * Created by William (WilliamTiger). @@ -23,28 +26,42 @@ public class NewYearCommand extends CommandBase { if (Plugin.isInProgress()) { - caller.sendMessage(ChatColor.RED + "A new year countdown event is already in progress!"); + caller.sendMessage(F.main("NYC", C.cRed + "A new year countdown event is already in progress!")); return; } - if (args.length != 1) + if (args.length != 3) { - caller.sendMessage(ChatColor.RED + "/newyear "); + caller.sendMessage(F.main("NYC", C.cRed + "/newyear ")); return; } - int mins = 0; + if (!(validateInteger(args[0]) && validateInteger(args[1]) && validateInteger(args[2]))) + { + caller.sendMessage(F.main("NYC", C.cRed + "You have entered invalid hours/minutes/seconds.")); + return; + } + + int hours = Integer.valueOf(args[0]); + int mins = Integer.valueOf(args[1]); + int secs = Integer.valueOf(args[2]); + int total = secs + (mins * 60) + (hours * 60 * 60); + + caller.sendMessage(F.main("NYC", "Sent command to all lobbies to start with " + F.elem(total + "") + " seconds.")); + new NewYearMessage(total).publish(); + } + + private boolean validateInteger(String str) + { + boolean passed = false; try { - mins = Integer.parseInt(args[0]); + int i = Integer.valueOf(str); + passed = true; } catch (Exception e) { - caller.sendMessage(ChatColor.RED + "That is not a valid amount of minutes!"); - return; } - - - Plugin.start(caller, mins); + return passed; } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java index 027b1c89e..286a9a152 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java @@ -6,10 +6,12 @@ import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.util.*; import java.util.List; +import java.util.concurrent.TimeUnit; import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.Location; +import org.bukkit.Sound; import org.bukkit.entity.Firework; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -30,6 +32,9 @@ import mineplex.core.common.util.UtilWorld; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.commands.NewYearCommand; +import mineplex.hub.modules.newyear.NewYearHandler; +import mineplex.hub.modules.newyear.NewYearMessage; +import mineplex.serverdata.commands.ServerCommandManager; /** * Created by William (WilliamTiger). @@ -46,6 +51,10 @@ public class NewYearCountdown extends MiniPlugin { super("New Year Countdown", plugin); + ServerCommandManager.getInstance().registerCommandType("NewYearCommand", + NewYearMessage.class, new NewYearHandler(this)); + + _center = new Location(UtilWorld.getWorld("world"), 0.5, 85, 37.5); _inProgress = false; } @@ -60,24 +69,24 @@ public class NewYearCountdown extends MiniPlugin return _inProgress; } - public void start(Player player, int mins) + public void start(int seconds) { _inProgress = true; - _center = player.getLocation(); - _stage = mins * 60; - UtilServer.broadcast(C.cGreenB + player.getName() + " has started a " + C.cAquaB + "New Year's Countdown"); + _stage = seconds; UtilWorld.getWorld("world").setTime(18000); - _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 36), formatTimer(_stage)); } @EventHandler public void cmd(PlayerCommandPreprocessEvent e) { + if (!e.getPlayer().getName().equalsIgnoreCase("WilliamTiger")) + return; + if (e.getMessage().equalsIgnoreCase("/lmao")) { e.setCancelled(true); - start(e.getPlayer(), 3); + start(30); } } @@ -92,6 +101,10 @@ public class NewYearCountdown extends MiniPlugin _stage--; + if (_stage > 0 && _stage <= 10) + for (Player p : UtilServer.getPlayers()) + p.playSound(p.getLocation(), Sound.NOTE_BASS, 1f, 1f); + if (_stage <= 0) return; @@ -109,7 +122,7 @@ public class NewYearCountdown extends MiniPlugin if (_stage == 0) { - _currentFrame = null; + _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 20), "Happy New Year"); UtilTextMiddle.display(C.cGoldB + "2016", C.cYellowB + "Happy New Year!", UtilServer.getPlayers()); } @@ -117,6 +130,7 @@ public class NewYearCountdown extends MiniPlugin { //End of event. _inProgress = false; + _currentFrame = null; UtilWorld.getWorld("world").setTime(0); return; } @@ -152,7 +166,7 @@ public class NewYearCountdown extends MiniPlugin continue; Vector v = new Vector((float) _currentFrame.getWidth() / 2 - x, (float) _currentFrame.getHeight() / 2 - y, 0).multiply(0.5); - UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, _center.add(v), 0, 0, 0, 0, 1, UtilParticle.ViewDist.MAX); + UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, _center.add(v), 0, 0, 0, 0, 1, UtilParticle.ViewDist.MAX); _center.subtract(v); } } @@ -182,19 +196,23 @@ public class NewYearCountdown extends MiniPlugin return img; } - private String formatTimer(int seconds) + private String formatTimer(long seconds) { - if (seconds <= 60) - return "" + seconds; + long minutes = seconds / 60; + long hours = minutes / 60; - int mins = seconds / 60; - int secs = seconds % 60; - String s = String.valueOf(secs); + if ((hours % 60) > 0) + return zeroNumber(hours % 60) + ":" + zeroNumber(minutes % 60) + ":" + zeroNumber(seconds % 60); - if (s.length() == 1) - s = "0" + s; + if ((minutes % 60) > 0) + return zeroNumber(minutes % 60) + ":" + zeroNumber(seconds % 60); - return mins + ":" + s; + return zeroNumber(seconds % 60); + } + + private String zeroNumber(long time) + { + return (time < 10 ? "0" : "") + time; } private Location offsetLoc(Location loc) @@ -224,13 +242,20 @@ public class NewYearCountdown extends MiniPlugin } FireworkEffect.Type t = FireworkEffect.Type.BALL; int rType = new Random().nextInt(4); - if (rType == 0) { + if (rType == 0) + { t = FireworkEffect.Type.BALL_LARGE; - } else if (rType == 1) { + } + else if (rType == 1) + { t = FireworkEffect.Type.BURST; - } else if (rType == 2) { + } + else if (rType == 2) + { t = FireworkEffect.Type.STAR; - } else if (rType == 3) { + } + else if (rType == 3) + { t = FireworkEffect.Type.CREEPER; } Firework f = l.getWorld().spawn(l, Firework.class); @@ -242,7 +267,7 @@ public class NewYearCountdown extends MiniPlugin public UtilParticle.ParticleType getRandomParticle() { - List types = Arrays.asList(UtilParticle.ParticleType.FLAME, UtilParticle.ParticleType.FIREWORKS_SPARK, UtilParticle.ParticleType.RED_DUST); + List types = Arrays.asList(UtilParticle.ParticleType.FLAME, UtilParticle.ParticleType.HAPPY_VILLAGER, UtilParticle.ParticleType.RED_DUST); return types.get(new Random().nextInt(types.size())); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearHandler.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearHandler.java new file mode 100644 index 000000000..7f2f3cf80 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearHandler.java @@ -0,0 +1,28 @@ +package mineplex.hub.modules.newyear; + +import mineplex.hub.modules.NewYearCountdown; +import mineplex.serverdata.commands.CommandCallback; +import mineplex.serverdata.commands.ServerCommand; + +/** + * Created by William (WilliamTiger). + * 31/12/15 + */ +public class NewYearHandler implements CommandCallback +{ + private NewYearCountdown _newYear; + + public NewYearHandler(NewYearCountdown newYear) + { + _newYear = newYear; + } + + @Override + public void run(ServerCommand command) + { + if (command instanceof NewYearMessage) + { + _newYear.start(((NewYearMessage)command).getSeconds()); + } + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearMessage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearMessage.java new file mode 100644 index 000000000..aaf21447f --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearMessage.java @@ -0,0 +1,29 @@ +package mineplex.hub.modules.newyear; + +import mineplex.serverdata.commands.ServerCommand; + +/** + * Created by William (WilliamTiger). + * 31/12/15 + */ +public class NewYearMessage extends ServerCommand +{ + + private int seconds; + + public NewYearMessage(int seconds) + { + this.seconds = seconds; + } + + public int getSeconds() + { + return seconds; + } + + @Override + public void run() + { + + } +} From 874695cdf6696fcc988f78dfc3e85cb193a453d1 Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 31 Dec 2015 00:50:53 +0000 Subject: [PATCH 10/48] Flame --- .../Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java index 286a9a152..f7ba5f1c1 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java @@ -166,7 +166,7 @@ public class NewYearCountdown extends MiniPlugin continue; Vector v = new Vector((float) _currentFrame.getWidth() / 2 - x, (float) _currentFrame.getHeight() / 2 - y, 0).multiply(0.5); - UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, _center.add(v), 0, 0, 0, 0, 1, UtilParticle.ViewDist.MAX); + UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, _center.add(v), 0, 0, 0, 0, 1, UtilParticle.ViewDist.MAX); _center.subtract(v); } } From 637baed830196831fc4f3fff978bf971eb9951d1 Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 31 Dec 2015 01:24:58 +0000 Subject: [PATCH 11/48] Small edits --- .../mineplex/hub/modules/NewYearCountdown.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java index f7ba5f1c1..33b96bda1 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java @@ -6,7 +6,6 @@ import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.util.*; import java.util.List; -import java.util.concurrent.TimeUnit; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -24,9 +23,11 @@ import org.bukkit.util.Vector; import mineplex.core.MiniPlugin; import mineplex.core.command.CommandCenter; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilWorld; import mineplex.core.updater.UpdateType; @@ -44,6 +45,7 @@ public class NewYearCountdown extends MiniPlugin { private boolean _inProgress; private Location _center; + private Location _spawn; private int _stage; private BufferedImage _currentFrame; @@ -55,6 +57,7 @@ public class NewYearCountdown extends MiniPlugin NewYearMessage.class, new NewYearHandler(this)); _center = new Location(UtilWorld.getWorld("world"), 0.5, 85, 37.5); + _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5); _inProgress = false; } @@ -108,6 +111,8 @@ public class NewYearCountdown extends MiniPlugin if (_stage <= 0) return; + UtilTextBottom.display(C.cWhiteB + "New Year's Countdown - " + C.cGoldB + formatTimer(_stage), UtilServer.getPlayers()); + _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 36), formatTimer(_stage)); } @@ -124,6 +129,7 @@ public class NewYearCountdown extends MiniPlugin { _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 20), "Happy New Year"); UtilTextMiddle.display(C.cGoldB + "2016", C.cYellowB + "Happy New Year!", UtilServer.getPlayers()); + //fireworkCircle(); } if (_stage <= -120) @@ -265,9 +271,17 @@ public class NewYearCountdown extends MiniPlugin f.setFireworkMeta(fm); } + private void fireworkCircle() + { + for (Location cur : UtilShapes.getPointsInCircle(_spawn, 35, 30)) + { + UtilFirework.launchFirework(cur, FireworkEffect.Type.BALL, Color.FUCHSIA, false, true, cur.toVector().setY(3).multiply(1), 2); + } + } + public UtilParticle.ParticleType getRandomParticle() { - List types = Arrays.asList(UtilParticle.ParticleType.FLAME, UtilParticle.ParticleType.HAPPY_VILLAGER, UtilParticle.ParticleType.RED_DUST); + List types = Arrays.asList(UtilParticle.ParticleType.FLAME, UtilParticle.ParticleType.HAPPY_VILLAGER, UtilParticle.ParticleType.RED_DUST, UtilParticle.ParticleType.FIREWORKS_SPARK); return types.get(new Random().nextInt(types.size())); } From 5ff9d1985b8e93a24c63845b55c6989a783e196f Mon Sep 17 00:00:00 2001 From: Mysticate Date: Thu, 31 Dec 2015 03:00:40 -0500 Subject: [PATCH 12/48] Monitoring for josh + the mods --- .../typewars/StaffKillMonitorManager.java | 101 ++++++++++++++++++ .../arcade/game/games/typewars/TypeWars.java | 48 ++++----- 2 files changed, 125 insertions(+), 24 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/StaffKillMonitorManager.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/StaffKillMonitorManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/StaffKillMonitorManager.java new file mode 100644 index 000000000..dc6a87727 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/StaffKillMonitorManager.java @@ -0,0 +1,101 @@ +package nautilus.game.arcade.game.games.typewars; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; + +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.typewars.TypeWars.KillType; + +public class StaffKillMonitorManager implements Listener +{ + /** + * Created by: Mysticate + * Timestamp: December 30, 2015 + */ + + private TypeWars _host; + private String _command = "/words"; + + private NautHashMap _monitoring = new NautHashMap(); + + public StaffKillMonitorManager(TypeWars host) + { + _host = host; + + host.Manager.registerEvents(this);; + } + + public TypeWars getHost() + { + return _host; + } + + @EventHandler + public void onEnd(GameStateChangeEvent event) + { + if (event.GetState() == GameState.End) + HandlerList.unregisterAll(this); + } + + @EventHandler + public void onKill(MinionKillEvent event) + { + if (event.getType() == KillType.SPELL) + return; + + for (Player staff : _monitoring.keySet()) + { + if (_monitoring.get(staff) == event.getPlayer()) + { + UtilPlayer.message(staff, F.elem(C.cRedB + ">>") + F.name(event.getPlayer().getName()) + " killed " + F.elem(C.cGold + event.getMinion().getName()) + "."); + } + } + } + + @EventHandler + public void onCommand(PlayerCommandPreprocessEvent event) + { + if (!_host.IsLive()) + return; + + if (!_host.Manager.GetClients().hasRank(event.getPlayer(), Rank.HELPER)) + return; + + event.setCancelled(true); + + String[] message = event.getMessage().toLowerCase().split(" "); + if (message.length == 0 || !message[0].equalsIgnoreCase(_command)) + return; + + if (message.length == 1) + { + if (_monitoring.containsKey(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("TypeWars", "You are no longer monitoring " + F.name(_monitoring.remove(event.getPlayer()).getName()) + ".")); + } + else + { + UtilPlayer.message(event.getPlayer(), F.main("TypeWars", "Please enter a player to monitor!")); + } + return; + } + + String playerName = message[1]; + + Player player = UtilPlayer.searchOnline(event.getPlayer(), playerName, true); + if (player == null) + return; + + _monitoring.put(event.getPlayer(), player); + UtilPlayer.message(event.getPlayer(), F.main("TypeWars", "You are now monitoring " + F.name(player.getName()) + ". Type " + F.elem(_command) + " to stop.")); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java index 0f0d7e6c5..97e660f81 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java @@ -5,6 +5,27 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Giant; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.util.Vector; + import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -45,33 +66,10 @@ import nautilus.game.arcade.game.games.typewars.tutorial.TutorialTypeWars; import nautilus.game.arcade.gametutorial.events.GameTutorialEndEvent; import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.stats.TimeInGameStatTracker; import nautilus.game.arcade.world.WorldData; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Giant; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntitySpawnEvent; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.util.Vector; - public class TypeWars extends TeamGame -{ - +{ private ArrayList _activeMinions; private ArrayList _deadMinions; private ArrayList _finishedMinions; @@ -114,6 +112,8 @@ public class TypeWars extends TeamGame "Kill your enemies Giant before they kill yours!" }); + new StaffKillMonitorManager(this); + this.DeathOut = false; this.DamageTeamSelf = false; this.DamageSelf = false; From 8ef1a524c19fa5a6df316e9f153c1d3d626fed37 Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 31 Dec 2015 12:01:24 +0100 Subject: [PATCH 13/48] updating /disguise --- .../game/arcade/command/DisguiseCommand.java | 154 ++++++++++++++++-- 1 file changed, 136 insertions(+), 18 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java index 7111ae370..ba13306e0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java @@ -3,7 +3,6 @@ package nautilus.game.arcade.command; import java.lang.reflect.Field; import java.util.UUID; -import mineplex.core.NCPDataManFix; import mineplex.core.account.CoreClient; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; @@ -21,8 +20,21 @@ import mineplex.core.treasure.event.TreasureStartEvent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.Game.GameState; +import net.minecraft.server.v1_8_R3.ChatComponentText; import net.minecraft.server.v1_8_R3.EntityHuman; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.EnumDifficulty; +import net.minecraft.server.v1_8_R3.IChatBaseComponent; import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; +import net.minecraft.server.v1_8_R3.WorldType; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.PlayerInfoData; +import net.minecraft.server.v1_8_R3.PacketPlayOutRespawn; +import net.minecraft.server.v1_8_R3.PacketPlayOutWindowData; +import net.minecraft.server.v1_8_R3.PacketPlayOutWorldEvent; +import net.minecraft.server.v1_8_R3.WorldSettings.EnumGamemode; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -52,10 +64,9 @@ public class DisguiseCommand extends CommandBase implements Liste public DisguiseCommand(ArcadeManager plugin) { - super(plugin, Rank.JNR_DEV, new Rank[] - { Rank.YOUTUBE, Rank.TWITCH }, "disguise"); + super(plugin, Rank.JNR_DEV, new Rank[] {Rank.YOUTUBE, Rank.TWITCH, Rank.YOUTUBE_SMALL}, "disguise"); + plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); - new NCPDataManFix(); } @Override @@ -65,11 +76,12 @@ public class DisguiseCommand extends CommandBase implements Liste { if(!Plugin.GetDisguise().isDisguised(caller)) { - UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first")); return; } try { + GameProfile profile = _disguisedPlayers.get(caller); _disguisedPlayers.remove(caller); _disguisedPlayerDisguises.remove(caller); Plugin.GetDisguise().undisguise(caller); @@ -81,7 +93,28 @@ public class DisguiseCommand extends CommandBase implements Liste client.setDisguised(false); changeName(caller, playerName, true); + + for(Player other : UtilServer.getPlayers()) + updateTabInfo(((CraftPlayer) caller).getProfile(), profile, other, false); + Field field; + try + { + field = GameProfile.class.getDeclaredField("id"); + field.setAccessible(true); + UUID old = ((CraftPlayer) caller).getProfile().getId(); + UUID newUUID = profile.getId(); + field.set(profile, old); + field.set(((CraftPlayer) caller).getProfile(), newUUID); + } + catch(Exception e) + { + e.printStackTrace(); + } + + PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); + UtilPlayer.sendPacket(caller, packet); + for(Player other : UtilServer.getPlayers()) { for(Team team : other.getScoreboard().getTeams()) @@ -91,7 +124,7 @@ public class DisguiseCommand extends CommandBase implements Liste other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); } - UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!"); + UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!")); return; } catch(Exception ex) { @@ -100,7 +133,7 @@ public class DisguiseCommand extends CommandBase implements Liste } if(args != null && args.length > 1) { - UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise "); + UtilPlayer.message(caller, F.main("Disguise", "/disguise ")); return; } @@ -111,40 +144,41 @@ public class DisguiseCommand extends CommandBase implements Liste { if(Plugin.GetDisguise().isDisguised(caller)) { - UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first")); return; } for(Player other : UtilServer.getPlayers()) { if(other.getName().equalsIgnoreCase(args[0])) { - UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!")); return; } } if(_disguisedPlayersNames.containsValue(args[0])) { - UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!")); return; } if(args[0].length() > 16) { - UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0])); return; } try { CoreClient client = Plugin.GetClients().Get(caller); - UUID uuid = UUIDFetcher.getUUIDOf(args[0]); + UUID uuid = UUID.randomUUID(); GameProfile profile = null; try { + uuid = UUIDFetcher.getUUIDOf(args[0]); profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); - } catch(Exception e) + } catch (Exception e) { - uuid = UUIDFetcher.getUUIDOf("Alex"); - profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + uuid = UUID.randomUUID(); + profile = new ProfileLoader(null, args[0]).loadProfile(); } Rank otherRank = Rank.ALL; @@ -157,7 +191,7 @@ public class DisguiseCommand extends CommandBase implements Liste {} if(otherRank.has(Rank.TWITCH)) { - UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!"); + UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff!")); return; } _disguisedPlayers.put(caller, profile); @@ -172,16 +206,100 @@ public class DisguiseCommand extends CommandBase implements Liste Plugin.getCosmeticManager().getGadgetManager().removeGadgetType(caller, GadgetType.Item); Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller)); - UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]); + UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + args[0])); + + Field field; + try + { + field = GameProfile.class.getDeclaredField("id"); + field.setAccessible(true); + UUID old = ((CraftPlayer) caller).getProfile().getId(); + UUID newUUID = profile.getId(); + field.set(profile, old); + field.set(((CraftPlayer) caller).getProfile(), newUUID); + } + catch(Exception e) + { + e.printStackTrace(); + } + + PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); + UtilPlayer.sendPacket(caller, packet); + + tablistRefresh(caller); } catch(Exception e) { e.printStackTrace(); - UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0])); return; } } }); } + + @EventHandler + public void refreshTabNames(UpdateEvent event) + { + if(event.getType() != UpdateType.FAST) + return; + + for(Player player : _disguisedPlayers.keySet()) + { + if(!player.isOnline()) + return; + + tablistRefresh(player); + } + } + + public void tablistRefresh(Player player) + { + for (Player other : UtilServer.getPlayers()) + { + if (player.canSee(other)) + { + updateTabInfo(_disguisedPlayers.get(player), ((CraftPlayer) player).getProfile(), other, false); + } + } + } + + public void updateTabInfo(GameProfile profileToAdd, GameProfile profileToRemove, Player target, boolean refreshOnly) + { + ChatColor team = ChatColor.WHITE; + Player player = Bukkit.getPlayer(profileToAdd.getName()); + EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); + if(Plugin.GetGame().GetTeam(player) != null) + { + team = Plugin.GetGame().GetTeam(player).GetColor(); + } + String tag = Plugin.GetClients().Get(player).GetRank().getTag(true, true) + " "; + if(Plugin.GetClients().Get(player).isDisguised()) + { + tag = Plugin.GetClients().Get(player).getDisguisedRank().getTag(true, true) + " "; + } + if(Plugin.GetGame().GetState() != GameState.Recruit) + tag = ""; + + IChatBaseComponent component = new ChatComponentText(tag + team + player.getName()); + + if(!refreshOnly) + { + PacketPlayOutPlayerInfo removePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); + PlayerInfoData removeData = removePacket.new PlayerInfoData(profileToRemove, entityPlayer.ping, EnumGamemode.SURVIVAL, component); + removePacket.b.add(removeData); + UtilPlayer.sendPacket(target, removePacket); + + PacketPlayOutPlayerInfo addPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER); + PlayerInfoData addData = addPacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component); + addPacket.b.add(addData); + UtilPlayer.sendPacket(target, addPacket); + } + + PacketPlayOutPlayerInfo updatePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.UPDATE_DISPLAY_NAME); + PlayerInfoData updateData = updatePacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component); + updatePacket.b.add(updateData); + UtilPlayer.sendPacket(target, updatePacket); + } @EventHandler public void updateDisguises(UpdateEvent event) From 6b3a5416643389a7bcac8df93f40f492452971e5 Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 31 Dec 2015 18:53:57 +0000 Subject: [PATCH 14/48] Accurate timings --- .../hub/modules/NewYearCountdown.java | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java index 33b96bda1..019c8d35b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java @@ -24,6 +24,7 @@ import mineplex.core.MiniPlugin; import mineplex.core.command.CommandCenter; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilShapes; @@ -47,6 +48,7 @@ public class NewYearCountdown extends MiniPlugin private Location _center; private Location _spawn; private int _stage; + private long _targetTime; private BufferedImage _currentFrame; public NewYearCountdown(JavaPlugin plugin) @@ -78,6 +80,7 @@ public class NewYearCountdown extends MiniPlugin _stage = seconds; UtilWorld.getWorld("world").setTime(18000); _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 36), formatTimer(_stage)); + _targetTime = System.currentTimeMillis() + (seconds * 1000); } @EventHandler @@ -94,26 +97,31 @@ public class NewYearCountdown extends MiniPlugin } @EventHandler - public void stageUpdate(UpdateEvent e) + public void updateStage(UpdateEvent e) { - if (e.getType() != UpdateType.SEC) + if (e.getType() != UpdateType.TICK) return; if (!_inProgress) return; - _stage--; + int stageAttempt = (int) ((_targetTime - System.currentTimeMillis()) / 1000); - if (_stage > 0 && _stage <= 10) - for (Player p : UtilServer.getPlayers()) - p.playSound(p.getLocation(), Sound.NOTE_BASS, 1f, 1f); + if (stageAttempt != _stage) + { + _stage = stageAttempt; - if (_stage <= 0) - return; + if (_stage > 0 && _stage <= 10) + for (Player p : UtilServer.getPlayers()) + p.playSound(p.getLocation(), Sound.NOTE_BASS, 1f, 1f); - UtilTextBottom.display(C.cWhiteB + "New Year's Countdown - " + C.cGoldB + formatTimer(_stage), UtilServer.getPlayers()); + if (_stage <= 0) + return; - _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 36), formatTimer(_stage)); + UtilTextBottom.display(C.cWhiteB + "New Year's Countdown - " + C.cGoldB + formatTimer(_stage), UtilServer.getPlayers()); + + _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 36), formatTimer(_stage)); + } } @EventHandler From 8232d11cd1d65140ae1aed9f013b6dd311c95b3e Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Thu, 31 Dec 2015 15:07:26 -0600 Subject: [PATCH 15/48] Remove in game notifications, change sale message --- .../core/notifier/NotificationManager.java | 4 +- .../src/mineplex/hub/modules/NewsManager.java | 53 +++++++++---------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java index 8e4cb3dc7..64cb728bd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java @@ -52,8 +52,8 @@ public class NotificationManager extends MiniPlugin // if (event.getType() == UpdateType.MIN_16) // sale(); - if (event.getType() == UpdateType.MIN_08) - christmasSale(); +// if (event.getType() == UpdateType.MIN_08) +// christmasSale(); } private void christmasSale() diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java index 424a582a1..1172751de 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java @@ -262,34 +262,33 @@ public class NewsManager extends MiniPlugin { _animationIndex = (_animationIndex + 1) % 40; - if (_animationIndex == 0) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 5" + C.cWhiteB + "0% OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 1) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50" + C.cWhiteB + "% OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 2) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% " + C.cWhiteB + "OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 3) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% O" + C.cWhiteB + "FF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 4) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OF" + C.cWhiteB + "F ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 5) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF " + C.cWhiteB + "ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 6) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF A" + C.cWhiteB + "LL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 7) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF AL" + C.cWhiteB + "L RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 8) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL " + C.cWhiteB + "RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 9) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL R" + C.cWhiteB + "ANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 10) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RA" + C.cWhiteB + "NKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 11) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RAN" + C.cWhiteB + "KS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 12) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANK" + C.cWhiteB + "S " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 13) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 2) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " U" + C.cWhiteB + "P TO 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 3) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP" + C.cWhiteB + " TO 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 4) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP " + C.cWhiteB + "TO 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 5) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP T" + C.cWhiteB + "O 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 6) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO" + C.cWhiteB + " 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 7) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO " + C.cWhiteB + "50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 8) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 5" + C.cWhiteB + "0% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 9) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50" + C.cWhiteB + "% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 10) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50%" + C.cWhiteB + " OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 11) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% " + C.cWhiteB + "OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 11) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% O" + C.cWhiteB + "FF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 12) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OF" + C.cWhiteB + "F " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 13) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 14) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 15) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 16) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 17) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 18) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 19) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 20) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 21) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 22) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 23) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 24) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 25) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 26) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 14) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 15) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 16) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 17) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 18) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 19) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 20) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 21) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 22) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 23) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 24) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 25) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 26) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; if (_animationIndex >= 27) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " " + C.cWhiteB + "50% OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; From 2e017fa5ca7bd04733de102e4ee1846243aeb203 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Thu, 31 Dec 2015 16:11:51 -0600 Subject: [PATCH 16/48] Fix redis command --- .../Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java index 019c8d35b..1c0766fa8 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java @@ -55,7 +55,7 @@ public class NewYearCountdown extends MiniPlugin { super("New Year Countdown", plugin); - ServerCommandManager.getInstance().registerCommandType("NewYearCommand", + ServerCommandManager.getInstance().registerCommandType("NewYearMessage", NewYearMessage.class, new NewYearHandler(this)); _center = new Location(UtilWorld.getWorld("world"), 0.5, 85, 37.5); From a30c2b0d75502a86ca060035aea665f6acc7c719 Mon Sep 17 00:00:00 2001 From: Sarah Date: Sat, 2 Jan 2016 00:53:56 +0100 Subject: [PATCH 17/48] update /Disguise for Hub as well --- .../hub/commands/DisguiseCommand.java | 357 ------------------ 1 file changed, 357 deletions(-) delete mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java deleted file mode 100644 index bb078b3bb..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java +++ /dev/null @@ -1,357 +0,0 @@ -package mineplex.hub.commands; - -import java.lang.reflect.Field; -import java.util.UUID; - -import mineplex.core.NCPDataManFix; -import mineplex.core.account.CoreClient; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.ProfileLoader; -import mineplex.core.common.util.UUIDFetcher; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.disguise.disguises.DisguisePlayer; -import mineplex.core.donation.Donor; -import mineplex.core.gadget.event.GadgetEnableEvent; -import mineplex.core.gadget.types.Gadget; -import mineplex.core.gadget.types.GadgetType; -import mineplex.core.treasure.event.TreasureStartEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.HubManager; -import net.minecraft.server.v1_8_R3.EntityHuman; -import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerToggleSneakEvent; -import org.bukkit.event.player.PlayerLoginEvent.Result; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.scoreboard.Team; - -import com.mojang.authlib.GameProfile; -import com.mysql.jdbc.BalanceStrategy; - -public class DisguiseCommand extends CommandBase implements Listener -{ - - private NautHashMap _disguisedPlayers = new NautHashMap<>(); - private NautHashMap _disguisedPlayersNames = new NautHashMap<>(); - private NautHashMap _disguisedPlayerDisguises = new NautHashMap<>(); - - public DisguiseCommand(HubManager plugin) - { - super(plugin, Rank.JNR_DEV, new Rank[] - { - Rank.YOUTUBE, Rank.TWITCH }, "disguise"); - plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); - new NCPDataManFix(); - } - - @Override - public void Execute(final Player caller, final String[] args) - { - if(args == null || args.length == 0) - { - if(!Plugin.GetDisguise().isDisguised(caller)) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); - return; - } - try - { - _disguisedPlayers.remove(caller); - _disguisedPlayerDisguises.remove(caller); - Plugin.GetDisguise().undisguise(caller); - String playerName = _disguisedPlayersNames.get(caller); - - CoreClient client = Plugin.GetClients().Get(caller); - client.setDisguisedRank(null); - client.setDisguisedAs(null); - client.setDisguised(false); - - changeName(caller, playerName); - - for(Player other : UtilServer.getPlayers()) - { - for(Team team : other.getScoreboard().getTeams()) - { - if(team.hasPlayer(caller)) - { - team.removePlayer(caller); - } - } - other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); - } - - UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!"); - return; - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - if(args != null && args.length > 1) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise "); - return; - } - - final Rank rank = Plugin.GetClients().Get(caller).GetRank(); - - Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() - { - @Override - public void run() - { - if(Plugin.GetDisguise().isDisguised(caller)) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); - return; - } - for(Player other : UtilServer.getPlayers()) - { - if(other.getName().equalsIgnoreCase(args[0])) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); - return; - } - } - if(_disguisedPlayersNames.containsValue(args[0])) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); - return; - } - if(args[0].length() > 16) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); - return; - } - - try - { - CoreClient client = Plugin.GetClients().Get(caller); - UUID uuid = UUIDFetcher.getUUIDOf(args[0]); - GameProfile profile = null; - try - { - profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); - } catch(Exception e) - { - uuid = UUIDFetcher.getUUIDOf("Alex"); - profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); - } - - Rank otherRank = Rank.ALL; - try - { - CoreClient other = new CoreClient(args[0]); - Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); - otherRank = other.GetRank(); - } catch(NullPointerException exception) - {} - if(otherRank.has(Rank.TWITCH) && !rank.has(Rank.OWNER)) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!"); - return; - } - _disguisedPlayers.put(caller, profile); - _disguisedPlayersNames.put(caller, caller.getName()); - client.setDisguisedRank(otherRank); - client.setDisguised(true); - - client.setDisguisedAs(args[0]); - - changeName(caller, args[0]); - - Plugin.GetGadget().removeGadgetType(caller, GadgetType.Item); - - UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]); - } catch(Exception e) - { - e.printStackTrace(); - UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); - return; - } - } - }); - } - - @EventHandler - public void updateDisguises(UpdateEvent event) - { - if(event.getType() != UpdateType.FASTEST) - return; - - for(final Player player : UtilServer.getPlayers()) - { - if(!_disguisedPlayers.containsKey(player)) - continue; - - for(Player other : UtilServer.getPlayers()) - { - try - { - for(Team team : other.getScoreboard().getTeams()) - { - if(team.hasPlayer(player)) - { - team.removePlayer(player); - } - } - other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); - - } catch(NullPointerException exp) - {} - } - - if(Plugin.GetDisguise().isDisguised(player)) - continue; - - DisguisePlayer playerDisguise = new DisguisePlayer(player, _disguisedPlayers.get(player)); - _disguisedPlayerDisguises.put(player, playerDisguise); - Plugin.GetDisguise().disguise(playerDisguise); - } - } - - public void changeName(Player player, String changedName) - { - try - { - Field name = GameProfile.class.getDeclaredField("name"); - Field declaredProfile = EntityHuman.class.getDeclaredField("bH"); - declaredProfile.setAccessible(true); - GameProfile gameProfile = (GameProfile) declaredProfile.get(((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); - - name.setAccessible(true); - name.set(gameProfile, changedName); - name.setAccessible(false); - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void Quit(PlayerQuitEvent event) - { - Player player = event.getPlayer(); - - if(_disguisedPlayers.containsKey(player)) - { - try - { - _disguisedPlayers.remove(player); - _disguisedPlayerDisguises.remove(player); - Plugin.GetDisguise().undisguise(player); - String playerName = _disguisedPlayersNames.get(player); - _disguisedPlayersNames.remove(player); - - CoreClient client = Plugin.GetClients().Get(player); - client.setDisguisedRank(null); - client.setDisguisedAs(null); - client.setDisguised(false); - - changeName(player, playerName); - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void Join(PlayerLoginEvent event) - { - for(Player player : _disguisedPlayers.keySet()) - { - if(player.getName().equalsIgnoreCase(event.getPlayer().getName())) - { - event.disallow(Result.KICK_OTHER, "There is already the same account playing. this probably happened because of /disguise"); - } - } - } - - @EventHandler - public void gadget(GadgetEnableEvent event) - { - if(!event.getGadget().GetName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.Morph) - return; - - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - event.setCancelled(true); - } - } - - @EventHandler - public void chest(TreasureStartEvent event) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - UtilPlayer.message(event.getPlayer(), F.main("Disguise", "You cant open Treasure Chests while you are disguised!")); - event.setCancelled(true); - } - } - - @EventHandler - public void onPlayerSneak(PlayerToggleSneakEvent event) - { - Player player = event.getPlayer(); - - if(_disguisedPlayers.containsKey(player)) - { - DisguisePlayer dp = _disguisedPlayerDisguises.get(player); - - dp.setSneaking(!dp.getSneaking()); - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void onDPlayerChat(AsyncPlayerChatEvent event) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - event.setFormat(" *" + event.getMessage()); - } - } - - @EventHandler - public void on(PlayerInteractEvent event) - { - if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - - Player player = event.getPlayer(); - - PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); - packet.a = player.getEntityId(); - - for(Player p : Bukkit.getOnlinePlayers()) - { - if(p != player) - { - Plugin.getPacketHandler().getPacketVerifier((Player) p).bypassProcess(packet); - } - } - } - } - } - -} From a06a0060aa214cd71e11a0b2e2beabd3841e70e2 Mon Sep 17 00:00:00 2001 From: Sarah Date: Sat, 2 Jan 2016 01:53:19 +0100 Subject: [PATCH 18/48] Fixing Disguise File --- .../hub/commands/DisguiseCommand.java | 467 ++++++++++++++++++ 1 file changed, 467 insertions(+) create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java new file mode 100644 index 000000000..84439b77d --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java @@ -0,0 +1,467 @@ +package mineplex.hub.commands; + +import java.lang.reflect.Field; +import java.util.UUID; + +import mineplex.core.account.CoreClient; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.ProfileLoader; +import mineplex.core.common.util.UUIDFetcher; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.gadget.event.GadgetEnableEvent; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.treasure.event.TreasureStartEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.HubManager; +import net.minecraft.server.v1_8_R3.ChatComponentText; +import net.minecraft.server.v1_8_R3.EntityHuman; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.EnumDifficulty; +import net.minecraft.server.v1_8_R3.IChatBaseComponent; +import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.PlayerInfoData; +import net.minecraft.server.v1_8_R3.PacketPlayOutRespawn; +import net.minecraft.server.v1_8_R3.WorldSettings.EnumGamemode; +import net.minecraft.server.v1_8_R3.WorldType; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerLoginEvent.Result; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.scoreboard.Team; + +import com.mojang.authlib.GameProfile; + +public class DisguiseCommand extends CommandBase implements Listener +{ + + private NautHashMap _disguisedPlayers = new NautHashMap<>(); + private NautHashMap _disguisedPlayersNames = new NautHashMap<>(); + private NautHashMap _disguisedPlayerDisguises = new NautHashMap<>(); + + public DisguiseCommand(HubManager plugin) + { + super(plugin, Rank.JNR_DEV, new Rank[] {Rank.YOUTUBE, Rank.TWITCH, Rank.YOUTUBE_SMALL}, "disguise"); + + plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); + } + + @Override + public void Execute(final Player caller, final String[] args) + { + if(args == null || args.length == 0) + { + if(!Plugin.GetDisguise().isDisguised(caller)) + { + UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first")); + return; + } + try + { + GameProfile profile = _disguisedPlayers.get(caller); + _disguisedPlayers.remove(caller); + _disguisedPlayerDisguises.remove(caller); + Plugin.GetDisguise().undisguise(caller); + String playerName = _disguisedPlayersNames.get(caller); + + CoreClient client = Plugin.GetClients().Get(caller); + client.setDisguisedRank(null); + client.setDisguisedAs(null); + client.setDisguised(false); + + changeName(caller, playerName, true); + + for(Player other : UtilServer.getPlayers()) + updateTabInfo(((CraftPlayer) caller).getProfile(), profile, other, false); + + Field field; + try + { + field = GameProfile.class.getDeclaredField("id"); + field.setAccessible(true); + UUID old = ((CraftPlayer) caller).getProfile().getId(); + UUID newUUID = profile.getId(); + field.set(profile, old); + field.set(((CraftPlayer) caller).getProfile(), newUUID); + } + catch(Exception e) + { + e.printStackTrace(); + } + + PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); + UtilPlayer.sendPacket(caller, packet); + + for(Player other : UtilServer.getPlayers()) + { + for(Team team : other.getScoreboard().getTeams()) + { + team.removePlayer(caller); + } + other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); + } + + UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!")); + return; + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + if(args != null && args.length > 1) + { + UtilPlayer.message(caller, F.main("Disguise", "/disguise ")); + return; + } + + Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() + { + @Override + public void run() + { + if(Plugin.GetDisguise().isDisguised(caller)) + { + UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first")); + return; + } + for(Player other : UtilServer.getPlayers()) + { + if(other.getName().equalsIgnoreCase(args[0])) + { + UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!")); + return; + } + } + if(_disguisedPlayersNames.containsValue(args[0])) + { + UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!")); + return; + } + if(args[0].length() > 16) + { + UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0])); + return; + } + + try + { + CoreClient client = Plugin.GetClients().Get(caller); + UUID uuid = UUID.randomUUID(); + GameProfile profile = null; + try + { + uuid = UUIDFetcher.getUUIDOf(args[0]); + profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + } catch (Exception e) + { + uuid = UUID.randomUUID(); + profile = new ProfileLoader(null, args[0]).loadProfile(); + } + + Rank otherRank = Rank.ALL; + try + { + CoreClient other = new CoreClient(args[0]); + Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); + otherRank = other.GetRank(); + } catch(NullPointerException exception) + {} + if(otherRank.has(Rank.TWITCH)) + { + UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff!")); + return; + } + _disguisedPlayers.put(caller, profile); + _disguisedPlayersNames.put(caller, caller.getName()); + client.setDisguisedRank(otherRank); + client.setDisguised(true); + + client.setDisguisedAs(args[0]); + + changeName(caller, args[0], true); + + Plugin.GetGadget().removeGadgetType(caller, GadgetType.Item); + + Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller)); + UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + args[0])); + + Field field; + try + { + field = GameProfile.class.getDeclaredField("id"); + field.setAccessible(true); + UUID old = ((CraftPlayer) caller).getProfile().getId(); + UUID newUUID = profile.getId(); + field.set(profile, old); + field.set(((CraftPlayer) caller).getProfile(), newUUID); + } + catch(Exception e) + { + e.printStackTrace(); + } + + PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); + UtilPlayer.sendPacket(caller, packet); + + tablistRefresh(caller); + } catch(Exception e) + { + e.printStackTrace(); + UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0])); + return; + } + } + }); + } + + @EventHandler + public void refreshTabNames(UpdateEvent event) + { + if(event.getType() != UpdateType.FAST) + return; + + for(Player player : _disguisedPlayers.keySet()) + { + if(!player.isOnline()) + return; + + tablistRefresh(player); + } + } + + public void tablistRefresh(Player player) + { + for (Player other : UtilServer.getPlayers()) + { + if (player.canSee(other)) + { + updateTabInfo(_disguisedPlayers.get(player), ((CraftPlayer) player).getProfile(), other, false); + } + } + } + + public void updateTabInfo(GameProfile profileToAdd, GameProfile profileToRemove, Player target, boolean refreshOnly) + { + ChatColor team = ChatColor.WHITE; + Player player = Bukkit.getPlayer(profileToAdd.getName()); + EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); + String tag = Plugin.GetClients().Get(player).GetRank().getTag(true, true) + " "; + if(Plugin.GetClients().Get(player).isDisguised()) + { + tag = Plugin.GetClients().Get(player).getDisguisedRank().getTag(true, true) + " "; + } + + IChatBaseComponent component = new ChatComponentText(tag + team + player.getName()); + + if(!refreshOnly) + { + PacketPlayOutPlayerInfo removePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); + PlayerInfoData removeData = removePacket.new PlayerInfoData(profileToRemove, entityPlayer.ping, EnumGamemode.SURVIVAL, component); + removePacket.b.add(removeData); + UtilPlayer.sendPacket(target, removePacket); + + PacketPlayOutPlayerInfo addPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER); + PlayerInfoData addData = addPacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component); + addPacket.b.add(addData); + UtilPlayer.sendPacket(target, addPacket); + } + + PacketPlayOutPlayerInfo updatePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.UPDATE_DISPLAY_NAME); + PlayerInfoData updateData = updatePacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component); + updatePacket.b.add(updateData); + UtilPlayer.sendPacket(target, updatePacket); + } + + @EventHandler + public void updateDisguises(UpdateEvent event) + { + if(event.getType() != UpdateType.FASTEST) + return; + + for(final Player player : UtilServer.getPlayers()) + { + if(!_disguisedPlayers.containsKey(player)) + continue; + + for(Player other : UtilServer.getPlayers()) + { + try + { + if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).getPlayers().contains(player)) + { + other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).removePlayer(player); + other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); + } + } catch(NullPointerException exp) + {} + } + + if(Plugin.GetDisguise().isDisguised(player)) + continue; + + DisguisePlayer playerDisguise = new DisguisePlayer(player, _disguisedPlayers.get(player)); + _disguisedPlayerDisguises.put(player, playerDisguise); + Plugin.GetDisguise().disguise(playerDisguise); + } + } + + public void changeName(final Player player, String changedName, boolean skin) + { + try + { + GameProfile gameProfile = ((CraftPlayer) player).getProfile(); + + Field name = GameProfile.class.getDeclaredField("name"); + name.setAccessible(true); + name.set(gameProfile, changedName); + name.setAccessible(false); + + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void Quit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + + if(_disguisedPlayers.containsKey(player)) + { + try + { + _disguisedPlayers.remove(player); + _disguisedPlayerDisguises.remove(player); + Plugin.GetDisguise().undisguise(player); + String playerName = _disguisedPlayersNames.get(player); + _disguisedPlayersNames.remove(player); + + CoreClient client = Plugin.GetClients().Get(player); + client.setDisguisedRank(null); + client.setDisguisedAs(null); + client.setDisguised(false); + + changeName(player, playerName, true); + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void Join(PlayerLoginEvent event) + { + for(Player player : _disguisedPlayers.keySet()) + { + if(player.getName().equalsIgnoreCase(event.getPlayer().getName())) + { + event.disallow(Result.KICK_OTHER, "There is already the same account playing. this probably happened because of /disguise"); + } + } + } + + @EventHandler + public void gadget(GadgetEnableEvent event) + { + if(!event.getGadget().GetName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.Morph) + return; + + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void chest(TreasureStartEvent event) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("Disguise", "You cant open Treasure Chests while you are disguised!")); + event.setCancelled(true); + } + } + + @EventHandler + public void onPlayerSneak(PlayerToggleSneakEvent event) + { + Player player = event.getPlayer(); + + if(_disguisedPlayers.containsKey(player)) + { + DisguisePlayer dp = _disguisedPlayerDisguises.get(player); + + dp.setSneaking(!dp.getSneaking()); + } + } + + @EventHandler + public void onPlayerLeftClick(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) + { + if(_disguisedPlayers.containsKey(player)) + { + EntityHuman human = (((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); + human.world.broadcastEntityEffect(human, (byte) 0); + } + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onDPlayerChat(AsyncPlayerChatEvent event) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + event.setFormat(" *" + event.getMessage()); + } + } + + @EventHandler + public void on(PlayerInteractEvent event) + { + if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + + Player player = event.getPlayer(); + + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); + packet.a = player.getEntityId(); + + for(Player p : Bukkit.getOnlinePlayers()) + { + if(p != player) + { + Plugin.getPacketHandler().getPacketVerifier((Player) p).bypassProcess(packet); + } + } + } + } + } +} From 7e1b0b911061d62fcfa6f1319cda93fe6d4fb7cd Mon Sep 17 00:00:00 2001 From: Morten Date: Sat, 2 Jan 2016 03:19:39 +0100 Subject: [PATCH 19/48] Love you Sarah <3 --- .../core/disguise/DisguisePlayerBean.java | 34 ++++++++++ .../core/disguise/PlayerDisguiseManager.java | 68 +++++++++++++++++++ .../core/disguise/PlayerUndisguiseEvent.java | 31 +++++++++ .../core/message/commands/AdminCommand.java | 8 ++- .../src/mineplex/hub/HubManager.java | 3 +- .../hub/commands/DisguiseCommand.java | 2 + .../serverdata/redis/RedisDataRepository.java | 1 + .../nautilus/game/arcade/ArcadeManager.java | 3 + .../game/arcade/command/DisguiseCommand.java | 2 + 9 files changed, 150 insertions(+), 2 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguisePlayerBean.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerUndisguiseEvent.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguisePlayerBean.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguisePlayerBean.java new file mode 100644 index 000000000..3403768bb --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguisePlayerBean.java @@ -0,0 +1,34 @@ +package mineplex.core.disguise; + +import mineplex.serverdata.data.Data; + +public class DisguisePlayerBean implements Data +{ + private int _accountID; + private String _disguisedPlayer; + private String _playerName; + public DisguisePlayerBean(int playerAccountID, String playerName, String disguiseAs) + { + this._accountID = playerAccountID; + this._disguisedPlayer = disguiseAs; + this._playerName = playerName; + + } + public int getAccountID() + { + return _accountID; + } + public String getDisguisedPlayer() + { + return _disguisedPlayer; + } + public String getPlayerName() + { + return _playerName; + } + @Override + public String getDataId() + { + return _accountID+_playerName; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java new file mode 100644 index 000000000..d7edc247a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java @@ -0,0 +1,68 @@ +package mineplex.core.disguise; + +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.serverdata.Region; +import mineplex.serverdata.redis.RedisDataRepository; + +public class PlayerDisguiseManager extends MiniPlugin +{ + private CoreClientManager _clients; + private RedisDataRepository _redis; + public PlayerDisguiseManager(JavaPlugin plugin, CoreClientManager clients) + { + super("Player Disguise Manager", plugin); + this._clients = clients; + + _redis = new RedisDataRepository(Region.ALL, DisguisePlayerBean.class, "disguisedPlayer"); + } + + @EventHandler + public void onDisguisedPlayerQuit(PlayerQuitEvent event) + { + CoreClient client = _clients.Get(event.getPlayer()); + if(client.isDisguised()) + { + _redis.addElement(new DisguisePlayerBean(client.getAccountId(), client.GetPlayerName(), client.getDisguisedAs()), 60*60*12); // 12 hours + } + } + + @EventHandler + public void onDisguisedPlayerJoin(PlayerJoinEvent event) + { + new BukkitRunnable() + { + @Override + public void run() + { + CoreClient client = _clients.Get(event.getPlayer()); + + if(!client.GetRank().has(Rank.JNR_DEV) && client.GetRank() != Rank.YOUTUBE_SMALL && client.GetRank() != Rank.TWITCH && client.GetRank() != Rank.YOUTUBE) + return; + + if(_redis.elementExists(client.getAccountId()+client.GetPlayerName())) + { + DisguisePlayerBean bean = _redis.getElement(client.getAccountId()+client.GetPlayerName()); + Bukkit.getPluginManager().callEvent(new PlayerCommandPreprocessEvent(event.getPlayer(), "/Disguise " + bean.getDisguisedPlayer())); + } + } + }.runTaskLater(getPlugin(), 7); + } + + @EventHandler + public void onPlayerUndisguise(PlayerUndisguiseEvent event) + { + CoreClient client = _clients.Get(event.getPlayer()); + _redis.removeElement(client.getAccountId()+client.GetPlayerName()); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerUndisguiseEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerUndisguiseEvent.java new file mode 100644 index 000000000..ad8d9a9d0 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerUndisguiseEvent.java @@ -0,0 +1,31 @@ +package mineplex.core.disguise; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PlayerUndisguiseEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + private Player _player; + public PlayerUndisguiseEvent(Player disguisee) + { + this._player = disguisee; + } + + public Player getPlayer() + { + return _player; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java index 5735a2dc4..f9c2242d1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java @@ -10,6 +10,7 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.message.MessageManager; +import mineplex.core.visibility.VisibilityManager; public class AdminCommand extends CommandBase { @@ -52,7 +53,12 @@ public class AdminCommand extends CommandBase { if (!to.equals(caller)) UtilPlayer.message(to, F.rank(Plugin.GetClientManager().Get(caller).GetRank()) + " " + caller.getName() + " " + C.cPurple + message); - + + if(Plugin.GetClientManager().Get(to).GetRank().has(Rank.JNR_DEV)) + { + if(Plugin.GetClientManager().Get(to).isDisguised() || !caller.canSee(to)) + continue; + } staff = true; //Sound diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 55d00076d..24be3b3dc 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -33,6 +33,7 @@ import mineplex.core.common.util.UtilWorld; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.PlayerDisguiseManager; import mineplex.core.disguise.disguises.DisguiseSlime; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; @@ -249,7 +250,7 @@ public class HubManager extends MiniClientPlugin // _halloweenManager = new HalloweenSpookinessManager(this); new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager); - + new PlayerDisguiseManager(plugin, _clientManager); // NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager); // new MailManager(_plugin, notificationManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java index 84439b77d..2fc0346ab 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java @@ -13,6 +13,7 @@ import mineplex.core.common.util.ProfileLoader; import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.PlayerUndisguiseEvent; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.types.GadgetType; @@ -83,6 +84,7 @@ public class DisguiseCommand extends CommandBase implements Listener _disguisedPlayerDisguises.remove(caller); Plugin.GetDisguise().undisguise(caller); String playerName = _disguisedPlayersNames.get(caller); + Plugin.getPluginManager().callEvent(new PlayerUndisguiseEvent(caller)); CoreClient client = Plugin.GetClients().Get(caller); client.setDisguisedRank(null); diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisDataRepository.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisDataRepository.java index a49de5b64..caea6188b 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisDataRepository.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisDataRepository.java @@ -55,6 +55,7 @@ public class RedisDataRepository implements DataRepository _region = region; _elementType = elementType; _elementLabel = elementLabel; + } public RedisDataRepository(ConnectionData conn, Region region, Class elementType, String elementLabel) 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 943be1a3e..db787f98e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -3,6 +3,7 @@ package nautilus.game.arcade; import java.io.File; import java.util.ArrayList; import java.util.HashSet; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -51,6 +52,7 @@ import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.creature.Creature; import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.PlayerDisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.elo.EloManager; import mineplex.core.energy.Energy; @@ -291,6 +293,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager); new HolidayManager(this, titanGiveaway); new GameTestingManager(this); + new PlayerDisguiseManager(plugin, _clientManager); // Game Addons new CompassAddon(plugin, this); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java index ba13306e0..c8f9f5a9a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java @@ -13,6 +13,7 @@ import mineplex.core.common.util.ProfileLoader; import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.PlayerUndisguiseEvent; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.types.GadgetType; @@ -86,6 +87,7 @@ public class DisguiseCommand extends CommandBase implements Liste _disguisedPlayerDisguises.remove(caller); Plugin.GetDisguise().undisguise(caller); String playerName = _disguisedPlayersNames.get(caller); + Plugin.getPluginManager().callEvent(new PlayerUndisguiseEvent(caller)); CoreClient client = Plugin.GetClients().Get(caller); client.setDisguisedRank(null); From dd6d7b1b96947a400911bc5fa310039ab147c159 Mon Sep 17 00:00:00 2001 From: Sarah Date: Sat, 2 Jan 2016 16:45:15 +0100 Subject: [PATCH 20/48] updating denial message --- .../src/mineplex/hub/commands/DisguiseCommand.java | 2 +- .../src/nautilus/game/arcade/command/DisguiseCommand.java | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java index 2fc0346ab..a74c4e858 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java @@ -190,7 +190,7 @@ public class DisguiseCommand extends CommandBase implements Listener {} if(otherRank.has(Rank.TWITCH)) { - UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff!")); + UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff, Youtubers or Twitchers!")); return; } _disguisedPlayers.put(caller, profile); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java index c8f9f5a9a..873adf239 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java @@ -29,13 +29,11 @@ import net.minecraft.server.v1_8_R3.EnumDifficulty; import net.minecraft.server.v1_8_R3.IChatBaseComponent; import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; -import net.minecraft.server.v1_8_R3.WorldType; import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction; import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.PlayerInfoData; import net.minecraft.server.v1_8_R3.PacketPlayOutRespawn; -import net.minecraft.server.v1_8_R3.PacketPlayOutWindowData; -import net.minecraft.server.v1_8_R3.PacketPlayOutWorldEvent; import net.minecraft.server.v1_8_R3.WorldSettings.EnumGamemode; +import net.minecraft.server.v1_8_R3.WorldType; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -193,7 +191,7 @@ public class DisguiseCommand extends CommandBase implements Liste {} if(otherRank.has(Rank.TWITCH)) { - UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff!")); + UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff, Youtubers or Twitchers!")); return; } _disguisedPlayers.put(caller, profile); From 03c6395a30245dd6b5a050336deb21fc2affc445 Mon Sep 17 00:00:00 2001 From: Thanos paravantis Date: Sat, 2 Jan 2016 23:30:27 +0200 Subject: [PATCH 21/48] Turf Wars: Fix sneaking near turf edge and wool placement near ladders. --- .gitignore | 2 + .../game/games/turfforts/TurfForts.java | 46 +++++++++++++++++-- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 36fe02146..3a4cc1661 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,5 @@ zSotanna2 /.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/segments_1 /.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/write.lock /Pocket +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_ +/RemoteSystemsTempFiles diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java index 9494c868e..010d1a86c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java @@ -4,7 +4,6 @@ import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.UUID; @@ -19,13 +18,13 @@ import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArrow; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Arrow; -import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityShootBowEvent; @@ -34,8 +33,6 @@ import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerQuitEvent; -import net.minecraft.server.v1_8_R3.EntityArrow; -import net.minecraft.server.v1_8_R3.Item; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; @@ -53,7 +50,6 @@ import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; @@ -694,6 +690,32 @@ public class TurfForts extends TeamGame continue; Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); + + // Apply velocity even if the player is sneaking near turf edges. + + if (block.isEmpty()) + { + Block[] nearby = { + block.getRelative(BlockFace.NORTH), + block.getRelative(BlockFace.SOUTH), + block.getRelative(BlockFace.WEST), + block.getRelative(BlockFace.EAST), + block.getRelative(BlockFace.NORTH_EAST), + block.getRelative(BlockFace.NORTH_WEST), + block.getRelative(BlockFace.SOUTH_EAST), + block.getRelative(BlockFace.SOUTH_WEST) + }; + + for (Block near : nearby) + { + if (near.getTypeId() == 159) + { + block = near; + break; + } + } + } + while (block.getTypeId() != 159 && block.getY() > 0) block = block.getRelative(BlockFace.DOWN); @@ -815,4 +837,18 @@ public class TurfForts extends TeamGame { return _enemyTurf.get(player); } + + @EventHandler + public void onBlockPhysics(BlockPhysicsEvent event) + { + if (!IsLive()) + return; + + Block block = event.getBlock(); + + if (block.getType() == Material.LADDER) + { + event.setCancelled(true); + } + } } From f6ce98f65b1ed3d903691d7478404b8af855274d Mon Sep 17 00:00:00 2001 From: Thanos paravantis Date: Sat, 2 Jan 2016 23:33:08 +0200 Subject: [PATCH 22/48] Turf Wars: Add comment on block physics event. --- .../nautilus/game/arcade/game/games/turfforts/TurfForts.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java index 010d1a86c..3c477c9c6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java @@ -838,6 +838,8 @@ public class TurfForts extends TeamGame return _enemyTurf.get(player); } + // Keep ladders placed on ice when block updates occur. + @EventHandler public void onBlockPhysics(BlockPhysicsEvent event) { From 47c78bcba184cb244af0783ec8bbfec362d50294 Mon Sep 17 00:00:00 2001 From: Thanos paravantis Date: Mon, 4 Jan 2016 17:19:40 +0200 Subject: [PATCH 23/48] Turf Wars: Apply knockback on all players when there are only two in the match. --- .gitignore | 1 + .../game/games/turfforts/TurfForts.java | 528 +++++++----------- 2 files changed, 211 insertions(+), 318 deletions(-) diff --git a/.gitignore b/.gitignore index 3a4cc1661..eff674339 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,4 @@ zSotanna2 /Pocket /.recommenders/index/http___download_eclipse_org_recommenders_models_mars_ /RemoteSystemsTempFiles +/.recommenders/caches diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java index 3c477c9c6..c33335dc4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java @@ -62,34 +62,28 @@ import nautilus.game.arcade.stats.BlockShreadStatTracker; import nautilus.game.arcade.stats.TheComebackStatTracker; import net.minecraft.server.v1_8_R3.EntityArrow; -public class TurfForts extends TeamGame -{ - public static class ShredBlockEvent extends BlockEvent - { +public class TurfForts extends TeamGame { + public static class ShredBlockEvent extends BlockEvent { private static final HandlerList handlers = new HandlerList(); - public static HandlerList getHandlerList() - { + public static HandlerList getHandlerList() { return handlers; } @Override - public HandlerList getHandlers() - { + public HandlerList getHandlers() { return getHandlerList(); } private final Arrow _arrow; - public ShredBlockEvent(Block theBlock, Arrow arrow) - { + public ShredBlockEvent(Block theBlock, Arrow arrow) { super(theBlock); _arrow = arrow; } - public Arrow getArrow() - { + public Arrow getArrow() { return _arrow; } } @@ -110,29 +104,18 @@ public class TurfForts extends TeamGame private long _fightTime = 90000; private boolean _fight = false; private int _lines = 0; - + private HashMap _enemyTurf = new HashMap(); - + private Set playersThatNeedBlocks = new HashSet(); - - public TurfForts(ArcadeManager manager) - { + + public TurfForts(ArcadeManager manager) { super(manager, GameType.TurfWars, - new Kit[] - { - new KitMarksman(manager), - new KitInfiltrator(manager), - new KitShredder(manager), - }, + new Kit[] { new KitMarksman(manager), new KitInfiltrator(manager), new KitShredder(manager), }, - new String[] - { - "You have 30 seconds to build your Fort!", - "", - "Each kill advances your turf forwards.", - "Take over all the turf to win!" - }); + new String[] { "You have 30 seconds to build your Fort!", "", "Each kill advances your turf forwards.", + "Take over all the turf to win!" }); this.StrictAntiHack = true; this.HungerSet = 20; @@ -144,16 +127,12 @@ public class TurfForts extends TeamGame this.DamageSelf = false; this.DeathSpectateSecs = 4; - registerStatTrackers( - new BlockShreadStatTracker(this), - new BehindEnemyLinesStatTracker(this), - new TheComebackStatTracker(this) - ); + registerStatTrackers(new BlockShreadStatTracker(this), new BehindEnemyLinesStatTracker(this), + new TheComebackStatTracker(this)); } @Override - public void ParseData() - { + public void ParseData() { _turf = WorldData.GetDataLocs("YELLOW"); _red = WorldData.GetDataLocs("RED").get(0); @@ -162,15 +141,18 @@ public class TurfForts extends TeamGame _blue = WorldData.GetDataLocs("BLUE").get(0); _blueBase = WorldData.GetDataLocs("LIGHT_BLUE").get(0); - if (_red.getBlockX() > _blue.getBlockX()) xRed = 1; - else if (_red.getBlockX() < _blue.getBlockX()) xRed = -1; + if (_red.getBlockX() > _blue.getBlockX()) + xRed = 1; + else if (_red.getBlockX() < _blue.getBlockX()) + xRed = -1; - if (_red.getBlockZ() > _blue.getBlockZ()) zRed = 1; - else if (_red.getBlockZ() < _blue.getBlockZ()) zRed = -1; + if (_red.getBlockZ() > _blue.getBlockZ()) + zRed = 1; + else if (_red.getBlockZ() < _blue.getBlockZ()) + zRed = -1; - //Color Turf - for (Location loc : _turf) - { + // Color Turf + for (Location loc : _turf) { if (UtilMath.offset(loc, _red) < UtilMath.offset(loc, _blue)) MapUtil.QuickChangeBlockAt(loc, 159, (byte) 14); else @@ -179,8 +161,7 @@ public class TurfForts extends TeamGame } @EventHandler - public void PlayerKillAward(CombatDeathEvent event) - { + public void PlayerKillAward(CombatDeathEvent event) { if (!(event.GetEvent().getEntity() instanceof Player)) return; @@ -202,26 +183,19 @@ public class TurfForts extends TeamGame if (GetTeam(killer).equals(GetTeam(killed))) return; - if (GetTeam(killer).GetColor() == ChatColor.RED) - { + if (GetTeam(killer).GetColor() == ChatColor.RED) { TurfMove(true); - } - else - { + } else { TurfMove(false); } } - private void TurfMove(boolean red) - { - for (int line = 0; line < GetLinesPerKill(); line++) - { - if (red) - { + private void TurfMove(boolean red) { + for (int line = 0; line < GetLinesPerKill(); line++) { + if (red) { if (xRed != 0) for (Location loc : _turf) - if (loc.getBlockX() == _blue.getBlockX()) - { + if (loc.getBlockX() == _blue.getBlockX()) { MapUtil.QuickChangeBlockAt(loc, 159, (byte) 14); for (int i = 1; i < 6; i++) @@ -229,11 +203,9 @@ public class TurfForts extends TeamGame MapUtil.QuickChangeBlockAt(loc.clone().add(0, i, 0), 0, (byte) 0); } - if (zRed != 0) for (Location loc : _turf) - if (loc.getBlockZ() == _blue.getBlockZ()) - { + if (loc.getBlockZ() == _blue.getBlockZ()) { MapUtil.QuickChangeBlockAt(loc, 159, (byte) 14); for (int i = 1; i < 6; i++) @@ -243,13 +215,10 @@ public class TurfForts extends TeamGame _red.subtract(xRed, 0, zRed); _blue.subtract(xRed, 0, zRed); - } - else - { + } else { if (xRed != 0) for (Location loc : _turf) - if (loc.getBlockX() == _red.getBlockX()) - { + if (loc.getBlockX() == _red.getBlockX()) { MapUtil.QuickChangeBlockAt(loc, 159, (byte) 3); for (int i = 1; i < 6; i++) @@ -259,8 +228,7 @@ public class TurfForts extends TeamGame if (zRed != 0) for (Location loc : _turf) - if (loc.getBlockZ() == _red.getBlockZ()) - { + if (loc.getBlockZ() == _red.getBlockZ()) { MapUtil.QuickChangeBlockAt(loc, 159, (byte) 3); for (int i = 1; i < 6; i++) @@ -275,94 +243,84 @@ public class TurfForts extends TeamGame EndCheck(); } } - + @EventHandler - public void BowCancel(EntityShootBowEvent event) - { - if (!_fight) - { + public void BowCancel(EntityShootBowEvent event) { + if (!_fight) { UtilPlayer.message(event.getEntity(), F.main("Game", "You cannot attack during Build Time!")); event.setCancelled(true); - + ((Player) event.getEntity()).updateInventory(); } } @EventHandler - public void BlockBreak(BlockBreakEvent event) - { - if (event.isCancelled()) // this statement might save just a small amount of time + public void BlockBreak(BlockBreakEvent event) { + if (event.isCancelled()) // this statement might save just a small + // amount of time return; - - - - if (!IsAlive(event.getPlayer())) - { + + if (!IsAlive(event.getPlayer())) { event.setCancelled(true); return; } - if (UtilPlayer.isSpectator(event.getPlayer())) - { + if (UtilPlayer.isSpectator(event.getPlayer())) { event.setCancelled(true); return; } - + Block block = event.getBlock(); - + GameTeam team = GetTeam(event.getPlayer()); GameTeam otherTeam = GetOtherTeam(team); - if (block.getType().equals(Material.WOOL) && (block.getData() == 14 && team.GetColor() != ChatColor.RED) || (block.getData() == 3 && team.GetColor() != ChatColor.AQUA)) - { - UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot break the " + F.elem(otherTeam.GetColor() + otherTeam.GetName()) + " team's blocks!")); + if (block.getType().equals(Material.WOOL) && (block.getData() == 14 && team.GetColor() != ChatColor.RED) + || (block.getData() == 3 && team.GetColor() != ChatColor.AQUA)) { + UtilPlayer.message(event.getPlayer(), F.main("Game", + "You cannot break the " + F.elem(otherTeam.GetColor() + otherTeam.GetName()) + " team's blocks!")); event.setCancelled(true); return; } } @EventHandler(ignoreCancelled = true) - public void BlockPlace(BlockPlaceEvent event) - { - //Remoeved and replaced by ignoreCancelled = true - //if (event.isCancelled()) - // return; + public void BlockPlace(BlockPlaceEvent event) { + // Remoeved and replaced by ignoreCancelled = true + // if (event.isCancelled()) + // return; GameTeam team = GetTeam(event.getPlayer()); - if (team == null) - { + if (team == null) { event.setCancelled(true); return; } - if (!IsAlive(event.getPlayer())) - { + if (!IsAlive(event.getPlayer())) { event.setCancelled(true); return; } - if (UtilPlayer.isSpectator(event.getPlayer())) - { + if (UtilPlayer.isSpectator(event.getPlayer())) { event.setCancelled(true); return; } - - //On Own + + // On Own Block block = event.getBlock().getRelative(BlockFace.DOWN); while (block.getTypeId() == 0) block = block.getRelative(BlockFace.DOWN); - if (block.getData() != team.GetColorData()) - { - UtilPlayer.message(event.getPlayer(), F.main("Game", "You can only build above " + F.elem(team.GetColor() + team.GetName()) + ".")); + if (block.getData() != team.GetColorData()) { + UtilPlayer.message(event.getPlayer(), + F.main("Game", "You can only build above " + F.elem(team.GetColor() + team.GetName()) + ".")); event.setCancelled(true); return; } - //Height + // Height boolean aboveTurf = false; - for (int i = 1; i <= 5; i++) - { + for (int i = 1; i <= 5; i++) { if (event.getBlock().getRelative(BlockFace.DOWN, i).getTypeId() != 159) continue; @@ -370,8 +328,7 @@ public class TurfForts extends TeamGame break; } - if (!aboveTurf) - { + if (!aboveTurf) { UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot build this high above Turf.")); event.setCancelled(true); return; @@ -379,8 +336,7 @@ public class TurfForts extends TeamGame } @EventHandler - public void BlockDamage(ProjectileHitEvent event) - { + public void BlockDamage(ProjectileHitEvent event) { if (event.getEntity().getShooter() == null) return; @@ -397,12 +353,9 @@ public class TurfForts extends TeamGame final Arrow arrow = (Arrow) event.getEntity(); - Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() - { - public void run() - { - try - { + Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() { + public void run() { + try { EntityArrow entityArrow = ((CraftArrow) arrow).getHandle(); Field fieldX = EntityArrow.class.getDeclaredField("d"); @@ -418,28 +371,29 @@ public class TurfForts extends TeamGame int z = fieldZ.getInt(entityArrow); Block block = arrow.getWorld().getBlockAt(x, y, z); - - if (block.getTypeId() == 35) - { - if (block.getData() == 14 /* && team.GetColor() != ChatColor.RED */) - { - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK.getId()); + + if (block.getTypeId() == 35) { + if (block.getData() == 14 /* + * && team.GetColor() != + * ChatColor.RED + */) { + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, + Material.REDSTONE_BLOCK.getId()); + } else if (block.getData() == 3 /* + * && team.GetColor() != + * ChatColor.AQUA + */) { + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, + Material.LAPIS_BLOCK.getId()); } - else if (block.getData() == 3 /* && team.GetColor() != ChatColor.AQUA */) - { - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.LAPIS_BLOCK.getId()); - } - + Bukkit.getPluginManager().callEvent(new ShredBlockEvent(block, arrow)); - - + block.setType(Material.AIR); } arrow.remove(); - } - catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); } } @@ -447,64 +401,51 @@ public class TurfForts extends TeamGame } @EventHandler - public void Damage(CustomDamageEvent event) - { - if (event.GetCause() == DamageCause.FALL) - { + public void Damage(CustomDamageEvent event) { + if (event.GetCause() == DamageCause.FALL) { event.SetCancelled("No Fall"); return; } - if (!_fight && (event.GetCause() == DamageCause.PROJECTILE || event.GetCause() == DamageCause.ENTITY_ATTACK)) - { + if (!_fight && (event.GetCause() == DamageCause.PROJECTILE || event.GetCause() == DamageCause.ENTITY_ATTACK)) { event.SetCancelled("Build Time"); return; } Player damager = event.GetDamagerPlayer(true); - if (damager == null) return; + if (damager == null) + return; - if (event.GetCause() == DamageCause.PROJECTILE) - { + if (event.GetCause() == DamageCause.PROJECTILE) { event.AddMod("Turf Forts", "Nullify", -event.GetDamageInitial(), false); - if (GetKit(damager).GetName().contains("Shredder")) - { + if (GetKit(damager).GetName().contains("Shredder")) { event.SetCancelled("Shredder"); - Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), damager, null, - DamageCause.CUSTOM, 9, true, true, false, - damager.getName(), "Barrage"); + Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), damager, null, DamageCause.CUSTOM, 9, true, + true, false, damager.getName(), "Barrage"); return; - } - else - { + } else { event.AddMod("Turf Forts", "One Hit Kill", 30, false); } - } - else if (event.GetCause() == DamageCause.ENTITY_ATTACK) - { + } else if (event.GetCause() == DamageCause.ENTITY_ATTACK) { event.AddMod("Turf Forts", "Nullify", -event.GetDamageInitial(), false); - if (UtilGear.isMat(damager.getItemInHand(), Material.IRON_SWORD)) - { + if (UtilGear.isMat(damager.getItemInHand(), Material.IRON_SWORD)) { event.AddMod("Turf Forts", "One Hit Kill", 12, false); - } - else - { + } else { event.AddMod("Turf Forts", "One Hit Kill", 6, false); } } } @EventHandler - public void ScoreboardTitle(UpdateEvent event) - { + public void ScoreboardTitle(UpdateEvent event) { if (GetState() != GameState.Live) return; - //2x Initial Build + // 2x Initial Build if (_phaseTime == 0) _phaseTime = System.currentTimeMillis() + _buildTime; @@ -512,48 +453,42 @@ public class TurfForts extends TeamGame return; long time; - if (!_fight) - { + if (!_fight) { time = _buildTime - (System.currentTimeMillis() - _phaseTime); - if (time <= 0) - { + if (time <= 0) { _fight = true; _lines++; Announce(" "); - Announce(C.cWhite + C.Bold + "1 Kill" + C.cWhite + C.Bold + " = " + C.cWhite + C.Bold + GetLinesPerKill() + " Turf Lines"); - Announce(C.cWhite + C.Bold + "90 Seconds of " + C.cYellow + C.Bold + "Combat Time" + C.cWhite + C.Bold + " has begun!"); + Announce(C.cWhite + C.Bold + "1 Kill" + C.cWhite + C.Bold + " = " + C.cWhite + C.Bold + + GetLinesPerKill() + " Turf Lines"); + Announce(C.cWhite + C.Bold + "90 Seconds of " + C.cYellow + C.Bold + "Combat Time" + C.cWhite + C.Bold + + " has begun!"); Announce(" "); _phaseTime = System.currentTimeMillis(); } } - else - { + else { time = _fightTime - (System.currentTimeMillis() - _phaseTime); - if (time <= 0) - { + if (time <= 0) { _fight = false; Announce(" "); - Announce(C.cWhite + C.Bold + "20 Seconds of " + C.cGreen + C.Bold + "Build Time" + C.cWhite + C.Bold + " has begun!"); + Announce(C.cWhite + C.Bold + "20 Seconds of " + C.cGreen + C.Bold + "Build Time" + C.cWhite + C.Bold + + " has begun!"); Announce(" "); _phaseTime = System.currentTimeMillis(); - for (GameTeam team : GetTeamList()) - { - for (Player player : team.GetPlayers(true)) - { - if (UtilPlayer.isSpectator(player)) - { + for (GameTeam team : GetTeamList()) { + for (Player player : team.GetPlayers(true)) { + if (UtilPlayer.isSpectator(player)) { this.playersThatNeedBlocks.add(player.getUniqueId()); - } - else - { + } else { addBlocks(team, player); } } @@ -561,52 +496,45 @@ public class TurfForts extends TeamGame } } } - - public void addBlocks(GameTeam team, Player player) - { + + public void addBlocks(GameTeam team, Player player) { player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOL, team.GetColorData(), 24)); } - + @EventHandler(ignoreCancelled = true) - public void onQuit(PlayerQuitEvent event) - { + public void onQuit(PlayerQuitEvent event) { this.playersThatNeedBlocks.remove(event.getPlayer().getUniqueId()); } - + @EventHandler(ignoreCancelled = true) - public void onSpawn(PlayerKitGiveEvent event) - { + public void onSpawn(PlayerKitGiveEvent event) { Player player = event.getPlayer(); - if (this.playersThatNeedBlocks.contains(player.getUniqueId())) - { + if (this.playersThatNeedBlocks.contains(player.getUniqueId())) { this.playersThatNeedBlocks.remove(player.getUniqueId()); this.addBlocks(GetTeam(player), player); } } - - - + @Override @EventHandler - public void ScoreboardUpdate(UpdateEvent event) - { + public void ScoreboardUpdate(UpdateEvent event) { if (event.getType() != UpdateType.FAST) return; Scoreboard.Reset(); - for (GameTeam team : this.GetTeamList()) - { + for (GameTeam team : this.GetTeamList()) { int lines = 0; - if (team.GetColor() == ChatColor.RED) lines = GetRedLines(); - else lines = GetBlueLines(); + if (team.GetColor() == ChatColor.RED) + lines = GetRedLines(); + else + lines = GetBlueLines(); Scoreboard.WriteBlank(); Scoreboard.Write(lines + " " + team.GetColor() + team.GetName()); } - if (!_fight) - { + if (!_fight) { long time = _buildTime - (System.currentTimeMillis() - _phaseTime); Scoreboard.WriteBlank(); @@ -615,8 +543,7 @@ public class TurfForts extends TeamGame } - else - { + else { long time = _fightTime - (System.currentTimeMillis() - _phaseTime); Scoreboard.WriteBlank(); @@ -627,95 +554,78 @@ public class TurfForts extends TeamGame Scoreboard.Draw(); } - public int GetRedLines() - { + public int GetRedLines() { if (!InProgress()) return 0; - if (xRed != 0) - { + if (xRed != 0) { return Math.abs(_redBase.getBlockX() - _red.getBlockX()); } return Math.abs(_redBase.getBlockZ() - _red.getBlockZ()); } - public int GetBlueLines() - { + public int GetBlueLines() { if (!InProgress()) return 0; - if (xRed != 0) - { + if (xRed != 0) { return Math.abs(_blueBase.getBlockX() - _blue.getBlockX()); } return Math.abs(_blueBase.getBlockZ() - _blue.getBlockZ()); } - public int getLines(GameTeam team) - { + public int getLines(GameTeam team) { if (team.GetColor() == ChatColor.RED) return GetRedLines(); else return GetBlueLines(); } - public int GetLinesPerKill() - { + public int GetLinesPerKill() { return _lines; - //return Math.min(5, 1 + (int)((System.currentTimeMillis() - GetStateTime() - 30000) / 60000)); + // return Math.min(5, 1 + (int)((System.currentTimeMillis() - + // GetStateTime() - 30000) / 60000)); } @EventHandler - public void PlayerDeath(PlayerDeathEvent event) - { + public void PlayerDeath(PlayerDeathEvent event) { _enemyTurf.remove(event.getEntity()); } @EventHandler - public void Territory(UpdateEvent event) - { + public void Territory(UpdateEvent event) { if (!IsLive()) return; if (event.getType() != UpdateType.FASTER) return; - for (GameTeam team : this.GetTeamList()) - { - for (Player player : team.GetPlayers(true)) - { - if (((CraftPlayer) player).getHandle().spectating) - continue; - + for (GameTeam team : this.GetTeamList()) { + for (Player player : team.GetPlayers(true)) { + if (((CraftPlayer) player).getHandle().spectating) + continue; + Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); - - // Apply velocity even if the player is sneaking near turf edges. - - if (block.isEmpty()) - { - Block[] nearby = { - block.getRelative(BlockFace.NORTH), - block.getRelative(BlockFace.SOUTH), - block.getRelative(BlockFace.WEST), - block.getRelative(BlockFace.EAST), - block.getRelative(BlockFace.NORTH_EAST), - block.getRelative(BlockFace.NORTH_WEST), - block.getRelative(BlockFace.SOUTH_EAST), - block.getRelative(BlockFace.SOUTH_WEST) - }; - - for (Block near : nearby) - { - if (near.getTypeId() == 159) - { + + // Apply velocity even if the player is sneaking near turf + // edges. + + if (block.isEmpty() && player.isOnGround()) { + Block[] nearby = { block.getRelative(BlockFace.NORTH), block.getRelative(BlockFace.SOUTH), + block.getRelative(BlockFace.WEST), block.getRelative(BlockFace.EAST), + block.getRelative(BlockFace.NORTH_EAST), block.getRelative(BlockFace.NORTH_WEST), + block.getRelative(BlockFace.SOUTH_EAST), block.getRelative(BlockFace.SOUTH_WEST) }; + + for (Block near : nearby) { + if (near.getType() == Material.STAINED_CLAY || near.getType() == Material.WOOL) { block = near; break; } } } - + while (block.getTypeId() != 159 && block.getY() > 0) block = block.getRelative(BlockFace.DOWN); @@ -724,22 +634,21 @@ public class TurfForts extends TeamGame byte data = block.getData(); - //Slow - if (_enemyTurf.containsKey(player)) - { + // Slow + if (_enemyTurf.containsKey(player)) { int time = (int) ((System.currentTimeMillis() - _enemyTurf.get(player)) / 2500); if (time > 0) - Manager.GetCondition().Factory().Slow("Infiltrator Slow", player, player, 0.9, time - 1, false, false, false, false); + Manager.GetCondition().Factory().Slow("Infiltrator Slow", player, player, 0.9, time - 1, false, + false, false, false); } - //On Enemy Turf - if ((team.GetColor() == ChatColor.RED && data == 3) || (team.GetColor() == ChatColor.AQUA && data == 14)) - { + // On Enemy Turf + if ((team.GetColor() == ChatColor.RED && data == 3) + || (team.GetColor() == ChatColor.AQUA && data == 14)) { - //Infiltrate - if (_fight && GetKit(player) != null && GetKit(player).GetName().contains("Infil")) - { + // Infiltrate + if (_fight && GetKit(player) != null && GetKit(player).GetName().contains("Infil")) { if (!_enemyTurf.containsKey(player)) _enemyTurf.put(player, System.currentTimeMillis()); @@ -747,79 +656,65 @@ public class TurfForts extends TeamGame continue; } - if (Recharge.Instance.use(player, "Territory Knockback", 2000, false, false)) - { - UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), team.GetSpawn()), 2, false, 0, 0.8, 1, true); + if (Recharge.Instance.use(player, "Territory Knockback", 2000, false, false)) { + UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), team.GetSpawn()), 2, + false, 0, 0.8, 1, true); player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); UtilPlayer.message(player, F.main("Game", "You cannot walk on the enemies turf!")); } - - return; + + // Looks like that with 'return' if there are only two + // players, one of them will not get knockback. + + // return; } - //On Own Turf - else if ((team.GetColor() == ChatColor.RED && data == 14) || (team.GetColor() == ChatColor.AQUA && data == 3)) - { + // On Own Turf + else if ((team.GetColor() == ChatColor.RED && data == 14) + || (team.GetColor() == ChatColor.AQUA && data == 3)) { _enemyTurf.remove(player); } } } } - + /* - @EventHandler - public void ItemRemoval(UpdateEvent event) - { - if (!IsLive()) - return; + * @EventHandler public void ItemRemoval(UpdateEvent event) { if (!IsLive()) + * return; + * + * if (event.getType() != UpdateType.FAST) return; + * + * for (Entity ent : _red.getWorld().getEntities()) { if (!(ent instanceof + * Item)) continue; + * + * if (ent.getTicksLived() > 40) ent.remove(); } } + */ - if (event.getType() != UpdateType.FAST) - return; - - for (Entity ent : _red.getWorld().getEntities()) - { - if (!(ent instanceof Item)) - continue; - - if (ent.getTicksLived() > 40) - ent.remove(); - } - } - */ - - public GameTeam GetOtherTeam(GameTeam team) { return team.GetColor() == ChatColor.RED ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED); } - + @EventHandler public void onItem(ItemSpawnEvent e) { if (e.getEntityType().equals(EntityType.DROPPED_ITEM)) { e.setCancelled(true); } } - + @Override - public void EndCheck() - { + public void EndCheck() { if (!IsLive()) return; - if (GetRedLines() == 0 || GetTeam(ChatColor.RED).GetPlayers(true).size() == 0) - { + if (GetRedLines() == 0 || GetTeam(ChatColor.RED).GetPlayers(true).size() == 0) { AnnounceEnd(GetTeam(ChatColor.AQUA)); - } - else if (GetBlueLines() == 0 || GetTeam(ChatColor.AQUA).GetPlayers(true).size() == 0) - { + } else if (GetBlueLines() == 0 || GetTeam(ChatColor.AQUA).GetPlayers(true).size() == 0) { AnnounceEnd(GetTeam(ChatColor.RED)); - } - else + } else return; - for (GameTeam team : GetTeamList()) - { - if (WinnerTeam != null && team.equals(WinnerTeam)) - { + for (GameTeam team : GetTeamList()) { + if (WinnerTeam != null && team.equals(WinnerTeam)) { for (Player player : team.GetPlayers(false)) AddGems(player, 10, "Winning Team", false, false); } @@ -828,28 +723,25 @@ public class TurfForts extends TeamGame if (player.isOnline()) AddGems(player, 10, "Participation", false, false); } - - //End + + // End SetState(GameState.End); } - public Long getEnemyTurfEntranceTime(Player player) - { + public Long getEnemyTurfEntranceTime(Player player) { return _enemyTurf.get(player); } - + // Keep ladders placed on ice when block updates occur. - + @EventHandler - public void onBlockPhysics(BlockPhysicsEvent event) - { + public void onBlockPhysics(BlockPhysicsEvent event) { if (!IsLive()) return; - + Block block = event.getBlock(); - - if (block.getType() == Material.LADDER) - { + + if (block.getType() == Material.LADDER) { event.setCancelled(true); } } From c739ecc26d610e4a1b83f837f36eb705aa829e18 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Mon, 4 Jan 2016 14:20:39 -0500 Subject: [PATCH 24/48] Fix forcefield for YOUTUBE_SMALL --- .../src/mineplex/hub/modules/ForcefieldManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java index c52990ac1..107fd8aa6 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 && (Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE || Manager.GetClients().Get(player).GetRank() == Rank.TWITCH)) + if (Manager.getPreferences().Get(player).HubForcefield && (Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE || Manager.GetClients().Get(player).GetRank() == Rank.TWITCH || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE_SMALL)) { for (Player other : UtilServer.getPlayers()) { From c50fb52a88c8aaf9d940132af3e8dbf04406eb7c Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Mon, 4 Jan 2016 14:21:21 -0500 Subject: [PATCH 25/48] Disable New Years Countdown --- Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java | 2 -- .../src/mineplex/hub/modules/NewYearCountdown.java | 13 ------------- 2 files changed, 15 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 7cc8e7def..41b2081a3 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -184,8 +184,6 @@ public class Hub extends JavaPlugin implements IRelation //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); - - new NewYearCountdown(this); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java index 1c0766fa8..9ebd311a6 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java @@ -83,19 +83,6 @@ public class NewYearCountdown extends MiniPlugin _targetTime = System.currentTimeMillis() + (seconds * 1000); } - @EventHandler - public void cmd(PlayerCommandPreprocessEvent e) - { - if (!e.getPlayer().getName().equalsIgnoreCase("WilliamTiger")) - return; - - if (e.getMessage().equalsIgnoreCase("/lmao")) - { - e.setCancelled(true); - start(30); - } - } - @EventHandler public void updateStage(UpdateEvent e) { From 982e684a45b7e3297c52132446f652ed9ddd36c0 Mon Sep 17 00:00:00 2001 From: Thanos paravantis Date: Mon, 4 Jan 2016 21:42:58 +0200 Subject: [PATCH 26/48] Turf Wars: Undo bracket formatting. --- .../game/games/turfforts/TurfForts.java | 524 +++++++++++------- 1 file changed, 316 insertions(+), 208 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java index c33335dc4..61a89a1e5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java @@ -62,28 +62,34 @@ import nautilus.game.arcade.stats.BlockShreadStatTracker; import nautilus.game.arcade.stats.TheComebackStatTracker; import net.minecraft.server.v1_8_R3.EntityArrow; -public class TurfForts extends TeamGame { - public static class ShredBlockEvent extends BlockEvent { +public class TurfForts extends TeamGame +{ + public static class ShredBlockEvent extends BlockEvent + { private static final HandlerList handlers = new HandlerList(); - public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() + { return handlers; } @Override - public HandlerList getHandlers() { + public HandlerList getHandlers() + { return getHandlerList(); } private final Arrow _arrow; - public ShredBlockEvent(Block theBlock, Arrow arrow) { + public ShredBlockEvent(Block theBlock, Arrow arrow) + { super(theBlock); _arrow = arrow; } - public Arrow getArrow() { + public Arrow getArrow() + { return _arrow; } } @@ -104,18 +110,29 @@ public class TurfForts extends TeamGame { private long _fightTime = 90000; private boolean _fight = false; private int _lines = 0; - + private HashMap _enemyTurf = new HashMap(); - + private Set playersThatNeedBlocks = new HashSet(); - - public TurfForts(ArcadeManager manager) { + + public TurfForts(ArcadeManager manager) + { super(manager, GameType.TurfWars, - new Kit[] { new KitMarksman(manager), new KitInfiltrator(manager), new KitShredder(manager), }, + new Kit[] + { + new KitMarksman(manager), + new KitInfiltrator(manager), + new KitShredder(manager), + }, - new String[] { "You have 30 seconds to build your Fort!", "", "Each kill advances your turf forwards.", - "Take over all the turf to win!" }); + new String[] + { + "You have 30 seconds to build your Fort!", + "", + "Each kill advances your turf forwards.", + "Take over all the turf to win!" + }); this.StrictAntiHack = true; this.HungerSet = 20; @@ -127,12 +144,16 @@ public class TurfForts extends TeamGame { this.DamageSelf = false; this.DeathSpectateSecs = 4; - registerStatTrackers(new BlockShreadStatTracker(this), new BehindEnemyLinesStatTracker(this), - new TheComebackStatTracker(this)); + registerStatTrackers( + new BlockShreadStatTracker(this), + new BehindEnemyLinesStatTracker(this), + new TheComebackStatTracker(this) + ); } @Override - public void ParseData() { + public void ParseData() + { _turf = WorldData.GetDataLocs("YELLOW"); _red = WorldData.GetDataLocs("RED").get(0); @@ -141,18 +162,15 @@ public class TurfForts extends TeamGame { _blue = WorldData.GetDataLocs("BLUE").get(0); _blueBase = WorldData.GetDataLocs("LIGHT_BLUE").get(0); - if (_red.getBlockX() > _blue.getBlockX()) - xRed = 1; - else if (_red.getBlockX() < _blue.getBlockX()) - xRed = -1; + if (_red.getBlockX() > _blue.getBlockX()) xRed = 1; + else if (_red.getBlockX() < _blue.getBlockX()) xRed = -1; - if (_red.getBlockZ() > _blue.getBlockZ()) - zRed = 1; - else if (_red.getBlockZ() < _blue.getBlockZ()) - zRed = -1; + if (_red.getBlockZ() > _blue.getBlockZ()) zRed = 1; + else if (_red.getBlockZ() < _blue.getBlockZ()) zRed = -1; - // Color Turf - for (Location loc : _turf) { + //Color Turf + for (Location loc : _turf) + { if (UtilMath.offset(loc, _red) < UtilMath.offset(loc, _blue)) MapUtil.QuickChangeBlockAt(loc, 159, (byte) 14); else @@ -161,7 +179,8 @@ public class TurfForts extends TeamGame { } @EventHandler - public void PlayerKillAward(CombatDeathEvent event) { + public void PlayerKillAward(CombatDeathEvent event) + { if (!(event.GetEvent().getEntity() instanceof Player)) return; @@ -183,19 +202,26 @@ public class TurfForts extends TeamGame { if (GetTeam(killer).equals(GetTeam(killed))) return; - if (GetTeam(killer).GetColor() == ChatColor.RED) { + if (GetTeam(killer).GetColor() == ChatColor.RED) + { TurfMove(true); - } else { + } + else + { TurfMove(false); } } - private void TurfMove(boolean red) { - for (int line = 0; line < GetLinesPerKill(); line++) { - if (red) { + private void TurfMove(boolean red) + { + for (int line = 0; line < GetLinesPerKill(); line++) + { + if (red) + { if (xRed != 0) for (Location loc : _turf) - if (loc.getBlockX() == _blue.getBlockX()) { + if (loc.getBlockX() == _blue.getBlockX()) + { MapUtil.QuickChangeBlockAt(loc, 159, (byte) 14); for (int i = 1; i < 6; i++) @@ -203,9 +229,11 @@ public class TurfForts extends TeamGame { MapUtil.QuickChangeBlockAt(loc.clone().add(0, i, 0), 0, (byte) 0); } + if (zRed != 0) for (Location loc : _turf) - if (loc.getBlockZ() == _blue.getBlockZ()) { + if (loc.getBlockZ() == _blue.getBlockZ()) + { MapUtil.QuickChangeBlockAt(loc, 159, (byte) 14); for (int i = 1; i < 6; i++) @@ -215,10 +243,13 @@ public class TurfForts extends TeamGame { _red.subtract(xRed, 0, zRed); _blue.subtract(xRed, 0, zRed); - } else { + } + else + { if (xRed != 0) for (Location loc : _turf) - if (loc.getBlockX() == _red.getBlockX()) { + if (loc.getBlockX() == _red.getBlockX()) + { MapUtil.QuickChangeBlockAt(loc, 159, (byte) 3); for (int i = 1; i < 6; i++) @@ -228,7 +259,8 @@ public class TurfForts extends TeamGame { if (zRed != 0) for (Location loc : _turf) - if (loc.getBlockZ() == _red.getBlockZ()) { + if (loc.getBlockZ() == _red.getBlockZ()) + { MapUtil.QuickChangeBlockAt(loc, 159, (byte) 3); for (int i = 1; i < 6; i++) @@ -243,84 +275,94 @@ public class TurfForts extends TeamGame { EndCheck(); } } - + @EventHandler - public void BowCancel(EntityShootBowEvent event) { - if (!_fight) { + public void BowCancel(EntityShootBowEvent event) + { + if (!_fight) + { UtilPlayer.message(event.getEntity(), F.main("Game", "You cannot attack during Build Time!")); event.setCancelled(true); - + ((Player) event.getEntity()).updateInventory(); } } @EventHandler - public void BlockBreak(BlockBreakEvent event) { - if (event.isCancelled()) // this statement might save just a small - // amount of time + public void BlockBreak(BlockBreakEvent event) + { + if (event.isCancelled()) // this statement might save just a small amount of time return; - - if (!IsAlive(event.getPlayer())) { + + + + if (!IsAlive(event.getPlayer())) + { event.setCancelled(true); return; } - if (UtilPlayer.isSpectator(event.getPlayer())) { + if (UtilPlayer.isSpectator(event.getPlayer())) + { event.setCancelled(true); return; } - + Block block = event.getBlock(); - + GameTeam team = GetTeam(event.getPlayer()); GameTeam otherTeam = GetOtherTeam(team); - if (block.getType().equals(Material.WOOL) && (block.getData() == 14 && team.GetColor() != ChatColor.RED) - || (block.getData() == 3 && team.GetColor() != ChatColor.AQUA)) { - UtilPlayer.message(event.getPlayer(), F.main("Game", - "You cannot break the " + F.elem(otherTeam.GetColor() + otherTeam.GetName()) + " team's blocks!")); + if (block.getType().equals(Material.WOOL) && (block.getData() == 14 && team.GetColor() != ChatColor.RED) || (block.getData() == 3 && team.GetColor() != ChatColor.AQUA)) + { + UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot break the " + F.elem(otherTeam.GetColor() + otherTeam.GetName()) + " team's blocks!")); event.setCancelled(true); return; } } @EventHandler(ignoreCancelled = true) - public void BlockPlace(BlockPlaceEvent event) { - // Remoeved and replaced by ignoreCancelled = true - // if (event.isCancelled()) - // return; + public void BlockPlace(BlockPlaceEvent event) + { + //Remoeved and replaced by ignoreCancelled = true + //if (event.isCancelled()) + // return; GameTeam team = GetTeam(event.getPlayer()); - if (team == null) { + if (team == null) + { event.setCancelled(true); return; } - if (!IsAlive(event.getPlayer())) { + if (!IsAlive(event.getPlayer())) + { event.setCancelled(true); return; } - if (UtilPlayer.isSpectator(event.getPlayer())) { + if (UtilPlayer.isSpectator(event.getPlayer())) + { event.setCancelled(true); return; } - - // On Own + + //On Own Block block = event.getBlock().getRelative(BlockFace.DOWN); while (block.getTypeId() == 0) block = block.getRelative(BlockFace.DOWN); - if (block.getData() != team.GetColorData()) { - UtilPlayer.message(event.getPlayer(), - F.main("Game", "You can only build above " + F.elem(team.GetColor() + team.GetName()) + ".")); + if (block.getData() != team.GetColorData()) + { + UtilPlayer.message(event.getPlayer(), F.main("Game", "You can only build above " + F.elem(team.GetColor() + team.GetName()) + ".")); event.setCancelled(true); return; } - // Height + //Height boolean aboveTurf = false; - for (int i = 1; i <= 5; i++) { + for (int i = 1; i <= 5; i++) + { if (event.getBlock().getRelative(BlockFace.DOWN, i).getTypeId() != 159) continue; @@ -328,7 +370,8 @@ public class TurfForts extends TeamGame { break; } - if (!aboveTurf) { + if (!aboveTurf) + { UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot build this high above Turf.")); event.setCancelled(true); return; @@ -336,7 +379,8 @@ public class TurfForts extends TeamGame { } @EventHandler - public void BlockDamage(ProjectileHitEvent event) { + public void BlockDamage(ProjectileHitEvent event) + { if (event.getEntity().getShooter() == null) return; @@ -353,9 +397,12 @@ public class TurfForts extends TeamGame { final Arrow arrow = (Arrow) event.getEntity(); - Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() { - public void run() { - try { + Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() + { + public void run() + { + try + { EntityArrow entityArrow = ((CraftArrow) arrow).getHandle(); Field fieldX = EntityArrow.class.getDeclaredField("d"); @@ -371,29 +418,28 @@ public class TurfForts extends TeamGame { int z = fieldZ.getInt(entityArrow); Block block = arrow.getWorld().getBlockAt(x, y, z); - - if (block.getTypeId() == 35) { - if (block.getData() == 14 /* - * && team.GetColor() != - * ChatColor.RED - */) { - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, - Material.REDSTONE_BLOCK.getId()); - } else if (block.getData() == 3 /* - * && team.GetColor() != - * ChatColor.AQUA - */) { - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, - Material.LAPIS_BLOCK.getId()); + + if (block.getTypeId() == 35) + { + if (block.getData() == 14 /* && team.GetColor() != ChatColor.RED */) + { + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK.getId()); } - + else if (block.getData() == 3 /* && team.GetColor() != ChatColor.AQUA */) + { + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.LAPIS_BLOCK.getId()); + } + Bukkit.getPluginManager().callEvent(new ShredBlockEvent(block, arrow)); - + + block.setType(Material.AIR); } arrow.remove(); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); } } @@ -401,51 +447,64 @@ public class TurfForts extends TeamGame { } @EventHandler - public void Damage(CustomDamageEvent event) { - if (event.GetCause() == DamageCause.FALL) { + public void Damage(CustomDamageEvent event) + { + if (event.GetCause() == DamageCause.FALL) + { event.SetCancelled("No Fall"); return; } - if (!_fight && (event.GetCause() == DamageCause.PROJECTILE || event.GetCause() == DamageCause.ENTITY_ATTACK)) { + if (!_fight && (event.GetCause() == DamageCause.PROJECTILE || event.GetCause() == DamageCause.ENTITY_ATTACK)) + { event.SetCancelled("Build Time"); return; } Player damager = event.GetDamagerPlayer(true); - if (damager == null) - return; + if (damager == null) return; - if (event.GetCause() == DamageCause.PROJECTILE) { + if (event.GetCause() == DamageCause.PROJECTILE) + { event.AddMod("Turf Forts", "Nullify", -event.GetDamageInitial(), false); - if (GetKit(damager).GetName().contains("Shredder")) { + if (GetKit(damager).GetName().contains("Shredder")) + { event.SetCancelled("Shredder"); - Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), damager, null, DamageCause.CUSTOM, 9, true, - true, false, damager.getName(), "Barrage"); + Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), damager, null, + DamageCause.CUSTOM, 9, true, true, false, + damager.getName(), "Barrage"); return; - } else { + } + else + { event.AddMod("Turf Forts", "One Hit Kill", 30, false); } - } else if (event.GetCause() == DamageCause.ENTITY_ATTACK) { + } + else if (event.GetCause() == DamageCause.ENTITY_ATTACK) + { event.AddMod("Turf Forts", "Nullify", -event.GetDamageInitial(), false); - if (UtilGear.isMat(damager.getItemInHand(), Material.IRON_SWORD)) { + if (UtilGear.isMat(damager.getItemInHand(), Material.IRON_SWORD)) + { event.AddMod("Turf Forts", "One Hit Kill", 12, false); - } else { + } + else + { event.AddMod("Turf Forts", "One Hit Kill", 6, false); } } } @EventHandler - public void ScoreboardTitle(UpdateEvent event) { + public void ScoreboardTitle(UpdateEvent event) + { if (GetState() != GameState.Live) return; - // 2x Initial Build + //2x Initial Build if (_phaseTime == 0) _phaseTime = System.currentTimeMillis() + _buildTime; @@ -453,42 +512,48 @@ public class TurfForts extends TeamGame { return; long time; - if (!_fight) { + if (!_fight) + { time = _buildTime - (System.currentTimeMillis() - _phaseTime); - if (time <= 0) { + if (time <= 0) + { _fight = true; _lines++; Announce(" "); - Announce(C.cWhite + C.Bold + "1 Kill" + C.cWhite + C.Bold + " = " + C.cWhite + C.Bold - + GetLinesPerKill() + " Turf Lines"); - Announce(C.cWhite + C.Bold + "90 Seconds of " + C.cYellow + C.Bold + "Combat Time" + C.cWhite + C.Bold - + " has begun!"); + Announce(C.cWhite + C.Bold + "1 Kill" + C.cWhite + C.Bold + " = " + C.cWhite + C.Bold + GetLinesPerKill() + " Turf Lines"); + Announce(C.cWhite + C.Bold + "90 Seconds of " + C.cYellow + C.Bold + "Combat Time" + C.cWhite + C.Bold + " has begun!"); Announce(" "); _phaseTime = System.currentTimeMillis(); } } - else { + else + { time = _fightTime - (System.currentTimeMillis() - _phaseTime); - if (time <= 0) { + if (time <= 0) + { _fight = false; Announce(" "); - Announce(C.cWhite + C.Bold + "20 Seconds of " + C.cGreen + C.Bold + "Build Time" + C.cWhite + C.Bold - + " has begun!"); + Announce(C.cWhite + C.Bold + "20 Seconds of " + C.cGreen + C.Bold + "Build Time" + C.cWhite + C.Bold + " has begun!"); Announce(" "); _phaseTime = System.currentTimeMillis(); - for (GameTeam team : GetTeamList()) { - for (Player player : team.GetPlayers(true)) { - if (UtilPlayer.isSpectator(player)) { + for (GameTeam team : GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + if (UtilPlayer.isSpectator(player)) + { this.playersThatNeedBlocks.add(player.getUniqueId()); - } else { + } + else + { addBlocks(team, player); } } @@ -496,45 +561,52 @@ public class TurfForts extends TeamGame { } } } - - public void addBlocks(GameTeam team, Player player) { + + public void addBlocks(GameTeam team, Player player) + { player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOL, team.GetColorData(), 24)); } - + @EventHandler(ignoreCancelled = true) - public void onQuit(PlayerQuitEvent event) { + public void onQuit(PlayerQuitEvent event) + { this.playersThatNeedBlocks.remove(event.getPlayer().getUniqueId()); } - + @EventHandler(ignoreCancelled = true) - public void onSpawn(PlayerKitGiveEvent event) { + public void onSpawn(PlayerKitGiveEvent event) + { Player player = event.getPlayer(); - if (this.playersThatNeedBlocks.contains(player.getUniqueId())) { + if (this.playersThatNeedBlocks.contains(player.getUniqueId())) + { this.playersThatNeedBlocks.remove(player.getUniqueId()); this.addBlocks(GetTeam(player), player); } } - + + + @Override @EventHandler - public void ScoreboardUpdate(UpdateEvent event) { + public void ScoreboardUpdate(UpdateEvent event) + { if (event.getType() != UpdateType.FAST) return; Scoreboard.Reset(); - for (GameTeam team : this.GetTeamList()) { + for (GameTeam team : this.GetTeamList()) + { int lines = 0; - if (team.GetColor() == ChatColor.RED) - lines = GetRedLines(); - else - lines = GetBlueLines(); + if (team.GetColor() == ChatColor.RED) lines = GetRedLines(); + else lines = GetBlueLines(); Scoreboard.WriteBlank(); Scoreboard.Write(lines + " " + team.GetColor() + team.GetName()); } - if (!_fight) { + if (!_fight) + { long time = _buildTime - (System.currentTimeMillis() - _phaseTime); Scoreboard.WriteBlank(); @@ -543,7 +615,8 @@ public class TurfForts extends TeamGame { } - else { + else + { long time = _fightTime - (System.currentTimeMillis() - _phaseTime); Scoreboard.WriteBlank(); @@ -554,78 +627,95 @@ public class TurfForts extends TeamGame { Scoreboard.Draw(); } - public int GetRedLines() { + public int GetRedLines() + { if (!InProgress()) return 0; - if (xRed != 0) { + if (xRed != 0) + { return Math.abs(_redBase.getBlockX() - _red.getBlockX()); } return Math.abs(_redBase.getBlockZ() - _red.getBlockZ()); } - public int GetBlueLines() { + public int GetBlueLines() + { if (!InProgress()) return 0; - if (xRed != 0) { + if (xRed != 0) + { return Math.abs(_blueBase.getBlockX() - _blue.getBlockX()); } return Math.abs(_blueBase.getBlockZ() - _blue.getBlockZ()); } - public int getLines(GameTeam team) { + public int getLines(GameTeam team) + { if (team.GetColor() == ChatColor.RED) return GetRedLines(); else return GetBlueLines(); } - public int GetLinesPerKill() { + public int GetLinesPerKill() + { return _lines; - // return Math.min(5, 1 + (int)((System.currentTimeMillis() - - // GetStateTime() - 30000) / 60000)); + //return Math.min(5, 1 + (int)((System.currentTimeMillis() - GetStateTime() - 30000) / 60000)); } @EventHandler - public void PlayerDeath(PlayerDeathEvent event) { + public void PlayerDeath(PlayerDeathEvent event) + { _enemyTurf.remove(event.getEntity()); } @EventHandler - public void Territory(UpdateEvent event) { + public void Territory(UpdateEvent event) + { if (!IsLive()) return; if (event.getType() != UpdateType.FASTER) return; - for (GameTeam team : this.GetTeamList()) { - for (Player player : team.GetPlayers(true)) { - if (((CraftPlayer) player).getHandle().spectating) - continue; - + for (GameTeam team : this.GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + if (((CraftPlayer) player).getHandle().spectating) + continue; + Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); + + // Apply velocity even if the player is sneaking near turf edges. + + if (block.isEmpty() && player.isOnGround()) + { + Block[] nearby = { + block.getRelative(BlockFace.NORTH), + block.getRelative(BlockFace.SOUTH), + block.getRelative(BlockFace.WEST), + block.getRelative(BlockFace.EAST), + block.getRelative(BlockFace.NORTH_EAST), + block.getRelative(BlockFace.NORTH_WEST), + block.getRelative(BlockFace.SOUTH_EAST), + block.getRelative(BlockFace.SOUTH_WEST) + }; - // Apply velocity even if the player is sneaking near turf - // edges. - - if (block.isEmpty() && player.isOnGround()) { - Block[] nearby = { block.getRelative(BlockFace.NORTH), block.getRelative(BlockFace.SOUTH), - block.getRelative(BlockFace.WEST), block.getRelative(BlockFace.EAST), - block.getRelative(BlockFace.NORTH_EAST), block.getRelative(BlockFace.NORTH_WEST), - block.getRelative(BlockFace.SOUTH_EAST), block.getRelative(BlockFace.SOUTH_WEST) }; - - for (Block near : nearby) { - if (near.getType() == Material.STAINED_CLAY || near.getType() == Material.WOOL) { + for (Block near : nearby) + { + if (near.getType() == Material.STAINED_CLAY || near.getType() == Material.WOOL) + { block = near; break; } } } - + while (block.getTypeId() != 159 && block.getY() > 0) block = block.getRelative(BlockFace.DOWN); @@ -634,21 +724,22 @@ public class TurfForts extends TeamGame { byte data = block.getData(); - // Slow - if (_enemyTurf.containsKey(player)) { + //Slow + if (_enemyTurf.containsKey(player)) + { int time = (int) ((System.currentTimeMillis() - _enemyTurf.get(player)) / 2500); if (time > 0) - Manager.GetCondition().Factory().Slow("Infiltrator Slow", player, player, 0.9, time - 1, false, - false, false, false); + Manager.GetCondition().Factory().Slow("Infiltrator Slow", player, player, 0.9, time - 1, false, false, false, false); } - // On Enemy Turf - if ((team.GetColor() == ChatColor.RED && data == 3) - || (team.GetColor() == ChatColor.AQUA && data == 14)) { + //On Enemy Turf + if ((team.GetColor() == ChatColor.RED && data == 3) || (team.GetColor() == ChatColor.AQUA && data == 14)) + { - // Infiltrate - if (_fight && GetKit(player) != null && GetKit(player).GetName().contains("Infil")) { + //Infiltrate + if (_fight && GetKit(player) != null && GetKit(player).GetName().contains("Infil")) + { if (!_enemyTurf.containsKey(player)) _enemyTurf.put(player, System.currentTimeMillis()); @@ -656,65 +747,79 @@ public class TurfForts extends TeamGame { continue; } - if (Recharge.Instance.use(player, "Territory Knockback", 2000, false, false)) { - UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), team.GetSpawn()), 2, - false, 0, 0.8, 1, true); + if (Recharge.Instance.use(player, "Territory Knockback", 2000, false, false)) + { + UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), team.GetSpawn()), 2, false, 0, 0.8, 1, true); player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); UtilPlayer.message(player, F.main("Game", "You cannot walk on the enemies turf!")); } - // Looks like that with 'return' if there are only two - // players, one of them will not get knockback. - // return; } - // On Own Turf - else if ((team.GetColor() == ChatColor.RED && data == 14) - || (team.GetColor() == ChatColor.AQUA && data == 3)) { + //On Own Turf + else if ((team.GetColor() == ChatColor.RED && data == 14) || (team.GetColor() == ChatColor.AQUA && data == 3)) + { _enemyTurf.remove(player); } } } } - + /* - * @EventHandler public void ItemRemoval(UpdateEvent event) { if (!IsLive()) - * return; - * - * if (event.getType() != UpdateType.FAST) return; - * - * for (Entity ent : _red.getWorld().getEntities()) { if (!(ent instanceof - * Item)) continue; - * - * if (ent.getTicksLived() > 40) ent.remove(); } } - */ + @EventHandler + public void ItemRemoval(UpdateEvent event) + { + if (!IsLive()) + return; + if (event.getType() != UpdateType.FAST) + return; + + for (Entity ent : _red.getWorld().getEntities()) + { + if (!(ent instanceof Item)) + continue; + + if (ent.getTicksLived() > 40) + ent.remove(); + } + } + */ + + public GameTeam GetOtherTeam(GameTeam team) { return team.GetColor() == ChatColor.RED ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED); } - + @EventHandler public void onItem(ItemSpawnEvent e) { if (e.getEntityType().equals(EntityType.DROPPED_ITEM)) { e.setCancelled(true); } } - + @Override - public void EndCheck() { + public void EndCheck() + { if (!IsLive()) return; - if (GetRedLines() == 0 || GetTeam(ChatColor.RED).GetPlayers(true).size() == 0) { + if (GetRedLines() == 0 || GetTeam(ChatColor.RED).GetPlayers(true).size() == 0) + { AnnounceEnd(GetTeam(ChatColor.AQUA)); - } else if (GetBlueLines() == 0 || GetTeam(ChatColor.AQUA).GetPlayers(true).size() == 0) { + } + else if (GetBlueLines() == 0 || GetTeam(ChatColor.AQUA).GetPlayers(true).size() == 0) + { AnnounceEnd(GetTeam(ChatColor.RED)); - } else + } + else return; - for (GameTeam team : GetTeamList()) { - if (WinnerTeam != null && team.equals(WinnerTeam)) { + for (GameTeam team : GetTeamList()) + { + if (WinnerTeam != null && team.equals(WinnerTeam)) + { for (Player player : team.GetPlayers(false)) AddGems(player, 10, "Winning Team", false, false); } @@ -723,26 +828,29 @@ public class TurfForts extends TeamGame { if (player.isOnline()) AddGems(player, 10, "Participation", false, false); } - - // End + + //End SetState(GameState.End); } - public Long getEnemyTurfEntranceTime(Player player) { + public Long getEnemyTurfEntranceTime(Player player) + { return _enemyTurf.get(player); } - + // Keep ladders placed on ice when block updates occur. - + @EventHandler - public void onBlockPhysics(BlockPhysicsEvent event) { + public void onBlockPhysics(BlockPhysicsEvent event) + { if (!IsLive()) return; - + Block block = event.getBlock(); - - if (block.getType() == Material.LADDER) { + + if (block.getType() == Material.LADDER) + { event.setCancelled(true); } } -} +} \ No newline at end of file From 3770211e66b41e16440609a0a79b3999b9b6cca7 Mon Sep 17 00:00:00 2001 From: Thanos paravantis Date: Mon, 4 Jan 2016 22:58:11 +0200 Subject: [PATCH 27/48] Turf Wars: Include Teddy's border fix. --- .../game/games/turfforts/TurfForts.java | 46 +++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java index 61a89a1e5..6bff9d4b2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java @@ -22,6 +22,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; +import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockEvent; import org.bukkit.event.block.BlockPhysicsEvent; @@ -31,6 +32,7 @@ import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.common.util.C; @@ -838,10 +840,48 @@ public class TurfForts extends TeamGame return _enemyTurf.get(player); } - // Keep ladders placed on ice when block updates occur. - + // Fixed by TeddyDev. @EventHandler - public void onBlockPhysics(BlockPhysicsEvent event) + public void blockGlitchFix(PlayerInteractEvent event) + { + if(event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if(event.getPlayer().isOnGround()) + return; + + Block block = event.getClickedBlock(); + if(block.getType() == Material.STAINED_CLAY || block.getType() == Material.WOOL) + return; + + Player player = event.getPlayer(); + Block ground = player.getLocation().getBlock(); + while (ground.getType() == Material.AIR && ground.getLocation().getBlockY() >= 0) + { + ground = ground.getRelative(BlockFace.DOWN); + } + + if(ground.isLiquid()) + { + Manager.GetDamage().NewDamageEvent(player, null, null, + DamageCause.VOID, 9001, false, false, false, + "Border", "Border Damage"); + player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); + return; + } + + if(player.getLocation().distance(ground.getLocation()) < 4) + return; + + Manager.GetDamage().NewDamageEvent(player, null, null, + DamageCause.VOID, 9001, false, false, false, + "Border", "Border Damage"); + player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); + } + + // Keep ladders placed on ice when block updates occur. + @EventHandler + public void ladderDestroyFix(BlockPhysicsEvent event) { if (!IsLive()) return; From ed814113734dd370c91bb820e1c921b60561d9bc Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Mon, 4 Jan 2016 15:58:27 -0500 Subject: [PATCH 28/48] Fix carl bonus messages --- .../src/mineplex/core/bonuses/BonusManager.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index 6c01d3719..a8dcbfa34 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -440,6 +440,7 @@ public class BonusManager extends MiniClientPlugin implements I incrementDailyStreak(player); awardBonus(player, amount); updateCreeperVisual(player, true, C.cAqua); + UtilPlayer.message(player, F.main("Carl", "Come back tomorrow for more!")); _statsManager.incrementStat(player, "Global.DailyReward", 1); } @@ -481,6 +482,7 @@ public class BonusManager extends MiniClientPlugin implements I { awardBonus(player, getRankBonusAmount(player)); updateCreeperVisual(player, true, C.cAqua); + UtilPlayer.message(player, F.main("Carl", "Come back next month for more!")); } result.run(aBoolean); @@ -814,9 +816,6 @@ public class BonusManager extends MiniClientPlugin implements I _statsManager.incrementStat(player, "Global.ExpEarned", experience); UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(experience + " Experience"))); } - - UtilPlayer.message(player, F.main("Carl", "Come back tomorrow for more!")); - } @EventHandler From 962efe4a614ebc8ecbbd34d2ea04682d9bed287e Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Mon, 4 Jan 2016 16:41:07 -0500 Subject: [PATCH 29/48] Fix not being able to join games through portals --- .../mineplex/hub/server/ServerManager.java | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index 0b54138c0..59b019540 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -86,7 +86,7 @@ public class ServerManager extends MiniPlugin private NautHashMap _serverNpcShopMap = new NautHashMap(); private NautHashMap _serverInfoMap = new NautHashMap(); private NautHashMap _serverUpdate = new NautHashMap(); - private NautHashMap _serverPortalLocations = new NautHashMap(); + private NautHashMap _portalToServerKey = new NautHashMap(); private ClansServerShop _clansShop; @@ -185,15 +185,16 @@ public class ServerManager extends MiniPlugin return; } - String serverName = _serverPortalLocations.get(player.getLocation().getBlock().getLocation().toVector()); + String serverKey = _portalToServerKey.get(player.getLocation().getBlock().getLocation().toVector()); - if (serverName != null) + if (serverKey != null) { List serverList = new ArrayList(); - - if (hasServerNpc(serverName)) - serverList.addAll(getServerList(serverName)); - + + Collection servers = getServerList(serverKey); + if (servers != null && servers.size() > 0) + serverList.addAll(servers); + int slots = 1; if (serverList.size() > 0) @@ -347,9 +348,9 @@ public class ServerManager extends MiniPlugin } } - public Collection getServerList(String serverNpcName) + public Collection getServerList(String serverKey) { - return _serverKeyInfoMap.get(serverNpcName); + return _serverKeyInfoMap.get(serverKey); } public Set getAllServers() @@ -362,11 +363,6 @@ public class ServerManager extends MiniPlugin return _serverInfoMap.get(serverName); } - public boolean hasServerNpc(String serverNpcName) - { - return _serverKeyInfoMap.containsKey(serverNpcName); - } - @EventHandler public void updatePages(UpdateEvent event) { @@ -711,7 +707,7 @@ public class ServerManager extends MiniPlugin while (blocks < 10 && (bottomVector.getBlockX() != topVector.getBlockX() || bottomVector.getBlockZ() != topVector.getBlockZ())) { - _serverPortalLocations.put(new Vector(bottomVector.getBlockX(), bottomVector.getBlockY(), bottomVector.getBlockZ()), serverGroup.getServerNpcName()); + _portalToServerKey.put(new Vector(bottomVector.getBlockX(), bottomVector.getBlockY(), bottomVector.getBlockZ()), serverGroup.getPrefix()); if (bottomVector.getBlockX() != topVector.getBlockX()) { @@ -725,7 +721,7 @@ public class ServerManager extends MiniPlugin blocks++; } - _serverPortalLocations.put(bottomVector, serverGroup.getServerNpcName()); + _portalToServerKey.put(bottomVector, serverGroup.getPrefix()); } } } From f749300d484be0860149b73e672c42101123d0c9 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Mon, 4 Jan 2016 18:13:54 -0500 Subject: [PATCH 30/48] Fix team stats not displaying properly --- .../src/mineplex/core/achievement/StatDisplay.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java index 0d6badd6e..a4dc577ed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java @@ -81,7 +81,7 @@ public class StatDisplay formattedStats[i] = gameDisplay.getName() + "." + stats[i]; } - return new StatDisplay(name, true, formattedStats); + return new StatDisplay(name, true, false, formattedStats); } public static final StatDisplay WINS = new StatDisplay("Wins"); From db2cddc443b1b549e2d1f9625724273390d0ecf3 Mon Sep 17 00:00:00 2001 From: Sarah Date: Tue, 5 Jan 2016 19:10:40 +0100 Subject: [PATCH 31/48] Fixing Join/Quit messages --- .../core/disguise/PlayerDisguiseManager.java | 18 ++++++++++-------- .../mineplex/hub/commands/DisguiseCommand.java | 2 +- .../game/arcade/command/DisguiseCommand.java | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java index d7edc247a..d7a900895 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java @@ -1,13 +1,5 @@ package mineplex.core.disguise; -import org.bukkit.Bukkit; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitRunnable; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; @@ -15,6 +7,15 @@ import mineplex.core.common.Rank; import mineplex.serverdata.Region; import mineplex.serverdata.redis.RedisDataRepository; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; + public class PlayerDisguiseManager extends MiniPlugin { private CoreClientManager _clients; @@ -54,6 +55,7 @@ public class PlayerDisguiseManager extends MiniPlugin { DisguisePlayerBean bean = _redis.getElement(client.getAccountId()+client.GetPlayerName()); Bukkit.getPluginManager().callEvent(new PlayerCommandPreprocessEvent(event.getPlayer(), "/Disguise " + bean.getDisguisedPlayer())); + event.setJoinMessage(""); } } }.runTaskLater(getPlugin(), 7); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java index a74c4e858..2ad478621 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java @@ -204,7 +204,7 @@ public class DisguiseCommand extends CommandBase implements Listener Plugin.GetGadget().removeGadgetType(caller, GadgetType.Item); - Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller)); + // Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller)); UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + args[0])); Field field; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java index 873adf239..0030fed08 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java @@ -205,7 +205,7 @@ public class DisguiseCommand extends CommandBase implements Liste Plugin.getCosmeticManager().getGadgetManager().removeGadgetType(caller, GadgetType.Item); - Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller)); + // Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller)); UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + args[0])); Field field; From c920d4efa13a460365d7bff4542e2d130f3f119d Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 7 Jan 2016 04:48:44 +1300 Subject: [PATCH 32/48] Modify MapText to actually work, modify UtilText to save the images of characters --- .../mineplex/core/common/util/UtilText.java | 85 +++++++++----- .../src/mineplex/core/map/MapText.java | 104 +----------------- 2 files changed, 61 insertions(+), 128 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java index 38e540824..2791c275f 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java @@ -17,6 +17,7 @@ import org.bukkit.ChatColor; public class UtilText { private static HashMap _characters = new HashMap(); + private static HashMap _characterImages = new HashMap(); static { @@ -263,13 +264,13 @@ public class UtilText public static String[] splitLinesToArray(String[] strings, LineFormat lineFormat) { ArrayList lineList = splitLines(strings, lineFormat); - + String[] lineArray = new String[lineList.size()]; lineArray = lineList.toArray(lineArray); - + return lineArray; } - + public static ArrayList splitLines(String[] strings, LineFormat lineFormat) { ArrayList lines = new ArrayList(); @@ -281,35 +282,35 @@ public class UtilText return lines; } - + public static String[] splitLineToArray(String string, LineFormat lineFormat) { ArrayList lineList = splitLine(string, lineFormat); - + String[] lineArray = new String[lineList.size()]; lineArray = lineList.toArray(lineArray); - + return lineArray; } public static ArrayList splitLine(String string, LineFormat lineFormat) { ArrayList strings = new ArrayList(); - - //Ignore lines with # + + // Ignore lines with # if (string.startsWith("#")) { strings.add(string.substring(1, string.length())); return strings; } - - //Empty + + // Empty if (string.equals("") || string.equals(" ")) { strings.add(string); return strings; } - + String current = ""; int currentLength = 0; String[] split = string.split(" "); @@ -453,35 +454,63 @@ public class UtilText private static void grab(Character character, BufferedImage image, int imageX, int imageY) { + BufferedImage newImage = image.getSubimage(imageX, imageY, 8, 8); + + int width = 8; + if (character == ' ') { - _characters.put(character, 3); - return; + width = 3; } - - for (int x = 0; x < 8; x++) + else { - boolean isTransparentLine = true; - - for (int y = 0; y < 8; y++) + for (int x = 0; x < 8; x++) { - int pixel = image.getRGB(imageX + x, imageY + y); + boolean isTransparentLine = true; - if ((pixel >> 24) != 0x00) + for (int y = 0; y < 8; y++) { - isTransparentLine = false; + int pixel = image.getRGB(imageX + x, imageY + y); + + if ((pixel >> 24) != 0x00) + { + isTransparentLine = false; + break; + } + } + + if (isTransparentLine) + { + width = x + 1; break; } } - - if (isTransparentLine) - { - _characters.put(character, x); - return; - } } - _characters.put(character, 8); + newImage = newImage.getSubimage(0, 0, width, 8); + + _characterImages.put(character, newImage); + _characters.put(character, width); + } + + public static int getLength(char character) + { + if (!_characters.containsKey(character)) + { + return 16; + } + + return _characters.get(character); + } + + public static BufferedImage getImage(char character) + { + if (!_characterImages.containsKey(character)) + { + character = '?'; + } + + return _characterImages.get(character); } public static boolean isStringSimilar(String newString, String oldString, float matchRequirement) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java b/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java index d11f032dc..3fcc5d2fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java @@ -2,14 +2,9 @@ package mineplex.core.map; import java.awt.Graphics; import java.awt.image.BufferedImage; -import java.io.IOException; -import java.io.InputStream; import java.util.ArrayList; -import java.util.HashMap; - -import javax.imageio.ImageIO; - import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -20,86 +15,6 @@ import org.bukkit.map.MapView; public class MapText { - private static HashMap _characters = new HashMap(); - - private void loadCharacters() - { - try - { - InputStream inputStream = getClass().getResourceAsStream("ascii.png"); - BufferedImage image = ImageIO.read(inputStream); - - char[] text = new char[] - { - ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', - '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', - 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', - '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', - 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~' - }; - - int x = 0; - int y = 16; - - for (char c : text) - { - grab(c, image, x, y); - - if (x < 15 * 8) - { - x += 8; - } - else - { - x = 0; - y += 8; - } - } - - inputStream.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - - private static void grab(Character character, BufferedImage image, int imageX, int imageY) - { - BufferedImage newImage = image.getSubimage(imageX, imageY, 8, 8); - - int width = character == ' ' ? 4 : 0; - - if (width == 0) - { - for (int x = 0; x < 8; x++) - { - width++; - boolean foundNonTrans = false; - - for (int y = 0; y < 8; y++) - { - int pixel = newImage.getRGB(x, y); - - if ((pixel >> 24) != 0x00) - { - foundNonTrans = true; - break; - } - } - - if (!foundNonTrans) - { - break; - } - } - } - - newImage = newImage.getSubimage(0, 0, width, 8); - - _characters.put(character, newImage); - } - private ArrayList split(String text) { ArrayList returns = new ArrayList(); @@ -112,7 +27,7 @@ public class MapText for (char c : word.toCharArray()) { - length += _characters.get(c).getWidth(); + length += UtilText.getImage(c).getWidth(); } if (lineWidth + length >= 127) @@ -133,11 +48,6 @@ public class MapText public ItemStack getMap(boolean sendToServer, String... text) { - if (_characters.isEmpty()) - { - loadCharacters(); - } - BufferedImage image = new BufferedImage(128, 128, BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics(); int height = 1; @@ -150,13 +60,7 @@ public class MapText for (char c : line.toCharArray()) { - BufferedImage img = _characters.get(c); - - if (img == null) - { - System.out.print("Error: '" + c + "' has no image associated"); - continue; - } + BufferedImage img = UtilText.getImage(c); g.drawImage(img, length, height, null); @@ -179,7 +83,7 @@ public class MapText ItemStack item = new ItemStack(Material.MAP); item.setDurability(map.getId()); - + if (sendToServer) { for (Player player : UtilServer.getPlayers()) From de6f6cf5f016aadd4bc3885f1f77c8c1089da630 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 7 Jan 2016 08:49:26 +1300 Subject: [PATCH 33/48] Add a IsLive check in Spleef --- .../src/nautilus/game/arcade/game/games/spleef/Spleef.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java index 73d245050..207ec28b4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java @@ -67,6 +67,9 @@ public class Spleef extends SoloGame @EventHandler public void SnowballDamage(ProjectileHitEvent event) { + if (!IsLive()) + return; + if (!(event.getEntity() instanceof Snowball)) return; From 003af1b87c2208c3fef909cc1d867d17357fbe6a Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 01:38:49 -0500 Subject: [PATCH 34/48] Disable Holiday Words in DMT and Build --- .../src/nautilus/game/arcade/game/games/build/Build.java | 3 ++- .../src/nautilus/game/arcade/game/games/draw/Draw.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java index a066fd174..bbcf02a2e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java @@ -119,6 +119,7 @@ public class Build extends SoloGame private String[] _words; private String[] _holidayWords; + private boolean _useHolidayWords = false; private String _word = "?"; @@ -249,7 +250,7 @@ public class Build extends SoloGame player.setFlySpeed(0.1f); } - if (Math.random() >= 0.5) + if (!_useHolidayWords || Math.random() >= 0.5) _word = _words[UtilMath.r(_words.length)]; else _word = _holidayWords[UtilMath.r(_holidayWords.length)]; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java index 53d88aeda..3098fe293 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java @@ -84,6 +84,7 @@ public class Draw extends SoloGame private HashSet _tools; private String[] _words; private String[] _holidayWords; + private boolean _useHolidayWords = false; private HashSet _usedWords = new HashSet(); public Draw(ArcadeManager manager) @@ -302,7 +303,7 @@ public class Draw extends SoloGame private String getRandomWord() { - if (Math.random() >= 0.30) + if (!_useHolidayWords || Math.random() >= 0.30) { return _words[UtilMath.r(_words.length)]; } From 9c3b07123f73ebecdd67b9534bfbc2ce454f8d42 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 01:39:54 -0500 Subject: [PATCH 35/48] Revert to normal HubType --- Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 24be3b3dc..a06a5a7b2 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -135,7 +135,7 @@ import org.bukkit.scoreboard.Scoreboard; public class HubManager extends MiniClientPlugin { // ☃❅ Snowman! - public HubType Type = HubType.Christmas; + public HubType Type = HubType.Normal; private BlockRestore _blockRestore; private CoreClientManager _clientManager; From 19bb44cb9abfd954e2216bbf378d28f9592c96d7 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 01:41:02 -0500 Subject: [PATCH 36/48] Disable HolidayManager and HolidayGiftManager --- Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java | 2 +- .../src/nautilus/game/arcade/ArcadeManager.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index a06a5a7b2..c3b304bdf 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -249,7 +249,7 @@ public class HubManager extends MiniClientPlugin // _halloweenManager = new HalloweenSpookinessManager(this); - new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager); +// new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager); new PlayerDisguiseManager(plugin, _clientManager); // NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager); // new MailManager(_plugin, notificationManager); 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 db787f98e..91f502c5d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -291,7 +291,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _hologramManager = hologramManager; _idleManager = new IdleManager(this); TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager); - new HolidayManager(this, titanGiveaway); +// new HolidayManager(this, titanGiveaway); new GameTestingManager(this); new PlayerDisguiseManager(plugin, _clientManager); From db7d814e02fba026583e8ef68365fe9ebbcdb615 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 01:42:05 -0500 Subject: [PATCH 37/48] Disable hub music --- Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index c3b304bdf..f63f18a74 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -296,6 +296,9 @@ public class HubManager extends MiniClientPlugin private void playNextSong() { + if (Type != HubType.Christmas) + return; + if (_songs.isEmpty()) return; From 1d2f61db8c45d5068bc7183cdfcd906c7fac4eb2 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 03:15:05 -0500 Subject: [PATCH 38/48] Disable purchasing Christmas Treasure --- .../mineplex/core/treasure/TreasureType.java | 24 +++++++++++++---- .../core/treasure/gui/TreasurePage.java | 27 +++++++++++-------- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java index bab37072b..159bd4f83 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java @@ -8,13 +8,13 @@ import mineplex.core.reward.RewardType; public enum TreasureType { - OLD(C.cYellow + "Old Treasure", "Old Chest", "Old", RewardType.OldChest, Material.CHEST, TreasureStyle.OLD, RewardPool.Type.NORMAL), + OLD(C.cYellow + "Old Treasure", "Old Chest", "Old", RewardType.OldChest, Material.CHEST, TreasureStyle.OLD, RewardPool.Type.NORMAL, true, 1000), - ANCIENT(C.cGold + "Ancient Treasure", "Ancient Chest", "Ancient", RewardType.AncientChest, Material.TRAPPED_CHEST, TreasureStyle.ANCIENT, RewardPool.Type.NORMAL), + ANCIENT(C.cGold + "Ancient Treasure", "Ancient Chest", "Ancient", RewardType.AncientChest, Material.TRAPPED_CHEST, TreasureStyle.ANCIENT, RewardPool.Type.NORMAL, true, 5000), - MYTHICAL(C.cRed + "Mythical Treasure", "Mythical Chest", "Mythical", RewardType.MythicalChest, Material.ENDER_CHEST, TreasureStyle.MYTHICAL, RewardPool.Type.NORMAL), + MYTHICAL(C.cRed + "Mythical Treasure", "Mythical Chest", "Mythical", RewardType.MythicalChest, Material.ENDER_CHEST, TreasureStyle.MYTHICAL, RewardPool.Type.NORMAL, true, 10000), - CHRISTMAS(C.cDGreen + "Winter Holiday Treasure", "Winter Chest", "Christmas", RewardType.WinterChest, Material.CHEST, TreasureStyle.CHRISTMAS, RewardPool.Type.WINTER_HOLIDAY); + CHRISTMAS(C.cDGreen + "Winter Holiday Treasure", "Winter Chest", "Christmas", RewardType.WinterChest, Material.CHEST, TreasureStyle.CHRISTMAS, RewardPool.Type.WINTER_HOLIDAY, false, 15000); private final String _name; private final RewardType _rewardType; @@ -23,8 +23,10 @@ public enum TreasureType private final String _itemName; private final String _statName; private final RewardPool.Type _rewardPool; + private final int _purchasePrice; + private final boolean _purchasable; - TreasureType(String name, String itemName, String statName, RewardType rewardType, Material material, TreasureStyle treasureStyle, RewardPool.Type rewardPool) + TreasureType(String name, String itemName, String statName, RewardType rewardType, Material material, TreasureStyle treasureStyle, RewardPool.Type rewardPool, boolean purchasable, int purchasePrice) { _name = name; _itemName = itemName; @@ -33,6 +35,8 @@ public enum TreasureType _material = material; _treasureStyle = treasureStyle; _rewardPool = rewardPool; + _purchasePrice = purchasePrice; + _purchasable = purchasable; } public RewardType getRewardType() @@ -69,4 +73,14 @@ public enum TreasureType { return _rewardPool; } + + public int getPurchasePrice() + { + return _purchasePrice; + } + + public boolean isPurchasable() + { + return _purchasable; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java index a0ad48354..ae345c49c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -122,9 +122,11 @@ public class TreasurePage extends ShopPageBase christmasLore.add(ChatColor.RESET + C.cGreen + "Click to Open!"); else { + /* christmasLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "15000 Treasure Shards"); christmasLore.add(" "); christmasLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop"); + */ } List cosmicLore = new ArrayList(); @@ -143,18 +145,21 @@ public class TreasurePage extends ShopPageBase addItem(40, shards); - if (basicCount > 0) addButton(20, basic, new OpenTreasureButton(getPlayer(), _treasureLocation, TreasureType.OLD)); - else addButton(20, basic, new BuyChestButton(getPlayer(), _inventoryManager, this, "Old Chest", Material.CHEST, 1000)); - - if (heroicCount > 0) addButton(22, heroic, new OpenTreasureButton(getPlayer(), _treasureLocation, TreasureType.ANCIENT)); - else addButton(22, heroic, new BuyChestButton(getPlayer(), _inventoryManager, this, "Ancient Chest", Material.CHEST, 5000)); - - if (legendaryCount > 0) addButton(24, legendary, new OpenTreasureButton(getPlayer(), _treasureLocation, TreasureType.MYTHICAL)); - else addButton(24, legendary, new BuyChestButton(getPlayer(), _inventoryManager, this, "Mythical Chest", Material.ENDER_CHEST, 10000)); - - if (christmasCount > 0) addButton(12, christmas, new OpenTreasureButton(getPlayer(), _treasureLocation, TreasureType.CHRISTMAS)); - else addButton(12, christmas, new BuyChestButton(getPlayer(), _inventoryManager, this, TreasureType.CHRISTMAS.getItemName(), Material.SNOW_BALL, 15000)); + addChest(20, basic, TreasureType.OLD, basicCount); + addChest(22, heroic, TreasureType.ANCIENT, heroicCount); + addChest(24, legendary, TreasureType.MYTHICAL, legendaryCount); + addChest(12, christmas, TreasureType.CHRISTMAS, christmasCount); addItem(14, cosmic); } + + private void addChest(int slot, ItemStack item, TreasureType treasureType, int owned) + { + if (owned > 0) + addButton(slot, item, new OpenTreasureButton(getPlayer(), _treasureLocation, treasureType)); + else if (treasureType.isPurchasable()) + addButton(slot, item, new BuyChestButton(getPlayer(), _inventoryManager, this, treasureType.getName(), Material.CHEST, treasureType.getPurchasePrice())); + else + setItem(slot, item); + } } From 504d9d508cccbe9d81cd737f4f9da1a62cab5cc2 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 03:15:30 -0500 Subject: [PATCH 39/48] Slightly reduce Squid's Ink Blast damage in SSM --- .../arcade/game/games/smash/kits/KitSkySquid.java | 4 ++-- .../nautilus/game/arcade/kit/perks/PerkInkBlast.java | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkySquid.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkySquid.java index 06b78a82e..0a403c85e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkySquid.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkySquid.java @@ -38,7 +38,7 @@ public class KitSkySquid extends SmashKit new PerkSmashStats(6, 1.5, 0.25, 5), new PerkDoubleJump("Double Jump", 0.9, 0.9, false), new PerkSuperSquid(), - new PerkInkBlast(), + new PerkInkBlast(7, 2), new PerkFishFlurry(), new PerkStormSquid() }, @@ -56,7 +56,7 @@ public class KitSkySquid extends SmashKit C.cYellow + C.Bold + "Right-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Ink Shotgun", new String[] { - ChatColor.RESET + "Blasts 6 ink pellets out at high velocity.", + ChatColor.RESET + "Blasts 7 ink pellets out at high velocity.", ChatColor.RESET + "They explode upon hitting something, dealing", ChatColor.RESET + "damage and knockback.", })); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInkBlast.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInkBlast.java index 99a6f459e..fee34747e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInkBlast.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInkBlast.java @@ -33,12 +33,18 @@ import nautilus.game.arcade.kit.SmashPerk; public class PerkInkBlast extends SmashPerk implements IThrown { - public PerkInkBlast() + private int _bullets; + private double _damagePerBullet; + + public PerkInkBlast(int bullets, double damagePerBullet) { super("Ink Shotgun", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Ink Shotgun" }); + + _bullets = bullets; + _damagePerBullet = damagePerBullet; } @@ -75,7 +81,7 @@ public class PerkInkBlast extends SmashPerk implements IThrown UtilInv.Update(player); - for (int i=0 ; i<7 ; i++) + for (int i=0 ; i < _bullets ; i++) { org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), ItemStackFactory.Instance.CreateStack(Material.INK_SACK, (byte)0, 1, "Ink" + Math.random())); @@ -113,7 +119,7 @@ public class PerkInkBlast extends SmashPerk implements IThrown //Damage Event Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null, - DamageCause.PROJECTILE, 3, true, true, false, + DamageCause.PROJECTILE, _damagePerBullet, true, true, false, UtilEnt.getName(data.GetThrower()), GetName()); UtilParticle.PlayParticle(ParticleType.EXPLODE, target.getLocation().add(0, 1, 0), 1f, 1f, 1f, 0, 12, ViewDist.LONG, UtilServer.getPlayers()); From 6096fcad429975162d2eda97fd541d8b364282a8 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 04:06:11 -0500 Subject: [PATCH 40/48] Fix hotbar issues --- .../games/gladiators/hotbar/HotbarEditor.java | 17 ++++++++++ .../games/gladiators/hotbar/HotbarLayout.java | 33 +++++++++++++++++++ .../gladiators/hotbar/HotbarPageListener.java | 14 ++++---- 3 files changed, 57 insertions(+), 7 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java index 518b86d96..e9ecdeae7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java @@ -163,6 +163,23 @@ public class HotbarEditor extends MiniPlugin items.indexOf(arrows) - 9 ); + if (save.getArrows() > 8 || save.getArrows() < 0) + { + save.setArrows(save.getEmpty()); + } + if (save.getBow() > 8 || save.getBow() < 0) + { + save.setBow(save.getEmpty()); + } + if (save.getSword() > 8 || save.getSword() < 0) + { + save.setSword(save.getEmpty()); + } + if (save.getRod() > 8 || save.getRod() < 0) + { + save.setRod(save.getEmpty()); + } + _host.Manager.getArcadePlayer(player).put("hotbar", save.toDataSaveNumber()); player.sendMessage(F.main("Game", "Saved new hotbar layout!")); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java index 459f70411..ad4d024be 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java @@ -39,6 +39,26 @@ public class HotbarLayout return arrows; } + public void setSword(int sword) + { + this.sword = sword; + } + + public void setRod(int rod) + { + this.rod = rod; + } + + public void setBow(int bow) + { + this.bow = bow; + } + + public void setArrows(int arrows) + { + this.arrows = arrows; + } + public int toDataSaveNumber() { String str = ""; @@ -57,4 +77,17 @@ public class HotbarLayout return Integer.parseInt(str); } + + public int getEmpty() + { + for (int i = 0; i < 9; i++) + { + if (i == sword || i == rod || i == bow || i == arrows) + continue; + + return i; + } + + return 0; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java index 249983dd7..736de92df 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java @@ -50,12 +50,6 @@ public class HotbarPageListener implements Listener System.out.println(e.getClickedInventory().getName() + " : " + e.getInventory().getName()); -// if ((e.getSlot() > 8 && e.getSlot() < 18)) -// { -// e.setCancelled(false); -// return; -// } - if (e.getCurrentItem().getType().equals(Material.REDSTONE_BLOCK)) { e.setCancelled(true); @@ -70,7 +64,7 @@ public class HotbarPageListener implements Listener if (e.getCurrentItem().getType().equals(Material.EMERALD_BLOCK)) { - if (e.getAction().equals(InventoryAction.SWAP_WITH_CURSOR)){ + if (!e.getAction().equals(InventoryAction.PICKUP_ALL)){ e.setCancelled(true); return; } @@ -81,6 +75,12 @@ public class HotbarPageListener implements Listener return; } + if ((e.getSlot() < 9 || e.getSlot() > 17)) + { + e.setCancelled(true); + return; + } + if (e.getCurrentItem().getType().equals(Material.STAINED_GLASS_PANE)) { e.setCancelled(true); From 0a56a838d2b8e2556064fb5181002aafb87e6e14 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 05:45:49 -0500 Subject: [PATCH 41/48] Fix ClansLoginManager, Remove pointless code in CoreClientManager --- Plugins/.idea/dataSources.xml | 2 +- .../src/mineplex/core/account/CoreClientManager.java | 9 +-------- .../game/clans/clans/commands/ClansLoginManager.java | 4 ++-- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/Plugins/.idea/dataSources.xml b/Plugins/.idea/dataSources.xml index 3aa4d521d..b55f2b18c 100644 --- a/Plugins/.idea/dataSources.xml +++ b/Plugins/.idea/dataSources.xml @@ -1,6 +1,6 @@ - + mysql true diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index cd62cf6fc..fe00a1a45 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -128,14 +128,7 @@ public class CoreClientManager extends MiniPlugin if (client == null) { - if (Bukkit.getPlayer(name) != null) - { - client = new CoreClient(Bukkit.getPlayer(name)); - } - else - { - client = new CoreClient(name); - } + client = new CoreClient(name); } return client; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java index 1b8575083..2b59d9ae3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java @@ -41,8 +41,8 @@ public class ClansLoginManager extends MiniPlugin implements ILoginProcessor { if (_queue.contains(event.getPlayer().getName()) && !event.getPlayer().isOp()) { -// event.setKickMessage("This is not your Clans home server"); -// event.setResult(PlayerLoginEvent.Result.KICK_OTHER); + event.setKickMessage("This is not your Clans home server"); + event.setResult(PlayerLoginEvent.Result.KICK_OTHER); } _queue.remove(event.getPlayer().getName()); From 5482d1dc402eb2746d65323d5f08b51b97285a54 Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 8 Jan 2016 12:17:28 +0100 Subject: [PATCH 42/48] Fixing "kicked for Flying" --- .../src/mineplex/hub/commands/DisguiseCommand.java | 5 +++-- .../src/nautilus/game/arcade/command/DisguiseCommand.java | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java index 2ad478621..52a41e81e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java @@ -111,8 +111,9 @@ public class DisguiseCommand extends CommandBase implements Listener e.printStackTrace(); } - PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); - UtilPlayer.sendPacket(caller, packet); + // removed "due to Kicked for Flying" + //PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); + //UtilPlayer.sendPacket(caller, packet); for(Player other : UtilServer.getPlayers()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java index 0030fed08..bc2c8fb70 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java @@ -112,8 +112,10 @@ public class DisguiseCommand extends CommandBase implements Liste e.printStackTrace(); } - PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); - UtilPlayer.sendPacket(caller, packet); + + // removed "due to Kicked for Flying" + //PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); + //UtilPlayer.sendPacket(caller, packet); for(Player other : UtilServer.getPlayers()) { From ee73b374a65e9546be2f3476218b97b3edd602d3 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 06:36:59 -0500 Subject: [PATCH 43/48] Forgot to uncomment in ClansLoginManager --- .../clans/commands/ClansLoginManager.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java index 2b59d9ae3..1267209fb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java @@ -50,18 +50,18 @@ public class ClansLoginManager extends MiniPlugin implements ILoginProcessor private void kickPlayer(final String playerName, final String homeServer) { -// runSyncLater(new Runnable() -// { -// @Override -// public void run() -// { -// Player player = UtilPlayer.searchExact(playerName); -// if (player != null && player.isOnline() && !player.isOp()) -// { -// player.kickPlayer("This is not your home server. To play clans, connect to " + homeServer); -// } -// } -// }, 20); + runSyncLater(new Runnable() + { + @Override + public void run() + { + Player player = UtilPlayer.searchExact(playerName); + if (player != null && player.isOnline() && !player.isOp()) + { + player.kickPlayer("This is not your home server. To play clans, connect to " + homeServer); + } + } + }, 20); } @Override From 2df626b35ef4bc84121f44ff380f9a5dd62ee720 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 18:06:33 -0500 Subject: [PATCH 44/48] Fix CustomDataManager crash --- .../mineplex/core/customdata/CustomDataManager.java | 11 ++++++++--- .../src/mineplex/core/customdata/MineplexPlayer.java | 3 ++- .../customdata/repository/CustomDataRepository.java | 11 ++++++----- .../game/games/gladiators/hotbar/HotbarEditor.java | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java index cd0543674..26652d24a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java @@ -48,10 +48,15 @@ public class CustomDataManager extends MiniDbClientPlugin return new PlayerCustomData(_repository); } - @Override - public void saveData(String name, int accountId) + public void saveAsync(Player player) { - _repository.saveData(name, accountId); + final int accountId = getClientManager().getAccountId(player); + final String name = player.getName(); + + if (accountId == -1) + return; + + runAsync(() -> _repository.saveData(name, accountId)); } public CorePlayer getCorePlayer(Player player) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java index e49f75211..bf350f843 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java @@ -27,10 +27,11 @@ public abstract class MineplexPlayer return ""; } - public void put(String key, int data) + public void put(String key, int data, boolean save) { key = getKeyPrefix() + key; _customDataManager.Get(getPlayer()).setData(key, data); + if (save) _customDataManager.saveAsync(_player); } public int get(String key) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java index 328aa6e6f..c896f2a03 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java @@ -3,6 +3,7 @@ package mineplex.core.customdata.repository; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Map; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -71,20 +72,20 @@ public class CustomDataRepository extends RepositoryBase { PlayerCustomData data = _customDataManager.Get(name); - for (CustomData cd : data.getDataMap().keySet()) + for (Map.Entry entry : data.getDataMap().entrySet()) { if (executeUpdate( UPDATE_DATA, - new ColumnInt("data", data.getDataMap().get(cd)), + new ColumnInt("data", entry.getValue()), new ColumnInt("account", accountId), - new ColumnInt("customData", cd.getId())) < 1) + new ColumnInt("customData", entry.getKey().getId())) < 1) { // Not already in the DB executeUpdate( INSERT_DATA, new ColumnInt("account", accountId), - new ColumnInt("customData", cd.getId()), - new ColumnInt("data", data.getDataMap().get(cd)) + new ColumnInt("customData", entry.getKey().getId()), + new ColumnInt("data", entry.getValue()) ); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java index e9ecdeae7..e12ee785e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java @@ -180,7 +180,7 @@ public class HotbarEditor extends MiniPlugin save.setRod(save.getEmpty()); } - _host.Manager.getArcadePlayer(player).put("hotbar", save.toDataSaveNumber()); + _host.Manager.getArcadePlayer(player).put("hotbar", save.toDataSaveNumber(), true); player.sendMessage(F.main("Game", "Saved new hotbar layout!")); } } From cd3037e7e54acbabba6384e3b50a1ef1c1f38ea2 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Sat, 9 Jan 2016 18:37:24 -0500 Subject: [PATCH 45/48] Fix treasure purchases --- .../src/mineplex/core/treasure/gui/TreasurePage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java index ae345c49c..ca2ddc8b2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -158,7 +158,7 @@ public class TreasurePage extends ShopPageBase if (owned > 0) addButton(slot, item, new OpenTreasureButton(getPlayer(), _treasureLocation, treasureType)); else if (treasureType.isPurchasable()) - addButton(slot, item, new BuyChestButton(getPlayer(), _inventoryManager, this, treasureType.getName(), Material.CHEST, treasureType.getPurchasePrice())); + addButton(slot, item, new BuyChestButton(getPlayer(), _inventoryManager, this, treasureType.getItemName(), Material.CHEST, treasureType.getPurchasePrice())); else setItem(slot, item); } From 8193b5121b8734774abcef00cf270e3297a3e015 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Sat, 9 Jan 2016 18:39:47 -0500 Subject: [PATCH 46/48] Dont allow /disguise for YOUTUBE_SMALL --- .../Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java index 52a41e81e..4c827f171 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java @@ -62,7 +62,7 @@ public class DisguiseCommand extends CommandBase implements Listener public DisguiseCommand(HubManager plugin) { - super(plugin, Rank.JNR_DEV, new Rank[] {Rank.YOUTUBE, Rank.TWITCH, Rank.YOUTUBE_SMALL}, "disguise"); + super(plugin, Rank.JNR_DEV, new Rank[] {Rank.YOUTUBE, Rank.TWITCH}, "disguise"); plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); } From 83e5c7399e36185f88c6e5d3e69781fa6dd3ab39 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Sat, 9 Jan 2016 18:41:19 -0500 Subject: [PATCH 47/48] Fix YOUTUBE_SMALL preferences --- .../core/preferences/ui/ExclusivePreferencesPage.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java index 79afa7b23..2cde41914 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java @@ -124,7 +124,7 @@ public class ExclusivePreferencesPage extends ShopPageBase Date: Sat, 9 Jan 2016 18:44:32 -0500 Subject: [PATCH 48/48] Fix hub fly for YOUTUBE_SMALL --- .../Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java index fb2c0090e..b6882a1f9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java @@ -10,6 +10,7 @@ import org.bukkit.event.player.PlayerToggleFlightEvent; import org.bukkit.util.Vector; import mineplex.core.MiniPlugin; +import mineplex.core.common.Rank; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; @@ -82,8 +83,9 @@ public class JumpManager extends MiniPlugin { if (player.getGameMode() == GameMode.CREATIVE) continue; - - if (Manager.getPreferences().Get(player).Invisibility) + + Rank rank = Manager.GetClients().Get(player).GetRank(); + if (Manager.getPreferences().Get(player).Invisibility && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) { player.setAllowFlight(true); continue;