Hey everyone, I am currently working on a /setwarp and /warp command. My problem is that my warppoint is not saved the way I like it to be saved int the Config... so if I type in /setwarp args[0] , the warppoint is set, but I can't access to it :/ Idk how the code function in spigot works, so I pasted my code down below. I appreciate every help, thx // ----------- /Setwarp Class ---------- \\ package flopp.main; import org.bukkit.Sound; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; public class setWarp implements CommandExecutor { public int counter; public static Plugin pl; @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { pl = Main.plugin; Player p = (Player) sender; FileConfiguration cfg = pl.getConfig(); if(sender instanceof Player) { if(args.length >= 1) { if (counter <= 0) { if (!pl.getConfig().contains("Warps" + ".name" + args[0])) { cfg.set("Warps" + ".name", args[0].toLowerCase().toString()); cfg.set("Warps" + ".world", p.getLocation().getWorld().getName()); cfg.set("Warps" + ".x", p.getLocation().getX()); cfg.set("Warps" + ".y", p.getLocation().getY()); cfg.set("Warps" + ".z", p.getLocation().getZ()); cfg.set("Warps" + ".yaw", p.getLocation().getYaw()); cfg.set("Warps" + ".pitch", p.getLocation().getPitch()); cfg.set("Warps" + ".list", args[0] + ", "); counter++; pl.saveConfig(); p.sendMessage(Main.s + "§6" + args[0] + " §7wurde erfolgeich als §6Warp §7gesetzt!"); p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 10, 1); } } else { p.sendMessage(Main.s + "Du hast bereits einen §6Warp §7gesetzt!"); } } else { p.sendMessage(Main.s + "Bitte benutze §c/setwarp <warp> §7!"); } } return false; } } -------------------------------------------------------- //-------------- /Warp Class -------------- \\ -------------------------------------------------------- package flopp.main; 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.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; public class warp implements CommandExecutor { public static Plugin pl; @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { pl = Main.plugin; Player p = (Player) sender; FileConfiguration cfg = pl.getConfig(); if(sender instanceof Player) { if(args.length >= 1) { if(cfg.contains("Warps" + ".name" + args[0])) { String name = cfg.getString("Warps" + ".name"); World w = Bukkit.getServer().getWorld(pl.getConfig().getString("warpname" + args[0] + ".world")); double x = cfg.getDouble("Warps" + ".x"); double y = cfg.getDouble("Warps" + ".y"); double z = cfg.getDouble("Warps" + ".z"); double yaw = cfg.getDouble("Warps" + ".yaw"); double pitch = cfg.getDouble("Warps" + ".pitch"); Location loc = new Location(w, x, y, z, (float) yaw, (float) pitch); p.teleport(loc); } else { p.sendMessage(Main.s + "§6Warp §7konnte nicht gefunden werden!"); } } else if(args.length == 1) { p.sendMessage(Main.s + "Diese §6Warps §7stehen zur Verfügung:" + cfg.get("Warps" + ".list" )); } } return false; } }
You save the name of the warp with Code (Text): cfg.set("Warps" + ".name", args[0].toLowerCase().toString()); Now args[0].toLowerCase() is mapped to Warps.name in your config. When you try to get your warp, you check Code (Text): if(cfg.contains("Warps" + ".name" + args[0])) This obviously returns false because the key in your config is only Warps.name. What you shoud do is to map each warp point to a different key of the format warps.[warp-name].property where you replace [warp-name]. Something like this: Code (Text): String name = args[0].toLowerCase(); cfg.set("warps." + name + ".world", p.getLocation().getWorld().getName()); cfg.set("warps." + name + ".x", p.getLocation().getX()); cfg.set("warps." + name + ".y", p.getLocation().getY());