MyPlugin doesnt work.

Discussion in 'Plugin Development' started by TitanConfigs, Apr 27, 2014.

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

    TitanConfigs

    Hello, i make to follow the instructions of pogostick and my plugin does not show up in the list or in the console plugin and also does not work. I did everything correctly using the library craftbukkit 1.7.2.

    This is the java code.
    Code:java
    1. package me.titan.miniworld;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10. public class MyAdmin extends JavaPlugin {
    11.  
    12. public void onEnable() {
    13. Bukkit.getServer().getLogger().info("Medic enabled!");
    14. }
    15.  
    16. public void onDisable() {
    17. Bukkit.getServer().getLogger().info("Medic disabled!");
    18. }
    19.  
    20. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    21.  
    22. if (!(sender instanceof Player)) {
    23. sender.sendMessage(ChatColor.RED + "The console cannot use Medic!");
    24. return true;
    25. }
    26.  
    27. Player player = (Player) sender;
    28.  
    29. if (cmd.getName().equalsIgnoreCase("heal")) {
    30. if (args.length == 0) {
    31. player.setHealth(20.0);
    32. player.sendMessage(ChatColor.GREEN + "You have been healed!");
    33. return true;
    34. }
    35. Player target = Bukkit.getServer().getPlayer(args[0]);
    36. if (target == null) {
    37. player.sendMessage(ChatColor.RED + "Could not find player!");
    38. return true;
    39. }
    40. target.setHealth(20.0);
    41. target.sendMessage(ChatColor.GREEN + "You have been healed!");
    42. player.sendMessage(ChatColor.GREEN + target.getName() + " has been healed!");
    43. }
    44.  
    45. if (cmd.getName().equalsIgnoreCase("feed")) {
    46. if (args.length == 0) {
    47. player.setFoodLevel(20);
    48. player.sendMessage(ChatColor.GREEN + "You have been fed!");
    49. return true;
    50. }
    51. Player target = Bukkit.getServer().getPlayer(args[0]);
    52. if (target == null) {
    53. player.sendMessage(ChatColor.RED + "Could not find player!");
    54. return true;
    55. }
    56. target.setFoodLevel(20);
    57. target.sendMessage(ChatColor.GREEN + "You have been fed!");
    58. player.sendMessage(ChatColor.GREEN + target.getName() + " has been fed!");
    59. }
    60. return true;
    61. }
    62. }


    This is the plugin.yml
    Code:
    name: MyAdmin
    version: 1.0
    main: me.titan.miniworld.MyAdmin
    author: waxcoder
    description: Heal and Feed!
     
    commands:
        heal:
            usage: /<command>
            aliases: [health, givehealth]
            description: Heal.
        feed:
            usage: /<command>
            aliases: [food, sate]
            description: Feed.
     
  2. Offline

    Knaxel

    Code:java
    1. public class MyAdmin extends JavaPlugin implements CommandExecutor{

    nvm here is all you need to do
     
  3. Offline

    Gater12

    Knaxel
    Shouldn't need to do that; it's his main class.

    TitanConfigs
    Did it throw any errors in the console?
     
    TitanConfigs likes this.
  4. Offline

    Rocoty

    TitanConfigs please don't just tell us it's not working. If you want help you should tell us what isn't working, what makes you think it isn't working, what you were trying to do and what happens instead. All this may be a lot easier if you try to set it up as a question.
     
  5. Offline

    TitanConfigs

    no, nothing appeared in the console.
     
  6. Offline

    Rocoty

    TitanConfigs Try telling us all the details. It may help
     
  7. @Override should be above the onCommand method and it should extend CommandExecutor.
     
  8. Offline

    Rocoty

    DJSkepter JavaPlugin already inherits from CommandExecutor. @Override tags only allows the compiler to display errors when trying to override a method that does not exist in the superclass.

    While this is true, I do agree that they should use the @Override annotation.
     
    chromestone likes this.
  9. Offline

    TitanConfigs

    I'm trying to make a custom plugin for my Portuguese server where the admin will be able to do / heal and / feed and other commands in which I will develop over time (instead I use essentials supposed to use the custom plugin ).
     
  10. Offline

    Rocoty

    Are you including the plugin.yml when exporting the project? And are you absolutely sure you do not get any sort of error in the console on reload?
     
  11. Offline

    TitanConfigs

    ok i do reload again and this appeared

    Code:
    19:02:51 ERROR]: Could not load 'plugins/MyAdmin.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
    at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:176) ~[craftbukkit_vgbin.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [craftbukkit_vgbin.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.craftbukkit.v1_7_R1.CraftServer.loadPlugins(CraftServer.java:350) [craftbukkit_vgbin.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.craftbukkit.v1_7_R1.CraftServer.reload(CraftServer.java:771) [craftbukkit_vgbin.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.Bukkit.reload(Bukkit.java:279) [craftbukkit_vgbin.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23) [craftbukkit_vgbin.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:175) [craftbukkit_vgbin.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServer.java:683) [craftbukkit_vgbin.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.PlayerConnection.handleCommand(PlayerConnection.java:952) [craftbukkit_vgbin.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java:814) [craftbukkit_vgbin.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.PacketPlayInChat.a(PacketPlayInChat.java:28) [craftbukkit_vgbin.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.PacketPlayInChat.handle(PacketPlayInChat.java:47) [craftbukkit_vgbin.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146) [craftbukkit_vgbin.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    yes includes me and the error has appeared, I have done reply to Knaxel with error.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  12. Offline

    Rocoty

    Make sure your plugin.yml does not contain tabs, and all indents are done with either two or four spaces. Also make sure you have spelled everything right. If nothing works, post the plugin.yml here, in code tags.
     
  13. Offline

    TitanConfigs

    Guys already solved the problem, had the plugin.yml in the wrong place (inside the package), thanks for everything :)
     
Thread Status:
Not open for further replies.

Share This Page