Skygun_ Posted July 16, 2019 Share Posted July 16, 2019 Hey Leute, ich helfe gerade einem Server beim Aufbau mit ein paar Plugins. Ich habe gestern ein Random TP Plugin geschrieben was auf meinem Test Server funktioniert aber auf dem richtigen Server nicht. Unten habe ich den Source Code und die Fehlermeldung. Kann mir wer helfen? package TDM; import java.io.File; import java.io.IOException; import java.util.HashMap; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.block.Block; 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.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; public class Main extends JavaPlugin { @SuppressWarnings({ "unchecked", "rawtypes" }) private HashMap<String, Long> healcs = new HashMap(); public void onEnable() { this.getCommand("wartung").setExecutor((CommandExecutor) new Main()); this.getCommand("tpr").setExecutor((CommandExecutor) new Main()); this.getCommand("randomperm").setExecutor((CommandExecutor) new Main()); PluginManager pm = Bukkit.getPluginManager(); System.out.println("======Plugin RANDOM aktiviert======"); } public void onDisable() { System.out.println("======Plugin RANDOM deaktiviert======"); } @Override public boolean onCommand(CommandSender sender, Command cmd, String arg2, String[] args) { Player p = (Player) sender; if (cmd.getName().equalsIgnoreCase("tpr")) { if (args.length == 0) { p.sendMessage("§bDu wirst nun auf eigene Gefahr teleportiert."); try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } File Ordner = new File("plugins//Random"); File File = new File("plugins//Random//random.yml"); if (!Ordner.exists()) { Ordner.mkdir(); } if (!File.exists()) { try { File.createNewFile(); } catch (IOException e1) { p.sendMessage("\u00a7cDiese Datei konnte auf diesem Pfad nicht erstellt werden."); } } YamlConfiguration cfg1 = YamlConfiguration.loadConfiguration((File) File); int maxx = cfg1.getInt("maxX"); int maxz1 = cfg1.getInt("maxX"); int minx = cfg1.getInt("minX"); int minz = cfg1.getInt("minZ"); int maxX = maxx; int minX = minx; int X = (int) Math.round(Math.random() * (double) (maxX - minX + 1) + (double) minX); double maxZ = maxz1; int minZ = minz; int Z = (int) Math.round(Math.random() * (double) (maxZ - minZ + 1) + (double) minZ); Location loc = p.getLocation(); String world = loc.getWorld().getName(); World welt = Bukkit.getWorld((String) world); loc.setX((double) X); loc.setZ((double) Z); Block b = welt.getHighestBlockAt(loc); loc.setY((double) b.getLocation().getBlockY()); loc.setWorld(welt); p.teleport(loc); } if (args.length == 1) { if (p.hasPermission("server.random.set")) { File ordner; YamlConfiguration cfg; double maxz; File file; if (args[0].equalsIgnoreCase("max")) { if (!(sender instanceof Player)) { System.out.println("Dein ernst ?"); return true; } ordner = new File("plugins//Random"); file = new File("plugins//Random//random.yml"); if (!ordner.exists()) { ordner.mkdir(); } if (!file.exists()) { try { file.createNewFile(); } catch (IOException e) { p.sendMessage("\u00a7cDiese Datei konnte auf diesem Pfad nicht erstellt werden."); } } cfg = YamlConfiguration.loadConfiguration((File) file); Location locMax = p.getLocation(); double maxx = locMax.getX(); maxz = locMax.getZ(); cfg.set("maxX", (Object) maxx); cfg.set("maxZ", (Object) maxz); try { cfg.save(file); } catch (IOException e) { e.printStackTrace(); } p.sendMessage("\u00a7aDu hast die Maximalen Koordinaten gesetzt!"); } if (args[0].equalsIgnoreCase("min")) { if (!(sender instanceof Player)) { System.out.println("Dein ernst"); return true; } ordner = new File("plugins//Random"); file = new File("plugins//Random//random.yml"); if (!ordner.exists()) { ordner.mkdir(); } if (!file.exists()) { try { file.createNewFile(); } catch (IOException e) { p.sendMessage("\u00a7cDiese Datei konnte auf diesem Pfad nicht erstellt werden."); } } cfg = YamlConfiguration.loadConfiguration((File) file); Location locMin = p.getLocation(); double minx = locMin.getX(); maxz = locMin.getZ(); cfg.set("minX", (Object) minx); cfg.set("minZ", (Object) maxz); try { cfg.save(file); } catch (IOException e) { e.printStackTrace(); } p.sendMessage("\u00a7aDu hast die Minimalen Koordinaten gesetzt!"); } } } } if (cmd.getName().equalsIgnoreCase("wartung")) { cmd.setPermission("server.wartung"); p = (Player) sender; if (!p.hasPermission("server.wartung")) { p.sendMessage("\u00a7cDu hast keine Berechtigung für diesen Befehl."); } else if (args.length == 0) { p.sendMessage("\u00a7cBitte Benutze /wartung an | /wartung aus"); } else if (args.length == 1) { if (args[0].equalsIgnoreCase("an")) { Bukkit.broadcastMessage((String) "\u00a7c\u00a7lDer Server geht kurz in den Wartungs Modus"); Bukkit.setWhitelist((boolean) true); this.getServer().setWhitelist(true); for (Player online : Bukkit.getOnlinePlayers()) { if (online.getName().equals(p.getName())) continue; online.kickPlayer("\u00a7cWartung"); } } else if (args[0].equals("aus")) { Bukkit.setWhitelist((boolean) false); this.getServer().setWhitelist(true); Bukkit.broadcastMessage((String) "\u00a7c\u00a7lDer Server ist nun nicht mehr im Wartungs Modus"); } } } if(cmd.getName().equalsIgnoreCase("randomperm")) { p.sendMessage("Setzten: server.random.set"); p.sendMessage("Wartung: server.wartung"); } return false; } } [17:22:46] [Server thread/INFO]: [Random] Enabling Random v0.1* [17:22:46] [Server thread/ERROR]: Error occurred while enabling Random v0.1 (Is it up to date?) java.lang.IllegalArgumentException: Plugin already initialized! at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:171) ~[patched_1.14.3.jar:git-Paper-131] at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:52) ~[patched_1.14.3.jar:git-Paper-131] at TDM.Main.<init>(Main.java:42) ~[?:?] at TDM.Main.onEnable(Main.java:48) ~[?:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.14.3.jar:git-Paper-131] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:338) ~[patched_1.14.3.jar:git-Paper-131] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:420) ~[patched_1.14.3.jar:git-Paper-131] at org.bukkit.craftbukkit.v1_14_R1.CraftServer.enablePlugin(CraftServer.java:467) ~[patched_1.14.3.jar:git-Paper-131] at org.bukkit.craftbukkit.v1_14_R1.CraftServer.enablePlugins(CraftServer.java:381) ~[patched_1.14.3.jar:git-Paper-131] at org.bukkit.craftbukkit.v1_14_R1.CraftServer.reload(CraftServer.java:859) ~[patched_1.14.3.jar:git-Paper-131] at org.bukkit.Bukkit.reload(Bukkit.java:610) ~[patched_1.14.3.jar:git-Paper-131] at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:54) ~[patched_1.14.3.jar:git-Paper-131] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[patched_1.14.3.jar:git-Paper-131] at org.bukkit.craftbukkit.v1_14_R1.CraftServer.dispatchCommand(CraftServer.java:739) ~[patched_1.14.3.jar:git-Paper-131] at net.minecraft.server.v1_14_R1.PlayerConnection.handleCommand(PlayerConnection.java:1831) ~[patched_1.14.3.jar:git-Paper-131] at net.minecraft.server.v1_14_R1.PlayerConnection.a(PlayerConnection.java:1639) ~[patched_1.14.3.jar:git-Paper-131] at net.minecraft.server.v1_14_R1.PacketPlayInChat.a(PacketPlayInChat.java:47) ~[patched_1.14.3.jar:git-Paper-131] at net.minecraft.server.v1_14_R1.PacketPlayInChat.a(PacketPlayInChat.java:5) ~[patched_1.14.3.jar:git-Paper-131] at net.minecraft.server.v1_14_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:18) ~[patched_1.14.3.jar:git-Paper-131] at net.minecraft.server.v1_14_R1.TickTask.run(SourceFile:18) ~[patched_1.14.3.jar:git-Paper-131] at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:127) ~[patched_1.14.3.jar:git-Paper-131] at net.minecraft.server.v1_14_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[patched_1.14.3.jar:git-Paper-131] at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:105) ~[patched_1.14.3.jar:git-Paper-131] at net.minecraft.server.v1_14_R1.MinecraftServer.aW(MinecraftServer.java:1002) ~[patched_1.14.3.jar:git-Paper-131] at net.minecraft.server.v1_14_R1.MinecraftServer.executeNext(MinecraftServer.java:995) ~[patched_1.14.3.jar:git-Paper-131] at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:115) ~[patched_1.14.3.jar:git-Paper-131] at net.minecraft.server.v1_14_R1.MinecraftServer.sleepForTick(MinecraftServer.java:979) ~[patched_1.14.3.jar:git-Paper-131] at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:912) ~[patched_1.14.3.jar:git-Paper-131] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_171] Caused by: java.lang.IllegalStateException: Initial initialization at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:174) ~[patched_1.14.3.jar:git-Paper-131] at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:52) ~[patched_1.14.3.jar:git-Paper-131] at TDM.Main.<init>(Main.java:42) ~[?:?] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_171] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_171] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_171] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_171] at java.lang.Class.newInstance(Class.java:442) ~[?:1.8.0_171] at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:75) ~[patched_1.14.3.jar:git-Paper-131] at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:134) ~[patched_1.14.3.jar:git-Paper-131] at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:337) ~[patched_1.14.3.jar:git-Paper-131] at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:257) ~[patched_1.14.3.jar:git-Paper-131] at org.bukkit.craftbukkit.v1_14_R1.CraftServer.loadPlugins(CraftServer.java:355) ~[patched_1.14.3.jar:git-Paper-131] at org.bukkit.craftbukkit.v1_14_R1.CraftServer.reload(CraftServer.java:857) ~[patched_1.14.3.jar:git-Paper-131] ... 19 more [17:22:46] [Server thread/INFO]: [Random] Disabling Random v0.1 [17:22:46] [Server thread/INFO]: ======Plugin RANDOM deaktiviert====== Link to comment Share on other sites More sharing options...
Yuki Posted July 17, 2019 Share Posted July 17, 2019 Hi, Zitat java.lang.IllegalArgumentException: Plugin already initialized! ist das Plugin eventuell ausversehen 2 mal im Ordner? -Yuki Link to comment Share on other sites More sharing options...
Boy132 Posted August 6, 2019 Share Posted August 6, 2019 this.getCommand("wartung").setExecutor((CommandExecutor) new Main()); this.getCommand("tpr").setExecutor((CommandExecutor) new Main()); this.getCommand("randomperm").setExecutor((CommandExecutor) new Main()); Es liegt an den 3 Zeilen: "new Main()" ist eine ganz schlechte Idee. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now