Here is what it is supposed to do: It is supposed to kick a player when /smp on is on but what it is doing right now is just kicking all the online players. It is supposed to kick them when they join too but it is not why is it not? CODE: Code:java package me.zangoran.kobaltorange.smp; import org.bukkit.Bukkit;import org.bukkit.ChatColor;import org.bukkit.command.Command;import org.bukkit.command.CommandSender;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.player.PlayerJoinEvent;import org.bukkit.plugin.java.JavaPlugin; public class SMP extends JavaPlugin implements Listener { public static boolean state = false; private int smp1; public void onEnable1() { getLogger().info("onEnable has been enabled!"); getServer().getPluginManager().registerEvents(this, this); } @ Override public void onDisable() {} int smp = 0; public void onEnable() { getServer().getPluginManager().registerEvents(this, this); } @EventHandler public void onPlayerJoin(PlayerJoinEvent event){ if(smp == 1){ Player player = event.getPlayer(); player.kickPlayer("Server is under maintencance!"); } else { } } public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("smp") && sender instanceof Player) { Player player = (Player) sender; if (!player.hasPermission("smp.toggle")) { player.sendMessage(ChatColor.RED + "You are not allowed to perform this command."); return true; } else if (args.length > 0) { if (args[0].equalsIgnoreCase("on")) { smp1 = 1; for (Player p: Bukkit.getServer().getOnlinePlayers()) { if (!p.hasPermission("smp.bypass")) { p.kickPlayer("Server is under maintenance!"); return true; } else { Bukkit.getLogger().info(ChatColor.RED + "[" + ChatColor.GOLD + "SMP" + ChatColor.RED + "]" + ChatColor.BLUE + " SMP has been turned" + ChatColor.DARK_GREEN + " ON"); p.sendMessage(ChatColor.RED + "[" + ChatColor.GOLD + "SMP" + ChatColor.RED + "]" + ChatColor.BLUE + " SMP has been turned" + ChatColor.DARK_GREEN + " ON"); } } } else if (args[0].equalsIgnoreCase("off")) { smp1 = 0; for (Player p: Bukkit.getServer().getOnlinePlayers()) { p.sendMessage(ChatColor.RED + "[" + ChatColor.GOLD + "SMP" + ChatColor.RED + "]" + ChatColor.BLUE + " SMP has been turned" + ChatColor.RED + " OFF"); } return true; } else if (args[0].equalsIgnoreCase("status")) { for (Player p: Bukkit.getServer().getOnlinePlayers()) { p.sendMessage(ChatColor.RED + "[" + ChatColor.GOLD + "SMP" + ChatColor.RED + "]" + " " + ChatColor.RED + ChatColor.BOLD + smp1 + ChatColor.GOLD + " 0 = OFF, 1 = ON"); } return true; } else if (args[0].equalsIgnoreCase("reload")) { if (player.hasPermission("smp.reload")) { this.reloadConfig(); player.sendMessage(ChatColor.RED + "[" + ChatColor.GOLD + "SMP" + ChatColor.RED + "]" + ChatColor.DARK_RED + " SMP reloaded!"); Bukkit.getLogger().info(ChatColor.RED + "[" + ChatColor.GOLD + "SMP" + ChatColor.RED + "]" + ChatColor.DARK_RED + " SMP reloaded!"); return true; } } } else { return false; } } else { return true; } return true; } }
Zangoran Please STOP asking the same question ever and ever again! This is like your 10. thread with the SAME thing. SEARCH for a JAVA tutorial AND do the turorial. This is not a Java basic help forum at all.
A progressive history of your work on this plugin in case anyone needs references: http://forums.bukkit.org/threads/plugin-yml-help.273695/ http://forums.bukkit.org/threads/plugin-yml-crashing-my-server.273984/ http://forums.bukkit.org/threads/onplayerjoin-help.274028/ http://forums.bukkit.org/threads/dev-help-please.274043/ http://forums.bukkit.org/threads/kick-message-help.274078/ http://forums.bukkit.org/threads/help-with-my-plugin.274284/ http://forums.bukkit.org/threads/having-problems-again.274534/ Locking the old posts and directing people to come to this one. After this, let's please try to keep everything in one place. There's no need to keep opening up new threads for working on the same project. Keep it here.
Code:java private int smp1; public void onEnable1() {getLogger().info("onEnable has been enabled!");getServer().getPluginManager().registerEvents(this, this);} @Overridepublic void onDisable() {} int smp = 0; Note the variables at the start and end of this syntax block and fix your error. You should really do some tutorials as this is EXTREMELY easy to fix, even for a Beginning Developer.
Do you know why it is not kicking a player when they join? I have searched and searched and it is not working. Please help.
You really need to start reading the bukkit docs. There is a method for this... And in several of your other posts I have even shown it to you...
es359 he doesn't even need to read the docs to solve this problem. He needs to learn Java before asking the Bukkit community about simple syntax and reference errors. I'm pretty sure there's a post stating the community is not here to teach anyone Java... I quote mbaxter - 'You can't start with a "how 2 bukkit" tutorial. Step further back and read some instruction on java itself.'
Zangoran When a player logs in, start a delayed task to kick them instead of trying to kick them in the event. Isn't this EXACTLY what whitelisting does?
Im_Zeus What he is saying is to kick them after a delay rather than kicking straight away - I'm pretty sure that's not what OP wants.