diff --git a/src/main/java/com/gamingmesh/jobs/PlayerManager.java b/src/main/java/com/gamingmesh/jobs/PlayerManager.java index 249c69b3..1a0630c7 100644 --- a/src/main/java/com/gamingmesh/jobs/PlayerManager.java +++ b/src/main/java/com/gamingmesh/jobs/PlayerManager.java @@ -1127,7 +1127,6 @@ public class PlayerManager { boost.add(BoostOf.Dynamic, new BoostMultiplier().add(prog.getBonus())); if (pl != null) { - CMIDebug.d(getItemBoostNBT(pl, prog).get(CurrencyType.MONEY)); boost.add(BoostOf.Item, getItemBoostNBT(pl, prog)); } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/explored.java b/src/main/java/com/gamingmesh/jobs/commands/list/explored.java index 57c1222e..67cdc125 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/explored.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/explored.java @@ -31,14 +31,14 @@ public class explored implements Cmd { ExploreRegion region = exploreRegion.get(RegionX + ":" + RegionZ); if (region == null) { player.sendMessage(Jobs.getLanguage().getMessage("command.explored.error.noexplore")); - return false; + return true; } ExploreChunk chunk = region.getChunk(player.getLocation().getChunk()); if (chunk == null) { player.sendMessage(Jobs.getLanguage().getMessage("command.explored.error.noexplore")); - return false; + return true; } if (Jobs.getGCManager().ExploreCompact && chunk.isFullyExplored()) { @@ -51,7 +51,7 @@ public class explored implements Cmd { for (int i = 0; i < players.size(); i++) { PlayerInfo ji = Jobs.getPlayerManager().getPlayerInfo(players.get(i)); if (ji != null) - player.sendMessage(Jobs.getLanguage().getMessage("command.explored.list", "%place%", i, "%playername%", ji.getName())); + player.sendMessage(Jobs.getLanguage().getMessage("command.explored.list", "%place%", i + 1, "%playername%", ji.getName())); } player.sendMessage(Jobs.getLanguage().getMessage("general.info.separator")); diff --git a/src/main/java/com/gamingmesh/jobs/config/ExploreManager.java b/src/main/java/com/gamingmesh/jobs/config/ExploreManager.java index b838273d..574e0ee4 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ExploreManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ExploreManager.java @@ -17,6 +17,8 @@ import com.gamingmesh.jobs.container.JobsWorld; import com.gamingmesh.jobs.dao.JobsDAO.ExploreDataTableFields; import com.gamingmesh.jobs.stuff.Util; +import net.Zrips.CMILib.Logs.CMIDebug; + public class ExploreManager { private final Map> worlds = new HashMap<>(); @@ -85,10 +87,14 @@ public class ExploreManager { if (region == null) { region = new ExploreRegion(RegionX, RegionZ); } - ExploreChunk chunk = region.getChunk(x, z); + + int chunkRelativeX = (RegionX * 32) - x; + int chunkRelativeZ = (RegionZ * 32) - z; + + ExploreChunk chunk = region.getChunk(chunkRelativeX, chunkRelativeZ); if (chunk == null) { chunk = new ExploreChunk(); - region.addChunk(x, z, chunk); + region.addChunk(chunkRelativeX, chunkRelativeZ, chunk); } eRegions.put(RegionX + ":" + RegionZ, region); @@ -119,14 +125,17 @@ public class ExploreManager { int RegionX = (int) Math.floor(x / 32D); int RegionZ = (int) Math.floor(z / 32D); + int chunkRelativeX = RegionX * 32 - x; + int chunkRelativeZ = RegionZ * 32 - z; + ExploreRegion region = eRegions.get(RegionX + ":" + RegionZ); if (region == null) { region = new ExploreRegion(RegionX, RegionZ); } - ExploreChunk chunk = region.getChunk(x, z); + ExploreChunk chunk = region.getChunk(chunkRelativeX, chunkRelativeZ); if (chunk == null) { chunk = new ExploreChunk(); - region.addChunk(x, z, chunk); + region.addChunk(chunkRelativeX, chunkRelativeZ, chunk); } chunk.deserializeNames(names); chunk.setDbId(id); diff --git a/src/main/java/com/gamingmesh/jobs/container/ExploreChunk.java b/src/main/java/com/gamingmesh/jobs/container/ExploreChunk.java index fa9e85e3..6250be36 100644 --- a/src/main/java/com/gamingmesh/jobs/container/ExploreChunk.java +++ b/src/main/java/com/gamingmesh/jobs/container/ExploreChunk.java @@ -5,6 +5,8 @@ import java.util.List; import com.gamingmesh.jobs.Jobs; +import net.Zrips.CMILib.Logs.CMIDebug; + public class ExploreChunk { private List playerIds = new ArrayList<>(); @@ -31,7 +33,7 @@ public class ExploreChunk { } List players = getPlayers(); - + return new ExploreRespond(newChunkForPlayer ? players.size() : players.size() + 1, newChunkForPlayer); } diff --git a/src/main/java/com/gamingmesh/jobs/container/ExploreRegion.java b/src/main/java/com/gamingmesh/jobs/container/ExploreRegion.java index a08c17b6..98ec68f9 100644 --- a/src/main/java/com/gamingmesh/jobs/container/ExploreRegion.java +++ b/src/main/java/com/gamingmesh/jobs/container/ExploreRegion.java @@ -7,49 +7,79 @@ import org.bukkit.Chunk; public class ExploreRegion { - int x; - int z; + private int x; + private int z; - private final Map chunks = new HashMap<>(); + private final Map chunks = new HashMap<>(); public ExploreRegion(int x, int z) { - this.x = x; - this.z = z; + this.x = x; + this.z = z; } - public void addChunk(int x, int z, ExploreChunk chunk) { - chunks.put(getPlace(x, z), chunk); + public void addChunk(int relativeX, int relativeZ, ExploreChunk chunk) { + chunks.put(getPlace(relativeX, relativeZ), chunk); } - public Map getChunks() { - return chunks; + public Map getChunks() { + return chunks; } - public ExploreChunk getChunk(int x, int z) { - return getChunk(getPlace(x, z)); + public ExploreChunk getChunk(int relativeX, int relativeZ) { + return getChunk(getPlace(relativeX, relativeZ)); } public ExploreChunk getChunk(Chunk chunk) { - return getChunk(getPlace(chunk)); + return getChunk(getPlace(chunk)); } public ExploreChunk getChunk(long place) { - return chunks.get(place); + return chunks.get((short) place); } - private static long getPlace(Chunk chunk) { - return getPlace(chunk.getX(), chunk.getZ()); + public ExploreChunk getChunk(Short place) { + return chunks.get(place); } - private static long getPlace(int x, int z) { - return (((long) x) << 32) | (z & 0xffffffff); + private long getPlace(Chunk chunk) { + return getPlace((x * 32) - chunk.getX(), (z * 32) - chunk.getZ()); } + private static short getPlace(int relativeX, int relativeZ) { + return (short) (relativeX * 32 + relativeZ); + } + + @Deprecated public int getChunkX(long place) { - return (int)(place >> 32); + return (int) (place / 32); } + public int getChunkRelativeX(short place) { + return place / 32; + } + + public int getChunkGlobalX(short place) { + return (getX() * 32) - getChunkRelativeX(place); + } + + @Deprecated public int getChunkZ(long place) { - return (int) place; + return (int) place % 32; + } + + public int getChunkRelativeZ(short place) { + return place % 32; + } + + public int getChunkGlobalZ(short place) { + return (getZ() * 32) - getChunkRelativeZ(place); + } + + public int getX() { + return x; + } + + public int getZ() { + return z; } } diff --git a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java index 4259f451..36911932 100644 --- a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java +++ b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java @@ -2484,14 +2484,14 @@ public abstract class JobsDAO { int id = jobsWorld == null ? 0 : jobsWorld.getId(); if (id != 0) - for (Entry oneChunk : region.getValue().getChunks().entrySet()) { + for (Entry oneChunk : region.getValue().getChunks().entrySet()) { ExploreChunk chunk = oneChunk.getValue(); if (chunk.getDbId() != -1) continue; prest2.setInt(1, id); - prest2.setInt(2, region.getValue().getChunkX(oneChunk.getKey())); - prest2.setInt(3, region.getValue().getChunkZ(oneChunk.getKey())); - prest2.setString(4, chunk.serializeNames()); + prest2.setInt(2, region.getValue().getChunkGlobalX(oneChunk.getKey())); + prest2.setInt(3, region.getValue().getChunkGlobalZ(oneChunk.getKey())); + prest2.setString(4, chunk.serializeNames()); prest2.setString(5, jobsWorld != null ? jobsWorld.getName() : ""); prest2.addBatch(); i++; diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 00eb79a0..7809db13 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -129,6 +129,7 @@ import net.Zrips.CMILib.Entities.CMIEntityType; import net.Zrips.CMILib.Items.CMIItemStack; import net.Zrips.CMILib.Items.CMIMaterial; import net.Zrips.CMILib.Locale.LC; +import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Version.Version; @@ -1806,7 +1807,6 @@ public final class JobsPaymentListener implements Listener { @EventHandler(ignoreCancelled = true) public void onExplore(JobsChunkChangeEvent event) { - if (!Jobs.getExploreManager().isExploreEnabled()) return;