mirror of
https://github.com/songoda/UltimateRepairing.git
synced 2024-11-01 00:10:19 +01:00
Redid how infinity works.
This commit is contained in:
parent
5f9dce66c9
commit
a878521e98
@ -8,6 +8,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
/**
|
||||
@ -46,4 +47,17 @@ public class BlockListeners implements Listener {
|
||||
anvil.setHologram(false);
|
||||
plugin.getAnvilManager().removeAnvil(event.getBlock().getLocation());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
String loc = Methods.serializeLocation(event.getBlock());
|
||||
if (!event.getBlock().getType().name().contains("ANVIL") && !plugin.getConfig().contains("data.anvil." + loc))
|
||||
return;
|
||||
|
||||
UAnvil anvil = plugin.getAnvilManager().getAnvil(event.getBlock());
|
||||
if (anvil.isInfinity())
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -33,7 +33,6 @@ public class InteractListeners implements Listener {
|
||||
@EventHandler
|
||||
public void onAnvilClick(PlayerInteractEvent event) {
|
||||
boolean ourRepair = false;
|
||||
boolean vanillaRepair = false;
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getClickedBlock();
|
||||
if (block == null) return;
|
||||
@ -63,10 +62,7 @@ public class InteractListeners implements Listener {
|
||||
return;
|
||||
}
|
||||
ourRepair = true;
|
||||
} else if (rightClick) {
|
||||
// allowing normal repair
|
||||
vanillaRepair = true;
|
||||
} else if (!player.isSneaking()) {
|
||||
} else if (!rightClick && !player.isSneaking()) {
|
||||
// that's us!
|
||||
ourRepair = true;
|
||||
}
|
||||
@ -74,9 +70,6 @@ public class InteractListeners implements Listener {
|
||||
if (ourRepair) {
|
||||
RepairGui.newGui(player, anvil1.getLocation());
|
||||
event.setCancelled(true);
|
||||
} else if (vanillaRepair && anvil1.isInfinity()) {
|
||||
player.openInventory(Bukkit.createInventory(null, InventoryType.ANVIL, ChatColor.DARK_GRAY + "Repair & Name"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user