Solved Plugin is not working.

Discussion in 'Spigot Help' started by Vytska111, Jun 12, 2018.

  1. Hello. I need some help with my plugin.
    Heres the Main.java code:

    Code (Text):
    package net.LTUWorld.test;

    import java.util.HashMap;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockIgniteEvent;
    import org.bukkit.event.player.PlayerChangedWorldEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scoreboard.DisplaySlot;
    import org.bukkit.scoreboard.Objective;
    import org.bukkit.scoreboard.Score;
    import org.bukkit.scoreboard.ScoreboardManager;

    import net.minecraft.server.v1_8_R3.Scoreboard;

    public class Main extends JavaPlugin implements Listener,CommandExecutor{
     
        public boolean gameStarted = false;
     
        public void OnEnable() {
         
            getCommand("test").setExecutor(this);
            getServer().getPluginManager().registerEvents(this, this);
         
            getServer().getLogger().info("[test] Enabled Succsessfully!");
        }
     
        public void OnDisable() {
            getServer().getLogger().info("[test] Disabled Succsessfully!");
        }
    @Override
        public boolean onCommand(CommandSender sender, Command command, String label,String[] args) {
            if(command.getName().equalsIgnoreCase("test")) {
             
                sender.sendMessage("test");
             
            }
            return true;
        }
    And here's my plugin.yml:

    Code (Text):
    name: test
    version: 1.0
    author: VytskaLT
    main: net.LTUWorld.test.Main

    commands:
      aw:
        description: test
        permission: ltuworld.testcmd
    And here's the output:

    Code (Text):
    [10:09:22] [Server thread/INFO]: [test] Loading test v1.0
    [10:09:24] [Server thread/INFO]: [test] Enabling test v1.0
    Well it doesn't show the "[test] Enabled Succsessfully!" and "[test] Disabled Succsessfully!" and no commands or listeners are working.

    Could someone help me?
     
  2. Method names are case sensitive and you wrote OnEnable/OnDisable instead of onEnable/onDisable. Methods in Java are generally always in lowerCamelCase.
     
    • Agree Agree x 3
  3. Your only command registered is "aw", but it does nothing and has no code. Change your plugin.yml to register the command "test" or change it to "aw" in your code.
     
    • Agree Agree x 1
  4. Thanks for the reply, but nothing changes.
     
  5. I did it. But it says "An internal error occurred while attempting to perform this command"
     
  6. Probably because you have the permission set to an unregistered permission. Your config should look like this:
    Code (Text):
    name: (plugin name)
    version: (version)
    author: (you)
    main: (main class)
    commands:
      command1:
        ...
    permissions:
      test.permission:
        default: (op/true/false)
        # default: op = only op has it by default (the normal default)
        # default: true = all players have it by default
        # default: false = nobody has it by default
     
  7. YES! Thank you so much. I was trying to find the mistake for a day.