Tim0123 Posted May 18, 2021 Posted May 18, 2021 Hi, währe nett wenn ihr mir helfen könntet Mein Minecraft plugin funktioniert nicht ich bin relativ neu hier ist der code der code soll einen Spawnpunkt setzen können und mann soo dorthin teleportiert werden können: SetspawnCommand package de.tim.tutorial.commands; 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 de.tim.tutorial.main.Main; public class SetspawnCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (sender instanceof Player) { Player player = (Player) sender; if (player.hasPermission("tutorial.setspawn")) { if (args.length == 0) { FileConfiguration config = Main.getPlugin().getConfig(); config.set("Spawn.World",player.getWorld().getName()); config.set("Spawn.X", player.getLocation().getX()); config.set("Spawn.z", player.getLocation().getZ()); config.set("Spawn.Yaw", player.getLocation().getYaw()); config.set("Spawn.Pitch", player.getLocation().getPitch()); Main.getPlugin().saveConfig(); player.sendMessage("§aDu hast den Worldwspawn umgesetzt!"); } else player.sendMessage("§cBitte benutze §6/setspawn§c!"); } else player.sendMessage("§cDazu hast du keine Rechte!"); } return false; } } SpawnCommand (zum spawn teleportieren) package de.tim.tutorial.commands; 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 de.tim.tutorial.main.Main; public class SpawnCommand implements CommandExecutor{ @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if(sender instanceof Player) { Player player = (Player) sender; if (player.hasPermission("tutorial.spawn")) { if(args.length == 0) { FileConfiguration config = Main.getPlugin().getConfig(); World world = Bukkit.getWorld(config.getString("Spawn.World")); double x = config.getDouble("spawn.x"); double y = config.getDouble("spawn.y"); double z = config.getDouble("spawn.z"); float yaw = (float) config.getDouble("Spawn.yaw"); float pitch = (float) config.getDouble("Spawn.Pitch"); Location location = new Location(world, x, y, z, yaw, pitch); player.teleport(location); }else player.sendMessage("§cBitte benutze §6/spanw§c!"); }else player.sendMessage("§cDazu hast du keine Rechte!"); } return false; } } da ich schon andere Commands gemacht habe habe ich in der Main mehr commands stehen und in der plugin.yml: Main: package de.tim.tutorial.main; import org.bukkit.Bukkit; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import de.tim.tutorial.commands.HealCommand; import de.tim.tutorial.commands.KitCommand; import de.tim.tutorial.commands.MessageCommand; import de.tim.tutorial.commands.SetspawnCommand; import de.tim.tutorial.commands.SpawnCommand; import de.tim.tutorial.listeners.JoinListener; public class Main extends JavaPlugin { private static Main plugin; public void onEnable() { plugin = this; getCommand("heal").setExecutor(new HealCommand()); getCommand("kit").setExecutor(new KitCommand()); getCommand("msg").setExecutor(new MessageCommand()); getCommand("setspawn").setExecutor(new SetspawnCommand()); getCommand("spawn").setExecutor(new SpawnCommand()); PluginManager pluginManager = Bukkit.getPluginManager(); pluginManager.registerEvents(new JoinListener(), this); } public static Main getPlugin() { return plugin; } } Plugin.yml: name: Tutorial version: 1.0 main: de.tim.tutorial.main.Main commands: heal: description: Dieses Kommando heilt dich! kit: description: Oeffne das Kit-Inventar! msg: description: Sende eine Nachricht! setspawn: description: Setze deinen Spawnpoint! spawn: description: Teleportiere dich zum Spawn!
TileEntity Posted May 18, 2021 Posted May 18, 2021 Was genau funktioniert nicht? Hattest du in den logs geschaut, wo der Fehler auftritt? Ansonsten schau mal bei Github nach ähnlichem Projekten bez. Aufbau etc: https://github.com/npmSteven/SimpleSpawn
Tim0123 Posted May 18, 2021 Author Posted May 18, 2021 Es gibt keine Fehlermeldung ich kann alle commands machen und es wird auch das ausgegeben also dein Spawn wurde gesetzt ect. aber ich werde an einen komplett anderen Ort teleportiert wenn ich /spawn eingebe.
TileEntity Posted May 18, 2021 Posted May 18, 2021 Evtl. greift das Plugin nicht auf die config zurück bzw. schreibt die neuen Koordinaten nicht rein 🤔
Tim0123 Posted May 18, 2021 Author Posted May 18, 2021 du meinst dass man die Koordinaten erst löschen muss und dann wieder rein machen muss ?
TileEntity Posted May 18, 2021 Posted May 18, 2021 Ka, evtl. funktioniert es garnicht und der /spawn befehl greift auf den server-standard Befehl zurück
TileEntity Posted May 18, 2021 Posted May 18, 2021 Ohne Fehlermeldungen wird es schwer Wie oben schon erwähnt, schau mal mit bei ähnlichen Projekten drüber
Tim0123 Posted May 19, 2021 Author Posted May 19, 2021 ich habs ich habe beim /Spawn command spawn bei double x = config.getDouble("Spawn.X"); ...
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