KaeseKuchen_DEV
Redstoneengineer
Schönen guten Tag
Mein heutiges Problem ist das ein String bei einer Config ausgabe als Null bezecihnet wird obwohl er in der config existiert
Code für die methode die die config schreibt:
Code zum auslesen der Config:
Config:
Vielen Dank im vorraus für die Hilfe
MfG KaeseKuchenDEV
Mein heutiges Problem ist das ein String bei einer Config ausgabe als Null bezecihnet wird obwohl er in der config existiert
Code für die methode die die config schreibt:
Code:
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(sender instanceof Player){
Player p = (Player) sender;
if(cmd.getName().equalsIgnoreCase("setKnockSpawn")){
if(p.hasPermission("kbffa.setSpawn")){
configHandler = Main.configHandler;
if(args.length == 1){
int anz = configHandler.getInt("Maps.anz");
String path = "Maps." + anz + 1;
String displayName = args[0];
configHandler.set(path + ".SLocation.X", p.getLocation().getX());
configHandler.set(path + ".SLocation.Y", p.getLocation().getY());
configHandler.set(path + ".SLocation.Z", p.getLocation().getZ());
configHandler.set(path + ".SLocation.YAW", (int)p.getLocation().getYaw());
configHandler.set(path + ".SLocation.PITCH", (int) p.getLocation().getPitch());
configHandler.set(path + ".SLocation.WORLD", p.getLocation().getWorld().getName());
configHandler.set(path + ".SLocation.DISPLAY", displayName);
configHandler.set("Maps.anz", anz + 1);
Main.getInstance().saveConfig();
}else{
p.sendMessage(Main.getPrefix() + "Bitte benutze /setKnockSpawn [Name]");
}
}else{
p.sendMessage(Main.getPrefix() + "Dazu hast du keine Berechtigung!");
}
}
}else{
sender.sendMessage("[KnockBackFFA] Du musst ein Spieler sein um diesen Befehl auszuführen!");
}
return true;
}
Code zum auslesen der Config:
Code:
public void loadMaps(){
int anz = configHandler.getInt("Maps.anz");
for(int i = 1; i <= anz; i++){
String path = "Maps." + i;
Double x = configHandler.getDouble(path + "SLocation.X");
Double y = configHandler.getDouble(path + "SLocation.Y");
Double z = configHandler.getDouble(path + "SLocation.Z");
Integer yaw = configHandler.getInt(path + "SLocation.YAW");
Integer pitch = configHandler.getInt(path + "SLocation.PITCH");
String displayName = configHandler.getString(path + "SLocation.DISPLAY");
Location loc = new Location(Bukkit.getWorld(path + "SLocation.WORLD"), x, y, z, yaw, pitch);
worlds world = new worlds(path + "SLocation.WORLD", loc, displayName);
this.mapmanager.addWorld(world);
System.out.println("[KnockBackFFA] Die Map" + displayName + "wurde geladen!");
}
}
Config:
Code:
KnockBackFFA:
Prefix: '&7[&6KnockBackFFA&7] &6'
Maps:
anz: 1
'01':
SLocation:
X: 206.24793193541078
Y: 69.0
Z: 310.3395077010187
YAW: 273
PITCH: 5
WORLD: world
DISPLAY: test
Vielen Dank im vorraus für die Hilfe
MfG KaeseKuchenDEV