mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2024-11-14 10:45:23 +01:00
Add option to prevent the backpack from being used as a hat
This commit is contained in:
parent
7fdc2acc45
commit
53d8183368
@ -174,6 +174,8 @@ ItemShortcut:
|
||||
HeadTextureValue: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGRjYzZlYjQwZjNiYWRhNDFlNDMzOTg4OGQ2ZDIwNzQzNzU5OGJkYmQxNzVjMmU3MzExOTFkNWE5YTQyZDNjOCJ9fX0="
|
||||
# Increases compatibility with some death chest plugins. Enable this if the backpack item is added to your death chest!
|
||||
ImproveDeathChestCompatibility: false
|
||||
# Prevents the backpack from being used as a hat
|
||||
BlockAsHat: false
|
||||
|
||||
Sound:
|
||||
# Enables all sound effects
|
||||
@ -200,4 +202,4 @@ Misc:
|
||||
UseBungeeCord: false
|
||||
|
||||
# Config file version. Don't touch it!
|
||||
Version: 26
|
||||
Version: 27
|
@ -38,7 +38,7 @@
|
||||
|
||||
public class Config extends Configuration implements DatabaseConnectionConfiguration
|
||||
{
|
||||
private static final int CONFIG_VERSION = 26, UPGRADE_THRESHOLD = CONFIG_VERSION, PRE_V2_VERSION = 20;
|
||||
private static final int CONFIG_VERSION = 27, UPGRADE_THRESHOLD = CONFIG_VERSION, PRE_V2_VERSION = 20;
|
||||
|
||||
public Config(JavaPlugin plugin)
|
||||
{
|
||||
@ -389,6 +389,11 @@ public boolean isItemShortcutImproveDeathChestCompatibilityEnabled()
|
||||
{
|
||||
return getConfigE().getBoolean("ItemShortcut.ImproveDeathChestCompatibility", false);
|
||||
}
|
||||
|
||||
public boolean isItemShortcutBlockAsHatEnabled()
|
||||
{
|
||||
return getConfigE().getBoolean("ItemShortcut.BlockAsHat", false);
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region Sound settings
|
||||
|
@ -34,10 +34,7 @@
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.inventory.*;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -52,7 +49,7 @@ public class ItemShortcut implements Listener
|
||||
private final Minepacks plugin;
|
||||
private final String itemName, value;
|
||||
private final Message messageDoNotRemoveItem;
|
||||
private boolean improveDeathChestCompatibility;
|
||||
private final boolean improveDeathChestCompatibility, blockAsHat;
|
||||
|
||||
public ItemShortcut(Minepacks plugin)
|
||||
{
|
||||
@ -60,6 +57,7 @@ public ItemShortcut(Minepacks plugin)
|
||||
itemName = ChatColor.translateAlternateColorCodes('&', plugin.getConfiguration().getItemShortcutItemName());
|
||||
value = plugin.getConfiguration().getItemShortcutHeadValue();
|
||||
improveDeathChestCompatibility = plugin.getConfiguration().isItemShortcutImproveDeathChestCompatibilityEnabled();
|
||||
blockAsHat = plugin.getConfiguration().isItemShortcutBlockAsHatEnabled();
|
||||
messageDoNotRemoveItem = plugin.getLanguage().getMessage("Ingame.DontRemoveShortcut");
|
||||
}
|
||||
|
||||
@ -210,10 +208,17 @@ else if((event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD || event.get
|
||||
messageDoNotRemoveItem.send(player);
|
||||
}
|
||||
}
|
||||
else if(isItemShortcut(event.getCursor()) && !player.getInventory().equals(event.getClickedInventory()))
|
||||
else if(isItemShortcut(event.getCursor()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
messageDoNotRemoveItem.send(player);
|
||||
if(!player.getInventory().equals(event.getClickedInventory()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
messageDoNotRemoveItem.send(player);
|
||||
}
|
||||
else if(event.getSlotType() == InventoryType.SlotType.ARMOR && blockAsHat)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user