mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 07:49:03 +00:00
Add Brew dumping into Hoppers when sneaking
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user