Merge remote-tracking branch 'refs/remotes/origin/develop' into feature/moba

This commit is contained in:
Sam 2017-06-18 10:55:46 +01:00
commit 17bfe9ee0a
17 changed files with 236 additions and 165 deletions

View File

@ -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);
}
}

View File

@ -9,9 +9,21 @@ import java.sql.Timestamp;
import java.util.Collection; import java.util.Collection;
import java.util.UUID; import java.util.UUID;
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.Callback;
import mineplex.core.common.util.NautHashMap; 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.DBPool;
import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.RepositoryBase;
import mineplex.serverdata.database.ResultSetCallable; 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.ColumnInt;
import mineplex.serverdata.database.column.ColumnTimestamp; import mineplex.serverdata.database.column.ColumnTimestamp;
import mineplex.serverdata.database.column.ColumnVarChar; 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 static mineplex.database.Tables.accountClan;
import org.bukkit.plugin.java.JavaPlugin; import static mineplex.database.Tables.accounts;
import static mineplex.database.Tables.clans;
import mineplex.game.clans.core.repository.tokens.ClanWarToken; import static org.jooq.impl.DSL.select;
import mineplex.game.clans.core.war.ClanWarData;
import org.jooq.DSLContext;
import static mineplex.database.Tables.*;
import static org.jooq.impl.DSL.*;
public class ClanRepository extends RepositoryBase public class ClanRepository extends RepositoryBase
{ {
@ -150,7 +151,6 @@ public class ClanRepository extends RepositoryBase
* alliances, enemies, teritory claims and homes set on * alliances, enemies, teritory claims and homes set on
* originating server. * originating server.
* @param clanId - the id of the clan to move * @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<Boolean> callback) public void moveClanServer(final int clanId, String serverName, final Callback<Boolean> callback)
{ {
@ -472,12 +472,12 @@ public class ClanRepository extends RepositoryBase
executeUpdate(DELETE_CLAN_ALLIANCE, new ColumnInt("clanid", clanId), new ColumnInt("otherClanId", otherClanId)); 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 affectedRows = 0;
int size = chunks.length; int size = chunks.length;
@ -498,8 +498,9 @@ public class ClanRepository extends RepositoryBase
Column<?> safeCol = new ColumnBoolean("safe", safe); Column<?> safeCol = new ColumnBoolean("safe", safe);
int i = 0; int i = 0;
for (String chunk : chunks) for (ClaimLocation claim : chunks)
{ {
String chunk = claim.toStoredString();
Column<?> chunkCol = new ColumnVarChar("chunk", 100, chunk); Column<?> chunkCol = new ColumnVarChar("chunk", 100, chunk);
clanIdCol.setValue(preparedStatement, i + 1); clanIdCol.setValue(preparedStatement, i + 1);
chunkCol.setValue(preparedStatement, i + 2); 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)); // 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) public void removeTerritoryClaims(int clanId)
@ -574,8 +575,8 @@ public class ClanRepository extends RepositoryBase
> 0; > 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()));
} }
} }

View File

