mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-01-07 19:28:11 +01:00
Add option to prevent backpack from being moved
This commit is contained in:
parent
7cb27ffb15
commit
2eee3b5fb4
@ -180,6 +180,8 @@ ItemShortcut:
|
||||
OpenContainerOnRightClick: false
|
||||
# The id of the slot that should be preferred when giving a player the shortcut item
|
||||
PreferredSlotId: -1
|
||||
# If this option is enabled the player will not be able to move the backpack item within their inventory
|
||||
BlockItemFromMoving: false
|
||||
|
||||
Sound:
|
||||
# Enables all sound effects
|
||||
@ -208,4 +210,4 @@ Misc:
|
||||
UseBungeeCord: false
|
||||
|
||||
# Config file version. Don't touch it!
|
||||
Version: 29
|
||||
Version: 30
|
@ -38,7 +38,7 @@
|
||||
|
||||
public class Config extends Configuration implements DatabaseConnectionConfiguration
|
||||
{
|
||||
private static final int CONFIG_VERSION = 29, UPGRADE_THRESHOLD = CONFIG_VERSION, PRE_V2_VERSION = 20;
|
||||
private static final int CONFIG_VERSION = 30, UPGRADE_THRESHOLD = CONFIG_VERSION, PRE_V2_VERSION = 20;
|
||||
|
||||
public Config(JavaPlugin plugin)
|
||||
{
|
||||
@ -420,6 +420,11 @@ public int getItemShortcutPreferredSlotId()
|
||||
{
|
||||
return getConfigE().getInt("ItemShortcut.PreferredSlotId", -1);
|
||||
}
|
||||
|
||||
public boolean getItemShortcutBlockItemFromMoving()
|
||||
{
|
||||
return getConfigE().getBoolean("ItemShortcut.BlockItemFromMoving", false);
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region Sound settings
|
||||
|
@ -52,7 +52,7 @@ public class ItemShortcut implements Listener
|
||||
private final Minepacks plugin;
|
||||
private final String itemName, value, openCommand;
|
||||
private final Message messageDoNotRemoveItem;
|
||||
private final boolean improveDeathChestCompatibility, blockAsHat, allowRightClickOnContainers;
|
||||
private final boolean improveDeathChestCompatibility, blockAsHat, allowRightClickOnContainers, blockItemFromMoving;
|
||||
private final int preferredSlotId;
|
||||
private final Set<Material> containerMaterials = new HashSet<>();
|
||||
|
||||
@ -65,6 +65,7 @@ public ItemShortcut(Minepacks plugin)
|
||||
blockAsHat = plugin.getConfiguration().isItemShortcutBlockAsHatEnabled();
|
||||
allowRightClickOnContainers = plugin.getConfiguration().isItemShortcutRightClickOnContainerAllowed();
|
||||
preferredSlotId = plugin.getConfiguration().getItemShortcutPreferredSlotId();
|
||||
blockItemFromMoving = plugin.getConfiguration().getItemShortcutBlockItemFromMoving();
|
||||
openCommand = plugin.getLanguage().getCommandAliases("Backpack", "backpack")[0] + ' ' + plugin.getLanguage().getCommandAliases("Open", "open")[0];
|
||||
messageDoNotRemoveItem = plugin.getLanguage().getMessage("Ingame.DontRemoveShortcut");
|
||||
|
||||
@ -247,6 +248,7 @@ else if(event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY)
|
||||
event.setCancelled(true);
|
||||
messageDoNotRemoveItem.send(player);
|
||||
}
|
||||
if(blockItemFromMoving) event.setCancelled(true);
|
||||
}
|
||||
else if((event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD || event.getAction() == InventoryAction.HOTBAR_SWAP) && event.getHotbarButton() != -1)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user