From 1658afefcab2686f017019bc730a0c2f64616b9e Mon Sep 17 00:00:00 2001 From: cnr Date: Sat, 17 Jun 2017 14:36:38 -0500 Subject: [PATCH] Don't key Maps by strings; use simple data type instead --- .../game/clans/core/ClaimLocation.java | 65 +++++++++++++++++++ .../clans/core/repository/ClanRepository.java | 53 +++++++-------- .../clans/core/repository/ClanTerritory.java | 19 +++--- .../game/clans/clans/ClanEnergyManager.java | 5 +- .../mineplex/game/clans/clans/ClanInfo.java | 15 ++--- .../mineplex/game/clans/clans/ClansAdmin.java | 19 +++--- .../clans/clans/ClansDataAccessLayer.java | 30 ++++----- .../game/clans/clans/ClansDisplay.java | 7 +- .../game/clans/clans/ClansManager.java | 17 +++-- .../game/clans/clans/ClansUtility.java | 49 +++++++------- .../clans/claimview/ClaimVisualizer.java | 40 ++++++------ .../clans/clans/commands/ClansCommand.java | 6 +- .../game/clans/clans/map/ItemMapRenderer.java | 13 ++-- .../clans/clans/regions/ClansRegions.java | 27 ++++---- .../elements/ScoreboardElementPlayer.java | 10 +-- .../clans/items/legendaries/MagneticMaul.java | 20 +++--- 16 files changed, 233 insertions(+), 162 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClaimLocation.java diff --git a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClaimLocation.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClaimLocation.java new file mode 100644 index 000000000..adfdfe9d3 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClaimLocation.java @@ -0,0 +1,65 @@ +package mineplex.game.clans.core; + +import java.util.Objects; + +import org.bukkit.Bukkit; +import org.bukkit.Chunk; + +public class ClaimLocation +{ + public final String _worldName; + public final int _chunkX; + public final int _chunkZ; + + private ClaimLocation(String worldName, int chunkX, int chunkZ) + { + _worldName = worldName; + _chunkX = chunkX; + _chunkZ = chunkZ; + } + + public static ClaimLocation of(String worldName, int chunkX, int chunkZ) + { + return new ClaimLocation(worldName, chunkX, chunkZ); + } + + public static ClaimLocation of(Chunk chunk) + { + return new ClaimLocation(chunk.getWorld().getName(), chunk.getX(), chunk.getZ()); + } + + public static ClaimLocation fromStoredString(String storedFormat) // TODO: change stored format for next season + { + // Current format: world,x,z + String[] split = storedFormat.split(","); + return new ClaimLocation(split[0], Integer.parseInt(split[1]), Integer.parseInt(split[2])); + } + + public String toStoredString() // TODO: change stored format for next season + { + return _worldName + "," + _chunkX + "," + _chunkZ; + } + + public Chunk toChunk() + { + return Bukkit.getWorld(_worldName).getChunkAt(_chunkX, _chunkZ); + } + + @Override + public int hashCode() + { + return Objects.hash(_worldName, _chunkX, _chunkZ); + } + + @Override + public boolean equals(Object other) + { + if (!(other instanceof ClaimLocation)) + { + return false; + } + + ClaimLocation that = (ClaimLocation) other; + return Objects.equals(_worldName, that._worldName) && Objects.equals(_chunkX, that._chunkX) && Objects.equals(_chunkZ, that._chunkZ); + } +} diff --git a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java index f0078e3d7..b57b279c0 100644 --- a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java +++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java @@ -9,9 +9,21 @@ import java.sql.Timestamp; import java.util.Collection; import java.util.UUID; -import mineplex.core.common.util.Callback; +import org.bukkit.Bukkit; +import org.bukkit.plugin.java.JavaPlugin; +import org.jooq.DSLContext; + +import mineplex.core.common.util.Callback; import mineplex.core.common.util.NautHashMap; -import mineplex.core.database.MinecraftRepository; +import mineplex.database.tables.records.ClansRecord; +import mineplex.game.clans.core.ClaimLocation; +import mineplex.game.clans.core.repository.tokens.ClanAllianceToken; +import mineplex.game.clans.core.repository.tokens.ClanMemberToken; +import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken; +import mineplex.game.clans.core.repository.tokens.ClanToken; +import mineplex.game.clans.core.repository.tokens.ClanWarToken; +import mineplex.game.clans.core.repository.tokens.SimpleClanToken; +import mineplex.game.clans.core.war.ClanWarData; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.ResultSetCallable; @@ -20,22 +32,11 @@ import mineplex.serverdata.database.column.ColumnBoolean; import mineplex.serverdata.database.column.ColumnInt; import mineplex.serverdata.database.column.ColumnTimestamp; import mineplex.serverdata.database.column.ColumnVarChar; -import mineplex.database.tables.records.ClansRecord; -import mineplex.game.clans.core.repository.tokens.ClanAllianceToken; -import mineplex.game.clans.core.repository.tokens.ClanMemberToken; -import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken; -import mineplex.game.clans.core.repository.tokens.ClanToken; -import mineplex.game.clans.core.repository.tokens.SimpleClanToken; - -import org.bukkit.Bukkit; -import org.bukkit.plugin.java.JavaPlugin; -import mineplex.game.clans.core.repository.tokens.ClanWarToken; -import mineplex.game.clans.core.war.ClanWarData; -import org.jooq.DSLContext; - -import static mineplex.database.Tables.*; -import static org.jooq.impl.DSL.*; +import static mineplex.database.Tables.accountClan; +import static mineplex.database.Tables.accounts; +import static mineplex.database.Tables.clans; +import static org.jooq.impl.DSL.select; public class ClanRepository extends RepositoryBase { @@ -150,7 +151,6 @@ public class ClanRepository extends RepositoryBase * alliances, enemies, teritory claims and homes set on * originating server. * @param clanId - the id of the clan to move - * @param serverId - the id of the destination server being moved to */ public void moveClanServer(final int clanId, String serverName, final Callback callback) { @@ -472,12 +472,12 @@ public class ClanRepository extends RepositoryBase executeUpdate(DELETE_CLAN_ALLIANCE, new ColumnInt("clanid", clanId), new ColumnInt("otherClanId", otherClanId)); } - public boolean addTerritoryClaim(int clanId, String chunk, boolean safe) + public boolean addTerritoryClaim(int clanId, ClaimLocation chunk, boolean safe) { - return executeUpdate(ADD_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("chunk", 100, chunk), new ColumnBoolean("safe", safe)) == 1; + return executeUpdate(ADD_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("chunk", 100, chunk.toStoredString()), new ColumnBoolean("safe", safe)) == 1; } - public boolean addTerritoryClaims(int clanId, boolean safe, String... chunks) + public boolean addTerritoryClaims(int clanId, boolean safe, ClaimLocation... chunks) { int affectedRows = 0; int size = chunks.length; @@ -498,8 +498,9 @@ public class ClanRepository extends RepositoryBase Column safeCol = new ColumnBoolean("safe", safe); int i = 0; - for (String chunk : chunks) + for (ClaimLocation claim : chunks) { + String chunk = claim.toStoredString(); Column chunkCol = new ColumnVarChar("chunk", 100, chunk); clanIdCol.setValue(preparedStatement, i + 1); chunkCol.setValue(preparedStatement, i + 2); @@ -539,9 +540,9 @@ public class ClanRepository extends RepositoryBase // executeUpdate(ADD_CLAN_ENEMY, new ColumnInt("clanId", clanId), new ColumnInt("otherClanId", otherClanId)); // } - public void removeTerritoryClaim(int clanId, String chunk) + public void removeTerritoryClaim(int clanId, ClaimLocation chunk) { - executeUpdate(DELETE_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("chunk", 100, chunk)); + executeUpdate(DELETE_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("chunk", 100, chunk.toStoredString())); } public void removeTerritoryClaims(int clanId) @@ -574,8 +575,8 @@ public class ClanRepository extends RepositoryBase > 0; } - public void updateTerritoryClaim(String chunk, boolean safe) + public void updateTerritoryClaim(ClaimLocation chunk, boolean safe) { - executeUpdate(UPDATE_CLAN_TERRITORY, new ColumnBoolean("safe", safe), new ColumnVarChar("chunk", 100, chunk)); + executeUpdate(UPDATE_CLAN_TERRITORY, new ColumnBoolean("safe", safe), new ColumnVarChar("chunk", 100, chunk.toStoredString())); } } diff --git a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanTerritory.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanTerritory.java index 904388533..658c391ab 100644 --- a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanTerritory.java +++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanTerritory.java @@ -2,23 +2,22 @@ package mineplex.game.clans.core.repository; import org.bukkit.Location; -import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken; +import mineplex.game.clans.core.ClaimLocation; public class ClanTerritory { - public ClanTerritory() { } - - public ClanTerritory(ClanTerritoryToken territoryToken) + + public ClanTerritory(ClaimLocation loc, String owner, boolean safe) { - Owner = territoryToken.ClanName; - Safe = territoryToken.Safe; - Chunk = territoryToken.Chunk; + ClaimLocation = loc; + Owner = owner; + Safe = safe; } - + public boolean Safe; public String Owner = ""; - public String Chunk = ""; - + public ClaimLocation ClaimLocation; + public boolean isSafe(Location location) { if (Owner.equals("Spawn")) 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 9184bd800..2a42c0ae1 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; @@ -10,6 +8,7 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.donation.DonationManager; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.shop.energy.EnergyShop; public class ClanEnergyManager extends MiniPlugin implements Runnable @@ -45,7 +44,7 @@ public class ClanEnergyManager extends MiniPlugin implements Runnable if (currentEnergy < energyPerMinute) { - for (String chunk : clanInfo.getClaimSet()) + for (ClaimLocation chunk : clanInfo.getClaimSet()) { _clansManager.getClanDataAccess().unclaimSilent(chunk, true); } 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 2d4d42389..fe1f9b517 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 @@ -9,6 +9,8 @@ import java.util.List; import java.util.Set; import java.util.UUID; +import net.minecraft.server.v1_8_R3.Material; + import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -25,13 +27,13 @@ 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.tntGenerator.TntGenerator; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.core.repository.tokens.ClanAllianceToken; import mineplex.game.clans.core.repository.tokens.ClanMemberToken; import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken; import mineplex.game.clans.core.repository.tokens.ClanToken; import mineplex.game.clans.core.repository.tokens.ClanWarToken; import mineplex.game.clans.core.war.ClanWarData; -import net.minecraft.server.v1_8_R3.Material; public class ClanInfo { @@ -59,7 +61,7 @@ public class ClanInfo // Loaded from Client private NautHashMap _memberMap = new NautHashMap(); private NautHashMap _allyMap = new NautHashMap(); - private Set _claimSet = new HashSet(); + private Set _claimSet = new HashSet<>(); // Wars Initiated By Others private HashMap _warIn = new HashMap(); @@ -134,7 +136,7 @@ public class ClanInfo for (ClanTerritoryToken territoryToken : token.Territories) { - _claimSet.add(territoryToken.Chunk); + _claimSet.add(ClaimLocation.fromStoredString(territoryToken.Chunk)); } for (ClanAllianceToken allianceToken : token.Alliances) @@ -378,10 +380,7 @@ public class ClanInfo stringList.add(F.main("Clans", getName() + " Territory;")); - for (String cur : getClaimSet()) - { - stringList.add(cur); - } + getClaimSet().stream().map(ClaimLocation::toStoredString).forEach(stringList::add); return stringList; } @@ -439,7 +438,7 @@ public class ClanInfo return _memberMap; } - public Set getClaimSet() + public Set getClaimSet() { return _claimSet; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java index fcc116670..8798c636f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java @@ -2,6 +2,9 @@ package mineplex.game.clans.clans; import java.util.ArrayList; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -9,13 +12,11 @@ import mineplex.core.common.util.UtilInput; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilWorld; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.tokens.ClanToken; import mineplex.game.clans.core.war.ClanWarData; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - public class ClansAdmin { private ClansManager Clans; @@ -761,7 +762,7 @@ public class ClansAdmin if (clientClan == null) return; - String chunk = UtilWorld.chunkToStr(caller.getLocation().getChunk()); + ClaimLocation chunk = ClaimLocation.of(caller.getLocation().getChunk()); ClanInfo ownerClan = Clans.getClanUtility().getOwner(caller.getLocation()); //Already Claimed @@ -800,7 +801,7 @@ public class ClansAdmin if (clientClan == null) return; - String chunk = UtilWorld.chunkToStr(caller.getLocation().getChunk()); + ClaimLocation chunk = ClaimLocation.of(caller.getLocation().getChunk()); ClanInfo ownerClan = Clans.getClanUtility().getOwner(caller.getLocation()); //Not Claimed @@ -826,12 +827,12 @@ public class ClansAdmin return; //Unclaim - ArrayList toUnclaim = new ArrayList(); + ArrayList toUnclaim = new ArrayList<>(); - for (String chunk : clientClan.getClaimSet()) + for (ClaimLocation chunk : clientClan.getClaimSet()) toUnclaim.add(chunk); - for (String chunk : toUnclaim) + for (ClaimLocation chunk : toUnclaim) Clans.getClanDataAccess().unclaim(chunk, caller.getName(), true); //Inform @@ -861,7 +862,7 @@ public class ClansAdmin return; } - if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(clan.getHome().getChunk()))) + if (!clan.getClaimSet().contains(ClaimLocation.of(clan.getHome().getChunk()))) { UtilPlayer.message(caller, F.main("Clans Admin", "Your Clan has lost its Home Territory.")); return; 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 f92282c73..81e0244f6 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 @@ -23,6 +23,7 @@ import mineplex.game.clans.clans.event.ClanLeaveEvent; import mineplex.game.clans.clans.event.ClanSetHomeEvent; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; import mineplex.game.clans.clans.tntGenerator.TntGenerator; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.core.repository.ClanRepository; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.tokens.ClanToken; @@ -71,7 +72,7 @@ public class ClansDataAccessLayer public void deleteLocally(ClanInfo clan) { // Territory Unclaim - for (String cur : clan.getClaimSet()) + for (ClaimLocation cur : clan.getClaimSet()) { _manager.getClaimMap().remove(cur); } @@ -454,14 +455,14 @@ public class ClansDataAccessLayer _manager.log("Added Neutral between [" + cA.getName() + "] and [" + cB.getName() + "] by [" + player + "]."); } - public boolean claimAll(final String name, final String player, final boolean safe, final String... chunks) + public boolean claimAll(final String name, final String player, final boolean safe, final ClaimLocation... chunks) { if (!_manager.getClanMap().containsKey(name)) return false; final ClanInfo clan = _manager.getClanMap().get(name); // Unclaim - for (String chunk : chunks) + for (ClaimLocation chunk : chunks) { if (_manager.getClaimMap().containsKey(chunk)) { @@ -469,9 +470,7 @@ public class ClansDataAccessLayer } // Memory - ClanTerritory claim = new ClanTerritory(); - claim.Owner = name; - claim.Safe = safe; + ClanTerritory claim = new ClanTerritory(chunk, name, safe); clan.getClaimSet().add(chunk); _manager.getClaimMap().put(chunk, claim); } @@ -493,7 +492,7 @@ public class ClansDataAccessLayer } @SuppressWarnings("deprecation") - public boolean claim(String name, final String chunk, String player, final boolean safe) + public boolean claim(String name, final ClaimLocation chunk, String player, final boolean safe) { if (!_manager.getClanMap().containsKey(name)) return false; @@ -503,10 +502,7 @@ public class ClansDataAccessLayer if (_manager.getClaimMap().containsKey(chunk)) unclaim(chunk, player, false); // Memory - ClanTerritory claim = new ClanTerritory(); - claim.Owner = name; - claim.Safe = safe; - claim.Chunk = chunk; + ClanTerritory claim = new ClanTerritory(chunk, name, safe); clan.getClaimSet().add(chunk); _manager.getClaimMap().put(chunk, claim); @@ -521,7 +517,7 @@ public class ClansDataAccessLayer }); // Visual - Chunk c = UtilWorld.strToChunk(chunk); + Chunk c = chunk.toChunk(); if (!clan.isAdmin()) { for (int x = 0; x < 16; x++) @@ -544,7 +540,7 @@ public class ClansDataAccessLayer return true; } - public boolean unclaim(final String chunk, String player, boolean sql) + public boolean unclaim(final ClaimLocation chunk, String player, boolean sql) { ClanTerritory claim = _manager.getClaimMap().remove(chunk); @@ -577,7 +573,7 @@ public class ClansDataAccessLayer }); // Restore any glowstone blocks - Chunk c = UtilWorld.strToChunk(chunk); + Chunk c = chunk.toChunk(); if (!clan.isAdmin()) { for (int x = 0; x < 16; x++) @@ -615,7 +611,7 @@ public class ClansDataAccessLayer return true; } - public boolean unclaimSilent(String chunk, boolean sql) + public boolean unclaimSilent(ClaimLocation chunk, boolean sql) { return unclaim(chunk, null, sql); } @@ -790,12 +786,12 @@ public class ClansDataAccessLayer @Override public void run() { - _repository.updateTerritoryClaim(claim.Chunk, claim.Safe); + _repository.updateTerritoryClaim(claim.ClaimLocation, claim.Safe); } }); // Log - _manager.log("Safe Zone at [" + claim.Chunk + "] set to [" + claim.Safe + "] by [" + player + "]."); + _manager.log("Safe Zone at [" + claim.ClaimLocation.toStoredString() + "] set to [" + claim.Safe + "] by [" + player + "]."); } public void retrieveClan(final String clanName, final Callback callback) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java index 0c5629d2d..8123f862a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java @@ -23,6 +23,7 @@ import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; import mineplex.game.clans.clans.nether.NetherManager; import mineplex.game.clans.clans.worldevent.WorldEventManager; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.core.repository.ClanTerritory; public class ClansDisplay extends MiniPlugin @@ -112,7 +113,7 @@ public class ClansDisplay extends MiniPlugin if (claim != null) { // Relation - ClanRelation relation = _clansManager.getClanUtility().relPT(player, claim.Chunk); + ClanRelation relation = _clansManager.getClanUtility().relPT(player, claim.ClaimLocation); // Name ownerString = _clansManager.getClanUtility().mRel(relation, claim.Owner, false); @@ -201,8 +202,8 @@ public class ClansDisplay extends MiniPlugin } // Get Data - ClanInfo curOwner = _clansManager.getClanUtility().getOwner(UtilWorld.chunkToStr(curChunk)); - ClanTerritory curClaim = _clansManager.getClanUtility().getClaim(UtilWorld.chunkToStr(curChunk)); + ClanInfo curOwner = _clansManager.getClanUtility().getOwner(ClaimLocation.of(curChunk)); + ClanTerritory curClaim = _clansManager.getClanUtility().getClaim(ClaimLocation.of(curChunk)); // Add Icon if (i == chunk.getX() && j == chunk.getZ()) 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 b5c293a04..1794c63e5 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 @@ -115,6 +115,7 @@ import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.clans.potato.PotatoManager; import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler; import mineplex.game.clans.clans.redis.ClanLoadCommandHandler; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.clans.regions.ClansRegions; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; import mineplex.game.clans.clans.siege.SiegeManager; @@ -245,8 +246,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati // NautHashMap(); private NautHashMap _clanMemberUuidMap = new NautHashMap(); private NautHashMap> _clanMemberLeftMap = new NautHashMap<>(); - private NautHashMap _claimMap = new NautHashMap(); - private NautHashMap _unclaimMap = new NautHashMap(); + private NautHashMap _claimMap = new NautHashMap<>(); + private NautHashMap _unclaimMap = new NautHashMap<>(); public String UserDataDir = UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "CLANS_USER_DATA" + File.separator; @@ -507,8 +508,12 @@ public class ClansManager extends MiniClientPluginimplements IRelati } for (ClanTerritoryToken territoryToken : clanToken.Territories) - _claimMap.put(territoryToken.Chunk, new ClanTerritory(territoryToken)); - + { + String[] split = territoryToken.Chunk.split(","); + ClaimLocation location = ClaimLocation.of(split[0], Integer.parseInt(split[1]), Integer.parseInt(split[2])); + _claimMap.put(location, new ClanTerritory(ClaimLocation.fromStoredString(territoryToken.Chunk), territoryToken.ClanName, territoryToken.Safe)); + } + if (loadBanner) _bannerManager.loadBanner(clan); } @@ -651,7 +656,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati return getClan(clanName) != null; } - public NautHashMap getClaimMap() + public NautHashMap getClaimMap() { return _claimMap; } @@ -1130,7 +1135,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati return _clanDisplay; } - public NautHashMap getUnclaimMap() + public NautHashMap getUnclaimMap() { return _unclaimMap; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index a2ecef65e..4f63bf168 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java @@ -23,6 +23,7 @@ import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.spawn.Spawn; @@ -300,10 +301,10 @@ public class ClansUtility // PlayerList#updatePlayers -> iterator -> PlayerVelocityEvent -> getChunk -> loadChunk -> loadPersistentEntities -> addTracker -> ITERATE ON SAME SET int chunkX = loc.getBlockX() >> 4; int chunkZ = loc.getBlockZ() >> 4; - String chunkStr = UtilWorld.chunkToStr(loc.getWorld().getName(), chunkX, chunkZ); - if (!_clansManager.getClaimMap().containsKey(chunkStr)) return false; + ClaimLocation claim = ClaimLocation.of(loc.getWorld().getName(), chunkX, chunkZ); + if (!_clansManager.getClaimMap().containsKey(claim)) return false; - return _clansManager.getClaimMap().get(chunkStr).isSafe(loc); + return _clansManager.getClaimMap().get(claim).isSafe(loc); } public boolean isChunkHome(ClanInfo clan, Chunk chunk) @@ -317,7 +318,7 @@ public class ClansUtility public ClanTerritory getClaim(Chunk chunk) { - String chunkTag = UtilWorld.chunkToStr(chunk); + ClaimLocation chunkTag = ClaimLocation.of(chunk); return _clansManager.getClaimMap().get(chunkTag); } @@ -334,12 +335,12 @@ public class ClansUtility return getClaim(loc.getChunk()); } - public ClanTerritory getClaim(String chunk) + public ClanTerritory getClaim(ClaimLocation location) { - return _clansManager.getClaimMap().get(chunk); + return _clansManager.getClaimMap().get(location); } - public ClanInfo getOwner(String chunk) + public ClanInfo getOwner(ClaimLocation chunk) { ClanTerritory claim = getClaim(chunk); @@ -365,7 +366,7 @@ public class ClansUtility { if (xOffset == 0 && zOffset == 0) continue; - String other = UtilWorld.chunkToStr(location.getWorld().getChunkAt(location.getChunk().getX() + xOffset, location.getChunk().getZ() + zOffset)); + ClaimLocation other = ClaimLocation.of(location.getWorld().getChunkAt(location.getChunk().getX() + xOffset, location.getChunk().getZ() + zOffset)); ClanInfo adjClan = getOwner(other); @@ -395,13 +396,13 @@ public class ClansUtility public String getOwnerStringRel(Location loc, Player player) { - ClanRelation rel = relPT(player, UtilWorld.chunkToStr(loc.getChunk())); + ClanRelation rel = relPT(player, ClaimLocation.of(loc.getChunk())); return mRel(rel, getOwnerString(loc), true); } public boolean isClaimed(Location loc) { - String chunk = UtilWorld.chunkToStr(loc.getChunk()); + ClaimLocation chunk = ClaimLocation.of(loc.getChunk()); return _clansManager.getClaimMap().containsKey(chunk); } @@ -478,7 +479,7 @@ public class ClansUtility } // Territory Territory - public ClanRelation relTT(String tA, String tB) + public ClanRelation relTT(ClaimLocation tA, ClaimLocation tB) { return rel(getOwner(tA), getOwner(tB)); } @@ -496,7 +497,7 @@ public class ClansUtility } // Player Territory - public ClanRelation relPT(Player player, String territory) + public ClanRelation relPT(Player player, ClaimLocation territory) { ClanTerritory claim = getClaim(territory); if (claim != null && claim.isSafe(player.getLocation())) @@ -508,7 +509,7 @@ public class ClansUtility } // Clan Territory - public ClanRelation relCT(String cA, String tB) + public ClanRelation relCT(String cA, ClaimLocation tB) { ClanTerritory claim = getClaim(tB); if (claim != null) if (claim.Safe) return ClanRelation.SAFE; @@ -792,7 +793,7 @@ public class ClansUtility return false; } - String chunk = UtilWorld.chunkToStr(caller.getLocation().getChunk()); + ClaimLocation chunk = ClaimLocation.of(caller.getLocation().getChunk()); ClanInfo ownerClan = getOwner(caller.getLocation()); // Try to Steal @@ -829,7 +830,7 @@ public class ClansUtility continue; } - String other = UtilWorld.chunkToStr(caller.getWorld().getChunkAt(caller.getLocation().getChunk().getX() + x, caller.getLocation().getChunk().getZ() + z)); + ClaimLocation other = ClaimLocation.of(caller.getWorld().getChunkAt(caller.getLocation().getChunk().getX() + x, caller.getLocation().getChunk().getZ() + z)); ClanInfo adjClan = getOwner(other); @@ -928,10 +929,10 @@ public class ClansUtility int boxed = 0; // This is bad. I know. But the other way doesn't seem to work. - String down = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() + 0, chunk.getZ() + 1)); - String up = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() - 1)); - String right = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() + 1, chunk.getZ())); - String left = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() - 1, chunk.getZ())); + ClaimLocation down = ClaimLocation.of(chunk.getWorld().getChunkAt(chunk.getX() + 0, chunk.getZ() + 1)); + ClaimLocation up = ClaimLocation.of(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() - 1)); + ClaimLocation right = ClaimLocation.of(chunk.getWorld().getChunkAt(chunk.getX() + 1, chunk.getZ())); + ClaimLocation left = ClaimLocation.of(chunk.getWorld().getChunkAt(chunk.getX() - 1, chunk.getZ())); ClanInfo downClan = getOwner(down); ClanInfo upClan = getOwner(up); @@ -960,7 +961,7 @@ public class ClansUtility UtilServer.broadcast(F.main("Clans", F.elem(clientClan.getName()) + " unclaimed from " + F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".")); // Unclaim - _clansManager.getClanDataAccess().unclaim(UtilWorld.chunkToStr(caller.getLocation().getChunk()), caller.getName(), true); + _clansManager.getClanDataAccess().unclaim(ClaimLocation.of(caller.getLocation().getChunk()), caller.getName(), true); return true; } @@ -1132,7 +1133,7 @@ public class ClansUtility return false; } - String chunk = UtilWorld.chunkToStr(c); + ClaimLocation chunk = ClaimLocation.of(c); ClanInfo ownerClan = getOwner(caller.getLocation()); // Try to Steal @@ -1189,14 +1190,14 @@ public class ClansUtility } // Unclaim - ArrayList toUnclaim = new ArrayList(); + ArrayList toUnclaim = new ArrayList<>(); - for (String chunk : clan.getClaimSet()) + for (ClaimLocation chunk : clan.getClaimSet()) { toUnclaim.add(chunk); } - for (String chunk : toUnclaim) + for (ClaimLocation chunk : toUnclaim) { _clansManager.getClanDataAccess().unclaim(chunk, caller.getName(), true); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/ClaimVisualizer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/ClaimVisualizer.java index 9408255bd..ef76e4a6b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/ClaimVisualizer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/ClaimVisualizer.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import net.minecraft.server.v1_8_R3.EnumDirection; + import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; @@ -25,7 +27,6 @@ import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilWorld; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanInfo; @@ -33,9 +34,8 @@ import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.claimview.commands.ClaimVisualizeCommand; import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.ClanLeaveEvent; -import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; -import net.minecraft.server.v1_8_R3.EnumDirection; +import mineplex.game.clans.core.ClaimLocation; public class ClaimVisualizer extends MiniPlugin { @@ -43,7 +43,7 @@ public class ClaimVisualizer extends MiniPlugin private List _visualizing; - private NautHashMap> _calculated; + private NautHashMap> _calculated; public ClaimVisualizer(JavaPlugin plugin, ClansManager clansManager) { @@ -55,7 +55,7 @@ public class ClaimVisualizer extends MiniPlugin for (ClanInfo clan : _clansManager.getClanMap().values()) { - _calculated.put(clan, new NautHashMap()); + _calculated.put(clan, new NautHashMap<>()); } } @@ -76,11 +76,11 @@ public class ClaimVisualizer extends MiniPlugin _calculated.clear(); for (ClanInfo clan : _clansManager.getClanMap().values()) { - _calculated.put(clan, new NautHashMap()); + _calculated.put(clan, new NautHashMap<>()); - for (String serialized : clan.getClaimSet()) + for (ClaimLocation chunk : clan.getClaimSet()) { - calculate(clan, serialized); + calculate(clan, chunk); } } } @@ -106,11 +106,11 @@ public class ClaimVisualizer extends MiniPlugin private void visualize(Player player) { - for (String serialized : _clansManager.getClan(player).getClaimSet()) + for (ClaimLocation claim : _clansManager.getClan(player).getClaimSet()) { - if (!_calculated.get(_clansManager.getClan(player)).containsKey(serialized)) + if (!_calculated.get(_clansManager.getClan(player)).containsKey(claim)) { - calculate(_clansManager.getClan(player), serialized); + calculate(_clansManager.getClan(player), claim); } } @@ -153,35 +153,35 @@ public class ClaimVisualizer extends MiniPlugin } } - private void calculate(ClanInfo clan, String serialized) + private void calculate(ClanInfo clan, ClaimLocation claim) { - Chunk chunk = UtilWorld.strToChunk(serialized); + Chunk chunk = claim.toChunk(); List dirs = new ArrayList<>(); - if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() - 1)))) + if (!clan.getClaimSet().contains(ClaimLocation.of(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() - 1)))) { dirs.add(EnumDirection.NORTH); } - if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() + 1, chunk.getZ())))) + if (!clan.getClaimSet().contains(ClaimLocation.of(chunk.getWorld().getChunkAt(chunk.getX() + 1, chunk.getZ())))) { dirs.add(EnumDirection.EAST); } - if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() + 1)))) + if (!clan.getClaimSet().contains(ClaimLocation.of(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() + 1)))) { dirs.add(EnumDirection.SOUTH); } - if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() - 1, chunk.getZ())))) + if (!clan.getClaimSet().contains(ClaimLocation.of(chunk.getWorld().getChunkAt(chunk.getX() - 1, chunk.getZ())))) { dirs.add(EnumDirection.WEST); } VisualizedChunkData cached = new VisualizedChunkData(chunk, dirs); - _calculated.get(clan).put(serialized, cached); + _calculated.get(clan).put(claim, cached); } @EventHandler @@ -228,9 +228,9 @@ public class ClaimVisualizer extends MiniPlugin { _calculated.clear(); - for (String serialized : clan.getClaimSet()) + for (ClaimLocation claim : clan.getClaimSet()) { - calculate(clan, serialized); + calculate(clan, claim); } } 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 adef219f9..acec71fc3 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 @@ -4,6 +4,8 @@ package mineplex.game.clans.clans.commands; import java.util.Collections; import java.util.List; +import net.minecraft.server.v1_8_R3.EnumDirection; + import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; @@ -37,9 +39,9 @@ import mineplex.game.clans.clans.ClientClan; import mineplex.game.clans.clans.event.ClanJoinEvent; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.spawn.Spawn; -import net.minecraft.server.v1_8_R3.EnumDirection; public class ClansCommand extends CommandBase { @@ -967,7 +969,7 @@ public class ClansCommand extends CommandBase UtilServer.broadcast(F.main("Clans", F.elem(clientClan.getName()) + " unclaimed from " + F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".")); // Unclaim - Plugin.getClanDataAccess().unclaim(UtilWorld.chunkToStr(caller.getLocation().getChunk()), caller.getName(), true); + Plugin.getClanDataAccess().unclaim(ClaimLocation.of(caller.getLocation().getChunk()), caller.getName(), true); return true; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java index 07ac8f1cf..37dfc4dc7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java @@ -1,6 +1,6 @@ package mineplex.game.clans.clans.map; -import java.awt.Color; +import java.awt.*; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -18,6 +18,7 @@ import mineplex.game.clans.clans.ClansUtility; import mineplex.game.clans.clans.worldevent.WorldEventManager; import mineplex.game.clans.clans.worldevent.api.EventState; import mineplex.game.clans.clans.worldevent.api.WorldEvent; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.tutorial.TutorialManager; public class ItemMapRenderer extends MapRenderer @@ -107,7 +108,7 @@ public class ItemMapRenderer extends MapRenderer blockX *= zoom; blockZ *= zoom; - String chunk = "world," + (int) Math.floor(blockX / 16D) + "," + (int) Math.floor(blockZ / 16D); + ClaimLocation chunk = ClaimLocation.of("world", (int) Math.floor(blockX / 16D), (int) Math.floor(blockZ / 16D)); ClanInfo owningClan = _manager.getClansUtility().getOwner(chunk); @@ -196,19 +197,19 @@ public class ItemMapRenderer extends MapRenderer ((chunkBX == 0 || zoom == 13) && - owningClan != _manager.getClansUtility().getOwner("world," + (chunkX1 - 1) + "," + chunkZ1)) + owningClan != _manager.getClansUtility().getOwner(ClaimLocation.of("world", chunkX1 - 1, chunkZ1))) || ((chunkBZ == 0 || zoom == 13) && - owningClan != _manager.getClansUtility().getOwner("world," + chunkX1 + "," + (chunkZ1 - 1))) + owningClan != _manager.getClansUtility().getOwner(ClaimLocation.of("world", chunkX1, chunkZ1 - 1))) || ((chunkBX + zoom > 15 || zoom == 13) && - owningClan != _manager.getClansUtility().getOwner("world," + (chunkX1 + 1) + "," + chunkZ1)) + owningClan != _manager.getClansUtility().getOwner(ClaimLocation.of("world", chunkX1 + 1, chunkZ1))) || ((chunkBZ + zoom > 15 || zoom == 13) && - owningClan != _manager.getClansUtility().getOwner("world," + chunkX1 + "," + (chunkZ1 + 1)))) + owningClan != _manager.getClansUtility().getOwner(ClaimLocation.of("world", chunkX1, chunkZ1 + 1)))) { Color cColor = MapPalette.getColor(color); double clans = colorAll ? 1 : 0.8;// 0.65; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java index 3ea0964b8..012fdc19b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java @@ -3,13 +3,6 @@ package mineplex.game.clans.clans.regions; import java.util.HashSet; import java.util.Set; -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.Callback; -import mineplex.game.clans.clans.ClanInfo; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.spawn.Spawn; -import mineplex.minecraft.game.classcombat.Skill.event.SkillTeleportEvent; - import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; @@ -17,6 +10,14 @@ import org.bukkit.WorldBorder; import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.Callback; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.core.ClaimLocation; +import mineplex.game.clans.spawn.Spawn; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTeleportEvent; + public class ClansRegions extends MiniPlugin { public final static String DEFAULT_WORLD_NAME = "world"; @@ -103,7 +104,7 @@ public class ClansRegions extends MiniPlugin System.out.println("Clearing claims for " + name + " with clan id " + clan + "!"); - for (String chunk : clan.getClaimSet()) + for (ClaimLocation chunk : clan.getClaimSet()) { _manager.getClaimMap().remove(chunk); } @@ -168,7 +169,7 @@ public class ClansRegions extends MiniPlugin { int chunkX = location.getChunk().getX(); int chunkZ = location.getChunk().getZ(); - Set chunks = new HashSet(); + Set chunks = new HashSet<>(); int start = addNegative ? -chunkRadius - 1 : -chunkRadius; @@ -178,7 +179,7 @@ public class ClansRegions extends MiniPlugin { int x = chunkX + xOffset; int z = chunkZ + zOffset; - String chunkStr = location.getWorld().getName() + "," + x + "," + z; + ClaimLocation chunk = ClaimLocation.of(location.getWorld().getName(), x, z); if (addNegative) { @@ -192,19 +193,19 @@ public class ClansRegions extends MiniPlugin continue; } - if (_manager.getClaimMap().containsKey(chunkStr)) + if (_manager.getClaimMap().containsKey(chunk)) { // System.out.println("get claim map contains " + chunkStr); // this is really really slowing server startup down. just saying. continue; } - chunks.add(chunkStr); + chunks.add(chunk); } } if (chunks.size() > 0) { - _manager.getClanDataAccess().claimAll(clan.getName(), "ClansRegions", safe, chunks.toArray(new String[0])); + _manager.getClanDataAccess().claimAll(clan.getName(), "ClansRegions", safe, chunks.toArray(new ClaimLocation[chunks.size()])); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java index 75b8ef44d..17ca21092 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java @@ -2,6 +2,10 @@ package mineplex.game.clans.clans.scoreboard.elements; import java.util.List; +import org.bukkit.entity.Player; + +import com.google.common.collect.Lists; + import mineplex.core.common.util.C; import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; @@ -9,10 +13,6 @@ import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansUtility; import mineplex.game.clans.core.repository.ClanTerritory; -import org.bukkit.entity.Player; - -import com.google.common.collect.Lists; - public class ScoreboardElementPlayer implements ScoreboardElement { private ClansManager _clansManager; @@ -37,7 +37,7 @@ public class ScoreboardElementPlayer implements ScoreboardElement if (claim != null) { //Relation - ClansUtility.ClanRelation relation = _clansManager.getClanUtility().relPT(player, claim.Chunk); + ClansUtility.ClanRelation relation = _clansManager.getClanUtility().relPT(player, claim.ClaimLocation); //Name regionString = _clansManager.getClanUtility().mRel(relation, claim.Owner, false); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MagneticMaul.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MagneticMaul.java index 8b05823fb..4f033e705 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MagneticMaul.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MagneticMaul.java @@ -1,5 +1,11 @@ package mineplex.game.clans.items.legendaries; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; @@ -11,17 +17,11 @@ import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilTextBottom; -import mineplex.core.common.util.UtilWorld; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - public class MagneticMaul extends LegendaryItem { private static final double PULL_RANGE = 10d; @@ -42,7 +42,7 @@ public class MagneticMaul extends LegendaryItem public void update(Player wielder) { Location loc = wielder.getLocation(); - ClanTerritory territory = ClansManager.getInstance().getClaimMap().get(UtilWorld.chunkToStr(loc)); + ClanTerritory territory = ClansManager.getInstance().getClaimMap().get(ClaimLocation.of(loc.getChunk())); if (territory != null && territory.isSafe(loc)) { return; @@ -95,9 +95,9 @@ public class MagneticMaul extends LegendaryItem if (otherTargetDistance < targetDistance && otherDistance <= PULL_RANGE) { // If entity is in safe zone, don't allow pulling of that entity. - if (ClansManager.getInstance().getClaimMap().containsKey(UtilWorld.chunkToStr(entity.getLocation()))) + if (ClansManager.getInstance().getClaimMap().containsKey(ClaimLocation.of(entity.getLocation().getChunk()))) { - if (ClansManager.getInstance().getClaimMap().get(UtilWorld.chunkToStr(entity.getLocation())).isSafe(entity.getLocation())) + if (ClansManager.getInstance().getClaimMap().get(ClaimLocation.of(entity.getLocation().getChunk())).isSafe(entity.getLocation())) { continue; }