@ -2,22 +2,21 @@ package mineplex.game.clans.core.repository;
import org.bukkit.Location; import org.bukkit.Location;
import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken; import mineplex.game.clans.core.ClaimLocation;
public class ClanTerritory public class ClanTerritory
{ {
public ClanTerritory() { }
public ClanTerritory(ClanTerritoryToken territoryToken) public ClanTerritory(ClaimLocation loc, String owner, boolean safe)
{ {
Owner = territoryToken.ClanName; ClaimLocation = loc;
Safe = territoryToken.Safe; Owner = owner;
Chunk = territoryToken.Chunk; Safe = safe;
} }
public boolean Safe; public boolean Safe;
public String Owner = ""; public String Owner = "";
public String Chunk = ""; public ClaimLocation ClaimLocation;
public boolean isSafe(Location location) public boolean isSafe(Location location)
{ {

View File

@ -1,8 +1,6 @@
package mineplex.game.clans.clans; package mineplex.game.clans.clans;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
@ -10,6 +8,7 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.game.clans.core.ClaimLocation;
import mineplex.game.clans.shop.energy.EnergyShop; import mineplex.game.clans.shop.energy.EnergyShop;
public class ClanEnergyManager extends MiniPlugin implements Runnable public class ClanEnergyManager extends MiniPlugin implements Runnable
@ -45,7 +44,7 @@ public class ClanEnergyManager extends MiniPlugin implements Runnable
if (currentEnergy < energyPerMinute) if (currentEnergy < energyPerMinute)
{ {
for (String chunk : clanInfo.getClaimSet()) for (ClaimLocation chunk : clanInfo.getClaimSet())
{ {
_clansManager.getClanDataAccess().unclaimSilent(chunk, true); _clansManager.getClanDataAccess().unclaimSilent(chunk, true);
} }

View File

@ -9,6 +9,8 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import net.minecraft.server.v1_8_R3.Material;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -25,13 +27,13 @@ import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.tntGenerator.TntGenerator; 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.ClanAllianceToken;
import mineplex.game.clans.core.repository.tokens.ClanMemberToken; import mineplex.game.clans.core.repository.tokens.ClanMemberToken;
import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken; import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken;
import mineplex.game.clans.core.repository.tokens.ClanToken; import mineplex.game.clans.core.repository.tokens.ClanToken;
import mineplex.game.clans.core.repository.tokens.ClanWarToken; import mineplex.game.clans.core.repository.tokens.ClanWarToken;
import mineplex.game.clans.core.war.ClanWarData; import mineplex.game.clans.core.war.ClanWarData;
import net.minecraft.server.v1_8_R3.Material;
public class ClanInfo public class ClanInfo
{ {
@ -59,7 +61,7 @@ public class ClanInfo
// Loaded from Client // Loaded from Client
private NautHashMap<UUID, ClansPlayer> _memberMap = new NautHashMap<UUID, ClansPlayer>(); private NautHashMap<UUID, ClansPlayer> _memberMap = new NautHashMap<UUID, ClansPlayer>();
private NautHashMap<String, Boolean> _allyMap = new NautHashMap<String, Boolean>(); private NautHashMap<String, Boolean> _allyMap = new NautHashMap<String, Boolean>();
private Set<String> _claimSet = new HashSet<String>(); private Set<ClaimLocation> _claimSet = new HashSet<>();
// Wars Initiated By Others // Wars Initiated By Others
private HashMap<String, ClanWarData> _warIn = new HashMap<String, ClanWarData>(); private HashMap<String, ClanWarData> _warIn = new HashMap<String, ClanWarData>();
@ -134,7 +136,7 @@ public class ClanInfo
for (ClanTerritoryToken territoryToken : token.Territories) for (ClanTerritoryToken territoryToken : token.Territories)
{ {
_claimSet.add(territoryToken.Chunk); _claimSet.add(ClaimLocation.fromStoredString(territoryToken.Chunk));
} }
for (ClanAllianceToken allianceToken : token.Alliances) for (ClanAllianceToken allianceToken : token.Alliances)
@ -378,10 +380,7 @@ public class ClanInfo
stringList.add(F.main("Clans", getName() + " Territory;")); stringList.add(F.main("Clans", getName() + " Territory;"));
for (String cur : getClaimSet()) getClaimSet().stream().map(ClaimLocation::toStoredString).forEach(stringList::add);
{
stringList.add(cur);
}
return stringList; return stringList;
} }
@ -439,7 +438,7 @@ public class ClanInfo
return _memberMap; return _memberMap;
} }
public Set<String> getClaimSet() public Set<ClaimLocation> getClaimSet()
{ {
return _claimSet; return _claimSet;
} }

View File

@ -2,6 +2,9 @@ package mineplex.game.clans.clans;
import java.util.ArrayList; import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F; 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.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilWorld; 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.ClanTerritory;
import mineplex.game.clans.core.repository.tokens.ClanToken; import mineplex.game.clans.core.repository.tokens.ClanToken;
import mineplex.game.clans.core.war.ClanWarData; import mineplex.game.clans.core.war.ClanWarData;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class ClansAdmin public class ClansAdmin
{ {
private ClansManager Clans; private ClansManager Clans;
@ -761,7 +762,7 @@ public class ClansAdmin
if (clientClan == null) if (clientClan == null)
return; return;
String chunk = UtilWorld.chunkToStr(caller.getLocation().getChunk()); ClaimLocation chunk = ClaimLocation.of(caller.getLocation().getChunk());
ClanInfo ownerClan = Clans.getClanUtility().getOwner(caller.getLocation()); ClanInfo ownerClan = Clans.getClanUtility().getOwner(caller.getLocation());
//Already Claimed //Already Claimed
@ -800,7 +801,7 @@ public class ClansAdmin
if (clientClan == null) if (clientClan == null)
return; return;
String chunk = UtilWorld.chunkToStr(caller.getLocation().getChunk()); ClaimLocation chunk = ClaimLocation.of(caller.getLocation().getChunk());
ClanInfo ownerClan = Clans.getClanUtility().getOwner(caller.getLocation()); ClanInfo ownerClan = Clans.getClanUtility().getOwner(caller.getLocation());
//Not Claimed //Not Claimed
@ -826,12 +827,12 @@ public class ClansAdmin
return; return;
//Unclaim //Unclaim
ArrayList<String> toUnclaim = new ArrayList<String>(); ArrayList<ClaimLocation> toUnclaim = new ArrayList<>();
for (String chunk : clientClan.getClaimSet()) for (ClaimLocation chunk : clientClan.getClaimSet())
toUnclaim.add(chunk); toUnclaim.add(chunk);
for (String chunk : toUnclaim) for (ClaimLocation chunk : toUnclaim)
Clans.getClanDataAccess().unclaim(chunk, caller.getName(), true); Clans.getClanDataAccess().unclaim(chunk, caller.getName(), true);
//Inform //Inform
@ -861,7 +862,7 @@ public class ClansAdmin
return; 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.")); UtilPlayer.message(caller, F.main("Clans Admin", "Your Clan has lost its Home Territory."));
return; return;

View File

@ -23,6 +23,7 @@ import mineplex.game.clans.clans.event.ClanLeaveEvent;
import mineplex.game.clans.clans.event.ClanSetHomeEvent; import mineplex.game.clans.clans.event.ClanSetHomeEvent;
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
import mineplex.game.clans.clans.tntGenerator.TntGenerator; 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.ClanRepository;
import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.game.clans.core.repository.tokens.ClanToken; import mineplex.game.clans.core.repository.tokens.ClanToken;
@ -71,7 +72,7 @@ public class ClansDataAccessLayer
public void deleteLocally(ClanInfo clan) public void deleteLocally(ClanInfo clan)
{ {
// Territory Unclaim // Territory Unclaim
for (String cur : clan.getClaimSet()) for (ClaimLocation cur : clan.getClaimSet())
{ {
_manager.getClaimMap().remove(cur); _manager.getClaimMap().remove(cur);
} }
@ -454,14 +455,14 @@ public class ClansDataAccessLayer
_manager.log("Added Neutral between [" + cA.getName() + "] and [" + cB.getName() + "] by [" + player + "]."); _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; if (!_manager.getClanMap().containsKey(name)) return false;
final ClanInfo clan = _manager.getClanMap().get(name); final ClanInfo clan = _manager.getClanMap().get(name);
// Unclaim // Unclaim
for (String chunk : chunks) for (ClaimLocation chunk : chunks)
{ {
if (_manager.getClaimMap().containsKey(chunk)) if (_manager.getClaimMap().containsKey(chunk))
{ {
@ -469,9 +470,7 @@ public class ClansDataAccessLayer
} }
// Memory // Memory
ClanTerritory claim = new ClanTerritory(); ClanTerritory claim = new ClanTerritory(chunk, name, safe);
claim.Owner = name;
claim.Safe = safe;
clan.getClaimSet().add(chunk); clan.getClaimSet().add(chunk);
_manager.getClaimMap().put(chunk, claim); _manager.getClaimMap().put(chunk, claim);
} }
@ -493,7 +492,7 @@ public class ClansDataAccessLayer
} }
@SuppressWarnings("deprecation") @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; if (!_manager.getClanMap().containsKey(name)) return false;
@ -503,10 +502,7 @@ public class ClansDataAccessLayer
if (_manager.getClaimMap().containsKey(chunk)) unclaim(chunk, player, false); if (_manager.getClaimMap().containsKey(chunk)) unclaim(chunk, player, false);
// Memory // Memory
ClanTerritory claim = new ClanTerritory(); ClanTerritory claim = new ClanTerritory(chunk, name, safe);
claim.Owner = name;
claim.Safe = safe;
claim.Chunk = chunk;
clan.getClaimSet().add(chunk); clan.getClaimSet().add(chunk);
_manager.getClaimMap().put(chunk, claim); _manager.getClaimMap().put(chunk, claim);
@ -521,7 +517,7 @@ public class ClansDataAccessLayer
}); });
// Visual // Visual
Chunk c = UtilWorld.strToChunk(chunk); Chunk c = chunk.toChunk();
if (!clan.isAdmin()) if (!clan.isAdmin())
{ {
for (int x = 0; x < 16; x++) for (int x = 0; x < 16; x++)
@ -544,7 +540,7 @@ public class ClansDataAccessLayer
return true; 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); ClanTerritory claim = _manager.getClaimMap().remove(chunk);
@ -577,7 +573,7 @@ public class ClansDataAccessLayer
}); });
// Restore any glowstone blocks // Restore any glowstone blocks
Chunk c = UtilWorld.strToChunk(chunk); Chunk c = chunk.toChunk();
if (!clan.isAdmin()) if (!clan.isAdmin())
{ {
for (int x = 0; x < 16; x++) for (int x = 0; x < 16; x++)
@ -615,7 +611,7 @@ public class ClansDataAccessLayer
return true; return true;
} }
public boolean unclaimSilent(String chunk, boolean sql) public boolean unclaimSilent(ClaimLocation chunk, boolean sql)
{ {
return unclaim(chunk, null, sql); return unclaim(chunk, null, sql);
} }
@ -790,12 +786,12 @@ public class ClansDataAccessLayer
@Override @Override
public void run() public void run()
{ {
_repository.updateTerritoryClaim(claim.Chunk, claim.Safe); _repository.updateTerritoryClaim(claim.ClaimLocation, claim.Safe);
} }
}); });
// Log // 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<ClanToken> callback) public void retrieveClan(final String clanName, final Callback<ClanToken> callback)

