First plugin not working Help!

Discussion in 'Plugin Development' started by militiaspack, Dec 8, 2013.

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


    So i have this code. I followed the plugin tutorial and Im trying to make a plugin so people can hide from another person. I know i am probably doing this completely wrong so help D:

    package io.github.militiaspack.Murderfun;

    import javax.persistence.Entity;

    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.entity.TNTPrimed;
    import org.bukkit.event.entity.ExplosionPrimeEvent;

    public final class Main extends JavaPlugin {

    public void onEnable(){
    getLogger().info("Hide has been enabled!");

    public void onDisable(){
    getLogger().info("Hide has been disabled!");

    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if(cmd.getName().equalsIgnoreCase("Hide") && args.length == 1) {
    if (!(sender instanceof Player)) {
    sender.sendMessage("Only players can use this command!");
    return true;

    Player s = (Player) sender;

    Player target = Bukkit.getServer().getPlayer(args[0]);
    if (target == null) {
    sender.sendMessage("Player " + args[0] + " is not online.");
    return true;

    return true;
    return false;

  2. Offline


    Are you getting any errors? If not, add a Bukkit.broadcastmessage("Step #") before and after every if and see which ones fire and which ones don't.
  3. what lordpyrak said. This seems like it should work
  4. Offline


  5. Offline



    Okay few things wrong. So some of the stuff I did was formatting and basically so I could understand the code, BUT there were some changes I made.

    I personally don't think you need to define the return statements every time, because if you did the command wrong it will send the message automatically.
    The reason the plugin probably wasn't working was because you didn't initialize the command which you must do in the onEnable(), so I did that.
    You had the if statements for the sender but in the end everything would be executed anyways, so I changed that and put it in an else statement. I also added comments so you can understand everything, which you should probably do as well.
    You had many unused imports so I fixed that. (I recommend using eclipse to code).
    Also, I added color to make it fun c:
    I did not test it. Haha. Message me if you have any problems.

    The source for your plugin is here:
  6. Offline


    Worked thanks! Also I had to fix my plugin.yml
Thread Status:
Not open for further replies.

Share This Page