ElgarL / Towny

Towny Advanced plugin for Bukkit @ http://palmergames.com/towny/
http://palmergames.com/towny/
76 stars 92 forks source link

ProtectionRegenTask #166

Closed DrkMatr1984 closed 8 years ago

DrkMatr1984 commented 8 years ago

I am trying to store locations in a yml, That works fine, and they can be retrieved. However, I cannot retrieve a ProtectionRegenTask stored inside of TownyRegenAPI by using this method.

public void onBlockBreak(BlockBreakEvent event) {
ProtectionRegenTask task = new ProtectionRegenTask(this.mplugin.getInstance().getTowny(), event.getBlock(), true);

ProtectionRegenTask tryTask;
TownyRegenAPI.addProtectionRegenTask(task);
BlockLocation bl = new BlockLocation(event.getBlock().getLocation());

if(TownyRegenAPI.hasProtectionRegenTask(bl)){
tryTask = TownyRegenAPI.getProtectionRegenTask(bl);
}
if(bl.equals(TownyRegenAPI.getProtectionRegenTask(task).getBlockLocation())){ // these are never equal
event.getPlayer().sendMessage("These are the same");
}
}

How to retrieve a ProtectionRegenTask by BlockLocation? And why are they not equal when the same block is used to assemble the task that is used to retrieve the task?

We also tried

ProtectionRegenTask task = new ProtectionRegenTask(this.mplugin.getInstance().getTowny(), event.getBlock(), true); ProtectionRegenTask tryTask; TownyRegenAPI.addProtectionRegenTask(task); BlockLocation bl = new BlockLocation(event.getBlock().getLocation()); if(TownyRegenAPI.hasProtectionRegenTask(bl)){ tryTask = TownyRegenAPI.getProtectionRegenTask(bl); } if(bl.equals(task.getBlockLocation())){ event.getPlayer().sendMessage("These are the same"); }else{ System.out.println("World:" + bl.getWorld().toString() + " X:" + ((Integer)bl.getX()).toString() + " Y:" + ((Integer)bl.getY()).toString() + " Z:" + ((Integer)bl.getZ()).toString()); System.out.println("World:" + task.getBlockLocation().getWorld().toString() + " X:" + ((Integer)task.getBlockLocation().getX()).toString() + " Y:" + ((Integer)task.getBlockLocation().getY()).toString() + " Z:" + ((Integer)task.getBlockLocation().getZ()).toString()); } }

And the locations are exactly the same.