regionpostitemwatcher: remove more api that was removed in 1.17

This commit is contained in:
Torrie Fischer 2021-06-14 13:26:52 -07:00
parent b1350ab36b
commit 5e309819eb
3 changed files with 13 additions and 10 deletions

View File

@ -47,12 +47,12 @@ public class Region {
private boolean m_isHub = false; private boolean m_isHub = false;
public Region(String name, Location location) { public Region(String name, Location location) {
m_location = location.toBlockLocation(); m_location = location.getBlock().getLocation();
m_name = name; m_name = name;
} }
public Region(String name, Location location, int visits, int charges, DyeColor color) { 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_name = name;
m_visits = visits; m_visits = visits;
m_charges = charges; m_charges = charges;

View File

@ -89,12 +89,13 @@ public class RegionPostInteractionWatcher implements Listener {
Location lanternRegion = nearest.interactLocation().add(0, 1, 0); Location lanternRegion = nearest.interactLocation().add(0, 1, 0);
boolean isInteracted = false; boolean isInteracted = false;
if (clickedBlock != null) { if (clickedBlock != null) {
isInteracted |= clickedBlock.getBlockKey() == interactRegion.toBlockKey();
isInteracted |= clickedBlock.getBlockKey() == lanternRegion.toBlockKey(); isInteracted |= clickedBlock.getLocation().equals(interactRegion.getBlock().getLocation());
isInteracted |= nearest.interactLocation().add(1, 0, 0).toBlockKey() == clickedBlock.getBlockKey(); isInteracted |= clickedBlock.getLocation().equals(lanternRegion.getBlock().getLocation());
isInteracted |= nearest.interactLocation().add(-1, 0, 0).toBlockKey() == clickedBlock.getBlockKey(); isInteracted |= nearest.interactLocation().add(1, 0, 0).getBlock().getLocation().equals(clickedBlock.getLocation());
isInteracted |= nearest.interactLocation().add(0, 0, 1).toBlockKey() == clickedBlock.getBlockKey(); isInteracted |= nearest.interactLocation().add(-1, 0, 0).getBlock().getLocation().equals(clickedBlock.getLocation());
isInteracted |= nearest.interactLocation().add(0, 0, -1).toBlockKey() == clickedBlock.getBlockKey(); 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) { if (isInteracted) {
event.setCancelled(true); event.setCancelled(true);
@ -110,7 +111,8 @@ public class RegionPostInteractionWatcher implements Listener {
builder.updateLantern(); builder.updateLantern();
}); });
m_plugin.saveRegions(); m_plugin.saveRegions();
player.setItemInHand(handStack.subtract()); handStack.setAmount(handStack.getAmount()-1);
player.setItemInHand(handStack);
m_plugin.getServer().getPluginManager().callEvent(new PlayerAddRegionChargeEvent(player, nearest)); m_plugin.getServer().getPluginManager().callEvent(new PlayerAddRegionChargeEvent(player, nearest));
// TODO: Make this configurable and disablable // TODO: Make this configurable and disablable
player.giveExp(1); player.giveExp(1);

View File

@ -169,7 +169,8 @@ public class RegionPostItemWatcher implements Listener {
RegionPostBuilder builder = new RegionPostBuilder(r, m_plugin); RegionPostBuilder builder = new RegionPostBuilder(r, m_plugin);
builder.build(); builder.build();
}); });
player.setItemInHand(handStack.subtract()); handStack.setAmount(handStack.getAmount()-1);
player.setItemInHand(handStack);
m_plugin.regionManager().addRegion(r); m_plugin.regionManager().addRegion(r);
m_plugin.saveRegions(); m_plugin.saveRegions();
player.sendMessage("You established the region "+r.coloredName()); player.sendMessage("You established the region "+r.coloredName());