From d1045685e58389e720f90c9a0d58ec17ff5a3f3e Mon Sep 17 00:00:00 2001 From: Torrie Fischer Date: Mon, 14 Jun 2021 13:26:52 -0700 Subject: [PATCH] regionpostitemwatcher: remove more api that was removed in 1.17 --- src/main/java/us/camin/regions/Region.java | 4 ++-- .../regions/RegionPostInteractionWatcher.java | 16 +++++++++------- .../us/camin/regions/RegionPostItemWatcher.java | 3 ++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/us/camin/regions/Region.java b/src/main/java/us/camin/regions/Region.java index 31b05b7..e5a4da0 100644 --- a/src/main/java/us/camin/regions/Region.java +++ b/src/main/java/us/camin/regions/Region.java @@ -47,12 +47,12 @@ public class Region { private boolean m_isHub = false; public Region(String name, Location location) { - m_location = location.toBlockLocation(); + m_location = location.getBlock().getLocation(); m_name = name; } public Region(String name, Location location, int visits, int charges, DyeColor color) { - m_location = location.toBlockLocation(); + m_location = location.getBlock().getLocation(); m_name = name; m_visits = visits; m_charges = charges; diff --git a/src/main/java/us/camin/regions/RegionPostInteractionWatcher.java b/src/main/java/us/camin/regions/RegionPostInteractionWatcher.java index 74cf1bd..544d9f5 100644 --- a/src/main/java/us/camin/regions/RegionPostInteractionWatcher.java +++ b/src/main/java/us/camin/regions/RegionPostInteractionWatcher.java @@ -89,12 +89,13 @@ public class RegionPostInteractionWatcher implements Listener { Location lanternRegion = nearest.interactLocation().add(0, 1, 0); boolean isInteracted = false; if (clickedBlock != null) { - isInteracted |= clickedBlock.getBlockKey() == interactRegion.toBlockKey(); - isInteracted |= clickedBlock.getBlockKey() == lanternRegion.toBlockKey(); - isInteracted |= nearest.interactLocation().add(1, 0, 0).toBlockKey() == clickedBlock.getBlockKey(); - isInteracted |= nearest.interactLocation().add(-1, 0, 0).toBlockKey() == clickedBlock.getBlockKey(); - isInteracted |= nearest.interactLocation().add(0, 0, 1).toBlockKey() == clickedBlock.getBlockKey(); - isInteracted |= nearest.interactLocation().add(0, 0, -1).toBlockKey() == clickedBlock.getBlockKey(); + + isInteracted |= clickedBlock.getLocation().equals(interactRegion.getBlock().getLocation()); + isInteracted |= clickedBlock.getLocation().equals(lanternRegion.getBlock().getLocation()); + isInteracted |= nearest.interactLocation().add(1, 0, 0).getBlock().getLocation().equals(clickedBlock.getLocation()); + isInteracted |= nearest.interactLocation().add(-1, 0, 0).getBlock().getLocation().equals(clickedBlock.getLocation()); + isInteracted |= nearest.interactLocation().add(0, 0, 1).getBlock().getLocation().equals(clickedBlock.getLocation()); + isInteracted |= nearest.interactLocation().add(0, 0, -1).getBlock().getLocation().equals(clickedBlock.getLocation()); } if (isInteracted) { event.setCancelled(true); @@ -110,7 +111,8 @@ public class RegionPostInteractionWatcher implements Listener { builder.updateLantern(); }); m_plugin.saveRegions(); - player.setItemInHand(handStack.subtract()); + handStack.setAmount(handStack.getAmount()-1); + player.setItemInHand(handStack); m_plugin.getServer().getPluginManager().callEvent(new PlayerAddRegionChargeEvent(player, nearest)); // TODO: Make this configurable and disablable player.giveExp(1); diff --git a/src/main/java/us/camin/regions/RegionPostItemWatcher.java b/src/main/java/us/camin/regions/RegionPostItemWatcher.java index 19e4f87..cbd831b 100644 --- a/src/main/java/us/camin/regions/RegionPostItemWatcher.java +++ b/src/main/java/us/camin/regions/RegionPostItemWatcher.java @@ -169,7 +169,8 @@ public class RegionPostItemWatcher implements Listener { RegionPostBuilder builder = new RegionPostBuilder(r, m_plugin); builder.build(); }); - player.setItemInHand(handStack.subtract()); + handStack.setAmount(handStack.getAmount()-1); + player.setItemInHand(handStack); m_plugin.regionManager().addRegion(r); m_plugin.saveRegions(); player.sendMessage("You established the region "+r.coloredName());