Add Brew dumping into Hoppers when sneaking

This commit is contained in:
Sn0wStorm
2021-04-06 17:14:36 +02:00
parent cb86a9000a
commit f8226ef3a6
16 changed files with 84 additions and 24 deletions
+23
View File
@@ -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
*/