|
|
|
@ -7,41 +7,56 @@ import org.bukkit.inventory.meta.ItemMeta; |
|
|
|
import org.bukkit.persistence.PersistentDataContainer; |
|
|
|
import org.bukkit.persistence.PersistentDataContainer; |
|
|
|
import org.bukkit.persistence.PersistentDataType; |
|
|
|
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 { |
|
|
|
public class PDC { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Zapíše hodnotu do hráče
|
|
|
|
public static void WritePlayerPDC(Player player, String key, PersistentDataType type, Object value){ |
|
|
|
public static void WritePlayerPDC(Player player, String key, PersistentDataType type, Object value){ |
|
|
|
NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); |
|
|
|
NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); |
|
|
|
PersistentDataContainer pdc = player.getPersistentDataContainer(); |
|
|
|
PersistentDataContainer pdc = player.getPersistentDataContainer(); |
|
|
|
pdc.set(nKey, type, value); |
|
|
|
pdc.set(nKey, type, value); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Vezme hodnotu z hráče
|
|
|
|
public static Object GetPlayerPDC(Player player, String key, PersistentDataType type){ |
|
|
|
public static Object GetPlayerPDC(Player player, String key, PersistentDataType type){ |
|
|
|
NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); |
|
|
|
NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); |
|
|
|
PersistentDataContainer pdc = player.getPersistentDataContainer(); |
|
|
|
PersistentDataContainer pdc = player.getPersistentDataContainer(); |
|
|
|
return pdc.get(nKey, type); |
|
|
|
return pdc.get(nKey, type); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Odstraní hodnotu z hráče
|
|
|
|
public static void DeletePlayerPDC(Player player, String key){ |
|
|
|
public static void DeletePlayerPDC(Player player, String key){ |
|
|
|
NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); |
|
|
|
NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); |
|
|
|
PersistentDataContainer pdc = player.getPersistentDataContainer(); |
|
|
|
PersistentDataContainer pdc = player.getPersistentDataContainer(); |
|
|
|
pdc.remove(nKey); |
|
|
|
pdc.remove(nKey); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Zapíše hodnotu do itemu
|
|
|
|
public static void WriteItemMetaPDC(ItemMeta itemMeta, String key, PersistentDataType type, Object value){ |
|
|
|
public static void WriteItemMetaPDC(ItemMeta itemMeta, String key, PersistentDataType type, Object value){ |
|
|
|
NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); |
|
|
|
NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); |
|
|
|
PersistentDataContainer pdc = itemMeta.getPersistentDataContainer(); |
|
|
|
PersistentDataContainer pdc = itemMeta.getPersistentDataContainer(); |
|
|
|
pdc.set(nKey, type, value); |
|
|
|
pdc.set(nKey, type, value); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Odstraní hodnotu z itemu
|
|
|
|
public static Object GetItemMetaPDC(ItemMeta itemMeta, String key, PersistentDataType type){ |
|
|
|
public static Object GetItemMetaPDC(ItemMeta itemMeta, String key, PersistentDataType type){ |
|
|
|
NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); |
|
|
|
NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); |
|
|
|
PersistentDataContainer pdc = itemMeta.getPersistentDataContainer(); |
|
|
|
PersistentDataContainer pdc = itemMeta.getPersistentDataContainer(); |
|
|
|
return pdc.get(nKey, type); |
|
|
|
return pdc.get(nKey, type); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Zapíše hodnotu do statusu bloku
|
|
|
|
public static void WriteTileStatePDC(TileState tileState, String key, PersistentDataType type, Object value){ |
|
|
|
public static void WriteTileStatePDC(TileState tileState, String key, PersistentDataType type, Object value){ |
|
|
|
NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); |
|
|
|
NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); |
|
|
|
PersistentDataContainer pdc = tileState.getPersistentDataContainer(); |
|
|
|
PersistentDataContainer pdc = tileState.getPersistentDataContainer(); |
|
|
|
pdc.set(nKey, type, value); |
|
|
|
pdc.set(nKey, type, value); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Vezme hodnotu ze statusu bloku
|
|
|
|
public static Object GetTileStatePDC(TileState tileState, String key, PersistentDataType type){ |
|
|
|
public static Object GetTileStatePDC(TileState tileState, String key, PersistentDataType type){ |
|
|
|
NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); |
|
|
|
NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); |
|
|
|
PersistentDataContainer pdc = tileState.getPersistentDataContainer(); |
|
|
|
PersistentDataContainer pdc = tileState.getPersistentDataContainer(); |
|
|
|
|