1.11.2 My first plugin dont work

Discussion in 'Spigot Plugin Development' started by miguelrebolo, Jul 19, 2020.

  1. Hello i make my first plugin with eclipse when i start the server console spawn spawn error with main class i know the problems but i dont know the correct syntax.Can you help me?. I dont have good java knowledge i started today with java world.
    CLASS 1
    Code (Java):
    package me.miguel.Comando;
    import org.bukkit.plugin.java.JavaPlugin;

    import me.miguel.Comando.comands.Guapo;

    public class Main extends JavaPlugin {
        public void onEnable() {
            new Guapo(this);
    CLASS 2
    Code (Java):
    package me.miguel.Comando.comands;

    import me.miguel.Comando.*;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;

    public class Guapo implements CommandExecutor {
        private main plugin;
        public Guapo(main plugin){
            this.plugin = plugin;
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (!(sender instanceof Player)){
                sender.sendMessage("Only player can execute this command");
                return true;
                Player p - (Player) sender;
                if (p.hasPermission("guapo.use")) {
                    return true;  
                } else {
                   p.sendMessage("You dont have perms sir");  
                return false;
    Errors with lines
    - private main plugin
    - public Guapo(main plugin)
    - this.plugin = plugin;
    - Player p - (Player) sender;
    Error message: main cannot resolve to a type and syntax error "p"
    Image with error:

    yml config:
    name: Comando
    version: 1.0
    author: Miguel
    main: me.miguel.Comando.Main
    description: My first plugin!

    aliases: [cool]
    description: Say hello
  2. Your ide will have errors in it, why have you even compiled this code? Fix the errors that the ide will identify for you.

    The error literally tells you what's wrong, if you read it.

    I highly suggest not making a plugin before you even know the basics of java.
    • Agree Agree x 1
  3. Main should be capital in the second class
  4. Thanks but whats wrong with p?
  5. You used a dash instead of an equal sign.
  6. In Main
    Code (Java):
    public void onEnable() {
        getCommand(commandName).setExecutor(new Guapo(this));

    In Guapo:
    Code (Java):
     private Main plugin;
        public Guapo(Main plugin){
            this.plugin = plugin;
    Other things like people said you have made a mistake your IDE will show.
    Code (Java):
    Player p - (Player) sender;
    should be:
    Code (Java):
    Player p = (Player) sender;
    Also why aren't you doing this in your onCommand method?
    Code (Java):
    if (cmd.getName().equalsIgnoreCase(commandName) {
        // stuff here
    You should learn java properly before starting.
  7. Ditto literally what everyone has said. Please learn java before diving into the spigot api. I know its very tempting to want to make cool plugins and show off to your friends or create something that everyone will want to use. But its a lot of work and skill thats required to create something that wont have a server shitting bricks (excuse my french). The IDE will flag errors usually by a red or yellow underline in your code you should lok at what it tells you as about 85% of the time it will be extremely helpful in telling you exactly what to do...
    Also click the link in my signature to learn how to read stack traces so you can actually read the errors that your plugin spits out...
  8. I cant find link with action like ItemMeta. Can you share with me?
  9. Oh ty i tell you my final result.
    • Useful Useful x 1
  10. Thats all variables?
  11. Uh, what are you confused on?
  12. Sir im new in java world can you recommend me one good youtuber or easy plugin to make?
  13. @miguelrebolo Don't learn java from youtube please... theres too many bad youtube videos or videos out there which have horrible coding practices... take a course on java from someone who actually knows what they are teaching. Use google, stackoverflow and github to learn how to use different methods and implemenetations of java and ask questions about java on stack overflow. Java was not made for spigot plugins... spigot plugins are made in java. That seems to be a point thats lost on many people today...