feat: WorldEdit Integration, fix logic error

This commit is contained in:
JOO200 2021-12-14 17:08:49 +01:00 committed by Sekwah
parent fdb22ab8b5
commit e3021367ab
1 changed files with 36 additions and 38 deletions

View File

@ -329,49 +329,47 @@ public class Listeners implements Listener {
} }
if (player.hasPermission("advancedportals.createportal")) { if (player.hasPermission("advancedportals.createportal")) {
if (!plugin.getSettings().enabledWorldEditIntegration()) { if (!plugin.getSettings().enabledWorldEditIntegration()
if (event.getItem() != null && event.getItem().getType() == WandMaterial // was type id && event.getItem() != null && event.getItem().getType() == WandMaterial // was type id
&& (!UseOnlyServerAxe || (checkItemForName(event.getItem()) && event.getItem().getItemMeta() && (!UseOnlyServerAxe || (checkItemForName(event.getItem()) && event.getItem().getItemMeta()
.getDisplayName().equals("\u00A7ePortal Region Selector")))) { .getDisplayName().equals("\u00A7ePortal Region Selector")))) {
// This checks if the action was a left or right click and if it was directly // This checks if the action was a left or right click and if it was directly
// effecting a block. // effecting a block.
if (event.getAction() == Action.LEFT_CLICK_BLOCK) { if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
Location blockloc = event.getClickedBlock().getLocation(); Location blockloc = event.getClickedBlock().getLocation();
// stores the selection as metadata on the character so then it isn't saved // stores the selection as metadata on the character so then it isn't saved
// anywhere, if the player logs out it will // anywhere, if the player logs out it will
// have to be selected again if the player joins, also it does not affect any // have to be selected again if the player joins, also it does not affect any
// other players. // other players.
player.setMetadata("Pos1X", new FixedMetadataValue(plugin, blockloc.getBlockX())); player.setMetadata("Pos1X", new FixedMetadataValue(plugin, blockloc.getBlockX()));
player.setMetadata("Pos1Y", new FixedMetadataValue(plugin, blockloc.getBlockY())); player.setMetadata("Pos1Y", new FixedMetadataValue(plugin, blockloc.getBlockY()));
player.setMetadata("Pos1Z", new FixedMetadataValue(plugin, blockloc.getBlockZ())); player.setMetadata("Pos1Z", new FixedMetadataValue(plugin, blockloc.getBlockZ()));
player.setMetadata("Pos1World", new FixedMetadataValue(plugin, blockloc.getWorld().getName())); player.setMetadata("Pos1World", new FixedMetadataValue(plugin, blockloc.getWorld().getName()));
player.sendMessage( player.sendMessage(
"\u00A7eYou have selected pos1! X:" + blockloc.getBlockX() + " Y:" + blockloc.getBlockY() "\u00A7eYou have selected pos1! X:" + blockloc.getBlockX() + " Y:" + blockloc.getBlockY()
+ " Z:" + blockloc.getBlockZ() + " World: " + blockloc.getWorld().getName()); + " Z:" + blockloc.getBlockZ() + " World: " + blockloc.getWorld().getName());
// Stops the event so the block is not damaged // Stops the event so the block is not damaged
event.setCancelled(true); event.setCancelled(true);
// Returns the event so no more code is executed(stops unnecessary code being // Returns the event so no more code is executed(stops unnecessary code being
// executed) // executed)
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { } else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
Location blockloc = event.getClickedBlock().getLocation(); Location blockloc = event.getClickedBlock().getLocation();
player.setMetadata("Pos2X", new FixedMetadataValue(plugin, blockloc.getBlockX())); player.setMetadata("Pos2X", new FixedMetadataValue(plugin, blockloc.getBlockX()));
player.setMetadata("Pos2Y", new FixedMetadataValue(plugin, blockloc.getBlockY())); player.setMetadata("Pos2Y", new FixedMetadataValue(plugin, blockloc.getBlockY()));
player.setMetadata("Pos2Z", new FixedMetadataValue(plugin, blockloc.getBlockZ())); player.setMetadata("Pos2Z", new FixedMetadataValue(plugin, blockloc.getBlockZ()));
player.setMetadata("Pos2World", new FixedMetadataValue(plugin, blockloc.getWorld().getName())); player.setMetadata("Pos2World", new FixedMetadataValue(plugin, blockloc.getWorld().getName()));
player.sendMessage( player.sendMessage(
"\u00A7eYou have selected pos2! X:" + blockloc.getBlockX() + " Y:" + blockloc.getBlockY() "\u00A7eYou have selected pos2! X:" + blockloc.getBlockX() + " Y:" + blockloc.getBlockY()
+ " Z:" + blockloc.getBlockZ() + " World: " + blockloc.getWorld().getName()); + " Z:" + blockloc.getBlockZ() + " World: " + blockloc.getWorld().getName());
// Stops the event so the block is not interacted with // Stops the event so the block is not interacted with
event.setCancelled(true); event.setCancelled(true);
// Returns the event so no more code is executed(stops unnecessary code being
// executed)
}
// Returns the event so no more code is executed(stops unnecessary code being
// executed)
} }
} else if (checkItemForName(event.getItem()) } else if (checkItemForName(event.getItem())
&& event.getItem().getItemMeta().getDisplayName().equals("\u00A75Portal Block Placer") && event.getItem().getItemMeta().getDisplayName().equals("\u00A75Portal Block Placer")