Server not recognizing plugin

Discussion in 'Plugin Development' started by MinecraftZach443, Oct 9, 2013.

Thread Status:
Not open for further replies.
  1. Ok, so I am making a plugin for my server and after I added the first command I tried to test it out. Well my server will not recognize my plugin.

    Here is the class for the Fly Command:
    Code:java
    1. package me.zach.Plugin.commands;
    2.  
    3. import java.util.HashSet;
    4. import me.zach.Plugin.Plugin;
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.Player;
    8.  
    9. public class CommandFly extends Plugin {
    10. public CommandFly(Plugin plugin) {
    11. super();
    12. }
    13.  
    14. public HashSet<String> flymode = new HashSet<String>();
    15.  
    16. public boolean execute(CommandSender sender, String[] args) {
    17. if (sender instanceof Player) {
    18. Player player = (Player) sender;
    19. if (args.length == 0) {
    20. if (player.hasPermission("perm.fly")) {
    21. player.setAllowFlight(true);
    22. if (flymode.contains(player.getName())) {
    23. player.setAllowFlight(false);
    24. player.setFlying(false);
    25. flymode.remove(player.getName());
    26. } else {
    27. flymode.add(player.getName());
    28. player.setFlying(true);
    29. }
    30. player.sendMessage(ChatColor.GREEN + "You now have flymode " + (flymode.contains(player.getName()) ? "enabled!" : "disabled."));
    31. } else {
    32. player.sendMessage(ChatColor.RED + "NO NO NO! NO FLY FOR YOU!");
    33. }
    34. } else {
    35. player.sendMessage(ChatColor.AQUA + "Usage: /fly");
    36. }
    37. } else {
    38. getLogger().info("You must be in-game to uset this commands");
    39. }
    40. return false;
    41. }
    42. }


    Here is the main class:
    Code:java
    1. package me.zach.Plugin;
    2.  
    3. import org.bukkit.plugin.java.JavaPlugin;
    4.  
    5.  
    6. public class Plugin extends JavaPlugin{
    7.  
    8. @Override
    9. public void onEnable() {
    10. getLogger().info("You have have set off the onEnable function!");
    11. }
    12. @Override
    13. public void onDisable() {
    14. getLogger().info("You have disabled my awesome plugin :'(");
    15. }
    16.  
    17. }


    Here is my 'plugin.yml' (I created it inside the project like folder):
    http://pastebin.com/NKAyAKXi

    Could you please tell me what I am doing wrong?
     
  2. Offline

    Axe2760

    Uhm... CommandFly has serious issues, where did you learn to do that ? It should implement CommandExecutor, and the executor should be set with getCommand(...).setExecutor(...); in the enable method.

    But "main" in the plugin.yml should be me.zach.Plugin.Plugin for it to even load.
     
  3. Axe2760

    I am trying to learn Java by looking at this guys code, here is the CommandsFly class that I copied:
    https://github.com/keybordpiano459/...Piano459/kEssentials/commands/CommandFly.java

    Ok, after I changed the plugin.yml my server recognizes the plugin, although when I use the command it just says "Usage: /fly". I think this has to do with what T3h Cr33p3r and Axe2760 said, although I don't really understand what they mean.

    How the heck do you do that?:confused:

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

    Mathias Eklund

    Learn some Java before you start with Bukkit.
     
  5. gee thanks, you're a big help -_-
     
  6. Offline

    PatrickH123

    This works:

    Code:java
    1. if(commandLabel.equalsIgnoreCase("fly")){
    2. Player p = (Player) sender;
    3. if(p.hasPermission("perm.fly")){
    4. if(p.isFlying() == false){
    5. p.setAllowFlight(true);
    6. p.setFlying(true);
    7. p.sendMessage(ChatColor.GREEN + "Fly has been enabled!");
    8. return false;
    9. }
    10. if(p.isFlying() == true){
    11. p.setAllowFlight(false);
    12. p.setFlying(false);
    13. p.sendMessage(ChatColor.GREEN + "Fly has been disabled!");
    14. return false;
    15. }
    16. }
    17. p.sendMessage(ChatColor.RED + "NO NO NO! NO FLY FOR YOU!");
    18. return true;
    19. }
     
  7. Offline

    Garris0n

    You can't learn a programming language by copy-pasting somebody's code and editing the messages without having any idea what it does. Watch java tutorials, learn the language, and when you're done and understand the basics of Java and object-oriented programming watch some bukkit tutorials and you'll be just fine.
     
  8. Offline

    Goblom

    MinecraftZach443 That guy is using his own Command Manager... So, you would need that as well if you are planning to try to use his commands in your code
     
Thread Status:
Not open for further replies.

Share This Page