Add option to prevent backpack from being moved

This commit is contained in:
GeorgH93 2020-05-07 23:34:18 +02:00
parent 7cb27ffb15
commit 2eee3b5fb4
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
4 changed files with 13 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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)
{

View File

@ -7,7 +7,7 @@
<packaging>pom</packaging>
<properties>
<revision>2.3.7</revision>
<revision>2.3.8-RC1</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>