View File

@ -23,6 +23,7 @@ import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent;
import mineplex.game.clans.clans.nether.NetherManager; import mineplex.game.clans.clans.nether.NetherManager;
import mineplex.game.clans.clans.worldevent.WorldEventManager; import mineplex.game.clans.clans.worldevent.WorldEventManager;
import mineplex.game.clans.core.ClaimLocation;
import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.ClanTerritory;
public class ClansDisplay extends MiniPlugin public class ClansDisplay extends MiniPlugin
@ -112,7 +113,7 @@ public class ClansDisplay extends MiniPlugin
if (claim != null) if (claim != null)
{ {
// Relation // Relation
ClanRelation relation = _clansManager.getClanUtility().relPT(player, claim.Chunk); ClanRelation relation = _clansManager.getClanUtility().relPT(player, claim.ClaimLocation);
// Name // Name
ownerString = _clansManager.getClanUtility().mRel(relation, claim.Owner, false); ownerString = _clansManager.getClanUtility().mRel(relation, claim.Owner, false);
@ -201,8 +202,8 @@ public class ClansDisplay extends MiniPlugin
} }
// Get Data // Get Data
ClanInfo curOwner = _clansManager.getClanUtility().getOwner(UtilWorld.chunkToStr(curChunk)); ClanInfo curOwner = _clansManager.getClanUtility().getOwner(ClaimLocation.of(curChunk));
ClanTerritory curClaim = _clansManager.getClanUtility().getClaim(UtilWorld.chunkToStr(curChunk)); ClanTerritory curClaim = _clansManager.getClanUtility().getClaim(ClaimLocation.of(curChunk));
// Add Icon // Add Icon
if (i == chunk.getX() && j == chunk.getZ()) if (i == chunk.getX() && j == chunk.getZ())

