I need help just continuing a plugin I'm making. I don't know what to do next. What it should do is when you type "/Enchant" it opens an enchanting table that you can use like you normally would. It is for servers that don't like the when people use "/Enchant Sharpness 10" for example. It is essentially a more fair way to enchant for donators. Could you tell me what to do next or what I have done wrong? Here it is.
Thanks. Do you see any other problems with the code. If I get it all ready and set up the plugin.yml could I run it on my server?
Thermo_Core I would skip logging when the plugin in enabled and disabled, because Bukkit does that automatically. Here is an updated onCommand to make things a bit better: Code:java public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){ if(cmd.getName().equalsIgnoreCase("enchantopen")) { //Using just "enchant" would conflict with over plugins. if(sender instanceof Player) { //Check if a player sent it Player player = (Player) sender; //Cast only after checking instanceof player.openEnchanting(null, true); //Open the enchanting table return true; } else { sender.sendMessage(ChatColor.RED+"Only players can open the enchanting table!"); return true; } } return false;}
Logger.getLogger("Minecraft") is kinda outdated. There is already a logger built into JavaPlugin (getLogger()). I just use this method to log messages to the console: Code:java public void log(String msg){ getLogger().info(msg);} This automatically adds the [YourPlugin] prefix to the message.
I did everything and set up the plugin.yml, but it won't load on my server? The error can not load PvPEnchant comes up. Here is the final code http://pastebin.com/2cTbdAJe . Here is the plugin.yml Code: name: PvPEnchant main: com.coredevelopment version: 1.0 commands: ExpTable: description: Opens An Enchanting Table! usage: /<command> permission: <plugin name>.ExpTable permission-message: You Don't Have <permission>
Thermo_Core i think you did something wrong there, Did u mean this Code: name: PvPEnchant main: com.coredevelopment version: 1.0 commands: ExpTable: description: Opens An Enchanting Table! usage: /<command> permission: <plugin name>.ExpTable permission-message: You Don't Have <permission>
Thank you for the reply, but it still doesn't work. This is the error it gives me when I load it. I probably did something really stupid wrong. Server Log: http://pastebin.com/JMhCngKh
Thermo_Core What is your main class file called? The error is that the Main Class File could not be found
If your main class file is PvPEnchant then use this Code: name: PvPEnchant main: com.coredevelopment.PvPEnchant version: 1.0 commands: ExpTable: description: Opens An Enchanting Table! usage: /<command> permission: <plugin name>.ExpTable permission-message: You Don't Have <permission>
Then he should use this for his plugin.yml Code: name: PvPEnchant main: com.coredevelopment.AlphaEnchant version: 1.0 commands: ExpTable: description: Opens An Enchanting Table! usage: /<command> permission: <plugin name>.ExpTable permission-message: You Don't Have <permission>
Miner_Fil gomeow Thank you so much for all of your help. So far it works and I have created my first plugin. I will now test it for a while until I am confident with the results. Thank You!
You Welcome No, You didn't Know!?!?!?! You only need a command executor when you create the commands in different classes EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Yes, You use ChatColor.RED for example if you put it like ChatColor. you should have options of colors
Yes sorry I'm used to making commands in a different class (keeps it neater) no need for the !!???? Though
thermo, for the color coding, create a method like this: Code: public String toColor(String string){ string = ChatColor.translateAlternateColorCodes('&', string); return string; } and to make the color do "&ahi" will return a light green or if you want manual way (no changing in config, no user interface changing, etc) just do ChatColor.GREEN + "String" for the bukkit dev, go to ur profile here and connect ur profile to ur buk dev profile.