Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<img align="right" src="https://user-images.githubusercontent.com/13753840/213902224-92f7e6ec-bc7e-4fea-8c45-154a202004dd.jpg" height="200" width="200">
<img align="right" src="https://user-images.githubusercontent.com/13753840/213946932-635d40a3-a278-427c-9e9c-245a89ed12a9.png" height="200" width="200">

# 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ 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"),
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"),
Expand Down
27 changes: 27 additions & 0 deletions zip-plugin/src/main/java/net/imprex/zip/config/StorageConfig.java
Original file line number Diff line number Diff line change
@@ -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");
}
}
}
27 changes: 27 additions & 0 deletions zip-plugin/src/main/java/net/imprex/zip/storage/Storage.java
Original file line number Diff line number Diff line change
@@ -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<ZIPUniqueId> getLockedIds();
}
Original file line number Diff line number Diff line change
@@ -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) {
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package net.imprex.zip.storage;

public class StorageType {

}
Original file line number Diff line number Diff line change
@@ -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<ZIPUniqueId> 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<ZIPUniqueId> getLockedIds() {
return Collections.unmodifiableSet(this.locked);
}
}
39 changes: 39 additions & 0 deletions zip-plugin/src/main/resources/lang/de_DE.yml
Original file line number Diff line number Diff line change
@@ -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"
8 changes: 6 additions & 2 deletions zip-plugin/src/main/resources/lang/en_US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ commandLoreButtonDelete: "&7[&eDelete&7]"
commandLoreButtonDeleteHover: "&eClick here to delete this line"
commandLoreEnd: "&8[]&7========== &eZeroInventoryProblems Lore &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)"
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\""
Expand All @@ -45,9 +45,13 @@ 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"
<<<<<<< feat-storage-system
stackedBackpacksCanNotBeLinked: "Stacked backpacks can not be linked"
=======
pleaseEnterANumber: "Please enter a number"
enterANumberBetweenArgsAndArgs: "Please enter a number between {0} and {1}"
loreLineCreate: "The lore line {0} was added"
loreLineChange: "The lore line {0} was changed"
loreLineDelete: "The lore line {0} was deleted"
maxLoreCountReached: "You have reached the max lore count of {0}"
maxLoreCountReached: "You have reached the max lore count of {0}"
>>>>>>> master