View File

@ -115,6 +115,7 @@ import mineplex.game.clans.clans.playtime.Playtime;
import mineplex.game.clans.clans.potato.PotatoManager; import mineplex.game.clans.clans.potato.PotatoManager;
import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler; import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler;
import mineplex.game.clans.clans.redis.ClanLoadCommandHandler; 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.regions.ClansRegions;
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
import mineplex.game.clans.clans.siege.SiegeManager; import mineplex.game.clans.clans.siege.SiegeManager;
@ -245,8 +246,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
// NautHashMap<String, ClanInfo>(); // NautHashMap<String, ClanInfo>();
private NautHashMap<UUID, ClanInfo> _clanMemberUuidMap = new NautHashMap<UUID, ClanInfo>(); private NautHashMap<UUID, ClanInfo> _clanMemberUuidMap = new NautHashMap<UUID, ClanInfo>();
private NautHashMap<UUID, Pair<ClanInfo, Long>> _clanMemberLeftMap = new NautHashMap<>(); private NautHashMap<UUID, Pair<ClanInfo, Long>> _clanMemberLeftMap = new NautHashMap<>();
private NautHashMap<String, ClanTerritory> _claimMap = new NautHashMap<String, ClanTerritory>(); private NautHashMap<ClaimLocation, ClanTerritory> _claimMap = new NautHashMap<>();
private NautHashMap<String, Long> _unclaimMap = new NautHashMap<String, Long>(); private NautHashMap<ClaimLocation, Long> _unclaimMap = new NautHashMap<>();
public String UserDataDir = UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "CLANS_USER_DATA" + File.separator; public String UserDataDir = UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "CLANS_USER_DATA" + File.separator;
@ -507,7 +508,11 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
} }
for (ClanTerritoryToken territoryToken : clanToken.Territories) 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) if (loadBanner)
_bannerManager.loadBanner(clan); _bannerManager.loadBanner(clan);
@ -651,7 +656,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
return getClan(clanName) != null; return getClan(clanName) != null;
} }
public NautHashMap<String, ClanTerritory> getClaimMap() public NautHashMap<ClaimLocation, ClanTerritory> getClaimMap()
{ {
return _claimMap; return _claimMap;
} }
@ -1130,7 +1135,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
return _clanDisplay; return _clanDisplay;
} }
public NautHashMap<String, Long> getUnclaimMap() public NautHashMap<ClaimLocation, Long> getUnclaimMap()
{ {
return _unclaimMap; return _unclaimMap;
} }

