From efa03945cb9b73247f7243320dfcc723fed52161 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 23 Sep 2014 17:05:21 -0500 Subject: [PATCH 01/14] Delete the MapParser zip file from root directory after copied --- .../src/mineplex/mapparser/WorldManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/WorldManager.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/WorldManager.java index 6f849f709..d34d0cc9e 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/WorldManager.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/WorldManager.java @@ -107,7 +107,10 @@ public class WorldManager try { - FileUtils.copyFile(new File(fileName), new File(File.separator + "home" + File.separator + "mineplex" + File.separator + "update" + File.separator + "maps" + File.separator + gameType.GetName() + File.separator + fileName)); + File zipFile = new File(fileName); + FileUtils.copyFile(zipFile, new File(File.separator + "home" + File.separator + "mineplex" + File.separator + "update" + File.separator + "maps" + File.separator + gameType.GetName() + File.separator + fileName)); + // Delete the zip file in root directory once zip is copied + FileUtils.deleteQuietly(zipFile); } catch (IOException e) { From d32085f05b5806345900c4591ba4556bc5b7b2cc Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Wed, 24 Sep 2014 01:31:56 -0700 Subject: [PATCH 02/14] Removed tab list stuff for friends. Implemented rudimentary friends chat list. removed unused code in server stuff. Added null check for retrieving server statuses. --- .../common/jsonchat/ChildJsonMessage.java | 8 ++ .../core/common/jsonchat/JsonMessage.java | 7 ++ .../mineplex/core/common/util/UtilTime.java | 4 +- .../mineplex/core/friend/FriendManager.java | 101 +++++++----------- .../core/friend/command/AddFriend.java | 4 +- .../core/friend/data/FriendRepository.java | 10 +- .../core/friend/ui/FriendTabList.java | 2 +- .../src/mineplex/core/friend/ui/TabList.java | 25 +++-- .../.externalToolBuilders/Hub Builder.launch | 2 +- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 3 + .../serverdata/RedisDataRepository.java | 2 - .../serverdata/RedisServerRepository.java | 10 +- .../src/mineplex/serverdata/ServerGroup.java | 3 - .../mineplex/serverdata/ServerManager.java | 1 - 14 files changed, 92 insertions(+), 90 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/jsonchat/ChildJsonMessage.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/jsonchat/ChildJsonMessage.java index 3d5e818a1..e6fdb1914 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/jsonchat/ChildJsonMessage.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/jsonchat/ChildJsonMessage.java @@ -34,6 +34,14 @@ public class ChildJsonMessage extends JsonMessage return this; } + + @Override + public ChildJsonMessage bold() + { + super.bold(); + + return this; + } @Override public ChildJsonMessage click(String action, String value) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/jsonchat/JsonMessage.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/jsonchat/JsonMessage.java index a37c9185f..428d3344e 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/jsonchat/JsonMessage.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/jsonchat/JsonMessage.java @@ -25,6 +25,13 @@ public class JsonMessage return this; } + public JsonMessage bold() + { + Builder.append(", bold:true"); + + return this; + } + public ChildJsonMessage extra(String text) { Builder.append(", \"extra\":["); diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java index 39102ff20..38c4a33a0 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java @@ -5,8 +5,8 @@ import java.util.Calendar; public class UtilTime { - public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss"; - public static final String DATE_FORMAT_DAY = "yyyy-MM-dd"; + public static final String DATE_FORMAT_NOW = "MM-dd-yyyy HH:mm:ss"; + public static final String DATE_FORMAT_DAY = "MM-dd-yyyy"; public static String now() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java index 8d4cb8a8f..b04f14c53 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java @@ -1,47 +1,42 @@ package mineplex.core.friend; -import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo; +import java.util.Collections; +import java.util.List; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniClientPlugin; import mineplex.core.account.event.RetrieveClientInformationEvent; +import mineplex.core.common.jsonchat.ChildJsonMessage; +import mineplex.core.common.jsonchat.JsonMessage; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.friend.command.AddFriend; import mineplex.core.friend.command.DeleteFriend; import mineplex.core.friend.data.FriendData; import mineplex.core.friend.data.FriendRepository; -import mineplex.core.friend.ui.FriendTabList; -import mineplex.core.packethandler.IPacketHandler; -import mineplex.core.packethandler.PacketHandler; -import mineplex.core.packethandler.PacketInfo; -import mineplex.core.timing.TimingManager; +import mineplex.core.friend.data.FriendStatus; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -public class FriendManager extends MiniClientPlugin implements IPacketHandler +public class FriendManager extends MiniClientPlugin { + private static FriendSorter _friendSorter = new FriendSorter(); + private FriendRepository _repository; - private NautHashMap _playerTabMap; - private boolean _sendingPackets = false; - - public FriendManager(JavaPlugin plugin, PacketHandler packetHandler) + public FriendManager(JavaPlugin plugin) { super("Friends", plugin); - packetHandler.addPacketHandler(this); - _repository = new FriendRepository(plugin); - _playerTabMap = new NautHashMap(); } @Override @@ -65,31 +60,12 @@ public class FriendManager extends MiniClientPlugin implements IPack { public void run() { - TimingManager.start(event.getPlayerName() + " friend Account call."); Set(event.getPlayerName(), _repository.loadClientInformation(event.getUniqueId())); - TimingManager.stop(event.getPlayerName() + " friend Account call."); event.decreaseProcessingCount(); } }); } - @EventHandler - public void updateTabLists(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - _sendingPackets = true; - for (Player player : Bukkit.getOnlinePlayers()) - { - if (!_playerTabMap.containsKey(player) || !_playerTabMap.get(player).shouldUpdate()) - continue; - - _playerTabMap.get(player).refreshForPlayer(player); - } - _sendingPackets = false; - } - @EventHandler public void updateFriends(UpdateEvent event) { @@ -106,7 +82,7 @@ public class FriendManager extends MiniClientPlugin implements IPack { public void run() { - for (Player player : _playerTabMap.keySet()) + for (Player player : Bukkit.getOnlinePlayers()) { if (newData.containsKey(player.getUniqueId().toString())) { @@ -116,38 +92,12 @@ public class FriendManager extends MiniClientPlugin implements IPack { Get(player).Friends.clear(); } - - _playerTabMap.get(player).updateFriends(Get(player).Friends); } } }); } }); } - - @EventHandler - public void addFriendTab(PlayerJoinEvent event) - { - _playerTabMap.put(event.getPlayer(), new FriendTabList(Get(event.getPlayer().getName()).Friends)); - _playerTabMap.get(event.getPlayer()).refreshForPlayer(event.getPlayer()); - } - - @EventHandler - public void removeFriendTab(PlayerQuitEvent event) - { - _playerTabMap.remove(event.getPlayer()); - } - - public void handle(PacketInfo packetInfo) - { - if (packetInfo.isCancelled()) - return; - - if (packetInfo.getPacket() instanceof PacketPlayOutPlayerInfo) - { - packetInfo.setCancelled(_sendingPackets); - } - } public void addFriend(final Player caller, final String name) { @@ -186,4 +136,31 @@ public class FriendManager extends MiniClientPlugin implements IPack } }); } + + public void showFriends(Player caller) + { + List friendStatuses = Get(caller).Friends; + Collections.sort(friendStatuses, _friendSorter); + + caller.sendMessage(C.cBlue + "======================[" + ChatColor.RESET + C.cYellow + C.Bold + "Friends" + ChatColor.RESET + C.cBlue + "]======================"); + + for (FriendStatus friend : friendStatuses) + { + ChildJsonMessage message = new JsonMessage(friend.Name).color(friend.Online ? "gold" : "gray").extra(" - ").color("white"); + + if (friend.Online) + { + if (friend.Mutual) + message.add(friend.ServerName + " Connect").color("green").bold().click("run_command", "/server " + friend.ServerName).add(" - ").color("white"); + else + message.add("Friend request pending").color("yellow").add(" - ").color("white"); + } + else + message.add("Last online : ").color("blue").add(UtilTime.when(friend.LastSeenOnline)).color("yellow").add(" - ").color("white"); + + message.add("Unfriend").color("red").bold().click("run_command", "/unfriend " + friend.Name).sendToPlayer(caller); + } + + caller.sendMessage(C.cBlue + "====================================================="); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java index 4a16c5858..ddecfeb66 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java @@ -19,7 +19,9 @@ public class AddFriend extends CommandBase public void Execute(final Player caller, final String[] args) { if (args == null) - F.main(Plugin.GetName(), "You need to include a player's name."); + { + Plugin.showFriends(caller); + } else { CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java index 45bbdaf37..7bc34a777 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java @@ -14,12 +14,16 @@ import mineplex.core.database.column.ColumnVarChar; public class FriendRepository extends RepositoryBase { - private static String CREATE_FRIEND_TABLE = "CREATE TABLE IF NOT EXISTS accountFriend (id INT NOT NULL AUTO_INCREMENT, uuidSource VARCHAR(100), uuidTarget VARCHAR(100), mutual BOOL, PRIMARY KEY (id), INDEX uuidIndex (uuidSource, uuidTarget));"; + private static String CREATE_FRIEND_TABLE = "CREATE TABLE IF NOT EXISTS accountFriend (id INT NOT NULL AUTO_INCREMENT, uuidSource VARCHAR(100), uuidTarget VARCHAR(100), mutual BOOL, PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuidSource, uuidTarget));"; private static String RETRIEVE_MULTIPLE_FRIEND_RECORDS = "SELECT uuidSource, tA.Name, mutual, serverName, tA.lastLogin FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource IN "; private static String RETRIEVE_FRIEND_RECORDS = "SELECT tA.Name, mutual, serverName, tA.lastLogin FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource = ?;"; private static String ADD_FRIEND_RECORD = "INSERT INTO accountFriend (uuidSource, uuidTarget) SELECT fA.uuid AS uuidSource, tA.uuid AS uuidTarget FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.uuid = ?;"; private static String DELETE_FRIEND_RECORD = "DELETE aF FROM accountFriend AS aF INNER JOIN accounts ON accounts.name = ? WHERE uuidSource = ? AND uuidTarget = accounts.uuid;"; + + // Not mutual, need to drop accountFriend to recreate with constraint. + // On add record need to check for a reverse uuidsource/uuidtarget and set mutual + public FriendRepository(JavaPlugin plugin) { super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh"); @@ -73,7 +77,9 @@ public class FriendRepository extends RepositoryBase friend.Name = resultSet.getString(2); friend.Mutual = resultSet.getBoolean(3); friend.ServerName = resultSet.getString(4); - friend.LastSeenOnline = resultSet.getLong(5); + friend.Online = !friend.ServerName.isEmpty(); + + friend.LastSeenOnline = resultSet.getTimestamp(5).getTime(); if (!friends.containsKey(uuidSource)) friends.put(uuidSource, new FriendData()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendTabList.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendTabList.java index a2b0f6a02..a75566137 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendTabList.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendTabList.java @@ -30,7 +30,7 @@ public class FriendTabList extends TabList Collections.sort(friends, _friendSorter); int row = 1; - for (int i = 0; i < 19; i++) + for (int i = 0; i < 16; i++) { if (i < friends.size()) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/TabList.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/TabList.java index 28c500142..d3ecec626 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/TabList.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/TabList.java @@ -13,6 +13,9 @@ import mineplex.core.common.util.NautHashMap; public class TabList implements Listener { + private static int MAX_SLOTS = 64; + private static int COLUMN_SLOTS = 16; + private static NautHashMap _invisibleHolders = new NautHashMap(); private NautHashMap _tabSlots = new NautHashMap(); @@ -23,12 +26,12 @@ public class TabList implements Listener static { String spaces = ""; - for (int i=0; i < 60; i++) + for (int i=0; i < MAX_SLOTS; i++) { - int markerSymbol = i / 15; + int markerSymbol = i / COLUMN_SLOTS; String symbol = null; - if (i % 15 == 0) + if (i % COLUMN_SLOTS == 0) spaces = ""; else spaces += " "; @@ -56,7 +59,7 @@ public class TabList implements Listener public TabList() { - for (Integer i=0; i < 60; i++) + for (Integer i=0; i < MAX_SLOTS; i++) { _tabSlots.put(i, new LineTracker(_invisibleHolders.get(i))); } @@ -64,9 +67,9 @@ public class TabList implements Listener public void set(int column, int row, String lineContent) { - int index = row * 3 + column; + int index = row * 4 + column; - if (index >= 60) + if (index >= MAX_SLOTS) return; if (lineContent == null || lineContent.isEmpty()) @@ -83,21 +86,21 @@ public class TabList implements Listener { EntityPlayer entityPlayer = ((CraftPlayer)player).getHandle(); - int indexChanged = 60; + int indexChanged = MAX_SLOTS; - for (int i=0; i < 60; i++) + for (int i=0; i < MAX_SLOTS; i++) { - if (indexChanged == 60 && _updatedSlots.contains(i)) + if (indexChanged == MAX_SLOTS && _updatedSlots.contains(i)) { indexChanged = i; } - else if (indexChanged != 60 && !_updatedSlots.contains(i)) + else if (indexChanged != MAX_SLOTS && !_updatedSlots.contains(i)) { _tabSlots.get(i).removeLineForPlayer(entityPlayer); } } - for (int i=indexChanged; i < 60; i++) + for (int i=indexChanged; i < MAX_SLOTS; i++) { _tabSlots.get(i).displayLineToPlayer(entityPlayer); } diff --git a/Plugins/Mineplex.Hub/.externalToolBuilders/Hub Builder.launch b/Plugins/Mineplex.Hub/.externalToolBuilders/Hub Builder.launch index 887eb7125..66529a78c 100644 --- a/Plugins/Mineplex.Hub/.externalToolBuilders/Hub Builder.launch +++ b/Plugins/Mineplex.Hub/.externalToolBuilders/Hub Builder.launch @@ -12,7 +12,7 @@ - + diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 62055c56c..ba865f4ed 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -16,6 +16,7 @@ import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.elo.EloManager; import mineplex.core.energy.Energy; +import mineplex.core.friend.FriendManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.logger.Logger; import mineplex.core.memory.MemoryFix; @@ -131,6 +132,8 @@ public class Hub extends JavaPlugin implements IRelation new ClassCombatShop(shopManager, clientManager, donationManager, "Knight", classManager.GetClass("Knight")); new ClassCombatShop(shopManager, clientManager, donationManager, "Assassin", classManager.GetClass("Assassin")); + //new FriendManager(this); + //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); } diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisDataRepository.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisDataRepository.java index ed9221b0b..a4787d417 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisDataRepository.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisDataRepository.java @@ -2,10 +2,8 @@ package mineplex.serverdata; import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Set; import redis.clients.jedis.Jedis; diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisServerRepository.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisServerRepository.java index ba74708a0..25c50dd56 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisServerRepository.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisServerRepository.java @@ -17,9 +17,6 @@ import redis.clients.jedis.Transaction; import redis.clients.jedis.Tuple; import redis.clients.jedis.exceptions.JedisConnectionException; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - /** * RedisServerRepository offers a Redis-based implementation of {@link ServerRepository} * using a mixture of hash and JSON encoded storage. @@ -72,7 +69,12 @@ public class RedisServerRepository implements ServerRepository for (Response response : responses) { String serializedData = response.get(); - servers.add(Utility.deserialize(serializedData, MinecraftServer.class)); + MinecraftServer server = Utility.deserialize(serializedData, MinecraftServer.class); + + if (server != null) + { + servers.add(server); + } } } catch (JedisConnectionException exception) diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerGroup.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerGroup.java index 78e942305..d57d16bbc 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerGroup.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerGroup.java @@ -1,10 +1,7 @@ package mineplex.serverdata; -import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Set; diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerManager.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerManager.java index 58168fb79..66f843ae4 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerManager.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerManager.java @@ -1,6 +1,5 @@ package mineplex.serverdata; -import java.util.Collection; import java.util.HashMap; import java.util.Map; From 1f0bd462e306fb73067082bd0646a994552c028e Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Wed, 24 Sep 2014 22:14:26 -0700 Subject: [PATCH 03/14] Fix for CustomTagFix leak. --- .../src/mineplex/core/CustomTagFix.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java index fea6cefba..c93bfc30b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java @@ -1,6 +1,7 @@ package mineplex.core; import java.lang.reflect.Field; +import java.util.Iterator; import java.util.List; import mineplex.core.common.DummyEntity; @@ -11,6 +12,8 @@ import mineplex.core.packethandler.PacketHandler; import mineplex.core.common.util.UtilPlayer; import mineplex.core.packethandler.PacketVerifier; import mineplex.core.packethandler.PacketInfo; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import net.minecraft.server.v1_7_R4.DataWatcher; import net.minecraft.server.v1_7_R4.EnumEntitySize; import net.minecraft.server.v1_7_R4.MathHelper; @@ -31,6 +34,7 @@ import org.bukkit.plugin.java.JavaPlugin; public class CustomTagFix extends MiniPlugin implements IPacketHandler { private NautHashMap> _entityMap = new NautHashMap>(); + private NautHashMap _loggedIn = new NautHashMap(); private Field _destroyId; @@ -58,6 +62,25 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler _entityMap.remove(event.getPlayer()); } + @EventHandler + public void cleanMap(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + for (Iterator iterator = _entityMap.keySet().iterator(); iterator.hasNext();) + { + Player player = iterator.next(); + + if (!_loggedIn.containsKey(player) || (System.currentTimeMillis() - _loggedIn.get(player) > 5000 && !player.isOnline())) + { + iterator.remove(); + _loggedIn.remove(player); + System.out.println("Found broken player in CustomTagFix.... '" + player.getName() + "'"); + } + } + } + @SuppressWarnings("unchecked") public void handle(PacketInfo packetInfo) { @@ -71,7 +94,10 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler if (UtilPlayer.is1_8(owner)) { if (owner.isOnline() && !_entityMap.containsKey(owner)) + { _entityMap.put(owner, new NautHashMap()); + _loggedIn.put(owner, System.currentTimeMillis()); + } if (packet instanceof PacketPlayOutSpawnEntityLiving) { From e29dd4ff71f36844f632ec729067e92d687cd9d9 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Thu, 25 Sep 2014 05:37:10 -0700 Subject: [PATCH 04/14] Fixes for ServerMonitor. --- .../serverdata/RedisServerRepository.java | 26 ++++-------------- .../mineplex/servermonitor/ServerMonitor.java | 27 +++++++++++++++++-- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisServerRepository.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisServerRepository.java index 25c50dd56..8f3ae9073 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisServerRepository.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisServerRepository.java @@ -185,7 +185,7 @@ public class RedisServerRepository implements ServerRepository String dataKey = concatenate(setKey, serverName); Transaction transaction = jedis.multi(); - transaction.set(dataKey, null); + transaction.del(dataKey); transaction.zrem(setKey, serverName); transaction.exec(); } @@ -258,25 +258,6 @@ public class RedisServerRepository implements ServerRepository } } - Map serverGroups = new HashMap(); - for (ServerGroup serverGroup : getServerGroups()) - { - serverGroups.put(serverGroup.getName(), serverGroup); - } - - // TODO: Find cleaner way to prep dedicated server group counts? - for (DedicatedServer server : servers) - { - for (MinecraftServer minecraftServer : getServerStatuses()) - { - if (serverGroups.containsKey(minecraftServer.getGroup())) - { - ServerGroup serverGroup = serverGroups.get(minecraftServer.getGroup()); - server.incrementServerCount(serverGroup); - } - } - } - return servers; } @@ -415,7 +396,10 @@ public class RedisServerRepository implements ServerRepository for (Response response : responses) { String serializedData = response.get(); - servers.add(Utility.deserialize(serializedData, MinecraftServer.class)); + MinecraftServer server = Utility.deserialize(serializedData, MinecraftServer.class); + + if (server != null) + servers.add(server); } } catch (JedisConnectionException exception) diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java index d271edc74..b01f2a25d 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java @@ -14,6 +14,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Map.Entry; import java.util.logging.FileHandler; import java.util.logging.Logger; @@ -74,7 +75,8 @@ public class ServerMonitor while (true) { Collection serverGroups = _repository.getServerGroups(); - + Collection serverStatuses = _repository.getServerStatuses(); + for (MinecraftServer deadServer : _repository.getDeadServers()) { killServer(deadServer.getName(), deadServer.getPublicAddress(), "[KILLED] [DEAD] " + deadServer.getName() + ":" + deadServer.getPublicAddress(), true); @@ -82,6 +84,24 @@ public class ServerMonitor List dedicatedServers = new ArrayList(_repository.getDedicatedServers()); + Map serverGroupMap = new HashMap(); + for (ServerGroup serverGroup : serverGroups) + { + serverGroupMap.put(serverGroup.getName(), serverGroup); + } + + for (MinecraftServer minecraftServer : serverStatuses) + { + for (DedicatedServer server : dedicatedServers) + { + if (serverGroupMap.containsKey(minecraftServer.getGroup()) && minecraftServer.getPublicAddress().equalsIgnoreCase(server.getPrivateAddress())) + { + ServerGroup serverGroup = serverGroupMap.get(minecraftServer.getGroup()); + server.incrementServerCount(serverGroup); + } + } + } + if (_count % 15 == 0) { _badServers.clear(); @@ -129,7 +149,7 @@ public class ServerMonitor HashSet onlineServers = new HashSet(); - for (MinecraftServer minecraftServer : _repository.getServerStatuses()) + for (MinecraftServer minecraftServer : serverStatuses) { onlineServers.add(minecraftServer.getName()); @@ -237,7 +257,10 @@ public class ServerMonitor int availableSlots = serverGroup.getMaxPlayerCount() - serverGroup.getPlayerCount(); if (availableSlots < 1500) + { serversToAdd = Math.max(1, (1500 - availableSlots) / serverGroup.getMaxPlayers()); + serversToKill = 0; + } else if (serversToKill > 0) serversToKill = Math.min(serversToKill, (availableSlots - 1500) / 80); } From 8bca23f0baad8b1d79d897a0cb90a0cb17524bcc Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Thu, 25 Sep 2014 23:27:08 -0700 Subject: [PATCH 05/14] Fixed bug with custom tag fix :P Fixed bug with server group up time check in servermonitor. --- .../Mineplex.Core/src/mineplex/core/CustomTagFix.java | 9 +++++---- Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java | 2 +- .../src/mineplex/serverdata/ServerGroup.java | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java index c93bfc30b..a1cf0ed03 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java @@ -60,6 +60,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler public void playerQuit(PlayerQuitEvent event) { _entityMap.remove(event.getPlayer()); + _loggedIn.remove(event.getPlayer()); } @EventHandler @@ -68,14 +69,14 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler if (event.getType() != UpdateType.SEC) return; - for (Iterator iterator = _entityMap.keySet().iterator(); iterator.hasNext();) + for (Iterator iterator = _loggedIn.keySet().iterator(); iterator.hasNext();) { Player player = iterator.next(); - if (!_loggedIn.containsKey(player) || (System.currentTimeMillis() - _loggedIn.get(player) > 5000 && !player.isOnline())) + if (System.currentTimeMillis() - _loggedIn.get(player) > 5000 && !player.isOnline()) { iterator.remove(); - _loggedIn.remove(player); + _entityMap.remove(player); System.out.println("Found broken player in CustomTagFix.... '" + player.getName() + "'"); } } @@ -91,7 +92,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler Player owner = packetInfo.getPlayer(); PacketVerifier verifier = packetInfo.getVerifier(); - if (UtilPlayer.is1_8(owner)) + if (owner.isOnline() && UtilPlayer.is1_8(owner)) { if (owner.isOnline() && !_entityMap.containsKey(owner)) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index ba865f4ed..38281e54c 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -70,7 +70,7 @@ public class Hub extends JavaPlugin implements IRelation Logger.initialize(this); //Static Modules - CommandCenter.Initialize(this); + CommandCenter.Initialize(this); CoreClientManager clientManager = new CoreClientManager(this, webServerAddress); CommandCenter.Instance.setClientManager(clientManager); diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerGroup.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerGroup.java index d57d16bbc..dfebd6849 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerGroup.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerGroup.java @@ -234,7 +234,7 @@ public class ServerGroup for (MinecraftServer server : _servers) { - if (server.isEmpty() && server.getUptime() <= 150) // Only return empty servers that have been online for >150 seconds + if (server.isEmpty() && server.getUptime() >= 150) // Only return empty servers that have been online for >150 seconds { emptyServers.add(server); } From eaee6c2733871667658d1137fc9bcb0dd1f35a88 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Fri, 26 Sep 2014 12:38:51 -0700 Subject: [PATCH 06/14] AWork on FRiends. --- .../mineplex/core/friend/FriendManager.java | 2 +- .../core/friend/data/FriendRepository.java | 38 ++++++++++++++----- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java index b04f14c53..02706fe38 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java @@ -105,7 +105,7 @@ public class FriendManager extends MiniClientPlugin { public void run() { - _repository.addFriend(caller.getUniqueId().toString(), name); + _repository.addFriend(caller, name); Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java index 7bc34a777..13db250ab 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java @@ -14,10 +14,12 @@ import mineplex.core.database.column.ColumnVarChar; public class FriendRepository extends RepositoryBase { - private static String CREATE_FRIEND_TABLE = "CREATE TABLE IF NOT EXISTS accountFriend (id INT NOT NULL AUTO_INCREMENT, uuidSource VARCHAR(100), uuidTarget VARCHAR(100), mutual BOOL, PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuidSource, uuidTarget));"; - private static String RETRIEVE_MULTIPLE_FRIEND_RECORDS = "SELECT uuidSource, tA.Name, mutual, serverName, tA.lastLogin FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource IN "; + private static String CREATE_FRIEND_TABLE = "CREATE TABLE IF NOT EXISTS accountFriend (id INT NOT NULL AUTO_INCREMENT, uuidSource VARCHAR(100), uuidTarget VARCHAR(100), status VARCHAR(100), PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuidSource, uuidTarget));"; + private static String RETRIEVE_MULTIPLE_FRIEND_RECORDS = "SELECT uuidSource, tA.Name, status, serverName, tA.lastLogin FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource IN "; private static String RETRIEVE_FRIEND_RECORDS = "SELECT tA.Name, mutual, serverName, tA.lastLogin FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource = ?;"; - private static String ADD_FRIEND_RECORD = "INSERT INTO accountFriend (uuidSource, uuidTarget) SELECT fA.uuid AS uuidSource, tA.uuid AS uuidTarget FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.uuid = ?;"; + private static String RETRIEVE_OTHER_FRIEND_RECORDS_BY_NAME = "SELECT tA.Name, mutual, serverName, tA.lastLogin FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE name = ?;"; + private static String ADD_FRIEND_RECORD = "INSERT INTO accountFriend (uuidSource, uuidTarget, status) SELECT fA.uuid AS uuidSource, tA.uuid AS uuidTarget, 'Pending' FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.name = ?;"; + private static String UPDATE_MUTUAL_RECORD = "UPDATE aF SET status = ? FROM accountFriend AS aF INNER JOIN accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.name = ?;"; private static String DELETE_FRIEND_RECORD = "DELETE aF FROM accountFriend AS aF INNER JOIN accounts ON accounts.name = ? WHERE uuidSource = ? AND uuidTarget = accounts.uuid;"; @@ -40,14 +42,34 @@ public class FriendRepository extends RepositoryBase { } - public boolean addFriend(String uuid, String name) + public boolean addFriend(final Player caller, String name) { - return executeUpdate(ADD_FRIEND_RECORD, new ColumnVarChar("name", 40, name), new ColumnVarChar("uuid", 100, uuid)) > 0; + int rowsAffected = executeUpdate(ADD_FRIEND_RECORD, new ColumnVarChar("name", 100, name), new ColumnVarChar("name", 100, caller.getName())); + + if (rowsAffected > 0) + return executeUpdate(ADD_FRIEND_RECORD, new ColumnVarChar("name", 100, caller.getName()), new ColumnVarChar("uuid", 100, name)) > 0; + + return false; } - public boolean removeFriend(String uuid, String name) + public boolean updateFriend(Player caller, String name, String status) { - return executeUpdate(DELETE_FRIEND_RECORD, new ColumnVarChar("name", 40, name), new ColumnVarChar("uuid", 100, uuid)) > 0; + int rowsAffected = executeUpdate(UPDATE_MUTUAL_RECORD, new ColumnVarChar("status", 100, status), new ColumnVarChar("name", 100, name), new ColumnVarChar("name", 100, caller.getName())); + + if (rowsAffected > 0) + return executeUpdate(UPDATE_MUTUAL_RECORD, new ColumnVarChar("status", 100, status), new ColumnVarChar("name", 100, caller.getName()), new ColumnVarChar("uuid", 100, name)) > 0; + + return false; + } + + public boolean removeFriend(Player caller, String name) + { + int rowsAffected = executeUpdate(DELETE_FRIEND_RECORD, new ColumnVarChar("name", 100, name), new ColumnVarChar("name", 100, caller.getName())); + + if (rowsAffected > 0) + return executeUpdate(DELETE_FRIEND_RECORD, new ColumnVarChar("name", 100, caller.getName()), new ColumnVarChar("uuid", 100, name)) > 0; + + return false; } public NautHashMap getFriendsForAll(Player...players) @@ -109,8 +131,6 @@ public class FriendRepository extends RepositoryBase friend.ServerName = resultSet.getString(3); friend.LastSeenOnline = resultSet.getLong(4); - System.out.println("Adding friend " + friend.Name + " for UUID " + uniqueId.toString()); - friendData.Friends.add(friend); } } From 1bf5debc06f9bb6cdf951a632b55092433c018ab Mon Sep 17 00:00:00 2001 From: Peter Miller Date: Sat, 27 Sep 2014 00:45:52 -0400 Subject: [PATCH 07/14] Updating DDoSProtectionSwitcher switchServer() method to launch remote script for IP change instead of local. --- .../src/mineplex/ddos/DDoSProtectionSwitcher.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.DDoSProtectionSwitcher/src/mineplex/ddos/DDoSProtectionSwitcher.java b/Plugins/Mineplex.DDoSProtectionSwitcher/src/mineplex/ddos/DDoSProtectionSwitcher.java index dd9898f6f..9bcaaf2de 100644 --- a/Plugins/Mineplex.DDoSProtectionSwitcher/src/mineplex/ddos/DDoSProtectionSwitcher.java +++ b/Plugins/Mineplex.DDoSProtectionSwitcher/src/mineplex/ddos/DDoSProtectionSwitcher.java @@ -275,10 +275,13 @@ public class DDoSProtectionSwitcher private static void switchServer(final String privateIp, String currentIp, String newIp, String currentGateway, String newGateway) { - String cmd = "/home/mineplex/switchBungeeIp.sh"; + String cmd = "/usr/bin/ssh"; + String args = "-to StrictHostKeyChecking=no -o ServerAliveInterval=10 mineplex@" + privateIp + " -p 5191"; + String remoteCmd = "\"sh /home/mineplex/config/switchBungeeIpRemote.sh"; + String remoteCmdEnd = "\""; - ProcessRunner pr = new ProcessRunner(new String[] { "/bin/sh", cmd, privateIp, currentIp, newIp, - currentGateway, newGateway }); + ProcessRunner pr = new ProcessRunner(new String[] { cmd, args, remoteCmd, currentIp, newIp, + currentGateway, newGateway, remoteCmdEnd }); pr.start(new GenericRunnable() { public void run(Boolean error) From 7892c442d0962f01678ecc4dfb17936c0fe1047e Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Mon, 29 Sep 2014 11:14:20 -0500 Subject: [PATCH 08/14] Add show mac reports user pref for mod+ --- .../src/mineplex/core/antihack/AntiHack.java | 44 +++++++++++-------- .../preferences/PreferencesRepository.java | 10 +++-- .../core/preferences/UserPreferences.java | 1 + .../core/preferences/ui/PreferencesPage.java | 37 ++++++++++++++-- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 4 +- .../src/nautilus/game/arcade/Arcade.java | 2 +- 6 files changed, 69 insertions(+), 29 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 66b107d9d..c3f0efc59 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -6,20 +6,6 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Map.Entry; -import mineplex.core.MiniPlugin; -import mineplex.core.antihack.types.*; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.portal.Portal; -import mineplex.core.punish.Punish; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Material; @@ -33,6 +19,24 @@ import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.antihack.types.Fly; +import mineplex.core.antihack.types.Idle; +import mineplex.core.antihack.types.Speed; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.portal.Portal; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.punish.Punish; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + public class AntiHack extends MiniPlugin { private static Object _antiHackLock = new Object(); @@ -43,6 +47,8 @@ public class AntiHack extends MiniPlugin public Punish Punish; public Portal Portal; + private PreferencesManager _preferences; + private CoreClientManager _clientManager; //Record Offenses private HashMap>> _suspicion = new HashMap>>(); @@ -71,12 +77,14 @@ public class AntiHack extends MiniPlugin private AntiHackRepository _repository; - protected AntiHack(JavaPlugin plugin, Punish punish, Portal portal) + protected AntiHack(JavaPlugin plugin, Punish punish, Portal portal, PreferencesManager preferences, CoreClientManager clientManager) { super("AntiHack", plugin); Punish = punish; Portal = portal; + _preferences = preferences; + _clientManager = clientManager; _repository = new AntiHackRepository(plugin.getConfig().getString("serverstatus.name")); _repository.initialize(); @@ -88,9 +96,9 @@ public class AntiHack extends MiniPlugin _detectors.add(new Speed(this)); } - public static void Initialize(JavaPlugin plugin, Punish punish, Portal portal) + public static void Initialize(JavaPlugin plugin, Punish punish, Portal portal, PreferencesManager preferences, CoreClientManager clientManager) { - Instance = new AntiHack(plugin, punish, portal); + Instance = new AntiHack(plugin, punish, portal, preferences, clientManager); } @EventHandler @@ -248,7 +256,7 @@ public class AntiHack extends MiniPlugin } for (Player admin : UtilServer.getPlayers()) - if (admin.isOp() && UtilGear.isMat(admin.getItemInHand(), Material.PAPER)) + if (_clientManager.Get(admin).GetRank().Has(Rank.MODERATOR) && _preferences.Get(admin).ShowMacReports) UtilPlayer.message(admin, C.cRed + C.Bold + player.getName() + " suspected for " + type + "."); // Print (Debug) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java index 3f764b6f2..ad9615a9f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java @@ -15,10 +15,10 @@ import mineplex.core.database.column.ColumnVarChar; public class PreferencesRepository extends RepositoryBase { - private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));"; + private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));"; private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;"; - private static String RETRIEVE_ACCOUNT_PREFERENCES = "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield FROM accountPreferences WHERE uuid = ?;"; - private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ? WHERE uuid=?;"; + private static String RETRIEVE_ACCOUNT_PREFERENCES = "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports FROM accountPreferences WHERE uuid = ?;"; + private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ? WHERE uuid=?;"; public PreferencesRepository(JavaPlugin plugin, String connectionString) { @@ -54,7 +54,8 @@ public class PreferencesRepository extends RepositoryBase preparedStatement.setBoolean(6, entry.getValue().PartyRequests); preparedStatement.setBoolean(7, entry.getValue().Invisibility); preparedStatement.setBoolean(8, entry.getValue().HubForcefield); - preparedStatement.setString(9, entry.getKey()); + preparedStatement.setBoolean(9, entry.getValue().ShowMacReports); + preparedStatement.setString(10, entry.getKey()); preparedStatement.addBatch(); } @@ -103,6 +104,7 @@ public class PreferencesRepository extends RepositoryBase preferences.PartyRequests = resultSet.getBoolean(6); preferences.Invisibility = resultSet.getBoolean(7); preferences.HubForcefield = resultSet.getBoolean(8); + preferences.ShowMacReports = resultSet.getBoolean(9); } } }, new ColumnVarChar("uuid", 100, uuid.toString())); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java index 6da2a2e16..a48011290 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java @@ -11,4 +11,5 @@ public class UserPreferences public boolean PartyRequests = true; public boolean Invisibility = false; public boolean HubForcefield = false; + public boolean ShowMacReports = false; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java index 59d972c17..761a11dff 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java @@ -1,5 +1,9 @@ package mineplex.core.preferences.ui; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; + import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; import mineplex.core.donation.DonationManager; @@ -9,10 +13,6 @@ import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; - public class PreferencesPage extends ShopPageBase { private IButton _toggleHubGames; @@ -22,6 +22,7 @@ public class PreferencesPage extends ShopPageBase Date: Mon, 29 Sep 2014 12:13:38 -0700 Subject: [PATCH 09/14] Fixed class path for PvP project. --- Plugins/Nautilus.Game.PvP/.classpath | 1 - 1 file changed, 1 deletion(-) diff --git a/Plugins/Nautilus.Game.PvP/.classpath b/Plugins/Nautilus.Game.PvP/.classpath index aeb789270..e94501478 100644 --- a/Plugins/Nautilus.Game.PvP/.classpath +++ b/Plugins/Nautilus.Game.PvP/.classpath @@ -3,7 +3,6 @@ - From 92f8dc7f610be93261ccc7a0db59868901d754de Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Mon, 29 Sep 2014 17:17:02 -0500 Subject: [PATCH 10/14] Add velocity toggle for mod+ --- .../preferences/PreferencesRepository.java | 10 +++-- .../core/preferences/UserPreferences.java | 1 + .../core/preferences/ui/PreferencesPage.java | 45 ++++++++++++++++--- .../src/mineplex/hub/HubManager.java | 10 +++++ 4 files changed, 55 insertions(+), 11 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java index ad9615a9f..7e647126c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java @@ -15,10 +15,10 @@ import mineplex.core.database.column.ColumnVarChar; public class PreferencesRepository extends RepositoryBase { - private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));"; + private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));"; private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;"; - private static String RETRIEVE_ACCOUNT_PREFERENCES = "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports FROM accountPreferences WHERE uuid = ?;"; - private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ? WHERE uuid=?;"; + private static String RETRIEVE_ACCOUNT_PREFERENCES = "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity FROM accountPreferences WHERE uuid = ?;"; + private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ? WHERE uuid=?;"; public PreferencesRepository(JavaPlugin plugin, String connectionString) { @@ -55,7 +55,8 @@ public class PreferencesRepository extends RepositoryBase preparedStatement.setBoolean(7, entry.getValue().Invisibility); preparedStatement.setBoolean(8, entry.getValue().HubForcefield); preparedStatement.setBoolean(9, entry.getValue().ShowMacReports); - preparedStatement.setString(10, entry.getKey()); + preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity); + preparedStatement.setString(11, entry.getKey()); preparedStatement.addBatch(); } @@ -105,6 +106,7 @@ public class PreferencesRepository extends RepositoryBase preferences.Invisibility = resultSet.getBoolean(7); preferences.HubForcefield = resultSet.getBoolean(8); preferences.ShowMacReports = resultSet.getBoolean(9); + preferences.IgnoreVelocity = resultSet.getBoolean(10); } } }, new ColumnVarChar("uuid", 100, uuid.toString())); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java index a48011290..7eb95ea1f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java @@ -12,4 +12,5 @@ public class UserPreferences public boolean Invisibility = false; public boolean HubForcefield = false; public boolean ShowMacReports = false; + public boolean IgnoreVelocity = false; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java index 761a11dff..fc2cb8f83 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java @@ -22,8 +22,9 @@ public class PreferencesPage extends ShopPageBase { } + + @EventHandler + public void ignoreVelocity(PlayerVelocityEvent event) + { + if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR) && _preferences.Get(event.getPlayer()).IgnoreVelocity) + { + event.setCancelled(true); + } + } } From 70fd8835acaa69ef77ca89147c584823af65dc36 Mon Sep 17 00:00:00 2001 From: CoderTim Date: Tue, 30 Sep 2014 02:45:20 -0400 Subject: [PATCH 11/14] Added GamesPlayed and TimeInGame stats --- .../src/nautilus/game/arcade/game/Game.java | 6 ++- .../arcade/stats/GamesPlayedStatTracker.java | 26 +++++++++++++ .../arcade/stats/TimeInGameStatTracker.java | 39 +++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/GamesPlayedStatTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TimeInGameStatTracker.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 6239ca794..20ee29ca1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -53,11 +53,13 @@ import nautilus.game.arcade.stats.AssistsStatTracker; import nautilus.game.arcade.stats.DamageDealtStatTracker; import nautilus.game.arcade.stats.DamageTakenStatTracker; import nautilus.game.arcade.stats.DeathsStatTracker; +import nautilus.game.arcade.stats.GamesPlayedStatTracker; import nautilus.game.arcade.stats.KillsStatTracker; import nautilus.game.arcade.stats.LoseStatTracker; import nautilus.game.arcade.stats.StatTracker; import nautilus.game.arcade.stats.TeamDeathsStatTracker; import nautilus.game.arcade.stats.TeamKillsStatTracker; +import nautilus.game.arcade.stats.TimeInGameStatTracker; import nautilus.game.arcade.stats.WinStatTracker; import nautilus.game.arcade.world.WorldData; @@ -282,7 +284,9 @@ public abstract class Game implements Listener new DamageDealtStatTracker(this), new DamageTakenStatTracker(this), new TeamDeathsStatTracker(this), - new TeamKillsStatTracker(this) + new TeamKillsStatTracker(this), + new GamesPlayedStatTracker(this), + new TimeInGameStatTracker(this) ); System.out.println("Loading " + GetName() + "..."); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/GamesPlayedStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/GamesPlayedStatTracker.java new file mode 100644 index 000000000..d87d1c3db --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/GamesPlayedStatTracker.java @@ -0,0 +1,26 @@ +package nautilus.game.arcade.stats; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; + +public class GamesPlayedStatTracker extends StatTracker +{ + public GamesPlayedStatTracker(Game game) + { + super(game); + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onGameStateChange(GameStateChangeEvent event) + { + if (event.GetState() == Game.GameState.Live) + { + for (Player player : getGame().GetPlayers(true)) + getGame().AddStat(player, "GamesPlayed", 1, false, true); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TimeInGameStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TimeInGameStatTracker.java new file mode 100644 index 000000000..0b4751c0d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TimeInGameStatTracker.java @@ -0,0 +1,39 @@ +package nautilus.game.arcade.stats; + +import java.util.HashMap; +import java.util.UUID; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import nautilus.game.arcade.game.Game; + +public class TimeInGameStatTracker extends StatTracker +{ + private final HashMap _joinTimes = new HashMap<>(); + + public TimeInGameStatTracker(Game game) + { + super(game); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerJoin(PlayerJoinEvent event) + { + _joinTimes.put(event.getPlayer().getUniqueId(), System.currentTimeMillis()); + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) + { + Long joinTime = _joinTimes.remove(event.getPlayer().getUniqueId()); + + if (joinTime != null) + { + int timeInGame = (int) ((System.currentTimeMillis() - joinTime) / 1000); + getGame().AddStat(event.getPlayer(), "TimeInGame", timeInGame, false, true); + } + } +} From 0228ef592142366f10fcdb86622b867e2e009260 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Tue, 30 Sep 2014 12:20:01 -0700 Subject: [PATCH 12/14] Staff server work to include treasure chests/keys and gem hunter level 8, 12. --- .../core/friend/data/FriendRepository.java | 6 +- .../src/mineplex/core/stats/StatsManager.java | 83 ++++++++++--------- .../core/treasure/TreasureManager.java | 2 +- .../src/mineplex/staffServer/StaffServer.java | 3 +- .../salespackage/SalesPackageManager.java | 17 +++- .../command/GemHunterCommand.java | 31 +++++++ .../salespackage/command/HeroCommand.java | 16 ++-- .../command/LifetimeHeroCommand.java | 15 ++-- .../command/LifetimeUltraCommand.java | 15 ++-- .../salespackage/command/Sales.java | 3 + .../command/TreasureChestCommand.java | 31 +++++++ .../command/TreasureKeyCommand.java | 31 +++++++ .../salespackage/command/UltraCommand.java | 15 ++-- .../salespackage/salespackages/GemHunter.java | 23 +++++ .../salespackages/LifetimeHero.java | 4 +- .../salespackages/LifetimeUltra.java | 4 +- .../salespackages/MonthlyHero.java | 2 + .../salespackages/MonthlyUltra.java | 2 + 18 files changed, 228 insertions(+), 75 deletions(-) create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/TreasureChestCommand.java create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/TreasureKeyCommand.java create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/GemHunter.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java index 13db250ab..9ce7a3ec9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java @@ -62,12 +62,12 @@ public class FriendRepository extends RepositoryBase return false; } - public boolean removeFriend(Player caller, String name) + public boolean removeFriend(String caller, String name) { - int rowsAffected = executeUpdate(DELETE_FRIEND_RECORD, new ColumnVarChar("name", 100, name), new ColumnVarChar("name", 100, caller.getName())); + int rowsAffected = executeUpdate(DELETE_FRIEND_RECORD, new ColumnVarChar("name", 100, name), new ColumnVarChar("name", 100, caller)); if (rowsAffected > 0) - return executeUpdate(DELETE_FRIEND_RECORD, new ColumnVarChar("name", 100, caller.getName()), new ColumnVarChar("uuid", 100, name)) > 0; + return executeUpdate(DELETE_FRIEND_RECORD, new ColumnVarChar("name", 100, caller), new ColumnVarChar("uuid", 100, name)) > 0; return false; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index 23837fe8d..002a84355 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -57,45 +57,7 @@ public class StatsManager extends MiniClientPlugin final String uuidString = player.getUniqueId().toString(); - // Verify stat is in our local cache, if not add it remotely. - if (!_stats.containsKey(statName)) - { - Bukkit.getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable() - { - public void run() - { - synchronized (_statSync) - { - // If many players come in for a new stat, when the first add finishes the others are queued to add again - // This makes a second check for the stat name (already added before lock was released) - // Then it pops into queue and forgets adding the new stat to db. - if (_stats.containsKey(statName)) - { - addToQueue(statName, uuidString, value); - return; - } - - _repository.addStat(statName); - - _stats.clear(); - - for (Stat stat : _repository.retrieveStats()) - { - _stats.put(stat.Name, stat.Id); - } - - addToQueue(statName, uuidString, value); - } - } - }); - } - else - { - synchronized (_statSync) - { - addToQueue(statName, uuidString, value); - } - } + incrementStat(uuidString, statName, value); } private void addToQueue(String statName, String uuidString, int value) @@ -181,4 +143,47 @@ public class StatsManager extends MiniClientPlugin } }); } + + public void incrementStat(final String uuidString, final String statName, final int value) + { + // Verify stat is in our local cache, if not add it remotely. + if (!_stats.containsKey(statName)) + { + Bukkit.getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable() + { + public void run() + { + synchronized (_statSync) + { + // If many players come in for a new stat, when the first add finishes the others are queued to add again + // This makes a second check for the stat name (already added before lock was released) + // Then it pops into queue and forgets adding the new stat to db. + if (_stats.containsKey(statName)) + { + addToQueue(statName, uuidString, value); + return; + } + + _repository.addStat(statName); + + _stats.clear(); + + for (Stat stat : _repository.retrieveStats()) + { + _stats.put(stat.Name, stat.Id); + } + + addToQueue(statName, uuidString, value); + } + } + }); + } + else + { + synchronized (_statSync) + { + addToQueue(statName, uuidString, value); + } + } + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java index 5692b8964..dc6e8fe24 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java @@ -102,7 +102,7 @@ public class TreasureManager extends MiniPlugin { // Remove a treasure and a key _inventoryManager.addItemToInventory(player, "Treasure", "Treasure Key", -1); - _inventoryManager.addItemToInventory(player, "Treasure", "Treasure Chest", -1); + _inventoryManager.addItemToInventory(player, "Utility", "Treasure Chest", -1); } Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + C.cGreen + "Treasure Chest")); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java index 7e8e7cc55..d8670c249 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java @@ -13,6 +13,7 @@ import mineplex.core.playerTracker.PlayerTracker; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.recharge.Recharge; +import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; @@ -56,7 +57,7 @@ public class StaffServer extends JavaPlugin new MemoryFix(this); new FileUpdater(this, portal); - new CustomerSupport(this, clientManager, donationManager, new SalesPackageManager(this, clientManager, donationManager, new InventoryManager(this))); + new CustomerSupport(this, clientManager, donationManager, new SalesPackageManager(this, clientManager, donationManager, new InventoryManager(this), new StatsManager(this))); new Password(this); //Updates diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java index d09722118..d191bea11 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java @@ -1,6 +1,5 @@ package mineplex.staffServer.salespackage; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -8,12 +7,13 @@ import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilServer; import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; +import mineplex.core.stats.StatsManager; import mineplex.staffServer.salespackage.command.DisplayPackageCommand; import mineplex.staffServer.salespackage.command.Sales; import mineplex.staffServer.salespackage.salespackages.Coins; +import mineplex.staffServer.salespackage.salespackages.GemHunter; import mineplex.staffServer.salespackage.salespackages.LifetimeHero; import mineplex.staffServer.salespackage.salespackages.LifetimeUltra; import mineplex.staffServer.salespackage.salespackages.MonthlyHero; @@ -25,16 +25,18 @@ public class SalesPackageManager extends MiniPlugin private CoreClientManager _clientManager; private DonationManager _donationManager; private InventoryManager _inventoryManager; + private StatsManager _statsManager; private NautHashMap _salesPackages = new NautHashMap(); - public SalesPackageManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager) + public SalesPackageManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, StatsManager statsManager) { super("SalesPackageManager", plugin); _clientManager = clientManager; _donationManager = donationManager; _inventoryManager = inventoryManager; + _statsManager = statsManager; AddSalesPackage(new Coins(this, 5000)); AddSalesPackage(new Coins(this, 25000)); @@ -42,7 +44,9 @@ public class SalesPackageManager extends MiniPlugin AddSalesPackage(new MonthlyUltra(this)); AddSalesPackage(new MonthlyHero(this)); AddSalesPackage(new LifetimeUltra(this)); - AddSalesPackage(new LifetimeHero(this)); + AddSalesPackage(new LifetimeHero(this)); + AddSalesPackage(new GemHunter(this, 8)); + AddSalesPackage(new GemHunter(this, 12)); } private void AddSalesPackage(SalesPackageBase salesPackage) @@ -101,4 +105,9 @@ public class SalesPackageManager extends MiniPlugin coinBuilder.sendToPlayer(caller); packageBuilder.sendToPlayer(caller); } + + public StatsManager getStatsManager() + { + return _statsManager; + } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java new file mode 100644 index 000000000..b47f6d8e2 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java @@ -0,0 +1,31 @@ +package mineplex.staffServer.salespackage.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.UUIDFetcher; +import mineplex.staffServer.salespackage.SalesPackageManager; + +public class GemHunterCommand extends CommandBase +{ + public GemHunterCommand(SalesPackageManager plugin) + { + super(plugin, Rank.MODERATOR, "gemhunter"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args == null || args.length != 2) + return; + + String playerName = args[0]; + int amount = Integer.parseInt(args[1]); + + Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, "Gem Hunter Level " + amount, false, 0, false); + Plugin.getStatsManager().incrementStat(UUIDFetcher.getUUIDOf(playerName).toString(), "Global.GemsEarned", amount); + caller.sendMessage(F.main(Plugin.GetName(), "Added Level " + amount + " Gem Hunter to " + playerName + "'s account!")); + } +} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/HeroCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/HeroCommand.java index 0d6bb4b1a..c0de8ec3b 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/HeroCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/HeroCommand.java @@ -6,7 +6,6 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; -import mineplex.core.recharge.Recharge; import mineplex.staffServer.salespackage.SalesPackageManager; public class HeroCommand extends CommandBase @@ -20,15 +19,18 @@ public class HeroCommand extends CommandBase public void Execute(Player caller, String[] args) { resetCommandCharge(caller); - PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " HERO false"); - Bukkit.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " HERO false")); resetCommandCharge(caller); - event = new PlayerCommandPreprocessEvent(caller, "/sales coin " + args[0] + " 15000"); - Bukkit.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales coin " + args[0] + " 15000")); resetCommandCharge(caller); - event = new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 90"); - Bukkit.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 90")); + + resetCommandCharge(caller); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales chest " + args[0] + " 40")); + + resetCommandCharge(caller); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales key " + args[0] + " 10")); } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeHeroCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeHeroCommand.java index 38676174b..08fffb258 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeHeroCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeHeroCommand.java @@ -19,15 +19,18 @@ public class LifetimeHeroCommand extends CommandBase public void Execute(Player caller, String[] args) { resetCommandCharge(caller); - PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " HERO true"); - Bukkit.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " HERO true")); resetCommandCharge(caller); - event = new PlayerCommandPreprocessEvent(caller, "/sales coin " + args[0] + " 40000"); - Bukkit.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales coin " + args[0] + " 40000")); resetCommandCharge(caller); - event = new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 180"); - Bukkit.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 180")); + + resetCommandCharge(caller); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales chest " + args[0] + " 40")); + + resetCommandCharge(caller); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales key " + args[0] + " 10")); } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeUltraCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeUltraCommand.java index 970221cfe..dbc33691d 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeUltraCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeUltraCommand.java @@ -19,15 +19,18 @@ public class LifetimeUltraCommand extends CommandBase public void Execute(Player caller, String[] args) { resetCommandCharge(caller); - PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " ULTRA true"); - Bukkit.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " ULTRA true")); resetCommandCharge(caller); - event = new PlayerCommandPreprocessEvent(caller, "/sales coin " + args[0] + " 20000"); - Bukkit.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales coin " + args[0] + " 20000")); resetCommandCharge(caller); - event = new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 60"); - Bukkit.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 60")); + + resetCommandCharge(caller); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales chest " + args[0] + " 20")); + + resetCommandCharge(caller); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales key " + args[0] + " 5")); } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/Sales.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/Sales.java index b5edb5362..47bb4faf3 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/Sales.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/Sales.java @@ -15,6 +15,9 @@ public class Sales extends MultiCommandBase AddCommand(new RankCommand(plugin)); AddCommand(new CoinCommand(plugin)); AddCommand(new BoosterCommand(plugin)); + AddCommand(new TreasureChestCommand(plugin)); + AddCommand(new TreasureKeyCommand(plugin)); + AddCommand(new GemHunterCommand(plugin)); AddCommand(new UltraCommand(plugin)); AddCommand(new HeroCommand(plugin)); AddCommand(new LifetimeUltraCommand(plugin)); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/TreasureChestCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/TreasureChestCommand.java new file mode 100644 index 000000000..8a562e236 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/TreasureChestCommand.java @@ -0,0 +1,31 @@ +package mineplex.staffServer.salespackage.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.UUIDFetcher; +import mineplex.staffServer.salespackage.SalesPackageManager; + +public class TreasureChestCommand extends CommandBase +{ + public TreasureChestCommand(SalesPackageManager plugin) + { + super(plugin, Rank.MODERATOR, "chest"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args == null || args.length != 2) + return; + + String playerName = args[0]; + int amount = Integer.parseInt(args[1]); + + Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, "Treasure Chest " + amount, false, 0, false); + Plugin.getInventoryManager().addItemToInventoryForOffline(UUIDFetcher.getUUIDOf(playerName).toString(), "Utility", "Treasure Chest", amount); + caller.sendMessage(F.main(Plugin.GetName(), "Added " + amount + " treasure chests to " + playerName + "'s account!")); + } +} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/TreasureKeyCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/TreasureKeyCommand.java new file mode 100644 index 000000000..26072bb11 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/TreasureKeyCommand.java @@ -0,0 +1,31 @@ +package mineplex.staffServer.salespackage.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.UUIDFetcher; +import mineplex.staffServer.salespackage.SalesPackageManager; + +public class TreasureKeyCommand extends CommandBase +{ + public TreasureKeyCommand(SalesPackageManager plugin) + { + super(plugin, Rank.MODERATOR, "key"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args == null || args.length != 2) + return; + + String playerName = args[0]; + int amount = Integer.parseInt(args[1]); + + Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, "Treasure Key " + amount, false, 0, false); + Plugin.getInventoryManager().addItemToInventoryForOffline(UUIDFetcher.getUUIDOf(playerName).toString(), "Treasure", "Treasure Key", amount); + caller.sendMessage(F.main(Plugin.GetName(), "Added " + amount + " treasure Keys to " + playerName + "'s account!")); + } +} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/UltraCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/UltraCommand.java index 3e014f75d..4aa7c6fd4 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/UltraCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/UltraCommand.java @@ -19,15 +19,18 @@ public class UltraCommand extends CommandBase public void Execute(Player caller, String[] args) { resetCommandCharge(caller); - PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " ULTRA false"); - Bukkit.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " ULTRA false")); resetCommandCharge(caller); - event = new PlayerCommandPreprocessEvent(caller, "/sales coin " + args[0] + " 7500"); - Bukkit.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales coin " + args[0] + " 7500")); resetCommandCharge(caller); - event = new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 30"); - Bukkit.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 30")); + + resetCommandCharge(caller); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales chest " + args[0] + " 20")); + + resetCommandCharge(caller); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales key " + args[0] + " 5")); } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/GemHunter.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/GemHunter.java new file mode 100644 index 000000000..977060810 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/GemHunter.java @@ -0,0 +1,23 @@ +package mineplex.staffServer.salespackage.salespackages; + +import mineplex.staffServer.salespackage.SalesPackageManager; + +import org.bukkit.entity.Player; + +public class GemHunter extends SalesPackageBase +{ + private int _level; + + public GemHunter(SalesPackageManager manager, int level) + { + super(manager, "Level " + level + " Gem Hunter"); + + _level = level; + } + public void displayToAgent(Player agent, String playerName) + { + addButton(agent, "/sales gemhunter " + playerName + " " + _level, "Level " + _level + " Gem Hunter."); + agent.sendMessage(" "); + addBackButton(agent, playerName); + } +} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/LifetimeHero.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/LifetimeHero.java index caf8b8eab..64940b81f 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/LifetimeHero.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/LifetimeHero.java @@ -15,7 +15,9 @@ public class LifetimeHero extends SalesPackageBase { addButton(agent, "/sales coin " + playerName + " 40000", " 40,000 Coins"); addButton(agent, "/sales booster " + playerName + " 180", " 180 Gem Boosters"); - addButton(agent, "/sales rank " + playerName + " HERO true", " Lifetime Hero (Also, unlocks kits)."); + addButton(agent, "/sales chest " + playerName + " 40", " 40 Treasure Chests"); + addButton(agent, "/sales key " + playerName + " 10", " 10 Treasure Keys"); + addButton(agent, "/sales rank " + playerName + " HERO true", " Lifetime Hero."); addButton(agent, "Apply All", "/sales lifetimehero " + playerName, " Apply all above."); agent.sendMessage(" "); addBackButton(agent, playerName); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/LifetimeUltra.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/LifetimeUltra.java index 991c1551e..bca70da38 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/LifetimeUltra.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/LifetimeUltra.java @@ -15,7 +15,9 @@ public class LifetimeUltra extends SalesPackageBase { addButton(agent, "/sales coin " + playerName + " 20000", " 20,000 Coins"); addButton(agent, "/sales booster " + playerName + " 60", " 60 Gem Boosters"); - addButton(agent, "/sales rank " + playerName + " ULTRA true", " Lifetime Ultra (Also, unlocks kits)."); + addButton(agent, "/sales chest " + playerName + " 20", " 20 Treasure Chests"); + addButton(agent, "/sales key " + playerName + " 5", " 5 Treasure Keys"); + addButton(agent, "/sales rank " + playerName + " ULTRA true", " Lifetime Ultra."); addButton(agent, "Apply All", "/sales lifetimeultra " + playerName, " Apply all above."); agent.sendMessage(" "); addBackButton(agent, playerName); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/MonthlyHero.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/MonthlyHero.java index ad82d4d83..811e0e8ec 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/MonthlyHero.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/MonthlyHero.java @@ -15,6 +15,8 @@ public class MonthlyHero extends SalesPackageBase { addButton(agent, "/sales coin " + playerName + " 15000", " 15,000 Coins"); addButton(agent, "/sales booster " + playerName + " 90", " 90 Gem Boosters"); + addButton(agent, "/sales chest " + playerName + " 40", " 40 Treasure Chests"); + addButton(agent, "/sales key " + playerName + " 10", " 10 Treasure Keys"); addButton(agent, "/sales rank " + playerName + " HERO false", " Monthly Hero."); addButton(agent, "Apply All", "/sales hero " + playerName, " Apply all above."); agent.sendMessage(" "); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/MonthlyUltra.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/MonthlyUltra.java index ce48bbf2f..7a28b1b73 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/MonthlyUltra.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/MonthlyUltra.java @@ -15,6 +15,8 @@ public class MonthlyUltra extends SalesPackageBase { addButton(agent, "/sales coin " + playerName + " 7500", " 7,500 Coins"); addButton(agent, "/sales booster " + playerName + " 30", " 30 Gem Boosters"); + addButton(agent, "/sales chest " + playerName + " 20", " 20 Treasure Chests"); + addButton(agent, "/sales key " + playerName + " 5", " 5 Treasure Keys"); addButton(agent, "/sales rank " + playerName + " ULTRA false", " Monthly Ultra."); addButton(agent, "Apply All", "/sales ultra " + playerName, " Apply all above."); agent.sendMessage(" "); From 9b2a2cbbd68366e3eb08f774b2291e1218133a66 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Wed, 1 Oct 2014 02:12:11 -0700 Subject: [PATCH 13/14] Fixed mounting blocks on yourself in 1.8 Added temp fix so 1.8 players can ride dragons again. Removed Block form in parkour and fly for block form. --- .../src/mineplex/core/CustomTagFix.java | 32 +++-- .../core/gadget/gadgets/BlockForm.java | 115 ++++++++++-------- .../core/gadget/gadgets/MorphBlock.java | 3 + .../src/mineplex/core/mount/DragonData.java | 22 +++- .../src/mineplex/core/mount/DragonMount.java | 2 + .../core/mount/types/MountDragon.java | 2 +- .../src/mineplex/hub/modules/JumpManager.java | 2 +- 7 files changed, 109 insertions(+), 69 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java index a1cf0ed03..8ae749d11 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java @@ -26,6 +26,7 @@ import net.minecraft.server.v1_7_R4.WatchableObject; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerQuitEvent; @@ -179,13 +180,15 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler if (attachPacket.c == owner.getEntityId()) { - packetInfo.setCancelled(true); - //verifier.bypassProcess(new PacketPlayOutEntityDestroy(attachPacket.b)); - /* - System.out.println("Adding patch item."); + System.out.println("Yea, adding patch mount item."); + if (_entityMap.get(owner).containsKey(attachPacket.b)) + { + verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(owner).get(attachPacket.b))); + } + PacketPlayOutSpawnEntityLiving armorPacket = new PacketPlayOutSpawnEntityLiving(); - armorPacket.a = _fakeIdCounter++; - armorPacket.b = (byte) EntityType.SLIME.getTypeId(); + armorPacket.a = UtilEnt.getNewEntityId(); + armorPacket.b = (byte) 30; armorPacket.c = (int)EnumEntitySize.SIZE_2.a(100); armorPacket.d = (int)MathHelper.floor(64 * 32.0D); armorPacket.e = (int)EnumEntitySize.SIZE_2.a(100); @@ -257,16 +260,21 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler armorPacket.l = watcher; - verifier.bypassProcess(packet); - - attachPacket.c = armorPacket.a; + // Spawn armor packet + verifier.bypassProcess(armorPacket); PacketPlayOutAttachEntity attachPacket2 = new PacketPlayOutAttachEntity(); attachPacket2.c = owner.getEntityId(); - attachPacket2.b = attachPacket.a; + attachPacket2.b = armorPacket.a; attachPacket2.a = 0; - verifier.bypassProcess(packet); - */ + + // Send armor attach to player. + verifier.bypassProcess(attachPacket2); + + // Change original packet to attach to armor stand + attachPacket.c = armorPacket.a; + + _entityMap.get(owner).put(attachPacket.b, armorPacket.a); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/BlockForm.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/BlockForm.java index 4941f2648..a2328f7a0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/BlockForm.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/BlockForm.java @@ -1,5 +1,8 @@ package mineplex.core.gadget.gadgets; +import java.util.ArrayList; +import java.util.List; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; @@ -8,9 +11,11 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguiseCat; import mineplex.core.disguise.disguises.DisguiseChicken; +import mineplex.core.gadget.event.GadgetBlockEvent; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; +import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; @@ -24,20 +29,17 @@ import org.bukkit.entity.Player; public class BlockForm { - public MorphBlock Host; - - public Player Player; + private MorphBlock _host; + private Player _player; private Material _mat; - private Block _block; - private Location _loc; public BlockForm(MorphBlock host, Player player, Material mat) { - Host = host; - Player = player; + _host = host; + _player = player; _mat = mat; _loc = player.getLocation(); @@ -48,21 +50,21 @@ public class BlockForm public void Apply() { //Remove Old - if (Player.getPassenger() != null) + if (_player.getPassenger() != null) { - Recharge.Instance.useForce(Player, "PassengerChange", 100); + Recharge.Instance.useForce(_player, "PassengerChange", 100); - Player.getPassenger().remove(); - Player.eject(); + _player.getPassenger().remove(); + _player.eject(); } - ((CraftEntity)Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32)); + ((CraftEntity)_player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32)); //Player > Chicken - DisguiseChicken disguise = new DisguiseChicken(Player); + DisguiseChicken disguise = new DisguiseChicken(_player); disguise.setBaby(); - disguise.setSoundDisguise(new DisguiseCat(Player)); - Host.Manager.getDisguiseManager().disguise(disguise); + disguise.setSoundDisguise(new DisguiseCat(_player)); + _host.Manager.getDisguiseManager().disguise(disguise); //Apply Falling Block FallingBlockCheck(); @@ -70,63 +72,70 @@ public class BlockForm //Inform String blockName = F.elem(ItemStackFactory.Instance.GetName(_mat, (byte)0, false)); if (!blockName.contains("Block")) - UtilPlayer.message(Player, F.main("Game", C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte)0, false) + " Block") + "!")); + UtilPlayer.message(_player, F.main("Game", C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte)0, false) + " Block") + "!")); else - UtilPlayer.message(Player, F.main("Game", C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte)0, false)) + "!")); + UtilPlayer.message(_player, F.main("Game", C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte)0, false)) + "!")); //Sound - Player.playSound(Player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f); + _player.playSound(_player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f); } public void Remove() { SolidifyRemove(); - Host.Manager.getDisguiseManager().undisguise(Player); + _host.Manager.getDisguiseManager().undisguise(_player); //Remove FB - if (Player.getPassenger() != null) + if (_player.getPassenger() != null) { - Recharge.Instance.useForce(Player, "PassengerChange", 100); + Recharge.Instance.useForce(_player, "PassengerChange", 100); - Player.getPassenger().remove(); - Player.eject(); + _player.getPassenger().remove(); + _player.eject(); } - ((CraftEntity)Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0)); + ((CraftEntity)_player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0)); } public void SolidifyUpdate() { - if (!Player.isSprinting()) - ((CraftEntity)Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32)); + if (!_player.isSprinting()) + ((CraftEntity)_player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32)); //Not a Block if (_block == null) { //Moved - if (!_loc.getBlock().equals(Player.getLocation().getBlock())) + if (!_loc.getBlock().equals(_player.getLocation().getBlock())) { - Player.setExp(0); - _loc = Player.getLocation(); + _player.setExp(0); + _loc = _player.getLocation(); } //Unmoved else { double hideBoost = 0.025; - Player.setExp((float) Math.min(0.999f, Player.getExp() + hideBoost)); + _player.setExp((float) Math.min(0.999f, _player.getExp() + hideBoost)); //Set Block - if (Player.getExp() >= 0.999f) + if (_player.getExp() >= 0.999f) { - Block block = Player.getLocation().getBlock(); + Block block = _player.getLocation().getBlock(); + List blockList = new ArrayList(); + blockList.add(block); + + GadgetBlockEvent event = new GadgetBlockEvent(_host, blockList); + + Bukkit.getServer().getPluginManager().callEvent(event); + //Not Able - if (block.getType() != Material.AIR || !UtilBlock.solid(block.getRelative(BlockFace.DOWN))) + if (block.getType() != Material.AIR || !UtilBlock.solid(block.getRelative(BlockFace.DOWN)) || event.getBlocks().isEmpty()) { - UtilPlayer.message(Player, F.main("Game", "You cannot become a Solid Block here.")); - Player.setExp(0f); + UtilPlayer.message(_player, F.main("Game", "You cannot become a Solid Block here.")); + _player.setExp(0f); return; } @@ -134,7 +143,7 @@ public class BlockForm _block = block; //Effect - Player.playEffect(Player.getLocation(), Effect.STEP_SOUND, _mat); + _player.playEffect(_player.getLocation(), Effect.STEP_SOUND, _mat); //block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, _mat); //Display @@ -144,7 +153,7 @@ public class BlockForm //Host.Manager.GetCondition().Factory().Cloak("Disguised as Block", Player, Player, 60000, false, false); //Sound - Player.playSound(Player.getLocation(), Sound.NOTE_PLING, 1f, 2f); + _player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1f, 2f); } } } @@ -152,7 +161,7 @@ public class BlockForm else { //Moved - if (!_loc.getBlock().equals(Player.getLocation().getBlock())) + if (!_loc.getBlock().equals(_player.getLocation().getBlock())) { SolidifyRemove(); } @@ -172,12 +181,12 @@ public class BlockForm _block = null; } - Player.setExp(0f); + _player.setExp(0f); //Host.Manager.GetCondition().EndCondition(Player, null, "Disguised as Block"); //Inform - Player.playSound(Player.getLocation(), Sound.NOTE_PLING, 1f, 0.5f); + _player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1f, 0.5f); FallingBlockCheck(); } @@ -189,20 +198,20 @@ public class BlockForm return; //Remove Old - if (Player.getPassenger() != null) + if (_player.getPassenger() != null) { - Recharge.Instance.useForce(Player, "PassengerChange", 100); + Recharge.Instance.useForce(_player, "PassengerChange", 100); - Player.getPassenger().remove(); - Player.eject(); + _player.getPassenger().remove(); + _player.eject(); } //Others for (Player other : UtilServer.getPlayers()) - other.sendBlockChange(Player.getLocation(), _mat, (byte)0); + other.sendBlockChange(_player.getLocation(), _mat, (byte)0); //Self - Player.sendBlockChange(Player.getLocation(), 36, (byte)0); + _player.sendBlockChange(_player.getLocation(), 36, (byte)0); FallingBlockCheck(); } @@ -214,27 +223,27 @@ public class BlockForm return; //Recreate Falling - if (Player.getPassenger() == null || !Player.getPassenger().isValid()) + if (_player.getPassenger() == null || !_player.getPassenger().isValid()) { - if (!Recharge.Instance.use(Player, "PassengerChange", 100, false, false)) + if (!Recharge.Instance.use(_player, "PassengerChange", 100, false, false)) return; //Falling Block - FallingBlock block = Player.getWorld().spawnFallingBlock(Player.getEyeLocation(), _mat, (byte)0); + FallingBlock block = _player.getWorld().spawnFallingBlock(_player.getEyeLocation(), _mat, (byte)0); //No Arrow Collision ((CraftFallingSand)block).getHandle().spectating = true; - Player.setPassenger(block); + _player.setPassenger(block); - Host.fallingBlockRegister(block); + _host.fallingBlockRegister(block); } //Ensure Falling doesnt Despawn else { - ((CraftFallingSand)Player.getPassenger()).getHandle().ticksLived = 1; - Player.getPassenger().setTicksLived(1); + ((CraftFallingSand)_player.getPassenger()).getHandle().ticksLived = 1; + _player.getPassenger().setTicksLived(1); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlock.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlock.java index e6af8ae24..774d46c4c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlock.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlock.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Player; @@ -21,6 +22,8 @@ import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.disguise.disguises.DisguiseBlock; import mineplex.core.event.StackerEvent; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetActivateEvent; +import mineplex.core.gadget.event.GadgetBlockEvent; import mineplex.core.gadget.types.MorphGadget; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonData.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonData.java index 43fa7f373..7387970a0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonData.java @@ -3,9 +3,13 @@ package mineplex.core.mount; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEnderDragon; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.entity.Chicken; import org.bukkit.entity.EnderDragon; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -24,6 +28,8 @@ public class DragonData public float Pitch = 0; public Vector Velocity = new Vector(0,0,0); + + public Entity Chicken; public DragonData(DragonMount dragonMount, Player rider) { @@ -35,15 +41,27 @@ public class DragonData Pitch = UtilAlg.GetPitch(rider.getLocation().getDirection()); Location = rider.getLocation(); + //Spawn Dragon Dragon = rider.getWorld().spawn(rider.getLocation(), EnderDragon.class); UtilEnt.Vegetate(Dragon); UtilEnt.ghost(Dragon, true, false); - rider.getWorld().playSound(rider.getLocation(), Sound.ENDERDRAGON_GROWL, 20f, 1f); + rider.getWorld().playSound(rider.getLocation(), Sound.ENDERDRAGON_GROWL, 20f, 1f); - Dragon.setPassenger(Rider); + Chicken = rider.getWorld().spawn(rider.getLocation(), Chicken.class); + Dragon.setPassenger(Chicken); + + Chicken.setPassenger(Rider); + + Bukkit.getServer().getScheduler().runTaskLater(Host.Manager.GetPlugin(), new Runnable() + { + public void run() + { + Chicken.setPassenger(Rider); + } + }, 10L); } public void Move() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonMount.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonMount.java index cfd8ac308..af1c1831e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonMount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonMount.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.disguise.disguises.DisguiseChicken; public class DragonMount extends Mount { @@ -42,6 +43,7 @@ public class DragonMount extends Mount if (data != null) { data.Dragon.remove(); + data.Chicken.remove(); //Inform UtilPlayer.message(player, F.main("Mount", "You despawned " + F.elem(GetName()) + ".")); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java index 67d89abed..19159db14 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java @@ -76,7 +76,7 @@ public class MountDragon extends DragonMount continue; } - if (!data.Dragon.isValid() || data.Dragon.getPassenger() == null) + if (!data.Dragon.isValid() || data.Dragon.getPassenger().getPassenger() == null) { data.Dragon.remove(); toRemove.add(player); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java index 34228016a..2ebe31acf 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java @@ -45,7 +45,7 @@ public class JumpManager extends MiniPlugin //Chicken Cancel DisguiseBase disguise = Manager.GetDisguise().getDisguise(player); - if (disguise != null && (disguise instanceof DisguiseChicken || disguise instanceof DisguiseBat || disguise instanceof DisguiseEnderman)) + if (disguise != null && ((disguise instanceof DisguiseChicken && !((DisguiseChicken)disguise).isBaby()) || disguise instanceof DisguiseBat || disguise instanceof DisguiseEnderman)) return; event.setCancelled(true); From 07576a2b127902223a3304bfe235e8d49d539430 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Thu, 2 Oct 2014 19:48:25 -0500 Subject: [PATCH 14/14] Add gamesplayed and timeingame to gui --- .../core/achievement/AchievementCategory.java | 6 ++--- .../ui/page/AchievementMainPage.java | 24 ++++++++++++++----- .../achievement/ui/page/AchievementPage.java | 21 +++++++++++++--- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index e46ee1c23..fe4d27b4e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -1,8 +1,6 @@ package mineplex.core.achievement; -import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; /** * Created by Shaun on 8/21/2014. @@ -11,8 +9,8 @@ import org.bukkit.inventory.ItemStack; public enum AchievementCategory { GLOBAL("Global", null, - new String[] { "GemsEarned" }, - new String[] { "Gems Earned" }, + new String[] { "GemsEarned", null, "GamesPlayed", "TimeInGame" }, + new String[] { "Gems Earned", null, "Games Played", "Time In Game" }, Material.EMERALD, 0, GameCategory.GLOBAL), //Survival diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java index b1d84ae4e..a0a739415 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java @@ -15,7 +15,9 @@ import mineplex.core.achievement.AchievementManager; import mineplex.core.achievement.ui.AchievementShop; import mineplex.core.achievement.ui.button.ArcadeButton; import mineplex.core.achievement.ui.button.CategoryButton; +import mineplex.core.common.Rank; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; @@ -55,7 +57,7 @@ public class AchievementMainPage extends ShopPageBase lore = new ArrayList(); lore.add(" "); - addStats(category, lore, 2); + addStats(category, lore, category == AchievementCategory.GLOBAL ? 5 : 2); lore.add(" "); addAchievements(category, lore, 9); lore.add(" "); @@ -88,17 +90,27 @@ public class AchievementMainPage extends ShopPageBase