本文整理汇总了Java中cn.nukkit.event.server.ServerCommandEvent类的典型用法代码示例。如果您正苦于以下问题:Java ServerCommandEvent类的具体用法?Java ServerCommandEvent怎么用?Java ServerCommandEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServerCommandEvent类属于cn.nukkit.event.server包,在下文中一共展示了ServerCommandEvent类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEnable
import cn.nukkit.event.server.ServerCommandEvent; //导入依赖的package包/类
@Override
public void onEnable() {
if (getConfig().getAll().isEmpty()) {
try {
getServer().getPluginManager().registerEvent(ServerCommandEvent.class, this, EventPriority.HIGHEST,
new MethodEventExecutor(this.getClass().getDeclaredMethod("chooseLanguage", ServerCommandEvent.class)), this);
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
this.getLogger().notice("欢迎使用本经济插件, 请选择语言: (输入 3 次错误自动选择中文)");
this.getLogger().notice(
"Hello. Please choose a language: (It will choose Chinese Simplified automatically when inputting error 3 times)");
this.getLogger().info(TextFormat.AQUA + "chs: 简体中文");
this.getLogger().info(TextFormat.AQUA + "cht: 繁體中文");
this.getLogger().info(TextFormat.AQUA + "eng: English\n");
chooseLanguage(new ServerCommandEvent(null, ""));
} else {
init();
}
}
示例2: onServerCommandEvent
import cn.nukkit.event.server.ServerCommandEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onServerCommandEvent(ServerCommandEvent event){
String command = event.getCommand();
if(command.startsWith(".")){
event.setCancelled();
Server.getInstance().broadcastMessage(PraterConsole.getFormat().replace("{%0}", command.substring(1, command.length())));
}
}
示例3: chooseLanguage
import cn.nukkit.event.server.ServerCommandEvent; //导入依赖的package包/类
@SuppressWarnings("WeakerAccess")
public void chooseLanguage(ServerCommandEvent event) {
if (getConfig().getAll().isEmpty()) {
event.setCancelled();
String language;
if (errorTimes == 3) {
language = "chs";
this.getLogger().info(TextFormat.GREEN + "输入3次无效. 将使用默认设置");
this.getLogger().notice("已使用 [简体中文] 作为默认语言.");
} else {
switch (event.getCommand()) {
case "":
return;
case "chs":
this.getLogger().notice("已使用 [简体中文] 作为默认语言.");
language = "chs";
break;
case "eng":
this.getLogger().notice("Have chosen [English] as the default language.");
language = "eng";
break;
case "cht":
this.getLogger().notice("已使用 [繁體中文] 作為默認語言.");
language = "cht";
break;
default:
this.getLogger().notice("欢迎使用本经济插件, 请选择语言: (输入 3 次错误自动选择中文)");
this.getLogger().notice(
"Hello. Please choose a language: (It will choose Chinese Simplified automatically when inputting error 3 times)");
this.getLogger().info(TextFormat.AQUA + "chs: 简体中文");
this.getLogger().info(TextFormat.AQUA + "cht: 繁體中文");
this.getLogger().info(TextFormat.AQUA + "eng: English\n");
errorTimes++;
return;
}
}
saveResource("Language_" + language + ".properties", "Language.properties", true);
saveResource("Config_" + language + ".yml", "Config.yml", true);
saveResource("Commands_" + language + ".yml", "Commands.yml", true);
init();
}
}
示例4: onServerCommandEvent
import cn.nukkit.event.server.ServerCommandEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onServerCommandEvent(ServerCommandEvent event){
if(event.getCommand().toLowerCase().startsWith("save-all")){
this.saveAll((CommandSender) event.getSender());
}
}