View File

@ -23,6 +23,7 @@ import mineplex.game.clans.clans.event.ClanDisbandedEvent;
import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent;
import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent;
import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent;
import mineplex.game.clans.core.ClaimLocation;
import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.game.clans.spawn.Spawn; 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 // PlayerList#updatePlayers -> iterator -> PlayerVelocityEvent -> getChunk -> loadChunk -> loadPersistentEntities -> addTracker -> ITERATE ON SAME SET
int chunkX = loc.getBlockX() >> 4; int chunkX = loc.getBlockX() >> 4;
int chunkZ = loc.getBlockZ() >> 4; int chunkZ = loc.getBlockZ() >> 4;
String chunkStr = UtilWorld.chunkToStr(loc.getWorld().getName(), chunkX, chunkZ); ClaimLocation claim = ClaimLocation.of(loc.getWorld().getName(), chunkX, chunkZ);
if (!_clansManager.getClaimMap().containsKey(chunkStr)) return false; 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) public boolean isChunkHome(ClanInfo clan, Chunk chunk)
@ -317,7 +318,7 @@ public class ClansUtility
public ClanTerritory getClaim(Chunk chunk) public ClanTerritory getClaim(Chunk chunk)
{ {
String chunkTag = UtilWorld.chunkToStr(chunk); ClaimLocation chunkTag = ClaimLocation.of(chunk);
return _clansManager.getClaimMap().get(chunkTag); return _clansManager.getClaimMap().get(chunkTag);
} }
@ -334,12 +335,12 @@ public class ClansUtility
return getClaim(loc.getChunk()); 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); ClanTerritory claim = getClaim(chunk);
@ -365,7 +366,7 @@ public class ClansUtility
{ {
if (xOffset == 0 && zOffset == 0) continue; 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); ClanInfo adjClan = getOwner(other);
@ -395,13 +396,13 @@ public class ClansUtility
public String getOwnerStringRel(Location loc, Player player) 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); return mRel(rel, getOwnerString(loc), true);
} }
public boolean isClaimed(Location loc) public boolean isClaimed(Location loc)
{ {
String chunk = UtilWorld.chunkToStr(loc.getChunk()); ClaimLocation chunk = ClaimLocation.of(loc.getChunk());
return _clansManager.getClaimMap().containsKey(chunk); return _clansManager.getClaimMap().containsKey(chunk);
} }
@ -478,7 +479,7 @@ public class ClansUtility
} }
// Territory Territory // Territory Territory
public ClanRelation relTT(String tA, String tB) public ClanRelation relTT(ClaimLocation tA, ClaimLocation tB)
{ {
return rel(getOwner(tA), getOwner(tB)); return rel(getOwner(tA), getOwner(tB));
} }
@ -496,7 +497,7 @@ public class ClansUtility
} }
// Player Territory // Player Territory
public ClanRelation relPT(Player player, String territory) public ClanRelation relPT(Player player, ClaimLocation territory)
{ {
ClanTerritory claim = getClaim(territory); ClanTerritory claim = getClaim(territory);
if (claim != null && claim.isSafe(player.getLocation())) if (claim != null && claim.isSafe(player.getLocation()))
@ -508,7 +509,7 @@ public class ClansUtility
} }
// Clan Territory // Clan Territory
public ClanRelation relCT(String cA, String tB) public ClanRelation relCT(String cA, ClaimLocation tB)
{ {
ClanTerritory claim = getClaim(tB); ClanTerritory claim = getClaim(tB);
if (claim != null) if (claim.Safe) return ClanRelation.SAFE; if (claim != null) if (claim.Safe) return ClanRelation.SAFE;
@ -792,7 +793,7 @@ public class ClansUtility
return false; return false;
} }
String chunk = UtilWorld.chunkToStr(caller.getLocation().getChunk()); ClaimLocation chunk = ClaimLocation.of(caller.getLocation().getChunk());
ClanInfo ownerClan = getOwner(caller.getLocation()); ClanInfo ownerClan = getOwner(caller.getLocation());
// Try to Steal // Try to Steal
@ -829,7 +830,7 @@ public class ClansUtility
continue; 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); ClanInfo adjClan = getOwner(other);
@ -928,10 +929,10 @@ public class ClansUtility
int boxed = 0; int boxed = 0;
// This is bad. I know. But the other way doesn't seem to work. // 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)); ClaimLocation down = ClaimLocation.of(chunk.getWorld().getChunkAt(chunk.getX() + 0, chunk.getZ() + 1));
String up = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() - 1)); ClaimLocation up = ClaimLocation.of(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() - 1));
String right = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() + 1, chunk.getZ())); ClaimLocation right = ClaimLocation.of(chunk.getWorld().getChunkAt(chunk.getX() + 1, chunk.getZ()));
String left = UtilWorld.chunkToStr(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 downClan = getOwner(down);
ClanInfo upClan = getOwner(up); 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())) + ".")); UtilServer.broadcast(F.main("Clans", F.elem(clientClan.getName()) + " unclaimed from " + F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + "."));
// Unclaim // 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; return true;
} }
@ -1132,7 +1133,7 @@ public class ClansUtility
return false; return false;
} }
String chunk = UtilWorld.chunkToStr(c); ClaimLocation chunk = ClaimLocation.of(c);
ClanInfo ownerClan = getOwner(caller.getLocation()); ClanInfo ownerClan = getOwner(caller.getLocation());
// Try to Steal // Try to Steal
@ -1189,14 +1190,14 @@ public class ClansUtility
} }
// Unclaim // Unclaim
ArrayList<String> toUnclaim = new ArrayList<String>(); ArrayList<ClaimLocation> toUnclaim = new ArrayList<>();
for (String chunk : clan.getClaimSet()) for (ClaimLocation chunk : clan.getClaimSet())
{ {
toUnclaim.add(chunk); toUnclaim.add(chunk);
} }
for (String chunk : toUnclaim) for (ClaimLocation chunk : toUnclaim)
{ {
_clansManager.getClanDataAccess().unclaim(chunk, caller.getName(), true); _clansManager.getClanDataAccess().unclaim(chunk, caller.getName(), true);
} }

