From 8bf64ec55c75c62d957126c7bab17f49d6073f11 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Thu, 22 Jan 2015 22:17:19 -0500 Subject: [PATCH 01/27] Database and code implementation of enemies --- .../mineplex/game/clans/clans/ClanInfo.java | 18 ++++++- .../clans/clans/ClansDataAccessLayer.java | 15 ++++++ .../game/clans/clans/ClansManager.java | 1 + .../mineplex/game/clans/clans/EnemyData.java | 37 ++++++++++++++ .../clans/repository/ClanRepository.java | 48 +++++++++++++++++++ .../repository/tokens/ClanEnemyToken.java | 9 ++++ .../clans/repository/tokens/ClanToken.java | 2 + 7 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanEnemyToken.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java index 83e159ff4..4e9a64df4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java @@ -13,6 +13,7 @@ import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken; +import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken; import mineplex.game.clans.clans.repository.tokens.ClanMemberToken; import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken; import mineplex.game.clans.clans.repository.tokens.ClanToken; @@ -51,11 +52,11 @@ public class ClanInfo private long _dateCreated = 0; private long _lastOnline = 0; - private NautHashMap _allyMap = new NautHashMap(); - // Loaded from Client private NautHashMap _memberMap = new NautHashMap(); + private NautHashMap _allyMap = new NautHashMap(); private HashSet _claimSet = new HashSet(); + private EnemyData _enemyData; // Temporary private NautHashMap _inviteeMap = new NautHashMap(); @@ -102,6 +103,9 @@ public class ClanInfo { _allyMap.put(allianceToken.ClanName, allianceToken.Trusted); } + + ClanEnemyToken enemyToken = token.EnemyToken; + _enemyData = new EnemyData(enemyToken.EnemyName, enemyToken.Initiator, enemyToken.Score, enemyToken.Kills); } public int getClaims() @@ -408,6 +412,16 @@ public class ClanInfo { return _energy; } + + public EnemyData getEnemyData() + { + return _enemyData; + } + + public boolean hasEnemy() + { + return _enemyData != null; + } public void adjustEnergy(int energy) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java index 6c5b37313..3d914a475 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java @@ -271,6 +271,21 @@ public class ClansDataAccessLayer //Log _manager.log("Set Home for [" + clan.getName() + "] to " + UtilWorld.locToStrClean(loc) + " by [" + player + "]."); } + + public void updateEnemy(ClanInfo clan, ClanInfo otherClan) + { + assert clan.getEnemyData() != null && otherClan.getEnemyData() != null; + assert clan.getEnemyData().getEnemyName() == otherClan.getName() && otherClan.getEnemyData().getEnemyName() == clan.getName(); + + ClanInfo initiator = clan.getEnemyData().isInitiator() ? clan : otherClan; + EnemyData iData = initiator.getEnemyData(); + ClanInfo other = clan == initiator ? otherClan : clan; + EnemyData oData = other.getEnemyData(); + _repository.updateEnemy(initiator.getId(), other.getId(), iData.getScore(), oData.getScore(), iData.getKills(), oData.getKills()); + + //Log + _manager.log("Updated Enemy Data for [" + clan.getName() + ", " + otherClan.getName() + "]"); + } public void updateEnergy(ClanInfo clan) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 4c07c40f3..082b5c910 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -35,6 +35,7 @@ import mineplex.game.clans.clans.commands.ClansAllyChatCommand; import mineplex.game.clans.clans.commands.ClansChatCommand; import mineplex.game.clans.clans.commands.ClansCommand; import mineplex.game.clans.clans.repository.ClanTerritory; +import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken; import mineplex.game.clans.clans.repository.tokens.ClanMemberToken; import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken; import mineplex.game.clans.clans.repository.tokens.ClanToken; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java new file mode 100644 index 000000000..09458a3a0 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java @@ -0,0 +1,37 @@ +package mineplex.game.clans.clans; + +public class EnemyData +{ + private String _enemy; + private boolean _initiator; + private int _score; + private int _kills; + + public EnemyData(String enemy, boolean initiator, int score, int kills) + { + _enemy = enemy; + _initiator = initiator; + _score = score; + _kills = kills; + } + + public String getEnemyName() + { + return _enemy; + } + + public int getScore() + { + return _score; + } + + public int getKills() + { + return _kills; + } + + public boolean isInitiator() + { + return _initiator; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/ClanRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/ClanRepository.java index 53f71597c..18e01fe56 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/ClanRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/ClanRepository.java @@ -15,6 +15,7 @@ import mineplex.core.database.column.ColumnLong; import mineplex.core.database.column.ColumnVarChar; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken; +import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken; import mineplex.game.clans.clans.repository.tokens.ClanMemberToken; import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken; import mineplex.game.clans.clans.repository.tokens.ClanToken; @@ -29,6 +30,7 @@ public class ClanRepository extends RepositoryBase private static String RETRIEVE_START_CLAN_INFO = "SELECT c.id, c.name, c.description, c.home, c.admin, c.energy, c.dateCreated, c.lastOnline, ct.chunk, ct.safe FROM clans AS c LEFT JOIN clanTerritory AS ct ON ct.clanId = c.id WHERE c.serverName = ?;"; private static String RETRIEVE_CLAN_MEMBER_INFO = "SELECT c.name, a.name, clanRole FROM accountClan AS ac INNER JOIN accounts AS a ON a.id = ac.accountId INNER JOIN clans AS c on c.id = ac.clanId WHERE c.serverName = ?;"; private static String RETRIEVE_CLAN_ALLIANCE_INFO = "SELECT c.name, cOther.name, ca.trusted FROM clanAlliances AS ca INNER JOIN clans AS c ON c.id = ca.clanId INNER JOIN clans as cOther ON cOther.id = ca.otherClanId WHERE c.serverName = ?;"; + private static String RETRIEVE_CLAN_ENEMY_INFO = "SELECT c.name, cOther.name, clanScore, otherClanScore, clanKills, otherClanKills FROM clanEnemies AS ce INNER JOIN clans AS c ON c.id = ce.clanId INNER JOIN clans as cOther ON cOther.id = ce.otherClanId WHERE c.serverName = ?;"; private static String DELETE_CLAN_MEMBER = "DELETE aC FROM accountClan AS aC INNER JOIN accounts ON accounts.id = aC.accountId WHERE aC.clanId = ? AND accounts.name = ?;"; private static String DELETE_CLAN_MEMBERS = "DELETE FROM accountClan WHERE clanId = ?;"; @@ -36,16 +38,19 @@ public class ClanRepository extends RepositoryBase private static String DELETE_CLAN_TERRITORIES = "DELETE FROM clanTerritory WHERE clanId = ?;"; private static String DELETE_CLAN_ALLIANCE = "DELETE FROM clanAlliances WHERE clanId = ? AND otherClanId = ?;"; private static String DELETE_CLAN_ALLIANCES = "DELETE FROM clanAlliances WHERE clanId = ? OR otherClanId = ?;"; + private static String DELETE_CLAN_ENEMY = "DELETE FROM clanEnemies WHERE clanId = ? OR otherClanId = ?;"; private static String DELETE_CLAN = "DELETE FROM clans WHERE id = ?;"; private static String ADD_CLAN = "INSERT INTO clans (serverName, name, description, home, admin, dateCreated, energy, lastOnline) VALUES (?, ?, ?, ?, ?, now(), ?, now());"; private static String ADD_CLAN_MEMBER = "INSERT INTO accountClan (accountId, clanId, clanRole) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.name = ?;"; private static String ADD_CLAN_ALLIANCE = "INSERT INTO clanAlliances (clanId, otherClanId, trusted) VALUES (?, ?, ?);"; + private static String ADD_CLAN_ENEMY = "INSERT INTO clanEnemies (clanId, otherClanId, timeFormed) VALUES (?, ?, now());"; private static String ADD_CLAN_TERRITORY = "INSERT INTO clanTerritory (clanId, serverName, chunk, safe) VALUES (?, ?, ?, ?);"; private static String UPDATE_CLAN = "UPDATE clans SET name = ?, description = ?, home = ?, admin = ?, energy = ?, lastOnline = ? WHERE id = ?;"; private static String UPDATE_CLAN_MEMBER = "UPDATE accountClan AS AC INNER JOIN accounts ON accounts.id = AC.accountId SET AC.clanRole = ? WHERE AC.clanId = ? AND accounts.name = ?;"; private static String UPDATE_CLAN_ALLIANCE = "UPDATE clanAlliances SET trusted = ? WHERE clanId = ? AND otherClanId = ?;"; + private static String UPDATE_CLAN_ENEMY = "UPDATE clanEnemies SET clanScore = ?, otherClanScore = ?, clanKills = ?, otherClanKills = ? WHERE clanId = ? AND otherClanId = ?;"; private static String UPDATE_CLAN_TERRITORY = "UPDATE clanTerritory SET safe = ? WHERE serverName = ? AND chunk = ?;"; private String _serverName; @@ -147,6 +152,41 @@ public class ClanRepository extends RepositoryBase } }, new ColumnVarChar("serverName", 100, _serverName)); + + executeQuery(RETRIEVE_CLAN_ENEMY_INFO, new ResultSetCallable() + { + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + while (resultSet.next()) + { + ClanEnemyToken clanToken = new ClanEnemyToken(); + ClanEnemyToken otherClanToken = new ClanEnemyToken(); + + //c.name, cOther.name, clanScore, otherClanScore, clanKills, otherClanKills + String clanName = resultSet.getString(1); + String otherClanName = resultSet.getString(2); + int clanScore = resultSet.getInt(3); + int otherClanScore = resultSet.getInt(4); + int clanKills = resultSet.getInt(5); + int otherClanKills = resultSet.getInt(6); + + clanToken.EnemyName = otherClanName; + clanToken.Score = clanScore; + clanToken.Kills = clanKills; + clanToken.Initiator = true; + + otherClanToken.EnemyName = clanName; + otherClanToken.Score = otherClanScore; + otherClanToken.Kills = otherClanKills; + otherClanToken.Initiator = false; + + clans.get(clanName).EnemyToken = clanToken; + clans.get(otherClanName).EnemyToken = otherClanToken; + } + } + + }, new ColumnVarChar("serverName", 100, _serverName)); return clans.values(); } @@ -161,6 +201,7 @@ public class ClanRepository extends RepositoryBase executeUpdate(DELETE_CLAN_MEMBERS, new ColumnInt("clanid", clanId)); executeUpdate(DELETE_CLAN_TERRITORIES, new ColumnInt("clanid", clanId)); executeUpdate(DELETE_CLAN_ALLIANCES, new ColumnInt("clanid", clanId), new ColumnInt("clanid", clanId)); + executeUpdate(DELETE_CLAN_ENEMY, new ColumnInt("clanid", clanId)); executeUpdate(DELETE_CLAN, new ColumnInt("clanid", clanId)); } @@ -226,6 +267,13 @@ public class ClanRepository extends RepositoryBase executeUpdate(UPDATE_CLAN, new ColumnVarChar("name", 100, name), new ColumnVarChar("desc", 100, desc), new ColumnVarChar("home", 100, home), new ColumnBoolean("admin", admin), new ColumnInt("energy", energy), new ColumnLong("lastOnline", lastOnline), new ColumnInt("clanId", clanId)); } + public void updateEnemy(int clanId, int otherClanId, int clanScore, int otherClanScore, int clanKills, int otherClanKills) + { + executeUpdate(UPDATE_CLAN_ENEMY, new ColumnInt("clanId", clanId), new ColumnInt("otherClanId", otherClanId), + new ColumnInt("clanScore", clanScore), new ColumnInt("otherClanScore", otherClanScore), new ColumnInt("clanKills", clanKills), + new ColumnInt("otherClanKills", otherClanKills), new ColumnInt("clanId", clanId), new ColumnInt("otherClanId", otherClanId)); + } + public void updateTerritoryClaim(String chunk, boolean safe) { executeUpdate(UPDATE_CLAN_TERRITORY, new ColumnBoolean("safe", safe), new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("chunk", 100, chunk)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanEnemyToken.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanEnemyToken.java new file mode 100644 index 000000000..393c2ac24 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanEnemyToken.java @@ -0,0 +1,9 @@ +package mineplex.game.clans.clans.repository.tokens; + +public class ClanEnemyToken +{ + public boolean Initiator; + public String EnemyName; + public int Score; + public int Kills; +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanToken.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanToken.java index 511fc7041..0cc1a7f8e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanToken.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanToken.java @@ -13,6 +13,8 @@ public class ClanToken public int Energy; public long DateCreated; public long LastOnline; + + public ClanEnemyToken EnemyToken; public List Members = new ArrayList(); public List Territories = new ArrayList(); From e91d76960c291c9994d3b81bad700de4635f4cd7 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Tue, 3 Feb 2015 22:03:07 +1300 Subject: [PATCH 02/27] Add a toggleable friends GUI - Chat to Inventory and back --- .../mineplex/core/friend/FriendManager.java | 23 ++++++++--- .../core/friend/command/AddFriend.java | 9 ++++- .../core/friend/command/FriendsDisplay.java | 39 +++++++++++++++++++ .../mineplex/core/friend/ui/FriendPage.java | 6 ++- .../mineplex/core/friend/ui/FriendsGUI.java | 10 ++++- .../core/preferences/PreferencesManager.java | 2 +- .../preferences/PreferencesRepository.java | 11 ++++-- .../core/preferences/UserPreferences.java | 1 + 8 files changed, 88 insertions(+), 13 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java index 578719c4f..b3b9eef40 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java @@ -25,6 +25,7 @@ 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.command.FriendsDisplay; import mineplex.core.friend.data.FriendData; import mineplex.core.friend.data.FriendRepository; import mineplex.core.friend.data.FriendStatus; @@ -49,7 +50,12 @@ public class FriendManager extends MiniDbClientPlugin _repository = new FriendRepository(plugin); _portal = portal; } - + + public PreferencesManager getPreferenceManager() + { + return _preferenceManager; + } + public Portal getPortal() { return _portal; @@ -60,6 +66,7 @@ public class FriendManager extends MiniDbClientPlugin { addCommand(new AddFriend(this)); addCommand(new DeleteFriend(this)); + addCommand(new FriendsDisplay(this)); } @Override @@ -107,8 +114,7 @@ public class FriendManager extends MiniDbClientPlugin { if (caller.getName().equalsIgnoreCase(name)) { - caller.sendMessage(F.main(getName(), ChatColor.GRAY - + "You cannot add yourself as a friend")); + caller.sendMessage(F.main(getName(), ChatColor.GRAY + "You cannot add yourself as a friend")); return; } @@ -243,7 +249,6 @@ public class FriendManager extends MiniDbClientPlugin }); } - @Deprecated public void showFriends(Player caller) { boolean isStaff = ClientManager.Get(caller).GetRank().Has(Rank.HELPER); @@ -369,7 +374,15 @@ public class FriendManager extends MiniDbClientPlugin caller.sendMessage(" "); } - caller.sendMessage(C.cAqua + C.Strike + "====================================================="); + ChildJsonMessage message = new JsonMessage("").extra(C.cAqua + C.Strike + "======================"); + + message.add(C.cDAqua + "Toggle GUI").click("run_command", "/friendsdisplay"); + + message.hover("show_text", C.cAqua + "Toggle friends to display in a inventory"); + + message.add(C.cAqua + C.Strike + "======================"); + + message.sendToPlayer(caller); } @Override 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 bb6f3aa47..706600eb6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java @@ -20,7 +20,14 @@ public class AddFriend extends CommandBase { if (args == null) { - new FriendsGUI(Plugin, caller); + if (Plugin.getPreferenceManager().Get(caller).friendDisplayInventoryUI) + { + new FriendsGUI(Plugin, caller); + } + else + { + Plugin.showFriends(caller); + } } else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java new file mode 100644 index 000000000..6109041f6 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java @@ -0,0 +1,39 @@ +package mineplex.core.friend.command; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.friend.FriendManager; +import mineplex.core.friend.ui.FriendsGUI; +import mineplex.core.preferences.UserPreferences; + +public class FriendsDisplay extends CommandBase +{ + public FriendsDisplay(FriendManager plugin) + { + super(plugin, Rank.ALL, "friendsdisplay"); + } + + @Override + public void Execute(Player caller, final String[] args) + { + UserPreferences preferences = Plugin.getPreferenceManager().Get(caller); + + preferences.friendDisplayInventoryUI = !preferences.friendDisplayInventoryUI; + + Plugin.getPreferenceManager().savePreferences(caller); + + caller.playSound(caller.getLocation(), Sound.NOTE_PLING, 1, 1.6f); + + if (preferences.friendDisplayInventoryUI) + { + new FriendsGUI(Plugin, caller); + } + else + { + Plugin.showFriends(caller); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendPage.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendPage.java index e10169e3c..ada0b2688 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendPage.java @@ -1,5 +1,6 @@ package mineplex.core.friend.ui; +import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import org.bukkit.Material; @@ -13,7 +14,10 @@ public enum FriendPage DELETE_FRIENDS(new ItemBuilder(Material.TNT).setTitle("Delete Friends").build(), "Delete Friends"), - SEND_REQUEST(new ItemBuilder(Material.BOOK_AND_QUILL).setTitle("Send Friend Request").build(), "Send Friend Request"); + SEND_REQUEST(new ItemBuilder(Material.BOOK_AND_QUILL).setTitle("Send Friend Request").build(), "Send Friend Request"), + + TOGGLE_DISPLAY(new ItemBuilder(Material.SIGN).setTitle(C.cGray + "Toggle friends to display in chat").build(), + "Toggle Display"); private ItemStack _icon; private String _name; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java index a5c103a5a..e5d53a560 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java @@ -320,7 +320,7 @@ public class FriendsGUI implements Listener _page = 0; _buttonMap.clear(); - ArrayList itemSlots = new ItemLayout("XOXOXOXOX").getItemSlots(); + ArrayList itemSlots = new ItemLayout("OXOXOXOXO").getItemSlots(); for (int i = 0; i < FriendPage.values().length; i++) { @@ -370,6 +370,14 @@ public class FriendsGUI implements Listener return; } + else if (_currentPage == FriendPage.TOGGLE_DISPLAY) + { + _player.closeInventory(); + + CommandCenter.Instance.OnPlayerCommandPreprocess(new PlayerCommandPreprocessEvent(_player, "/friendsdisplay")); + + return; + } if (_previousPage != _currentPage) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java index 309cf6d79..9bbb15bca 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java @@ -130,6 +130,6 @@ public class PreferencesManager extends MiniDbClientPlugin @Override public String getQuery(String uuid, String name) { - return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;"; + return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;"; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java index 332f9b2db..9b3678016 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java @@ -15,7 +15,7 @@ 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, 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 UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ? WHERE uuid=?;"; + private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ?, friendDisplayInventoryUI = ? WHERE uuid=?;"; public PreferencesRepository(JavaPlugin plugin, String connectionString) { @@ -53,8 +53,9 @@ public class PreferencesRepository extends RepositoryBase preparedStatement.setBoolean(8, entry.getValue().HubForcefield); preparedStatement.setBoolean(9, entry.getValue().ShowMacReports); preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity); - preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests); - preparedStatement.setString(12, entry.getKey()); + preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests); + preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI); + preparedStatement.setString(13, entry.getKey()); preparedStatement.addBatch(); } @@ -79,7 +80,8 @@ public class PreferencesRepository extends RepositoryBase preparedStatement.setBoolean(9, entry.getValue().ShowMacReports); preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity); preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests); - preparedStatement.setString(12, entry.getKey()); + preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI); + preparedStatement.setString(13, entry.getKey()); preparedStatement.execute(); } @@ -123,6 +125,7 @@ public class PreferencesRepository extends RepositoryBase preferences.ShowMacReports = resultSet.getBoolean(9); preferences.IgnoreVelocity = resultSet.getBoolean(10); preferences.PendingFriendRequests = resultSet.getBoolean(11); + preferences.friendDisplayInventoryUI = resultSet.getBoolean(12); } return preferences; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java index 45700ccf1..e52e7d249 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java @@ -14,4 +14,5 @@ public class UserPreferences public boolean ShowMacReports = false; public boolean IgnoreVelocity = false; public boolean PendingFriendRequests = true; + public boolean friendDisplayInventoryUI = true; } From 6cefeb1b7490643b25ba8ca7ef33b385770718f6 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 3 Feb 2015 14:02:45 -0500 Subject: [PATCH 03/27] More work on War --- .../mineplex/game/clans/clans/ClanInfo.java | 41 ++++++++-- .../clans/clans/ClansDataAccessLayer.java | 23 ++++++ .../game/clans/clans/ClansManager.java | 11 ++- .../mineplex/game/clans/clans/EnemyData.java | 20 ++++- .../clans/clans/commands/ClansCommand.java | 43 +++++++++- .../clans/repository/ClanRepository.java | 11 ++- .../repository/tokens/ClanEnemyToken.java | 3 + .../game/clans/clans/war/WarManager.java | 82 +++++++++++++++++++ .../arcade/managers/GameLobbyManager.java | 43 ++++++++-- 9 files changed, 257 insertions(+), 20 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java index 4e9a64df4..5094143d5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java @@ -3,14 +3,18 @@ package mineplex.game.clans.clans; import java.util.HashSet; import java.util.LinkedList; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.common.util.UtilWorld; import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken; import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken; @@ -18,10 +22,6 @@ import mineplex.game.clans.clans.repository.tokens.ClanMemberToken; import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken; import mineplex.game.clans.clans.repository.tokens.ClanToken; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.entity.Player; - public class ClanInfo { public enum Role @@ -104,8 +104,15 @@ public class ClanInfo _allyMap.put(allianceToken.ClanName, allianceToken.Trusted); } - ClanEnemyToken enemyToken = token.EnemyToken; - _enemyData = new EnemyData(enemyToken.EnemyName, enemyToken.Initiator, enemyToken.Score, enemyToken.Kills); + updateEnemy(token.EnemyToken); + } + + public void updateEnemy(ClanEnemyToken enemyToken) + { + if (enemyToken != null) + { + _enemyData = new EnemyData(enemyToken.EnemyName, enemyToken.Initiator, enemyToken.Score, enemyToken.Kills, enemyToken.TimeFormed); + } } public int getClaims() @@ -249,6 +256,26 @@ public class ClanInfo return stringList; } + public LinkedList mEnemy() + { + LinkedList stringList = new LinkedList(); + + if (_enemyData == null) + { + stringList.add(F.main("Clans", "You do not have an enemy!")); + } + else + { + String enemyName = _enemyData.getEnemyName(); + EnemyData otherEnemyData = Clans.getClanUtility().getClanByClanName(enemyName).getEnemyData(); + stringList.add(F.value("Enemy", _enemyData.getEnemyName())); + stringList.add(F.value("Formed", _enemyData.getRelativeTimeFormed())); + stringList.add(F.value("War Score", _enemyData.getScore() + " : " + otherEnemyData.getScore())); + } + + return stringList; + } + public LinkedList mTerritory() { LinkedList stringList = new LinkedList(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java index 3d914a475..4a1a3080d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java @@ -1,5 +1,7 @@ package mineplex.game.clans.clans; +import java.util.Date; + import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.block.Block; @@ -10,6 +12,7 @@ import mineplex.core.common.util.UtilWorld; import mineplex.game.clans.clans.ClanInfo.Role; import mineplex.game.clans.clans.repository.ClanRepository; import mineplex.game.clans.clans.repository.ClanTerritory; +import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken; import mineplex.game.clans.clans.repository.tokens.ClanToken; public class ClansDataAccessLayer @@ -152,6 +155,26 @@ public class ClansDataAccessLayer _manager.log("Added Ally for [" + cB.getName() + "] and [" + cA.getName() + "] by [" + player + "]."); } + public void enemy(ClanInfo clan, ClanInfo otherClan, String player) + { + _repository.addEnemy(clan.getId(), otherClan.getId()); + Date currDate = new Date(); + + ClanEnemyToken clanEnemyToken = new ClanEnemyToken(); + clanEnemyToken.Initiator = true; + clanEnemyToken.TimeFormed = currDate; + clanEnemyToken.EnemyName = otherClan.getName(); + clan.updateEnemy(clanEnemyToken); + + ClanEnemyToken otherClanEnemyToken = new ClanEnemyToken(); + otherClanEnemyToken.Initiator = false; + otherClanEnemyToken.TimeFormed = currDate; + otherClanEnemyToken.EnemyName = clan.getName(); + otherClan.updateEnemy(otherClanEnemyToken); + + _manager.log("Added Enemy for [" + clan.getName() + "] and [" + otherClan.getName() + "] by [" + player + "]."); + } + public boolean trust(ClanInfo ownerClan, ClanInfo otherClan, String player) { if (!ownerClan.getAllyMap().containsKey(otherClan.getName())) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 082b5c910..27021f539 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -2,7 +2,6 @@ package mineplex.game.clans.clans; import java.util.HashSet; -import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -35,10 +34,10 @@ import mineplex.game.clans.clans.commands.ClansAllyChatCommand; import mineplex.game.clans.clans.commands.ClansChatCommand; import mineplex.game.clans.clans.commands.ClansCommand; import mineplex.game.clans.clans.repository.ClanTerritory; -import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken; import mineplex.game.clans.clans.repository.tokens.ClanMemberToken; import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken; import mineplex.game.clans.clans.repository.tokens.ClanToken; +import mineplex.game.clans.clans.war.WarManager; import mineplex.game.clans.fields.Field; import mineplex.game.clans.gameplay.Gameplay; import mineplex.minecraft.game.classcombat.Class.ClassManager; @@ -72,6 +71,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat private ConditionManager _condition; private ClassCombatShop _classShop; private ClassManager _classManager; + private WarManager _warManager; private int _inviteExpire = 2; private int _nameMin = 3; @@ -135,6 +135,8 @@ public class ClansManager extends MiniClientPlugin implements IRelat AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, donationManager); ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager); _classShop = new ClassCombatShop(shopManager, _clientManager, donationManager, true, "Class Shop"); + + _warManager = new WarManager(plugin, this); for (ClanToken token : _clanDataAccess.getRepository().retrieveClans()) { @@ -467,4 +469,9 @@ public class ClansManager extends MiniClientPlugin implements IRelat { return _classShop; } + + public WarManager getWarManager() + { + return _warManager; + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java index 09458a3a0..68b116776 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java @@ -1,18 +1,24 @@ package mineplex.game.clans.clans; +import java.util.Date; + +import mineplex.core.common.util.UtilTime; + public class EnemyData { private String _enemy; private boolean _initiator; private int _score; private int _kills; + private Date _timeFormed; - public EnemyData(String enemy, boolean initiator, int score, int kills) + public EnemyData(String enemy, boolean initiator, int score, int kills, Date timeFormed) { _enemy = enemy; _initiator = initiator; _score = score; _kills = kills; + _timeFormed = timeFormed; } public String getEnemyName() @@ -34,4 +40,16 @@ public class EnemyData { return _initiator; } + + public Date getTimeFormed() + { + return _timeFormed; + } + + public String getRelativeTimeFormed() + { + long timeFormed = _timeFormed.getTime(); + long currentTime = System.currentTimeMillis(); + return UtilTime.convertString(System.currentTimeMillis() - timeFormed, 1, UtilTime.TimeUnit.FIT); + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 0037dca03..f3366ad9e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -14,8 +14,8 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.common.util.UtilWorld; import mineplex.core.recharge.Recharge; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClanInfo.Role; @@ -97,6 +97,9 @@ public class ClansCommand extends CommandBase else if (args[0].equalsIgnoreCase("sethome")) homeSet(caller); + else if (args[0].equalsIgnoreCase("enemy") || args[0].equals("e")) + enemy(caller, args); + else if (args[0].equalsIgnoreCase("territory") || args[0].equalsIgnoreCase("t")) infoTerritory(caller, args); @@ -110,6 +113,44 @@ public class ClansCommand extends CommandBase infoClan(caller, args[0]); } + public void enemy(Player caller, String[] args) + { + if (args.length == 2) + { + ClanInfo playerClan = Plugin.getClanUtility().getClanByPlayer(caller); + ClanInfo otherClan = Plugin.getClanUtility().getClanByClanName(args[1]); + + if (playerClan == null) + { + UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); + return; + } + else if (otherClan == null) + { + UtilPlayer.message(caller, F.main("Clans", "Could not find a clan with the name " + F.elem(args[1]))); + return; + } + + attemptEnemy(caller, playerClan, otherClan); + } + else + { + infoEnemy(caller); + } + } + + private void attemptEnemy(Player caller, ClanInfo initiatorClan, ClanInfo otherClan) + { + Plugin.getWarManager().attemptEnemy(caller, initiatorClan, otherClan); + } + + private void infoEnemy(Player caller) + { + ClanInfo playerClan = Plugin.getClanUtility().getClanByPlayer(caller); + + UtilPlayer.message(caller, playerClan.mEnemy()); + } + public void commandChat(Player caller, String[] args) { if (args.length == 0) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/ClanRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/ClanRepository.java index 18e01fe56..10cb049a5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/ClanRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/ClanRepository.java @@ -3,6 +3,7 @@ package mineplex.game.clans.clans.repository; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Collection; +import java.util.Date; import org.bukkit.plugin.java.JavaPlugin; @@ -30,7 +31,7 @@ public class ClanRepository extends RepositoryBase private static String RETRIEVE_START_CLAN_INFO = "SELECT c.id, c.name, c.description, c.home, c.admin, c.energy, c.dateCreated, c.lastOnline, ct.chunk, ct.safe FROM clans AS c LEFT JOIN clanTerritory AS ct ON ct.clanId = c.id WHERE c.serverName = ?;"; private static String RETRIEVE_CLAN_MEMBER_INFO = "SELECT c.name, a.name, clanRole FROM accountClan AS ac INNER JOIN accounts AS a ON a.id = ac.accountId INNER JOIN clans AS c on c.id = ac.clanId WHERE c.serverName = ?;"; private static String RETRIEVE_CLAN_ALLIANCE_INFO = "SELECT c.name, cOther.name, ca.trusted FROM clanAlliances AS ca INNER JOIN clans AS c ON c.id = ca.clanId INNER JOIN clans as cOther ON cOther.id = ca.otherClanId WHERE c.serverName = ?;"; - private static String RETRIEVE_CLAN_ENEMY_INFO = "SELECT c.name, cOther.name, clanScore, otherClanScore, clanKills, otherClanKills FROM clanEnemies AS ce INNER JOIN clans AS c ON c.id = ce.clanId INNER JOIN clans as cOther ON cOther.id = ce.otherClanId WHERE c.serverName = ?;"; + private static String RETRIEVE_CLAN_ENEMY_INFO = "SELECT c.name, cOther.name, clanScore, otherClanScore, clanKills, otherClanKills, timeFormed FROM clanEnemies AS ce INNER JOIN clans AS c ON c.id = ce.clanId INNER JOIN clans as cOther ON cOther.id = ce.otherClanId WHERE c.serverName = ?;"; private static String DELETE_CLAN_MEMBER = "DELETE aC FROM accountClan AS aC INNER JOIN accounts ON accounts.id = aC.accountId WHERE aC.clanId = ? AND accounts.name = ?;"; private static String DELETE_CLAN_MEMBERS = "DELETE FROM accountClan WHERE clanId = ?;"; @@ -170,16 +171,19 @@ public class ClanRepository extends RepositoryBase int otherClanScore = resultSet.getInt(4); int clanKills = resultSet.getInt(5); int otherClanKills = resultSet.getInt(6); + Date timeFormed = resultSet.getTimestamp(7); clanToken.EnemyName = otherClanName; clanToken.Score = clanScore; clanToken.Kills = clanKills; clanToken.Initiator = true; + clanToken.TimeFormed = timeFormed; otherClanToken.EnemyName = clanName; otherClanToken.Score = otherClanScore; otherClanToken.Kills = otherClanKills; otherClanToken.Initiator = false; + otherClanToken.TimeFormed = timeFormed; clans.get(clanName).EnemyToken = clanToken; clans.get(otherClanName).EnemyToken = otherClanToken; @@ -257,6 +261,11 @@ public class ClanRepository extends RepositoryBase executeUpdate(ADD_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("chunk", 100, chunk), new ColumnBoolean("safe", safe)); } + public void addEnemy(int clanId, int otherClanId) + { + executeUpdate(ADD_CLAN_ENEMY, new ColumnInt("clanId", clanId), new ColumnInt("otherClanId", otherClanId)); + } + public void removeTerritoryClaim(int clanId, String chunk) { executeUpdate(DELETE_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("chunk", 100, chunk)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanEnemyToken.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanEnemyToken.java index 393c2ac24..13389612e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanEnemyToken.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanEnemyToken.java @@ -1,9 +1,12 @@ package mineplex.game.clans.clans.repository.tokens; +import java.util.Date; + public class ClanEnemyToken { public boolean Initiator; public String EnemyName; public int Score; public int Kills; + public Date TimeFormed; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java new file mode 100644 index 000000000..f4b0a04e2 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java @@ -0,0 +1,82 @@ +package mineplex.game.clans.clans.war; + +import java.util.Calendar; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansManager; + +public class WarManager extends MiniPlugin +{ + private final ClansManager _clansManager; + + public WarManager(JavaPlugin plugin, ClansManager clansManager) + { + super("War Manager", plugin); + _clansManager = clansManager; + + + } + + public void attemptEnemy(Player player, ClanInfo initiatingClan, ClanInfo otherClan) + { + attemptEnemy(player, initiatingClan, otherClan, true); + } + + public void attemptEnemy(Player player, ClanInfo initiatingClan, ClanInfo otherClan, boolean notify) + { + String notifyMessage = ""; + + if (isEnemyTime()) + { + notifyMessage = "Enemies cannot be formed at this time. Please see mineplex.com/clans for info"; + } + else if (initiatingClan.getEnemyData() != null) + { + notifyMessage = "Your clan already has an enemy."; + } + else if (otherClan.getEnemyData() != null) + { + notifyMessage = "The clan " + F.elem(otherClan.getName()) + " already has an enemy."; + } + else + { + _clansManager.getClanDataAccess().enemy(initiatingClan, otherClan, player.getName()); + _clansManager.chatClan(); + } + + if (notify) + UtilPlayer.message(player, F.main("Clans", notifyMessage)); + } + + @EventHandler + public void handleDeath(PlayerDeathEvent event) + { + // TODO handle war deaths + } + + + /** + * Can enemies be formed at the current time? + */ + private boolean isEnemyTime() + { + Calendar c = Calendar.getInstance(); + int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); + + if (dayOfWeek == Calendar.SUNDAY) + { + return true; + } + + return false; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java index 04f82d8c7..9b1028065 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java @@ -11,13 +11,14 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.DyeColor; -import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect.Type; +import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.Creature; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -31,11 +32,15 @@ import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Scoreboard; +import net.minecraft.server.v1_7_R4.Packet; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata; +import net.minecraft.server.v1_7_R4.WatchableObject; import mineplex.core.account.CoreClient; import mineplex.core.common.Rank; @@ -43,13 +48,13 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilBlockText; +import mineplex.core.common.util.UtilBlockText.TextAlign; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilBlockText; -import mineplex.core.common.util.UtilBlockText.TextAlign; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; import mineplex.core.cosmetic.event.ActivateGemBoosterEvent; @@ -57,8 +62,8 @@ import mineplex.core.donation.Donor; import mineplex.core.event.CustomTagEvent; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler; -import mineplex.core.packethandler.PacketVerifier; import mineplex.core.packethandler.PacketInfo; +import mineplex.core.packethandler.PacketVerifier; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -71,10 +76,6 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.KitSorter; -import net.minecraft.server.v1_7_R4.Packet; -import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata; -import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving; -import net.minecraft.server.v1_7_R4.WatchableObject; public class GameLobbyManager implements Listener, IPacketHandler { @@ -1301,4 +1302,30 @@ public class GameLobbyManager implements Listener, IPacketHandler event.setCancelled(true); } + + /** + * DEBUG + */ + @EventHandler + public void command(PlayerCommandPreprocessEvent event) + { + Player player = event.getPlayer(); + if (event.getMessage().startsWith("/enable")) + { + player.setGameMode(GameMode.CREATIVE); + player.setFlying(true); + player.setFlySpeed(0.1f); + ((CraftPlayer) player).getHandle().spectating = true; + ((CraftPlayer) player).getHandle().k = false; + } + else if (event.getMessage().startsWith("/disable")) + { + player.setGameMode(GameMode.SURVIVAL); + player.setFlying(false); + player.setFlySpeed(0.1f); + ((CraftPlayer) player).getHandle().spectating = false; + ((CraftPlayer) player).getHandle().k = true; + } + } + } From b0a2e655c12e49652b9cea82b152dbbee6c302e5 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 3 Feb 2015 14:12:52 -0500 Subject: [PATCH 04/27] Changes to IntellIJ Files --- .../Mineplex.Bungee.Mineplexer.iml | 5 +++-- Plugins/Mineplex.Game.Clans/Mineplex.Game.Clans.iml | 1 + Plugins/Mineplex.Hub/Mineplex.Hub.iml | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Bungee.Mineplexer/Mineplex.Bungee.Mineplexer.iml b/Plugins/Mineplex.Bungee.Mineplexer/Mineplex.Bungee.Mineplexer.iml index 75e50cc46..81ce3df96 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/Mineplex.Bungee.Mineplexer.iml +++ b/Plugins/Mineplex.Bungee.Mineplexer/Mineplex.Bungee.Mineplexer.iml @@ -11,6 +11,7 @@ + + - - + \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/Mineplex.Game.Clans.iml b/Plugins/Mineplex.Game.Clans/Mineplex.Game.Clans.iml index b896f358d..9f3f37b52 100644 --- a/Plugins/Mineplex.Game.Clans/Mineplex.Game.Clans.iml +++ b/Plugins/Mineplex.Game.Clans/Mineplex.Game.Clans.iml @@ -11,6 +11,7 @@ + \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/Mineplex.Hub.iml b/Plugins/Mineplex.Hub/Mineplex.Hub.iml index d609cb37f..5c4477b27 100644 --- a/Plugins/Mineplex.Hub/Mineplex.Hub.iml +++ b/Plugins/Mineplex.Hub/Mineplex.Hub.iml @@ -12,6 +12,7 @@ + @@ -19,5 +20,6 @@ + \ No newline at end of file From 3b324448b5d76191667e9b12a541435741149f0c Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 3 Feb 2015 14:19:22 -0500 Subject: [PATCH 05/27] Fix errors in war manager --- .../src/mineplex/game/clans/clans/war/WarManager.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java index f4b0a04e2..eb728d6bd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java @@ -32,7 +32,7 @@ public class WarManager extends MiniPlugin public void attemptEnemy(Player player, ClanInfo initiatingClan, ClanInfo otherClan, boolean notify) { - String notifyMessage = ""; + String notifyMessage = null; if (isEnemyTime()) { @@ -49,10 +49,11 @@ public class WarManager extends MiniPlugin else { _clansManager.getClanDataAccess().enemy(initiatingClan, otherClan, player.getName()); - _clansManager.chatClan(); + _clansManager.messageClan(initiatingClan, F.main("Clans", "Your clan is now enemies with " + F.elem(otherClan.getName()))); + _clansManager.messageClan(otherClan, F.main("Clans", "Your clan is now enemies with " + F.elem(initiatingClan.getName()))); } - if (notify) + if (notify && notifyMessage != null) UtilPlayer.message(player, F.main("Clans", notifyMessage)); } From b0be5b25106836644bcfca853a652e756ed1883a Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 3 Feb 2015 16:48:26 -0500 Subject: [PATCH 06/27] Time code for war, server time command --- .../game/clans/clans/ClansManager.java | 2 + .../clans/commands/ServerTimeCommand.java | 22 +++++++ .../game/clans/clans/war/WarManager.java | 58 ++++++++++++++++++- 3 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ServerTimeCommand.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 81d4abc4b..850256d08 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -34,6 +34,7 @@ import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.commands.ClansAllyChatCommand; import mineplex.game.clans.clans.commands.ClansChatCommand; import mineplex.game.clans.clans.commands.ClansCommand; +import mineplex.game.clans.clans.commands.ServerTimeCommand; import mineplex.game.clans.clans.repository.ClanTerritory; import mineplex.game.clans.clans.repository.tokens.ClanMemberToken; import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken; @@ -160,6 +161,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat addCommand(new ClansCommand(this)); addCommand(new ClansChatCommand(this)); addCommand(new ClansAllyChatCommand(this)); + addCommand(new ServerTimeCommand(this)); } public int getInviteExpire() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ServerTimeCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ServerTimeCommand.java new file mode 100644 index 000000000..8f862c736 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ServerTimeCommand.java @@ -0,0 +1,22 @@ +package mineplex.game.clans.clans.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.ClansManager; + +public class ServerTimeCommand extends CommandBase +{ + public ServerTimeCommand(ClansManager plugin) + { + super(plugin, Rank.ALL, "servertime", "t"); + } + + @Override + public void Execute(Player caller, String[] args) + { + UtilPlayer.message(caller, Plugin.getWarManager().mServerTime()); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java index eb728d6bd..bc1fa2c66 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java @@ -1,6 +1,9 @@ package mineplex.game.clans.clans.war; +import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Date; +import java.util.LinkedList; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -10,6 +13,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; @@ -60,12 +64,13 @@ public class WarManager extends MiniPlugin @EventHandler public void handleDeath(PlayerDeathEvent event) { - // TODO handle war deaths + } - /** - * Can enemies be formed at the current time? + * Can enemies be formed at the current time + * + * Enemy forming will happen once a week during a set period */ private boolean isEnemyTime() { @@ -80,4 +85,51 @@ public class WarManager extends MiniPlugin return false; } + /** + * Get the starting time of when enemies can be formed next + * @return The enemy start time in the form of {@link java.util.Date} + */ + private Date getNextEnemyTime() + { + Calendar c = Calendar.getInstance(); + c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); + c.set(Calendar.HOUR_OF_DAY, 0); + c.set(Calendar.MINUTE, 0); + c.set(Calendar.SECOND, 0); + + c.add(Calendar.DATE, 7); + + return c.getTime(); + } + + /** + * Send the current server time information to the player + */ + public LinkedList mServerTime() + { + LinkedList messageList = new LinkedList(); + + Date currDate = new Date(); + SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy"); + + messageList.add(F.value("Server Time", dateFormat.format(currDate))); + + if (isEnemyTime()) + { + messageList.add(F.elem("Enemies can be formed at this time")); + } + else + { + long next = getNextEnemyTime().getTime(); + long currTime = System.currentTimeMillis(); + + messageList.add(F.value("Can Form Enemies In", UtilTime.convertString(next - currTime, 1, UtilTime.TimeUnit.FIT))); + } + + + // TODO Time until next war + + return messageList; + } + } From 2060b7434366404146b17e8335931785684973d8 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 3 Feb 2015 19:35:53 -0500 Subject: [PATCH 07/27] War death handling, more war logic, other fixes --- .../game/clans/clans/ClanEnergyManager.java | 19 ++--- .../mineplex/game/clans/clans/ClanInfo.java | 9 +-- .../mineplex/game/clans/clans/ClansGame.java | 9 +-- .../mineplex/game/clans/clans/EnemyData.java | 21 +++++ .../clans/clans/commands/ClansCommand.java | 3 +- .../game/clans/clans/war/WarManager.java | 80 ++++++++++++++++--- 6 files changed, 108 insertions(+), 33 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyManager.java index 9f2a271bf..aa14e48e6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyManager.java @@ -1,8 +1,6 @@ package mineplex.game.clans.clans; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; @@ -71,13 +69,12 @@ public class ClanEnergyManager extends MiniPlugin implements Runnable _shop.attemptShopOpen(player); } - // TODO DEBUG - @EventHandler - public void command(PlayerCommandPreprocessEvent event) - { - if (event.getMessage().startsWith("/energyshop")) - { - openShop(event.getPlayer()); - } - } +// @EventHandler +// public void command(PlayerCommandPreprocessEvent event) +// { +// if (event.getMessage().startsWith("/energyshop")) +// { +// openShop(event.getPlayer()); +// } +// } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java index b2c3edf78..d0a5644b5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java @@ -10,10 +10,6 @@ import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.Player; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.entity.Player; - import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -230,7 +226,8 @@ public class ClanInfo stringList.add(F.value("Clan Energy", "" + energy)); // stringList.add(F.value("Max Energy", "" + getEnergyMax())); stringList.add(F.value("Energy Drain/Hour", "" + costPerHour)); - stringList.add(F.value("Hours Left", "" + energy / costPerHour)); + if (costPerHour > 0) + stringList.add(F.value("Hours Left", "" + energy / costPerHour)); stringList.add(" "); // Ally String @@ -284,6 +281,7 @@ public class ClanInfo } else { + stringList.add(F.main("Clans", "Enemy Details")); String enemyName = _enemyData.getEnemyName(); EnemyData otherEnemyData = Clans.getClanUtility().getClanByClanName(enemyName).getEnemyData(); stringList.add(F.value("Enemy", _enemyData.getEnemyName())); @@ -485,7 +483,6 @@ public class ClanInfo public int getEnergyMax() { - // TODO // 10080 = 7 days of minutes return 1440 + (getEnergyCostPerMinute() * 10080); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java index 5c126126b..0de6011f3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java @@ -23,9 +23,6 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.core.MiniPlugin; import mineplex.core.blockrestore.BlockRestoreData; import mineplex.core.common.util.C; @@ -38,12 +35,14 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.creature.event.CreatureSpawnCustomEvent; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanInfo.Role; import mineplex.game.clans.clans.ClansUtility.ClanRelation; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class ClansGame extends MiniPlugin { @@ -172,7 +171,7 @@ public class ClansGame extends MiniPlugin @EventHandler(priority = EventPriority.LOW) public void BlockBreak(BlockBreakEvent event) { - if (event.isCancelled() || event.getPlayer().getWorld().getEnvironment() != Environment.NORMAL) + if (event.isCancelled() || event.getPlayer().getWorld().getEnvironment() != Environment.NORMAL || event.getPlayer().getGameMode() == GameMode.CREATIVE) return; String mimic = Clans.Get(event.getPlayer()).getMimic(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java index 68b116776..1921834ca 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java @@ -36,6 +36,27 @@ public class EnemyData return _kills; } + public void addDeath() + { + addScore(-1); + } + + public void addKill() + { + addScore(1); + addKills(1); + } + + private void addScore(int add) + { + _score = Math.max(0, Math.min(_score + 1, 40)); + } + + private void addKills(int add) + { + _kills++; + } + public boolean isInitiator() { return _initiator; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index f3366ad9e..161ec786e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -118,7 +118,7 @@ public class ClansCommand extends CommandBase if (args.length == 2) { ClanInfo playerClan = Plugin.getClanUtility().getClanByPlayer(caller); - ClanInfo otherClan = Plugin.getClanUtility().getClanByClanName(args[1]); + ClanInfo otherClan = Plugin.getClanUtility().searchClan(caller, args[1], true); if (playerClan == null) { @@ -127,7 +127,6 @@ public class ClansCommand extends CommandBase } else if (otherClan == null) { - UtilPlayer.message(caller, F.main("Clans", "Could not find a clan with the name " + F.elem(args[1]))); return; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java index bc1fa2c66..ec7e64f24 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java @@ -19,14 +19,15 @@ import mineplex.game.clans.clans.ClansManager; public class WarManager extends MiniPlugin { + private static final int INVADE_ENEMY_DATE = Calendar.SATURDAY; + private static final int CREATE_ENEMY_DATE = Calendar.SUNDAY; + private final ClansManager _clansManager; public WarManager(JavaPlugin plugin, ClansManager clansManager) { super("War Manager", plugin); _clansManager = clansManager; - - } public void attemptEnemy(Player player, ClanInfo initiatingClan, ClanInfo otherClan) @@ -38,7 +39,7 @@ public class WarManager extends MiniPlugin { String notifyMessage = null; - if (isEnemyTime()) + if (!isEnemyTime()) { notifyMessage = "Enemies cannot be formed at this time. Please see mineplex.com/clans for info"; } @@ -64,6 +65,23 @@ public class WarManager extends MiniPlugin @EventHandler public void handleDeath(PlayerDeathEvent event) { + Player player = event.getEntity(); + Player killer = player.getKiller(); + + ClanInfo playerClan = _clansManager.getClan(player); + ClanInfo killerClan = _clansManager.getClan(killer); + + if (playerClan != null && killerClan != null) + { + if (playerClan.getEnemyData() != null && playerClan.getEnemyData().getEnemyName().equalsIgnoreCase(killerClan.getName())) + { + if (isWarInProgress()) + { + playerClan.getEnemyData().addDeath(); + killerClan.getEnemyData().addKill(); + } + } + } } @@ -74,10 +92,11 @@ public class WarManager extends MiniPlugin */ private boolean isEnemyTime() { + Calendar c = Calendar.getInstance(); int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); - if (dayOfWeek == Calendar.SUNDAY) + if (dayOfWeek == CREATE_ENEMY_DATE) { return true; } @@ -85,6 +104,23 @@ public class WarManager extends MiniPlugin return false; } + private boolean isInvadeTime() + { + Calendar c = Calendar.getInstance(); + int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); + + if (dayOfWeek == INVADE_ENEMY_DATE) + { + return true; + } + return false; + } + + private boolean isWarInProgress() + { + return !isInvadeTime(); + } + /** * Get the starting time of when enemies can be formed next * @return The enemy start time in the form of {@link java.util.Date} @@ -92,7 +128,24 @@ public class WarManager extends MiniPlugin private Date getNextEnemyTime() { Calendar c = Calendar.getInstance(); - c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); + c.set(Calendar.DAY_OF_WEEK, CREATE_ENEMY_DATE); + c.set(Calendar.HOUR_OF_DAY, 0); + c.set(Calendar.MINUTE, 0); + c.set(Calendar.SECOND, 0); + + c.add(Calendar.DATE, 7); + + return c.getTime(); + } + + /** + * Get the starting time of the next enemy invasion + * @return The invasion start time in the form of {@link java.util.Date} + */ + private Date getNextInvadeTime() + { + Calendar c = Calendar.getInstance(); + c.set(Calendar.DAY_OF_WEEK, INVADE_ENEMY_DATE); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); @@ -109,11 +162,24 @@ public class WarManager extends MiniPlugin { LinkedList messageList = new LinkedList(); + messageList.add(F.main("Clans", "Server Time;")); Date currDate = new Date(); SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy"); messageList.add(F.value("Server Time", dateFormat.format(currDate))); + if (isInvadeTime()) + { + messageList.add(F.elem("Winning clans can invade enemies right now")); + } + else + { + long next = getNextInvadeTime().getTime(); + long currTime = System.currentTimeMillis(); + + messageList.add(F.value("Enemy Invasion", UtilTime.convertString(next - currTime, 1, UtilTime.TimeUnit.FIT))); + } + if (isEnemyTime()) { messageList.add(F.elem("Enemies can be formed at this time")); @@ -126,10 +192,6 @@ public class WarManager extends MiniPlugin messageList.add(F.value("Can Form Enemies In", UtilTime.convertString(next - currTime, 1, UtilTime.TimeUnit.FIT))); } - - // TODO Time until next war - return messageList; } - } From 0f23533f41448c2ecd88b024d3f52cf15c4fb19a Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 3 Feb 2015 23:18:42 -0500 Subject: [PATCH 08/27] Fix typos in EnemyData --- .../src/mineplex/game/clans/clans/EnemyData.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java index 1921834ca..726fc11c3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java @@ -49,12 +49,12 @@ public class EnemyData private void addScore(int add) { - _score = Math.max(0, Math.min(_score + 1, 40)); + _score = Math.max(0, Math.min(_score + add, 40)); } private void addKills(int add) { - _kills++; + _kills += add; } public boolean isInitiator() From 55b9435877b93be4f8e542bea49e95b1303660f1 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Wed, 4 Feb 2015 18:36:44 +1300 Subject: [PATCH 09/27] Change event used to track player's in bungee --- .../src/mineplex/bungee/playerTracker/PlayerTracker.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java index 6736b507d..40e3cb979 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java @@ -3,7 +3,7 @@ package mineplex.bungee.playerTracker; import java.io.File; import net.md_5.bungee.api.event.PlayerDisconnectEvent; -import net.md_5.bungee.api.event.ServerSwitchEvent; +import net.md_5.bungee.api.event.ServerConnectedEvent; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.event.EventHandler; @@ -26,7 +26,7 @@ public class PlayerTracker implements Listener } @EventHandler - public void playerConnect(final ServerSwitchEvent event) + public void playerConnect(final ServerConnectedEvent event) { _plugin.getProxy().getScheduler().runAsync(_plugin, new Runnable() { From c7d4b14f4cb9073e9dc9861f06d0a159ec82e061 Mon Sep 17 00:00:00 2001 From: Chiss Date: Thu, 5 Feb 2015 11:34:29 +1100 Subject: [PATCH 10/27] Revert "Revert "Work on treasure............"" This reverts commit 49bfe385bf308fbf853525cdd744279506deefb6. --- .../cosmetic/ui/button/TreasureButton.java | 44 -- .../mineplex/core/cosmetic/ui/page/Menu.java | 69 +-- .../src/mineplex/core/treasure/BlockInfo.java | 12 - .../src/mineplex/core/treasure/ChestData.java | 14 +- .../src/mineplex/core/treasure/Treasure.java | 297 ++++------- .../core/treasure/TreasureLocation.java | 322 ++++++++++++ .../core/treasure/TreasureManager.java | 461 +++--------------- .../mineplex/core/treasure/TreasureType.java | 53 ++ .../animation/BlockChangeAnimation.java | 76 +++ .../animation/ChestSpawnAnimation.java | 34 +- .../treasure/animation/ParticleAnimation.java | 2 +- .../animation/TreasureRemoveAnimation.java | 62 +-- .../core/treasure/gui/OpenTreasureButton.java | 30 ++ .../core/treasure/gui/TreasurePage.java | 73 +++ .../core/treasure/gui/TreasureShop.java | 30 ++ .../src/mineplex/game/clans/Clans.java | 6 +- .../src/mineplex/hub/HubManager.java | 5 +- 17 files changed, 799 insertions(+), 791 deletions(-) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/TreasureButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/OpenTreasureButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasureShop.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/TreasureButton.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/TreasureButton.java deleted file mode 100644 index 05855bcde..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/TreasureButton.java +++ /dev/null @@ -1,44 +0,0 @@ -package mineplex.core.cosmetic.ui.button; - -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - -import mineplex.core.cosmetic.ui.page.Menu; -import mineplex.core.shop.item.IButton; - -public class TreasureButton implements IButton -{ - private Menu _menu; - private boolean _hasEnoughChests; - private boolean _hasEnoughKeys; - private boolean _canPurchaseKey; - - public TreasureButton(Menu menu, boolean hasEnoughChests, boolean hasEnoughKeys, boolean canPurchaseKey) - { - _menu = menu; - _hasEnoughChests = hasEnoughChests; - _hasEnoughKeys = hasEnoughKeys; - _canPurchaseKey = canPurchaseKey; - } - - public void onClick(Player player, ClickType clickType) - { - if (clickType.isLeftClick()) - { - if (_hasEnoughChests && _hasEnoughKeys) - { - _menu.openTreasure(player); - player.closeInventory(); - } - else if (_hasEnoughChests && _canPurchaseKey) - { - _menu.attemptPurchaseKey(player); - } - } - else if (clickType.isRightClick()) - { - if (_canPurchaseKey) - _menu.attemptPurchaseKey(player); - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index b012cc6ac..0e7253a2c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -1,7 +1,5 @@ package mineplex.core.cosmetic.ui.page; -import java.util.ArrayList; - import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Creature; @@ -12,8 +10,6 @@ import org.bukkit.event.inventory.ClickType; import mineplex.core.account.CoreClientManager; import mineplex.core.common.CurrencyType; import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.button.OpenCostumes; @@ -23,7 +19,6 @@ import mineplex.core.cosmetic.ui.button.OpenMounts; import mineplex.core.cosmetic.ui.button.OpenMusic; import mineplex.core.cosmetic.ui.button.OpenParticles; import mineplex.core.cosmetic.ui.button.OpenPets; -import mineplex.core.cosmetic.ui.button.TreasureButton; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; @@ -33,7 +28,6 @@ import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ConfirmationPage; import mineplex.core.shop.page.ShopPageBase; import mineplex.core.treasure.TreasureKey; -import mineplex.core.treasure.TreasureManager; public class Menu extends ShopPageBase { @@ -47,7 +41,7 @@ public class Menu extends ShopPageBase @Override protected void BuildPage() { - AddItem(2, new ShopItem(175, DonationManager.Get(Player.getName()).getCoins() + " Coins", new String[] + AddItem(4, new ShopItem(175, DonationManager.Get(Player.getName()).getCoins() + " Coins", new String[] { " ", ChatColor.RESET + C.cYellow + "Purchase Coins", @@ -60,54 +54,6 @@ public class Menu extends ShopPageBase ChatColor.RESET + "Receives 15000 Coins per Month", }, 1, false)); - int treasureChestCount = Plugin.getInventoryManager().Get(Player).getItemCount("Treasure Chest"); - int treasureKeyCount = Plugin.getInventoryManager().Get(Player).getItemCount("Treasure Key"); - boolean canPurchaseKey = DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Coins) >= 1000; - - ArrayList lore = new ArrayList(); - - lore.add(ChatColor.RESET + "You can find all kinds of rare"); - lore.add(ChatColor.RESET + "and exciting loot inside!"); - lore.add(" "); - lore.add(ChatColor.RESET + C.cYellow + "Treasure Chests: " + ChatColor.RESET + treasureChestCount); - lore.add(ChatColor.RESET + C.cYellow + "Treasure Keys: " + ChatColor.RESET + treasureKeyCount); - lore.add(" "); - - if (treasureChestCount > 0 && treasureKeyCount > 0) - { - lore.add(ChatColor.RESET + C.cGreen + "Left-Click to open Treasure Chest"); - lore.add(ChatColor.RESET + " Uses 1 Treasure Chest"); - lore.add(ChatColor.RESET + " Uses 1 Treasure Key"); - } - - else if (treasureChestCount > 0) - { - lore.add(ChatColor.RESET + C.cRed + "Left-Click to open Treasure Chest"); - lore.add(ChatColor.RESET + " This requires 1 Treasure Key"); - lore.add(ChatColor.RESET + " You do not have any Treasure Keys"); - } - else - { - lore.add(ChatColor.RESET + C.cRed + "Left-Click to open Treasure Chest"); - lore.add(ChatColor.RESET + " This requires 1 Treasure Chest"); - lore.add(ChatColor.RESET + " Find Treasure Chests by playing games"); - } - - - lore.add(" "); - if (canPurchaseKey) - { - lore.add(ChatColor.RESET + C.cGreen + "Right-Click to purchase Treasure Key"); - lore.add(ChatColor.RESET + " Costs 1000 Coins"); - } - else - { - lore.add(ChatColor.RESET + C.cRed + "Right-Click to purchase Treasure Key"); - lore.add(ChatColor.RESET + " Costs 1000 Coins"); - lore.add(ChatColor.RESET + " You cannot afford a Treasure Key"); - } - - AddButton(4, new ShopItem(Material.CHEST, ChatColor.RESET + C.cGreen + C.Bold + "Treasure Chest", lore.toArray(new String[0]), 1, false), new TreasureButton(this, treasureChestCount > 0, treasureKeyCount > 0, canPurchaseKey)); AddButton(18, new ShopItem(Material.NETHER_STAR, "Particle Effects", 1, false), new OpenParticles(this)); AddButton(20, new ShopItem(Material.BOW, "Gadgets", 1, false), new OpenGadgets(this)); AddButton(22, new ShopItem(Material.LEATHER, "Morphs", 1, false), new OpenMorphs(this)); @@ -212,19 +158,6 @@ public class Menu extends ShopPageBase Shop.OpenPageForPlayer(player, new MusicPage(Plugin, Shop, ClientManager, DonationManager, "Music", player)); } - public void openTreasure(Player player) - { - TreasureManager treasureManager = Plugin.getTreasureManager(); - if (treasureManager == null) - { - UtilPlayer.message(player, F.main("Treasure", "You cannot open Treasure Chests on this server")); - } - else - { - treasureManager.attemptOpenTreasure(player); - } - } - public void attemptPurchaseKey(Player player) { Shop.OpenPageForPlayer(player, new ConfirmationPage(Plugin, Shop, ClientManager, DonationManager, new Runnable() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/BlockInfo.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/BlockInfo.java index 8bcd13f37..894705556 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/BlockInfo.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/BlockInfo.java @@ -33,16 +33,4 @@ public class BlockInfo { return _data; } - - @Override - public int hashCode() - { - return _block.hashCode(); - } - - @Override - public boolean equals(Object obj) - { - return _block.equals(obj); - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/ChestData.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/ChestData.java index b5b93540a..43c970262 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/ChestData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/ChestData.java @@ -2,22 +2,15 @@ package mineplex.core.treasure; import org.bukkit.block.Block; -import mineplex.core.reward.Reward; - -/** - * Created by Shaun on 8/29/2014. - */ public class ChestData { private Block _block; - private Reward _reward; private boolean _opened; - public ChestData(Block block, Reward reward) + public ChestData(Block block) { _block = block; _opened = false; - _reward = reward; } public boolean isOpened() @@ -35,9 +28,4 @@ public class ChestData return _block; } - public Reward getReward() - { - return _reward; - } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java index 46099fb23..abef020d7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java @@ -1,21 +1,20 @@ package mineplex.core.treasure; -import java.util.HashSet; +import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; +import java.util.List; import java.util.Random; -import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers; import org.bukkit.entity.Player; - import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction; + import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -25,6 +24,7 @@ import mineplex.core.reward.Reward; import mineplex.core.reward.RewardData; import mineplex.core.reward.RewardRarity; import mineplex.core.treasure.animation.Animation; +import mineplex.core.treasure.animation.BlockChangeAnimation; import mineplex.core.treasure.animation.ChestOpenAnimation; import mineplex.core.treasure.animation.ChestSpawnAnimation; import mineplex.core.treasure.animation.LegendaryAnimation; @@ -39,135 +39,59 @@ public class Treasure { private BlockRestore _blockRestore; - // Decay Sets - private HashSet _wallsBlockInfo = new HashSet<>(); - private HashSet _outerRingBlockInfo = new HashSet<>(); - private HashSet _centerBlockInfo = new HashSet<>(); - private HashSet _chestBlockInfo = new HashSet<>(); + private List _chestBlockInfo = new ArrayList(); + private List _openedChestBlockInfo = new ArrayList(); + private List _otherBlockInfo = new ArrayList(); private Player _player; private Random _random; private Block _centerBlock; private int _tickCount; + private TreasureType _treasureType; + private ChestData[] _chestData; + private int _currentChest; + + private Reward[] _rewards; + private int _currentReward; private boolean _finished; private int _finishedTickCount; private LinkedList _animations; - private TreasureStyle _style; private HologramManager _hologramManager; - public Treasure(Player player, Reward[] rewards, BlockRestore blockRestore, HologramManager hologramManager) + public Treasure(Player player, Reward[] rewards, Block centerBlock, Block[] chestBlocks, TreasureType treasureType, BlockRestore blockRestore, HologramManager hologramManager) { - this(player, new Random(), rewards, hologramManager); + this(player, new Random(), rewards, centerBlock, chestBlocks, treasureType, hologramManager); _blockRestore = blockRestore; } - public Treasure(Player player, Random seed, Reward[] rewards, HologramManager hologramManager) + public Treasure(Player player, Random seed, Reward[] rewards, Block centerBlock, Block[] chestBlocks, TreasureType treasureType, HologramManager hologramManager) { _player = player; _random = seed; - _style = TreasureStyle.values()[_random.nextInt(TreasureStyle.values().length)]; + _treasureType = treasureType; - _centerBlock = player.getLocation().getBlock().getRelative(BlockFace.DOWN); + _centerBlock = centerBlock; _animations = new LinkedList(); _hologramManager = hologramManager; -// _animations.add(new ParticleAnimation(this)); + _currentChest = 0; + _currentReward = 0; + _rewards = rewards; - _chestData = new ChestData[4]; - _chestData[0] = new ChestData(_centerBlock.getRelative(2, 1, 0), rewards[0]); - _chestData[1] = new ChestData(_centerBlock.getRelative(-2, 1, 0), rewards[1]); - _chestData[2] = new ChestData(_centerBlock.getRelative(0, 1, 2), rewards[2]); - _chestData[3] = new ChestData(_centerBlock.getRelative(0, 1, -2), rewards[3]); - } - - private void createCenterClay() - { - for (int x = -1; x <= 1; x++) + _chestData = new ChestData[chestBlocks.length]; + for (int i = 0; i < _chestData.length; i++) { - for (int z = -1; z <= 1; z++) - { - if (Math.abs(x) == 1 || Math.abs(z) == 1) - { - Block block = _centerBlock.getRelative(x, 0, z); - - _blockRestore.Restore(block); - - _centerBlockInfo.add(new BlockInfo(block)); - setBlock(block, _style.getPrimaryMaterial(), _style.getPrimaryData()); - } - } - } - } - - private void createOuterClay() - { - for (int x = -2; x <= 2; x++) - { - { - Block block = _centerBlock.getRelative(x, 0, -2); - - _blockRestore.Restore(block); - - _outerRingBlockInfo.add(new BlockInfo(block)); - setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData()); - } - - { - Block block = _centerBlock.getRelative(x, 0, 2); - - _blockRestore.Restore(block); - - _outerRingBlockInfo.add(new BlockInfo(block)); - setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData()); - } + _chestData[i] = new ChestData(chestBlocks[i]); } - for (int z = -1; z <= 1; z++) - { - { - Block block = _centerBlock.getRelative(-2, 0, z); - - _blockRestore.Restore(block); - - _outerRingBlockInfo.add(new BlockInfo(block)); - setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData()); - } - - { - Block block = _centerBlock.getRelative(2, 0, z); - - _blockRestore.Restore(block); - - _outerRingBlockInfo.add(new BlockInfo(block)); - setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData()); - } - } - } - - private void createWalls() - { - for (int z = -2; z <= 2; z++) - { - for (int x = -2; x <= 2; x++) - { - if ((Math.abs(x) == 2 || Math.abs(z) == 2) && (x != 0 && z != 0)) - { - Block playerBlock = getPlayerBlock(); - Block block = playerBlock.getRelative(x, 0, z); - - _blockRestore.Restore(block); - - _wallsBlockInfo.add(new BlockInfo(block)); - setBlock(block, _style.getWallMaterial(), _style.getWallData()); - } - } - } + if (_treasureType == TreasureType.HEROIC || _treasureType == TreasureType.LEGENDARY) + _animations.add(new BlockChangeAnimation(this, _otherBlockInfo)); } public int getFinishedTickCount() @@ -182,59 +106,21 @@ public class Treasure _finishedTickCount++; } - if (_tickCount == 5) + if (_tickCount % 10 == 0 && _currentChest < _chestData.length) { - Block block = _centerBlock; - - _blockRestore.Restore(block); - - _centerBlockInfo.add(new BlockInfo(block)); - _centerBlockInfo.add(new BlockInfo(block.getRelative(BlockFace.DOWN))); - setBlock(block, Material.REDSTONE_LAMP_ON, (byte) 0); - setBlock(block.getRelative(BlockFace.DOWN), Material.REDSTONE_TORCH_ON, (byte) 0); + Block block = _chestData[_currentChest].getBlock(); + ChestSpawnAnimation chestSpawn = new ChestSpawnAnimation(this, block, _chestBlockInfo); + _animations.add(chestSpawn); + + _currentChest++; } - else if (_tickCount == 10) - { - createCenterClay(); - } - else if (_tickCount == 20) - { - createOuterClay(); - } - else if (_tickCount == 30) - { - createWalls(); - } - else if (_tickCount == 50) - { - Block block = getPlayerBlock().getRelative(2, 0, 0); - ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)4, _chestBlockInfo); - _animations.add(task); - } - else if (_tickCount == 80) - { - Block block = getPlayerBlock().getRelative(-2, 0, 0); - ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)5, _chestBlockInfo); - _animations.add(task); - } - else if (_tickCount == 110) - { - Block block = getPlayerBlock().getRelative(0, 0, 2); - ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)2, _chestBlockInfo); - _animations.add(task); - } - else if (_tickCount == 140) - { - Block block = getPlayerBlock().getRelative(0, 0, -2); - ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)3, _chestBlockInfo); - _animations.add(task); - } - else if (_tickCount == 60 * 20) + + if (_tickCount == 60 * 20) { for (BlockInfo blockInfo : _chestBlockInfo) { Block block = blockInfo.getBlock(); - openChest(block); + openChest(block, false); } } @@ -271,11 +157,6 @@ public class Treasure return _centerBlock; } - public Block getPlayerBlock() - { - return _centerBlock.getRelative(BlockFace.UP); - } - public void setBlock(Block block, Material material, byte data) { block.setType(material); @@ -284,27 +165,41 @@ public class Treasure } public void openChest(Block block) + { + openChest(block, true); + } + + public void openChest(Block block, boolean swapList) { ChestData data = getChestData(block); - if (data != null && !data.isOpened()) + if (data != null && !data.isOpened() && _currentReward < _rewards.length) { - RewardData rewardData = data.getReward().giveReward("Treasure", _player); + Reward reward = _rewards[_currentReward]; + RewardData rewardData = reward.giveReward("Treasure", _player); + _currentReward++; + + if (swapList) + { + BlockInfo info = getBlockInfo(block); + _chestBlockInfo.remove(info); + _openedChestBlockInfo.add(info); + } data.setOpened(true); ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(this, data, rewardData, _hologramManager); _animations.add(chestOpenTask); // Extra effects based off the rarity of the treasure - if (data.getReward().getRarity() == RewardRarity.UNCOMMON) + if (reward.getRarity() == RewardRarity.UNCOMMON) { _animations.add(new UncommonAnimation(this, data.getBlock())); } - else if (data.getReward().getRarity() == RewardRarity.RARE) + else if (reward.getRarity() == RewardRarity.RARE) { _animations.add(new RareAnimation(this, data.getBlock().getLocation().add(0.5, 1.5, 0.5))); Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cGold + "Rare " + rewardData.getFriendlyName())); } - else if (data.getReward().getRarity() == RewardRarity.LEGENDARY) + else if (reward.getRarity() == RewardRarity.LEGENDARY) { _animations.add(new LegendaryAnimation(this, data.getBlock())); Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cRed + "Legendary " + rewardData.getFriendlyName())); @@ -312,13 +207,23 @@ public class Treasure if (isFinished()) { - TreasureRemoveAnimation animation = new TreasureRemoveAnimation(this, _centerBlockInfo, _outerRingBlockInfo, _wallsBlockInfo); + TreasureRemoveAnimation animation = new TreasureRemoveAnimation(this, _openedChestBlockInfo, _chestBlockInfo); _animations.add(animation); _finished = true; } } } + public BlockInfo getBlockInfo(Block block) + { + for (BlockInfo blockInfo : _chestBlockInfo) + { + if (blockInfo.getBlock().equals(block)) + return blockInfo; + } + return null; + } + public void sendChestOpenPackets(Player... players) { for (ChestData data : _chestData) @@ -357,35 +262,21 @@ public class Treasure public boolean isFinished() { - boolean allOpened = true; - for (int i = 0; i < _chestData.length; i++) - { - if (!_chestData[i].isOpened()) - allOpened = false; - } - - return allOpened; + return _currentReward == _rewards.length; } public void cleanup() { - for (ChestData chestData : _chestData) + + for (int i = _currentReward; i < _rewards.length; i++) { - // Give any unopened rewards to the player - // This only applies if they leave the server - // while opening a treasure - if (!chestData.isOpened()) - { - chestData.setOpened(true); - chestData.getReward().giveReward("Treasure", _player); - } + _rewards[_currentReward].giveReward("Treasure", _player); } // Remove any extra blocks - resetBlockInfo(_wallsBlockInfo); - resetBlockInfo(_centerBlockInfo); - resetBlockInfo(_outerRingBlockInfo); resetBlockInfo(_chestBlockInfo); + resetBlockInfo(_openedChestBlockInfo); + resetBlockInfo(_otherBlockInfo); for (Animation animation : _animations) { @@ -394,40 +285,33 @@ public class Treasure _animations.clear(); } - public void resetBlockInfo(Set blockInfoSet) + public void resetBlockInfo(List blockInfoSet) { for (BlockInfo blockInfo : blockInfoSet) { - Block block = blockInfo.getBlock(); - - if (block.getType().equals(Material.CHEST)) - { - UtilParticle.PlayParticle(UtilParticle.ParticleType.LARGE_SMOKE, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.1F, 10); -// block.getLocation().getWorld().createExplosion(block.getLocation().add(0.5, 0.5, 0.5), 0F); - } - block.getLocation().getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); - - block.setTypeId(blockInfo.getId()); - block.setData(blockInfo.getData()); + resetBlockInfo(blockInfo); } blockInfoSet.clear(); } + public void resetBlockInfo(BlockInfo blockInfo) + { + Block block = blockInfo.getBlock(); + + if (block.getType().equals(Material.CHEST)) + { + UtilParticle.PlayParticle(UtilParticle.ParticleType.LARGE_SMOKE, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.1F, 10); +// block.getLocation().getWorld().createExplosion(block.getLocation().add(0.5, 0.5, 0.5), 0F); + } + block.getLocation().getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); + + block.setTypeId(blockInfo.getId()); + block.setData(blockInfo.getData()); + } + public boolean containsBlock(Block block) { - for (BlockInfo info : _wallsBlockInfo) - if (info.getBlock().equals(block)) - return true; - - for (BlockInfo info : _outerRingBlockInfo) - if (info.getBlock().equals(block)) - return true; - - for (BlockInfo info : _centerBlockInfo) - if (info.getBlock().equals(block)) - return true; - for (BlockInfo info : _chestBlockInfo) if (info.getBlock().equals(block)) return true; @@ -435,9 +319,8 @@ public class Treasure return false; } - public TreasureStyle getStyle() + public TreasureType getTreasureType() { - return _style; + return _treasureType; } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java new file mode 100644 index 000000000..60b3f1338 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java @@ -0,0 +1,322 @@ +package mineplex.core.treasure; + +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.inventory.InventoryOpenEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerVelocityEvent; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.event.GadgetBlockEvent; +import mineplex.core.hologram.Hologram; +import mineplex.core.hologram.HologramManager; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.reward.Reward; +import mineplex.core.treasure.event.TreasureFinishEvent; +import mineplex.core.treasure.event.TreasureStartEvent; +import mineplex.core.treasure.gui.TreasureShop; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class TreasureLocation implements Listener +{ + private TreasureManager _treasureManager; + private InventoryManager _inventoryManager; + private Hologram _hologram; + private HologramManager _hologramManager; + private Treasure _currentTreasure; + private Block _chestBlock; + private byte _chestBlockData; + private Block[] _chestSpawns; + private TreasureShop _shop; + private Location _resetLocation; + + public TreasureLocation(TreasureManager treasureManager, InventoryManager inventoryManager, CoreClientManager clientManager, DonationManager donationManager, Block chestBlock, Block[] chestSpawns, Location resetLocation, HologramManager hologramManager) + { + _treasureManager = treasureManager; + _resetLocation = resetLocation; + _inventoryManager = inventoryManager; + _chestBlock = chestBlock; + _chestBlockData = _chestBlock.getData(); + _chestSpawns = chestSpawns; + _hologramManager = hologramManager; + _currentTreasure = null; + _hologram = new Hologram(_hologramManager, chestBlock.getLocation().add(0.5, 2.5, 0.5), C.cGreen + C.Bold + "Open Treasure"); + setHoloChestVisible(true); + _shop = new TreasureShop(treasureManager, _inventoryManager, clientManager, donationManager, this); + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().equals(_chestBlock)) + { + openShop(event.getPlayer()); + event.setCancelled(true); + } + } + + public void attemptOpenTreasure(Player player, TreasureType treasureType) + { + if (isTreasureInProgress()) + { + player.sendMessage(F.main("Treasure", "Please wait for the current chest to be opened")); + return; + } + + if (!chargeAccount(player, treasureType)) + { + player.sendMessage(F.main("Treasure", "You dont have any chests to open!")); + return; + } + + TreasureStartEvent event = new TreasureStartEvent(player); + Bukkit.getPluginManager().callEvent(event); + + if (event.isCancelled()) + { + return; + } + + setHoloChestVisible(false); + + if (treasureType == TreasureType.HEROIC || treasureType == TreasureType.LEGENDARY) + Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + treasureType.getName())); + + Reward[] rewards = _treasureManager.getRewards(player, treasureType.getRewardType()); + Treasure treasure = new Treasure(player, rewards, _chestBlock, _chestSpawns, treasureType, _treasureManager.getBlockRestore(), _hologramManager); + _currentTreasure = treasure; + + UtilTextMiddle.display(treasureType.getName(), "Choose 4 Chests To Open", 20, 180, 20, player); + UtilPlayer.message(player, F.main("Treasure", "Choose 4 Chests To Open")); + + Location teleportLocation = treasure.getCenterBlock().getLocation().add(0.5, 0, 0.5); + teleportLocation.setPitch(player.getLocation().getPitch()); + teleportLocation.setYaw(player.getLocation().getYaw()); + + for (Entity entity : player.getNearbyEntities(3, 3, 3)) + { + UtilAction.velocity(entity, UtilAlg.getTrajectory(entity.getLocation(), treasure.getCenterBlock().getLocation()).multiply(-1), 1.5, true, 0.8, 0, 1.0, true); + } + + player.teleport(teleportLocation); + + } + + private boolean chargeAccount(Player player, TreasureType treasureType) + { + int itemCount = _inventoryManager.Get(player).getItemCount(treasureType.getItemName()); + if (itemCount > 0) + { + _inventoryManager.addItemToInventory(player, "Item", treasureType.getItemName(), -1); + return true; + } + return false; + } + + private void setHoloChestVisible(boolean visible) + { + if (visible) + { + _hologram.start(); + _chestBlock.setType(Material.CHEST); + _chestBlock.setData(_chestBlockData); + } + else + { + _hologram.stop(); + _chestBlock.setType(Material.AIR); + } + } + + public void cleanup() + { + if (_currentTreasure != null) + { + _currentTreasure.cleanup(); + _currentTreasure = null; + } + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (isTreasureInProgress()) + { + Treasure treasure = _currentTreasure; + + treasure.update(); + + if (treasure.isFinished() && treasure.getFinishedTickCount() >= 80) + { + treasure.cleanup(); + + TreasureFinishEvent finishEvent = new TreasureFinishEvent(treasure.getPlayer(), treasure); + Bukkit.getPluginManager().callEvent(finishEvent); + } + } + } + + @EventHandler + public void onTreasureFinish(TreasureFinishEvent event) + { + if (event.getTreasure().equals(_currentTreasure)) + { + Player player = _currentTreasure.getPlayer(); + player.teleport(_resetLocation); + _currentTreasure = null; + setHoloChestVisible(true); + } + } + + @EventHandler + public void preventGadgetBlockEvent(GadgetBlockEvent event) + { + if (isTreasureInProgress()) + { + List blocks = event.getBlocks(); + + for (Block block : blocks) + { + if (_currentTreasure.containsBlock(block)) + { + event.setCancelled(true); + return; + } + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void interact(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + if (isTreasureInProgress()) + { + if (_currentTreasure.getPlayer().equals(player)) + { + if (event.getAction() == Action.RIGHT_CLICK_BLOCK) + { + _currentTreasure.openChest(event.getClickedBlock()); + } + event.setCancelled(true); + } + else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) + { + ChestData chestData = _currentTreasure.getChestData(event.getClickedBlock()); + if (chestData != null) + { + event.setCancelled(true); + } + } + } + } + + @EventHandler + public void inventoryOpen(InventoryOpenEvent event) + { + if (isTreasureInProgress() && event.getPlayer().equals(_currentTreasure.getPlayer())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void cancelMove(PlayerMoveEvent event) + { + Player player = event.getPlayer(); + if (isTreasureInProgress()) + { + if (_currentTreasure.getPlayer().equals(player)) + { + Treasure treasure = _currentTreasure; + Location centerLocation = treasure.getCenterBlock().getLocation().add(0.5, 0.5, 0.5); + if (event.getTo().distanceSquared(centerLocation) > 9) + { + Location newTo = event.getFrom(); + newTo.setPitch(event.getTo().getPitch()); + newTo.setYaw(event.getTo().getYaw()); + event.setTo(newTo); + } + } + else + { + Location fromLocation = event.getFrom(); + Location toLocation = event.getTo(); + Location centerLocation = _currentTreasure.getCenterBlock().getLocation().add(0.5, 1.5, 0.5); + double toDistanceFromCenter = centerLocation.distanceSquared(toLocation); + + if (toDistanceFromCenter <= 16 && player.getVelocity().lengthSquared() < 10) + { + // Only cancel movement if they are moving towards the center + double fromDistanceFromCenter = centerLocation.distanceSquared(fromLocation); + if (toDistanceFromCenter < fromDistanceFromCenter) + { + Location spawnLocation = new Location(player.getWorld(), 0, 64, 0); + UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), spawnLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true); + event.setTo(event.getFrom()); + } + } + } + } + } + + @EventHandler + public void cancelVelocity(PlayerVelocityEvent event) + { + Player player = event.getPlayer(); + if (isTreasureInProgress() && _currentTreasure.getPlayer().equals(player)) + { + event.setCancelled(true); + } + } + + @EventHandler + public void quit(PlayerQuitEvent event) + { + if (isTreasureInProgress() && _currentTreasure.getPlayer().equals(event.getPlayer())) + { + reset(); + } + } + + public boolean isTreasureInProgress() + { + return _currentTreasure != null; + } + + public void reset() + { + cleanup(); + _chestBlock.setType(Material.CHEST); + _chestBlock.setData(_chestBlockData); + _hologram.start(); + } + + public void openShop(Player player) + { + _shop.attemptShopOpen(player); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java index 34207df10..dbcf16f21 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java @@ -1,441 +1,132 @@ package mineplex.core.treasure; -import java.util.Iterator; +import java.util.ArrayList; import java.util.List; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.Action; -import org.bukkit.event.inventory.InventoryOpenEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; import mineplex.core.blockrestore.BlockRestore; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; -import mineplex.core.event.StackerEvent; -import mineplex.core.gadget.event.GadgetBlockEvent; import mineplex.core.hologram.HologramManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.pet.PetManager; import mineplex.core.reward.Reward; import mineplex.core.reward.RewardManager; -import mineplex.core.reward.RewardRarity; import mineplex.core.reward.RewardType; -import mineplex.core.treasure.event.TreasureFinishEvent; -import mineplex.core.treasure.event.TreasureStartEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; /** * Created by Shaun on 8/27/2014. */ public class TreasureManager extends MiniPlugin { - private NautHashMap _playerTreasureMap; private RewardManager _rewardManager; private InventoryManager _inventoryManager; private BlockRestore _blockRestore; private HologramManager _hologramManager; + private List _treasureLocations; - public TreasureManager(JavaPlugin plugin, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager) + public TreasureManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager) { super("Treasure", plugin); - _playerTreasureMap = new NautHashMap(); _inventoryManager = inventoryManager; _blockRestore = blockRestore; _hologramManager = hologramManager; - _rewardManager = new RewardManager(donationManager, inventoryManager, petManager, + _rewardManager = new RewardManager(donationManager, inventoryManager, petManager, 100, 250, 500, 1000, 1500, 2500, 6000, 12000, true); + + World world = Bukkit.getWorlds().get(0); + + _treasureLocations = new ArrayList(); + { + Block chestBlock = world.getBlockAt(-19, 72, -19); + Block chestLoc1 = world.getBlockAt(-16, 72, -20); + Block chestLoc2 = world.getBlockAt(-18, 72, -22); + Block chestLoc3 = world.getBlockAt(-20, 72, -22); + Block chestLoc4 = world.getBlockAt(-22, 72, -20); + Block chestLoc5 = world.getBlockAt(-22, 72, -18); + Block chestLoc6 = world.getBlockAt(-20, 72, -16); + Block chestLoc7 = world.getBlockAt(-18, 72, -16); + Block chestLoc8 = world.getBlockAt(-16, 72, -18); + Location resetLocation = new Location(world, -23.5, 72, -23.5); + _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager)); + } + + { + Block chestBlock = world.getBlockAt(19, 72, 19); + Block chestLoc1 = world.getBlockAt(16, 72, 20); + Block chestLoc2 = world.getBlockAt(18, 72, 22); + Block chestLoc3 = world.getBlockAt(20, 72, 22); + Block chestLoc4 = world.getBlockAt(22, 72, 20); + Block chestLoc5 = world.getBlockAt(22, 72, 18); + Block chestLoc6 = world.getBlockAt(20, 72, 16); + Block chestLoc7 = world.getBlockAt(18, 72, 16); + Block chestLoc8 = world.getBlockAt(16, 72, 18); + Location resetLocation = new Location(world, 23.5, 72, 23.5); + _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager)); + } + + { + Block chestBlock = world.getBlockAt(19, 72, -19); + Block chestLoc1 = world.getBlockAt(16, 72, -20); + Block chestLoc2 = world.getBlockAt(18, 72, -22); + Block chestLoc3 = world.getBlockAt(20, 72, -22); + Block chestLoc4 = world.getBlockAt(22, 72, -20); + Block chestLoc5 = world.getBlockAt(22, 72, -18); + Block chestLoc6 = world.getBlockAt(20, 72, -16); + Block chestLoc7 = world.getBlockAt(18, 72, -16); + Block chestLoc8 = world.getBlockAt(16, 72, -18); + Location resetLocation = new Location(world, 23.5, 72, -23.5); + _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager)); + } + + { + Block chestBlock = world.getBlockAt(-19, 72, 19); + Block chestLoc1 = world.getBlockAt(-16, 72, 20); + Block chestLoc2 = world.getBlockAt(-18, 72, 22); + Block chestLoc3 = world.getBlockAt(-20, 72, 22); + Block chestLoc4 = world.getBlockAt(-22, 72, 20); + Block chestLoc5 = world.getBlockAt(-22, 72, 18); + Block chestLoc6 = world.getBlockAt(-20, 72, 16); + Block chestLoc7 = world.getBlockAt(-18, 72, 16); + Block chestLoc8 = world.getBlockAt(-16, 72, 18); + Location resetLocation = new Location(world, -23.5, 72, 23.5); + _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager)); + } + + for (TreasureLocation treasureLocation : _treasureLocations) + { + _plugin.getServer().getPluginManager().registerEvents(treasureLocation, _plugin); + } } @Override public void Disable() { - for (Treasure treasure : _playerTreasureMap.values()) + for (TreasureLocation treasureLocation : _treasureLocations) { - treasure.cleanup(); + treasureLocation.cleanup(); } } - public void attemptOpenTreasure(Player player) + public Reward[] getRewards(Player player, RewardType rewardType) { - attemptOpenTreasure(player, false); + return _rewardManager.getRewards(player, rewardType); } - private void attemptOpenTreasure(Player player, boolean ignoreKey) + public BlockRestore getBlockRestore() { - if (checkNearbyBlocks(player) || checkNearSpawn(player) || checkInAir(player) || checkNearbyTreasure(player) || (!ignoreKey && checkNoTreasureAndKey(player))) - return; - - TreasureStartEvent event = new TreasureStartEvent(player); - Bukkit.getPluginManager().callEvent(event); - - if (event.isCancelled()) - { - return; - } - - if (!ignoreKey) - { - // Remove a treasure and a key - _inventoryManager.addItemToInventory(player, "Treasure", "Treasure Key", -1); - _inventoryManager.addItemToInventory(player, "Utility", "Treasure Chest", -1); - } - - Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + C.cGreen + "Treasure Chest")); - - Reward[] rewards = _rewardManager.getRewards(player, RewardType.HeroicChest); - Treasure treasure = new Treasure(player, rewards, _blockRestore, _hologramManager); - _playerTreasureMap.put(player, treasure); - - Location teleportLocation = treasure.getPlayerBlock().getLocation().add(0.5, 0, 0.5); - teleportLocation.setPitch(player.getLocation().getPitch()); - teleportLocation.setYaw(player.getLocation().getYaw()); - - for (Entity entity : player.getNearbyEntities(3, 3, 3)) - { - UtilAction.velocity(entity, UtilAlg.getTrajectory(entity.getLocation(), treasure.getCenterBlock().getLocation()).multiply(-1), 1.5, true, 0.8, 0, 1.0, true); - } - - player.teleport(teleportLocation); - + return _blockRestore; } - - private boolean checkNoTreasureAndKey(Player player) - { - int treasureCount = _inventoryManager.Get(player).getItemCount("Treasure Chest"); - int treasureKeyCount = _inventoryManager.Get(player).getItemCount("Treasure Key"); - - if (treasureCount < 1) - { - UtilPlayer.message(player, F.main("Treasure", "You don't have any treasure chests.")); - } - else if (treasureKeyCount < 1) - { - UtilPlayer.message(player, F.main("Treasure", "You don't have any treasure keys.")); - } - - return (treasureCount < 1 || treasureKeyCount < 1); - } - - private boolean checkNearbyTreasure(Player player) - { - boolean nearTreasure = false; - - for (Treasure treasure : _playerTreasureMap.values()) - { - if (UtilMath.offset2d(treasure.getCenterBlock().getLocation(), player.getLocation()) <= 10) - nearTreasure = true; - } - - if (nearTreasure) - UtilPlayer.message(player, F.main("Treasure", "You are too close to another players treasure.")); - - return nearTreasure; - } - - private boolean checkNearbyBlocks(Player player) - { - //todo improve this - Block centerBlock = player.getLocation().getBlock(); - - for (int y = 0; y <= 3; y++) - { - for (int x = -3; x <= 3; x++) - { - for (int z = -3; z <= 3; z++) - { - Block block = centerBlock.getRelative(x, y, z); - if (UtilBlock.solid(block)) - { - UtilPlayer.message(player, F.main("Treasure", "You need a clear area to open Treasure Chests.")); - return true; - } - } - } - } - return false; - } - - private boolean checkInAir(Player player) - { - boolean grounded = UtilEnt.isGrounded(player); - - if (!grounded) - UtilPlayer.message(player, F.main("Treasure", "You can't open chests while in the air.")); - - return !grounded; - } - - private boolean checkNearSpawn(Player player) - { - boolean nearSpawn = UtilMath.offset2d(new Location(player.getWorld(), 0, 0, 0), player.getLocation()) < 10; - - if (nearSpawn) - UtilPlayer.message(player, F.main("Treasure", "You can't open chests near spawn.")); - - return nearSpawn; - } - - @EventHandler - public void update(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - Iterator iterator = _playerTreasureMap.values().iterator(); - while(iterator.hasNext()) - { - Treasure treasure = iterator.next(); - - treasure.update(); - - if (treasure.isFinished() && treasure.getFinishedTickCount() >= 80) - { - treasure.cleanup(); - iterator.remove(); - - TreasureFinishEvent finishEvent = new TreasureFinishEvent(treasure.getPlayer(), treasure); - Bukkit.getPluginManager().callEvent(finishEvent); - } - } - } - - @EventHandler - public void join(PlayerJoinEvent event) - { - final Player player = event.getPlayer(); - - _plugin.getServer().getScheduler().runTaskLater(_plugin, new Runnable() - { - @Override - public void run() - { - if (!player.isOnline()) - return; - - for (Treasure treasure : _playerTreasureMap.values()) - { - treasure.sendChestOpenPackets(player); - } - } - }, 10L); - } - - @EventHandler - public void quit(PlayerQuitEvent event) - { - if (_playerTreasureMap.containsKey(event.getPlayer())) - { - Treasure treasure = _playerTreasureMap.remove(event.getPlayer()); - treasure.cleanup(); - } - } - - @EventHandler - public void cancelMove(PlayerMoveEvent event) - { - Player player = event.getPlayer(); - if (_playerTreasureMap.containsKey(player)) - { - Treasure treasure = _playerTreasureMap.get(player); - if (!event.getTo().getBlock().getRelative(BlockFace.DOWN).equals(treasure.getCenterBlock())) - { - Location newTo = treasure.getCenterBlock().getLocation().add(0.5, 1.1, 0.5); - newTo.setPitch(event.getTo().getPitch()); - newTo.setYaw(event.getTo().getYaw()); - event.setTo(newTo); - } - } - else - { - for (Treasure treasure : _playerTreasureMap.values()) - { - Location fromLocation = event.getFrom(); - Location toLocation = event.getTo(); - Location centerLocation = treasure.getCenterBlock().getLocation().add(0.5, 1.5, 0.5); - - double toDistanceFromCenter = centerLocation.distanceSquared(toLocation); - - if (toDistanceFromCenter <= 9) - { - // Only cancel movement if they are moving towards the center - double fromDistanceFromCenter = centerLocation.distanceSquared(fromLocation); - if (toDistanceFromCenter < fromDistanceFromCenter) - { - UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), centerLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true); - event.setTo(event.getFrom()); - } - } - } - } - } - - @EventHandler - public void cancelVelocity(PlayerVelocityEvent event) - { - // Need to prevent players - - Player player = event.getPlayer(); - if (_playerTreasureMap.containsKey(player)) - { - event.setCancelled(true); - } - } - - @EventHandler - public void cancelStacker(StackerEvent event) - { - if (event.getEntity() instanceof Player) - { - Player player = ((Player) event.getEntity()); - if (_playerTreasureMap.containsKey(player)) - { - event.setCancelled(true); - } - } - } - - @EventHandler - public void inventoryOpen(InventoryOpenEvent event) - { - // Prevent players in treasures from opening inventories - if (event.getPlayer() instanceof Player) - { - if (_playerTreasureMap.containsKey(((Player) event.getPlayer()))) - { - event.setCancelled(true); - } - } - } - - @EventHandler(priority = EventPriority.HIGH) - public void interact(PlayerInteractEvent event) - { - Player player = event.getPlayer(); - if (_playerTreasureMap.containsKey(player)) - { - if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST) - { - Treasure treasure = _playerTreasureMap.get(player); - treasure.openChest(event.getClickedBlock()); - } - - // Always cancel interact for treasure players, prevents players from being able to open up cosmetic menu and other menus - event.setCancelled(true); - } - else if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST) - { - for (Treasure treasure : _playerTreasureMap.values()) - { - ChestData data = treasure.getChestData(event.getClickedBlock()); - if (data != null) - { - event.setCancelled(true); - } - } - } - } - - @EventHandler - public void preventGadgetBlockEvent(GadgetBlockEvent event) - { - List blocks = event.getBlocks(); - - for (Block block : blocks) - { - for (Treasure treasure : _playerTreasureMap.values()) - { - if (treasure.containsBlock(block)) - { - event.setCancelled(true); - return; - } - } - } - } - - @EventHandler - public void treasureFinish(TreasureFinishEvent event) - { - _playerTreasureMap.remove(event.getPlayer()); - } - - @EventHandler - public void command(PlayerCommandPreprocessEvent event) - { - if (!event.getPlayer().isOp()) - return; - - if (event.getMessage().startsWith("/treasurechest")) - { - event.getPlayer().sendMessage(C.cGreen + C.Bold + "Received 10 Treasure Chest..."); - _inventoryManager.addItemToInventory(event.getPlayer(), "Utility", "Treasure Chest", 10); - event.setCancelled(true); - } - - if (event.getMessage().startsWith("/treasuredebug")) - { - event.getPlayer().sendMessage(C.cGreen + C.Bold + "Treasure Debug..."); - attemptOpenTreasure(event.getPlayer(), true); - event.setCancelled(true); - } - - if (event.getMessage().startsWith("/rewardchest") || event.getMessage().startsWith("/rewardgame")) - { - int common = 0; - int uncommon = 0; - int rare = 0; - int legend = 0; - - int toTest = 10000000; - - for (int i=0 ; i _blockInfoList; + + public BlockChangeAnimation(Treasure treasure, List blockInfoList) + { + super(treasure); + + _currentRadius = 0; + _blockInfoList = blockInfoList; + } + + @Override + protected void tick() + { + if (_currentRadius == MAX_RADIUS) + { + finish(); + return; + } + else if (getTicks() % 10 == 0) + { + Block centerBlock = getTreasure().getCenterBlock().getRelative(BlockFace.DOWN); + + for (int x = -_currentRadius; x <= _currentRadius; x++) + { + for (int y = 0; y <= _currentRadius; y++) + { + for (int z = -_currentRadius; z <= _currentRadius; z++) + { + Block b = centerBlock.getRelative(x, y, z); + if (y > 0 && b.getType() == Material.SMOOTH_BRICK || b.getType() == Material.STEP || b.getType() == Material.SMOOTH_STAIRS) + { + _blockInfoList.add(new BlockInfo(b)); + b.setType(Material.AIR); + } + else if (b.getType() == Material.SMOOTH_BRICK) + { + Material newMaterial = getTreasure().getTreasureType() == TreasureType.HEROIC ? Material.NETHER_BRICK : Material.QUARTZ_BLOCK; + _blockInfoList.add(new BlockInfo(b)); + b.setType(newMaterial); + } + else if (b.getType() == Material.SMOOTH_STAIRS || b.getType() == Material.COBBLESTONE_STAIRS) + { + Material newMaterial = getTreasure().getTreasureType() == TreasureType.HEROIC ? Material.NETHER_BRICK_STAIRS : Material.QUARTZ_STAIRS; + _blockInfoList.add(new BlockInfo(b)); + b.setType(newMaterial); + } + } + } + } + _currentRadius++; + } + } + + @Override + protected void onFinish() + { + + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java index 434460ab0..c4298c5cf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java @@ -1,9 +1,8 @@ package mineplex.core.treasure.animation; -import java.util.HashSet; +import java.util.List; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; @@ -18,22 +17,39 @@ import mineplex.core.treasure.Treasure; */ public class ChestSpawnAnimation extends Animation { - private static final int ANIMATION_DURATION = 30; + private static final int ANIMATION_DURATION = 10; private Block _block; private byte _direction; private Location _centerLocation; - private HashSet _chestBlockInfo; + private List _chestBlockInfo; - public ChestSpawnAnimation(Treasure tresure, Block block, byte direction, HashSet chestBlockInfo) + public ChestSpawnAnimation(Treasure tresure, Block block, List chestBlockInfo) { super(tresure); _block = block; - _direction = direction; + int relX = getTreasure().getCenterBlock().getX() - block.getX(); + int relZ = getTreasure().getCenterBlock().getZ() - block.getZ(); + if (Math.abs(relX) > Math.abs(relZ)) + { + if (relX > 0) + _direction = (byte) 5; + else + _direction = (byte) 4; + } + else + { + if (relZ > 0) + _direction = (byte) 3; + else + _direction = (byte) 2; + } _centerLocation = block.getLocation().clone().add(0.5, 0.5, 0.5); _centerLocation.getWorld().playSound(_centerLocation, Sound.LAVA, 1, 1); _chestBlockInfo = chestBlockInfo; + + } @Override @@ -49,16 +65,16 @@ public class ChestSpawnAnimation extends Animation double lead = i * ((2d * Math.PI)/2); float x = (float) (Math.sin(getTicks()/4D + lead)); float z = (float) (Math.cos(getTicks()/4D + lead)); - UtilParticle.PlayParticle(getTreasure().getStyle().getSecondaryParticle(), _centerLocation.clone().add(x * width, y, z * width), 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), _centerLocation.clone().add(x * width, y, z * width), 0f, 0f, 0f, 0, 1); } if (getTicks() >= ANIMATION_DURATION) { _chestBlockInfo.add(new BlockInfo(_block)); - getTreasure().setBlock(_block, Material.CHEST, _direction); + getTreasure().setBlock(_block, getTreasure().getTreasureType().getMaterial(), _direction); _block.getLocation().getWorld().playSound(_centerLocation, Sound.ANVIL_LAND, 0.5f, 1f); - UtilParticle.ParticleType particleType = getTreasure().getStyle().getChestSpawnParticle(); + UtilParticle.ParticleType particleType = getTreasure().getTreasureType().getStyle().getChestSpawnParticle(); if (particleType != null) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ParticleAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ParticleAnimation.java index 40745a47f..9dc89ea02 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ParticleAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ParticleAnimation.java @@ -54,7 +54,7 @@ public class ParticleAnimation extends Animation { Vector position = PATH.get(pathPosition); - UtilParticle.PlayParticle(getTreasure().getStyle().getPrimaryParticle(), getTreasure().getCenterBlock().getLocation().add(0.5, 0, 0.5).add(position), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getPrimaryParticle(), getTreasure().getCenterBlock().getLocation().add(0.5, 0, 0.5).add(position), 0, 0, 0, 0, 1); pathPosition = (pathPosition + 1) % PATH.size(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/TreasureRemoveAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/TreasureRemoveAnimation.java index 74da014dd..a97d29f14 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/TreasureRemoveAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/TreasureRemoveAnimation.java @@ -1,6 +1,6 @@ package mineplex.core.treasure.animation; -import java.util.HashSet; +import java.util.List; import java.util.Random; import mineplex.core.treasure.BlockInfo; @@ -12,66 +12,38 @@ import mineplex.core.treasure.Treasure; public class TreasureRemoveAnimation extends Animation { private Random _random = new Random(); + private List _openedChests; + private List _otherChests; - private HashSet _wallsBlockInfo; - private HashSet _outerRingBlockInfo; - private HashSet _centerBlockInfo; - - public TreasureRemoveAnimation(Treasure treasure, HashSet centerBlockInfo, HashSet outerRingBlockInfo, HashSet wallsBlockInfo) + public TreasureRemoveAnimation(Treasure treasure, List openedChests, List otherChests) { super(treasure); - _wallsBlockInfo = wallsBlockInfo; - _centerBlockInfo = centerBlockInfo; - _outerRingBlockInfo = outerRingBlockInfo; + _openedChests = openedChests; + _otherChests = otherChests; } @Override protected void tick() { - // Chests go away at 100 ticks - HashSet blockInfoSet = null; - - if (getTicks() == 40) + if (getTicks() >= 20 && getTicks() % 10 == 0) { - blockInfoSet = _wallsBlockInfo; - } - else if (getTicks() == 50) - { - blockInfoSet = _outerRingBlockInfo; - } - else if (getTicks() == 60) - { - blockInfoSet = _centerBlockInfo; - } - - if (blockInfoSet != null) - { - getTreasure().resetBlockInfo(blockInfoSet); - } - - /* - if (getTicks() % 2 == 0) - { - if (_blockRestoreMap.size() > 4) + if (!_otherChests.isEmpty()) { - Block block; - do - { - Block[] keyArray = _blockRestoreMap.keySet().toArray(new Block[0]); - - block = keyArray[_random.nextInt(keyArray.length)]; - } - while (block.getType() == Material.CHEST); - - BlockInfo blockInfo = _blockRestoreMap.remove(block); - getTreasure().setBlock(block, Material.getMaterial(blockInfo.getId()), blockInfo.getData(), false); + BlockInfo info = _otherChests.remove(_random.nextInt(_otherChests.size())); + getTreasure().resetBlockInfo(info); +// System.out.println("otherchests"); } +// else if (!_openedChests.isEmpty()) +// { +// System.out.println("openchests"); +// BlockInfo info = _openedChests.remove(_random.nextInt(_openedChests.size())); +// getTreasure().resetBlockInfo(info); +// } else { finish(); } } - */ } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/OpenTreasureButton.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/OpenTreasureButton.java new file mode 100644 index 000000000..1914e2b8b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/OpenTreasureButton.java @@ -0,0 +1,30 @@ +package mineplex.core.treasure.gui; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import mineplex.core.treasure.TreasureLocation; +import mineplex.core.treasure.TreasureType; + +public class OpenTreasureButton implements IButton +{ + + private Player _player; + private TreasureLocation _treasureLocation; + private TreasureType _treasureType; + + public OpenTreasureButton(Player player, TreasureLocation treasureLocation, TreasureType treasureType) + { + _player = player; + _treasureLocation = treasureLocation; + _treasureType = treasureType; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _treasureLocation.attemptOpenTreasure(player, _treasureType); + player.closeInventory(); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java new file mode 100644 index 000000000..d8ebf78c9 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -0,0 +1,73 @@ +package mineplex.core.treasure.gui; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.donation.DonationManager; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.core.treasure.TreasureLocation; +import mineplex.core.treasure.TreasureManager; +import mineplex.core.treasure.TreasureType; + +public class TreasurePage extends ShopPageBase +{ + private TreasureLocation _treasureLocation; + private InventoryManager _inventoryManager; + + public TreasurePage(TreasureManager plugin, TreasureShop shop, TreasureLocation treasureLocation, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, Player player) + { + super(plugin, shop, clientManager, donationManager, "Open Treasure", player, 9); + + _treasureLocation = treasureLocation; + _inventoryManager = inventoryManager; + + BuildPage(); + } + + @Override + protected void BuildPage() + { + int basicCount = _inventoryManager.Get(Player).getItemCount(TreasureType.BASIC.getItemName()); + int heroicCount = _inventoryManager.Get(Player).getItemCount(TreasureType.HEROIC.getItemName()); + int legendaryCount = _inventoryManager.Get(Player).getItemCount(TreasureType.LEGENDARY.getItemName()); + + List basicLore = new ArrayList(); + basicLore.add(" "); + basicLore.add(F.value("Basic Chests Owned", "" + basicCount)); + basicLore.add(" "); + if (basicCount > 0) + basicLore.add(ChatColor.RESET + "Click to open!"); + + List heroicLore = new ArrayList(); + heroicLore.add(" "); + heroicLore.add(F.value("Heroic Chests Owned", "" + heroicCount)); + heroicLore.add(" "); + if (heroicCount > 0) + heroicLore.add(ChatColor.RESET + "Click to open!"); + + List legendaryLore = new ArrayList(); + legendaryLore.add(" "); + legendaryLore.add(F.value("Legendary Chests Owned", "" + legendaryCount)); + legendaryLore.add(" "); + if (legendaryCount > 0) + legendaryLore.add(ChatColor.RESET + "Click to open!"); + + + ShopItem basic = new ShopItem(Material.CHEST, C.cGreen + C.Bold + "Basic Chest", basicLore.toArray(new String[0]), 0, false, false); + ShopItem heroic = new ShopItem(Material.TRAPPED_CHEST, C.cGold + C.Bold + "Heroic Chest", heroicLore.toArray(new String[0]), 0, false, false); + ShopItem legendary = new ShopItem(Material.ENDER_CHEST, C.cRed + C.Bold + "Legendary Chest", legendaryLore.toArray(new String[0]), 0, false, false); + + AddButton(2, basic, new OpenTreasureButton(Player, _treasureLocation, TreasureType.BASIC)); + AddButton(4, heroic, new OpenTreasureButton(Player, _treasureLocation, TreasureType.HEROIC)); + AddButton(6, legendary, new OpenTreasureButton(Player, _treasureLocation, TreasureType.LEGENDARY)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasureShop.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasureShop.java new file mode 100644 index 000000000..644b94497 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasureShop.java @@ -0,0 +1,30 @@ +package mineplex.core.treasure.gui; + +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.core.treasure.TreasureLocation; +import mineplex.core.treasure.TreasureManager; + +public class TreasureShop extends ShopBase +{ + private TreasureLocation _treasureLocation; + private InventoryManager _inventoryManager; + + public TreasureShop(TreasureManager plugin, InventoryManager inventoryManager, CoreClientManager clientManager, DonationManager donationManager, TreasureLocation treasureLocation) + { + super(plugin, clientManager, donationManager, "Treasure Shop"); + _treasureLocation = treasureLocation; + _inventoryManager = inventoryManager; + } + + @Override + protected ShopPageBase> BuildPagesFor(Player player) + { + return new TreasurePage(Plugin, this, _treasureLocation, ClientManager, DonationManager, _inventoryManager, player); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 1b141a485..01f0ff5fa 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -1,5 +1,8 @@ package mineplex.game.clans; +import org.bukkit.plugin.java.JavaPlugin; +import net.minecraft.server.v1_7_R4.MinecraftServer; + import mineplex.core.account.CoreClientManager; import mineplex.core.antihack.AntiHack; import mineplex.core.blockrestore.BlockRestore; @@ -25,9 +28,6 @@ import mineplex.core.updater.Updater; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.shop.building.BuildingShop; import mineplex.game.clans.shop.pvp.PvpShop; -import net.minecraft.server.v1_7_R4.MinecraftServer; - -import org.bukkit.plugin.java.JavaPlugin; public class Clans extends JavaPlugin { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index d8016d055..03ff5fa6f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -45,7 +45,6 @@ import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; -import mineplex.core.benefit.BenefitManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.Rank; import mineplex.core.common.util.C; @@ -85,7 +84,6 @@ import mineplex.hub.commands.ForcefieldRadius; import mineplex.hub.commands.GadgetToggle; import mineplex.hub.commands.GameModeCommand; import mineplex.hub.commands.NewsCommand; -import mineplex.hub.mail.MailManager; import mineplex.hub.modules.ForcefieldManager; import mineplex.hub.modules.JumpManager; import mineplex.hub.modules.MapManager; @@ -95,7 +93,6 @@ import mineplex.hub.modules.TextManager; import mineplex.hub.modules.UHCManager; import mineplex.hub.modules.VisibilityManager; import mineplex.hub.modules.WorldManager; -import mineplex.hub.notification.NotificationManager; import mineplex.hub.party.Party; import mineplex.hub.party.PartyManager; import mineplex.hub.poll.PollManager; @@ -182,7 +179,7 @@ public class HubManager extends MiniClientPlugin _inventoryManager = new InventoryManager(plugin, clientManager); //new BenefitManager(plugin, clientManager, _inventoryManager); _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin)); - _treasureManager = new TreasureManager(_plugin, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager); + _treasureManager = new TreasureManager(_plugin, clientManager, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager); new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager); _petManager = petManager; From 6f8d39b630811327795303d97014b5726bb16a16 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 5 Feb 2015 22:34:06 +1300 Subject: [PATCH 11/27] Fixed spiders climbing liquids --- .../src/nautilus/game/arcade/kit/perks/PerkSpiderLeap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpiderLeap.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpiderLeap.java index 89d448661..af7879443 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpiderLeap.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpiderLeap.java @@ -71,7 +71,7 @@ public class PerkSpiderLeap extends Perk for (Block block : UtilBlock.getSurrounding(player.getLocation().getBlock(), true)) { - if (!UtilBlock.airFoliage(block)) + if (!UtilBlock.airFoliage(block) && !block.isLiquid()) { player.setVelocity(new Vector(0,0.2,0)); From 79cde8f5cf19b287cc072455b2e94015be73b974 Mon Sep 17 00:00:00 2001 From: Chiss Date: Thu, 5 Feb 2015 21:39:42 +1100 Subject: [PATCH 12/27] fixed util textbottom for 1.8.2 --- .../src/mineplex/core/common/util/UtilTextBottom.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTextBottom.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTextBottom.java index 56e4f6770..26300c36d 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTextBottom.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTextBottom.java @@ -46,7 +46,7 @@ public class UtilTextBottom amount = 1 - amount; //Generate Bar - int bars = 24; + int bars = 52; String progressBar = C.cGreen + ""; boolean colorChange = false; for (int i=0 ; i Date: Thu, 5 Feb 2015 23:42:26 +1300 Subject: [PATCH 13/27] Modify wizards to use | for bossbar displays --- .../src/nautilus/game/arcade/game/games/wizards/Wizards.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java index a7c2909c6..67d53f384 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java @@ -461,7 +461,7 @@ public class Wizards extends SoloGame private void displayProgress(String progressColor, String prefix, double amount, String suffix, Player... players) { // Generate Bar - int bars = 12; + int bars = 52; String progressBar = C.cGreen + ""; boolean colorChange = false; for (int i = 0; i < bars; i++) @@ -472,7 +472,7 @@ public class Wizards extends SoloGame colorChange = true; } - progressBar += "â–ˆ"; + progressBar += "|"; } // Send to Player From d878e3940e8b0b4c8f752447d3dd588cffc8d30b Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Thu, 5 Feb 2015 21:36:07 -0500 Subject: [PATCH 14/27] War state, handle time better, ability to have a server timezone (see ClanManager) --- .../game/clans/clans/ClansManager.java | 14 ++ .../mineplex/game/clans/clans/EnemyData.java | 17 +-- .../game/clans/clans/war/WarManager.java | 133 +++++++++++++----- .../game/clans/clans/war/WarState.java | 20 +++ .../clans/clans/war/WarStateChangeEvent.java | 39 +++++ 5 files changed, 173 insertions(+), 50 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarState.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarStateChangeEvent.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 850256d08..dd85820e3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -1,6 +1,7 @@ package mineplex.game.clans.clans; import java.util.HashSet; +import java.util.TimeZone; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -58,6 +59,8 @@ import mineplex.minecraft.game.core.mechanics.Weapon; public class ClansManager extends MiniClientPlugin implements IRelation { + private static final TimeZone TIME_ZONE = TimeZone.getDefault(); + private String _serverName; private CoreClientManager _clientManager; @@ -504,4 +507,15 @@ public class ClansManager extends MiniClientPlugin implements IRelat { return (energy / 4) + (energy % 4 == 0 ? 0 : 1); } + + /** + * Get the timezone for this server. + * This may be used in the future if we have + * clans servers with varying timezones. + * @return {@link java.util.TimeZone} that this server should run at + */ + public TimeZone getServerTimeZone() + { + return TIME_ZONE; + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java index 726fc11c3..fb9bb9d03 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/EnemyData.java @@ -36,25 +36,14 @@ public class EnemyData return _kills; } - public void addDeath() - { - addScore(-1); - } - - public void addKill() - { - addScore(1); - addKills(1); - } - - private void addScore(int add) + public void addScore(int add) { _score = Math.max(0, Math.min(_score + add, 40)); } - private void addKills(int add) + public void addKill() { - _kills += add; + _kills++; } public boolean isInitiator() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java index ec7e64f24..1d5437992 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java @@ -5,6 +5,7 @@ import java.util.Calendar; import java.util.Date; import java.util.LinkedList; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.PlayerDeathEvent; @@ -13,7 +14,10 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; @@ -24,10 +28,44 @@ public class WarManager extends MiniPlugin private final ClansManager _clansManager; + private WarState _warState; + public WarManager(JavaPlugin plugin, ClansManager clansManager) { super("War Manager", plugin); _clansManager = clansManager; + _warState = calculateWarState(); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOWEST) + return; + + WarState currentState = calculateWarState(); + + if (currentState != _warState) + { + WarStateChangeEvent warEvent = new WarStateChangeEvent(_warState, currentState); + UtilServer.getServer().getPluginManager().callEvent(warEvent); + _warState = currentState; + } + } + + private WarState calculateWarState() + { + // Get a calendar snapshot of the current time using server timezone + Calendar calendar = Calendar.getInstance(_clansManager.getServerTimeZone()); + + WarState warState = WarState.WAR; + + if (isEnemyTime(calendar)) + warState = WarState.FORM_ENEMIES; + else if (isInvadeTime(calendar)) + warState = WarState.INVADE; + + return warState; } public void attemptEnemy(Player player, ClanInfo initiatingClan, ClanInfo otherClan) @@ -39,7 +77,7 @@ public class WarManager extends MiniPlugin { String notifyMessage = null; - if (!isEnemyTime()) + if (_warState != WarState.FORM_ENEMIES) { notifyMessage = "Enemies cannot be formed at this time. Please see mineplex.com/clans for info"; } @@ -75,25 +113,30 @@ public class WarManager extends MiniPlugin { if (playerClan.getEnemyData() != null && playerClan.getEnemyData().getEnemyName().equalsIgnoreCase(killerClan.getName())) { - if (isWarInProgress()) + // Only adjust score if we are in WAR or FORM ENEMIES state. Once invasion begins score should never change + // Adjust kill stats no matter what war state we are in (so we track kills during invasion) + + if (_warState == WarState.WAR || _warState == WarState.FORM_ENEMIES) { - playerClan.getEnemyData().addDeath(); - killerClan.getEnemyData().addKill(); + playerClan.getEnemyData().addScore(-1); + killerClan.getEnemyData().addScore(1); } + + killerClan.getEnemyData().addKill(); } } } - /** - * Can enemies be formed at the current time - * - * Enemy forming will happen once a week during a set period - */ - private boolean isEnemyTime() - { - Calendar c = Calendar.getInstance(); + /** + * Check if a specific Calendar is currently in enemy time + * If this returns true, isInvadeTime should always return false for the same Calendar + * + * @param c {@link java.util.Calendar} instance that should be checked + */ + private boolean isEnemyTime(Calendar c) + { int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); if (dayOfWeek == CREATE_ENEMY_DATE) @@ -104,9 +147,14 @@ public class WarManager extends MiniPlugin return false; } - private boolean isInvadeTime() + /** + * Check if a specific Calendar is currently in invade time + * If this returns true, isEnemyTime should always return false for the same Calendar + * + * @param c {@link java.util.Calendar} instance that should be checked + */ + private boolean isInvadeTime(Calendar c) { - Calendar c = Calendar.getInstance(); int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); if (dayOfWeek == INVADE_ENEMY_DATE) @@ -116,24 +164,22 @@ public class WarManager extends MiniPlugin return false; } - private boolean isWarInProgress() - { - return !isInvadeTime(); - } - /** * Get the starting time of when enemies can be formed next * @return The enemy start time in the form of {@link java.util.Date} */ private Date getNextEnemyTime() { - Calendar c = Calendar.getInstance(); + Calendar c = Calendar.getInstance(_clansManager.getServerTimeZone()); + int currDayOfWeek = c.get(Calendar.DAY_OF_WEEK); + c.set(Calendar.DAY_OF_WEEK, CREATE_ENEMY_DATE); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); - c.add(Calendar.DATE, 7); + if (currDayOfWeek >= CREATE_ENEMY_DATE) + c.add(Calendar.DATE, 7); return c.getTime(); } @@ -144,17 +190,37 @@ public class WarManager extends MiniPlugin */ private Date getNextInvadeTime() { - Calendar c = Calendar.getInstance(); + Calendar c = Calendar.getInstance(_clansManager.getServerTimeZone()); + int currDayOfWeek = c.get(Calendar.DAY_OF_WEEK); + c.set(Calendar.DAY_OF_WEEK, INVADE_ENEMY_DATE); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); - c.add(Calendar.DATE, 7); + if (currDayOfWeek >= INVADE_ENEMY_DATE) + c.add(Calendar.DATE, 7); return c.getTime(); } + /** + * Get the current War State of the server + * War state determines what events are going on + * with respect to the current war. + */ + public WarState getWarState() + { + return _warState; + } + + @EventHandler + public void stateChange(WarStateChangeEvent event) + { + WarState state = event.getNewState(); + Bukkit.broadcastMessage(F.main("Clans", "War state changed: " + F.elem(state.getDescription()))); + } + /** * Send the current server time information to the player */ @@ -162,34 +228,29 @@ public class WarManager extends MiniPlugin { LinkedList messageList = new LinkedList(); - messageList.add(F.main("Clans", "Server Time;")); + messageList.add(F.main("Clans", "Server Time")); Date currDate = new Date(); SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy"); + dateFormat.setTimeZone(_clansManager.getServerTimeZone()); messageList.add(F.value("Server Time", dateFormat.format(currDate))); - if (isInvadeTime()) - { - messageList.add(F.elem("Winning clans can invade enemies right now")); - } - else + messageList.add(F.value("Status", _warState.getDescription())); + + if (_warState != WarState.INVADE) { long next = getNextInvadeTime().getTime(); long currTime = System.currentTimeMillis(); - messageList.add(F.value("Enemy Invasion", UtilTime.convertString(next - currTime, 1, UtilTime.TimeUnit.FIT))); + messageList.add(F.value("Invasion", UtilTime.convertString(next - currTime, 1, UtilTime.TimeUnit.FIT))); } - if (isEnemyTime()) - { - messageList.add(F.elem("Enemies can be formed at this time")); - } - else + if (_warState != WarState.FORM_ENEMIES) { long next = getNextEnemyTime().getTime(); long currTime = System.currentTimeMillis(); - messageList.add(F.value("Can Form Enemies In", UtilTime.convertString(next - currTime, 1, UtilTime.TimeUnit.FIT))); + messageList.add(F.value("Enemy Reset", UtilTime.convertString(next - currTime, 1, UtilTime.TimeUnit.FIT))); } return messageList; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarState.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarState.java new file mode 100644 index 000000000..e8bac93ea --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarState.java @@ -0,0 +1,20 @@ +package mineplex.game.clans.clans.war; + +public enum WarState +{ + FORM_ENEMIES("Enemies can now be formed"), + WAR("War is in progress"), + INVADE("Winning teams can invade enemies"); + + private String _description; + + WarState(String description) + { + _description = description; + } + + public String getDescription() + { + return _description; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarStateChangeEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarStateChangeEvent.java new file mode 100644 index 000000000..b525f63c5 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarStateChangeEvent.java @@ -0,0 +1,39 @@ +package mineplex.game.clans.clans.war; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class WarStateChangeEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private WarState _oldState; + private WarState _newState; + + public WarStateChangeEvent(WarState oldState, WarState newState) + { + _oldState = oldState; + _newState = newState; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public WarState getOldState() + { + return _oldState; + } + + public WarState getNewState() + { + return _newState; + } + +} \ No newline at end of file From 14fc6f2145a6876aca3114368851a56e4f5cf68d Mon Sep 17 00:00:00 2001 From: Chiss Date: Fri, 6 Feb 2015 14:16:10 +1100 Subject: [PATCH 15/27] Chest Update --- .../mineplex/core/reward/RewardManager.java | 22 +++- .../mineplex/core/reward/RewardRarity.java | 10 +- .../src/mineplex/core/reward/RewardType.java | 2 +- .../core/reward/rewards/RankReward.java | 56 ++++++++ .../src/mineplex/core/treasure/Treasure.java | 27 ++-- .../core/treasure/TreasureManager.java | 2 +- .../mineplex/core/treasure/TreasureStyle.java | 123 +++++------------- .../mineplex/core/treasure/TreasureType.java | 8 +- .../animation/BlockChangeAnimation.java | 2 +- .../animation/ChestSpawnAnimation.java | 76 ++++++++--- ...ation.java => LootLegendaryAnimation.java} | 23 ++-- .../animation/LootMythicalAnimation.java | 65 +++++++++ ...eAnimation.java => LootRareAnimation.java} | 14 +- ...mation.java => LootUncommonAnimation.java} | 17 +-- .../treasure/animation/ParticleAnimation.java | 2 +- .../src/mineplex/hub/HubManager.java | 1 + .../game/arcade/command/GameCommand.java | 2 +- .../game/arcade/command/SetCommand.java | 2 +- .../game/arcade/command/StartCommand.java | 2 +- .../game/arcade/kit/perks/PerkDoubleJump.java | 2 +- .../game/arcade/managers/GameLootManager.java | 18 ++- 21 files changed, 303 insertions(+), 173 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java rename Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/{LegendaryAnimation.java => LootLegendaryAnimation.java} (70%) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootMythicalAnimation.java rename Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/{RareAnimation.java => LootRareAnimation.java} (74%) rename Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/{UncommonAnimation.java => LootUncommonAnimation.java} (62%) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index 6d2b90bee..cb8db6608 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -12,12 +12,15 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.pet.PetManager; import mineplex.core.reward.rewards.CoinReward; import mineplex.core.reward.rewards.InventoryReward; import mineplex.core.reward.rewards.PetReward; +import mineplex.core.reward.rewards.RankReward; import mineplex.core.reward.rewards.UnknownPackageReward; public class RewardManager @@ -26,9 +29,11 @@ public class RewardManager private HashMap> _treasureMap; private Random _random; + private CoreClientManager _clientManager; + private boolean _doubleGadgetValue; - public RewardManager(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, + public RewardManager(CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, int commonValueMin, int commonValueMax, int uncommonValueMin, int uncommonValueMax, int rareValueMin, int rareValueMax, @@ -44,6 +49,8 @@ public class RewardManager _treasureMap.put(rarity, new ArrayList()); } + _clientManager = clientManager; + _doubleGadgetValue = doubleGadgetValue; addCommon(donationManager, inventoryManager, petManager, commonValueMin, commonValueMax); @@ -325,6 +332,19 @@ public class RewardManager { RewardRarity rarity = type.generateRarity(requiresUncommon); + //Dont give Rank Upgrade if already has Legend + if (rarity == RewardRarity.MYTHICAL) + { + if (_clientManager.Get(player).GetRank().Has(Rank.LEGEND)) + { + rarity = RewardRarity.LEGENDARY; + } + else + { + return new RankReward(_clientManager, 0, rarity); + } + } + List treasureList = _treasureMap.get(rarity); int totalWeight = 0; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java index 2754ad3c5..fc186ed03 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java @@ -15,11 +15,11 @@ public enum RewardRarity */ OTHER("Other", cWhite), - COMMON("Common", cAqua), - UNCOMMON("Uncommon", cGreen), - RARE("Rare", cGold), - LEGENDARY("Legendary", cRed), - MYTHICAL("Mythical", C.cBlack); + COMMON("Common", cWhite), + UNCOMMON("Uncommon", cAqua), + RARE("Rare", cPurple), + LEGENDARY("Legendary", cGreen), + MYTHICAL("Mythical", cRed); private String _name; private String _color; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java index 55b206e3a..a7d480b5a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java @@ -6,7 +6,7 @@ public enum RewardType GameLoot( 0.000001, 0.001, 0.004, 3), BasicChest( 0, 0.01, 0.04, 5), HeroicChest( 0, 1, 4, 25), - LegendaryChest( 1, 2, 8, 40); + LegendaryChest( 1, 2.5, 10, 40); private double _mythicalChance; private double _legendaryChance; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java new file mode 100644 index 000000000..92e8c8bdc --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java @@ -0,0 +1,56 @@ +package mineplex.core.reward.rewards; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.reward.Reward; +import mineplex.core.reward.RewardData; +import mineplex.core.reward.RewardRarity; + +public class RankReward extends Reward +{ + private CoreClientManager _clientManager; + + public RankReward(CoreClientManager clientManager, int weight, RewardRarity rarity) + { + super(rarity, weight); + + _clientManager = clientManager; + } + + + @Override + public RewardData giveRewardCustom(Player player) + { + Rank rank = null; + if (_clientManager.Get(player).GetRank() == Rank.ALL) rank = Rank.ULTRA; + else if (_clientManager.Get(player).GetRank() == Rank.ULTRA) rank = Rank.HERO; + else if (_clientManager.Get(player).GetRank() == Rank.HERO) rank = Rank.LEGEND; + + if (rank == null) + return new RewardData(getRarity().getColor() + "Rank Upgrade Error", new ItemStack(Material.PAPER)); + + _clientManager.Get(player).SetRank(rank); + _clientManager.getRepository().saveRank(null, player.getName(), rank, true); + + return new RewardData(getRarity().getColor() + rank.Name + " Rank", new ItemStack(Material.NETHER_STAR)); + } + + @Override + public boolean canGiveReward(Player player) + { + return !_clientManager.Get(player).GetRank().Has(Rank.LEGEND); + } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof RankReward) + return true; + + return false; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java index abef020d7..43584d990 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java @@ -27,10 +27,11 @@ import mineplex.core.treasure.animation.Animation; import mineplex.core.treasure.animation.BlockChangeAnimation; import mineplex.core.treasure.animation.ChestOpenAnimation; import mineplex.core.treasure.animation.ChestSpawnAnimation; -import mineplex.core.treasure.animation.LegendaryAnimation; -import mineplex.core.treasure.animation.RareAnimation; +import mineplex.core.treasure.animation.LootLegendaryAnimation; +import mineplex.core.treasure.animation.LootMythicalAnimation; +import mineplex.core.treasure.animation.LootRareAnimation; import mineplex.core.treasure.animation.TreasureRemoveAnimation; -import mineplex.core.treasure.animation.UncommonAnimation; +import mineplex.core.treasure.animation.LootUncommonAnimation; /** * Created by Shaun on 8/27/2014. @@ -108,13 +109,12 @@ public class Treasure if (_tickCount % 10 == 0 && _currentChest < _chestData.length) { - Block block = _chestData[_currentChest].getBlock(); - ChestSpawnAnimation chestSpawn = new ChestSpawnAnimation(this, block, _chestBlockInfo); + ChestSpawnAnimation chestSpawn = new ChestSpawnAnimation(this,_chestData[_currentChest].getBlock(), _chestBlockInfo, _centerBlock, _currentChest); _animations.add(chestSpawn); - _currentChest++; } + //Auto-open after 1 minute if (_tickCount == 60 * 20) { for (BlockInfo blockInfo : _chestBlockInfo) @@ -192,17 +192,22 @@ public class Treasure // Extra effects based off the rarity of the treasure if (reward.getRarity() == RewardRarity.UNCOMMON) { - _animations.add(new UncommonAnimation(this, data.getBlock())); + _animations.add(new LootUncommonAnimation(this, data.getBlock())); } else if (reward.getRarity() == RewardRarity.RARE) { - _animations.add(new RareAnimation(this, data.getBlock().getLocation().add(0.5, 1.5, 0.5))); - Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cGold + "Rare " + rewardData.getFriendlyName())); + _animations.add(new LootRareAnimation(this, data.getBlock().getLocation().add(0.5, 1.5, 0.5))); + Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cPurple + "Rare " + rewardData.getFriendlyName())); } else if (reward.getRarity() == RewardRarity.LEGENDARY) { - _animations.add(new LegendaryAnimation(this, data.getBlock())); - Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cRed + "Legendary " + rewardData.getFriendlyName())); + _animations.add(new LootLegendaryAnimation(this, data.getBlock())); + Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cGreen + "Legendary " + rewardData.getFriendlyName())); + } + else if (reward.getRarity() == RewardRarity.MYTHICAL) + { + _animations.add(new LootMythicalAnimation(this, data.getBlock())); + Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cRed + "Mythical " + rewardData.getFriendlyName())); } if (isFinished()) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java index dbcf16f21..518e1adf0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java @@ -39,7 +39,7 @@ public class TreasureManager extends MiniPlugin _inventoryManager = inventoryManager; _blockRestore = blockRestore; _hologramManager = hologramManager; - _rewardManager = new RewardManager(donationManager, inventoryManager, petManager, + _rewardManager = new RewardManager(clientManager, donationManager, inventoryManager, petManager, 100, 250, 500, 1000, 1500, 2500, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java index e1cf20d15..35bb83239 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java @@ -1,6 +1,7 @@ package mineplex.core.treasure; import org.bukkit.Material; +import org.bukkit.Sound; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -12,103 +13,37 @@ public enum TreasureStyle /** * These are examples, not final! */ - NETHER(Material.NETHERRACK, (byte) 0, - Material.NETHER_BRICK, (byte) 0, - Material.NETHER_FENCE, (byte) 0, - null, + + + BASIC( + ParticleType.EXPLODE, + ParticleType.EXPLODE, + Sound.FIZZ, + Sound.HORSE_ARMOR), + + HEROIC( ParticleType.FLAME, - ParticleType.LAVA), - - NATURE(Material.GRASS, (byte) 0, - Material.LOG, (byte) 0, - Material.LEAVES, (byte) 0, - null, + ParticleType.LAVA, + Sound.LAVA_POP, + Sound.EXPLODE), + + LEGENDARY( ParticleType.HAPPY_VILLAGER, - ParticleType.SLIME), + ParticleType.LARGE_EXPLODE, + Sound.PORTAL_TRAVEL, + Sound.ANVIL_BREAK); - WATER(Material.ICE,(byte) 9, - Material.PACKED_ICE, (byte) 5, - Material.STAINED_GLASS_PANE, (byte) 8, - null, - ParticleType.SNOW_SHOVEL, - ParticleType.SNOWBALL_POOF); - -// FANCY(Material.DIAMOND_BLOCK,(byte) 0, -// Material.GOLD_BLOCK, (byte) 0, -// Material.AIR, (byte) 0, -// ParticleType.FLAME, -// ParticleType.CLOUD, -// ParticleType.LAVA), -// -// FANCY_2(Material.IRON_BLOCK,(byte) 0, -// Material.EMERALD_BLOCK, (byte) 0, -// Material.AIR, (byte) 0, -// ParticleType.FLAME, -// ParticleType.HAPPY_VILLAGER, -// null); - - private Material _primaryMaterial; - private byte _primaryData; - - private Material _secondaryMaterial; - private byte _secondaryData; - - private Material _wallMaterial; - private byte _wallData; - - private ParticleType _primaryParticle; private ParticleType _secondaryParticle; private ParticleType _chestSpawnParticle; - - TreasureStyle(Material primaryMaterial, byte primaryData, Material secondaryMaterial, byte secondaryData, Material wallMaterial, byte wallData, ParticleType primaryParticle, ParticleType secondaryParticle, ParticleType chestSpawnParticle) + private Sound _sound; + private Sound _chestSpawnSound; + + TreasureStyle(ParticleType secondaryParticle, ParticleType chestSpawnParticle, Sound sound, Sound chestSpawnSound) { - _primaryMaterial = primaryMaterial; - _primaryData = primaryData; - - _secondaryMaterial = secondaryMaterial; - _secondaryData = secondaryData; - - _wallMaterial = wallMaterial; - _wallData = wallData; - - _primaryParticle = primaryParticle; _secondaryParticle = secondaryParticle; _chestSpawnParticle = chestSpawnParticle; - } - - public Material getPrimaryMaterial() - { - return _primaryMaterial; - } - - public byte getPrimaryData() - { - return _primaryData; - } - - public Material getSecondaryMaterial() - { - return _secondaryMaterial; - } - - public byte getSecondaryData() - { - return _secondaryData; - } - - public Material getWallMaterial() - { - return _wallMaterial; - } - - public byte getWallData() - { - return _wallData; - } - - public ParticleType getPrimaryParticle() - { - return _primaryParticle; + _sound = sound; + _chestSpawnSound = chestSpawnSound; } public ParticleType getSecondaryParticle() @@ -120,4 +55,14 @@ public enum TreasureStyle { return _chestSpawnParticle; } + + public Sound getSound() + { + return _sound; + } + + public Sound getChestSpawnSound() + { + return _chestSpawnSound; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java index f20665227..6cff3e970 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java @@ -7,9 +7,11 @@ import mineplex.core.reward.RewardType; public enum TreasureType { - BASIC(C.cYellow + "Basic Chest", "Basic Chest", RewardType.BasicChest, Material.CHEST, TreasureStyle.NATURE), - HEROIC(C.cGold + "Heroic Chest", "Heroic Chest", RewardType.HeroicChest, Material.TRAPPED_CHEST, TreasureStyle.WATER), - LEGENDARY(C.cRed + "Legendary Chest", "Legendary Chest", RewardType.LegendaryChest, Material.ENDER_CHEST, TreasureStyle.NETHER); + BASIC(C.cYellow + "Basic Chest", "Basic Chest", RewardType.BasicChest, Material.CHEST, TreasureStyle.BASIC), + + HEROIC(C.cGold + "Heroic Chest", "Heroic Chest", RewardType.HeroicChest, Material.TRAPPED_CHEST, TreasureStyle.HEROIC), + + LEGENDARY(C.cRed + "Legendary Chest", "Legendary Chest", RewardType.LegendaryChest, Material.ENDER_CHEST, TreasureStyle.LEGENDARY); private final String _name; private final RewardType _rewardType; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java index a413dff77..8cf206761 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java @@ -44,7 +44,7 @@ public class BlockChangeAnimation extends Animation for (int z = -_currentRadius; z <= _currentRadius; z++) { Block b = centerBlock.getRelative(x, y, z); - if (y > 0 && b.getType() == Material.SMOOTH_BRICK || b.getType() == Material.STEP || b.getType() == Material.SMOOTH_STAIRS) + if (y > 0 && (b.getType() == Material.SMOOTH_BRICK || b.getType() == Material.STEP || b.getType() == Material.SMOOTH_STAIRS)) { _blockInfoList.add(new BlockInfo(b)); b.setType(Material.AIR); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java index c4298c5cf..eff3d533a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java @@ -2,30 +2,43 @@ package mineplex.core.treasure.animation; import java.util.List; +import org.bukkit.Effect; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.util.Vector; + import net.minecraft.server.v1_7_R4.MathHelper; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.treasure.BlockInfo; import mineplex.core.treasure.Treasure; +import mineplex.core.treasure.TreasureType; /** * Created by Shaun on 8/29/2014. */ public class ChestSpawnAnimation extends Animation { - private static final int ANIMATION_DURATION = 10; + private static final int ANIMATION_DURATION = 80; private Block _block; private byte _direction; private Location _centerLocation; + + private Location _particleLocation; + private Vector _particleDirection; private List _chestBlockInfo; + + private double _radialOffset; - public ChestSpawnAnimation(Treasure tresure, Block block, List chestBlockInfo) + public ChestSpawnAnimation(Treasure tresure, Block block, List chestBlockInfo, Block openingCenter, double radialOffset) { super(tresure); _block = block; @@ -36,7 +49,7 @@ public class ChestSpawnAnimation extends Animation if (relX > 0) _direction = (byte) 5; else - _direction = (byte) 4; + _direction = (byte) 4; } else { @@ -45,11 +58,17 @@ public class ChestSpawnAnimation extends Animation else _direction = (byte) 2; } + _centerLocation = block.getLocation().clone().add(0.5, 0.5, 0.5); - _centerLocation.getWorld().playSound(_centerLocation, Sound.LAVA, 1, 1); _chestBlockInfo = chestBlockInfo; - - + + _particleLocation = openingCenter.getLocation().add(0.5, 4, 0.5); + + _particleDirection = UtilAlg.getTrajectory(_particleLocation, _centerLocation); + _particleDirection.multiply(UtilMath.offset(_particleLocation, _centerLocation) / (double)ANIMATION_DURATION); + + + _radialOffset = radialOffset; } @Override @@ -57,22 +76,47 @@ public class ChestSpawnAnimation extends Animation { float scale = (float)((double)(ANIMATION_DURATION - getTicks()) / (double)ANIMATION_DURATION); - float y = 5 * scale; - double width = 1.4 * ((double) getTicks() / (double) ANIMATION_DURATION); - - for (int i=0 ; i < 2 ; i++) + //Move Paticle Forwards + _particleLocation.add(_particleDirection); + + //Play Particels + if (getTreasure().getTreasureType() == TreasureType.BASIC) { - double lead = i * ((2d * Math.PI)/2); - float x = (float) (Math.sin(getTicks()/4D + lead)); - float z = (float) (Math.cos(getTicks()/4D + lead)); - UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), _centerLocation.clone().add(x * width, y, z * width), 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), _centerLocation, 0.1f, 0.1f, 0.1f, 0, 1); } - + else if (getTreasure().getTreasureType() == TreasureType.HEROIC) + { + float x = (float) (Math.sin(getTicks()/4D)); + float z = (float) (Math.cos(getTicks()/4D)); + + Location newLoc = _particleLocation.clone(); + newLoc.add(UtilAlg.getLeft(_particleDirection).multiply(x * scale)); + newLoc.add(UtilAlg.getUp(_particleDirection).multiply(z * scale)); + + UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), newLoc, 0f, 0f, 0f, 0, 1); + } + else if (getTreasure().getTreasureType() == TreasureType.LEGENDARY) + { + float y = 5 * scale; + double width = 0.7 * ((double) getTicks() / (double) ANIMATION_DURATION); + + for (int i=0 ; i < 2 ; i++) + { + double lead = i * ((2d * Math.PI)/2); + + float x = (float) (Math.sin(getTicks()/4D + lead)); + float z = (float) (Math.cos(getTicks()/4D + lead)); + + UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), _centerLocation.clone().add(x * width, y, z * width), 0f, 0f, 0f, 0, 1); + } + } + + //Spawn Chest if (getTicks() >= ANIMATION_DURATION) { _chestBlockInfo.add(new BlockInfo(_block)); getTreasure().setBlock(_block, getTreasure().getTreasureType().getMaterial(), _direction); - _block.getLocation().getWorld().playSound(_centerLocation, Sound.ANVIL_LAND, 0.5f, 1f); + _block.getLocation().getWorld().playSound(_centerLocation, getTreasure().getTreasureType().getStyle().getChestSpawnSound(), 0.5f, 1f); UtilParticle.ParticleType particleType = getTreasure().getTreasureType().getStyle().getChestSpawnParticle(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LegendaryAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootLegendaryAnimation.java similarity index 70% rename from Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LegendaryAnimation.java rename to Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootLegendaryAnimation.java index 4c3a31c7e..7cd5e4742 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LegendaryAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootLegendaryAnimation.java @@ -6,6 +6,7 @@ import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.Location; import org.bukkit.Sound; +import org.bukkit.FireworkEffect.Type; import org.bukkit.block.Block; import mineplex.core.common.util.UtilFirework; @@ -15,7 +16,7 @@ import mineplex.core.treasure.Treasure; /** * Created by shaun on 14-09-12. */ -public class LegendaryAnimation extends Animation +public class LootLegendaryAnimation extends Animation { /** * Played when a "Very Rare" chest is opened @@ -24,7 +25,7 @@ public class LegendaryAnimation extends Animation private Random _random = new Random(); private Block _chestBlock; - public LegendaryAnimation(Treasure treasure, Block chestBlock) + public LootLegendaryAnimation(Treasure treasure, Block chestBlock) { super(treasure); @@ -34,18 +35,16 @@ public class LegendaryAnimation extends Animation @Override protected void tick() { + if (getTicks() < 12 && getTicks() % 3 == 0) + { + UtilFirework.playFirework(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.LIME, true, true); + } + if (getTicks() == 1) { -// _chestBlock.getLocation().getWorld().playSound(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Sound.WITHER_SPAWN, 10F, 1.2F); _chestBlock.getLocation().getWorld().playSound(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F); } - if (getTicks() == 20) - { - FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(Color.RED).withFade(Color.BLACK).build(); - UtilFirework.playFirework(_chestBlock.getLocation().add(0.5, 0.5, 0.5), effect); -// ((CraftWorld) _chestBlock.getWorld()).getHandle().triggerEffect(1005, _chestBlock.getX(), _chestBlock.getY(), _chestBlock.getZ(), 2257); - } - else if (getTicks() < 15) + else if (getTicks() < 35) { double radius = 2 - (getTicks() / 10D * 2); int particleAmount = 20 - (getTicks() * 2); @@ -56,10 +55,10 @@ public class LegendaryAnimation extends Animation double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius; Location location = _centerLocation.clone().add(xDiff, 0, zDiff); - UtilParticle.PlayParticle(UtilParticle.ParticleType.CLOUD, location, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0, 1); } } - else if (getTicks() < 20) + else if (getTicks() < 40) { double xDif = _random.nextGaussian() * 0.5; double zDif = _random.nextGaussian() * 0.5; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootMythicalAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootMythicalAnimation.java new file mode 100644 index 000000000..bdb720f4c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootMythicalAnimation.java @@ -0,0 +1,65 @@ +package mineplex.core.treasure.animation; + +import java.util.Random; + +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.block.Block; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.treasure.Treasure; + +/** + * Created by shaun on 14-09-12. + */ +public class LootMythicalAnimation extends Animation +{ + /** + * Played when a "Very Rare" chest is opened + */ + + private Random _random = new Random(); + private Block _chestBlock; + + public LootMythicalAnimation(Treasure treasure, Block chestBlock) + { + super(treasure); + + _chestBlock = chestBlock; + } + + @Override + protected void tick() + { + if (getTicks() < 30 && getTicks() % 3 == 0) + { + UtilFirework.playFirework(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true); + } + + if (getTicks() == 1) + { + _chestBlock.getLocation().getWorld().playSound(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Sound.PORTAL_TRAVEL, 10F, 2.0F); + _chestBlock.getLocation().getWorld().playSound(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Sound.ZOMBIE_UNFECT, 10F, 0.1F); + } + else if (getTicks() < 60) + { + UtilFirework.launchFirework(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true, + new Vector((Math.random()-0.5)*0.05, 0.1, (Math.random()-0.5)*0.05), 1); + } + else + { + finish(); + } + } + + @Override + protected void onFinish() + { + + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/RareAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootRareAnimation.java similarity index 74% rename from Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/RareAnimation.java rename to Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootRareAnimation.java index c43ced09a..33aadf2f0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/RareAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootRareAnimation.java @@ -4,6 +4,7 @@ import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.Location; import org.bukkit.Sound; +import org.bukkit.FireworkEffect.Type; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilParticle; @@ -12,7 +13,7 @@ import mineplex.core.treasure.Treasure; /** * Created by shaun on 2014-09-09. */ -public class RareAnimation extends Animation +public class LootRareAnimation extends Animation { /** * Played when a "Rare" chest is opened @@ -20,7 +21,7 @@ public class RareAnimation extends Animation private Location _centerLocation; - public RareAnimation(Treasure treasure, Location centerLocation) + public LootRareAnimation(Treasure treasure, Location centerLocation) { super(treasure); @@ -32,7 +33,8 @@ public class RareAnimation extends Animation { if (getTicks() == 2) { - UtilFirework.playFirework(_centerLocation, FireworkEffect.builder().withColor(Color.ORANGE).with(FireworkEffect.Type.BURST).build()); + UtilFirework.playFirework(_centerLocation, Type.BALL, Color.FUCHSIA, false, false); + _centerLocation.getWorld().playSound(_centerLocation, Sound.WITHER_SPAWN, 10F, 1.2F); } else if (getTicks() >= 60) @@ -40,6 +42,7 @@ public class RareAnimation extends Animation finish(); } + //Particle Ground { double currentRotation = getTicks() / 20D; double radius = currentRotation; @@ -49,9 +52,10 @@ public class RareAnimation extends Animation Location location = _centerLocation.clone().add(xDiff, yDiff, zDiff); - UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, location, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1); } + //Particle Spiral Up double radius = getTicks() / 20D; int particleAmount = getTicks() / 2; for (int i = 0; i < particleAmount; i++) @@ -60,7 +64,7 @@ public class RareAnimation extends Animation double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius; Location location = _centerLocation.clone().add(xDiff, -1.3, zDiff); - UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, location, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/UncommonAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootUncommonAnimation.java similarity index 62% rename from Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/UncommonAnimation.java rename to Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootUncommonAnimation.java index 0fbcb55b7..3c3fdec93 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/UncommonAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootUncommonAnimation.java @@ -4,6 +4,7 @@ import java.util.Random; import org.bukkit.Color; import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; import org.bukkit.block.Block; import mineplex.core.common.util.UtilFirework; @@ -13,7 +14,7 @@ import mineplex.core.treasure.Treasure; /** * Created by shaun on 2014-09-09. */ -public class UncommonAnimation extends Animation +public class LootUncommonAnimation extends Animation { /** * Played when an "Uncommon" chest is opened @@ -22,7 +23,7 @@ public class UncommonAnimation extends Animation private Random _random = new Random(); private Block _block; - public UncommonAnimation(Treasure treasure, Block block) + public LootUncommonAnimation(Treasure treasure, Block block) { super(treasure); @@ -37,22 +38,12 @@ public class UncommonAnimation extends Animation if (getTicks() == 10) { - double xDif = 0;//_random.nextGaussian() * 1; - double zDif = 0;//_random.nextGaussian() * 1; - double yDif = 2;//(_random.nextInt(3) * _random.nextDouble()) + 2; - - FireworkEffect effect = FireworkEffect.builder().withColor(Color.RED) - .withFade(Color.fromRGB(_random.nextInt(255), _random.nextInt(255), _random.nextInt(255))) - .with(FireworkEffect.Type.STAR) - .build(); - - UtilFirework.playFirework(_block.getLocation().add(0.5, 0.5, 0.5).add(xDif, yDif, zDif), effect); + UtilFirework.playFirework(_block.getLocation().add(0.5, 0.5, 0.5), Type.BURST, Color.AQUA, false, false); } else if (getTicks() % 2 == 0) { UtilParticle.PlayParticle(UtilParticle.ParticleType.HEART, _block.getLocation().add(0.5, 1.2, 0.5), 0.5F, 0.2F, 0.5F, 0, 1); } - } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ParticleAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ParticleAnimation.java index 9dc89ea02..7c600900d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ParticleAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ParticleAnimation.java @@ -54,7 +54,7 @@ public class ParticleAnimation extends Animation { Vector position = PATH.get(pathPosition); - UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getPrimaryParticle(), getTreasure().getCenterBlock().getLocation().add(0.5, 0, 0.5).add(position), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), getTreasure().getCenterBlock().getLocation().add(0.5, 0, 0.5).add(position), 0, 0, 0, 0, 1); pathPosition = (pathPosition + 1) % PATH.size(); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 03ff5fa6f..39bd94ed4 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -75,6 +75,7 @@ import mineplex.core.pet.PetManager; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; +import mineplex.core.recharge.Recharge; import mineplex.core.stats.StatsManager; import mineplex.core.task.TaskManager; import mineplex.core.treasure.TreasureManager; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java index e1cc12a87..08887dde8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java @@ -10,7 +10,7 @@ public class GameCommand extends MultiCommandBase { public GameCommand(ArcadeManager plugin) { - super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPDEV}, "game"); + super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPLEAD}, "game"); AddCommand(new StartCommand(Plugin)); AddCommand(new StopCommand(Plugin)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java index 4e688bfe0..b4fc74c58 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java @@ -17,7 +17,7 @@ public class SetCommand extends CommandBase { public SetCommand(ArcadeManager plugin) { - super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPDEV}, "set"); + super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPLEAD}, "set"); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java index a57fd55d2..79a38a797 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java @@ -12,7 +12,7 @@ public class StartCommand extends CommandBase { public StartCommand(ArcadeManager plugin) { - super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPDEV}, "start"); + super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPLEAD}, "start"); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDoubleJump.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDoubleJump.java index c0b1cc2f3..1722b453a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDoubleJump.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDoubleJump.java @@ -98,7 +98,7 @@ public class PerkDoubleJump extends Perk Recharge.Instance.setDisplayForce(player, GetName(), true); } } - } + } @EventHandler public void FlightUpdate(UpdateEvent event) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java index 0ae1d8fa4..38c161767 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java @@ -21,7 +21,6 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.pet.PetManager; @@ -51,7 +50,7 @@ public class GameLootManager implements Listener Manager.GetPluginManager().registerEvents(this, Manager.GetPlugin()); - _rewardManager = new RewardManager(Manager.GetDonation(), Manager.getInventoryManager(), petManager, + _rewardManager = new RewardManager(Manager.GetClients(), Manager.GetDonation(), Manager.getInventoryManager(), petManager, 100, 250, 500, 1000, 1500, 2500, @@ -59,15 +58,14 @@ public class GameLootManager implements Listener false); //Chest - _rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Treasure Chest", "Treasure Chest", 1, 1, - new ItemStack(Material.CHEST), RewardRarity.COMMON, 4)); - - _rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Treasure Chest", "Treasure Chest", 1, 2, - new ItemStack(Material.CHEST), RewardRarity.COMMON, 1)); + _rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Basic Chest", "Basic Chest", 1, 1, + new ItemStack(Material.CHEST), RewardRarity.UNCOMMON, 1000)); - //Key - _rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Treasure Key", "Treasure Key", 1, 1, - new ItemStack(Material.DIAMOND), RewardRarity.UNCOMMON, 1000)); + _rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Heroic Chest", "Heroic Chest", 1, 1, + new ItemStack(Material.CHEST), RewardRarity.UNCOMMON, 40)); + + _rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Legendary Chest", "Legendary Chest", 1, 1, + new ItemStack(Material.CHEST), RewardRarity.UNCOMMON, 1)); } @EventHandler From 417122b7a7912148aae768c9a3ebb7b4d507788d Mon Sep 17 00:00:00 2001 From: Chiss Date: Fri, 6 Feb 2015 14:47:34 +1100 Subject: [PATCH 16/27] reduced rate that smash crystal spawns --- .../src/nautilus/game/arcade/game/games/smash/SuperSmash.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java index 72f65ca55..174dcfd5b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java @@ -142,7 +142,7 @@ public class SuperSmash extends SoloGame for (Player player : GetPlayers(true)) _lives.put(player, 4); - _nextPowerup = (long) (System.currentTimeMillis() + 120000 + 180000 * Math.random()); + _nextPowerup = (long) (System.currentTimeMillis() + 240000 + 360000 * Math.random()); } @EventHandler @@ -333,7 +333,7 @@ public class SuperSmash extends SoloGame best.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.NETHER_STAR, (byte)0, ((SmashKit)GetKit(best)).getSuperCharges(), C.cYellow + C.Bold + "Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + ((SmashKit)GetKit(best)).getSuperName())); - _nextPowerup = (long) (System.currentTimeMillis() + 120000 + 180000 * Math.random()); + _nextPowerup = (long) (System.currentTimeMillis() + 240000 + 360000 * Math.random()); Manager.GetGame().Announce(C.Bold + best.getName() + " collected " + C.cGreen + C.Bold + "Smash Crystal" + ChatColor.RESET + C.Bold + "!"); } From 2f64b5f40175f5173eba08f7f0b6efcc68b0f644 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Thu, 5 Feb 2015 23:09:20 -0500 Subject: [PATCH 17/27] 1.8 tablist fix - spigot needs to be updated! --- .../v1_7_R4/PacketPlayOutPlayerInfo.java | 157 ++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 Plugins/Classpath.Dummy/src/net/minecraft/server/v1_7_R4/PacketPlayOutPlayerInfo.java diff --git a/Plugins/Classpath.Dummy/src/net/minecraft/server/v1_7_R4/PacketPlayOutPlayerInfo.java b/Plugins/Classpath.Dummy/src/net/minecraft/server/v1_7_R4/PacketPlayOutPlayerInfo.java new file mode 100644 index 000000000..28744fa09 --- /dev/null +++ b/Plugins/Classpath.Dummy/src/net/minecraft/server/v1_7_R4/PacketPlayOutPlayerInfo.java @@ -0,0 +1,157 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by Fernflower decompiler) +// + +package net.minecraft.server.v1_7_R4; + +import java.io.IOException; +import java.util.Iterator; + +import org.bukkit.craftbukkit.v1_7_R4.scoreboard.CraftScoreboard; +import org.bukkit.craftbukkit.v1_7_R4.util.CraftChatMessage; +import org.bukkit.scoreboard.Team; +import net.minecraft.util.com.mojang.authlib.GameProfile; +import net.minecraft.util.com.mojang.authlib.properties.Property; +import net.minecraft.util.com.mojang.authlib.properties.PropertyMap; + +public class PacketPlayOutPlayerInfo extends Packet { + public static final int ADD_PLAYER = 0; + public static final int UPDATE_GAMEMODE = 1; + public static final int UPDATE_LATENCY = 2; + public static final int UPDATE_DISPLAY_NAME = 3; + public static final int REMOVE_PLAYER = 4; + public int action; + public GameProfile player; + public int gamemode; + public int ping; + public String username; + public String _tabName; + + public PacketPlayOutPlayerInfo() { + } + + public static PacketPlayOutPlayerInfo addPlayer(EntityPlayer player) { + PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(); + packet.action = 0; + packet.username = player.listName; + packet.player = player.getProfile(); + packet.ping = player.ping; + packet.gamemode = player.playerInteractManager.getGameMode().getId(); + packet._tabName = getFormattedName(player); + return packet; + } + + public static PacketPlayOutPlayerInfo updatePing(EntityPlayer player) { + PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(); + packet.action = 2; + packet.username = player.listName; + packet.player = player.getProfile(); + packet.ping = player.ping; + return packet; + } + + public static PacketPlayOutPlayerInfo updateGamemode(EntityPlayer player) { + PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(); + packet.action = 1; + packet.username = player.listName; + packet.player = player.getProfile(); + packet.gamemode = player.playerInteractManager.getGameMode().getId(); + return packet; + } + + public static PacketPlayOutPlayerInfo updateDisplayName(EntityPlayer player) { + PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(); + packet.action = 3; + packet.username = player.listName; + packet.player = player.getProfile(); + packet._tabName = getFormattedName(player); + return packet; + } + + public static PacketPlayOutPlayerInfo removePlayer(EntityPlayer player) { + PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(); + packet.action = 4; + packet.username = player.listName; + packet.player = player.getProfile(); + return packet; + } + + public void a(PacketDataSerializer packetdataserializer) throws IOException { + } + + public void b(PacketDataSerializer packetdataserializer) throws IOException { + if(packetdataserializer.version >= 20) { + packetdataserializer.b(this.action); + packetdataserializer.b(1); + packetdataserializer.writeUUID(this.player.getId()); + switch(this.action) { + case 0: + packetdataserializer.a(this.player.getName()); + PropertyMap properties = this.player.getProperties(); + packetdataserializer.b(properties.size()); + Iterator var3 = properties.values().iterator(); + + while(var3.hasNext()) { + Property property = (Property)var3.next(); + packetdataserializer.a(property.getName()); + packetdataserializer.a(property.getValue()); + packetdataserializer.writeBoolean(property.hasSignature()); + if(property.hasSignature()) { + packetdataserializer.a(property.getSignature()); + } + } + + packetdataserializer.b(this.gamemode); + packetdataserializer.b(this.ping); + packetdataserializer.writeBoolean(this.username != null); + if(this.username != null) { +// packetdataserializer.a(ChatSerializer.a(CraftChatMessage.fromString(this.username)[0])); + packetdataserializer.a(ChatSerializer.a(CraftChatMessage.fromString(this._tabName)[0])); + } + break; + case 1: + packetdataserializer.b(this.gamemode); + break; + case 2: + packetdataserializer.b(this.ping); + break; + case 3: + packetdataserializer.writeBoolean(this.username != null); + if(this.username != null) { +// packetdataserializer.a(ChatSerializer.a(CraftChatMessage.fromString(this.username)[0])); + packetdataserializer.a(ChatSerializer.a(CraftChatMessage.fromString(this._tabName)[0])); + } + case 4: + } + } else { + packetdataserializer.a(this.username); + packetdataserializer.writeBoolean(this.action != 4); + packetdataserializer.writeShort(this.ping); + } + + } + + public void a(PacketPlayOutListener packetplayoutlistener) { + packetplayoutlistener.a(this); + } + + public void handle(PacketListener packetlistener) { + this.a((PacketPlayOutListener)((PacketPlayOutListener)packetlistener)); + } + + private static String getFormattedName(EntityPlayer player) + { + String name = player.getName(); + + CraftScoreboard scoreboard = player.getBukkitEntity().getScoreboard(); + if (scoreboard != null) + { + Team team = scoreboard.getPlayerTeam(player.getBukkitEntity()); + if (team != null) + name = team.getPrefix() + name + team.getSuffix(); + } + + return name; + } +} From fcb3d20778fb1776fcd8572fd72d9aa4ce682b06 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Thu, 5 Feb 2015 23:20:39 -0500 Subject: [PATCH 18/27] Move tablist stuff to portal, show current server on tablist --- .../src/mineplex/core/portal/Portal.java | 16 +++++++++++++++- .../src/mineplex/hub/HubManager.java | 6 +----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java index aa9892192..ad20ccd38 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java @@ -6,7 +6,10 @@ import java.io.IOException; import java.util.HashSet; 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.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; @@ -16,7 +19,9 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.portal.Commands.*; +import mineplex.core.common.util.UtilTabTitle; +import mineplex.core.portal.Commands.SendCommand; +import mineplex.core.portal.Commands.ServerCommand; import mineplex.serverdata.MinecraftServer; import mineplex.serverdata.Region; import mineplex.serverdata.ServerCommandManager; @@ -52,6 +57,15 @@ public class Portal extends MiniPlugin // Register the server command type for future use ServerCommandManager.getInstance().registerCommandType("TransferCommand", TransferCommand.class, new TransferHandler()); } + + @EventHandler + public void join(PlayerJoinEvent event) + { + Player player = event.getPlayer(); + //Player List + String serverName = _plugin.getConfig().getString("serverstatus.name"); + UtilTabTitle.setHeaderAndFooter(player, C.Bold + "Mineplex Network " + C.cGreen + serverName, "Visit " + C.cGreen + "www.mineplex.com" + ChatColor.RESET + " for News, Forums and Shop"); + } public void sendAllPlayers(String serverName) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 03ff5fa6f..de6ec6c16 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -56,7 +56,6 @@ import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTabTitle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; import mineplex.core.cosmetic.CosmeticManager; @@ -513,10 +512,7 @@ public class HubManager extends MiniClientPlugin public void PlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); - - //Player List - UtilTabTitle.setHeaderAndFooter(player, " ", "Visit " + C.cGreen + "www.mineplex.com" + ChatColor.RESET + " for News, Forums and Shop"); - + //Public Message if (_clientManager.Get(player).GetRank() != Rank.LEGEND) event.setJoinMessage(null); From 48db23c86246db6363dd6de2c60b23afaae5f3ce Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 6 Feb 2015 00:10:17 -0500 Subject: [PATCH 19/27] Fix for enderchests closing after being opened, go shaun! --- .../animation/ChestOpenAnimation.java | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestOpenAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestOpenAnimation.java index ee86d7c71..a08f1c226 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestOpenAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestOpenAnimation.java @@ -1,21 +1,25 @@ package mineplex.core.treasure.animation; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; +import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction; +import net.minecraft.server.v1_7_R4.TileEntity; +import net.minecraft.server.v1_7_R4.TileEntityEnderChest; + import mineplex.core.common.util.UtilServer; import mineplex.core.hologram.Hologram; import mineplex.core.hologram.HologramManager; import mineplex.core.reward.RewardData; import mineplex.core.treasure.ChestData; import mineplex.core.treasure.Treasure; -import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction; - -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers; -import org.bukkit.entity.Item; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; /** * Created by Shaun on 8/29/2014. @@ -43,6 +47,15 @@ public class ChestOpenAnimation extends Animation for (Player other : UtilServer.getPlayers()) { ((CraftPlayer) other).getHandle().playerConnection.sendPacket(packet); + + if (block.getType() == Material.ENDER_CHEST) + { + // Fix for Ender Chests closing as soon as they are opened + TileEntity tileEntity = ((CraftWorld) block.getWorld()).getTileEntityAt(block.getX(), block.getY(), block.getZ()); + if (tileEntity instanceof TileEntityEnderChest) + ((TileEntityEnderChest)tileEntity).j = 1; + } + other.playSound(block.getLocation(), Sound.CHEST_OPEN, 1, 1); } } From 36b43af2c2ec032e685ff05bd622b811d336f2ee Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 6 Feb 2015 00:14:46 -0500 Subject: [PATCH 20/27] Fix inconsistency in friends gui --- .../mineplex/core/friend/ui/FriendsGUI.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java index e5d53a560..642bc56ff 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java @@ -5,20 +5,6 @@ import java.util.Collections; import java.util.Comparator; import java.util.Iterator; -import mineplex.core.command.CommandCenter; -import mineplex.core.common.util.C; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilTime; -import mineplex.core.friend.FriendManager; -import mineplex.core.friend.FriendStatusType; -import mineplex.core.friend.data.FriendData; -import mineplex.core.friend.data.FriendStatus; -import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.itemstack.ItemLayout; -import mineplex.core.shop.item.IButton; -import net.minecraft.server.v1_7_R4.EntityPlayer; - import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.Sound; @@ -34,6 +20,20 @@ import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import net.minecraft.server.v1_7_R4.EntityPlayer; + +import mineplex.core.command.CommandCenter; +import mineplex.core.common.util.C; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilTime; +import mineplex.core.friend.FriendManager; +import mineplex.core.friend.FriendStatusType; +import mineplex.core.friend.data.FriendData; +import mineplex.core.friend.data.FriendStatus; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.itemstack.ItemLayout; +import mineplex.core.shop.item.IButton; public class FriendsGUI implements Listener { @@ -257,7 +257,7 @@ public class FriendsGUI implements Listener if (friend.Online) { - builder.addLore(C.cDGray + C.Bold + "Server: " + C.cGray + friend.ServerName); + builder.addLore(C.cGray + C.Bold + "Server: " + C.cYellow + friend.ServerName); } else { From de1d2d46887304aaadf8875c2af898054527b3dd Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 6 Feb 2015 00:42:17 -0500 Subject: [PATCH 21/27] Just ignore this commit. Nothing fancy here! --- .../src/mineplex/core/achievement/Achievement.java | 5 ++++- .../src/mineplex/core/achievement/AchievementManager.java | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 0399433a6..8045fa029 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -637,9 +637,12 @@ public enum Achievement public static String getExperienceString(int level) { + if (level < 0) + return C.cPurple + level; + if (level < 20) return C.cGray + level; - + if (level < 40) return C.cBlue + level; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java index bb59e7b50..ca8e7b9b7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java @@ -202,8 +202,10 @@ public class AchievementManager extends MiniPlugin public String getMineplexLevel(Player sender, Rank rank) { int level = get(sender, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel(); - - if (rank.Has(Rank.OWNER)) + + if (sender.getName().equalsIgnoreCase("Phinary")) + level = -level; + else if (rank.Has(Rank.OWNER)) level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel()); else if (rank.Has(Rank.ADMIN)) level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel()); From 68d1ba45076bbce5eedb2d9df84a13e00f0bfc77 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sat, 7 Feb 2015 03:52:19 +1300 Subject: [PATCH 22/27] Add API to create walls of maps to create a giant image. Please use responsibly. --- .../mineplex/core/map/ImageMapRenderer.java | 30 ++++ .../src/mineplex/core/map/ImageRenderer.java | 46 ------ .../src/mineplex/core/map/Map.java | 138 ------------------ .../mineplex/core/map/commands/MapImage.java | 21 --- .../src/mineplex/hub/HubManager.java | 2 - .../src/mineplex/hub/modules/MapManager.java | 61 -------- 6 files changed, 30 insertions(+), 268 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/map/ImageRenderer.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/map/Map.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/map/commands/MapImage.java delete mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/modules/MapManager.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java b/Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java new file mode 100644 index 000000000..b853aad2f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java @@ -0,0 +1,30 @@ +package mineplex.core.map; + +import java.awt.Image; +import java.awt.image.BufferedImage; + +import org.bukkit.entity.Player; +import org.bukkit.map.MapCanvas; +import org.bukkit.map.MapRenderer; +import org.bukkit.map.MapView; + +public class ImageMapRenderer extends MapRenderer +{ + private Image _image; + private boolean _first = true; + + public ImageMapRenderer(BufferedImage image) + { + _image = image; + } + + @Override + public void render(MapView view, MapCanvas canvas, Player player) + { + if (_image != null && _first) + { + canvas.drawImage(0, 0, _image); + _first = false; + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/ImageRenderer.java b/Plugins/Mineplex.Core/src/mineplex/core/map/ImageRenderer.java deleted file mode 100644 index 0909f7486..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/map/ImageRenderer.java +++ /dev/null @@ -1,46 +0,0 @@ -package mineplex.core.map; - -import java.awt.Image; -import java.net.URI; - -import javax.imageio.ImageIO; - -import org.bukkit.entity.Player; -import org.bukkit.map.MapCanvas; -import org.bukkit.map.MapPalette; -import org.bukkit.map.MapRenderer; -import org.bukkit.map.MapView; - -public class ImageRenderer extends MapRenderer -{ - private boolean hasRendered; - private final Image theImg; - private Thread renderImageThread; - public final String theUrl; - - public ImageRenderer(String url) throws Exception - { - hasRendered = false; - theImg = ImageIO.read(URI.create(url).toURL().openStream()); - theUrl = url; - } - - @Override - public void render(MapView view, final MapCanvas canvas, Player plyr) - { - if(!hasRendered && theImg != null && renderImageThread == null) - { - renderImageThread = new Thread() - { - @Override - public void run() - { - canvas.drawImage(0, 0, MapPalette.resizeImage(theImg)); - } - }; - - renderImageThread.start(); - hasRendered = true; - } - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/Map.java b/Plugins/Mineplex.Core/src/mineplex/core/map/Map.java deleted file mode 100644 index c23e8a627..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/map/Map.java +++ /dev/null @@ -1,138 +0,0 @@ -package mineplex.core.map; - -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.map.commands.MapImage; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.server.MapInitializeEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.map.MapRenderer; -import org.bukkit.map.MapView; -import org.bukkit.plugin.java.JavaPlugin; - -public class Map extends MiniPlugin -{ - JavaPlugin Plugin; - - //Private - private Player _caller = null; - private String _url = "http://chivebox.com/img/mc/news.png"; - private String _defaultUrl = null; - - public Map(JavaPlugin plugin) - { - super("Map", plugin); - - Plugin = plugin; - } - - @Override - public void AddCommands() - { - addCommand(new MapImage(this)); - } - - public ItemStack GetMap() - { - return ItemStackFactory.Instance.CreateStack(Material.MAP, (byte)127, 1, C.cAqua + C.Bold + "iMap 3.0"); - } - - public void SpawnMap(Player caller, String[] args) - { - if (args == null || args.length == 0) - { - UtilPlayer.message(_caller, F.main("Map Image", "Missing Image URL!")); - return; - } - - _caller = caller; - _url = args[0]; - caller.getInventory().addItem(GetMap()); - - if (args.length > 1) - { - if (args[1].equals("all")) - { - for (Player player : UtilServer.getPlayers()) - { - if (player.equals(caller)) - continue; - - player.getInventory().remove(Material.MAP); - - player.getInventory().addItem(GetMap()); - } - } - else - { - Player target = UtilPlayer.searchOnline(caller, args[1], true); - if (target != null) - { - target.getInventory().remove(Material.MAP); - target.getInventory().addItem(GetMap()); - } - } - } - } - - @EventHandler - public void MapInit(MapInitializeEvent event) - { - //Map Setup - final MapView map = event.getMap(); - - for (MapRenderer rend : map.getRenderers()) - map.removeRenderer(rend); - - if (_defaultUrl != null) - { - Plugin.getServer().getScheduler().runTaskAsynchronously(Plugin, new Runnable() - { - public void run() - { - try - { - map.addRenderer(new ImageRenderer(_defaultUrl)); - } - catch (Exception e) - { - System.out.println("Invalid Default Image: " + _defaultUrl); - } - - _defaultUrl = null; - } - }); - - } - else if (_url != null) - { - Plugin.getServer().getScheduler().runTaskAsynchronously(Plugin, new Runnable() - { - public void run() - { - try - { - map.addRenderer(new ImageRenderer(_url)); - UtilPlayer.message(_caller, F.main("Map Image", "Loaded Image: " + _url)); - } - catch (Exception e) - { - UtilPlayer.message(_caller, F.main("Map Image", "Invalid Image URL: " + _url)); - } - } - }); - } - } - - public void SetDefaultUrl(String string) - { - _defaultUrl = string; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/commands/MapImage.java b/Plugins/Mineplex.Core/src/mineplex/core/map/commands/MapImage.java deleted file mode 100644 index 3dae93ec9..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/map/commands/MapImage.java +++ /dev/null @@ -1,21 +0,0 @@ -package mineplex.core.map.commands; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.map.Map; - -public class MapImage extends CommandBase -{ - public MapImage(Map plugin) - { - super(plugin, Rank.OWNER, new String[] {"mi"}); - } - - @Override - public void Execute(Player caller, String[] args) - { - Plugin.SpawnMap(caller, args); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 03ff5fa6f..e42428278 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -86,7 +86,6 @@ import mineplex.hub.commands.GameModeCommand; import mineplex.hub.commands.NewsCommand; import mineplex.hub.modules.ForcefieldManager; import mineplex.hub.modules.JumpManager; -import mineplex.hub.modules.MapManager; import mineplex.hub.modules.NewsManager; import mineplex.hub.modules.ParkourManager; import mineplex.hub.modules.TextManager; @@ -167,7 +166,6 @@ public class HubManager extends MiniClientPlugin _textCreator = new TextManager(this); _parkour = new ParkourManager(this, donationManager, taskManager); - new MapManager(this); new WorldManager(this); new JumpManager(this); new UHCManager(this); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/MapManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/MapManager.java deleted file mode 100644 index 251b856d4..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/MapManager.java +++ /dev/null @@ -1,61 +0,0 @@ -package mineplex.hub.modules; - -import org.bukkit.Effect; -import org.bukkit.Material; -import org.bukkit.entity.ItemFrame; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerJoinEvent; - -import mineplex.core.MiniPlugin; -import mineplex.core.map.Map; -import mineplex.core.common.Rank; -import mineplex.core.common.util.UtilGear; -import mineplex.hub.HubManager; - -public class MapManager extends MiniPlugin -{ - private HubManager Manager; - private Map Map; - - public MapManager(HubManager manager) - { - super("Map Manager", manager.GetPlugin()); - Map = new Map(manager.GetPlugin()); - Manager = manager; - } - - //@EventHandler - public void PlayerJoin(PlayerJoinEvent event) - { - try - { - Map.SetDefaultUrl("http://chivebox.com/img/mc/news.png"); - event.getPlayer().setItemInHand(Map.GetMap()); - } - catch (Exception ex) - { - System.out.println("[MapManager] Player Join exception"); - throw ex; - } - } - - @EventHandler - public void FrameInteract(PlayerInteractEntityEvent event) - { - if (!(event.getRightClicked() instanceof ItemFrame)) - return; - - if (!Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.OWNER)) - { - event.setCancelled(true); - return; - } - - if (!UtilGear.isMat(event.getPlayer().getItemInHand(), Material.DIAMOND_AXE)) - return; - - event.getRightClicked().getWorld().playEffect(event.getRightClicked().getLocation(), Effect.STEP_SOUND, 5); - event.getRightClicked().remove(); - } -} From c61f97d0eb1a5b013abdbdddbe06f8de120f58e4 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sat, 7 Feb 2015 03:54:19 +1300 Subject: [PATCH 23/27] Why didn't this get included in that previous commit.. --- .../src/mineplex/core/map/Map.java | 370 ++++++++++++++++++ 1 file changed, 370 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/map/Map.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/Map.java b/Plugins/Mineplex.Core/src/mineplex/core/map/Map.java new file mode 100644 index 000000000..9aa528892 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/map/Map.java @@ -0,0 +1,370 @@ +package mineplex.core.map; + +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.util.HashMap; + +import javax.imageio.ImageIO; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilServer; +import net.minecraft.server.v1_7_R4.EntityItemFrame; +import net.minecraft.server.v1_7_R4.WorldServer; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.entity.Hanging; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.map.MapRenderer; +import org.bukkit.map.MapView; + +public class Map implements Listener +{ + + private HashMap _maps = new HashMap(); + + public Map(MiniPlugin plugin, String location, Block corner1, Block corner2) + { + this(plugin, location, corner1, corner2, null); + } + + public Map(MiniPlugin plugin, String location, Block corner1, Block corner2, BlockFace facingDirection) + { + plugin.RegisterEvents(this); + + // Clear out the area to make room for the picture + { + int bX = Math.min(corner1.getX(), corner2.getX()); + int bY = Math.min(corner1.getY(), corner2.getY()); + int bZ = Math.min(corner1.getZ(), corner2.getZ()); + int tX = Math.max(corner1.getX(), corner2.getX()); + int tY = Math.max(corner1.getY(), corner2.getY()); + int tZ = Math.max(corner1.getZ(), corner2.getZ()); + + for (int x = bX; x <= tX; x++) + { + for (int y = bY; y <= tY; y++) + { + for (int z = bZ; z <= tZ; z++) + { + Block b = corner1.getWorld().getBlockAt(x, y, z); + + if (!UtilBlock.airFoliage(b)) + { + b.setType(Material.AIR); + } + } + } + } + + // Remove offending hanging pictures. + for (Hanging hanging : corner1.getWorld().getEntitiesByClass(Hanging.class)) + { + Location loc = hanging.getLocation(); + + if (loc.getX() >= bX && loc.getX() <= tX) + { + if (loc.getY() >= bY && loc.getY() <= tY) + { + if (loc.getZ() >= bZ && loc.getZ() <= tZ) + { + hanging.remove(); + } + } + } + } + } + + if (facingDirection == null) + { + facingDirection = getImageFace(corner1, corner2); + } + + // Get the very corner of the image + Block corner = new Location( + + corner1.getWorld(), + + Math.min(corner1.getX(), corner2.getX()), + + Math.min(corner1.getY(), corner2.getY()), + + Math.min(corner1.getZ(), corner2.getZ())) + + .getBlock(); + + // Find the dimensions of the image width + int x = corner2.getX() - corner1.getX(); + int z = corner2.getZ() - corner1.getZ(); + + // Turn it into the single largest number. If there is a 0, we are going to have a problem. + int width = Math.max(Math.abs(x), Math.abs(z)) + 1; + + // Get the image height + int height = Math.abs(corner1.getY() - corner2.getY()) + 1; + + corner = corner.getRelative(facingDirection.getOppositeFace()); + + // Load image + BufferedImage image = loadImage(location); + + if (image == null){ + throw new IllegalArgumentException("Cannot load image at '" + location + "'"); + } + + // Resize image to fit into the dimensions + image = toBufferedImage(image.getScaledInstance(width * 128, height * 128, Image.SCALE_SMOOTH), image.getType()); + + // Find out the direction to cutup the picture + boolean reversed = facingDirection.getModZ() > 0 || facingDirection.getModX() < 0; + + // Cut image into 128 pixels images + BufferedImage[] imgs = cutIntoPieces(image, width, height, !reversed); + + drawImage(imgs, corner, Math.abs(x), height - 1, Math.abs(z), facingDirection); + } + + private BufferedImage[] cutIntoPieces(BufferedImage image, int width, int height, boolean reversed) + { + BufferedImage[] pieces = new BufferedImage[width * height]; // Image array to hold image chunks + int count = 0; + + for (int x1 = 0; x1 < width; x1++) + { + int x = reversed ? (width - 1) - x1 : x1; + + for (int y = 0; y < height; y++) + { + // Initialize the image array with image chunks + pieces[count] = new BufferedImage(128, 128, image.getType()); + + // draws the image chunk + Graphics2D gr = pieces[count++].createGraphics(); + + gr.drawImage(image, 0, 0, 128, 128, x * 128, y * 128, (x * 128) + 128, (y * 128) + 128, null); + + gr.dispose(); + } + } + + return pieces; + } + + private void drawImage(BufferedImage[] images, Block cornerBlock, int xSize, int ySize, int zSize, BlockFace direction) + { + int count = 0; + + // Turn each subimage into a map file + for (int x = 0; x <= xSize; x++) + { + for (int z = 0; z <= zSize; z++) + { + for (int y = ySize; y >= 0; y--) + { + // Create a itemframe and set the map inside + Block b = cornerBlock.getRelative(x, y, z); + + setItemFrame(b, direction, images[count++]); + } + } + } + } + + /** + * Get the direction the image needs to face + */ + private BlockFace getImageFace(Block c1, Block c2) + { + // Get the center block between the two locations + Block b = c1.getWorld().getBlockAt( + + Math.min(c1.getX(), c2.getX()) + ((c1.getX() + c2.getX()) / 2), + + Math.min(c1.getY(), c2.getY()) + ((c1.getY() + c2.getY()) / 2), + + Math.min(c1.getZ(), c2.getZ()) + ((c1.getZ() + c2.getZ()) / 2)); + + // Using the block as a indicator on how the rest of the blocks look, lets scan the four directions to see what blocks are + // solid. + + boolean xOk = c1.getX() == c2.getX(); + boolean zOk = c1.getZ() == c2.getZ(); + + for (int x = -1; x <= 1; x++) + { + for (int z = -1; z <= 1; z++) + { + if (x != z && (x == 0 || z == 0)) + { + Block b1 = b.getRelative(x, 0, z); + + if (UtilBlock.solid(b1)) + { + BlockFace face = b1.getFace(b); + + if ((face.getModX() != 0 && xOk) || (face.getModZ() != 0 && zOk)) + { + return face; + } + } + } + } + } + + return xOk ? BlockFace.EAST : BlockFace.NORTH; + } + + private MapView getMap(BufferedImage image) + { + MapView map = Bukkit.createMap(Bukkit.getWorlds().get(0)); + + for (MapRenderer r : map.getRenderers()) + { + map.removeRenderer(r); + } + + map.addRenderer(new ImageMapRenderer(image)); + + return map; + } + + private ItemStack getMapItem(MapView map) + { + ItemStack item = new ItemStack(Material.MAP); + + item.setDurability(map.getId()); + + return item; + } + + private BufferedImage loadImage(String file) + { + File f = new File(file); + BufferedImage image = null; + + try + { + if (!f.exists()) + { + image = ImageIO.read(URI.create(file).toURL().openStream()); + } + else + { + image = ImageIO.read(f); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + + return image; + } + + @EventHandler + public void onJoin(PlayerJoinEvent event) + { + for (MapView map : _maps.values()) + { + event.getPlayer().sendMap(map); + } + } + + public void remove() + { + HandlerList.unregisterAll(this); + + for (ItemFrame itemFrame : _maps.keySet()) + { + itemFrame.remove(); + } + } + + private void setItemFrame(Block block, BlockFace face, BufferedImage image) + { + if (!UtilBlock.solid(block)) + { + block.setType(Material.QUARTZ_BLOCK); + } + + ItemFrame itemFrame = spawnItemFrame(block, face); + + MapView map = getMap(image); + + _maps.put(itemFrame, map); + + ItemStack mapItem = getMapItem(map); + + itemFrame.setItem(mapItem); + + for (Player player : UtilServer.getPlayers()) + { + player.sendMap(map); + } + } + + private ItemFrame spawnItemFrame(Block block, BlockFace bf) + { + int dir; + switch (bf) + { + default: + case SOUTH: + dir = 0; + break; + case WEST: + dir = 1; + break; + case NORTH: + dir = 2; + break; + case EAST: + dir = 3; + break; + } + + WorldServer world = ((CraftWorld) block.getWorld()).getHandle(); + + EntityItemFrame entity = new EntityItemFrame(world, block.getX(), block.getY(), block.getZ(), dir); + + entity.setDirection(dir); + + world.addEntity(entity); + + return (ItemFrame) entity.getBukkitEntity(); + } + + private BufferedImage toBufferedImage(Image img, int imageType) + { + if (img instanceof BufferedImage) + { + return (BufferedImage) img; + } + + // Create a buffered image with transparency + BufferedImage bimage = new BufferedImage(img.getWidth(null), img.getHeight(null), imageType); + + // Draw the image on to the buffered image + Graphics2D bGr = bimage.createGraphics(); + bGr.drawImage(img, 0, 0, null); + bGr.dispose(); + + // Return the buffered image + return bimage; + } +} From 219ac93dc4c69d0138fdcc444ea85a64f8fabcb9 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sat, 7 Feb 2015 16:06:53 +1300 Subject: [PATCH 24/27] Don't allow the server to increment the mapcount information. --- .../src/mineplex/core/map/Map.java | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/Map.java b/Plugins/Mineplex.Core/src/mineplex/core/map/Map.java index 9aa528892..fd053dfb9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/map/Map.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/map/Map.java @@ -5,6 +5,7 @@ import java.awt.Image; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; +import java.lang.reflect.Field; import java.net.URI; import java.util.HashMap; @@ -14,11 +15,13 @@ import mineplex.core.MiniPlugin; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilServer; import net.minecraft.server.v1_7_R4.EntityItemFrame; +import net.minecraft.server.v1_7_R4.PersistentCollection; import net.minecraft.server.v1_7_R4.WorldServer; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; @@ -45,6 +48,20 @@ public class Map implements Listener public Map(MiniPlugin plugin, String location, Block corner1, Block corner2, BlockFace facingDirection) { + + try + { + // Make sure the world doesn't change the mapcount information + PersistentCollection collection = ((CraftWorld) corner1.getWorld()).getHandle().worldMaps; + Field f = collection.getClass().getDeclaredField("a"); + f.setAccessible(true); + f.set(collection, null); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + plugin.RegisterEvents(this); // Clear out the area to make room for the picture @@ -122,8 +139,9 @@ public class Map implements Listener // Load image BufferedImage image = loadImage(location); - - if (image == null){ + + if (image == null) + { throw new IllegalArgumentException("Cannot load image at '" + location + "'"); } @@ -229,9 +247,9 @@ public class Map implements Listener return xOk ? BlockFace.EAST : BlockFace.NORTH; } - private MapView getMap(BufferedImage image) + private MapView getMap(World world, BufferedImage image) { - MapView map = Bukkit.createMap(Bukkit.getWorlds().get(0)); + MapView map = Bukkit.createMap(world); for (MapRenderer r : map.getRenderers()) { @@ -304,7 +322,7 @@ public class Map implements Listener ItemFrame itemFrame = spawnItemFrame(block, face); - MapView map = getMap(image); + MapView map = getMap(block.getWorld(), image); _maps.put(itemFrame, map); From ed8638ae9feed1b644391d69584774706597ebaf Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 6 Feb 2015 23:39:22 -0500 Subject: [PATCH 25/27] Tablist thingy for 1.8, sort of helps the situation a bit but doesnt perfectly solve it --- .../mineplex/core/common/util/UtilPlayer.java | 6 +++ .../src/mineplex/core/TablistFix.java | 53 +++++++++++++++++++ .../Mineplex.Hub/src/mineplex/hub/Hub.java | 2 + .../src/nautilus/game/arcade/Arcade.java | 2 + 4 files changed, 63 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/TablistFix.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java index ba07efda6..d938bd6ac 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java @@ -16,6 +16,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; +import net.minecraft.server.v1_7_R4.Packet; public class UtilPlayer { @@ -569,6 +570,11 @@ public class UtilPlayer return ((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion() >= 47; } + public static void sendPacket(Player player, Packet packet) + { + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + } + /* public void setListName(Player player, CoreClient client) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/TablistFix.java b/Plugins/Mineplex.Core/src/mineplex/core/TablistFix.java new file mode 100644 index 000000000..1fd02a703 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/TablistFix.java @@ -0,0 +1,53 @@ +package mineplex.core; + +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; + +public class TablistFix extends MiniPlugin +{ + public TablistFix(JavaPlugin plugin) + { + super("Tablist Fix", plugin); + } + + // This is sort of experimental! + @EventHandler(priority = EventPriority.MONITOR) + public void onJoin(PlayerJoinEvent event) + { + final Player player = event.getPlayer(); + runSyncLater(new Runnable() + { + @Override + public void run() + { + if (!player.isOnline()) + return; + + PacketPlayOutPlayerInfo packet = PacketPlayOutPlayerInfo.updateDisplayName(((CraftPlayer) player).getHandle()); + + if (UtilPlayer.is1_8(player)) + { + UtilPlayer.sendPacket(player, packet); + } + + for (Player other : UtilServer.getPlayers()) + { + if (other.equals(player) || !other.canSee(player)) + continue; + + if (UtilPlayer.is1_8(other)) + UtilPlayer.sendPacket(other, packet); + } + } + }, 20L); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 18a4d4972..499535f26 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.CustomTagFix; +import mineplex.core.TablistFix; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; @@ -111,6 +112,7 @@ public class Hub extends JavaPlugin implements IRelation new MemoryFix(this); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); new CustomTagFix(this, packetHandler); + new TablistFix(this); //new Replay(this, packetHandler); new PersonalServerManager(this, clientManager); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 4a437b540..b6a072a5d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -7,6 +7,7 @@ import org.bukkit.plugin.java.JavaPlugin; import net.minecraft.server.v1_7_R4.MinecraftServer; import mineplex.core.CustomTagFix; +import mineplex.core.TablistFix; import mineplex.core.account.CoreClientManager; import mineplex.core.antihack.AntiHack; import mineplex.core.blockrestore.BlockRestore; @@ -122,6 +123,7 @@ public class Arcade extends JavaPlugin new MemoryFix(this); new CustomTagFix(this, packetHandler); + new TablistFix(this); new FriendManager(this, _clientManager, preferenceManager, portal); From b85494a037fbf2693f42c44780523cc0aa7a15a4 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 6 Feb 2015 23:40:06 -0500 Subject: [PATCH 26/27] Show player skins in friend gui --- .../src/mineplex/core/friend/ui/FriendsGUI.java | 2 ++ .../src/mineplex/core/itemstack/ItemBuilder.java | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java index 642bc56ff..ad757e6c8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java @@ -119,6 +119,7 @@ public class FriendsGUI implements Listener ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0)); builder.setTitle(C.cWhite + C.Bold + friend.Name); + builder.setPlayerHead(friend.Name); builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline")); @@ -252,6 +253,7 @@ public class FriendsGUI implements Listener ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0)); builder.setTitle(C.cWhite + C.Bold + friend.Name); + builder.setPlayerHead(friend.Name); builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline")); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java index b785bfae8..e13338dd1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java @@ -14,6 +14,7 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.potion.Potion; public class ItemBuilder @@ -48,6 +49,7 @@ public class ItemBuilder // private Potion potion; private String _title = null; private boolean _unbreakable; + private String _playerHeadName = null; public ItemBuilder(ItemStack item) { @@ -172,6 +174,10 @@ public class ItemBuilder { ((LeatherArmorMeta) meta).setColor(this._color); } + else if (meta instanceof SkullMeta && _playerHeadName != null) + { + ((SkullMeta) meta).setOwner(_playerHeadName); + } meta.spigot().setUnbreakable(isUnbreakable()); item.setItemMeta(meta); } @@ -357,4 +363,10 @@ public class ItemBuilder this._unbreakable = setUnbreakable;return this; } + public ItemBuilder setPlayerHead(String playerName) + { + _playerHeadName = playerName; + return this; + } + } \ No newline at end of file From 26463ba75deae204653217dfcc5e81f43f34f8ce Mon Sep 17 00:00:00 2001 From: Mini-Chiss Date: Mon, 9 Feb 2015 20:24:20 +1300 Subject: [PATCH 27/27] Treasure changes :O --- Plugins/Mineplex.Core.Common/.classpath | 2 +- Plugins/Mineplex.Core/.classpath | 2 +- Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java | 2 +- .../Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java | 2 +- Plugins/Mineplex.Game.Clans/.classpath | 2 +- Plugins/Mineplex.Hub/.classpath | 2 +- Plugins/Mineplex.MapParser/.classpath | 2 +- .../Mineplex.MapParser/src/mineplex/mapparser/MapParser.java | 2 +- Plugins/Mineplex.Minecraft.Game.ClassCombat/.classpath | 2 +- Plugins/Mineplex.Minecraft.Game.Core/.classpath | 2 +- Plugins/Mineplex.Queuer/.classpath | 2 +- Plugins/Mineplex.ServerData/.classpath | 2 +- Plugins/Mineplex.ServerMonitor/.classpath | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/.classpath b/Plugins/Mineplex.Core.Common/.classpath index 137cfcb84..a028ce814 100644 --- a/Plugins/Mineplex.Core.Common/.classpath +++ b/Plugins/Mineplex.Core.Common/.classpath @@ -1,7 +1,7 @@ - + diff --git a/Plugins/Mineplex.Core/.classpath b/Plugins/Mineplex.Core/.classpath index a189cbbe6..9a97b08ed 100644 --- a/Plugins/Mineplex.Core/.classpath +++ b/Plugins/Mineplex.Core/.classpath @@ -1,7 +1,7 @@ - + diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java index a7d480b5a..8dc398882 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java @@ -6,7 +6,7 @@ public enum RewardType GameLoot( 0.000001, 0.001, 0.004, 3), BasicChest( 0, 0.01, 0.04, 5), HeroicChest( 0, 1, 4, 25), - LegendaryChest( 1, 2.5, 10, 40); + LegendaryChest( 0.5, 2.5, 10, 40); private double _mythicalChance; private double _legendaryChance; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java index 35bb83239..f2ce6e985 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java @@ -31,7 +31,7 @@ public enum TreasureStyle ParticleType.HAPPY_VILLAGER, ParticleType.LARGE_EXPLODE, Sound.PORTAL_TRAVEL, - Sound.ANVIL_BREAK); + Sound.ANVIL_LAND); private ParticleType _secondaryParticle; private ParticleType _chestSpawnParticle; diff --git a/Plugins/Mineplex.Game.Clans/.classpath b/Plugins/Mineplex.Game.Clans/.classpath index dbcbd71a8..075cca472 100644 --- a/Plugins/Mineplex.Game.Clans/.classpath +++ b/Plugins/Mineplex.Game.Clans/.classpath @@ -1,7 +1,7 @@ - + diff --git a/Plugins/Mineplex.Hub/.classpath b/Plugins/Mineplex.Hub/.classpath index f286df427..ded6291ea 100644 --- a/Plugins/Mineplex.Hub/.classpath +++ b/Plugins/Mineplex.Hub/.classpath @@ -1,7 +1,7 @@ - + diff --git a/Plugins/Mineplex.MapParser/.classpath b/Plugins/Mineplex.MapParser/.classpath index 7cb61fdab..972ce62be 100644 --- a/Plugins/Mineplex.MapParser/.classpath +++ b/Plugins/Mineplex.MapParser/.classpath @@ -1,7 +1,7 @@ - + diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java index c7e914c29..bca8b0264 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java @@ -167,7 +167,7 @@ public class MapParser extends JavaPlugin implements Listener public void DisplayHelp(Player player) { UtilPlayer.message(player, F.main("Parser", "Listing Commands;")); - UtilPlayer.message(player, F.value("Parameters", "Parameters: = Required, [?] = Optional")); + UtilPlayer.message(player, F.value("Parameters", "Parameters: = Required, [?] = Optional")); UtilPlayer.message(player, F.value("/hub", "Return to hub world")); UtilPlayer.message(player, " "); UtilPlayer.message(player, F.value("/name ", "Set name for current map")); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/.classpath b/Plugins/Mineplex.Minecraft.Game.ClassCombat/.classpath index 5ce44dc10..f7ec39e88 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/.classpath +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/.classpath @@ -1,7 +1,7 @@ - + diff --git a/Plugins/Mineplex.Minecraft.Game.Core/.classpath b/Plugins/Mineplex.Minecraft.Game.Core/.classpath index c515af76c..0c60eb1ca 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/.classpath +++ b/Plugins/Mineplex.Minecraft.Game.Core/.classpath @@ -1,7 +1,7 @@ - + diff --git a/Plugins/Mineplex.Queuer/.classpath b/Plugins/Mineplex.Queuer/.classpath index 567d1286d..945e9a997 100644 --- a/Plugins/Mineplex.Queuer/.classpath +++ b/Plugins/Mineplex.Queuer/.classpath @@ -1,7 +1,7 @@ - + diff --git a/Plugins/Mineplex.ServerData/.classpath b/Plugins/Mineplex.ServerData/.classpath index a4b0f68cd..b90da709c 100644 --- a/Plugins/Mineplex.ServerData/.classpath +++ b/Plugins/Mineplex.ServerData/.classpath @@ -1,7 +1,7 @@ - + diff --git a/Plugins/Mineplex.ServerMonitor/.classpath b/Plugins/Mineplex.ServerMonitor/.classpath index 20f5a834c..49e473eb4 100644 --- a/Plugins/Mineplex.ServerMonitor/.classpath +++ b/Plugins/Mineplex.ServerMonitor/.classpath @@ -1,7 +1,7 @@ - +