From 8330ef560ddc118b0a7e662e2c0b4e96076b01f4 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 4 Apr 2016 14:55:47 +0100 Subject: [PATCH 01/44] not rider spam --- .../src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java index 472363459..11520d2dc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java @@ -758,7 +758,6 @@ public abstract class SiegeWeapon implements Listener { if (!event.getPlayer().equals(_rider)) { - System.out.println("NOT RIDER"); return; } From 14207c2073f4919b5b7049b4bef5c60537485443 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 4 Apr 2016 14:56:20 +0100 Subject: [PATCH 02/44] clansbans --- .../src/mineplex/game/clans/Clans.java | 4 +- .../game/clans/clans/ClansManager.java | 55 ++++++++++++++----- .../game/clans/clans/ban/ClansBanManager.java | 31 ++++++++++- .../clans/clans/nether/NetherManager.java | 1 + .../game/clans/clans/nether/Portal.java | 6 +- 5 files changed, 76 insertions(+), 21 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 8385bc856..582aa5cdc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -107,7 +107,7 @@ public class Clans extends JavaPlugin Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); -// new ClansBanManager(this, _clientManager, _donationManager); + ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager); PacketHandler packetHandler = new PacketHandler(this); Punish punish = new Punish(this, webServerAddress, _clientManager); @@ -137,7 +137,7 @@ public class Clans extends JavaPlugin GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager); HologramManager hologram = new HologramManager(this, packetHandler); - _clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress); + _clansManager = new ClansManager(this, clansBans, serverStatusManager.getCurrentServerName(), packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress); new Recipes(this); new Farming(this); new BuildingShop(_clansManager, _clientManager, _donationManager); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 233b267e2..7c6ba76dc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -74,6 +74,7 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansUtility.ClanRelation; +import mineplex.game.clans.clans.ban.ClansBanManager; import mineplex.game.clans.clans.commands.ClanManagementCommand; import mineplex.game.clans.clans.commands.ClansAllyChatCommand; import mineplex.game.clans.clans.commands.ClansChatCommand; @@ -220,16 +221,19 @@ public class ClansManager extends MiniClientPluginimplements IRelati public String UserDataDir = UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "CLANS_USER_DATA" + File.separator; + private ClansBanManager _clansBans; + public ClanTips ClanTips; // Spawn area - public ClansManager(JavaPlugin plugin, String serverName, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress) + public ClansManager(JavaPlugin plugin, ClansBanManager clansBans, String serverName, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress) { super("Clans Manager", plugin); _instance = this; + _clansBans = clansBans; _punish = punish; _serverName = serverName; @@ -593,23 +597,34 @@ public class ClansManager extends MiniClientPluginimplements IRelati public void Join(PlayerJoinEvent event) { event.setJoinMessage(null); - + + if (_clansBans.willBeKicked(event.getPlayer())) + { + return; + } + if (IncognitoManager.Instance.Get(event.getPlayer()).Status) { return; } - - - for (Player other : UtilServer.getPlayers()) - { - if (_tutorial.inTutorial(other)) + + _clansBans.runAfterLoad(event.getPlayer().getName(), () -> { + if (_clansBans.Get(event.getPlayer().getName()).isBanned()) { - // Don't display join message if player in tutorial. - continue; + return; } - - other.sendMessage(F.sys("Join", event.getPlayer().getName())); - } + + for (Player other : UtilServer.getPlayers()) + { + if (_tutorial.inTutorial(other)) + { + // Don't display join message if player in tutorial. + continue; + } + + other.sendMessage(F.sys("Join", event.getPlayer().getName())); + } + }); } @EventHandler(priority = EventPriority.HIGHEST) @@ -621,7 +636,11 @@ public class ClansManager extends MiniClientPluginimplements IRelati { return; } - + + if (_clansBans.willBeKicked(event.getPlayer())) + { + return; + } for (Player other : UtilServer.getPlayers()) { @@ -644,6 +663,16 @@ public class ClansManager extends MiniClientPluginimplements IRelati return; } + if (_clansBans.willBeKicked(event.getPlayer())) + { + return; + } + + if (event.getReason().contains("You are banned from Clans")) + { + return; + } + if (event.getLeaveMessage() != null) { event.setLeaveMessage(null); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java index 96b7392c3..b0c5d4601 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java @@ -2,6 +2,7 @@ package mineplex.game.clans.clans.ban; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -12,8 +13,6 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.player.AsyncPlayerPreLoginEvent; -import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; @@ -23,6 +22,7 @@ import com.google.common.collect.Lists; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.ILoginProcessor; +import mineplex.core.common.DefaultHashMap; import mineplex.core.common.Pair; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; @@ -32,6 +32,7 @@ import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.donation.DonationManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ban.commands.ClansBanCommand; import mineplex.game.clans.clans.ban.ui.ClansBanShop; @@ -41,6 +42,7 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor private ClansBanRepository _repository; private Map _clients; private Map> _cache; + private DefaultHashMap> _runAfterLoad; private ClansBanShop _shop; private Map _toKick = new HashMap<>(); @@ -57,7 +59,7 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor _clients = new HashMap<>(); _cache = new HashMap<>(); - + _runAfterLoad = new DefaultHashMap<>(name -> new ArrayList<>()); _shop = new ClansBanShop(this, clientManager, donationManager); clientManager.addStoredProcedureLoginProcessor(this); @@ -232,6 +234,11 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor LoadClient(name, callback); } + public boolean willBeKicked(Player player) + { + return _toKick.containsKey(player.getName()); + } + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException { _repository.loadBans(playerName, client -> { @@ -246,6 +253,19 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor "\n" + C.cWhite + client.getLongestBan().getReason(); _toKick.put(playerName, reason); + + ClansManager.getInstance().runSyncLater(() -> { + if (Bukkit.getPlayer(playerName) != null) + { + Bukkit.getPlayer(playerName).kickPlayer(_toKick.remove(playerName)); + } + else + { + _runAfterLoad.get(playerName).forEach(Runnable::run); + _runAfterLoad.get(playerName).clear(); + } + }, 5L); + } }); } @@ -254,4 +274,9 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor { return "SELECT * FROM clanBans WHERE uuid = '" + uuid + "';"; } + + public void runAfterLoad(String playerName, Runnable run) + { + _runAfterLoad.get(playerName).add(run); + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index 2ba9aeb80..b17121c43 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -210,6 +210,7 @@ public class NetherManager extends MiniPlugin _clansManager.getItemMapManager().removeMap(player); }); } + if (event.getType() == UpdateType.SLOW) { _portals.forEach(portal -> { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/Portal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/Portal.java index 7d466ffd4..362599881 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/Portal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/Portal.java @@ -39,10 +39,10 @@ public class Portal if (!isValidPortalBlock(from.getBlock()) || !isValidPortalBlock(to.getBlock())) { if (!isValidPortalBlock(from.getBlock())) - from = UtilBlock.getInRadius(from.getBlock(), 12).keySet().stream().filter(this::isValidPortalBlock).limit(1).iterator().next().getLocation(); + from = UtilBlock.getInRadius(from.getBlock(), 4).keySet().stream().filter(this::isValidPortalBlock).limit(1).iterator().next().getLocation(); if (!isValidPortalBlock(to.getBlock())) - to = UtilBlock.getInRadius(to.getBlock(), 9).keySet().stream().filter(this::isValidPortalBlock).limit(1).iterator().next().getLocation(); + to = UtilBlock.getInRadius(to.getBlock(), 4).keySet().stream().filter(this::isValidPortalBlock).limit(1).iterator().next().getLocation(); if (to == null || from == null) { @@ -54,7 +54,7 @@ public class Portal } } - for (Block other : UtilBlock.getInRadius(from, 7.5d).keySet()) + for (Block other : UtilBlock.getInRadius(from, 25).keySet()) { if (other.getType() == Material.OBSIDIAN) { From b3b72f1ca0b6778813023963dddef99f5c7ac300 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 4 Apr 2016 20:40:58 +0100 Subject: [PATCH 03/44] commenting out clans bans --- .../src/mineplex/game/clans/Clans.java | 4 ++-- .../game/clans/clans/ClansManager.java | 24 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 582aa5cdc..e83c185f7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -107,7 +107,7 @@ public class Clans extends JavaPlugin Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); - ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager); +// ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager); PacketHandler packetHandler = new PacketHandler(this); Punish punish = new Punish(this, webServerAddress, _clientManager); @@ -137,7 +137,7 @@ public class Clans extends JavaPlugin GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager); HologramManager hologram = new HologramManager(this, packetHandler); - _clansManager = new ClansManager(this, clansBans, serverStatusManager.getCurrentServerName(), packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress); + _clansManager = new ClansManager(this, /*clansBans,*/ serverStatusManager.getCurrentServerName(), packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress); new Recipes(this); new Farming(this); new BuildingShop(_clansManager, _clientManager, _donationManager); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 7c6ba76dc..726432355 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -221,19 +221,19 @@ public class ClansManager extends MiniClientPluginimplements IRelati public String UserDataDir = UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "CLANS_USER_DATA" + File.separator; - private ClansBanManager _clansBans; + /*private ClansBanManager _clansBans;*/ public ClanTips ClanTips; // Spawn area - public ClansManager(JavaPlugin plugin, ClansBanManager clansBans, String serverName, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress) + public ClansManager(JavaPlugin plugin/*, ClansBanManager clansBans*/, String serverName, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress) { super("Clans Manager", plugin); _instance = this; - _clansBans = clansBans; + /*_clansBans = clansBans;*/ _punish = punish; _serverName = serverName; @@ -598,21 +598,21 @@ public class ClansManager extends MiniClientPluginimplements IRelati { event.setJoinMessage(null); - if (_clansBans.willBeKicked(event.getPlayer())) + /*if (_clansBans.willBeKicked(event.getPlayer())) { return; - } + }*/ if (IncognitoManager.Instance.Get(event.getPlayer()).Status) { return; } - _clansBans.runAfterLoad(event.getPlayer().getName(), () -> { + /*_clansBans.runAfterLoad(event.getPlayer().getName(), () -> { if (_clansBans.Get(event.getPlayer().getName()).isBanned()) { return; - } + }*/ for (Player other : UtilServer.getPlayers()) { @@ -624,7 +624,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati other.sendMessage(F.sys("Join", event.getPlayer().getName())); } - }); + /*});*/ } @EventHandler(priority = EventPriority.HIGHEST) @@ -637,10 +637,10 @@ public class ClansManager extends MiniClientPluginimplements IRelati return; } - if (_clansBans.willBeKicked(event.getPlayer())) + /*if (_clansBans.willBeKicked(event.getPlayer())) { return; - } + }*/ for (Player other : UtilServer.getPlayers()) { @@ -663,10 +663,10 @@ public class ClansManager extends MiniClientPluginimplements IRelati return; } - if (_clansBans.willBeKicked(event.getPlayer())) + /*if (_clansBans.willBeKicked(event.getPlayer())) { return; - } + }*/ if (event.getReason().contains("You are banned from Clans")) { From 7f92a3c0485a86b33054e7e1c34cb446d22619ef Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 5 Apr 2016 00:38:27 +0100 Subject: [PATCH 04/44] incognito changes --- .../src/mineplex/core/chat/Chat.java | 8 ++- .../core/incognito/IncognitoManager.java | 72 +++++++++---------- .../events/IncognitoStatusChangeEvent.java | 12 ++++ .../mineplex/core/message/MessageManager.java | 18 +++-- .../core/message/commands/AdminCommand.java | 13 +++- .../src/mineplex/game/clans/Clans.java | 6 +- .../game/clans/clans/ClansManager.java | 15 ++-- .../clans/clans/commands/ClansCommand.java | 2 +- .../clans/clans/staff/SilentChestOpen.java | 2 +- .../items/legendaries/MeridianScepter.java | 2 +- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 4 +- .../src/mineplex/hub/HubManager.java | 15 +++- .../src/mineplex/staffServer/StaffServer.java | 15 ++-- .../src/nautilus/game/arcade/Arcade.java | 6 +- .../nautilus/game/arcade/ArcadeManager.java | 31 ++++++-- 15 files changed, 142 insertions(+), 79 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index b0d9d7448..fcdb2aafa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -58,6 +58,7 @@ public class Chat extends MiniPlugin private CoreClientManager _clientManager; private PreferencesManager _preferences; private AchievementManager _achievements; + private IncognitoManager _incognitoManager; private String[] _hackusations = {"hack", "hax", "hacker", "hacking", "cheat", "cheater", "cheating", "forcefield", "flyhack", "flyhacking", "autoclick", "aimbot"}; private String _filterUrl = "https://chat.mineplex.com:8003/content/item/moderate"; @@ -74,10 +75,11 @@ public class Chat extends MiniPlugin private HashMap _playerLastMessage = new HashMap(); - public Chat(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences, AchievementManager achievements, String serverName) + public Chat(JavaPlugin plugin, IncognitoManager incognitoManager, CoreClientManager clientManager, PreferencesManager preferences, AchievementManager achievements, String serverName) { super("Chat", plugin); - + + _incognitoManager = incognitoManager; _clientManager = clientManager; _serverName = serverName; _preferences = preferences; @@ -308,7 +310,7 @@ public class Chat extends MiniPlugin Player sender = event.getPlayer(); - if (IncognitoManager.Instance.Get(sender).Status) + if (_incognitoManager != null && _incognitoManager.Get(sender).Status) { UtilPlayer.message(sender, C.cYellow + "You can not chat while incognito."); event.setCancelled(true); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java index db73b3b55..91d873faa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java @@ -2,24 +2,26 @@ package mineplex.core.incognito; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.player.AsyncPlayerPreLoginEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.MiniClientPlugin; +import com.google.common.base.Function; + import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; -import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.incognito.commands.IncognitoToggleCommand; +import mineplex.core.incognito.events.IncognitoHidePlayerEvent; import mineplex.core.incognito.events.IncognitoStatusChangeEvent; import mineplex.core.incognito.repository.IncognitoClient; import mineplex.core.incognito.repository.IncognitoRepository; @@ -31,17 +33,13 @@ public class IncognitoManager extends MiniDbClientPlugin { private CoreClientManager _clientManager; private IncognitoRepository _repository; - - public static IncognitoManager Instance; - + public IncognitoManager(JavaPlugin plugin, CoreClientManager clientManager, PacketHandler packetHandler) { super("Incognito", plugin, clientManager); _repository = new IncognitoRepository(this); _clientManager = clientManager; - - Instance = this; } public void addCommands() @@ -64,9 +62,23 @@ public class IncognitoManager extends MiniDbClientPlugin if (!enabled) { - for (Player other : UtilServer.getPlayers()) + if (event.doShow()) { - other.showPlayer(caller); + for (Player other : UtilServer.getPlayers()) + { + other.showPlayer(caller); + } + } + } + else + { + IncognitoHidePlayerEvent customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(caller)); + + if (!customEvent.isCancelled()) + { + UtilServer.getPlayersCollection().forEach(player -> { + player.hidePlayer(caller); + }); } } @@ -75,28 +87,6 @@ public class IncognitoManager extends MiniDbClientPlugin return enabled; } - @EventHandler(priority = EventPriority.LOWEST) - public void Update(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - { - UtilServer.getPlayersCollection().forEach(player -> - { - UtilServer.getPlayersCollection().forEach(other -> - { - if (Get(other).Status && !_clientManager.hasRank(player, _clientManager.Get(other).GetRank())) - player.hidePlayer(other); - - if (Get(player).Status) - { - if (!_clientManager.hasRank(other, _clientManager.Get(player).GetRank())) - other.hidePlayer(player); - } - }); - }); - } - } - @EventHandler(priority = EventPriority.HIGHEST) public void Join(PlayerJoinEvent event) { @@ -105,15 +95,23 @@ public class IncognitoManager extends MiniDbClientPlugin event.setJoinMessage(null); informIncognito(event.getPlayer()); } - + + IncognitoHidePlayerEvent customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(event.getPlayer())); + UtilServer.getPlayersCollection().forEach(player -> { - if (Get(event.getPlayer()).Status && !_clientManager.hasRank(player, _clientManager.Get(event.getPlayer()).GetRank())) + if (!customEvent.isCancelled() && Get(event.getPlayer()).Status && !_clientManager.hasRank(player, _clientManager.Get(event.getPlayer()).GetRank())) + { player.hidePlayer(event.getPlayer()); - + } + if (Get(player).Status) { - if (!_clientManager.hasRank(event.getPlayer(), _clientManager.Get(player).GetRank())) + IncognitoHidePlayerEvent customEvent2 = UtilServer.CallEvent(new IncognitoHidePlayerEvent(player)); + + if (!customEvent2.isCancelled() && !_clientManager.hasRank(event.getPlayer(), _clientManager.Get(player).GetRank())) + { event.getPlayer().hidePlayer(player); + } } }); } @@ -153,7 +151,7 @@ public class IncognitoManager extends MiniDbClientPlugin { return _repository; } - + @Override public String getQuery(int accountId, String uuid, String name) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoStatusChangeEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoStatusChangeEvent.java index 1bf0f1ed2..79e3291ee 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoStatusChangeEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoStatusChangeEvent.java @@ -13,6 +13,8 @@ public class IncognitoStatusChangeEvent extends Event private boolean _cancelled; + private boolean _show = true; + public IncognitoStatusChangeEvent(Player player, boolean newState) { _player = player; @@ -49,4 +51,14 @@ public class IncognitoStatusChangeEvent extends Event return handlers; } + public void show(boolean show) + { + _show = show; + } + + public boolean doShow() + { + return _show; + } + } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index 8e1790063..a84ed8cdf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -27,7 +27,12 @@ import mineplex.core.friend.data.FriendData; import mineplex.core.friend.data.FriendStatus; import mineplex.core.ignore.IgnoreManager; import mineplex.core.incognito.IncognitoManager; -import mineplex.core.message.commands.*; +import mineplex.core.message.commands.AdminCommand; +import mineplex.core.message.commands.AnnounceCommand; +import mineplex.core.message.commands.MessageAdminCommand; +import mineplex.core.message.commands.MessageCommand; +import mineplex.core.message.commands.ResendAdminCommand; +import mineplex.core.message.commands.ResendCommand; import mineplex.core.message.redis.AnnouncementHandler; import mineplex.core.message.redis.MessageHandler; import mineplex.core.message.redis.RedisMessage; @@ -45,6 +50,8 @@ public class MessageManager extends MiniClientPlugin private CoreClientManager _clientManager; private FriendManager _friendsManager; private IgnoreManager _ignoreManager; + private IncognitoManager _incognitoManager; + private HashMap _messageTimeouts = new HashMap(); private PreferencesManager _preferences; private Punish _punish; @@ -52,11 +59,12 @@ public class MessageManager extends MiniClientPlugin private ArrayList _randomMessage; private String _serverName; - public MessageManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences, + public MessageManager(JavaPlugin plugin, IncognitoManager incognitoManager, CoreClientManager clientManager, PreferencesManager preferences, IgnoreManager ignoreManager, Punish punish, FriendManager friendManager, Chat chat) { super("Message", plugin); - + + _incognitoManager = incognitoManager; _clientManager = clientManager; _preferences = preferences; _ignoreManager = ignoreManager; @@ -86,7 +94,7 @@ public class MessageManager extends MiniClientPlugin addCommand(new AnnounceCommand(this)); //addCommand(new GlobalCommand(this)); - addCommand(new AdminCommand(this)); + addCommand(new AdminCommand(this, _incognitoManager)); } @Override @@ -523,7 +531,7 @@ public class MessageManager extends MiniClientPlugin // If this is a message inside the server if (to != null) { - if (IncognitoManager.Instance.Get(to).Status) + if (_incognitoManager.Get(to).Status) { UtilPlayer.message(sender, F.main("Online Player Search", F.elem("0") + " matches for [" + F.elem(target) + "].")); return; 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 f9c2242d1..be869c072 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java @@ -9,14 +9,18 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.incognito.IncognitoManager; import mineplex.core.message.MessageManager; -import mineplex.core.visibility.VisibilityManager; public class AdminCommand extends CommandBase { - public AdminCommand(MessageManager plugin) + private IncognitoManager _incognitoManager; + + public AdminCommand(MessageManager plugin, IncognitoManager incognitoManager) { super(plugin, Rank.ALL, "a","admin"); + + _incognitoManager = incognitoManager; } @Override @@ -51,6 +55,11 @@ public class AdminCommand extends CommandBase { if (Plugin.GetClientManager().Get(to).GetRank().has(Rank.HELPER)) { + if (_incognitoManager.Get(to).Status) + { + continue; + } + if (!to.equals(caller)) UtilPlayer.message(to, F.rank(Plugin.GetClientManager().Get(caller).GetRank()) + " " + caller.getName() + " " + C.cPurple + message); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index bf654ff83..a9e32d2dd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -120,12 +120,12 @@ public class Clans extends JavaPlugin IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); - new IncognitoManager(this, _clientManager, packetHandler); + IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler); StatsManager statsManager = new StatsManager(this, _clientManager); AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager); - Chat chat = new Chat(this, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); - new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat); + Chat chat = new Chat(this, incognito, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); + new MessageManager(this, incognito, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat); new MemoryFix(this); new FoodDupeFix(this); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 567362919..6c1165401 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -74,7 +74,6 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansUtility.ClanRelation; -import mineplex.game.clans.clans.ban.ClansBanManager; import mineplex.game.clans.clans.commands.ClanManagementCommand; import mineplex.game.clans.clans.commands.ClansAllyChatCommand; import mineplex.game.clans.clans.commands.ClansChatCommand; @@ -99,7 +98,6 @@ import mineplex.game.clans.clans.redis.ClanLoadCommandHandler; import mineplex.game.clans.clans.regions.ClansRegions; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; import mineplex.game.clans.clans.siege.SiegeManager; -import mineplex.game.clans.clans.siege.outpost.OutpostManager; import mineplex.game.clans.clans.staff.SilentChestOpen; import mineplex.game.clans.clans.supplyDrop.SupplyDropManager; import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager; @@ -172,6 +170,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati private NetherManager _netherManager; private DamageManager _damageManager; private SiegeManager _siegeManager; + private IncognitoManager _incognitoManager; private ClansBlacklist _blacklist; @@ -236,6 +235,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati /*_clansBans = clansBans;*/ _punish = punish; + _incognitoManager = new IncognitoManager(plugin, clientManager, packetHandler); _serverName = serverName; _clientManager = clientManager; _combatManager = new CombatManager(plugin); @@ -603,7 +603,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati return; }*/ - if (IncognitoManager.Instance.Get(event.getPlayer()).Status) + if (_incognitoManager.Get(event.getPlayer()).Status) { return; } @@ -632,7 +632,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati { event.setQuitMessage(null); - if (IncognitoManager.Instance.Get(event.getPlayer()).Status) + if (_incognitoManager.Get(event.getPlayer()).Status) { return; } @@ -657,7 +657,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati @EventHandler(priority = EventPriority.HIGHEST) public void Kick(PlayerKickEvent event) { - if (IncognitoManager.Instance.Get(event.getPlayer()).Status) + if (_incognitoManager.Get(event.getPlayer()).Status) { event.setLeaveMessage(null); return; @@ -1370,4 +1370,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati { return _siegeManager; } + + public IncognitoManager getIncognitoManager() + { + return _incognitoManager; + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 7d063af44..741fc365a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -357,7 +357,7 @@ public class ClansCommand extends CommandBase } Player target = UtilPlayer.searchOnline(caller, args[1], true); - if (target == null || IncognitoManager.Instance.Get(target).Status) return; + if (target == null || _clansManager.getIncognitoManager().Get(target).Status) return; Plugin.getClanUtility().invite(caller, clan, target); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/staff/SilentChestOpen.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/staff/SilentChestOpen.java index c3fe7119d..2f9bfabae 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/staff/SilentChestOpen.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/staff/SilentChestOpen.java @@ -25,7 +25,7 @@ public class SilentChestOpen extends MiniPlugin @EventHandler public void onInteract(PlayerInteractEvent event) { - if (!IncognitoManager.Instance.Get(event.getPlayer()).Status) + if (!_clansManager.getIncognitoManager().Get(event.getPlayer()).Status) return; if (!ClansManager.getInstance().getClientManager().hasRank(event.getPlayer(), Rank.CMOD)) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java index d29c7a9c1..cff2d6e38 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java @@ -152,7 +152,7 @@ public class MeridianScepter extends LegendaryItem continue; } - if (IncognitoManager.Instance.Get(closest).Status) + if (ClansManager.getInstance().getIncognitoManager().Get(closest).Status) { continue; } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index e87cd18d4..b663e7f1d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -143,8 +143,8 @@ public class Hub extends JavaPlugin implements IRelation IncognitoManager incognito = new IncognitoManager(this, clientManager, packetHandler); new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager); - Chat chat = new Chat(this, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); - new MessageManager(this, clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); + Chat chat = new Chat(this, incognito, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); + new MessageManager(this, incognito, clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); new MemoryFix(this); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); new CustomTagFix(this, packetHandler); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 985e8c5f3..da9d102aa 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -9,8 +9,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Random; -import mineplex.core.reward.RewardManager; -import mineplex.core.valentines.ValentinesGiftManager; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -74,8 +72,8 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.types.GadgetType; -import mineplex.core.giveaway.GiveawayManager; import mineplex.core.hologram.HologramManager; +import mineplex.core.incognito.events.IncognitoHidePlayerEvent; import mineplex.core.inventory.InventoryManager; import mineplex.core.message.PrivateMessageEvent; import mineplex.core.mount.MountManager; @@ -97,12 +95,14 @@ import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; +import mineplex.core.reward.RewardManager; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; import mineplex.core.treasure.TreasureManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.valentines.ValentinesGiftManager; import mineplex.hub.commands.DisguiseCommand; import mineplex.hub.commands.ForcefieldRadius; import mineplex.hub.commands.GadgetToggle; @@ -574,6 +574,15 @@ public class HubManager extends MiniClientPlugin event.setCancelled(true); } } + + @EventHandler + public void Incog(IncognitoHidePlayerEvent event) + { + if (!_clientManager.hasRank(event.getPlayer(), Rank.ADMIN)) + { + event.setCancelled(true); + } + } @EventHandler public void PlayerChat(AsyncPlayerChatEvent event) diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java index cdb02169a..33e1eb2d5 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java @@ -2,6 +2,12 @@ package mineplex.staffServer; import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_8_R3.CraftServer; +import org.bukkit.plugin.java.JavaPlugin; + +import com.mojang.authlib.GameProfile; + import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; @@ -9,6 +15,7 @@ import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; import mineplex.core.creature.Creature; import mineplex.core.donation.DonationManager; +import mineplex.core.incognito.IncognitoManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.memory.MemoryFix; import mineplex.core.monitor.LagMeter; @@ -26,12 +33,6 @@ import mineplex.staffServer.customerSupport.CustomerSupport; import mineplex.staffServer.salespackage.SalesPackageManager; import net.minecraft.server.v1_8_R3.MinecraftServer; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_8_R3.CraftServer; -import org.bukkit.plugin.java.JavaPlugin; - -import com.mojang.authlib.GameProfile; - public class StaffServer extends JavaPlugin { private String WEB_CONFIG = "webServer"; @@ -60,7 +61,7 @@ public class StaffServer extends JavaPlugin preferenceManager.GiveItem = false; Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName()); - new Chat(this, clientManager, preferenceManager, new AchievementManager(new StatsManager(this, clientManager), clientManager, donationManager), serverStatusManager.getCurrentServerName()); + new Chat(this, null, clientManager, preferenceManager, new AchievementManager(new StatsManager(this, clientManager), clientManager, donationManager), serverStatusManager.getCurrentServerName()); new MemoryFix(this); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 35d44e8cd..72b1024b1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -134,8 +134,8 @@ public class Arcade extends JavaPlugin StatsManager statsManager = new StatsManager(this, _clientManager); AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager); FriendManager friendManager = new FriendManager(this, _clientManager, preferenceManager, portal); - Chat chat = new Chat(this, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); - new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); + Chat chat = new Chat(this, incognito, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); + new MessageManager(this, incognito, _clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); BlockRestore blockRestore = new BlockRestore(this); @@ -157,7 +157,7 @@ public class Arcade extends JavaPlugin //Arcade Manager PollManager pollManager = new PollManager(this, _clientManager, _donationManager); - _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, customDataManager, punish); + _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, incognito, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, customDataManager, punish); new MemoryFix(this); new CustomTagFix(this, packetHandler); 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 4aa33a1d3..6dd245b99 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -191,6 +191,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation private ResourcePackManager _resourcePackManager; private CustomDataManager _customDataManager; private Punish _punishmentManager; + + private IncognitoManager _incognitoManager; private TaskManager _taskManager; private PacketHandler _packetHandler; @@ -212,7 +214,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig, CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager, - StatsManager statsManager, AchievementManager achievementManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, Chat chat, + StatsManager statsManager, IncognitoManager incognitoManager, AchievementManager achievementManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, Chat chat, Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler, CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress, PollManager pollManager, NpcManager npcManager, CustomDataManager customDataManager, Punish punish) @@ -224,6 +226,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation // Modules _blockRestore = new BlockRestore(plugin); + _incognitoManager = incognitoManager; + _blood = blood; _preferencesManager = preferences; @@ -616,7 +620,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation { if (event.getNewState() && _game != null && _game.IsPlaying(event.getPlayer()) && _game.IsLive()) { - UtilPlayer.message(event.getPlayer(), F.main("Incognito", "You may not go incognito whilst in a game.")); + addSpectator(event.getPlayer(), true); event.setCancelled(true); return; } @@ -624,13 +628,28 @@ public class ArcadeManager extends MiniPlugin implements IRelation if (event.getNewState()) { UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName())); + + if (_game == null || _game.GetState() != GameState.Live) + { + _specList.add(event.getPlayer()); + } } else { UtilServer.broadcast(F.sys("Join", event.getPlayer().getName())); + + if (_game != null && isSpectator(event.getPlayer())) + { + if (_game.GetState() != GameState.Live) + { + _specList.remove(event.getPlayer()); + } + + event.show(false); + } } } - + @EventHandler public void MessageMOTD(ServerListPingEvent event) { @@ -695,7 +714,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation { String name = event.getPlayer().getName(); - if (IncognitoManager.Instance.Get(event.getPlayer()).Status) + if (_incognitoManager.Get(event.getPlayer()).Status) { event.setJoinMessage(null); return; @@ -714,7 +733,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation @EventHandler public void MessageQuit(PlayerQuitEvent event) { - if (IncognitoManager.Instance.Get(event.getPlayer()).Status) + if (_incognitoManager.Get(event.getPlayer()).Status) { event.setQuitMessage(null); return; @@ -1123,7 +1142,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation public boolean IsObserver(Player player) { - if (IncognitoManager.Instance.Get(player).Status) + if (_incognitoManager.Get(player).Status) { _specList.add(player); } From 23232efd63cc1caaebb39a455effe443ee66cb1a Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 5 Apr 2016 13:04:39 +1000 Subject: [PATCH 05/44] Merge remote-tracking branch 'remotes/origin/develop' into clans/beta # Conflicts: # Plugins/Mineplex.Core/src/mineplex/core/MiniPlugin.java # Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResourcePackManager.java --- .../src/mineplex/bungee/motd/MotdManager.java | 4 +- .../game/clans/clans/siege/weapon/Cannon.java | 40 +++++++++---------- .../hub/server/ui/ServerGameMenu.java | 4 +- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java index 324da4b52..1f5bc2b09 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java @@ -56,12 +56,12 @@ public class MotdManager implements Listener, Runnable //String motdLine = "§f§l◄ §c§lMaintenance§f§l ►"; //String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►"; // String motdLine = " §2§l§n M O N S T E R M A Z E B E T A §f"; - String motdLine = " §f❄ §2§lMerry Christmas §f❄ §2§lElf Presents §f❄"; + String motdLine = " §f> §4§lCLANS BETA §f- §c§lOpen to Everyone §f<"; // String motdLine = " §f❄ §2§lServer Maintenance §f❄ §2§lBe Back Soon §f❄"; //String motdLine = " §d§lRank Sale §a§l40% Off"); //String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►"); - updateMainMotd(" §c§m §f§m §c§m §f§m §2§l§m[ §r §c§lMineplex§r §f§lGames§r §2§l§m ]§f§m §c§m §f§m §c§m §r", motdLine); + updateMainMotd(" §f§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§f§m §r", motdLine); System.out.println("Updated Bungee MOTD"); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java index ea9bb2cad..45510438c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java @@ -77,11 +77,11 @@ public class Cannon extends SiegeWeapon return false; } - if (!_ownerClan.isMember(player)) - { - UtilPlayer.message(player, F.main("Clans", "This cannon is not owned by your Clan.")); - return false; - } +// if (!_ownerClan.isMember(player)) +// { +// UtilPlayer.message(player, F.main("Clans", "This cannon is not owned by your Clan.")); +// return false; +// } if(_clans.hasTimer(player)) { @@ -107,11 +107,11 @@ public class Cannon extends SiegeWeapon enableInventory(UtilServer.getServer().createInventory(null, InventoryType.DISPENSER, C.cDAquaB + _name), new AccessRule(AccessType.RCLICK_BB, player -> player.equals(getRider()))); setRideable(new AccessRule(AccessType.RCLICK_BB, player -> { - if (!_ownerClan.isMember(player)) - { - UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan.")); - return false; - } +// if (!_ownerClan.isMember(player)) +// { +// UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan.")); +// return false; +// } if (getRider() != null && !getRider().equals(player)) { @@ -161,11 +161,11 @@ public class Cannon extends SiegeWeapon return false; } - if (!_ownerClan.isMember(player)) - { - UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan.")); - return false; - } +// if (!_ownerClan.isMember(player)) +// { +// UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan.")); +// return false; +// } if (_clans.hasTimer(player)) { @@ -191,11 +191,11 @@ public class Cannon extends SiegeWeapon enableInventory(UtilServer.getServer().createInventory(null, InventoryType.DISPENSER, C.cDAquaB + _name), new AccessRule(AccessType.RCLICK_BB, player -> player.equals(getRider()))); setRideable(new AccessRule(AccessType.RCLICK_BB, player -> { - if (!_ownerClan.isMember(player)) - { - UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan.")); - return false; - } +// if (!_ownerClan.isMember(player)) +// { +// UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan.")); +// return false; +// } if (getRider() != null && !getRider().equals(player)) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java index 246b93fc2..20764ef6b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -272,9 +272,9 @@ public class ServerGameMenu extends ShopPageBase C.Reset + "the games you want, when you want.", }).setHideInfo(true).build(), new SelectPLAYERButton(this)); - addButton(40, new ItemBuilder(Material.IRON_DOOR).setTitle(C.cYellowB + "Mineplex Clans " + C.cGray + "Champions Teams").addLore(new String[] + addButton(40, new ItemBuilder(Material.IRON_DOOR).setTitle(C.cYellowB + "Mineplex Clans " + C.cGray + "Factions PvP").addLore(new String[] { - (_extraValue ? C.cAquaB : C.cWhiteB) + "ALPHA RELEASE", + (_extraValue ? C.cAquaB : C.cWhiteB) + "BETA RELEASE", C.Reset + "", C.Reset + "Equip custom skills and builds", C.Reset + "and join your clan to destroy", From ae87db1742553d43fdd953df3bc28eba62e3c162 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 5 Apr 2016 13:04:52 +1000 Subject: [PATCH 06/44] Fix TNT generator timings --- .../game/clans/clans/tntGenerator/TntGeneratorManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/tntGenerator/TntGeneratorManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/tntGenerator/TntGeneratorManager.java index 22a370533..cf57f77d1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/tntGenerator/TntGeneratorManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/tntGenerator/TntGeneratorManager.java @@ -12,7 +12,7 @@ import mineplex.game.clans.clans.ClansManager; public class TntGeneratorManager extends MiniPlugin { - public static final int SECONDS_PER_TNT = 30;//60 * 60 * 10; // 10 Hours + public static final int SECONDS_PER_TNT = 60 * 60 * 12; // 12 Hours public static final int MAX_GENERATOR_STOCK = 3; private ClansManager _clansManager; From b34a175a2bbb55a7bd1f05a999404bdb743d8e56 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Tue, 5 Apr 2016 00:35:44 -0500 Subject: [PATCH 07/44] Fixed error in Outpost throwing NPE. --- .../src/mineplex/game/clans/clans/siege/outpost/Outpost.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java index 3648885b9..f8dbbe9cb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java @@ -83,7 +83,7 @@ public class Outpost implements Listener private Location _core; private LinkedHashMap _blocks; - private LinkedHashMap _buildQueue; + private LinkedHashMap _buildQueue = new LinkedHashMap<>(); protected OutpostType _type; private OutpostState _state; From e23362bd6fae16fb8b06a8b43943ea30011a7e61 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Tue, 5 Apr 2016 00:36:00 -0500 Subject: [PATCH 08/44] Fixed NPE in OrderedObjective --- .../game/clans/tutorial/objective/OrderedObjective.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/OrderedObjective.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/OrderedObjective.java index 91302df37..450d3b167 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/OrderedObjective.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/OrderedObjective.java @@ -46,7 +46,7 @@ public abstract class OrderedObjective extends Objectiv OrderedObjectiveData data = getData(player); assert index == data.getIndex(); - if (data.getIndex() + 1 >= _goals.size()) + if (data == null || data.getIndex() + 1 >= _goals.size()) { finish(player); } From dd5b2d5e3f773d2b8d5e16979d6f47ed5a29ec23 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Tue, 5 Apr 2016 00:36:18 -0500 Subject: [PATCH 09/44] Fixed NPE with poison condition effect. --- .../mineplex/minecraft/game/core/condition/ConditionEffect.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionEffect.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionEffect.java index 74e3f7473..718434d95 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionEffect.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionEffect.java @@ -379,7 +379,7 @@ public class ConditionEffect implements Listener Manager.getDamagerManager().NewDamageEvent(ent, condition.GetSource(), null, DamageCause.CUSTOM, 0.1, false, true, false, - condition.GetSource().getName(), "Poison"); + condition.GetSource() != null ? condition.GetSource().getName() : "The Mighty Defek7", "Poison"); } } From cfac41f2168a2b8ccc5c93dc85878bc9c15b3816 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 5 Apr 2016 12:37:04 +0100 Subject: [PATCH 10/44] full server trainee+ fix --- .../src/mineplex/game/clans/clans/ClansManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 6c1165401..1eaa3abda 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -1202,10 +1202,11 @@ public class ClansManager extends MiniClientPluginimplements IRelati { Rank rank = _clientManager.Get(event.getPlayer()).GetRank(); - if (rank.has(Rank.MODERATOR)) + if (rank.has(Rank.HELPER)) { event.allow(); event.setResult(PlayerLoginEvent.Result.ALLOWED); + return; } if (UtilServer.getPlayers().length >= UtilServer.getServer().getMaxPlayers() && !rank.has(Rank.ADMIN) && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp()) From be63012d1898010c0c0aaf162f7a76c40cf176ef Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 5 Apr 2016 12:43:19 +0100 Subject: [PATCH 11/44] make trainees+ not count to kicked player count --- .../game/clans/clans/ClansManager.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 1eaa3abda..fd275f63e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -1209,11 +1209,28 @@ public class ClansManager extends MiniClientPluginimplements IRelati return; } - if (UtilServer.getPlayers().length >= UtilServer.getServer().getMaxPlayers() && !rank.has(Rank.ADMIN) && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp()) + int online = 0; + + for (Player player : UtilServer.getPlayers()) + { + if (_clientManager.hasRank(player, Rank.HELPER)) + { + continue; + } + + online++; + } + + if (online >= UtilServer.getServer().getMaxPlayers() && !rank.has(Rank.ADMIN) && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp()) { event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Clans Beta is full! Try again soon"); event.setKickMessage("Clans Beta is full! Try again soon"); } + else + { + event.allow(); + event.setResult(PlayerLoginEvent.Result.ALLOWED); + } } @EventHandler From 744d8891b4e4c3b0f99500dd490afd71c5d24e09 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 5 Apr 2016 22:58:03 +0100 Subject: [PATCH 12/44] import --- .../src/mineplex/game/clans/clans/ClansManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index fd275f63e..66bf8b575 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -57,6 +57,7 @@ import mineplex.core.explosion.Explosion; import mineplex.core.hologram.Hologram; import mineplex.core.hologram.HologramManager; import mineplex.core.incognito.IncognitoManager; +import mineplex.core.incognito.events.IncognitoHidePlayerEvent; import mineplex.core.incognito.events.IncognitoStatusChangeEvent; import mineplex.core.movement.Movement; import mineplex.core.npc.NpcManager; From 4bdd33c87bfd7b236de57b2a363d0aa546dc928a Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 5 Apr 2016 23:15:38 +0100 Subject: [PATCH 13/44] blowing holes in the ground and interacting with cannon sometimes not working --- .../clans/clans/siege/weapon/SiegeWeapon.java | 19 ++++++++++--------- .../goals/attackenemy/BlowUpWallGoal.java | 6 +++--- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java index 11520d2dc..ba9089851 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java @@ -162,15 +162,16 @@ public abstract class SiegeWeapon implements Listener _infoHologram = new Hologram(ClansManager.getInstance().getHologramManager(), _location.clone().add(.5, 3, .5), _name + " Health", getDisplayHealth()); _infoHologram.start(); -// _infoHologram.setInteraction((player, type) -> { -// if (player.equals(_rider)) -// { -// if (type.equals(ClickType.LEFT)) -// { -// handleLeftClick(player); -// } -// } -// }); + _infoHologram.setInteraction((player, type) -> { + if (type.equals(ClickType.LEFT)) + { + handleLeftClick(player); + } + else if (type.equals(ClickType.RIGHT)) + { + handleRightClick(player); + } + }); UtilServer.RegisterEvents(this); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/BlowUpWallGoal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/BlowUpWallGoal.java index ad7be8c42..23488e15a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/BlowUpWallGoal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/BlowUpWallGoal.java @@ -101,16 +101,16 @@ public class BlowUpWallGoal extends ObjectiveGoal FallingBlocks.Instance.Spawn(block.getLocation(), block.getType(), block.getData(), center); } }); - + + event.setCancelled(true); finish(shooter); } else { UtilPlayer.message(shooter, F.main("Clans", "You missed! Try to hit the enemy's front wall, that should make a nice big hole!")); UtilInv.give(shooter, Material.TNT); + event.setCancelled(true); } - - event.setCancelled(true); } @Override From 738825ea9d78de949a03b5d4fe3fb6e8a1e24b59 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 5 Apr 2016 23:37:08 +0100 Subject: [PATCH 14/44] perms for tutoirial command --- .../src/mineplex/game/clans/tutorial/command/FinishCommand.java | 2 +- .../mineplex/game/clans/tutorial/command/TutorialCommand.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/FinishCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/FinishCommand.java index 92decfb05..954db2c0d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/FinishCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/FinishCommand.java @@ -10,7 +10,7 @@ public class FinishCommand extends CommandBase { public FinishCommand(TutorialManager plugin) { - super(plugin, Rank.DEVELOPER, "finish", "end"); + super(plugin, Rank.JNR_DEV, "finish", "end"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/TutorialCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/TutorialCommand.java index cf38bd009..c9722a1bf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/TutorialCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/TutorialCommand.java @@ -13,7 +13,7 @@ public class TutorialCommand extends MultiCommandBase { public TutorialCommand(TutorialManager plugin) { - super(plugin, Rank.DEVELOPER, "tutorial", "tut"); + super(plugin, Rank.JNR_DEV, "tutorial", "tut"); AddCommand(new StartCommand(plugin)); AddCommand(new FinishCommand(plugin)); From d25f1abfbfc5f6737ff9d602b228c5340b88535b Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 5 Apr 2016 23:49:16 +0100 Subject: [PATCH 15/44] stop iron door from being opened by players not in clan (outpost) --- .../game/clans/clans/siege/outpost/Outpost.java | 17 +++++++++++++++++ .../mineplex/game/clans/gameplay/Gameplay.java | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java index f8dbbe9cb..6f2a19718 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java @@ -53,6 +53,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.event.ClansWaterPlaceEvent; +import mineplex.game.clans.clans.event.IronDoorOpenEvent; import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent; import mineplex.game.clans.clans.siege.outpost.build.OutpostBlock; @@ -561,6 +562,22 @@ public class Outpost implements Listener _ownerClan.inform("Your Clan's Outpost has been destroyed.", null); } + @EventHandler + public void doorOpen(IronDoorOpenEvent event) + { + if (!UtilAlg.inBoundingBox(event.getBlock().getLocation(), _startCorner.clone().subtract(.5, 0, .5), _endCorner)) + { + return; + } + + if (_ownerClan.isMember(event.getPlayer())) + { + return; + } + + event.setCancelled(true); + } + @EventHandler public void onSiegeWeaponExplode(SiegeWeaponExplodeEvent event) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java index 392273fa9..5a212665d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -68,6 +68,7 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.event.ClansWaterPlaceEvent; +import mineplex.game.clans.clans.event.IronDoorOpenEvent; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.minecraft.game.classcombat.Class.ClientClass; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; @@ -449,6 +450,13 @@ public class Gameplay extends MiniPlugin // Open else { + IronDoorOpenEvent customEvent = UtilServer.CallEvent(new IronDoorOpenEvent(event.getPlayer(), block)); + + if (customEvent.isCancelled()) + { + return; + } + if (block.getData() >= 8) block = block.getRelative(BlockFace.DOWN); if (block.getData() < 4) From d75d63a81a1ae28efdb2ad9f73f3ab13e1b14337 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 6 Apr 2016 18:26:56 +0100 Subject: [PATCH 16/44] some missing files and blacklist barrier block from block toss --- .../events/IncognitoHidePlayerEvent.java | 45 +++++++++++++++ .../clans/clans/event/IronDoorOpenEvent.java | 55 +++++++++++++++++++ .../classcombat/Skill/Brute/BlockToss.java | 1 + 3 files changed, 101 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoHidePlayerEvent.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/IronDoorOpenEvent.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoHidePlayerEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoHidePlayerEvent.java new file mode 100644 index 000000000..d26927cb1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoHidePlayerEvent.java @@ -0,0 +1,45 @@ +package mineplex.core.incognito.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class IncognitoHidePlayerEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Player _player; + + private boolean _cancelled; + + public IncognitoHidePlayerEvent(Player player) + { + _player = player; + } + + public Player getPlayer() + { + return _player; + } + + public void setCancelled(boolean cancelled) + { + _cancelled = cancelled; + } + + public boolean isCancelled() + { + return _cancelled; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/IronDoorOpenEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/IronDoorOpenEvent.java new file mode 100644 index 000000000..9b99c60cd --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/IronDoorOpenEvent.java @@ -0,0 +1,55 @@ +package mineplex.game.clans.clans.event; + +import java.sql.Timestamp; + +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class IronDoorOpenEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Player _player; + private Block _block; + + private boolean _cancelled; + + public IronDoorOpenEvent(Player player, Block block) + { + _player = player; + _block = block; + } + + public Player getPlayer() + { + return _player; + } + + public Block getBlock() + { + return _block; + } + + public void setCancelled(boolean cancelled) + { + _cancelled = cancelled; + } + + public boolean isCancelled() + { + return _cancelled; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java index cde190a34..c25d056b8 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java @@ -70,6 +70,7 @@ public class BlockToss extends SkillCharge implements IThrown Material.STONE_BUTTON, Material.WOOD_BUTTON, Material.LEVER, + Material.BARRIER, }; public BlockToss(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels) From 3a8ab581dde1e5df3a0d6c0a42bcf8b514d70e60 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 7 Apr 2016 06:52:52 +0100 Subject: [PATCH 17/44] Add JavaDoc to new classes to comply with the new standards --- .../core/incognito/events/IncognitoHidePlayerEvent.java | 4 +++- .../mineplex/game/clans/clans/event/IronDoorOpenEvent.java | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoHidePlayerEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoHidePlayerEvent.java index d26927cb1..54dabeebc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoHidePlayerEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoHidePlayerEvent.java @@ -4,12 +4,14 @@ import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +/** + * Called when an Incognito player is getting hidden from all other players. + */ public class IncognitoHidePlayerEvent extends Event { private static final HandlerList handlers = new HandlerList(); private Player _player; - private boolean _cancelled; public IncognitoHidePlayerEvent(Player player) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/IronDoorOpenEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/IronDoorOpenEvent.java index 9b99c60cd..5c22c5229 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/IronDoorOpenEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/IronDoorOpenEvent.java @@ -1,12 +1,15 @@ package mineplex.game.clans.clans.event; -import java.sql.Timestamp; - import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +/** + * Called before an iron door is opened by right clicking. + * + * (Custom mechanic in Clans) + */ public class IronDoorOpenEvent extends Event { private static final HandlerList handlers = new HandlerList(); From eed3df720a77a99d884a5f30ee8dad78b2db140a Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 7 Apr 2016 07:00:46 +0100 Subject: [PATCH 18/44] Disable incognito mode for staff members that have been demoted whilst using it. Also fixes a bug that caused IncognitoHidePlayerEvent fire even if the player logging in does not have incognito mode enabled. --- .../core/incognito/IncognitoManager.java | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java index 91d873faa..afb328093 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java @@ -17,6 +17,7 @@ import com.google.common.base.Function; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -90,30 +91,45 @@ public class IncognitoManager extends MiniDbClientPlugin @EventHandler(priority = EventPriority.HIGHEST) public void Join(PlayerJoinEvent event) { + Player player = event.getPlayer(); + + if (Get(event.getPlayer()).Status && !_clientManager.hasRank(event.getPlayer(), Rank.HELPER)) + { + Get(event.getPlayer()).Status = false; + runAsync(() -> _repository.setStatus(_clientManager.getAccountId(player), false)); + return; + } + if (Get(event.getPlayer()).Status) { event.setJoinMessage(null); - informIncognito(event.getPlayer()); + informIncognito(player); } - IncognitoHidePlayerEvent customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(event.getPlayer())); + IncognitoHidePlayerEvent customEvent = null; - UtilServer.getPlayersCollection().forEach(player -> { - if (!customEvent.isCancelled() && Get(event.getPlayer()).Status && !_clientManager.hasRank(player, _clientManager.Get(event.getPlayer()).GetRank())) + if (Get(event.getPlayer()).Status) + { + customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(player)); + } + + for (Player other : UtilServer.getPlayers()) + { + if (customEvent != null && !customEvent.isCancelled() && !_clientManager.hasRank(other, _clientManager.Get(player).GetRank())) { - player.hidePlayer(event.getPlayer()); + other.hidePlayer(player); } - if (Get(player).Status) + if (Get(other).Status) { - IncognitoHidePlayerEvent customEvent2 = UtilServer.CallEvent(new IncognitoHidePlayerEvent(player)); + IncognitoHidePlayerEvent customEvent2 = UtilServer.CallEvent(new IncognitoHidePlayerEvent(other)); - if (!customEvent2.isCancelled() && !_clientManager.hasRank(event.getPlayer(), _clientManager.Get(player).GetRank())) + if (!customEvent2.isCancelled() && !_clientManager.hasRank(player, _clientManager.Get(other).GetRank())) { - event.getPlayer().hidePlayer(player); + player.hidePlayer(other); } } - }); + } } @EventHandler(priority = EventPriority.HIGHEST) From 9ccec50fd03b42148c9fec0f0092d672939f4721 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 7 Apr 2016 08:06:16 +0100 Subject: [PATCH 19/44] Remove unnecessary database calls that checked for siege weapons remaining in the database, which is not possible, as siege weapons clean themselves up. --- .../game/clans/clans/siege/SiegeManager.java | 24 +------------------ 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java index 9744381f6..dedfd4a62 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java @@ -1,7 +1,5 @@ package mineplex.game.clans.clans.siege; -import java.util.Stack; - import org.bukkit.Location; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; @@ -188,8 +186,6 @@ public class SiegeManager extends MiniPlugin private void saveSiegeWeapons() { - final Stack queue = new Stack<>(); - for (final SiegeWeapon weapon : LiveSiegeWeapons.values()) { final SiegeWeaponToken token = weapon.toToken(); @@ -197,28 +193,10 @@ public class SiegeManager extends MiniPlugin if (UnsyncedSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId))) continue; - queue.push(() -> { + runAsync(() -> { _repository.updateWeapon(token); }); } - - - runAsync(() -> { - while (!queue.isEmpty()) - { - queue.pop().run(); - } - - _repository.getWeaponsByServer(_clansManager.getServerId(), tokens -> { - tokens.forEach(token -> { - if (!LiveSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId)) && !UnsyncedSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId))) - { - System.out.println("LiveSiegeWeapons no longer contains old weapon " + token.UniqueId + ", deleting."); - _repository.deleteWeapon(token.UniqueId); - } - }); - }); - }); } @EventHandler From f2ac2d87bf134e0fe923cff2519ad0e6f3309875 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 7 Apr 2016 08:07:18 +0100 Subject: [PATCH 20/44] Remove debug command, that could be very abused --- .../game/clans/clans/siege/SiegeManager.java | 2 -- .../siege/commands/CommandSiegeSupplies.java | 35 ------------------- 2 files changed, 37 deletions(-) delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/commands/CommandSiegeSupplies.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java index dedfd4a62..f4ae486e1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java @@ -56,8 +56,6 @@ public class SiegeManager extends MiniPlugin _outpostManager = new OutpostManager(clans, this); - addCommand(new CommandSiegeSupplies(_outpostManager)); - Instance = this; _repository = new SiegeWeaponRepository(clans.getPlugin()); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/commands/CommandSiegeSupplies.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/commands/CommandSiegeSupplies.java deleted file mode 100644 index 8f0b7a6ae..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/commands/CommandSiegeSupplies.java +++ /dev/null @@ -1,35 +0,0 @@ -package mineplex.game.clans.clans.siege.commands; - -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.game.clans.clans.siege.outpost.Outpost; -import mineplex.game.clans.clans.siege.outpost.OutpostManager; -import mineplex.game.clans.clans.siege.weapon.Cannon; - -public class CommandSiegeSupplies extends CommandBase -{ - public CommandSiegeSupplies(OutpostManager plugin) - { - super(plugin, Rank.MODERATOR, "siege"); - } - - @Override - public void Execute(Player caller, String[] args) - { - ItemStack outpost = new ItemStack(Outpost.OUTPOST_ITEM); - ItemStack cannons = new ItemStack(Cannon.CANNON_ITEM); - - outpost.setAmount(64); - cannons.setAmount(64); - - caller.getInventory().addItem(outpost); - caller.getInventory().addItem(cannons); - - UtilPlayer.message(caller, F.main("Clans", "Received supplies for a siege.")); - } -} From b70ff03185702b553c44259594b846be913eae84 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 7 Apr 2016 08:11:37 +0100 Subject: [PATCH 21/44] Fix siege weapon crater being spawned at the lowest block at the current collision location. This was causing issues when Cannons were fired at a vertical wall, and would not do any damage to the wall as it would just do damage to the blocks at the nearest ground block. --- .../clans/clans/siege/weapon/projectile/WeaponProjectile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java index fc893ceaf..a58e96ce0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java @@ -110,7 +110,7 @@ public class WeaponProjectile implements Listener if (!newEvent.isCancelled()) { - new Crater(_weapon, this, UtilBlock.nearestFloor(_projectileEntity.getLocation()), _attributes._craterSize, _attributes._craterChanceOfAir, _attributes._craterDoFire); + new Crater(_weapon, this, _projectileEntity.getLocation(), _attributes._craterSize, _attributes._craterChanceOfAir, _attributes._craterDoFire); } UtilServer.getServer().getOnlinePlayers().forEach(player -> player.playSound(_projectileEntity.getLocation(), Sound.EXPLODE, 1.f, 1.f)); From c484a80a14b70f905bda157268dc832663bf3cc9 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 7 Apr 2016 08:12:05 +0100 Subject: [PATCH 22/44] Remove incorrect import --- .../src/mineplex/game/clans/clans/siege/SiegeManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java index f4ae486e1..f58084378 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java @@ -21,7 +21,6 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.siege.commands.CommandSiegeSupplies; import mineplex.game.clans.clans.siege.outpost.OutpostManager; import mineplex.game.clans.clans.siege.repository.SiegeWeaponRepository; import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken; From 2c05743f625c0a93e9182791c8c24e3f5ce105b8 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 7 Apr 2016 21:01:25 +0100 Subject: [PATCH 23/44] Stop using static with Siege Manager --- .../game/clans/clans/ClansManager.java | 2 +- .../game/clans/clans/siege/SiegeManager.java | 7 +--- .../repository/SiegeWeaponRepository.java | 24 +++++++----- .../game/clans/tutorial/TutorialManager.java | 6 ++- .../tutorials/clans/ClansMainTutorial.java | 38 +++++++++++-------- .../clans/objective/AttackEnemyObjective.java | 6 ++- .../goals/attackenemy/MountCannonGoal.java | 9 ++++- 7 files changed, 53 insertions(+), 39 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 66bf8b575..9ce33da08 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -276,7 +276,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati _clanDisplay = new ClansDisplay(plugin, this); _clanGame = new ClansGame(plugin, this); _clanUtility = new ClansUtility(this); - _tutorial = new TutorialManager(plugin, clientManager, donationManager, chat, hologramManager, _npcManager, _taskManager); + _tutorial = new TutorialManager(plugin, clientManager, donationManager, chat, hologramManager, this, _npcManager, _taskManager); _itemMapManager = new ItemMapManager(this, _tutorial, _worldEvent); new TntGeneratorManager(plugin, this); new SupplyDropManager(plugin, this); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java index f58084378..e48801344 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java @@ -33,11 +33,8 @@ import net.minecraft.server.v1_8_R3.Material; public class SiegeManager extends MiniPlugin { private ClansManager _clansManager; - private OutpostManager _outpostManager; - public static SiegeManager Instance; - public NautHashMap LiveSiegeWeapons = new NautHashMap<>(); public NautHashMap UnsyncedSiegeWeapons = new NautHashMap<>(); @@ -55,9 +52,7 @@ public class SiegeManager extends MiniPlugin _outpostManager = new OutpostManager(clans, this); - Instance = this; - - _repository = new SiegeWeaponRepository(clans.getPlugin()); + _repository = new SiegeWeaponRepository(clans.getPlugin(), this); _outpostManager.loadOutposts(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/SiegeWeaponRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/SiegeWeaponRepository.java index 5fc7caca3..b43d47d23 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/SiegeWeaponRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/SiegeWeaponRepository.java @@ -44,23 +44,27 @@ public class SiegeWeaponRepository extends MinecraftRepository private static final String DELETE_WEAPON = "DELETE FROM clansSiegeWeapons WHERE uniqueId=?;"; - public SiegeWeaponRepository(JavaPlugin plugin) + private SiegeManager _siegeManager; + + public SiegeWeaponRepository(JavaPlugin plugin, SiegeManager siegeManager) { super(plugin, DBPool.getAccount()); + + _siegeManager = siegeManager; } public void deleteWeapon(final int uniqueId) { System.out.println("Siege Repo> Deleting weapon " + uniqueId); - SiegeManager.Instance.runAsync(() -> + _siegeManager.runAsync(() -> executeUpdate(DELETE_WEAPON, new ColumnInt("uniqueId", uniqueId)) ); } public void getWeaponById(final int uniqueId, final Callback callback) { - SiegeManager.Instance.runAsync(() -> + _siegeManager.runAsync(() -> executeQuery(GET_WEAPON_BY_ID, resultSet -> { SiegeWeaponToken token = new SiegeWeaponToken(); @@ -75,7 +79,7 @@ public class SiegeWeaponRepository extends MinecraftRepository public void getWeaponsByServer(final int serverId, final Callback> callback) { - SiegeManager.Instance.runAsync(() -> + _siegeManager.runAsync(() -> executeQuery(GET_WEAPONS_BY_SERVER, resultSet -> { List tokens = Lists.newArrayList(); @@ -95,7 +99,7 @@ public class SiegeWeaponRepository extends MinecraftRepository public void getWeaponsByClan(final ClanInfo clan, final Callback> callback) { - SiegeManager.Instance.runAsync(() -> + _siegeManager.runAsync(() -> executeQuery(GET_WEAPONS_BY_CLAN, resultSet -> { List tokens = Lists.newArrayList(); @@ -117,7 +121,7 @@ public class SiegeWeaponRepository extends MinecraftRepository { token.UniqueId = columns.getInt("uniqueId"); token.Location = UtilWorld.strToLoc(columns.getString("location")); - token.OwnerClan = SiegeManager.Instance.getClansManager().getClanUtility().getClanById(columns.getInt("ownerClan")); + token.OwnerClan = _siegeManager.getClansManager().getClanUtility().getClanById(columns.getInt("ownerClan")); token.WeaponType = columns.getByte("weaponType"); token.Health = columns.getShort("health"); token.Yaw = columns.getShort("yaw"); @@ -131,7 +135,7 @@ public class SiegeWeaponRepository extends MinecraftRepository { System.out.println("Siege Repo> Updating weapon " + token.UniqueId); - SiegeManager.Instance.runAsync(() -> + _siegeManager.runAsync(() -> executeUpdate(UPDATE_WEAPON, new ColumnInt("health", token.Health), new ColumnInt("yaw", token.Yaw), @@ -144,10 +148,10 @@ public class SiegeWeaponRepository extends MinecraftRepository { System.out.println("Siege Repo> Inserting new weapon " + token.UniqueId); - SiegeManager.Instance.runAsync(() -> + _siegeManager.runAsync(() -> executeUpdate(INSERT_WEAPON, new ColumnInt("uniqueId", token.UniqueId), - new ColumnInt("serverId", SiegeManager.Instance.getClansManager().getServerId()), + new ColumnInt("serverId", _siegeManager.getClansManager().getServerId()), new ColumnVarChar("location", 30, UtilWorld.locToStr(token.Location)), new ColumnInt("ownerClan", token.OwnerClan.getId()), new ColumnInt("weaponType", token.WeaponType), @@ -192,7 +196,7 @@ public class SiegeWeaponRepository extends MinecraftRepository @Override protected void initialize() { - SiegeManager.Instance.runAsync(() -> + _siegeManager.runAsync(() -> executeUpdate(CREATE) ); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java index 29609b670..d8593dc2f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java @@ -23,6 +23,8 @@ import mineplex.core.npc.NpcManager; import mineplex.core.scoreboard.ScoreboardManager; import mineplex.core.scoreboard.elements.ScoreboardElement; import mineplex.core.task.TaskManager; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.siege.SiegeManager; import mineplex.game.clans.message.ClansMessageManager; import mineplex.game.clans.tutorial.command.TutorialCommand; import mineplex.game.clans.tutorial.gui.TutorialShop; @@ -37,7 +39,7 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement private EnumMap _tutorialMap; private EnumMap _shopMap; // Don't need to do anything with shops currently - public TutorialManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Chat chat, HologramManager hologram, NpcManager npcManager, TaskManager taskManager) + public TutorialManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Chat chat, HologramManager hologram, ClansManager clansManager, NpcManager npcManager, TaskManager taskManager) { super("Clans Tutorial", plugin); @@ -48,7 +50,7 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement _tutorialMap = new EnumMap(TutorialType.class); _shopMap = new EnumMap(TutorialType.class); - addTutorial(TutorialType.MAIN, new ClansMainTutorial(plugin, _clansMessageManager, hologram, npcManager, taskManager)); + addTutorial(TutorialType.MAIN, new ClansMainTutorial(plugin, clansManager, _clansMessageManager, hologram, npcManager, taskManager)); chat.AddFilter(event -> { if (inTutorial(event.getPlayer())) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java index f26a6ac72..8a38565c2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java @@ -3,19 +3,14 @@ package mineplex.game.clans.tutorial.tutorials.clans; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import java.util.Objects; -import java.util.UUID; -import com.google.common.collect.Lists; -import mineplex.core.hologram.Hologram; -import mineplex.core.common.util.*; -import mineplex.core.task.TaskManager; -import mineplex.game.clans.clans.ClanInfo; -import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; -import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent; -import mineplex.game.clans.clans.event.PreEnergyShopBuyEvent; -import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.DyeColor; +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -30,17 +25,30 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; +import com.google.common.collect.Lists; + import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; import mineplex.core.hologram.HologramManager; import mineplex.core.npc.NpcManager; +import mineplex.core.task.TaskManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent; +import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; +import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent; +import mineplex.game.clans.clans.event.PreEnergyShopBuyEvent; import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent; +import mineplex.game.clans.clans.siege.SiegeManager; import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.message.ClansMessageManager; import mineplex.game.clans.spawn.Spawn; @@ -57,8 +65,6 @@ import mineplex.game.clans.tutorial.tutorials.clans.objective.FieldsObjective; import mineplex.game.clans.tutorial.tutorials.clans.objective.FinalObjective; import mineplex.game.clans.tutorial.tutorials.clans.objective.PurchaseItemsObjective; import mineplex.game.clans.tutorial.tutorials.clans.objective.ShopsObjective; -import mineplex.game.clans.tutorial.tutorials.clans.repository.TutorialRepository; -//import mineplex.game.clans.tutorial.tutorials.clans.repository.TutorialRepository; public class ClansMainTutorial extends Tutorial { @@ -79,7 +85,7 @@ public class ClansMainTutorial extends Tutorial ); - public ClansMainTutorial(JavaPlugin plugin, ClansMessageManager message, HologramManager hologram, NpcManager npcManager, TaskManager taskManager) + public ClansMainTutorial(JavaPlugin plugin, ClansManager clansManager, ClansMessageManager message, HologramManager hologram, NpcManager npcManager, TaskManager taskManager) { super(plugin, message, hologram, "Clans Tutorial", "main", Material.DIAMOND_SWORD, (byte) 0); @@ -100,7 +106,7 @@ public class ClansMainTutorial extends Tutorial // _repository = new TutorialRepository(ClansManager.getInstance().getClientManager()); addObjective(new ClanObjective(this, plugin)); - addObjective(new AttackEnemyObjective(this, plugin)); + addObjective(new AttackEnemyObjective(this, clansManager, plugin)); addObjective(new ShopsObjective(this, npcManager, plugin)); addObjective(new PurchaseItemsObjective(this, plugin)); addObjective(new ClassesObjective(this, plugin)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/AttackEnemyObjective.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/AttackEnemyObjective.java index 35ba6c7ec..53c44ec30 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/AttackEnemyObjective.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/AttackEnemyObjective.java @@ -30,6 +30,8 @@ import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.siege.SiegeManager; import mineplex.game.clans.clans.siege.weapon.Cannon; import mineplex.game.clans.tutorial.TutorialRegion; import mineplex.game.clans.tutorial.TutorialSession; @@ -49,7 +51,7 @@ public class AttackEnemyObjective extends OrderedObjective private DefaultHashMap> _shooters; - public AttackEnemyObjective(ClansMainTutorial clansMainTutorial, JavaPlugin javaPlugin) + public AttackEnemyObjective(ClansMainTutorial clansMainTutorial, ClansManager clansManager, JavaPlugin javaPlugin) { super(clansMainTutorial, javaPlugin, "Enemy Clans Tutorial", "Attack and raid this enemy!"); @@ -66,7 +68,7 @@ public class AttackEnemyObjective extends OrderedObjective 40 )); addGoal(new ClanInfoGoal(this)); - addGoal(new MountCannonGoal(this)); + addGoal(new MountCannonGoal(this, clansManager)); addGoal(new LoadCannonGoal(this)); addGoal(new BlowUpWallGoal(this)); addGoal(new StealEnemyPotatoesGoal(this)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/MountCannonGoal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/MountCannonGoal.java index a7d6c3562..c3620c601 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/MountCannonGoal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/MountCannonGoal.java @@ -9,6 +9,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import mineplex.core.common.util.UtilInv; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.siege.SiegeManager; import mineplex.game.clans.clans.siege.events.MountSiegeWeaponEvent; import mineplex.game.clans.clans.siege.weapon.Cannon; @@ -21,7 +22,9 @@ import mineplex.game.clans.tutorial.tutorials.clans.objective.AttackEnemyObjecti public class MountCannonGoal extends ObjectiveGoal { - public MountCannonGoal(AttackEnemyObjective objective) + private ClansManager _clansManager; + + public MountCannonGoal(AttackEnemyObjective objective, ClansManager clansManager) { super( objective, @@ -31,12 +34,14 @@ public class MountCannonGoal extends ObjectiveGoal + "TNT Cannons are the best way to do destroy enemy bases!", DyeColor.BLACK ); + + _clansManager = clansManager; } @Override protected void customStart(Player player) { - getObjective().getCannons().put(player.getName(), SiegeManager.Instance.spawnCannon(player, getObjective().getPlugin().getPoint(getObjective().getPlugin().getRegion(player), Point.CANNON), false)); + getObjective().getCannons().put(player.getName(), _clansManager.getSiegeManager().spawnCannon(player, getObjective().getPlugin().getPoint(getObjective().getPlugin().getRegion(player), Point.CANNON), false)); getObjective().getCannons().get(player.getName()).SetForcedVelocity(0.4, 2.45); getObjective().getCannons().get(player.getName()).setInvincible(true); From 79a2ef3608e961ffa6e834c8c79440f709a01fe5 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 7 Apr 2016 22:24:47 +0100 Subject: [PATCH 24/44] Fix staff members getting unhidden when in incognito whenever players are shown to the player (can happen when a regular player toggles player vision, and the staff member gets shown to all other players.) --- .../core/incognito/IncognitoManager.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java index afb328093..2bf7946fb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java @@ -131,6 +131,41 @@ public class IncognitoManager extends MiniDbClientPlugin } } } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + for (Player player : UtilServer.getPlayers()) + { + for (Player other : UtilServer.getPlayers()) + { + if (Get(player).Status) + { + IncognitoHidePlayerEvent customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(player)); + + if (!customEvent.isCancelled() && !_clientManager.hasRank(other, _clientManager.Get(player).GetRank())) + { + other.hidePlayer(player); + } + } + + if (Get(other).Status) + { + IncognitoHidePlayerEvent customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(other)); + + if (!customEvent.isCancelled() && !_clientManager.hasRank(player, _clientManager.Get(other).GetRank())) + { + player.hidePlayer(other); + } + } + } + } + } @EventHandler(priority = EventPriority.HIGHEST) public void Quit(PlayerQuitEvent event) From 8a2efa2f0b1c00d4c2a85f77d2ba26f89327e8bf Mon Sep 17 00:00:00 2001 From: Conrad S Date: Fri, 8 Apr 2016 10:48:55 -0400 Subject: [PATCH 25/44] Make sure a user has enough gold to make a purchase. --- .../repository/DonationRepository.java | 55 ++++++++++--------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java index 5e696359e..8b842f424 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java @@ -27,20 +27,20 @@ public class DonationRepository extends MinecraftRepository private static String CREATE_GEM_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountGemTransactions (id INT NOT NULL AUTO_INCREMENT, accountId INT, reason VARCHAR(100), gems INT, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id));"; private static String INSERT_COIN_TRANSACTION = "INSERT INTO accountCoinTransactions(accountId, reason, coins) VALUES(?, ?, ?);"; private static String UPDATE_ACCOUNT_COINS = "UPDATE accounts SET coins = coins + ? WHERE id = ?;"; - private static String UPDATE_ACCOUNT_GOLD = "UPDATE accounts SET gold = gold + ? WHERE id = ?;"; + private static String UPDATE_ACCOUNT_GOLD = "UPDATE accounts SET gold = gold + ? WHERE id = ? && gold >= ?;"; private static String SET_ACCOUNT_GOLD = "UPDATE accounts SET gold = ? WHERE id = ?;"; private static String UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_ = "UPDATE accounts SET gems = ?, coins = ? WHERE id = ? AND gems IS NULL AND coins IS NULL;"; private String _webAddress; - + public DonationRepository(JavaPlugin plugin, String webAddress) { super(plugin, DBPool.getAccount()); - + _webAddress = webAddress; } - - public void PurchaseKnownSalesPackage(final Callback callback, String name, final String uuid, final int cost, final int salesPackageId) + + public void PurchaseKnownSalesPackage(final Callback callback, String name, final String uuid, final int cost, final int salesPackageId) { final PurchaseToken token = new PurchaseToken(); token.AccountName = name; @@ -61,7 +61,7 @@ public class DonationRepository extends MinecraftRepository }); } }; - + handleDatabaseCall(new DatabaseRunnable(new Runnable() { public void run() @@ -70,7 +70,7 @@ public class DonationRepository extends MinecraftRepository } }), "Error purchasing known sales package in DonationRepository : "); } - + public void PurchaseUnknownSalesPackage(final Callback callback, final String name, final int accountId, final String packageName, final CurrencyType currencyType, final int cost) { final UnknownPurchaseToken token = new UnknownPurchaseToken(); @@ -96,7 +96,7 @@ public class DonationRepository extends MinecraftRepository executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", -cost), new ColumnInt("id", accountId)); } } - + Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable() { @Override @@ -107,7 +107,7 @@ public class DonationRepository extends MinecraftRepository }); } }; - + handleDatabaseCall(new DatabaseRunnable(new Runnable() { public void run() @@ -116,18 +116,18 @@ public class DonationRepository extends MinecraftRepository } }), "Error purchasing unknown sales package in DonationRepository : "); } - + public void gemReward(final Callback callback, final String giver, String name, final String uuid, final int greenGems) { final GemRewardToken token = new GemRewardToken(); token.Source = giver; token.Name = name; token.Amount = greenGems; - + final Callback extraCallback = new Callback() { public void run(final Boolean response) - { + { Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable() { @Override @@ -138,7 +138,7 @@ public class DonationRepository extends MinecraftRepository }); } }; - + handleDatabaseCall(new DatabaseRunnable(new Runnable() { public void run() @@ -147,14 +147,14 @@ public class DonationRepository extends MinecraftRepository } }), "Error updating player gem amount in DonationRepository : "); } - + public void rewardCoins(final Callback callback, final String giver, String name, final int accountId, final int coins) { final GemRewardToken token = new GemRewardToken(); token.Source = giver; token.Name = name; token.Amount = coins; - + final Callback extraCallback = new Callback() { public void run(final Boolean response) @@ -164,7 +164,7 @@ public class DonationRepository extends MinecraftRepository //executeUpdate(UPDATE_ACCOUNT_COINS, new ColumnInt("coins", coins), new ColumnInt("id", accountId)); //executeUpdate(INSERT_COIN_TRANSACTION, new ColumnInt("id", accountId), new ColumnVarChar("reason", 100, "Rewarded by " + giver), new ColumnInt("coins", coins)); } - + Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable() { @Override @@ -175,7 +175,7 @@ public class DonationRepository extends MinecraftRepository }); } }; - + handleDatabaseCall(new DatabaseRunnable(new Runnable() { public void run() @@ -184,21 +184,26 @@ public class DonationRepository extends MinecraftRepository } }), "Error updating player coin amount in DonationRepository : "); } - + public void rewardGold(final Callback callback, final String giver, final String name, final int accountId, final int gold) - { + { handleDatabaseCall(new DatabaseRunnable(new Runnable() { public void run() { - boolean success = executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId)) > 0; + ColumnInt min = new ColumnInt("gold", gold < 0 ? -gold : 0); + boolean success = executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId), min) > 0; callback.run(success); } }), "Error updating player gold amount in DonationRepository : "); } - + public void setGold(final Callback callback, final String giver, final String name, final int accountId, final int gold) - { + { + if (gold < 0) + { + throw new IllegalArgumentException("gold cannot be negative"); + } handleDatabaseCall(new DatabaseRunnable(new Runnable() { public void run() @@ -208,7 +213,7 @@ public class DonationRepository extends MinecraftRepository } }), "Error updating player gold amount in DonationRepository : "); } - + @Override protected void initialize() { @@ -240,12 +245,12 @@ public class DonationRepository extends MinecraftRepository public Donor retrieveDonorInfo(ResultSet resultSet) throws SQLException { Donor donor = new Donor(); - + while (resultSet.next()) { donor.setGold(resultSet.getInt(1)); } - + return donor; } } \ No newline at end of file From a04f7c23c6b749336c5f93492efc0b9f20e75b2e Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 8 Apr 2016 20:18:56 +0100 Subject: [PATCH 26/44] Disable incognito for staff in hub invisibility, and vice-versa --- .../core/incognito/IncognitoManager.java | 18 +++++--- .../commands/IncognitoToggleCommand.java | 6 +++ .../core/preferences/PreferencesManager.java | 41 ++++++++++++------- .../ui/ExclusivePreferencesPage.java | 8 ++++ .../src/mineplex/game/clans/Clans.java | 13 +++--- .../game/clans/clans/ClansManager.java | 4 +- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 7 +++- .../src/mineplex/staffServer/StaffServer.java | 2 +- .../src/nautilus/game/arcade/Arcade.java | 10 +++-- 9 files changed, 74 insertions(+), 35 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java index 2bf7946fb..18b94a27b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java @@ -2,8 +2,6 @@ package mineplex.core.incognito; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -13,8 +11,6 @@ import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; -import com.google.common.base.Function; - import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; @@ -27,6 +23,7 @@ import mineplex.core.incognito.events.IncognitoStatusChangeEvent; import mineplex.core.incognito.repository.IncognitoClient; import mineplex.core.incognito.repository.IncognitoRepository; import mineplex.core.packethandler.PacketHandler; +import mineplex.core.preferences.PreferencesManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -34,11 +31,12 @@ public class IncognitoManager extends MiniDbClientPlugin { private CoreClientManager _clientManager; private IncognitoRepository _repository; + private PreferencesManager _preferencesManager; public IncognitoManager(JavaPlugin plugin, CoreClientManager clientManager, PacketHandler packetHandler) { super("Incognito", plugin, clientManager); - + _repository = new IncognitoRepository(this); _clientManager = clientManager; } @@ -217,4 +215,14 @@ public class IncognitoManager extends MiniDbClientPlugin Get(playerName).Status = resultSet.getInt("status") == 1; } } + + public PreferencesManager getPreferences() + { + return _preferencesManager; + } + + public void setPreferencesManager(PreferencesManager preferencesManager) + { + _preferencesManager = preferencesManager; + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/commands/IncognitoToggleCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/commands/IncognitoToggleCommand.java index 23f54dca7..83eefcdc9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/commands/IncognitoToggleCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/commands/IncognitoToggleCommand.java @@ -18,6 +18,12 @@ public class IncognitoToggleCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { + if (Plugin.getPreferences().Get(caller).Invisibility) + { + UtilPlayer.message(caller, F.main("Incognito", "You are not allowed to toggle incognito on while Hub Invisibility is enabled.")); + return; + } + if (Plugin.toggle(caller)) { UtilPlayer.message(caller, F.main("Incognito", "You are now incognito. Your status will only change when you run " + F.elem(AliasUsed) + " again.")); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java index ae7f67755..9d6439e46 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java @@ -4,20 +4,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Map.Entry; -import mineplex.core.MiniDbClientPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilInv; -import mineplex.core.donation.DonationManager; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.preferences.command.PreferencesCommand; -import mineplex.core.preferences.ui.ExclusivePreferencesShop; -import mineplex.core.preferences.ui.PreferencesShop; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -29,17 +15,35 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.MiniDbClientPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.donation.DonationManager; +import mineplex.core.incognito.IncognitoManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.packethandler.PacketHandler; +import mineplex.core.preferences.command.PreferencesCommand; +import mineplex.core.preferences.ui.ExclusivePreferencesShop; +import mineplex.core.preferences.ui.PreferencesShop; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + public class PreferencesManager extends MiniDbClientPlugin { private PreferencesRepository _repository; private PreferencesShop _shop; private ExclusivePreferencesShop _exclusiveShop; + private IncognitoManager _incognitoManager; + private NautHashMap _saveBuffer = new NautHashMap(); public boolean GiveItem; - public PreferencesManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) + public PreferencesManager(JavaPlugin plugin, IncognitoManager incognito, CoreClientManager clientManager, DonationManager donationManager) { super("Preferences", plugin, clientManager); @@ -47,6 +51,8 @@ public class PreferencesManager extends MiniDbClientPlugin _exclusiveShop = new ExclusivePreferencesShop(this, clientManager, donationManager); _shop = new PreferencesShop(this, clientManager, donationManager, _exclusiveShop); + _incognitoManager = incognito; + _exclusiveShop.setPreferencesShop(_shop); addCommand(new PreferencesCommand(this)); @@ -138,4 +144,9 @@ public class PreferencesManager extends MiniDbClientPlugin { return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI, clanTips, hubMusic, disableAds FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;"; } + + public IncognitoManager getIncognitoManager() + { + return _incognitoManager; + } } 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 2cde41914..65f7d4b58 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java @@ -8,6 +8,8 @@ import org.bukkit.event.inventory.ClickType; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilUI; import mineplex.core.donation.DonationManager; import mineplex.core.preferences.PreferencesManager; @@ -149,6 +151,12 @@ public class ExclusivePreferencesPage extends ShopPageBaseimplements IRelati // Spawn area - public ClansManager(JavaPlugin plugin/*, ClansBanManager clansBans*/, String serverName, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress) + public ClansManager(JavaPlugin plugin/*, ClansBanManager clansBans*/, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress) { super("Clans Manager", plugin); @@ -236,7 +236,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati /*_clansBans = clansBans;*/ _punish = punish; - _incognitoManager = new IncognitoManager(plugin, clientManager, packetHandler); + _incognitoManager = incognitoManager; _serverName = serverName; _clientManager = clientManager; _combatManager = new CombatManager(plugin); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index b663e7f1d..3aa1d6eed 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -106,7 +106,11 @@ public class Hub extends JavaPlugin implements IRelation //Other Modules PacketHandler packetHandler = new PacketHandler(this); DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler); - PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager); + IncognitoManager incognito = new IncognitoManager(this, clientManager, packetHandler); + PreferencesManager preferenceManager = new PreferencesManager(this, incognito, clientManager, donationManager); + + incognito.setPreferencesManager(preferenceManager); + preferenceManager.GiveItem = true; Creature creature = new Creature(this); NpcManager npcManager = new NpcManager(this, creature); @@ -140,7 +144,6 @@ public class Hub extends JavaPlugin implements IRelation QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager); - IncognitoManager incognito = new IncognitoManager(this, clientManager, packetHandler); new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager); Chat chat = new Chat(this, incognito, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java index 33e1eb2d5..14d2f9958 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java @@ -57,7 +57,7 @@ public class StaffServer extends JavaPlugin Punish punish = new Punish(this, webServerAddress, clientManager); new NpcManager(this, new Creature(this)); ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager)); - PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager); + PreferencesManager preferenceManager = new PreferencesManager(this, null, clientManager, donationManager); preferenceManager.GiveItem = false; Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 72b1024b1..08553888b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -109,15 +109,19 @@ public class Arcade extends JavaPlugin _serverConfiguration = new ServerConfiguration(this, _clientManager); - PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager); + PacketHandler packetHandler = new PacketHandler(this); + + IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler); + PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager, _donationManager); + incognito.setPreferencesManager(preferenceManager); + Creature creature = new Creature(this); ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager)); LeaderboardManager leaderboardManager = new LeaderboardManager(this, _clientManager); Teleport teleport = new Teleport(this, _clientManager); Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); - PacketHandler packetHandler = new PacketHandler(this); DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler); @@ -128,8 +132,6 @@ public class Arcade extends JavaPlugin AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); AntiHack.Instance.setKick(false); - IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler); - IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); StatsManager statsManager = new StatsManager(this, _clientManager); AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager); From 05b31725a8c648f7da0300fa6f50d74c3cc2cf12 Mon Sep 17 00:00:00 2001 From: Conrad S Date: Fri, 8 Apr 2016 18:48:16 -0400 Subject: [PATCH 27/44] Fix initialization NPE. --- .../repository/SiegeWeaponRepository.java | 70 +++++++++---------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/SiegeWeaponRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/SiegeWeaponRepository.java index b43d47d23..452e3a396 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/SiegeWeaponRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/SiegeWeaponRepository.java @@ -34,64 +34,64 @@ public class SiegeWeaponRepository extends MinecraftRepository + "lastFired LONG," + "entities VARCHAR(200)," + "PRIMARY KEY (uniqueId));"; - + private static final String GET_WEAPON_BY_ID = "SELECT * FROM clansSiegeWeapons WHERE uniqueId=?;"; private static final String GET_WEAPONS_BY_CLAN = "SELECT * FROM clansSiegeWeapons WHERE ownerClan=?;"; private static final String GET_WEAPONS_BY_SERVER = "SELECT * FROM clansSiegeWeapons WHERE serverId=?;"; - + private static final String UPDATE_WEAPON = "UPDATE clansSiegeWeapons SET health=?,yaw=?,lastFired=? WHERE uniqueId=?;"; private static final String INSERT_WEAPON = "INSERT INTO clansSiegeWeapons VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);"; - + private static final String DELETE_WEAPON = "DELETE FROM clansSiegeWeapons WHERE uniqueId=?;"; - + private SiegeManager _siegeManager; - + public SiegeWeaponRepository(JavaPlugin plugin, SiegeManager siegeManager) { super(plugin, DBPool.getAccount()); - + _siegeManager = siegeManager; } - + public void deleteWeapon(final int uniqueId) { System.out.println("Siege Repo> Deleting weapon " + uniqueId); - + _siegeManager.runAsync(() -> executeUpdate(DELETE_WEAPON, new ColumnInt("uniqueId", uniqueId)) ); } - + public void getWeaponById(final int uniqueId, final Callback callback) { _siegeManager.runAsync(() -> executeQuery(GET_WEAPON_BY_ID, resultSet -> { SiegeWeaponToken token = new SiegeWeaponToken(); - + resultSet.next(); - + load(token, resultSet); - + callback.run(token); }, new ColumnInt("uniqueId", uniqueId)) ); } - + public void getWeaponsByServer(final int serverId, final Callback> callback) { _siegeManager.runAsync(() -> executeQuery(GET_WEAPONS_BY_SERVER, resultSet -> { List tokens = Lists.newArrayList(); - + while (resultSet.next()) { SiegeWeaponToken token = new SiegeWeaponToken(); - + load(token, resultSet); - + tokens.add(token); } - + callback.run(tokens); }, new ColumnInt("serverId", serverId)) ); @@ -102,21 +102,21 @@ public class SiegeWeaponRepository extends MinecraftRepository _siegeManager.runAsync(() -> executeQuery(GET_WEAPONS_BY_CLAN, resultSet -> { List tokens = Lists.newArrayList(); - + while (resultSet.next()) { SiegeWeaponToken token = new SiegeWeaponToken(); - + load(token, resultSet); - + tokens.add(token); } - + callback.run(tokens); }, new ColumnInt("ownerClan", clan.getId())) ); } - + private void load(SiegeWeaponToken token, ResultSet columns) throws SQLException { token.UniqueId = columns.getInt("uniqueId"); @@ -127,14 +127,14 @@ public class SiegeWeaponRepository extends MinecraftRepository token.Yaw = columns.getShort("yaw"); token.LastFired = columns.getTimestamp("lastFired").getTime(); token.Entities = decodeEntities(columns.getString("entities")); - + System.out.println("Siege Repo> Loaded weapon " + token.UniqueId); } public void updateWeapon(SiegeWeaponToken token) { System.out.println("Siege Repo> Updating weapon " + token.UniqueId); - + _siegeManager.runAsync(() -> executeUpdate(UPDATE_WEAPON, new ColumnInt("health", token.Health), @@ -147,9 +147,9 @@ public class SiegeWeaponRepository extends MinecraftRepository public void insertWeapon(SiegeWeaponToken token) { System.out.println("Siege Repo> Inserting new weapon " + token.UniqueId); - + _siegeManager.runAsync(() -> - executeUpdate(INSERT_WEAPON, + executeUpdate(INSERT_WEAPON, new ColumnInt("uniqueId", token.UniqueId), new ColumnInt("serverId", _siegeManager.getClansManager().getServerId()), new ColumnVarChar("location", 30, UtilWorld.locToStr(token.Location)), @@ -161,11 +161,11 @@ public class SiegeWeaponRepository extends MinecraftRepository new ColumnVarChar("entities", 100, encodeEntities(token.Entities))) ); } - + private String encodeEntities(Map entities) { StringBuilder builder = new StringBuilder(); - + int l = 0; for (String name : entities.keySet()) { @@ -173,32 +173,30 @@ public class SiegeWeaponRepository extends MinecraftRepository { builder.append(","); } - + builder.append(name + ":" + entities.get(name)); l++; } - + return builder.toString(); } - + private Map decodeEntities(String data) { Map map = new HashMap<>(); - + for (String entries : data.split(",")) { map.put(entries.split(":")[0], entries.split(":")[1]); } - + return map; } @Override protected void initialize() { - _siegeManager.runAsync(() -> - executeUpdate(CREATE) - ); + executeUpdate(CREATE); } @Override From 6e9ae04118e966b350f390382dfe963ee400621f Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 9 Apr 2016 00:27:24 +0100 Subject: [PATCH 28/44] Cut Gem to Gold conversion rate down to 16 Gems per Gold, instead of 32 --- .../src/mineplex/game/clans/economy/GoldManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java index 96cbf228b..ab3a0b03c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java @@ -41,7 +41,7 @@ import mineplex.game.clans.shop.bank.BankShop; public class GoldManager extends MiniPlugin { - public static final double GEM_CONVERSION_RATE = 32; // The number of gold coins when converted from a single gem + public static final double GEM_CONVERSION_RATE = 16; // The number of gold coins when converted from a single gem public static final double DEATH_TAX = 0.04d; // Percentage of gold lost on death public static final String META_STRING = "clans.goldAmount"; From 92195a12d2de8c8d6abc0554825fb72b99c65e09 Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 9 Apr 2016 00:37:20 +0100 Subject: [PATCH 29/44] Completely rework Cannon explosions to use the vanilla Minecraft explosions, as those seem to look much more visually appealing, and have less issues. Fixed a loading and saving bug with Cannons, they seem to be a lot more stable now than before. --- .../mineplex/core/common/util/UtilWorld.java | 10 +- .../game/clans/clans/siege/SiegeManager.java | 3 + .../repository/SiegeWeaponRepository.java | 34 +--- .../repository/tokens/SiegeWeaponToken.java | 1 - .../game/clans/clans/siege/weapon/Cannon.java | 68 ++++---- .../clans/clans/siege/weapon/SiegeWeapon.java | 21 +-- .../clans/siege/weapon/projectile/Crater.java | 146 +++++------------- 7 files changed, 92 insertions(+), 191 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java index f156f7f5a..19281c9ce 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java @@ -1,8 +1,8 @@ package mineplex.core.common.util; import java.util.Collection; +import java.util.Iterator; import java.util.List; -import java.util.function.Predicate; import org.bukkit.Chunk; import org.bukkit.Location; @@ -10,10 +10,18 @@ import org.bukkit.World; import org.bukkit.World.Environment; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import org.bukkit.util.Vector; import com.google.common.collect.Lists; +import net.minecraft.server.v1_8_R3.EntityHuman; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.Explosion; +import net.minecraft.server.v1_8_R3.PacketPlayOutExplosion; +import net.minecraft.server.v1_8_R3.Vec3D; + public class UtilWorld { public static World getWorld(String world) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java index e48801344..902aa968a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java @@ -112,6 +112,7 @@ public class SiegeManager extends MiniPlugin if (!part) { + System.out.println("Removing slime..."); slime.remove(); } else @@ -162,11 +163,13 @@ public class SiegeManager extends MiniPlugin { if (((ArmorStand) entity).getHelmet() != null && ((ArmorStand) entity).getHelmet().getType().equals(Material.SPONGE)) { + System.out.println("Removing armor stand"); entity.remove(); } if (entity.getPassenger() != null && entity.getPassenger() instanceof Slime && entity.getPassenger().getPassenger() instanceof Slime) { + System.out.println("Removing armostand + children"); entity.getPassenger().getPassenger().remove(); entity.getPassenger().remove(); entity.remove(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/SiegeWeaponRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/SiegeWeaponRepository.java index b43d47d23..af1820380 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/SiegeWeaponRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/SiegeWeaponRepository.java @@ -126,7 +126,6 @@ public class SiegeWeaponRepository extends MinecraftRepository token.Health = columns.getShort("health"); token.Yaw = columns.getShort("yaw"); token.LastFired = columns.getTimestamp("lastFired").getTime(); - token.Entities = decodeEntities(columns.getString("entities")); System.out.println("Siege Repo> Loaded weapon " + token.UniqueId); } @@ -158,41 +157,10 @@ public class SiegeWeaponRepository extends MinecraftRepository new ColumnInt("health", token.Health), new ColumnInt("yaw", token.Yaw), new ColumnTimestamp("lastFired", new Timestamp(token.LastFired)), - new ColumnVarChar("entities", 100, encodeEntities(token.Entities))) + new ColumnVarChar("entities", 100, "")) ); } - private String encodeEntities(Map entities) - { - StringBuilder builder = new StringBuilder(); - - int l = 0; - for (String name : entities.keySet()) - { - if (l != 0) - { - builder.append(","); - } - - builder.append(name + ":" + entities.get(name)); - l++; - } - - return builder.toString(); - } - - private Map decodeEntities(String data) - { - Map map = new HashMap<>(); - - for (String entries : data.split(",")) - { - map.put(entries.split(":")[0], entries.split(":")[1]); - } - - return map; - } - @Override protected void initialize() { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/tokens/SiegeWeaponToken.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/tokens/SiegeWeaponToken.java index 876e73935..638aa800c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/tokens/SiegeWeaponToken.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/tokens/SiegeWeaponToken.java @@ -16,6 +16,5 @@ public class SiegeWeaponToken public int Health; public int Yaw; public long LastFired; - public Map Entities; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java index 45510438c..cd0e77876 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java @@ -55,6 +55,13 @@ public class Cannon extends SiegeWeapon { super(300, "Cannon", token, siegeManager.getClansManager(), siegeManager); + if (_ownerClan == null) + { + System.out.println("[cannon] owner clan null, killing"); + kill(); + return; + } + System.out.println("Siege> Loading Cannon from token " + token.UniqueId); setBoundingBox(1); @@ -107,11 +114,11 @@ public class Cannon extends SiegeWeapon enableInventory(UtilServer.getServer().createInventory(null, InventoryType.DISPENSER, C.cDAquaB + _name), new AccessRule(AccessType.RCLICK_BB, player -> player.equals(getRider()))); setRideable(new AccessRule(AccessType.RCLICK_BB, player -> { -// if (!_ownerClan.isMember(player)) -// { -// UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan.")); -// return false; -// } + if (!_ownerClan.isMember(player)) + { + UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan.")); + return false; + } if (getRider() != null && !getRider().equals(player)) { @@ -140,7 +147,7 @@ public class Cannon extends SiegeWeapon setStateInfo("Unloaded", new WeaponStateInfo(Material.SPONGE, (byte) 1)); setStateInfo("Loaded", new WeaponStateInfo(Material.SPONGE, (byte) 0)); - loadEntities(); + loadEntities(true); setFirepowerType(Material.SULPHUR); setAmmunitionType(Material.TNT); @@ -179,9 +186,9 @@ public class Cannon extends SiegeWeapon return false; } - if (System.currentTimeMillis() - _lastFired < 20000) + if (System.currentTimeMillis() - _lastFired < 30000) { - UtilPlayer.message(player, F.main("Clans", "Cannon is cooling down (" + F.time(UtilTime.MakeStr(20000 - (System.currentTimeMillis() - _lastFired))) + ")")); + UtilPlayer.message(player, F.main("Clans", "Cannon is cooling down (" + F.time(UtilTime.MakeStr(30000 - (System.currentTimeMillis() - _lastFired))) + ")")); return false; } @@ -191,11 +198,11 @@ public class Cannon extends SiegeWeapon enableInventory(UtilServer.getServer().createInventory(null, InventoryType.DISPENSER, C.cDAquaB + _name), new AccessRule(AccessType.RCLICK_BB, player -> player.equals(getRider()))); setRideable(new AccessRule(AccessType.RCLICK_BB, player -> { -// if (!_ownerClan.isMember(player)) -// { -// UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan.")); -// return false; -// } + if (!_ownerClan.isMember(player)) + { + UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan.")); + return false; + } if (getRider() != null && !getRider().equals(player)) { @@ -298,7 +305,7 @@ public class Cannon extends SiegeWeapon return true; // all slots are now filled; slot == 0 || slot == 1 || slot == 2; } - private void loadEntities() + private void loadEntities(boolean insert) { Slime filler = _location.getWorld().spawn(_location.clone(), Slime.class); @@ -332,8 +339,10 @@ public class Cannon extends SiegeWeapon addEntity(weapon, "WEAPON"); - - insert(); + if (insert) + { + insert(); + } } @Override @@ -341,20 +350,13 @@ public class Cannon extends SiegeWeapon { Lists.newArrayList(_location.getWorld().getEntities()) .forEach(entity -> { - for (Entry entry : _loadedToken.Entities.entrySet()) + if (Integer.toString(_uniqueId).equals(entity.getCustomName())) { - if (entity.getUniqueId().toString().equals(entry.getValue())) - { - addEntity(entity, entry.getKey()); - } + entity.remove(); } }); - if (getEntity("WEAPON") == null || getEntity("Filler_1") == null || getEntity("PLAYERMOUNT") == null) - { - System.out.println("[Cannon] Could not find all entities, killing."); - kill(); - } + loadEntities(false); } @Override @@ -428,12 +430,12 @@ public class Cannon extends SiegeWeapon @EventHandler public void explosionEffects(SiegeWeaponExplodeEvent event) { - for (int i = 0; i < 8; i++) - { - // Explosion particle effects. - Location point = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), 5); - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, point, 0, 0, 0, 1, 2, ViewDist.MAX); - } +// for (int i = 0; i < 8; i++) +// { +// // Explosion particle effects. +// Location point = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), 5); +// UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, point, 0, 0, 0, 1, 2, ViewDist.MAX); +// } // Block explosion. ArrayList blocks = new ArrayList<>(); @@ -449,7 +451,7 @@ public class Cannon extends SiegeWeapon attempts++; } - _siegeManager.getClansManager().getExplosion().BlockExplosion( + _clans.getExplosion().BlockExplosion( blocks, event.getProjectile().getLocation(), false diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java index ba9089851..474b3f7d2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java @@ -536,6 +536,9 @@ public abstract class SiegeWeapon implements Listener protected final void addEntity(Entity entity, String uniqueName) { + entity.setCustomName(Integer.toString(_uniqueId)); + entity.setCustomNameVisible(false); + _comprisedOf.add(entity); _entityMapping.put(uniqueName, entity); @@ -942,29 +945,19 @@ public abstract class SiegeWeapon implements Listener token.Location = _location; token.Health = _health; token.Yaw = (int) _yaw; - token.Entities = new HashMap<>(); - - _entityMapping.entrySet().forEach(entry -> - token.Entities.put(entry.getKey(), entry.getValue().getUniqueId().toString()) - ); return token; } public boolean isPartOf(UUID uniqueId) { - if (_loadedToken == null) + for (Entity entity : _comprisedOf) { - for (Entity entity : _comprisedOf) - { - if (entity.getUniqueId().equals(uniqueId)) - return true; - } - - return false; + if (entity.getUniqueId().equals(uniqueId)) + return true; } - return _loadedToken.Entities.values().contains(uniqueId.toString()); + return false; } public void setInvincible(boolean invincible) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java index 6443697b8..c16f4f5c5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java @@ -26,9 +26,9 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.nameblacklist.ClansBlacklist; import mineplex.game.clans.clans.siege.weapon.SiegeWeapon; import mineplex.game.clans.core.repository.ClanTerritory; +import net.minecraft.server.v1_8_R3.Explosion; public class Crater implements Listener { @@ -108,124 +108,52 @@ public class Crater implements Listener return; } - _blocks.add(new CraterBlock(_origin, 0, Material.AIR)); + boolean explosion = _origin.getWorld().createExplosion(_origin, 2.6f); - HashMap blockList = new HashMap(); - int iR = (int) _size + 1; + boolean floating = _origin.distance(UtilBlock.nearestFloor(_origin)) > 0.6; - for (int x = -iR; x <= iR; x++) + if (explosion) { - for (int z = -iR; z <= iR; z++) + for (Block block : UtilBlock.getInRadius(_origin.getBlock(), 2.6f).keySet()) { - for (int y = -iR; y <= iR; y++) + boolean charred = false; + double dist = block.getLocation().distance(_origin); + + if (floating) { - Block curBlock = _origin.getBlock().getRelative(x, y, z); - - double offset = UtilMath.offset(_origin, curBlock.getLocation()); - - if (offset <= _size) + if (!block.getRelative(BlockFace.DOWN).getType().equals(CHARRED_TYPE) + && !block.getRelative(BlockFace.DOWN).getType().equals(Material.AIR) + && Math.random() > 0.79) { - blockList.put(curBlock, Double.valueOf(offset)); + charred = true; } } + else + { + if (block.getRelative(BlockFace.UP).getType().equals(Material.AIR) + && !block.getRelative(BlockFace.DOWN).getType().equals(CHARRED_TYPE) + && !block.getRelative(BlockFace.DOWN).getType().equals(Material.AIR) + && Math.random() > 0.79) + { + charred = true; + } + } + + if (block.getType().equals(Material.SMOOTH_BRICK)) + { + charred = false; + } + + if (charred) + { + CraterBlock charredBlock = new CraterBlock(block.getLocation(), dist, CHARRED_TYPE, (byte) 0); + + charredBlock.set(); + + _blocks.add(charredBlock); + } } } - - for (Entry entry : blockList.entrySet()) - { - Block block = entry.getKey(); - - ClanTerritory territory = _weapon.getClans().getClanUtility().getClaim(block.getLocation()); - - if (territory != null && !ClansManager.getInstance().getBlacklist().allowed(territory.Owner)) - { - continue; - } - - double distance = entry.getValue().doubleValue(); - - boolean air = distance <= _airChance || (Math.random() > (distance) / 3.65d); - - if (block.getState() instanceof Chest) continue; - - if (block.getType() == Material.AIR) continue; - - if (air) - { - _blocks.add(new CraterBlock(block.getLocation(), distance, Material.AIR)); - - Block above = block; - - while (!UtilItem.isBoundless((above = above.getRelative(BlockFace.UP)).getType())) - { - _blocks.add(new CraterBlock(above.getLocation(), distance, Material.AIR)); - } - - if (!UtilItem.isBoundless(block.getRelative(BlockFace.DOWN).getType())) - { - if (_fire && Math.random() >= .5) - { - _blocks.add(new CraterBlock(block.getLocation(), distance, Material.FIRE)); - } - } - } - } - - _blocks.forEach(CraterBlock::set); - - for (Entry entry : blockList.entrySet()) - { - Block block = entry.getKey(); - - ClanTerritory territory = _weapon.getClans().getClanUtility().getClaim(block.getLocation()); - - if (territory != null && !ClansManager.getInstance().getBlacklist().allowed(territory.Owner)) - { - continue; - } - - double distance = entry.getValue().doubleValue(); - - if (block.getType() == Material.AIR) continue; - - if (block.getState() instanceof Chest) - { - Chest chest = (Chest) block.getState(); - - for (ItemStack item : chest.getBlockInventory().getContents()) - { - if (item == null) - { - continue; - } - - if (item.getType() == Material.AIR) - { - continue; - } - - _origin.getWorld().dropItemNaturally(_origin, item); - } - } - - if ( - distance > _airChance && - Math.random() > .75 && - UtilItem.isBoundless(block.getRelative(BlockFace.UP).getType()) && - !UtilItem.isBoundless(block.getRelative(BlockFace.DOWN).getType()) && - !block.getRelative(BlockFace.UP).getType().equals(CHARRED_TYPE) && - !block.getRelative(BlockFace.DOWN).getType().equals(CHARRED_TYPE)) - { - _blocks.add(new CraterBlock(block.getLocation(), distance, CHARRED_TYPE)); - - if (_fire) - { - _blocks.add(new CraterBlock(block.getRelative(BlockFace.UP).getLocation(), distance, Material.FIRE)); - } - } - } - - _blocks.forEach(CraterBlock::set); } } From dd3e009413cc1c10b5bb9eed5f1e8bb5be7fa94b Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 10 Apr 2016 10:53:07 +0100 Subject: [PATCH 30/44] Remove silent chest opening mechanism (which was completely broken), and instead don't allow incognito staff to open chests --- .../game/clans/clans/ClansManager.java | 4 -- .../clans/staff/SilentChestInventory.java | 37 -------------- .../clans/clans/staff/SilentChestOpen.java | 49 ------------------- .../game/clans/gameplay/Gameplay.java | 19 +++++++ 4 files changed, 19 insertions(+), 90 deletions(-) delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/staff/SilentChestInventory.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/staff/SilentChestOpen.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 82320d92f..4d3d9c72f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -57,7 +57,6 @@ import mineplex.core.explosion.Explosion; import mineplex.core.hologram.Hologram; import mineplex.core.hologram.HologramManager; import mineplex.core.incognito.IncognitoManager; -import mineplex.core.incognito.events.IncognitoHidePlayerEvent; import mineplex.core.incognito.events.IncognitoStatusChangeEvent; import mineplex.core.movement.Movement; import mineplex.core.npc.NpcManager; @@ -99,7 +98,6 @@ import mineplex.game.clans.clans.redis.ClanLoadCommandHandler; import mineplex.game.clans.clans.regions.ClansRegions; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; import mineplex.game.clans.clans.siege.SiegeManager; -import mineplex.game.clans.clans.staff.SilentChestOpen; import mineplex.game.clans.clans.supplyDrop.SupplyDropManager; import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager; import mineplex.game.clans.clans.war.WarManager; @@ -296,8 +294,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati new Field(plugin, creature, _condition, this, energy, serverName); - new SilentChestOpen(this); - // Required managers to be initialized new Spawn(plugin, this); new NPCManager(this, _hologramManager); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/staff/SilentChestInventory.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/staff/SilentChestInventory.java deleted file mode 100644 index 505f0a340..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/staff/SilentChestInventory.java +++ /dev/null @@ -1,37 +0,0 @@ -package mineplex.game.clans.clans.staff; - -import org.bukkit.block.Chest; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryCloseEvent; -import org.bukkit.inventory.Inventory; - -import mineplex.core.common.util.UtilServer; - -public class SilentChestInventory implements Listener -{ - private Chest _chest; - private Inventory _inventory; - - private Player _viewer; - - public SilentChestInventory(Chest chest, Player viewer) - { - _chest = chest; - - viewer.openInventory(_chest.getBlockInventory()); - - UtilServer.RegisterEvents(this); - } - - @EventHandler - public void closeInventory(InventoryCloseEvent event) - { - if (event.getInventory().equals(_inventory) && event.getPlayer().equals(_viewer)) - { - UtilServer.Unregister(this); - } - } - -} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/staff/SilentChestOpen.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/staff/SilentChestOpen.java deleted file mode 100644 index 2f9bfabae..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/staff/SilentChestOpen.java +++ /dev/null @@ -1,49 +0,0 @@ -package mineplex.game.clans.clans.staff; - -import org.bukkit.block.BlockState; -import org.bukkit.block.Chest; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerInteractEvent; - -import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; -import mineplex.core.common.util.UtilServer; -import mineplex.core.incognito.IncognitoManager; -import mineplex.game.clans.clans.ClansManager; - -public class SilentChestOpen extends MiniPlugin -{ - private ClansManager _clansManager; - - public SilentChestOpen(ClansManager clansManager) - { - super("Silent Chest", clansManager.getPlugin()); - - _clansManager = clansManager; - } - - @EventHandler - public void onInteract(PlayerInteractEvent event) - { - if (!_clansManager.getIncognitoManager().Get(event.getPlayer()).Status) - return; - - if (!ClansManager.getInstance().getClientManager().hasRank(event.getPlayer(), Rank.CMOD)) - return; - - if (event.getClickedBlock() == null) - return; - - BlockState block = event.getClickedBlock().getState(); - - if (!(block instanceof Chest)) - return; - - Chest chest = (Chest) block; - - UtilServer.RegisterEvents(new SilentChestInventory(chest, event.getPlayer())); - - event.setCancelled(true); - - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java index 5a212665d..23c226fe0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -304,6 +304,25 @@ public class Gameplay extends MiniPlugin event.setCancelled(true); } + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (!_clansManager.getIncognitoManager().Get(event.getPlayer()).Status) + { + return; + } + + if (!event.getClickedBlock().getType().equals(Material.CHEST) + && !event.getClickedBlock().getType().equals(Material.TRAPPED_CHEST)) + { + return; + } + + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You are not allowed to use this whilst incognito.")); + + event.setCancelled(true); + } + /** * Disable all Piston related events in Clans * From e8e73306be5672f58209379ae23fe34a48a9ac10 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 10 Apr 2016 11:15:43 +0100 Subject: [PATCH 31/44] Change the Giant's Broadswords regeneration effect level from 41 to 3 --- .../mineplex/game/clans/items/legendaries/GiantsBroadsword.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/GiantsBroadsword.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/GiantsBroadsword.java index d9f71353c..746ac5312 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/GiantsBroadsword.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/GiantsBroadsword.java @@ -60,6 +60,6 @@ public class GiantsBroadsword extends LegendaryItem private void buffPlayer(Player player) { grantPotionEffect(player, PotionEffectType.SLOW, 40, SLOW_AMPLIFIER); - grantPotionEffect(player, PotionEffectType.REGENERATION, 40, REGEN_AMPLIFIER); //Regen + grantPotionEffect(player, PotionEffectType.REGENERATION, 2, REGEN_AMPLIFIER); //Regen } } From 8ee2c02dd93d0b2d5c9b77d3dce504ced788cac5 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 10 Apr 2016 11:20:51 +0100 Subject: [PATCH 32/44] Disable the use of Ender Chests --- .../src/mineplex/game/clans/gameplay/Gameplay.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java index 23c226fe0..5ceaab637 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -304,6 +304,16 @@ public class Gameplay extends MiniPlugin event.setCancelled(true); } + @EventHandler + public void disableEnderChest(PlayerInteractEvent event) + { + if (event.getClickedBlock().getType().equals(Material.ENDER_CHEST)) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You are not permitted to use Ender Chests.")); + return; + } + } + @EventHandler public void onInteract(PlayerInteractEvent event) { From 3ee1f8684156c053610226acf2974a77e38fa2fb Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 10 Apr 2016 12:36:31 +0100 Subject: [PATCH 33/44] Fix Null Pointers in the ender chest blocker and regular chest blocker for incognito staff. --- .../game/clans/gameplay/Gameplay.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java index 5ceaab637..b7627fc19 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -59,6 +59,7 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; import mineplex.core.common.weight.Weight; import mineplex.core.common.weight.WeightSet; import mineplex.core.itemstack.ItemStackFactory; @@ -307,6 +308,16 @@ public class Gameplay extends MiniPlugin @EventHandler public void disableEnderChest(PlayerInteractEvent event) { + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) + { + return; + } + + if (event.getClickedBlock() == null) + { + return; + } + if (event.getClickedBlock().getType().equals(Material.ENDER_CHEST)) { UtilPlayer.message(event.getPlayer(), F.main("Clans", "You are not permitted to use Ender Chests.")); @@ -322,6 +333,16 @@ public class Gameplay extends MiniPlugin return; } + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) + { + return; + } + + if (event.getClickedBlock() == null) + { + return; + } + if (!event.getClickedBlock().getType().equals(Material.CHEST) && !event.getClickedBlock().getType().equals(Material.TRAPPED_CHEST)) { From 37bb64bffd50913f0b3e95685df8eb01cb1d59bf Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 10 Apr 2016 12:47:56 +0100 Subject: [PATCH 34/44] Fix Undead Camps from spawning outside of the World Border. --- .../mineplex/core/common/util/UtilWorld.java | 87 +++++++++++++++++-- .../clans/worldevent/EventTerrainFinder.java | 8 +- 2 files changed, 86 insertions(+), 9 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java index 19281c9ce..cef329774 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java @@ -1,26 +1,20 @@ package mineplex.core.common.util; import java.util.Collection; -import java.util.Iterator; import java.util.List; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.World.Environment; +import org.bukkit.WorldBorder; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; import org.bukkit.util.Vector; import com.google.common.collect.Lists; -import net.minecraft.server.v1_8_R3.EntityHuman; -import net.minecraft.server.v1_8_R3.EntityPlayer; -import net.minecraft.server.v1_8_R3.Explosion; -import net.minecraft.server.v1_8_R3.PacketPlayOutExplosion; -import net.minecraft.server.v1_8_R3.Vec3D; +import net.minecraft.server.v1_8_R3.AxisAlignedBB; public class UtilWorld { @@ -218,4 +212,81 @@ public class UtilWorld origin.getBlock().getRelative(BlockFace.WEST)); } + /** + * This method will use the World provided by the given Location.