View File

@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import net.minecraft.server.v1_8_R3.EnumDirection;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; 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.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo; 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.claimview.commands.ClaimVisualizeCommand;
import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.ClanDisbandedEvent;
import mineplex.game.clans.clans.event.ClanLeaveEvent; import mineplex.game.clans.clans.event.ClanLeaveEvent;
import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent;
import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; 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 public class ClaimVisualizer extends MiniPlugin
{ {
@ -43,7 +43,7 @@ public class ClaimVisualizer extends MiniPlugin
private List<String> _visualizing; private List<String> _visualizing;
private NautHashMap<ClanInfo, NautHashMap<String, VisualizedChunkData>> _calculated; private NautHashMap<ClanInfo, NautHashMap<ClaimLocation, VisualizedChunkData>> _calculated;
public ClaimVisualizer(JavaPlugin plugin, ClansManager clansManager) public ClaimVisualizer(JavaPlugin plugin, ClansManager clansManager)
{ {
@ -55,7 +55,7 @@ public class ClaimVisualizer extends MiniPlugin
for (ClanInfo clan : _clansManager.getClanMap().values()) for (ClanInfo clan : _clansManager.getClanMap().values())
{ {
_calculated.put(clan, new NautHashMap<String, VisualizedChunkData>()); _calculated.put(clan, new NautHashMap<>());
} }
} }
@ -76,11 +76,11 @@ public class ClaimVisualizer extends MiniPlugin
_calculated.clear(); _calculated.clear();
for (ClanInfo clan : _clansManager.getClanMap().values()) for (ClanInfo clan : _clansManager.getClanMap().values())
{ {
_calculated.put(clan, new NautHashMap<String, VisualizedChunkData>()); _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) 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<EnumDirection> dirs = new ArrayList<>(); List<EnumDirection> 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); 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); 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); 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); dirs.add(EnumDirection.WEST);
} }
VisualizedChunkData cached = new VisualizedChunkData(chunk, dirs); VisualizedChunkData cached = new VisualizedChunkData(chunk, dirs);
_calculated.get(clan).put(serialized, cached); _calculated.get(clan).put(claim, cached);
} }
@EventHandler @EventHandler
@ -228,9 +228,9 @@ public class ClaimVisualizer extends MiniPlugin
{ {
_calculated.clear(); _calculated.clear();
for (String serialized : clan.getClaimSet()) for (ClaimLocation claim : clan.getClaimSet())
{ {
calculate(clan, serialized); calculate(clan, claim);
} }
} }

