Minecraft Bukkit Plugin Text Datei auslesen

TobSob

Neues Mitglied
Hallo,
Ich möchte gerne für jeden Spieler eine Einstellungsdatei erstellen.
Ich bin schon soweit, dass diese erstellt wird und ich Einträge darin speichern kann.
Aber wie lese ich diese dann aus ??
Java:
	public static File getPlayerFile(UUID arg0) {
		  File file = new File("plugins/EventLocator/Players", arg0.toString() + ".yml");
		  file.setWritable(true);
	      return file;
	   }
	   
	   public static YamlConfiguration getPlayerCfg(UUID arg0) {
	      YamlConfiguration playerscfg = YamlConfiguration.loadConfiguration(getPlayerFile(arg0));
	      return playerscfg;
	   }
	   public static void SetText(UUID arg0, String Name ,String Value) throws IOException {
			YamlConfiguration config = YamlConfiguration.loadConfiguration(getPlayerFile(arg0));
			config.set(Name, Value);
			try {
				config.save(getPlayerFile(arg0));
			} catch (Exception e) {}
		}
	   
	   public static boolean existPlayerFile(UUID arg0) {
	      if(getPlayerFile(arg0).exists()) {
	         return true;
	      } else {
	         return false;
	      }
	   }
 
Ich würde damit eher beim Bukkit-Forum fragen, da man sofern ich weiß für Bukkit-Plugins auch einige durch Bukkit bereitgestellte Bibliotheken nutzen kann. Da wird dir wohl konkreter geholfen werden können als hier, denke ich. https://forums.bukkit.org/

Achja, und statt:
Java:
public static boolean existPlayerFile(UUID arg0) {
	      if(getPlayerFile(arg0).exists()) {
	         return true;
	      } else {
	         return false;
	      }
kannst du das hier benutzen:
Java:
public static boolean existPlayerFile(UUID arg0) {
            return getPlayerFile(arg0).exists()

da wenn deine if-Abfrage true ergibt, du true zurückgibst, und umgekehrt.
 
Zuletzt bearbeitet:

Zurück
Oben