D
deleted209242
Guest
Sehr geehrte Foren Mitglieder,
ich habe soeben ein Home Plugin geschrieben und wollte dies nun testen, allerdings bekomme ich beim befehl zum Home zu teleportieren einen fehler.
Das kam nachdem ich /home Test eingegeben habe, welchen ich davor erstellt habe.
Hier meine beiden Klassen:
Und noch die yml files:
Hat jemand eine idee wo der fehler liegt?
mfg Sullaysur
ich habe soeben ein Home Plugin geschrieben und wollte dies nun testen, allerdings bekomme ich beim befehl zum Home zu teleportieren einen fehler.
Das kam nachdem ich /home Test eingegeben habe, welchen ich davor erstellt habe.
Code:
[14:55:33 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'home' in plugin Calderya v1.0.5
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:648) ~[spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PlayerConnection.handleCommand(PlayerConnection.java:1399) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1234) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_201]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_201]
at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:748) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_201]
Caused by: java.lang.IllegalArgumentException: Name cannot be null
at org.apache.commons.lang.Validate.notNull(Validate.java:192) ~[spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.getWorld(CraftServer.java:1030) ~[spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.Bukkit.getWorld(Bukkit.java:486) ~[spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
at de.thegreeny.calderya.commands.Home.onCommand(Home.java:32) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
... 15 more
Hier meine beiden Klassen:
Code:
public class Sethome implements CommandExecutor{
File file = new File("plugins/Calderya", "homes.yml");
FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
@Override
public boolean onCommand(CommandSender sender, Command cmd, String lable, String[] args) {
Player p = (Player) sender;
if(args.length == 1) {
if(!cfg.isSet(p.getName() + "." + args[0] + ".world")) {
String world = p.getWorld().getName();
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
float yaw = p.getLocation().getYaw();
float pitch = p.getLocation().getPitch();
cfg.set(p.getName() + "." + args[0] + ".world", world);
cfg.set(p.getName() + "." + args[0] + ".x", x);
cfg.set(p.getName() + "." + args[0] + ".y", y);
cfg.set(p.getName() + "." + args[0] + ".z", z);
cfg.set(p.getName() + "." + args[0] + ".yaw", yaw);
cfg.set(p.getName() + "." + args[0] + ".pitch", pitch);
try {
cfg.save(file);
} catch (IOException e) {
e.printStackTrace();
}
p.sendMessage("§eDas Home §b " + args[0] + " §ewurde erstellt!");
} else {
p.sendMessage("§4Das Home §b " + args[0] + " §7existiert bereits!");
}
} else {
p.sendMessage("§4Falsche Angabe! §7Bitte nutze /sethome [name]");
}
return false;
}
}
Code:
public class Home implements CommandExecutor{
File file = new File("plugins/Calderya", "homes.yml");
FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
@Override
public boolean onCommand(CommandSender sender, Command cmd, String lable, String[] args) {
Player p = (Player) sender;
if(args.length == 1) {
String world = cfg.getString(p.getName() + "." + args[0] + ".world");
double x = cfg.getDouble(p.getName() + "." + args[0] + ".x");
double y = cfg.getDouble(p.getName() + "." + args[0] + ".y");
double z = cfg.getDouble(p.getName() + "." + args[0] + ".z");
double yaw = cfg.getDouble(p.getName() + "." + args[0] + ".yaw");
double pitch = cfg.getDouble(p.getName() + "." + args[0] + ".pitch");
Location loc = new Location(Bukkit.getWorld(world), x, y, z);
loc.setPitch((float) pitch);
loc.setYaw((float) yaw);
p.teleport(loc);
p.sendMessage("§eDu befindest dich jetzt bei deinem Home§b " + args[0] + " §e!");
} else {
p.sendMessage("§4Falsche Angabe! §7Bitte nutze /home [name]");
}
return false;
}
}
Und noch die yml files:
yaml:
commands:
sethome:
description: Setzte einen HomePunkt!
usage: /sethome <name>
home:
description: Teleportiert zu einen HomePunkt!
usage: /home <name>
yaml:
Sullaysur:
Test:
world: world
x: -201.97820526475581
y: 70.0
z: 249.2064266720636
yaw: 124.35049
pitch: 9.29999
Hat jemand eine idee wo der fehler liegt?
mfg Sullaysur