View File

@ -4,6 +4,8 @@ package mineplex.game.clans.clans.commands;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import net.minecraft.server.v1_8_R3.EnumDirection;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; 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.ClanJoinEvent;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent; import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent;
import mineplex.game.clans.core.ClaimLocation;
import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.game.clans.spawn.Spawn; import mineplex.game.clans.spawn.Spawn;
import net.minecraft.server.v1_8_R3.EnumDirection;
public class ClansCommand extends CommandBase<ClansManager> public class ClansCommand extends CommandBase<ClansManager>
{ {
@ -967,7 +969,7 @@ public class ClansCommand extends CommandBase<ClansManager>
UtilServer.broadcast(F.main("Clans", F.elem(clientClan.getName()) + " unclaimed from " + F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".")); UtilServer.broadcast(F.main("Clans", F.elem(clientClan.getName()) + " unclaimed from " + F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + "."));
// Unclaim // 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; return true;
} }
@ -1025,7 +1027,7 @@ public class ClansCommand extends CommandBase<ClansManager>
return; 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", "Your Clan has lost its Home Territory.")); UtilPlayer.message(caller, F.main("Clans", "Your Clan has lost its Home Territory."));
return; return;

View File

@ -1,6 +1,6 @@
package mineplex.game.clans.clans.map; package mineplex.game.clans.clans.map;
import java.awt.Color; import java.awt.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; 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.WorldEventManager;
import mineplex.game.clans.clans.worldevent.api.EventState; import mineplex.game.clans.clans.worldevent.api.EventState;
import mineplex.game.clans.clans.worldevent.api.WorldEvent; import mineplex.game.clans.clans.worldevent.api.WorldEvent;
import mineplex.game.clans.core.ClaimLocation;
import mineplex.game.clans.tutorial.TutorialManager; import mineplex.game.clans.tutorial.TutorialManager;
public class ItemMapRenderer extends MapRenderer public class ItemMapRenderer extends MapRenderer
@ -107,7 +108,7 @@ public class ItemMapRenderer extends MapRenderer
blockX *= zoom; blockX *= zoom;
blockZ *= 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); ClanInfo owningClan = _manager.getClansUtility().getOwner(chunk);
@ -196,19 +197,19 @@ public class ItemMapRenderer extends MapRenderer
((chunkBX == 0 || zoom == 13) && ((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) && || ((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) && || ((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) && || ((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); Color cColor = MapPalette.getColor(color);
double clans = colorAll ? 1 : 0.8;// 0.65; double clans = colorAll ? 1 : 0.8;// 0.65;

View File

@ -3,13 +3,6 @@ package mineplex.game.clans.clans.regions;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; 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.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -17,6 +10,14 @@ import org.bukkit.WorldBorder;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin; 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 class ClansRegions extends MiniPlugin
{ {
public final static String DEFAULT_WORLD_NAME = "world"; 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 + "!"); 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); _manager.getClaimMap().remove(chunk);
} }
@ -168,7 +169,7 @@ public class ClansRegions extends MiniPlugin
{ {
int chunkX = location.getChunk().getX(); int chunkX = location.getChunk().getX();
int chunkZ = location.getChunk().getZ(); int chunkZ = location.getChunk().getZ();
Set<String> chunks = new HashSet<String>(); Set<ClaimLocation> chunks = new HashSet<>();
int start = addNegative ? -chunkRadius - 1 : -chunkRadius; int start = addNegative ? -chunkRadius - 1 : -chunkRadius;
@ -178,7 +179,7 @@ public class ClansRegions extends MiniPlugin
{ {
int x = chunkX + xOffset; int x = chunkX + xOffset;
int z = chunkZ + zOffset; int z = chunkZ + zOffset;
String chunkStr = location.getWorld().getName() + "," + x + "," + z; ClaimLocation chunk = ClaimLocation.of(location.getWorld().getName(), x, z);
if (addNegative) if (addNegative)
{ {
@ -192,19 +193,19 @@ public class ClansRegions extends MiniPlugin
continue; 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. // System.out.println("get claim map contains " + chunkStr); // this is really really slowing server startup down. just saying.
continue; continue;
} }
chunks.add(chunkStr); chunks.add(chunk);
} }
} }
if (chunks.size() > 0) 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()]));
} }
} }

