Skip to content

Instantly share code, notes, and snippets.

@keepoff07
Last active April 1, 2019 22:09
Show Gist options
  • Save keepoff07/23b80cc5cd695f73282b to your computer and use it in GitHub Desktop.
Save keepoff07/23b80cc5cd695f73282b to your computer and use it in GitHub Desktop.
ymlを必要としないコマンドの登録
try {
Constructor<?> cs = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class);
cs.setAccessible(true);
PluginCommand cmd = (PluginCommand)cs.newInstance("setblock", this);
cmd.setDescription("This is command description.");
cmd.setUsage("/<command> <x> <y> <z> <TileName> [dataValue] [dataTag]");
cmd.setPermission("minecraft.command.setblock");
cmd.setPermissionMessage("I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error.");
cmd.setExecutor(new CommandExecutor() {
@Override
public boolean onCommand(CommandSender arg0, Command arg1, String arg2, String[] arg3) {
// TODO 自動生成されたメソッド・スタブ
return false;
}
});
cmd.setTabCompleter(new TabCompleter() {
@Override
public List<String> onTabComplete(CommandSender arg0, Command arg1, String arg2, String[] arg3) {
// TODO 自動生成されたメソッド・スタブ
return null;
}
});
//this "minecraft" is command prefix.
((CraftServer)getServer()).getCommandMap().register("minecraft", cmd);
} catch (Throwable e) {
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment