From f71cb4c0326294275bc551fbe33b47628664c80d Mon Sep 17 00:00:00 2001 From: jakub Date: Wed, 16 Oct 2024 21:45:15 +0200 Subject: [PATCH] =?UTF-8?q?P=C5=99id=C3=A1n=C3=AD=20funkc=C3=AD=20pro=20PD?= =?UTF-8?q?C=20a=20jejich=20lep=C5=A1=C3=AD=20okomentov=C3=A1n=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mineconomiaCoreV2/core/MsgRetriever.java | 2 ++ .../xyz/soukup/mineconomiaCoreV2/core/PDC.java | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/main/java/xyz/soukup/mineconomiaCoreV2/core/MsgRetriever.java b/src/main/java/xyz/soukup/mineconomiaCoreV2/core/MsgRetriever.java index 11181ea..1f001ab 100644 --- a/src/main/java/xyz/soukup/mineconomiaCoreV2/core/MsgRetriever.java +++ b/src/main/java/xyz/soukup/mineconomiaCoreV2/core/MsgRetriever.java @@ -1,11 +1,13 @@ package xyz.soukup.mineconomiaCoreV2.core; import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.inventory.Inventory; import static xyz.soukup.mineconomiaCoreV2.core.sharedValues.config; import static xyz.soukup.mineconomiaCoreV2.core.sharedValues.plugin; public class MsgRetriever { + public static YamlConfiguration lang = null; public static void loadLang(){ String langPath = "lang/" + config.getString("lang"); diff --git a/src/main/java/xyz/soukup/mineconomiaCoreV2/core/PDC.java b/src/main/java/xyz/soukup/mineconomiaCoreV2/core/PDC.java index bf5f637..2d76800 100644 --- a/src/main/java/xyz/soukup/mineconomiaCoreV2/core/PDC.java +++ b/src/main/java/xyz/soukup/mineconomiaCoreV2/core/PDC.java @@ -7,41 +7,56 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.persistence.PersistentDataContainer; import org.bukkit.persistence.PersistentDataType; +//funkce pro lehčí manipulaci s minecraft PDC (trvalé uchovávání dat v entitách, itemech a blocích) public class PDC { + + //Zapíše hodnotu do hráče public static void WritePlayerPDC(Player player, String key, PersistentDataType type, Object value){ NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); PersistentDataContainer pdc = player.getPersistentDataContainer(); pdc.set(nKey, type, value); } + + //Vezme hodnotu z hráče public static Object GetPlayerPDC(Player player, String key, PersistentDataType type){ NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); PersistentDataContainer pdc = player.getPersistentDataContainer(); return pdc.get(nKey, type); } + + //Odstraní hodnotu z hráče public static void DeletePlayerPDC(Player player, String key){ NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); PersistentDataContainer pdc = player.getPersistentDataContainer(); pdc.remove(nKey); } + + //Zapíše hodnotu do itemu public static void WriteItemMetaPDC(ItemMeta itemMeta, String key, PersistentDataType type, Object value){ NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); PersistentDataContainer pdc = itemMeta.getPersistentDataContainer(); pdc.set(nKey, type, value); } + + //Odstraní hodnotu z itemu public static Object GetItemMetaPDC(ItemMeta itemMeta, String key, PersistentDataType type){ NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); PersistentDataContainer pdc = itemMeta.getPersistentDataContainer(); return pdc.get(nKey, type); } + + //Zapíše hodnotu do statusu bloku public static void WriteTileStatePDC(TileState tileState, String key, PersistentDataType type, Object value){ NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); PersistentDataContainer pdc = tileState.getPersistentDataContainer(); pdc.set(nKey, type, value); } + + //Vezme hodnotu ze statusu bloku public static Object GetTileStatePDC(TileState tileState, String key, PersistentDataType type){ NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); PersistentDataContainer pdc = tileState.getPersistentDataContainer();