diff --git a/src/de/craftinc/gates/listeners/ChunkLoadListener.java b/src/de/craftinc/gates/listeners/ChunkLoadListener.java index b6854e7..ae991c4 100644 --- a/src/de/craftinc/gates/listeners/ChunkLoadListener.java +++ b/src/de/craftinc/gates/listeners/ChunkLoadListener.java @@ -1,6 +1,7 @@ package de.craftinc.gates.listeners; import de.craftinc.gates.Plugin; +import de.craftinc.gates.util.SimpleChunk; import de.craftinc.gates.util.TeleportRequest; import org.bukkit.ChatColor; import org.bukkit.Chunk; @@ -17,12 +18,15 @@ import java.util.List; public class ChunkLoadListener implements Listener { - private HashMap> pendingRequests = new HashMap>(); + private HashMap> pendingRequests = new HashMap>(); @EventHandler(priority = EventPriority.NORMAL) public void onChunkLoad(ChunkLoadEvent event) { - Chunk c = event.getChunk(); + System.out.println("loaded chunk: " + event.getChunk() + "world: " + event.getChunk().getWorld()); + System.out.println("pending: " + pendingRequests.keySet()); + + SimpleChunk c = new SimpleChunk(event.getChunk()); List requests = pendingRequests.get(c); if (requests != null) { @@ -50,7 +54,7 @@ public class ChunkLoadListener implements Listener throw new IllegalArgumentException("The request must not be null!"); } - Chunk c = r.getDestination().getChunk(); + SimpleChunk c = new SimpleChunk(r.getDestination().getChunk()); List requests = pendingRequests.get(c); if (requests == null) { diff --git a/src/de/craftinc/gates/listeners/PlayerMoveListener.java b/src/de/craftinc/gates/listeners/PlayerMoveListener.java index 4823ae4..9c92265 100644 --- a/src/de/craftinc/gates/listeners/PlayerMoveListener.java +++ b/src/de/craftinc/gates/listeners/PlayerMoveListener.java @@ -87,19 +87,24 @@ public class PlayerMoveListener implements Listener playerLocation.getPitch() ); - Chunk c = exit.getChunk(); - World w = exit.getWorld(); + Chunk teleportToChunk = teleportToLocation.getChunk(); - if (w.isChunkLoaded(c)) { - p.teleport(teleportToLocation); - p.sendMessage(ChatColor.DARK_AQUA + "Thank you for traveling with Craft Inc. Gates."); - } - else { - TeleportRequest request = new TeleportRequest(p, exit); +// System.out.println(teleportToChunk.getWorld() + "\n" + +// teleportToChunk.getX() + "," + teleportToChunk.getZ() + "\n" + +// teleportToChunk + "\n" + +// teleportToChunk.getChunkSnapshot() + "\n" + +// teleportToChunk.getTileEntities()); +// +// if (teleportToChunk.isLoaded()) { +// p.teleport(teleportToLocation); +// p.sendMessage(ChatColor.DARK_AQUA + "Thank you for traveling with Craft Inc. Gates."); +// } +// else { + TeleportRequest request = new TeleportRequest(p, teleportToLocation); Plugin.getPlugin().getChunkLoadListener().addTeleportRequest(request); - w.loadChunk(c); - } + teleportToChunk.load(); +// } } diff --git a/src/de/craftinc/gates/util/SimpleChunk.java b/src/de/craftinc/gates/util/SimpleChunk.java index 3c3b032..45bd513 100644 --- a/src/de/craftinc/gates/util/SimpleChunk.java +++ b/src/de/craftinc/gates/util/SimpleChunk.java @@ -44,4 +44,11 @@ public class SimpleChunk return hash; } + + + @Override + public String toString() + { + return this.getClass().toString() + " (x=" + this.x + " z=" + this.z + " world='" + this.world + "')"; + } } diff --git a/src/de/craftinc/gates/util/SimpleLocation.java b/src/de/craftinc/gates/util/SimpleLocation.java index d80f61e..337d9d7 100644 --- a/src/de/craftinc/gates/util/SimpleLocation.java +++ b/src/de/craftinc/gates/util/SimpleLocation.java @@ -23,7 +23,7 @@ public class SimpleLocation @Override - public boolean equals(Object o) + public boolean equals(final Object o) { if (o instanceof SimpleLocation) { SimpleLocation otherLocation = (SimpleLocation)o;