当前位置: 首页>>代码示例>>Java>>正文


Java ServerException类代码示例

本文整理汇总了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;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:26,代码来源:Server.java

示例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);
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:17,代码来源:MetadataStore.java

示例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);
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:9,代码来源:PermissibleBase.java

示例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);
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:13,代码来源:MetadataStore.java

示例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");
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:8,代码来源:Effect.java

示例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");
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:8,代码来源:Potion.java

示例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);
	}
}
 
开发者ID:rutgerkok,项目名称:Pokkit,代码行数:9,代码来源:PokkitPotionEffectType.java

示例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");
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:7,代码来源:Attribute.java


注:本文中的cn.nukkit.utils.ServerException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。