View File

@ -2,6 +2,10 @@ package mineplex.game.clans.clans.scoreboard.elements;
import java.util.List; import java.util.List;
import org.bukkit.entity.Player;
import com.google.common.collect.Lists;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager;
import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; 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.clans.ClansUtility;
import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.ClanTerritory;
import org.bukkit.entity.Player;
import com.google.common.collect.Lists;
public class ScoreboardElementPlayer implements ScoreboardElement public class ScoreboardElementPlayer implements ScoreboardElement
{ {
private ClansManager _clansManager; private ClansManager _clansManager;
@ -37,7 +37,7 @@ public class ScoreboardElementPlayer implements ScoreboardElement
if (claim != null) if (claim != null)
{ {
//Relation //Relation
ClansUtility.ClanRelation relation = _clansManager.getClanUtility().relPT(player, claim.Chunk); ClansUtility.ClanRelation relation = _clansManager.getClanUtility().relPT(player, claim.ClaimLocation);
//Name //Name
regionString = _clansManager.getClanUtility().mRel(relation, claim.Owner, false); regionString = _clansManager.getClanUtility().mRel(relation, claim.Owner, false);

View File

@ -1,5 +1,11 @@
package mineplex.game.clans.items.legendaries; 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.C;
import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilAction; 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.UtilServer;
import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.core.ClaimLocation;
import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; 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 public class MagneticMaul extends LegendaryItem
{ {
private static final double PULL_RANGE = 10d; private static final double PULL_RANGE = 10d;
@ -42,7 +42,7 @@ public class MagneticMaul extends LegendaryItem
public void update(Player wielder) public void update(Player wielder)
{ {
Location loc = wielder.getLocation(); 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)) if (territory != null && territory.isSafe(loc))
{ {
return; return;
@ -95,9 +95,9 @@ public class MagneticMaul extends LegendaryItem
if (otherTargetDistance < targetDistance && otherDistance <= PULL_RANGE) if (otherTargetDistance < targetDistance && otherDistance <= PULL_RANGE)
{ {
// If entity is in safe zone, don't allow pulling of that entity. // 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; continue;
} }

View File

@ -464,7 +464,7 @@ public class ClansMainTutorial extends Tutorial
// } // }
// }); // });
if (!_taskManager.hasCompletedTask(event.getPlayer(), getTaskIdentifier())) /*if (!_taskManager.hasCompletedTask(event.getPlayer(), getTaskIdentifier()))
{ {
ClanInfo clan = ClansManager.getInstance().getClan(event.getPlayer()); ClanInfo clan = ClansManager.getInstance().getClan(event.getPlayer());
if (clan == null) if (clan == null)
@ -476,7 +476,7 @@ public class ClansMainTutorial extends Tutorial
UtilPlayer.message(event.getPlayer(), F.main("Clans", "It seems you already have a clan here, so we can skip the tutorial")); UtilPlayer.message(event.getPlayer(), F.main("Clans", "It seems you already have a clan here, so we can skip the tutorial"));
} }
} }
else if (!event.getPlayer().hasPlayedBefore() || !event.getPlayer().getLocation().getWorld().equals(Spawn.getSpawnWorld())) else */if (!event.getPlayer().hasPlayedBefore() || !event.getPlayer().getLocation().getWorld().equals(Spawn.getSpawnWorld()))
{ {
Spawn.getInstance().teleport(event.getPlayer(), Spawn.getInstance().getSpawnLocation(), 2); Spawn.getInstance().teleport(event.getPlayer(), Spawn.getInstance().getSpawnLocation(), 2);
} }