From e7c46b8f348d4b74520ef17d2cff45605e122f42 Mon Sep 17 00:00:00 2001 From: NgLoader Date: Mon, 23 Jan 2023 00:05:12 +0100 Subject: [PATCH 1/4] chore: disallow link more than one backpack at the same moment feat: added german translation, thanks to @Dragon0697 --- .../src/main/java/net/imprex/zip/command/LinkCommand.java | 3 +++ zip-plugin/src/main/java/net/imprex/zip/config/MessageKey.java | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/zip-plugin/src/main/java/net/imprex/zip/command/LinkCommand.java b/zip-plugin/src/main/java/net/imprex/zip/command/LinkCommand.java index 49dbe18..da4f1e3 100644 --- a/zip-plugin/src/main/java/net/imprex/zip/command/LinkCommand.java +++ b/zip-plugin/src/main/java/net/imprex/zip/command/LinkCommand.java @@ -71,6 +71,9 @@ public void onCommand(CommandSender sender, String[] args) { } else if (linkingBackpack.equals(backpack)) { this.messageConfig.send(player, MessageKey.ThisBackpackIsAlreadyLinkedThoThat); return; + } else if (item.getAmount() > 1) { + this.messageConfig.send(player, MessageKey.StackedBackpacksCanNotBeLinked); + return; } linkingBackpack.applyOnItem(item); diff --git a/zip-plugin/src/main/java/net/imprex/zip/config/MessageKey.java b/zip-plugin/src/main/java/net/imprex/zip/config/MessageKey.java index 3275b2f..67fffa2 100644 --- a/zip-plugin/src/main/java/net/imprex/zip/config/MessageKey.java +++ b/zip-plugin/src/main/java/net/imprex/zip/config/MessageKey.java @@ -39,7 +39,8 @@ public enum MessageKey { YouNeedToLinkABackpackFirst("youNeedToLinkABackpackFirst", "You need to link a backpack at first"), YourBackpackLinkRequestWasCancelled("yourBackpackLinkRequestWasCancelled", "Your backpack link request was cancelled"), BothBackpacksNeedToBeTheSameType("bothBackpacksNeedToBeTheSameType", "Both Backpacks need to be the same type"), - ThisBackpackIsAlreadyLinkedThoThat("thisBackpackIsAlreadyLinkedThoThat", "This backpack is already linked to that backpack"); + ThisBackpackIsAlreadyLinkedThoThat("thisBackpackIsAlreadyLinkedThoThat", "This backpack is already linked to that backpack"), + StackedBackpacksCanNotBeLinked("stackedBackpacksCanNotBeLinked", "Stacked backpacks can not be linked"); public static MessageKey findByKey(String key) { for (MessageKey messageKey : values()) { From 13f753fe315ba39fa5b44560acf3babaf622a29e Mon Sep 17 00:00:00 2001 From: NgLoader Date: Mon, 23 Jan 2023 23:48:00 +0100 Subject: [PATCH 2/4] wip: storage system layout --- .../net/imprex/zip/config/StorageConfig.java | 27 +++++++ .../java/net/imprex/zip/storage/Storage.java | 27 +++++++ .../net/imprex/zip/storage/StorageData.java | 8 ++ .../imprex/zip/storage/StorageManager.java | 19 +++++ .../net/imprex/zip/storage/StorageType.java | 5 ++ .../imprex/zip/storage/type/LocalStorage.java | 80 +++++++++++++++++++ 6 files changed, 166 insertions(+) create mode 100644 zip-plugin/src/main/java/net/imprex/zip/config/StorageConfig.java create mode 100644 zip-plugin/src/main/java/net/imprex/zip/storage/Storage.java create mode 100644 zip-plugin/src/main/java/net/imprex/zip/storage/StorageData.java create mode 100644 zip-plugin/src/main/java/net/imprex/zip/storage/StorageManager.java create mode 100644 zip-plugin/src/main/java/net/imprex/zip/storage/StorageType.java create mode 100644 zip-plugin/src/main/java/net/imprex/zip/storage/type/LocalStorage.java diff --git a/zip-plugin/src/main/java/net/imprex/zip/config/StorageConfig.java b/zip-plugin/src/main/java/net/imprex/zip/config/StorageConfig.java new file mode 100644 index 0000000..69cb771 --- /dev/null +++ b/zip-plugin/src/main/java/net/imprex/zip/config/StorageConfig.java @@ -0,0 +1,27 @@ +package net.imprex.zip.config; + +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.YamlConfiguration; + +public class StorageConfig { + + public LocalConfig local; + + public StorageConfig(ConfigurationSection config) { + + config.addDefault("local", new YamlConfiguration()); + ConfigurationSection localSection = config.getConfigurationSection("local"); + this.local = new LocalConfig(localSection); + } + + public class LocalConfig { + + public String dataFolder; + + public LocalConfig(ConfigurationSection config) { + config.addDefault("dataFolder", "plugins/ZeroInventoryProblems/storage"); + + this.dataFolder = config.getString("dataFolder"); + } + } +} \ No newline at end of file diff --git a/zip-plugin/src/main/java/net/imprex/zip/storage/Storage.java b/zip-plugin/src/main/java/net/imprex/zip/storage/Storage.java new file mode 100644 index 0000000..0564087 --- /dev/null +++ b/zip-plugin/src/main/java/net/imprex/zip/storage/Storage.java @@ -0,0 +1,27 @@ +package net.imprex.zip.storage; + +import java.util.Set; + +import net.imprex.zip.api.ZIPUniqueId; +import net.imprex.zip.config.StorageConfig; + +public interface Storage { + + void connect(StorageConfig config); + + void disconnect(); + + boolean isConnected(); + + StorageData load(ZIPUniqueId id); + + boolean save(StorageData data); + + boolean lock(ZIPUniqueId id); + + boolean unlock(ZIPUniqueId id); + + boolean isLocked(ZIPUniqueId id); + + Set getLockedIds(); +} \ No newline at end of file diff --git a/zip-plugin/src/main/java/net/imprex/zip/storage/StorageData.java b/zip-plugin/src/main/java/net/imprex/zip/storage/StorageData.java new file mode 100644 index 0000000..88eee11 --- /dev/null +++ b/zip-plugin/src/main/java/net/imprex/zip/storage/StorageData.java @@ -0,0 +1,8 @@ +package net.imprex.zip.storage; + +import org.bukkit.inventory.ItemStack; + +import net.imprex.zip.api.ZIPUniqueId; + +public record StorageData(ZIPUniqueId id, String type, ItemStack[] content) { +} diff --git a/zip-plugin/src/main/java/net/imprex/zip/storage/StorageManager.java b/zip-plugin/src/main/java/net/imprex/zip/storage/StorageManager.java new file mode 100644 index 0000000..fa14db5 --- /dev/null +++ b/zip-plugin/src/main/java/net/imprex/zip/storage/StorageManager.java @@ -0,0 +1,19 @@ +package net.imprex.zip.storage; + +import net.imprex.zip.BackpackPlugin; + +public class StorageManager { + + private Storage storage; + + public StorageManager(BackpackPlugin plugin) { + } + + public void setStorage(Storage storage) { + + } + + public Storage getStorage() { + return this.storage; + } +} diff --git a/zip-plugin/src/main/java/net/imprex/zip/storage/StorageType.java b/zip-plugin/src/main/java/net/imprex/zip/storage/StorageType.java new file mode 100644 index 0000000..1805da2 --- /dev/null +++ b/zip-plugin/src/main/java/net/imprex/zip/storage/StorageType.java @@ -0,0 +1,5 @@ +package net.imprex.zip.storage; + +public class StorageType { + +} diff --git a/zip-plugin/src/main/java/net/imprex/zip/storage/type/LocalStorage.java b/zip-plugin/src/main/java/net/imprex/zip/storage/type/LocalStorage.java new file mode 100644 index 0000000..50ebc83 --- /dev/null +++ b/zip-plugin/src/main/java/net/imprex/zip/storage/type/LocalStorage.java @@ -0,0 +1,80 @@ +package net.imprex.zip.storage.type; + +import java.nio.file.Path; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; + +import net.imprex.zip.api.ZIPUniqueId; +import net.imprex.zip.config.StorageConfig; +import net.imprex.zip.storage.Storage; +import net.imprex.zip.storage.StorageData; + +public class LocalStorage implements Storage { + + private Path dataFolder; + + private AtomicBoolean connected = new AtomicBoolean(false); + + private Set locked = new LinkedHashSet<>(); + + @Override + public void connect(StorageConfig config) { + if (this.connected.compareAndSet(false, true)) { + + } else { + throw new IllegalStateException("Local storage is already connected"); + } + } + + @Override + public void disconnect() { + if (this.connected.compareAndSet(true, false)) { + + } else { + throw new IllegalStateException("Local storage is already disconnected"); + } + } + + @Override + public boolean isConnected() { + return this.connected.get(); + } + + @Override + public StorageData load(ZIPUniqueId id) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean save(StorageData data) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean lock(ZIPUniqueId id) { + synchronized (this.locked) { + return this.locked.add(id); + } + } + + @Override + public boolean unlock(ZIPUniqueId id) { + synchronized (this.locked) { + return this.locked.remove(id); + } + } + + @Override + public boolean isLocked(ZIPUniqueId id) { + return this.locked.contains(id); + } + + @Override + public Set getLockedIds() { + return Collections.unmodifiableSet(this.locked); + } +} \ No newline at end of file From 5955a92f058873d2193673d96d519b5e10ab2d5d Mon Sep 17 00:00:00 2001 From: NgLoader Date: Mon, 23 Jan 2023 23:54:06 +0100 Subject: [PATCH 3/4] feat: added german translation chore: changed logo --- README.md | 2 +- zip-plugin/src/main/resources/lang/de_DE.yml | 39 ++++++++++++++++++++ zip-plugin/src/main/resources/lang/en_US.yml | 7 ++-- 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 zip-plugin/src/main/resources/lang/de_DE.yml diff --git a/README.md b/README.md index 398ffb1..8a3c025 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ - + # Zero Inventory Problems - ZIP [![Release Status](https://github.com/Imprex-Development/zero-inventory-problems/workflows/Releases/badge.svg)](https://github.com/Imprex-Development/zero-inventory-problems/releases/latest) [![Build Status](https://github.com/Imprex-Development/zero-inventory-problems/workflows/Build/badge.svg)](https://github.com/Imprex-Development/zero-inventory-problems/actions?query=workflow%3ABuild) diff --git a/zip-plugin/src/main/resources/lang/de_DE.yml b/zip-plugin/src/main/resources/lang/de_DE.yml new file mode 100644 index 0000000..1f4167d --- /dev/null +++ b/zip-plugin/src/main/resources/lang/de_DE.yml @@ -0,0 +1,39 @@ +prefix: "&8[&eZIP&8] &7" +notAConsoleCommand: "Dieser Command kann nur von einen Spieler genutzt werden" +youDontHaveTheFollowingPermission: "Du brauche folgende Rechte um diesen Command zu nutzen &8\"&e{0}&8\"" +ThisBackpackNoLongerExist: "Dieses Backpack existiert nicht mehr" +clickHereToSeeTheLatestRelease: "Klicke hier um die neuste Version zu sehen" +ANewReleaseIsAvailable: "Eine neue Version ist verfügbar" +clickHere: "&f&l[Hier Klicken]" +commandHelpStart: "&8[]&7========== &eZeroInventoryProblems &7==========&8[]" +commandHelpPickup: "&8/&7zip &epickup &8| &7Greife auf nicht mehr verfügbare Items zu&8." +commandHelpLink: "&8/&7zip &elink &7<&ecancel&7> &8| &7Linke ein zwei Backpacks aufs selbe Inventar&8." +commandHelpGive: "&8/&7zip &egive &7[&eType&7] &7<&eSpieler&7> &8| &7Gib dir oder anderen ein Backpack&8." +commandHelpType: "&8/&7zip &etype &8| &7Eine Liste mit allen Backpack Typen&8." +commandHelpEnd: "&8[]&7========== &eZeroInventoryProblems &7==========&8[]" +commandTypeStart: "&8[]&7========== &eZeroInventoryProblems Types &7==========&8[]" +commandTypeContent: "&8-&e{0}" +commandTypeButtonGive: "&7[&eHerstellen&7]" +commandTypeButtonGiveHover: "&eKlicke hier um dir ein &8\"&e{0}&8\" §eBackpack zu geben" +commandTypeEnd: "&8[]&7========== &eZeroInventoryProblems Types &7==========&8[]" +noOnlinePlayerWasFound: "Es wurde kein Spieler namens &8\"&e{0}&8" &7gefunden" +pleaseEnterABackpackType: "Bitte gebe ein Backpack typen ein" +backpackTypeWasNotFound: "Backpack type &8\"&e{0}&8\" &7wurde nicht gefunden" +youHaveGivenYourselfABackpack: "Du hast dir selbst ein &8\"&e{0}&8\" &7Backpack gegeben" +youHaveGivenTargetPlayerABackpack: "Du hast &8\"&e{1}&8\" &7ein &8\"&e{0}&8\" Backpack gegeben" +youNeedToHoldABackpackInYourHand: "Du musst ein Backpack in deiner Hand halten" +yourBackpackHasNoUnusableItems: "Dein Backpack hat keine nicht Verfügbaren Items" +youNeedMoreSpaceInYourInventory: "Du brauchst mehr Platz in deinen Inventar" +targetPlayerNeedMoreSpaceInYourInventory: "&8\"&e{0}&8\" &7hat kein platz in seinen Inventar mehr" +youReceivedAllUnusableItems: "Du hast alle nicht verfügbaren Items erhalten" +youHaveUnusableItemsUsePickup: "Dein Backpack enthält nicht mehr verfügbare Items&8! &7Nutze &e/zip pickup" +yourBackpackIsNotEmpty: "Dein Backpack ist nicht leer" +youNeedToHoldBothBackpacksInYourInventory: "Du musst beide Backpack in deinen Inventar haben" +youCanNowHoldTheBackpackWhichShouldBeLinked: "Halte nun das Backpack welches zu diesen Inventar verlinkt werden soll in deiner Hand und gebe diesen Command erneut ein" +thisShouldNotHappenedPleaseTryToLinkAgain: "Es ist ein Fehler aufgetreten, bitte versuche es erneut" +yourBackpackIsNowLinked: "Dein Backpacks teilen nun das selbe Inventar" +youNeedToLinkABackpackFirst: "Du musst zuerst ein Backpack verlinken" +yourBackpackLinkRequestWasCancelled: "Deine Backpack link anfrage wurde abgebrochen" +bothBackpacksNeedToBeTheSameType: "Beide Backpacks müssen vom gleichen typen sein" +thisBackpackIsAlreadyLinkedThoThat: "Dieses Backpacks habe bereits das gleiche Inventar verlinkt" +stackedBackpacksCanNotBeLinked: "Mehrere Backpacks können nicht auf einmal verlinkt werden" \ No newline at end of file diff --git a/zip-plugin/src/main/resources/lang/en_US.yml b/zip-plugin/src/main/resources/lang/en_US.yml index 13c8d8d..6f7d8e2 100644 --- a/zip-plugin/src/main/resources/lang/en_US.yml +++ b/zip-plugin/src/main/resources/lang/en_US.yml @@ -16,8 +16,8 @@ commandTypeContent: " &8-&e{0}" commandTypeButtonGive: "&7[&eGive&7]" commandTypeButtonGiveHover: "&eClick here to give yourself a &8\"&e{0}&8\" §ebackpack" commandTypeEnd: "&8[]&7========== &eZeroInventoryProblems Types &7==========&8[]" -noOnlinePlayerWasFound: "No online player with the name &8\"&e{0}&8} &7was found" -pleaseEnterABackpackType: "Please enter a backpack type &8(small/medium/big)" +noOnlinePlayerWasFound: "No online player with the name &8\"&e{0}&8\" &7was found" +pleaseEnterABackpackType: "Please enter a backpack type" backpackTypeWasNotFound: "Backpack type &8\"&e{0}&8\" &7was not found" youHaveGivenYourselfABackpack: "You received a &8\"&e{0}&8\" &7backpack" youHaveGivenTargetPlayerABackpack: "You given a &8\"&e{0}&8\" &7backpack to &8\"&e{1}&8\"" @@ -35,4 +35,5 @@ yourBackpackIsNowLinked: "Your backpack is now linked" youNeedToLinkABackpackFirst: "You need to link a backpack at first" yourBackpackLinkRequestWasCancelled: "Your backpack link request was cancelled" bothBackpacksNeedToBeTheSameType: "Both Backpacks need to be the same type" -thisBackpackIsAlreadyLinkedThoThat: "This backpack is already linked to that backpack" \ No newline at end of file +thisBackpackIsAlreadyLinkedThoThat: "This backpack is already linked to that backpack" +stackedBackpacksCanNotBeLinked: "Stacked backpacks can not be linked" \ No newline at end of file From 73101994dc8bd12d60731a5c7e07d174ce22577a Mon Sep 17 00:00:00 2001 From: NgLoader Date: Mon, 30 Jan 2023 23:04:14 +0100 Subject: [PATCH 4/4] fix: build issue --- .../src/main/java/net/imprex/zip/config/MessageKey.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/zip-plugin/src/main/java/net/imprex/zip/config/MessageKey.java b/zip-plugin/src/main/java/net/imprex/zip/config/MessageKey.java index b3c5598..86451b3 100644 --- a/zip-plugin/src/main/java/net/imprex/zip/config/MessageKey.java +++ b/zip-plugin/src/main/java/net/imprex/zip/config/MessageKey.java @@ -54,16 +54,13 @@ public enum MessageKey { YourBackpackLinkRequestWasCancelled("yourBackpackLinkRequestWasCancelled", "Your backpack link request was cancelled"), BothBackpacksNeedToBeTheSameType("bothBackpacksNeedToBeTheSameType", "Both Backpacks need to be the same type"), ThisBackpackIsAlreadyLinkedThoThat("thisBackpackIsAlreadyLinkedThoThat", "This backpack is already linked to that backpack"), -<<<<<<< feat-storage-system - StackedBackpacksCanNotBeLinked("stackedBackpacksCanNotBeLinked", "Stacked backpacks can not be linked"); -======= + StackedBackpacksCanNotBeLinked("stackedBackpacksCanNotBeLinked", "Stacked backpacks can not be linked"), PleaseEnterANumber("pleaseEnterANumber", "Please enter a number"), EnterANumberBetweenArgsAndArgs("enterANumberBetweenArgsAndArgs", "Please enter a number between {0} and {1}"), LoreLineCreate("loreLineCreate", "The lore line {0} was added"), LoreLineChange("loreLineChange", "The lore line {0} was changed"), LoreLineDelete("loreLineDelete", "The lore line {0} was deleted"), MaxLoreCountReached("maxLoreCountReached", "You have reached the max lore count of {0}"); ->>>>>>> master public static MessageKey findByKey(String key) { for (MessageKey messageKey : values()) {