Gelöscht_25272 Posted March 31, 2021 Share Posted March 31, 2021 package CommandExecutor; import Main.main; import org.bukkit.Bukkit; import org.bukkit.Sound; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitRunnable; import ru.tehkode.permissions.bukkit.PermissionsEx; public class CMD_Stop implements CommandExecutor { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (sender instanceof ConsoleCommandSender) { if (cmd.getName().equalsIgnoreCase("stop")) { new BukkitRunnable() { int count = 3; public void run() { if (count >= 1) { for (Player all : Bukkit.getOnlinePlayers()) { Bukkit.broadcastMessage( "§8| §4Server§f-§4shutdown in§8: §e" + count + " Sekunde(n) §f| §cBitte nicht verlassen!"); all.playSound(all.getLocation(), Sound.BLOCK_ANVIL_LAND, 1.0F, 50.0F); count--; } } } }.runTaskTimer((Plugin) this, 0, 20); sender.sendMessage("Bukkit.shutdown();"); } } else if (PermissionsEx.getUser((Player) sender).inGroup("Owner") || PermissionsEx.getUser((Player) sender).inGroup("Vice")) { Bukkit.getConsoleSender().sendMessage("§4! §e" + sender.getName() + " tried to stop the server"); sender.sendMessage("§7| §4Only for the §bConsoleCommandSender"); } else { sender.sendMessage(main.noperm); } return false; } } Was habe ich vor? Spieler tippt stop in der Console ein > Allen Spielern auf dem Server wird der Text in Bukkit.broadcastMessage(""); ausgegeben und nach den drei Sekunden wird der Server heruntergefahren. Wo ist der Fehler? https://pastebin.com/MeAqiH9p 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