Java Code Examples for cn.nukkit.utils.ServerException

The following examples show how to use cn.nukkit.utils.ServerException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Jupiter   Source File: Server.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * コマンドを実行します。
 * @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;
}
 
Example 2
Source Project: Jupiter   Source File: PermissibleBase.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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);
    }
}
 
Example 3
Source Project: Jupiter   Source File: MetadataStore.java    License: GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 4
Source Project: Jupiter   Source File: Effect.java    License: GNU General Public License v3.0 5 votes vote down vote up
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");
    }
}
 
Example 5
Source Project: Jupiter   Source File: Potion.java    License: GNU General Public License v3.0 5 votes vote down vote up
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");
    }
}
 
Example 6
Source Project: Nukkit   Source File: PermissibleBase.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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);
    }
}
 
Example 7
Source Project: Nukkit   Source File: MetadataStore.java    License: GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 8
Source Project: Nukkit   Source File: Effect.java    License: GNU General Public License v3.0 5 votes vote down vote up
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");
    }
}
 
Example 9
Source Project: Nukkit   Source File: Potion.java    License: GNU General Public License v3.0 5 votes vote down vote up
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");
    }
}
 
Example 10
Source Project: Nukkit   Source File: PermissibleBase.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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);
    }
}
 
Example 11
Source Project: Nukkit   Source File: MetadataStore.java    License: GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 12
Source Project: Nukkit   Source File: Effect.java    License: GNU General Public License v3.0 5 votes vote down vote up
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");
    }
}
 
Example 13
Source Project: Nukkit   Source File: Potion.java    License: GNU General Public License v3.0 5 votes vote down vote up
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");
    }
}
 
Example 14
Source Project: Jupiter   Source File: Attribute.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static Attribute getAttribute(int id) {
    if (attributes.containsKey(id)) {
        return attributes.get(id).clone();
    }
    throw new ServerException("Attribute id: " + id + " not found");
}
 
Example 15
Source Project: Nukkit   Source File: Attribute.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static Attribute getAttribute(int id) {
    if (attributes.containsKey(id)) {
        return attributes.get(id).clone();
    }
    throw new ServerException("Attribute id: " + id + " not found");
}
 
Example 16
Source Project: Nukkit   Source File: Attribute.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static Attribute getAttribute(int id) {
    if (attributes.containsKey(id)) {
        return attributes.get(id).clone();
    }
    throw new ServerException("Attribute id: " + id + " not found");
}