diff --git a/pom.xml b/pom.xml index cccf25a..41af42e 100644 --- a/pom.xml +++ b/pom.xml @@ -147,7 +147,7 @@ org.spigotmc spigot-api - 1.16.4-R0.1-SNAPSHOT + 1.16.5-R0.1-SNAPSHOT provided diff --git a/resources/config/v12/de/config.yml b/resources/config/v12/de/config.yml index 370ac6a..deab55c 100644 --- a/resources/config/v12/de/config.yml +++ b/resources/config/v12/de/config.yml @@ -509,6 +509,9 @@ openLargeBarrelEverywhere: true # Ob nur ein Minimum an Kessel-Partikeln dargestellt werden sollen [false] minimalParticles: false +# Ob das Entleeren von Brewery Tränken mit Hilfe von Trichtern möglich ist, um die Glasflasche zurück zu bekommen [true] +brewHopperDump: true + # -- Chat Veränderungs Einstellungen -- diff --git a/resources/config/v12/en/config.yml b/resources/config/v12/en/config.yml index f9b2500..eee80b8 100644 --- a/resources/config/v12/en/config.yml +++ b/resources/config/v12/en/config.yml @@ -510,6 +510,9 @@ openLargeBarrelEverywhere: true # If Cauldron Particles should be reduced to the bare minimum [false] minimalParticles: false +# Allow emptying brews into hoppers to discard brews while keeping the glass bottle [true] +brewHopperDump: true + # -- Chat Distortion Settings -- diff --git a/resources/config/v12/fr/config.yml b/resources/config/v12/fr/config.yml index 5510f23..cda1846 100644 --- a/resources/config/v12/fr/config.yml +++ b/resources/config/v12/fr/config.yml @@ -505,6 +505,9 @@ openLargeBarrelEverywhere: true # If Cauldron Particles should be reduced to the bare minimum [false] minimalParticles: false +# Allow emptying brews into hoppers to discard brews while keeping the glass bottle [true] +brewHopperDump: true + # -- Paramètres de la distorsion du Chat -- diff --git a/resources/config/v12/it/config.yml b/resources/config/v12/it/config.yml index e77e18e..7fe51f3 100644 --- a/resources/config/v12/it/config.yml +++ b/resources/config/v12/it/config.yml @@ -497,6 +497,9 @@ openLargeBarrelEverywhere: true # If Cauldron Particles should be reduced to the bare minimum [false] minimalParticles: false +# Allow emptying brews into hoppers to discard brews while keeping the glass bottle [true] +brewHopperDump: true + # -- Imostazioni di distorsione della chat -- diff --git a/resources/config/v13/de/config.yml b/resources/config/v13/de/config.yml index 6b1701e..81ae961 100644 --- a/resources/config/v13/de/config.yml +++ b/resources/config/v13/de/config.yml @@ -906,6 +906,9 @@ openLargeBarrelEverywhere: true # Ob nur ein Minimum an Kessel-Partikeln dargestellt werden sollen [false] minimalParticles: false +# Ob das Entleeren von Brewery Tränken mit Hilfe von Trichtern möglich ist, um die Glasflasche zurück zu bekommen [true] +brewHopperDump: true + # -- Chat Veränderungs Einstellungen -- diff --git a/resources/config/v13/en/config.yml b/resources/config/v13/en/config.yml index c99650b..581b494 100644 --- a/resources/config/v13/en/config.yml +++ b/resources/config/v13/en/config.yml @@ -899,6 +899,9 @@ openLargeBarrelEverywhere: true # If Cauldron Particles should be reduced to the bare minimum [false] minimalParticles: false +# Allow emptying brews into hoppers to discard brews while keeping the glass bottle [true] +brewHopperDump: true + # -- Chat Distortion Settings -- diff --git a/resources/config/v13/es/config.yml b/resources/config/v13/es/config.yml index c2af9d0..8f80366 100644 --- a/resources/config/v13/es/config.yml +++ b/resources/config/v13/es/config.yml @@ -898,6 +898,9 @@ openLargeBarrelEverywhere: true # If Cauldron Particles should be reduced to the bare minimum [false] minimalParticles: false +# Allow emptying brews into hoppers to discard brews while keeping the glass bottle [true] +brewHopperDump: true + # -- Chat Distortion Settings -- diff --git a/resources/config/v13/fr/config.yml b/resources/config/v13/fr/config.yml index e0d9e1c..fa6e82a 100644 --- a/resources/config/v13/fr/config.yml +++ b/resources/config/v13/fr/config.yml @@ -904,6 +904,9 @@ openLargeBarrelEverywhere: true # If Cauldron Particles should be reduced to the bare minimum [false] minimalParticles: false +# Allow emptying brews into hoppers to discard brews while keeping the glass bottle [true] +brewHopperDump: true + # -- Paramètres de la distorsion du Chat -- diff --git a/resources/config/v13/it/config.yml b/resources/config/v13/it/config.yml index 9703201..6c8beef 100644 --- a/resources/config/v13/it/config.yml +++ b/resources/config/v13/it/config.yml @@ -898,6 +898,9 @@ openLargeBarrelEverywhere: true # If Cauldron Particles should be reduced to the bare minimum [false] minimalParticles: false +# Allow emptying brews into hoppers to discard brews while keeping the glass bottle [true] +brewHopperDump: true + # -- Imostazioni di distorsione della chat -- diff --git a/resources/config/v13/zh/config.yml b/resources/config/v13/zh/config.yml index a7d2c5e..9171431 100644 --- a/resources/config/v13/zh/config.yml +++ b/resources/config/v13/zh/config.yml @@ -902,6 +902,9 @@ openLargeBarrelEverywhere: false # If Cauldron Particles should be reduced to the bare minimum [false] minimalParticles: false +# Allow emptying brews into hoppers to discard brews while keeping the glass bottle [true] +brewHopperDump: true + # -- 口糊设置 -- diff --git a/src/com/dre/brewery/BCauldron.java b/src/com/dre/brewery/BCauldron.java index fae52c6..035228c 100644 --- a/src/com/dre/brewery/BCauldron.java +++ b/src/com/dre/brewery/BCauldron.java @@ -389,7 +389,7 @@ public class BCauldron { if (item.getAmount() > 1) { item.setAmount(item.getAmount() - 1); } else { - setItemInHand(event, Material.AIR, false); + BUtil.setItemInHand(event, Material.AIR, false); } } } @@ -458,30 +458,17 @@ public class BCauldron { } } else { if (isBucket) { - setItemInHand(event, Material.BUCKET, handSwap); + BUtil.setItemInHand(event, Material.BUCKET, handSwap); } else if (isBottle) { - setItemInHand(event, Material.GLASS_BOTTLE, handSwap); + BUtil.setItemInHand(event, Material.GLASS_BOTTLE, handSwap); } else { - setItemInHand(event, Material.AIR, handSwap); + BUtil.setItemInHand(event, Material.AIR, handSwap); } } } } } - @SuppressWarnings("deprecation") - public static void setItemInHand(PlayerInteractEvent event, Material mat, boolean swapped) { - if (P.use1_9) { - if ((event.getHand() == EquipmentSlot.OFF_HAND) != swapped) { - event.getPlayer().getInventory().setItemInOffHand(new ItemStack(mat)); - } else { - event.getPlayer().getInventory().setItemInMainHand(new ItemStack(mat)); - } - } else { - event.getPlayer().setItemInHand(new ItemStack(mat)); - } - } - /** * Recalculate the Cauldron Particle Recipe */ diff --git a/src/com/dre/brewery/BDistiller.java b/src/com/dre/brewery/BDistiller.java index e4ed727..191e941 100644 --- a/src/com/dre/brewery/BDistiller.java +++ b/src/com/dre/brewery/BDistiller.java @@ -175,7 +175,7 @@ public class BDistiller { BlockState now = standBlock.getState(); if (now instanceof BrewingStand) { BrewingStand stand = (BrewingStand) now; - if (brewTime == -1) { // only check at the beginning (and end) for distillables + if (brewTime == -1) { // check at the beginning for distillables if (!prepareForDistillables(stand)) { return; } @@ -185,7 +185,7 @@ public class BDistiller { stand.setBrewingTime((int) ((float) brewTime / ((float) runTime / (float) DISTILLTIME)) + 1); if (brewTime <= 1) { // Done! - contents = getDistillContents(stand.getInventory()); + contents = getDistillContents(stand.getInventory()); // Get the contents again at the end just in case stand.setBrewingTime(0); stand.update(); if (!runDistill(stand.getInventory(), contents)) { diff --git a/src/com/dre/brewery/filedata/BConfig.java b/src/com/dre/brewery/filedata/BConfig.java index 00e5e7f..8444ea6 100644 --- a/src/com/dre/brewery/filedata/BConfig.java +++ b/src/com/dre/brewery/filedata/BConfig.java @@ -89,6 +89,7 @@ public class BConfig { public static boolean enableEncode; public static boolean alwaysShowQuality; // Always show quality stars public static boolean alwaysShowAlc; // Always show alc% + public static boolean brewHopperDump; // Allow Dumping of Brew liquid into Hoppers //Features public static boolean craftSealingTable; // Allow Crafting of Sealing Table @@ -240,6 +241,7 @@ public class BConfig { minimalParticles = config.getBoolean("minimalParticles", false); useOffhandForCauldron = config.getBoolean("useOffhandForCauldron", false); loadDataAsync = config.getBoolean("loadDataAsync", true); + brewHopperDump = config.getBoolean("brewHopperDump", false); if (P.use1_14) { MCBarrel.maxBrews = config.getInt("maxBrewsInMCBarrels", 6); diff --git a/src/com/dre/brewery/listeners/PlayerListener.java b/src/com/dre/brewery/listeners/PlayerListener.java index 05077b6..22e5432 100644 --- a/src/com/dre/brewery/listeners/PlayerListener.java +++ b/src/com/dre/brewery/listeners/PlayerListener.java @@ -3,6 +3,7 @@ package com.dre.brewery.listeners; import com.dre.brewery.*; import com.dre.brewery.filedata.BConfig; import com.dre.brewery.filedata.UpdateChecker; +import com.dre.brewery.utility.BUtil; import com.dre.brewery.utility.LegacyUtil; import com.dre.brewery.utility.PermissionUtil; import org.bukkit.GameMode; @@ -29,11 +30,25 @@ public class PlayerListener implements Listener { if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return; Player player = event.getPlayer(); - if (player.isSneaking()) return; - Material type = clickedBlock.getType(); - // Interacting with a Cauldron + // -- Clicking an Hopper -- + if (type == Material.HOPPER) { + if (BConfig.brewHopperDump && event.getPlayer().isSneaking()) { + if (!P.use1_9 || event.getHand() == EquipmentSlot.HAND) { + ItemStack item = event.getItem(); + if (Brew.isBrew(item)) { + event.setCancelled(true); + BUtil.setItemInHand(event, Material.GLASS_BOTTLE, false); + } + } + } + return; + } + + if (player.isSneaking()) return; + + // -- Interacting with a Cauldron -- if (type == Material.CAULDRON) { // Handle the Cauldron Interact // The Event might get cancelled in here @@ -42,6 +57,7 @@ public class PlayerListener implements Listener { } + // -- Opening a Sealing Table -- if (P.use1_14 && BSealer.isBSealer(clickedBlock)) { event.setCancelled(true); if (BConfig.enableSealingTable) { @@ -52,6 +68,8 @@ public class PlayerListener implements Listener { } return; } + + // -- Opening a Minecraft Barrel -- if (P.use1_14 && type == Material.BARREL) { if (!player.hasPermission("brewery.openbarrel.mc")) { event.setCancelled(true); @@ -65,7 +83,7 @@ public class PlayerListener implements Listener { return; } - // Access a Barrel + // -- Access a Barrel -- Barrel barrel = null; if (LegacyUtil.isWoodPlanks(type)) { if (BConfig.openEverywhere) { diff --git a/src/com/dre/brewery/utility/BUtil.java b/src/com/dre/brewery/utility/BUtil.java index 07e5721..1cdc7da 100644 --- a/src/com/dre/brewery/utility/BUtil.java +++ b/src/com/dre/brewery/utility/BUtil.java @@ -13,6 +13,9 @@ import org.bukkit.block.Block; import org.bukkit.command.CommandSender; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.Nullable; @@ -78,6 +81,26 @@ public class BUtil { ); } + /** + * Sets the Item in the Players hand, depending on which hand he used and if the hand should be swapped + * + * @param event Interact Event to tell which hand the player used + * @param mat The Material of the new item + * @param swapped If true, will set the opposite Hand instead of the one he used + */ + @SuppressWarnings("deprecation") + public static void setItemInHand(PlayerInteractEvent event, Material mat, boolean swapped) { + if (P.use1_9) { + if ((event.getHand() == EquipmentSlot.OFF_HAND) != swapped) { + event.getPlayer().getInventory().setItemInOffHand(new ItemStack(mat)); + } else { + event.getPlayer().getInventory().setItemInMainHand(new ItemStack(mat)); + } + } else { + event.getPlayer().setItemInHand(new ItemStack(mat)); + } + } + /** * Returns either uuid or Name of player, depending on bukkit version */