xtrontross xtrontross - 1 year ago 149
Java Question

Bukkit plugin Syntax error, multiple classes

i'm trying to create plugin with multiple classes, but when I type the command in Minecraft, it shows me command syntax error msg (Syntax error! Simply type /ct create.). I think it is silly misstake somewhere, but i can't find it.

My core.java:

public class Core extends JavaPlugin {

public ArrayList<Block> chests = new ArrayList<>();

public boolean createMode = false;

public void onEnabled() {
getCommand("ct").setExecutor(new Commands(this));
getServer().getPluginManager().registerEvents(new Listeners(this), this);

My Commands.java:

public class Commands implements CommandExecutor {

private Core plugin;

public Commands(Core core) {
this.plugin = core;

public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("ct")) {
if(args.length > 0) {
if(args[0].equalsIgnoreCase("create")) {
plugin.createMode = true;
sender.sendMessage(ChatColor.GOLD + "[ChestTreasure] " + ChatColor.RESET + "Now rightclick the chest");
} else {
sender.sendMessage(ChatColor.GOLD + "[ChestTreasure] " + ChatColor.RESET + "Too few arguments!");
return false;


My plugin.yml:

name: ChestTreasure
description: this plugin...
main: me.sudoman281.chestTreasure.Core
version: 1.0
author: sudoman281

description: ...
permission: ct.create
usage: Syntax error! Simply type /ct create.

Answer Source

You have to correctly override the method by having the same exact name and method signature/return type. To do this you must do the following:

  1. Your onEnabled method should be onEnable per the Bukkit API
  2. You should always use the @Override annotation to signify that you are overriding a superclass method. (Optional but highly recommended for finding errors and convention. It will work without this)

Your onEnable should look like this:

public void onEnable() {
    /* Do stuff when plugin starts */
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download