From 60f10ae765a597eb2a3b2a5a207babd1425431dc Mon Sep 17 00:00:00 2001 From: MoBrot <90271578+MoBrot@users.noreply.github.com> Date: Sat, 3 Sep 2022 16:35:06 +0200 Subject: [PATCH 1/4] +Add InventoryFillerCommand +Add INVENTORY_FILL_HELP in BauSystem.properties +Add INVENTORY_FILL_INFO in BauSystem.properties --- BauSystem_Main/src/BauSystem.properties | 6 ++++ BauSystem_Main/src/BauSystem_de.properties | 6 ++++ .../InventoryFiller.java | 7 ++++- .../InventoryFillerCommand.java | 30 +++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) rename BauSystem_Main/src/de/steamwar/bausystem/features/{util => inventoryfiller}/InventoryFiller.java (93%) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillerCommand.java diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 9a709a1f..c878ab57 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -632,6 +632,12 @@ SMART_PLACE_INFO = §7Places rotatable blocks §eaway§7 from you when §esneaki SMART_PLACE_ENABLE = §aSmartPlace activated SMART_PLACE_DISABLE = §cSmartPlace deactivated +# InventoryFiller +INVENTORY_FILL_HELP = §8/§einventoryfill §8- §7Toggles InventoryFill +INVENTORY_FILL_INFO = §7Helps you fill containers by looking at them while sneaking and dropping the item. Or just scroll on a container to change the amount of the item inside. +INVENTORY_FILL_ENABLE = §aInventoryFiller activated +INVENTORY_FILL_DISABLE = §cInventoryFiller deactivated + # BlockCounter BLOCK_COUNTER_HELP_TOGGLE = §8/§eblockcounter §8- §7Toggle on/off BLOCK_COUNTER_HELP_ENABLE = §8/§eblockcounter enable §8- §7Toggles BlockCounter on diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index 37dda73a..778aef4e 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -613,6 +613,12 @@ SMART_PLACE_INFO = §7Plaziert rotierbare Blöcke beim §esneaken§7 von dir §e SMART_PLACE_ENABLE = §aSmartPlace aktiviert SMART_PLACE_DISABLE = §cSmartPlace deaktiviert +# InventoryFiller +INVENTORY_FILL_HELP = §8/§einventoryfill §8- §7Toggled InventoryFill +INVENTORY_FILL_INFO = §7Hilft dir, Behälter zu füllen, indem du sie beim sneaken ansiehst und den Gegenstand fallen lässt. Oder scrolle einfach auf einen Behälter, um die Menge des gehaltenen Gegenstandes darin zu ändern. +INVENTORY_FILL_ENABLE = §aInventoryFiller activated +INVENTORY_FILL_DISABLE = §cInventoryFiller deactivated + # BlockCounter BLOCK_COUNTER_HELP_TOGGLE = §8/§eblockcounter §8- §7Wechsel zwischen an und aus BLOCK_COUNTER_HELP_ENABLE = §8/§eblockcounter enable §8- §7Schalte den BlockCounter an diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/InventoryFiller.java b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFiller.java similarity index 93% rename from BauSystem_Main/src/de/steamwar/bausystem/features/util/InventoryFiller.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFiller.java index 37c957bc..068aaf2d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/InventoryFiller.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFiller.java @@ -17,9 +17,10 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.util; +package de.steamwar.bausystem.features.inventoryfiller; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.configplayer.Config; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import net.md_5.bungee.api.ChatMessageType; @@ -38,6 +39,8 @@ public class InventoryFiller implements Listener { @EventHandler public void onPlayerDropItem(PlayerDropItemEvent event) { + + if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("inventoryfill", false)) return; if (!event.getPlayer().isSneaking()) return; Block block = event.getPlayer().getTargetBlockExact(5); if (block == null) return; @@ -58,6 +61,8 @@ public class InventoryFiller implements Listener { */ @EventHandler public void onPlayerItemHeld(PlayerItemHeldEvent event) { + + if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("inventoryfill", false)) return; if (!event.getPlayer().isSneaking()) return; ItemStack itemStack = event.getPlayer().getInventory().getItemInMainHand(); if (itemStack.getType() == Material.AIR) return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillerCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillerCommand.java new file mode 100644 index 00000000..1c13d8b5 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillerCommand.java @@ -0,0 +1,30 @@ +package de.steamwar.bausystem.features.inventoryfiller; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.SWUtils; +import de.steamwar.bausystem.configplayer.Config; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.command.SWCommand; +import org.bukkit.entity.Player; + +@Linked(LinkageType.COMMAND) +public class InventoryFillerCommand extends SWCommand { + + public InventoryFillerCommand() { + super("inventoryfill"); + } + + @Register(description = {"INVENTORY_FILL_HELP", "INVENTORY_FILL_INFO"}) + public void toggle(Player player) { + + boolean inventoryFill = Config.getInstance().get(player).getPlainValueOrDefault("inventoryfill", false); + Config.getInstance().get(player).put("inventoryfill", !inventoryFill); + + if(!inventoryFill) { + SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("INVENTORY_FILL_ENABLE", player)); + BauSystem.MESSAGE.send("INVENTORY_FILL_INFO", player); + }else + SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("INVENTORY_FILL_DISABLE", player)); + } +} -- 2.39.2 From f878efab32e599341da70b4f01299ecf05decd88 Mon Sep 17 00:00:00 2001 From: MoBrot <90271578+MoBrot@users.noreply.github.com> Date: Sun, 4 Sep 2022 21:16:57 +0200 Subject: [PATCH 2/4] +Add InventoryFillBauGuiItem +Add OTHER_ITEMS_INVENTORY_FILL_NAME in BauSystem.properties --- BauSystem_Main/src/BauSystem.properties | 1 + .../inventoryfiller/InventoryFiller.java | 2 - .../InventoryFillerCommand.java | 7 ++-- .../util/items/InventoryFillBauGuiItem.java | 40 +++++++++++++++++++ 4 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/util/items/InventoryFillBauGuiItem.java diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index c878ab57..0ccb5281 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -885,6 +885,7 @@ OTHER_ITEMS_GAMEMODE_LORE_2=§eLeft-Click§8:§7 Toggle between survival and adv OTHER_ITEMS_KILLALL_NAME=§eKillAll OTHER_ITEMS_KILLALL_LORE_1=§eWithout Shift§8:§7 only this region OTHER_ITEMS_KILLALL_LORE_2=§eWith Shift§8:§7 global +OTHER_ITEMS_INVENTORY_FILL_NAME=§eInventoryFill OTHER_SLOT_INVALID_SLOT=§cInvalid slot OTHER_NOCLIP_SLOT_INFO=§7With /slot you can change the selected slot and take another block in the slot. OTHER_NOCLIP_SLOT_HELP_PICK = §8/§eslot pick §8-§7 Take the faced block into your inventory. diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFiller.java b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFiller.java index 068aaf2d..dd7c1b01 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFiller.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFiller.java @@ -39,7 +39,6 @@ public class InventoryFiller implements Listener { @EventHandler public void onPlayerDropItem(PlayerDropItemEvent event) { - if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("inventoryfill", false)) return; if (!event.getPlayer().isSneaking()) return; Block block = event.getPlayer().getTargetBlockExact(5); @@ -61,7 +60,6 @@ public class InventoryFiller implements Listener { */ @EventHandler public void onPlayerItemHeld(PlayerItemHeldEvent event) { - if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("inventoryfill", false)) return; if (!event.getPlayer().isSneaking()) return; ItemStack itemStack = event.getPlayer().getInventory().getItemInMainHand(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillerCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillerCommand.java index 1c13d8b5..8ef0d841 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillerCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillerCommand.java @@ -17,14 +17,13 @@ public class InventoryFillerCommand extends SWCommand { @Register(description = {"INVENTORY_FILL_HELP", "INVENTORY_FILL_INFO"}) public void toggle(Player player) { - boolean inventoryFill = Config.getInstance().get(player).getPlainValueOrDefault("inventoryfill", false); Config.getInstance().get(player).put("inventoryfill", !inventoryFill); - - if(!inventoryFill) { + if (!inventoryFill) { SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("INVENTORY_FILL_ENABLE", player)); BauSystem.MESSAGE.send("INVENTORY_FILL_INFO", player); - }else + }else { SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("INVENTORY_FILL_DISABLE", player)); + } } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/InventoryFillBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/InventoryFillBauGuiItem.java new file mode 100644 index 00000000..c09468b1 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/InventoryFillBauGuiItem.java @@ -0,0 +1,40 @@ +package de.steamwar.bausystem.features.util.items; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.features.inventoryfiller.InventoryFillerCommand; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.bausystem.linkage.LinkedInstance; +import de.steamwar.bausystem.linkage.specific.BauGuiItem; +import de.steamwar.inventory.SWItem; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +@Linked(LinkageType.BAU_GUI_ITEM) +public class InventoryFillBauGuiItem extends BauGuiItem { + public InventoryFillBauGuiItem() { + super(34); + } + + @LinkedInstance + public InventoryFillerCommand command; + + @Override + public Permission permission() { + return Permission.MEMBER; + } + + @Override + public ItemStack getItem(Player player) { + return new SWItem(Material.BARREL, BauSystem.MESSAGE.parse("OTHER_ITEMS_INVENTORY_FILL_NAME", player), null, false, clickType -> {}).getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + command.toggle(p); + return false; + } +} -- 2.39.2 From 73f7fb29709c1d0c8768cb73ee477c90f1c9ca27 Mon Sep 17 00:00:00 2001 From: MoBrot <90271578+MoBrot@users.noreply.github.com> Date: Tue, 6 Sep 2022 20:30:29 +0200 Subject: [PATCH 3/4] +Add Lore to InventoryFillBauGuiItem.getItem --- BauSystem_Main/src/BauSystem.properties | 2 ++ BauSystem_Main/src/BauSystem_de.properties | 2 ++ .../features/util/items/InventoryFillBauGuiItem.java | 6 +++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 0ccb5281..24f934f5 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -886,6 +886,8 @@ OTHER_ITEMS_KILLALL_NAME=§eKillAll OTHER_ITEMS_KILLALL_LORE_1=§eWithout Shift§8:§7 only this region OTHER_ITEMS_KILLALL_LORE_2=§eWith Shift§8:§7 global OTHER_ITEMS_INVENTORY_FILL_NAME=§eInventoryFill +OTHER_ITEMS_INVENTORY_FILL_LORE_1=§aActivated +OTHER_ITEMS_INVENTORY_FILL_LORE_2=§aDisabled OTHER_SLOT_INVALID_SLOT=§cInvalid slot OTHER_NOCLIP_SLOT_INFO=§7With /slot you can change the selected slot and take another block in the slot. OTHER_NOCLIP_SLOT_HELP_PICK = §8/§eslot pick §8-§7 Take the faced block into your inventory. diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index 778aef4e..efa63a29 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -866,6 +866,8 @@ OTHER_ITEMS_GAMEMODE_LORE_2=§eLinks-Click§8:§7 Umschalten zwischen Survival u OTHER_ITEMS_KILLALL_NAME=§eKillAll OTHER_ITEMS_KILLALL_LORE_1=§eOhne Shift§8:§7 nur die Region OTHER_ITEMS_KILLALL_LORE_2=§eMit Shift§8:§7 Global +OTHER_ITEMS_INVENTORY_FILL_LORE_1=§aAktiviert +OTHER_ITEMS_INVENTORY_FILL_LORE_2=§aDeaktiviert OTHER_SLOT_INVALID_SLOT=§cInvalider Slot OTHER_NOCLIP_SLOT_INFO=§7Mit /slot kannst du den ausgewählten Slot ändern und einen anderen Block in den Slot nehmen. OTHER_NOCLIP_SLOT_HELP_PICK = §8/§eslot pick §8-§7 Lege den angeguckten Block ins Inventar diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/InventoryFillBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/InventoryFillBauGuiItem.java index c09468b1..79881e63 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/InventoryFillBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/InventoryFillBauGuiItem.java @@ -2,6 +2,7 @@ package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.configplayer.Config; import de.steamwar.bausystem.features.inventoryfiller.InventoryFillerCommand; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; @@ -13,6 +14,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; +import java.util.Collections; + @Linked(LinkageType.BAU_GUI_ITEM) public class InventoryFillBauGuiItem extends BauGuiItem { public InventoryFillBauGuiItem() { @@ -29,7 +32,8 @@ public class InventoryFillBauGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { - return new SWItem(Material.BARREL, BauSystem.MESSAGE.parse("OTHER_ITEMS_INVENTORY_FILL_NAME", player), null, false, clickType -> {}).getItemStack(); + String loreKey = Config.getInstance().get(player).getPlainValueOrDefault("inventoryfill", false) ? "OTHER_ITEMS_INVENTORY_FILL_LORE_1" : "OTHER_ITEMS_INVENTORY_FILL_LORE_2"; + return new SWItem(Material.HOPPER, BauSystem.MESSAGE.parse("OTHER_ITEMS_INVENTORY_FILL_NAME", player), Collections.singletonList(BauSystem.MESSAGE.parse(loreKey, player)), false, clickType -> {}).getItemStack(); } @Override -- 2.39.2 From 4e431c298a47ec9af8a09a3686e960dbf8180546 Mon Sep 17 00:00:00 2001 From: MoBrot <90271578+MoBrot@users.noreply.github.com> Date: Wed, 7 Sep 2022 14:45:08 +0200 Subject: [PATCH 4/4] +move InventoryFillBauGuiItem to inventoryfiller package --- BauSystem_Main/src/BauSystem.properties | 4 ++-- BauSystem_Main/src/BauSystem_de.properties | 4 ++-- .../items => inventoryfiller}/InventoryFillBauGuiItem.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) rename BauSystem_Main/src/de/steamwar/bausystem/features/{util/items => inventoryfiller}/InventoryFillBauGuiItem.java (92%) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 24f934f5..6b4874b7 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -886,8 +886,8 @@ OTHER_ITEMS_KILLALL_NAME=§eKillAll OTHER_ITEMS_KILLALL_LORE_1=§eWithout Shift§8:§7 only this region OTHER_ITEMS_KILLALL_LORE_2=§eWith Shift§8:§7 global OTHER_ITEMS_INVENTORY_FILL_NAME=§eInventoryFill -OTHER_ITEMS_INVENTORY_FILL_LORE_1=§aActivated -OTHER_ITEMS_INVENTORY_FILL_LORE_2=§aDisabled +OTHER_ITEMS_INVENTORY_FILL_LORE_ACTIVE=§aActivated +OTHER_ITEMS_INVENTORY_FILL_LORE_INACTIVE=§aDisabled OTHER_SLOT_INVALID_SLOT=§cInvalid slot OTHER_NOCLIP_SLOT_INFO=§7With /slot you can change the selected slot and take another block in the slot. OTHER_NOCLIP_SLOT_HELP_PICK = §8/§eslot pick §8-§7 Take the faced block into your inventory. diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index efa63a29..75ca8f0d 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -866,8 +866,8 @@ OTHER_ITEMS_GAMEMODE_LORE_2=§eLinks-Click§8:§7 Umschalten zwischen Survival u OTHER_ITEMS_KILLALL_NAME=§eKillAll OTHER_ITEMS_KILLALL_LORE_1=§eOhne Shift§8:§7 nur die Region OTHER_ITEMS_KILLALL_LORE_2=§eMit Shift§8:§7 Global -OTHER_ITEMS_INVENTORY_FILL_LORE_1=§aAktiviert -OTHER_ITEMS_INVENTORY_FILL_LORE_2=§aDeaktiviert +OTHER_ITEMS_INVENTORY_FILL_LORE_ACTIVE=§aAktiviert +OTHER_ITEMS_INVENTORY_FILL_LORE_INACTIVE=§aDeaktiviert OTHER_SLOT_INVALID_SLOT=§cInvalider Slot OTHER_NOCLIP_SLOT_INFO=§7Mit /slot kannst du den ausgewählten Slot ändern und einen anderen Block in den Slot nehmen. OTHER_NOCLIP_SLOT_HELP_PICK = §8/§eslot pick §8-§7 Lege den angeguckten Block ins Inventar diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/InventoryFillBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillBauGuiItem.java similarity index 92% rename from BauSystem_Main/src/de/steamwar/bausystem/features/util/items/InventoryFillBauGuiItem.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillBauGuiItem.java index 79881e63..d5b7f70e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/InventoryFillBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillBauGuiItem.java @@ -1,4 +1,4 @@ -package de.steamwar.bausystem.features.util.items; +package de.steamwar.bausystem.features.inventoryfiller; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; @@ -32,7 +32,7 @@ public class InventoryFillBauGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { - String loreKey = Config.getInstance().get(player).getPlainValueOrDefault("inventoryfill", false) ? "OTHER_ITEMS_INVENTORY_FILL_LORE_1" : "OTHER_ITEMS_INVENTORY_FILL_LORE_2"; + String loreKey = Config.getInstance().get(player).getPlainValueOrDefault("inventoryfill", false) ? "OTHER_ITEMS_INVENTORY_FILL_LORE_ACTIVE" : "OTHER_ITEMS_INVENTORY_FILL_LORE_INACTIVE"; return new SWItem(Material.HOPPER, BauSystem.MESSAGE.parse("OTHER_ITEMS_INVENTORY_FILL_NAME", player), Collections.singletonList(BauSystem.MESSAGE.parse(loreKey, player)), false, clickType -> {}).getItemStack(); } -- 2.39.2