Config help

Discussion in 'Plugin Development' started by XxHazzana43xX, Nov 19, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    XxHazzana43xX

    Hola, im a struggling coder and I'm testing out stuff to learn how to code and I'm trying to add in a config so they can edit the prefix and then edit the player messages could someone help me?? this is my code so far

    Code:
    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.plugin.java.JavaPlugin;
     
    public class Test extends JavaPlugin {
     
        private String prefix = (ChatColor.GREEN + "" + ChatColor.BOLD + "Prefix" + ChatColor.WHITE + " " + ChatColor.BOLD + "ยป ");
       
        public void onEnable() {
            Bukkit.getServer().getLogger().info(prefix + "Test plugin Enabled!");
           
        }
       
        public void onDisable() {
            Bukkit.getServer().getLogger().info(prefix + "Test plugin Disabled!");
        }
       
        public boolean onCommand(CommandSender sender, Command cmd, String  commandLable, String[] args) {
           
            if (!(sender instanceof Player)) {
                sender.sendMessage(ChatColor.RED + "Cosnole can'nt run this command");
                return true;
            }
           
            Player player = (Player) sender;
           
            if (cmd.getName().equalsIgnoreCase("test")) {
                player.sendMessage(ChatColor.GOLD + "You ran the test command! Good Job!");
                player.sendMessage(ChatColor.AQUA + "this is a test for the 2nd line!");
            }
            return true;
        }
       
    }
     
  2. Offline

    FabeGabeMC

    There is a Configuration API built into Bukkit.
    Or:
    You could check the JavaDocs and get a better understanding on what each method does.
     
  3. Offline

    SuperOriginal

    1. You don't need to state when your plugin is enabled and disabled. Bukkit already does that.

    2. I don't think you should get into the habit of blocking console from using all your commands. Only block console if the command actually can't be run by it. Console is perfectly capable of receiving messages, therefore you shouldn't need to block console. Just use sender instead of player.
     
Thread Status:
Not open for further replies.

Share This Page