本文整理汇总了Java中cn.nukkit.utils.ServerException类的典型用法代码示例。如果您正苦于以下问题:Java ServerException类的具体用法?Java ServerException怎么用?Java ServerException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServerException类属于cn.nukkit.utils包,在下文中一共展示了ServerException类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispatchCommand
import cn.nukkit.utils.ServerException; //导入依赖的package包/类
/**
* コマンドを実行します。
* @param sender 対象のCommandSender
* @param commandLine 送るパケット
* @return boolean trueが完了/falseが失敗
*/
public boolean dispatchCommand(CommandSender sender, String commandLine) throws ServerException {
// First we need to check if this command is on the main thread or not, if not, warn the user
if (!this.isPrimaryThread()) {
getLogger().warning("Command Dispatched Async: " + commandLine);
getLogger().warning("Please notify author of plugin causing this execution to fix this bug!", new Throwable());
// TODO: We should sync the command to the main thread too!
}
if (sender == null) {
throw new ServerException("CommandSender is not valid");
}
if (this.commandMap.dispatch(sender, commandLine)) {
return true;
}
sender.sendMessage(TextFormat.RED + this.getLanguage().translateString("commands.generic.notFound"));
return false;
}
示例2: setMetadata
import cn.nukkit.utils.ServerException; //导入依赖的package包/类
public void setMetadata(Object subject, String metadataKey, MetadataValue newMetadataValue) {
if (newMetadataValue == null) {
throw new ServerException("Value cannot be null");
}
Plugin owningPlugin = newMetadataValue.getOwningPlugin();
if (owningPlugin == null) {
throw new PluginException("Plugin cannot be null");
}
String key = this.disambiguate((Metadatable) subject, metadataKey);
Map<Plugin, MetadataValue> entry = this.metadataMap.get(key);
if (entry == null) {
entry = new WeakHashMap<>(1);
this.metadataMap.put(key, entry);
}
entry.put(owningPlugin, newMetadataValue);
}
示例3: setOp
import cn.nukkit.utils.ServerException; //导入依赖的package包/类
@Override
public void setOp(boolean value) {
if (this.opable == null) {
throw new ServerException("Cannot change op value as no ServerOperator is set");
} else {
this.opable.setOp(value);
}
}
示例4: setMetadata
import cn.nukkit.utils.ServerException; //导入依赖的package包/类
public void setMetadata(Object subject, String metadataKey, MetadataValue newMetadataValue) {
if (newMetadataValue == null) {
throw new ServerException("Value cannot be null");
}
Plugin owningPlugin = newMetadataValue.getOwningPlugin();
if (owningPlugin == null) {
throw new PluginException("Plugin cannot be null");
}
String key = this.disambiguate((Metadatable) subject, metadataKey);
Map<Plugin, MetadataValue> entry = this.metadataMap.computeIfAbsent(key, k -> new WeakHashMap<>(1));
entry.put(owningPlugin, newMetadataValue);
}
示例5: getEffect
import cn.nukkit.utils.ServerException; //导入依赖的package包/类
public static Effect getEffect(int id) {
if (id >= 0 && id < effects.length && effects[id] != null) {
return effects[id].clone();
} else {
throw new ServerException("Effect id: " + id + " not found");
}
}
示例6: getPotion
import cn.nukkit.utils.ServerException; //导入依赖的package包/类
public static Potion getPotion(int id) {
if (id >= 0 && id < potions.length && potions[id] != null) {
return potions[id].clone();
} else {
throw new ServerException("Effect id: " + id + " not found");
}
}
示例7: toNukkit
import cn.nukkit.utils.ServerException; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public static Effect toNukkit(PotionEffectType type) {
try {
return Effect.getEffect(type.getId());
} catch (ServerException e) {
return new Effect(type.getId(), "bukkit_" + type.getId(), 9, 0, 0);
}
}
示例8: getAttribute
import cn.nukkit.utils.ServerException; //导入依赖的package包/类
public static Attribute getAttribute(int id) {
if (attributes.containsKey(id)) {
return attributes.get(id).clone();
}
throw new ServerException("Attribute id: " + id + " not found");
}