1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Do this is correct?//Esta correcto?

Discussion in 'Plugins/Codes' started by A Christmas Hangar, Nov 27, 2015.

  1. A Christmas Hangar

    A Christmas Hangar Member

    Joined:
    Sep 15, 2015
    Messages:
    2,545
    Likes Received:
    1,492
    Trophy Points:
    113
    Gender:
    Male
    Location:
    Kepler452B
    Home Page:
    Hi! I'm aking a plugin....
    package mjs.minecraft.plugin.hello;

    import java.util.logging.Logger;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;

    public class HelloPlugin extends JavaPlugin {

    public static final Logger log = Logger.getLogger("Minecraft");

    @Override
    public void onDisable() {
    PluginManager pluginManager = getServer().getPluginManager();
    log.info("Hello plugin has been disabled.");
    }

    @Override
    public void onEnable() {
    log.info("Plugin has been enabled!");
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command,
    String label, String[] args) {

    if(label.equals("hello")) {
    Player player = (Player) sender;
    player.sendMessage("Hello " + player.getDisplayName());
    return true;
    }

    return false;
    }
    }
    name: MHello
    main: mjs.minecraft.plugin.hello.HelloPlugin
    version: 0.1
    author: Hangar555
    website:
    description: Example command to say hello to the user

    commands:
    hello:
    description: Say hello to the user.
    usage: /hi
     
  2. DanOF

    DanOF Member

    Joined:
    Aug 20, 2015
    Messages:
    335
    Likes Received:
    230
    Trophy Points:
    43
    Gender:
    Male
    Location:
    New Jersey, USA
    Home Page:
    • Change "label.equals" to "command.getName().equalsIgnoreCase"
    • Remove the website from the yml because you're not using.
    • Change the logger to "this.getLogger()"
    • In onEnable put "this.getCommand("hello").setExecutor(this::eek:nCommand);" (if you're running Java 8)
    • Add "if(sender instanceof Player)" where you create the player
     
  3. Mattuki

    Mattuki Member

    Joined:
    Mar 21, 2015
    Messages:
    451
    Likes Received:
    153
    Trophy Points:
    43
    Gender:
    Male
    can you explain us ? plsssssss
     
  4. DanOF

    DanOF Member

    Joined:
    Aug 20, 2015
    Messages:
    335
    Likes Received:
    230
    Trophy Points:
    43
    Gender:
    Male
    Location:
    New Jersey, USA
    Home Page:
    where it has the ":eek:" it should be this:: onCommand without the space between the : and the o
     
  5. A Christmas Hangar

    A Christmas Hangar Member

    Joined:
    Sep 15, 2015
    Messages:
    2,545
    Likes Received:
    1,492
    Trophy Points:
    113
    Gender:
    Male
    Location:
    Kepler452B
    Home Page: