-1

I have a problem with my java plugin. This is never i had before. Normal it went all good.

Here is the code:

package me.brian.CubeRanks;

import me.brian.CubeRanks.CubeRanks;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;


public class CubeRanks {

    public class CubeRanks extends JavaPlugin {

        public static CubeRanks plugin;
        public final Logger log = Logger.getLogger("Minecraft");
        public boolean enabled = false;
        public final PlayerListener pl = new PlayerListener(this);
        public final ArrayList<Player> OreHunterUsers = new ArrayList<Player>();
        public String cr = "[CubeRanks] ";


        @Override
        public void onEnable() {
            log.info(cr + "is now enabled.");   
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvents(pl, this);

        }

        @Override
        public void onDisable() {
            log.info(cr + "is now disabled.");
        }

        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            if(commandLabel.equalsIgnoreCase("CubeRanks")) {
                if(args.length==0) {
                    if(!enabled) {
                        enabled = true;
                        ((Player) sender).sendMessage(ChatColor.GREEN + cr + "is now enabled");
                    }
                    else {
                        enabled = false;
                        ((Player) sender).sendMessage(ChatColor.RED + cr + "is now disbaled");
                    }
                }
            }
            return false;
        }
    }
}

Can someone see whats wrong?

Whole Error Code:

Description Resource Path Location Type The nested type CubeRanks cannot hide an enclosing type CubeRanks.java /CubeRanks/src/me/brian/CubeRanks line 16 Java Problem

Photo of the error: This is the error

Jason C
  • 38,729
  • 14
  • 126
  • 182
BrianHGP
  • 1
  • 1

1 Answers1

0

You have a class enclosing a class of the same name. I'm not sure why you have that outer CubeRanks class, but either get rid of the outer one, or rename one of them.

public class CubeRanks { // remove or rename

    public class CubeRanks extends JavaPlugin { // or rename this
        ...
    }

}

Syntactically, the reason why you can't have an inner class that is the same name as its outer class is to remove the following ambiguity:

public class Ambiguous {
    public class Ambiguous {
        Ambiguous a; // <-- which type is Ambiguous referring to here?
    } 
}

You could argue that the most recent enclosing type name could take precedence, but then how would you refer to the outer type? While there are theoretically ways to design a language around all of that, it's easier to just disallow it.

Jason C
  • 38,729
  • 14
  • 126
  • 182