+ * @return true if the specified location is within the bounds of the + * world's set border, or false if {@link World#getWorldBorder()} returns null. + */ + public static boolean inWorldBorder(Location location) + { + WorldBorder border = location.getWorld().getWorldBorder(); + + if (border == null) + { + return false; + } + + double size = border.getSize() / 2; + + double maxX = size; + double maxZ = size; + double minX = -size; + double minZ = -size; + + return location.getX() >= minX && location.getX() <= maxX && location.getZ() >= minZ && location.getZ() <= maxZ; + } + + /** + * This method will use the World specified by the second argument, and the + * x, y, and z provided by the given Location.

+ * @return true if the specified location is within the bounds of the + * world's set border, or false if {@link World#getWorldBorder()} returns null. + */ + public static boolean inWorldBorder(World world, Location location) + { + WorldBorder border = world.getWorldBorder(); + + if (border == null) + { + return false; + } + + double size = border.getSize() / 2; + + double maxX = size; + double maxZ = size; + double minX = -size; + double minZ = -size; + + return location.getX() >= minX && location.getX() <= maxX && location.getZ() >= minZ && location.getZ() <= maxZ; + } + + /** + * @return true if the specified bounding box is within the bounds of the + * world's set border, or false if {@link World#getWorldBorder()} returns null. + */ + public static boolean isBoxInWorldBorder(World world, Location min, Location max) + { + WorldBorder border = world.getWorldBorder(); + + if (border == null) + { + return false; + } + + double size = border.getSize() / 2; + + double maxX = size; + double maxZ = size; + double minX = -size; + double minZ = -size; + + double startX = Math.min(min.getX(), max.getX()); + double startZ = Math.min(min.getZ(), max.getZ()); + double endX = Math.max(min.getX(), max.getX()); + double endZ = Math.max(min.getZ(), max.getZ()); + + return startX >= minX && startZ <= maxX && endX >= minZ && endZ <= maxZ; + } + } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java index 27d574419..0f8018dc0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java @@ -52,9 +52,15 @@ public class EventTerrainFinder loc.Set(UtilBlock.getHighest(chunk.getWorld(), chunk.getBlock(0, 0, 0)).getLocation()); }); + if (!UtilWorld.isBoxInWorldBorder(world, loc.Get().clone().subtract(size, vert, size), loc.Get().clone().add(size, vert, size))) + { + continue; + } if (loc.Get() == null) + { continue; + } System.out.println("Done finding area... [success]"); @@ -62,7 +68,7 @@ public class EventTerrainFinder return loc.Get(); } - System.out.println("Done finding area..."); + System.out.println("Failed to find area..."); return null; } From 66274188c807b2cb15bd8bb934ef68a2d68ecbdf Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 10 Apr 2016 12:56:00 +0100 Subject: [PATCH 35/44] Add a /we random command to spawn a random world event --- .../clans/clans/worldevent/WorldEventManager.java | 11 +++++++++++ .../clans/worldevent/command/WorldEventCommand.java | 1 + 2 files changed, 12 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index 6db1192cd..0edc6e6e7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -124,6 +124,17 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement } } + public void randomEvent() + { + if (_runningEvents.size() == 0) + { + if (UtilServer.getPlayers().length > 0) + { + tryStartEvent(); + } + } + } + private void tryStartEvent() { WorldEventType[] types = WorldEventType.values(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java index 2e3f0c181..7a830d9c6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java @@ -14,6 +14,7 @@ public class WorldEventCommand extends MultiCommandBase AddCommand(new StartCommand(Plugin)); AddCommand(new ClearCommand(Plugin)); + AddCommand(new RandomCommand(Plugin)); } @Override From fe89a5b68ea0d3dded677b02e2b0cdfe200e6541 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 10 Apr 2016 14:50:00 +0100 Subject: [PATCH 36/44] Fix the Recall rare item duplication bug --- .../game/classcombat/Skill/Assassin/Recall.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java index cd7af9243..9e449a9fb 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java @@ -57,9 +57,14 @@ public class Recall extends Skill public void use(PlayerDropItemEvent event) { Player player = event.getPlayer(); - + + if (player.getOpenInventory() != null) + { + return; + } + int level = getLevel(player); - if (level == 0) + if (level == 0) return; if (!UtilGear.isWeapon(event.getItemDrop().getItemStack())) From 9a2f4a89368a5d3fdf088d2ddccd71c84d90c952 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 10 Apr 2016 15:23:43 +0100 Subject: [PATCH 37/44] Fix Meridian Scepter not damaging the victim (would just give the wither effect) --- .../items/legendaries/MeridianScepter.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java index cff2d6e38..ce2999b4d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java @@ -20,6 +20,7 @@ import mineplex.core.common.util.RGBData; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilCollections; import mineplex.core.common.util.UtilColor; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; @@ -38,6 +39,8 @@ public class MeridianScepter extends LegendaryItem private RGBData[] colors = { UtilColor.RgbPurple, UtilColor.RgbPurple.Lighten(), UtilColor.RgbPurple.Darken() }; + private int _witherDamageTimes = 5; + public MeridianScepter() { super("Meridian Scepter", UtilText.splitLinesToArray(new String[] { @@ -80,7 +83,6 @@ public class MeridianScepter extends LegendaryItem final Vector direction = shooter.getEyeLocation().getDirection().normalize().multiply(0.25); final int maxRange = 50; final int maxDings = maxRange * 4; - final int damage = 6; UtilServer.repeat(new BukkitRunnable() { @@ -101,11 +103,18 @@ public class MeridianScepter extends LegendaryItem // If they are less than 0.5 blocks away if (eLoc.clone().add(0, player.getEyeHeight() / 2, 0).distance(projectile) <= 0.7) { - ClansManager.getInstance().getDamageManager().NewDamageEvent(player, player, null, - DamageCause.CUSTOM, damage, true, true, false, - player.getName(), "Meridian Scepter"); + player.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 20 * _witherDamageTimes, 0)); - player.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 20 * 4, 0)); + int time = 0; + + for (int i = 0; i < _witherDamageTimes; i++) + { + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(UtilServer.getPlugin(), () -> { + ClansManager.getInstance().getDamageManager().NewDamageEvent(player, shooter, null, + DamageCause.CUSTOM, 2, false, true, true, + shooter.getName(), "Meridian Scepter"); + }, ++time * 20); + } UtilPlayer.message(player, F.main("Clans", F.elem(player.getName()) + " hit you with a " + F.elem("Meridian Scepter") + C.mBody + ".")); UtilPlayer.message(shooter, F.main("Clans", "You hit " + F.elem(player.getName()) + " with your " + F.elem("Meridian Scepter") + C.mBody + ".")); From 0ac9747df1f8b64aa18f6cc961f514bcb639f15a Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 10 Apr 2016 15:27:20 +0100 Subject: [PATCH 38/44] Modifying how the Meridian Scepter picks a target, as the previous logic was a bit flawed. --- .../game/clans/items/legendaries/MeridianScepter.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java index ce2999b4d..2311cc8ec 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java @@ -151,7 +151,7 @@ public class MeridianScepter extends LegendaryItem continue; } - if (ClansManager.getInstance().getClan(shooter) == ClansManager.getInstance().getClan(closest)) + if (ClansManager.getInstance().isInClan(shooter) && ClansManager.getInstance().getClan(shooter).isMember(closest)) { continue; } @@ -161,12 +161,17 @@ public class MeridianScepter extends LegendaryItem continue; } + if (closest.getGameMode().equals(GameMode.CREATIVE) || closest.getGameMode().equals(GameMode.SPECTATOR)) + { + continue; + } + if (ClansManager.getInstance().getIncognitoManager().Get(closest).Status) { continue; } - if (ClansManager.getInstance().getClan(shooter) != null && ClansManager.getInstance().getClan(shooter).isAlly(ClansManager.getInstance().getClan(closest))) + if (ClansManager.getInstance().isInClan(shooter) && ClansManager.getInstance().getClan(shooter).isAlly(ClansManager.getInstance().getClan(closest))) { continue; } From db8ca3156780d3559a3f7db9c751d79860232552 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 10 Apr 2016 16:16:53 +0100 Subject: [PATCH 39/44] Fix Meridian Scepter not being perfectly accurate. --- .../game/clans/items/legendaries/MeridianScepter.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java index 2311cc8ec..61bdc4645 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java @@ -98,10 +98,8 @@ public class MeridianScepter extends LegendaryItem Player player = (Player) cur; - Location eLoc = player.getLocation(); - // If they are less than 0.5 blocks away - if (eLoc.clone().add(0, player.getEyeHeight() / 2, 0).distance(projectile) <= 0.7) + if (player.getEyeLocation().subtract(0, .3, 0).distance(projectile) <= 2) { player.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 20 * _witherDamageTimes, 0)); @@ -111,7 +109,7 @@ public class MeridianScepter extends LegendaryItem { UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(UtilServer.getPlugin(), () -> { ClansManager.getInstance().getDamageManager().NewDamageEvent(player, shooter, null, - DamageCause.CUSTOM, 2, false, true, true, + DamageCause.CUSTOM, 1.75, false, true, true, shooter.getName(), "Meridian Scepter"); }, ++time * 20); } From 159a5403ac6ed6c3fe4371920fecfa6a259e1dd3 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 10 Apr 2016 16:47:46 +0100 Subject: [PATCH 40/44] Fix rare item duplication bug with Smoke Bomb (was told that it's just like the Recall duplication bug) --- .../classcombat/Skill/Assassin/SmokeBomb.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/SmokeBomb.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/SmokeBomb.java index 41f70572b..7a7e54133 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/SmokeBomb.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/SmokeBomb.java @@ -24,6 +24,7 @@ import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -55,7 +56,12 @@ public class SmokeBomb extends Skill public void Use(PlayerDropItemEvent event) { Player player = event.getPlayer(); - + + if (player.getOpenInventory() != null) + { + return; + } + int level = getLevel(player); if (level == 0) return; @@ -140,7 +146,19 @@ public class SmokeBomb extends Skill Factory.Condition().EndCondition(event.getPlayer(), null, GetName()); } - + + @EventHandler + public void closeInv(InventoryCloseEvent event) + { + if (getLevel(event.getPlayer()) == 0) + { + return; + } + + event.getPlayer().getInventory().addItem(event.getPlayer().getItemOnCursor()); + event.getPlayer().setItemOnCursor(null); + } + @EventHandler public void Smoke(UpdateEvent event) { From e014f4fff9e518eb2c24c300069c2f483e15a8f7 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 10 Apr 2016 16:51:12 +0100 Subject: [PATCH 41/44] Fix null pointer in the tutorial when using /tutorial finish --- .../mineplex/game/clans/tutorial/objective/Objective.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/Objective.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/Objective.java index 34cc9151a..a5488a5a5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/Objective.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/Objective.java @@ -277,6 +277,11 @@ public abstract class Objective Date: Sun, 10 Apr 2016 16:51:42 +0100 Subject: [PATCH 42/44] Fix the terrain finder miscalculating the size of undead camps --- .../game/clans/clans/worldevent/EventTerrainFinder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java index 0f8018dc0..4cc189f34 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java @@ -52,7 +52,7 @@ public class EventTerrainFinder loc.Set(UtilBlock.getHighest(chunk.getWorld(), chunk.getBlock(0, 0, 0)).getLocation()); }); - if (!UtilWorld.isBoxInWorldBorder(world, loc.Get().clone().subtract(size, vert, size), loc.Get().clone().add(size, vert, size))) + if (!UtilWorld.isBoxInWorldBorder(world, loc.Get().clone().subtract(size * 2, vert, size * 2), loc.Get().clone().add(size * 2, vert, size * 2))) { continue; } From b313bc5308c2f4cc2a7b848710d8674d11b3b6e6 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 10 Apr 2016 16:52:54 +0100 Subject: [PATCH 43/44] Make undead chests not show the 'you are not permitted to use ender chest' messages. --- .../mineplex/core/common/util/UtilAlg.java | 18 ++++++ .../clans/worldevent/WorldEventManager.java | 13 ++++ .../game/clans/gameplay/Gameplay.java | 7 ++- .../minecraft/game/core/boss/WorldEvent.java | 60 ++++++++++++++++++- 4 files changed, 94 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java index ebf5f7f8d..1945a0e1b 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java @@ -216,6 +216,24 @@ public class UtilAlg return true; } + + public static boolean inBoundingBox(Location loc, Vector cornerA, Vector cornerB) + { + if (loc.getX() <= Math.min(cornerA.getX(), cornerB.getX())) return false; + if (loc.getX() >= Math.max(cornerA.getX(), cornerB.getX())) return false; + + if (cornerA.getY() != cornerB.getY()) + { + if (loc.getY() <= Math.min(cornerA.getY(), cornerB.getY())) return false; + if (loc.getY() >= Math.max(cornerA.getY(), cornerB.getY())) return false; + } + + if (loc.getZ() <= Math.min(cornerA.getZ(), cornerB.getZ())) return false; + if (loc.getZ() >= Math.max(cornerA.getZ(), cornerB.getZ())) return false; + + return true; + } + public static Vector cross(Vector a, Vector b) { double x = a.getY()*b.getZ() - a.getZ()*b.getY(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index 0edc6e6e7..a419b2d1c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -77,6 +77,19 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement } } + public boolean isInEvent(Location location) + { + for (WorldEvent event : _runningEvents) + { + if (event.isInBounds(location)) + { + return true; + } + } + + return false; + } + @EventHandler public void update(UpdateEvent event) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java index b7627fc19..a6dbb83d6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -305,7 +305,7 @@ public class Gameplay extends MiniPlugin event.setCancelled(true); } - @EventHandler + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void disableEnderChest(PlayerInteractEvent event) { if (event.getAction() != Action.RIGHT_CLICK_BLOCK) @@ -318,6 +318,11 @@ public class Gameplay extends MiniPlugin return; } + if (_clansManager.getWorldEvent().isInEvent(event.getClickedBlock().getLocation())) + { + return; + } + if (event.getClickedBlock().getType().equals(Material.ENDER_CHEST)) { UtilPlayer.message(event.getPlayer(), F.main("Clans", "You are not permitted to use Ender Chests.")); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java index f1cd8424b..6f10d660c 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java @@ -5,8 +5,8 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.Set; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -15,6 +15,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blockrestore.BlockRestoreMap; @@ -25,7 +26,7 @@ import mineplex.core.common.block.schematic.UtilSchematic; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; @@ -65,6 +66,14 @@ public abstract class WorldEvent implements Listener, ScoreboardElement private boolean _isArcade; private double _difficulty = 1; + private double _minX; + private double _minY; + private double _minZ; + + private double _maxX; + private double _maxY; + private double _maxZ; + public WorldEvent(DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name, Location cornerLocation) { this(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, name, cornerLocation, null); @@ -328,7 +337,6 @@ public abstract class WorldEvent implements Listener, ScoreboardElement { onComplete.run(); } - } }); @@ -407,4 +415,50 @@ public abstract class WorldEvent implements Listener, ScoreboardElement } } + public boolean isInBounds(Location location) + { + if (_minX == 0) + { + // Calculate bounds + Set blocks = _blocks.getChangedBlocks(); + + for (Block block : blocks) + { + if (_minX > block.getX()) + { + _minX = block.getX(); + } + + if (_minY > block.getY()) + { + _minY = block.getY(); + } + + if (_minZ > block.getZ()) + { + _minZ = block.getZ(); + } + + if (_maxX < block.getX()) + { + _maxX = block.getX(); + } + + if (_maxY < block.getY()) + { + _maxY = block.getY(); + } + + if (_maxZ < block.getZ()) + { + _maxZ = block.getZ(); + } + } + + _maxY++; + } + + return UtilAlg.inBoundingBox(location, new Vector(_minX, _minY, _minZ), new Vector(_maxX, _maxY, _maxZ)); + } + } From eefed175ecef9439c3e838dccd8d35a4abf53a83 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 11 Apr 2016 18:07:11 +0100 Subject: [PATCH 44/44] Add the random world event command. --- .../worldevent/command/RandomCommand.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java new file mode 100644 index 000000000..9fd1762b8 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java @@ -0,0 +1,28 @@ +package mineplex.game.clans.clans.worldevent.command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.worldevent.WorldEventManager; +import mineplex.game.clans.clans.worldevent.WorldEventType; +import mineplex.minecraft.game.core.boss.WorldEvent; + +/** + * Command for spawning a random world event in the world. + */ +public class RandomCommand extends CommandBase +{ + public RandomCommand(WorldEventManager plugin) + { + super(plugin, Rank.JNR_DEV, "random", "rand"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Plugin.randomEvent(); + } +}