diff --git a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/listener/OnBlockBreak.java b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/listener/OnBlockBreak.java deleted file mode 100644 index a9e5477..0000000 --- a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/listener/OnBlockBreak.java +++ /dev/null @@ -1,26 +0,0 @@ -package eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.listener; - -import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main; -import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterBlock; -import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterItem; -import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterManager; -import org.bukkit.GameMode; -import org.bukkit.event.block.BlockBreakEvent; - -public class OnBlockBreak { - - public static void onBlockBreakEvent(BlockBreakEvent e, LinkedBeaconTeleporterBlock lbtBlock){ - LinkedBeaconTeleporterItem lbtItem = Main.lbtManager.breakLbtBlock(lbtBlock); - - // Dont drop anything - e.setDropItems(false); - e.setExpToDrop(0); - - // Drop custom-item - if(e.getPlayer().getGameMode() != GameMode.CREATIVE) - lbtBlock.block().getLocation().getWorld().dropItemNaturally( - lbtBlock.block().getLocation(), - lbtItem.item() - ); - } -} diff --git a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/listener/OnBlockPlace.java b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/listener/OnBlockPlace.java deleted file mode 100644 index e474b01..0000000 --- a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/listener/OnBlockPlace.java +++ /dev/null @@ -1,16 +0,0 @@ -package eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.listener; - -import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main; -import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterBlock; -import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterItem; -import org.bukkit.block.Block; -import org.bukkit.event.block.BlockPlaceEvent; - -public class OnBlockPlace { - - public static void onBlockPlaceEvent(BlockPlaceEvent e, LinkedBeaconTeleporterItem lbtItem){ - Block block = e.getBlock(); - - LinkedBeaconTeleporterBlock lbtBlock = Main.lbtManager.placeLbtItem(lbtItem, block); - } -} diff --git a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/listener/OnCraftItemEvent.java b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/listener/OnCraftItemEvent.java deleted file mode 100644 index 80c72a9..0000000 --- a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/listener/OnCraftItemEvent.java +++ /dev/null @@ -1,27 +0,0 @@ -package eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.listener; - -import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main; -import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterItem; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.CraftItemEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.Recipe; - -public class OnCraftItemEvent { - - public static void onCraftItemEvent(CraftItemEvent e, LinkedBeaconTeleporterItem lbtItem){ - - // Create new LinkedBeaconTeleporterItem - lbtItem = new LinkedBeaconTeleporterItem(); - - ItemStack item = lbtItem.item(); - // Exactly 2 - item.setAmount(2); - - // FIXME: Changing the just-crafted-item only works for a single item, bulk-crafting (e.g. Shift-Click) will result in default-items getting crafted! - - e.setCurrentItem(item); - } -} diff --git a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnBlockBreak.java b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnBlockBreak.java index cbf4eff..2018faa 100644 --- a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnBlockBreak.java +++ b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnBlockBreak.java @@ -2,6 +2,8 @@ package eu.ruekov.ruakij.LinkedBeaconTeleporters.listener; import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main; import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterBlock; +import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterItem; +import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -21,9 +23,21 @@ public class OnBlockBreak implements Listener { // Check if this beacon is a LinkedBeaconTeleporter LinkedBeaconTeleporterBlock lbtBlock = LinkedBeaconTeleporterBlock.getFromLocation(loc); - if(lbtBlock != null){ - eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.listener.OnBlockBreak.onBlockBreakEvent(e, lbtBlock); - } + // Ignore if not found + if(lbtBlock == null) return; + + LinkedBeaconTeleporterItem lbtItem = Main.lbtManager.breakLbtBlock(lbtBlock); + + // Dont drop anything + e.setDropItems(false); + e.setExpToDrop(0); + + // Drop custom-item + if(e.getPlayer().getGameMode() != GameMode.CREATIVE) + lbtBlock.block().getLocation().getWorld().dropItemNaturally( + lbtBlock.block().getLocation(), + lbtItem.item() + ); } } } diff --git a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnBlockPlace.java b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnBlockPlace.java index d117163..11ea48e 100644 --- a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnBlockPlace.java +++ b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnBlockPlace.java @@ -1,5 +1,7 @@ package eu.ruekov.ruakij.LinkedBeaconTeleporters.listener; +import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main; +import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterBlock; import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterItem; import org.bukkit.Material; import org.bukkit.block.Block; @@ -20,9 +22,11 @@ public class OnBlockPlace implements Listener { // Check if this beacon is a LinkedBeaconTeleporter LinkedBeaconTeleporterItem lbtItem = LinkedBeaconTeleporterItem.getFromItemStack(item); - if(lbtItem != null){ - eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.listener.OnBlockPlace.onBlockPlaceEvent(e, lbtItem); - } + // Ignore if not found + if(lbtItem == null) return; + + Block block = e.getBlock(); + LinkedBeaconTeleporterBlock lbtBlock = Main.lbtManager.placeLbtItem(lbtItem, block); } } } diff --git a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnCraftItemEvent.java b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnCraftItemEvent.java index b9cc7b7..ef02021 100644 --- a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnCraftItemEvent.java +++ b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnCraftItemEvent.java @@ -22,8 +22,19 @@ public class OnCraftItemEvent implements Listener { // Check if it has LinkedBeaconTeleporter-Data LinkedBeaconTeleporterItem lbtItem = Main.lbtManager.getLbtItemFromItemStack(itemResult); - if(lbtItem != null){ - eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.listener.OnCraftItemEvent.onCraftItemEvent(e, lbtItem); - } + + // Ignore if not found + if(lbtItem == null) return; + + // Create new LinkedBeaconTeleporterItem + lbtItem = new LinkedBeaconTeleporterItem(); + + ItemStack item = lbtItem.item(); + // Exactly 2 + item.setAmount(2); + + // FIXME: Changing the just-crafted-item only works for a single item, bulk-crafting (e.g. Shift-Click) will result in default-items getting crafted! + + e.setCurrentItem(item); } }