Testing code for not working chunk load listener.
This commit is contained in:
parent
e6e6273147
commit
faabb2f9db
@ -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<Chunk, List<TeleportRequest>> pendingRequests = new HashMap<Chunk, List<TeleportRequest>>();
|
||||
private HashMap<SimpleChunk, List<TeleportRequest>> pendingRequests = new HashMap<SimpleChunk, List<TeleportRequest>>();
|
||||
|
||||
@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<TeleportRequest> 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<TeleportRequest> requests = pendingRequests.get(c);
|
||||
|
||||
if (requests == null) {
|
||||
|
@ -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();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 + "')";
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user