haha alright... heres what I use to create my config.yml (checks if it exists) Code: public class Flow extends JavaPlugin { @Override public void onEnable() { final File f = new File(getDataFolder(), "config.yml"); if (!f.exists()) { saveDefaultConfig(); }
thanks!! btw do you know how to change the config file on a command like change: Code: Kick: false to Code: Kick: true on a command
do you know how to get if it is true or false i am doing this but it doen't work Code: if (plugin.getConfig().getBoolean("Kick") == true) { }
it tells me "could not pass PlayerJoinEvent" here is the rest on my code if you need it: Code: public class LoginMessage extends JavaPlugin { public static LoginMessage plugin; @Override public void onEnable() { super.onEnable(); final File f = new File(getDataFolder(), "config.yml"); if (!f.exists()) { saveDefaultConfig(); } getServer().getPluginManager().registerEvents(new Listener() { @SuppressWarnings("unused") @EventHandler public void playerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); if (plugin.getConfig().getBoolean("Kick") == true) { if (player.isOp()) { return; } else { String output = ChatColor.translateAlternateColorCodes( '&', getConfig().getString("KickMessage")); player.kickPlayer(output); } } else { return; } } }, this); } @Override public void onDisable() { super.onDisable(); } @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { Player player = (Player) sender; if (label.equalsIgnoreCase("k")) { if (args.length == 1) { if (args[0].equalsIgnoreCase("on")) { this.getConfig().set("Kick",true); player.sendMessage("The server will now kick the players that whant to join"); } else if (args[0].equalsIgnoreCase("off")) { this.getConfig().set("Kick",false); player.sendMessage("The server will now let players enter"); } } } return super.onCommand(sender, command, label, args); } }
what is the stack trace? to whits line is the stack trace pointing? {edit} cause: plugin = null, you forgot to do plugin = this inside onEnable()
k i have never done that. btw: i think you are a plugin god EDIT by Moderator: merged posts, please use the edit button instead of double posting.