Minecraft Java Bukkit Config Probleme

Hey Leute, ich bin wieder mal am Programmieren eines Bukkit Plugins, jedoch habe ich momentan ein kleines Problem.
und zwar hatte ich die Idee zu einem Prison Plugin. Und zwar gibt es Polizei und Räuber und ich habe den Command /prison eingebaut, welcher noch einige Argumente mitliefert, bei denen eigentlich eine Config eingerichtet werden soll. Mein Problem ist das wenn ich zum Beispiel /prison prison-set ausführe zwar die prison.yml erstellt wird aber die Koordinaten die eigentlich in ihr stehen sollten nicht eingetragen wurden. Meinen Code habe ich hier Unten. Falls die Frage aufkommen sollte, ja ich habe den Command und alles in der main registriert und in der Console gibt es keine Fehler . Ich hoffe mir kann wer helfen




package Main;

import java.io.File;
import java.io.IOException;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;

public class commands implements Listener, CommandExecutor {

   public boolean onCommand(CommandSender sender, Command cmd, String cmdlabel, String[] args) {
      if (cmd.getName().equalsIgnoreCase("Prison")) {
         Player p = (Player) sender;
         if (args.length == 0) {
            if (p.hasPermission("Prison.op")) {
               p.sendMessage("§8§l====Prison Spieler Commands====");
               p.sendMessage("/prison help    (Liste alle Commands auf)");
               p.sendMessage("/prison join    (Betrete ein Spiel)");
               p.sendMessage("/prison leave    (Verlasse ein Spiel)");
               p.sendMessage("§8§l====Prison Setup Commands====");
               p.sendMessage("/prison prison-set    (Setzte das Gefängnis)");
               p.sendMessage("/prison spawn-set    (Setze den Spawn)");
               p.sendMessage("/prison start-set    (Setze die Wartelobby)");
               p.sendMessage("§8§l====Prison Reset Command====");
               p.sendMessage(
                     "/prison reset    (Resete alle Spawns in den Dateien prison.yml, spawn.yml, start.yml)");
            } else {
               p.sendMessage("§8§l====Prison Spieler Commands====");
               p.sendMessage("/prison help    (Liste alle Commands auf)");
               p.sendMessage("/prison join    (Betrete ein Spiel)");
               p.sendMessage("/prison leave    (Verlasse ein Spiel)");
            }
         } else {
            if ((args[0].equalsIgnoreCase("help"))) {
               if (p.hasPermission("Prison.op")) {
                  p.sendMessage("§8§l====Prison Spieler Commands====");
                  p.sendMessage("/prison help    (Liste alle Commands auf)");
                  p.sendMessage("/prison join    (Betrete ein Spiel)");
                  p.sendMessage("/prison leave    (Verlasse ein Spiel)");
                  p.sendMessage("§8§l====Prison Setup Commands====");
                  p.sendMessage("/prison prison-set    (Setzte das Gefängnis)");
                  p.sendMessage("/prison spawn-set    (Setze den Spawn)");
                  p.sendMessage("/prison start-set    (Setze die Wartelobby)");
                  p.sendMessage("§8§l====Prison Reset Command====");
                  p.sendMessage(
                        "/prison reset    (Resete alle Spawns in den Dateien prison.yml, spawn.yml, start.yml)");
               } else {
                  p.sendMessage("§8§l====Prison Spieler Commands====");
                  p.sendMessage("/prison help    (Liste alle Commands auf)");
                  p.sendMessage("/prison join    (Betrete ein Spiel)");
                  p.sendMessage("/prison leave    (Verlasse ein Spiel)");
               }

            } else {
               if ((args[0].equalsIgnoreCase("prison-set"))) {
                  if (p.hasPermission("prison.*")) {
                     File ordner = new File("plugins//Prisons");
                     File file = new File("plugins//Prisons//prisons.yml");
                     if (!ordner.exists()) {
                        ordner.mkdir();
                     }
                     if (!file.exists()) {
                        try {
                           file.createNewFile();
                        } catch (IOException i) {
                           p.sendMessage("§cprisons.yml konnte nicht erstellt werden !");
                        }
                     }
                     YamlConfiguration cfg = YamlConfiguration.loadConfiguration((File) file);
                     Location locMin = p.getLocation();

                     double x = locMin.getX();
                     double y = locMin.getY();
                     double z = locMin.getZ();

                     float yaw = locMin.getYaw();
                     float pitch = locMin.getPitch();

                     String world = locMin.getWorld().getName();

                     cfg.set("X", (int) x);
                     cfg.set("Y", (int) y);
                     cfg.set("Z", (int) z);
                     cfg.set("Yaw", (int) yaw);
                     cfg.set("Pitch", (int) pitch);
                     cfg.set("Welt", (String) world);
                  } else {
                     p.sendMessage("§cKeine Berechtigung!");
                  }

               } else {
                  if ((args[0].equalsIgnoreCase("reset"))) {
                     if (p.hasPermission("prison.*")) {
                        File ordner = new File("plugins//Prisons");
                        File file = new File("plugins//Prisons//prisons.yml");
                        if (!ordner.exists()) {
                           ordner.mkdir();
                        }
                        if (file.exists()) {
                           try {
                              file.delete();
                              file.createNewFile();
                           } catch (IOException i) {
                              p.sendMessage("§cDie Datei Prison.yml wurde nicht zurückgesetzt!");

                           }
                        }
                        File ordner1 = new File("plugins//Prisons");
                        File file1 = new File("plugins//Prisons//spawn.yml");
                        if (!ordner1.exists()) {
                           ordner1.mkdir();
                        }
                        if (file1.exists()) {
                           try {
                              file1.delete();
                              file1.createNewFile();
                           } catch (IOException i) {
                              p.sendMessage("§cDie Datei spawn.yml wurde nicht zurückgesetzt!");
                           }
                        }
                        File ordner2 = new File("plugins//Prisons");
                        File file2 = new File("plugins//Prisons//start.yml");
                        if (!ordner2.exists()) {
                           ordner2.mkdir();
                        }
                        if (file2.exists()) {
                           try {
                              file2.delete();
                              file2.createNewFile();
                           } catch (IOException i) {
                              p.sendMessage("§cDie Datei start.yml wurde nicht zurückgesetzt!");
                           }
                        }
                     } else {
                        p.sendMessage("§cKeine Berechtigung!");
                     }

                  } else {
                     if ((args[0].equalsIgnoreCase("join"))) {
                        File ordner = new File("plugins//Prisons");
                        File file = new File("plugins//Prisons//start.yml");
                        if (!ordner.exists()) {
                           ordner.mkdir();
                        }
                        if (file.exists()) {
                           p.sendMessage("§aEin Adminestrator muss zu erst das Setup ausführen!");
                        }
                        YamlConfiguration cfg = YamlConfiguration.loadConfiguration((File) file);

                        Location loc = p.getLocation();

                        loc.setX((double) cfg.getDouble("X"));
                        loc.setZ((double) cfg.getDouble("Z"));

                        loc.setY((double) cfg.getDouble("Y"));
                        loc.setWorld((World) cfg.get("Welt"));
                        loc.setYaw(cfg.getInt("Yaw"));
                        loc.setPitch(cfg.getInt("Pitch"));

                        p.teleport(loc);

                     } else {

                        if ((args[0].equalsIgnoreCase("leave"))) {
                           File ordner = new File("plugins//Prisons");
                           File file = new File("plugins//Prisons//spawn.yml");
                           if (!ordner.exists()) {
                              ordner.mkdir();
                           }
                           if (!file.exists()) {
                              p.sendMessage("§aEin Adminestrator muss zu erst das Setup ausführen!");
                           }
                           YamlConfiguration cfg = YamlConfiguration.loadConfiguration((File) file);

                           Location loc = p.getLocation();

                           loc.setX((double) cfg.getDouble("X"));
                           loc.setZ((double) cfg.getDouble("Z"));

                           loc.setY((double) cfg.getDouble("Y"));
                           loc.setWorld((World) cfg.get("Welt"));
                           loc.setYaw(cfg.getInt("Yaw"));
                           loc.setPitch(cfg.getInt("Pitch"));

                           p.teleport(loc);

                        } else {

                           if ((args[0].equalsIgnoreCase("spawn-set"))) {
                              if (p.hasPermission("prison.*")) {
                                 File ordner = new File("plugins//Prisons");
                                 File file = new File("plugins//Prisons//spawn.yml");
                                 if (!ordner.exists()) {
                                    ordner.mkdir();
                                 }
                                 if (!file.exists()) {
                                    try {
                                       file.createNewFile();
                                    } catch (IOException i) {
                                       p.sendMessage("§cspawn.yml konnte nicht erstellt werden !");
                                    }
                                 }
                                 YamlConfiguration cfg = YamlConfiguration.loadConfiguration((File) file);
                                 Location locMin = p.getLocation();

                                 double x = locMin.getX();
                                 double y = locMin.getY();
                                 double z = locMin.getZ();

                                 float yaw = locMin.getYaw();
                                 float pitch = locMin.getPitch();

                                 String world = locMin.getWorld().getName();
                                 World welt = Bukkit.getWorld((String) world);

                                 cfg.set("X", (int) x);
                                 cfg.set("Y", (int) y);
                                 cfg.set("Z", (int) z);
                                 cfg.set("Yaw", (int) yaw);
                                 cfg.set("Pitch", (int) pitch);
                                 cfg.set("Welt", (String) world);
                              } else {
                                 p.sendMessage("§cKeine Berechtigung!");
                              }

                           } else {
                              if ((args[0].equalsIgnoreCase("start-set"))) {
                                 if (p.hasPermission("prison.*")) {
                                    File ordner = new File("plugins//Prisons");
                                    File file = new File("plugins//Prisons//start.yml");
                                    if (!ordner.exists()) {
                                       ordner.mkdir();
                                    }
                                    if (!file.exists()) {
                                       try {
                                          file.createNewFile();
                                       } catch (IOException i) {
                                          p.sendMessage("§cstart.yml konnte nicht erstellt werden !");
                                       }
                                    }
                                    YamlConfiguration cfg = YamlConfiguration
                                          .loadConfiguration((File) file);
                                    Location locMin = p.getLocation();

                                    double x = locMin.getX();
                                    double y = locMin.getY();
                                    double z = locMin.getZ();

                                    float yaw = locMin.getYaw();
                                    float pitch = locMin.getPitch();

                                    String world = locMin.getWorld().getName();
                                    World welt = Bukkit.getWorld((String) world);

                                    cfg.set("X", (int) x);
                                    cfg.set("Y", (int) y);
                                    cfg.set("Z", (int) z);
                                    cfg.set("Yaw", (int) yaw);
                                    cfg.set("Pitch", (int) pitch);
                                    cfg.set("Welt", (String) world);
                                 } else {
                                    p.sendMessage("§cKeine Berechtigung!");
                                 }

                              }
                           }
                        }

                     }

                  }
               }
            }
         }
      }

      return false;

   }

}
 






« C# - Forms Textbox - Text einer Variable zuweisenTimer Erstellung nach Nachricht »
 

Schnelle Hilfe: Hier nach ähnlichen Fragen und passenden Tipps suchen!