mirror of
https://github.com/songoda/EpicAnchors.git
synced 2024-10-31 23:59:35 +01:00
Anchors are now breakable.
Anchors are now properly identified before breaking.
This commit is contained in:
parent
c76370af43
commit
89c3856ae1
@ -11,5 +11,7 @@ public interface AnchorManager {
|
||||
|
||||
Anchor getAnchor(Location location);
|
||||
|
||||
boolean isAnchor(Location location);
|
||||
|
||||
Map<Location, Anchor> getAnchors();
|
||||
}
|
||||
|
@ -237,6 +237,19 @@ public class EpicAnchorsPlugin extends JavaPlugin implements EpicAnchors {
|
||||
return item;
|
||||
}
|
||||
|
||||
public void bust(Location location) {
|
||||
if (!getAnchorManager().isAnchor(location)) return;
|
||||
|
||||
Anchor anchor = getAnchorManager().getAnchor(location);
|
||||
|
||||
if (getConfig().getBoolean("Main.Allow Anchor Breaking")) {
|
||||
ItemStack item = makeAnchorItem(anchor.getTicksLeft());
|
||||
anchor.getLocation().getWorld().dropItemNaturally(anchor.getLocation(), item);
|
||||
}
|
||||
location.getBlock().setType(Material.AIR);
|
||||
getAnchorManager().removeAnchor(location);
|
||||
}
|
||||
|
||||
public MenuHandler getMenuHandler() {
|
||||
return menuHandler;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public class EAnchorManager implements AnchorManager {
|
||||
|
||||
@Override
|
||||
public Anchor addAnchor(Location location, Anchor anchor) {
|
||||
return registeredAnchors.put(location, anchor);
|
||||
return registeredAnchors.put(roundLocation(location), anchor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -24,7 +24,12 @@ public class EAnchorManager implements AnchorManager {
|
||||
|
||||
@Override
|
||||
public Anchor getAnchor(Location location) {
|
||||
return registeredAnchors.get(location);
|
||||
return registeredAnchors.get(roundLocation(location));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAnchor(Location location) {
|
||||
return registeredAnchors.containsKey(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,15 +34,4 @@ public class BlockListeners implements Listener {
|
||||
instance.getAnchorManager().addAnchor(event.getBlock().getLocation(), new EAnchor(event.getBlock().getLocation(), instance.getTicksFromItem(item)));
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Anchor anchor = instance.getAnchorManager().getAnchor(event.getBlock().getLocation());
|
||||
|
||||
if (instance.getConfig().getBoolean("Main.Allow Anchor Breaking")) {
|
||||
ItemStack item = instance.makeAnchorItem(anchor.getTicksLeft());
|
||||
anchor.getLocation().getWorld().dropItemNaturally(anchor.getLocation(), item);
|
||||
}
|
||||
instance.getAnchorManager().removeAnchor(event.getBlock().getLocation());
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,10 @@ public class InteractListeners implements Listener {
|
||||
@EventHandler
|
||||
public void onBlockInteract(PlayerInteractEvent e) {
|
||||
|
||||
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
||||
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) {
|
||||
instance.bust(e.getClickedBlock().getLocation());
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance.getAnchorManager().getAnchor(e.getClickedBlock().getLocation()) == null) return;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: EpicAnchors
|
||||
description: EpicAnchors
|
||||
version: 1.1
|
||||
version: 1.1.2
|
||||
depend: [Arconix]
|
||||
main: com.songoda.epicanchors.EpicAnchorsPlugin
|
||||
author: songoda
|
||||
|
Loading…
Reference in New Issue
Block a user