Solved I Can't Export My Plugin.java

Discussion in 'Plugin Development' started by MCPlaysMC Productions, Jan 9, 2015.

Thread Status:
Not open for further replies.
    • I Can't Export My Plugin.java. It says changes need to be modified with plugin.java before exporting.
    • "import org.bukkit.plugin.java.JavaPlugin;" That number: 3 is coming up pinkish / highlighted and when i focus on it is says "public class Plugin {" Help me please
     
  1. Offline

    Ganga

    could you please post your Plugin.java?
    Have you implemented JavaPlugin in the main class?
     
  2. Code:
    package com.youtube.www;
    
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.command.ConsoleCommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Plugin extends JavaPlugin {
    
        public static Plugin plugin;
    
        @Override
        public void onEnable() {
            plugin = this;
        }
    
        @Override
        public void onDisable() {
        }
    
        public static Plugin getPlugin() {
            return plugin;
        }
    
        @Override
        public boolean onCommand(CommandSender cs, Command cmd, String label,
                String[] args) {
    
            if (cmd.getName().equalsIgnoreCase("Hello"))
                if (cs instanceof Player) {
                    Player player = (Player) cs;
                    player.sendMessage(ChatColor.GREEN + "Hello, "
                            + player.getName() + " How are you?");
                } else if (cs instanceof ConsoleCommandSender) {
                    cs.sendMessage(ChatColor.GREEN + "Hello Console, "
                            + player.getName() + " How are you?");
    
                }
    
            return false;
        }
    }
     
    Last edited by a moderator: Jan 9, 2015
  3. Offline

    1Rogue

    You're trying to get the player name in the branch under ConsoleCommandSender, remove that bit. (Also, make your "public static Plugin plugin" private or protected).
     
  4. It still says i can't export. The imports on line 3 - the number 3 is highlighted
     
  5. Offline

    timtower Administrator Administrator Moderator

    @MCPlaysMC Productions Hover your mouse over the error line, hit f2, copy all, paste here.
    Or just go into the errors tab and copy it from there.
     
  6. Offline

    MisterErwin

  7. You can compile the plugin ? maybe is just a visual bug ... i have some ones in my code .
     
  8. Offline

    1Rogue

    Make sure you've added Bukkit as a dependency.
     
  9. 3 (+) import org.bukkit.ChatColor;

    Never Mind It Works :D

    Ohh my /hi doesn't work d; It's just blank
     
    Last edited by a moderator: Jan 9, 2015
  10. Offline

    stoneminer02

    Well, the command is /hello soo..
    That may work a bit better?
    Also:
    public static Plugin getPlugin() {
    return plugin;
    }
    1. No static needed
    2. Use org.bukkit.Plugin or something like that if you are meaning to cast it to bukkit's type.
     
    ChipDev likes this.
  11. Offline

    1Rogue

    static would be needed in that case if he is providing a static accessor method for his class instance (which he implemented correctly). Also his main class is named Plugin, which while is a bit conflicting with bukkit's own class, isn't incorrect.
     
  12. Offline

    ChipDev

    Thats useful!
    Also, don't make a plugin inside of the JavaPlugin, use the main instance for non NPE'S
     
  13. Offline

    stoneminer02

    Wow.. I'm drunk.
    I was thinking it should of return the Plugin(org.bukkit version).
     
  14. */hello* Also I've forgot to change the class (It's the same) on my other plugin so this is useless
     
Thread Status:
Not open for further replies.

Share This Page