Search in sources :

Example 6 with Plugin

use of cn.nukkit.plugin.Plugin in project Nukkit by Nukkit.

the class MetadataStore method setMetadata.

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);
}
Also used : ServerException(cn.nukkit.utils.ServerException) PluginException(cn.nukkit.utils.PluginException) Plugin(cn.nukkit.plugin.Plugin)

Example 7 with Plugin

use of cn.nukkit.plugin.Plugin in project Nukkit by Nukkit.

the class PluginsCommand method sendPluginList.

private void sendPluginList(CommandSender sender) {
    String list = "";
    Map<String, Plugin> plugins = sender.getServer().getPluginManager().getPlugins();
    for (Plugin plugin : plugins.values()) {
        if (list.length() > 0) {
            list += TextFormat.WHITE + ", ";
        }
        list += plugin.isEnabled() ? TextFormat.GREEN : TextFormat.RED;
        list += plugin.getDescription().getFullName();
    }
    sender.sendMessage(new TranslationContainer("nukkit.command.plugins.success", new String[] { String.valueOf(plugins.size()), list }));
}
Also used : TranslationContainer(cn.nukkit.lang.TranslationContainer) Plugin(cn.nukkit.plugin.Plugin)

Aggregations

Plugin (cn.nukkit.plugin.Plugin)7 TranslationContainer (cn.nukkit.lang.TranslationContainer)3 PluginDescription (cn.nukkit.plugin.PluginDescription)3 IOException (java.io.IOException)3 Type (cn.nukkit.AdventureSettings.Type)1 Player (cn.nukkit.Player)1 Server (cn.nukkit.Server)1 cn.nukkit.block (cn.nukkit.block)1 BlockEntity (cn.nukkit.blockentity.BlockEntity)1 BlockEntityItemFrame (cn.nukkit.blockentity.BlockEntityItemFrame)1 BlockEntitySpawnable (cn.nukkit.blockentity.BlockEntitySpawnable)1 Command (cn.nukkit.command.Command)1 CommandSender (cn.nukkit.command.CommandSender)1 CommandDataVersions (cn.nukkit.command.data.CommandDataVersions)1 cn.nukkit.entity (cn.nukkit.entity)1 cn.nukkit.entity.data (cn.nukkit.entity.data)1 cn.nukkit.entity.item (cn.nukkit.entity.item)1 EntityArrow (cn.nukkit.entity.projectile.EntityArrow)1 ItemFrameDropItemEvent (cn.nukkit.event.block.ItemFrameDropItemEvent)1 EntityDamageByBlockEvent (cn.nukkit.event.entity.EntityDamageByBlockEvent)1