Přidání funkcí pro PDC a jejich lepší okomentování #7

Merged
jakub merged 1 commits from PDC into master 1 year ago
  1. 2
      src/main/java/xyz/soukup/mineconomiaCoreV2/core/MsgRetriever.java
  2. 15
      src/main/java/xyz/soukup/mineconomiaCoreV2/core/PDC.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");

@ -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();

Loading…
Cancel
Save