cn.nukkit.utils.ServerException Java Examples

The following examples show how to use cn.nukkit.utils.ServerException. 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 File: Server.java    From Jupiter with 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 File: PermissibleBase.java    From Jupiter with 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 File: MetadataStore.java    From Jupiter with 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 File: Effect.java    From Jupiter with 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 File: Potion.java    From Jupiter with 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 File: PermissibleBase.java    From Nukkit with 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 File: MetadataStore.java    From Nukkit with 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 File: Effect.java    From Nukkit with 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 File: Potion.java    From Nukkit with 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 File: PermissibleBase.java    From Nukkit with 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 File: MetadataStore.java    From Nukkit with 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 File: Effect.java    From Nukkit with 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 File: Potion.java    From Nukkit with 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 File: Attribute.java    From Jupiter with 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 File: Attribute.java    From Nukkit with 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 File: Attribute.java    From Nukkit with 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");
}