mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2025-02-16 01:11:19 +01:00
Add Brew dumping into Hoppers when sneaking
This commit is contained in:
parent
cb86a9000a
commit
f8226ef3a6
2
pom.xml
2
pom.xml
@ -147,7 +147,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.16.4-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
@ -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 --
|
||||
|
||||
|
@ -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 --
|
||||
|
||||
|
@ -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 --
|
||||
|
||||
|
@ -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 --
|
||||
|
||||
|
@ -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 --
|
||||
|
||||
|
@ -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 --
|
||||
|
||||
|
@ -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 --
|
||||
|
||||
|
@ -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 --
|
||||
|
||||
|
@ -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 --
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
||||
# -- 口糊设置 --
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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)) {
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user