本文整理汇总了Java中cn.nukkit.plugin.Plugin类的典型用法代码示例。如果您正苦于以下问题:Java Plugin类的具体用法?Java Plugin怎么用?Java Plugin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Plugin类属于cn.nukkit.plugin包,在下文中一共展示了Plugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: QueryRegenerateEvent
import cn.nukkit.plugin.Plugin; //导入依赖的package包/类
public QueryRegenerateEvent(Server server, int timeout) {
this.timeout = timeout;
this.serverName = server.getMotd();
this.listPlugins = (boolean) server.getConfig("settings.query-plugins", true);
this.plugins = server.getPluginManager().getPlugins().values().toArray(new Plugin[server.getPluginManager().getPlugins().values().size()]);
List<Player> players = new ArrayList<>();
for (Player player : server.getOnlinePlayers().values()) {
if (player.isOnline()) {
players.add(player);
}
}
this.players = players.toArray(new Player[players.size()]);
this.gameType = (server.getDefaultGamemode() & 0x01) == 0 ? "SMP" : "CMP";
this.version = server.getVersion();
this.server_engine = server.getName() + " " + server.getNukkitVersion();
this.map = server.getDefaultLevel() == null ? "unknown" : server.getDefaultLevel().getName();
this.numPlayers = this.players.length;
this.maxPlayers = server.getMaxPlayers();
this.whitelist = server.hasWhitelist() ? "on" : "off";
this.port = server.getPort();
this.ip = server.getIp();
}
示例2: cancelTask
import cn.nukkit.plugin.Plugin; //导入依赖的package包/类
public void cancelTask(Plugin plugin) {
if (plugin == null) {
throw new NullPointerException("Plugin cannot be null!");
}
for (Map.Entry<Integer, TaskHandler> entry : taskMap.entrySet()) {
TaskHandler taskHandler = entry.getValue();
// TODO: Remove the "taskHandler.getPlugin() == null" check
// It is only there for backwards compatibility!
if (taskHandler.getPlugin() == null || plugin.equals(taskHandler.getPlugin())) {
try {
taskHandler.cancel(); /* It will remove from task map automatic in next main heartbeat. */
} catch (RuntimeException ex) {
Server.getInstance().getLogger().critical("Exception while invoking onCancel", ex);
}
}
}
}
示例3: addTask
import cn.nukkit.plugin.Plugin; //导入依赖的package包/类
private TaskHandler addTask(Plugin plugin, Runnable task, int delay, int period, boolean asynchronous) {
if (plugin != null && plugin.isDisabled()) {
throw new PluginException("Plugin '" + plugin.getName() + "' attempted to register a task while disabled.");
}
if (delay < 0 || period < 0) {
throw new PluginException("Attempted to register a task with negative delay or period.");
}
TaskHandler taskHandler = new TaskHandler(plugin, task, nextTaskId(), asynchronous);
taskHandler.setDelay(delay);
taskHandler.setPeriod(period);
taskHandler.setNextRunTick(taskHandler.isDelayed() ? currentTick + taskHandler.getDelay() : currentTick);
if (task instanceof Task) {
((Task) task).setHandler(taskHandler);
}
pending.offer(taskHandler);
taskMap.put(taskHandler.getTaskId(), taskHandler);
return taskHandler;
}
示例4: getRegisteredListeners
import cn.nukkit.plugin.Plugin; //导入依赖的package包/类
public static ArrayList<RegisteredListener> getRegisteredListeners(Plugin plugin) {
ArrayList<RegisteredListener> listeners = new ArrayList<>();
synchronized (allLists) {
for (HandlerList h : allLists) {
synchronized (h) {
for (List<RegisteredListener> list : h.handlerslots.values()) {
for (RegisteredListener listener : list) {
if (listener.getPlugin().equals(plugin)) {
listeners.add(listener);
}
}
}
}
}
}
return listeners;
}
示例5: addAttachment
import cn.nukkit.plugin.Plugin; //导入依赖的package包/类
@Override
public PermissionAttachment addAttachment(Plugin plugin, String name, Boolean value) {
if (plugin == null) {
throw new PluginException("Plugin cannot be null");
} else if (!plugin.isEnabled()) {
throw new PluginException("Plugin " + plugin.getDescription().getName() + " is disabled");
}
PermissionAttachment result = new PermissionAttachment(plugin, this.parent != null ? this.parent : this);
this.attachments.add(result);
if (name != null && value != null) {
result.setPermission(name, value);
}
this.recalculatePermissions();
return result;
}
示例6: QueryRegenerateEvent
import cn.nukkit.plugin.Plugin; //导入依赖的package包/类
public QueryRegenerateEvent(Server server, int timeout) {
this.timeout = timeout;
this.serverName = server.getMotd();
this.listPlugins = (boolean) server.getConfig("settings.query-plugins", true);
this.plugins = server.getPluginManager().getPlugins().values().toArray(new Plugin[server.getPluginManager().getPlugins().values().size()]);
List<Player> players = new ArrayList<>();
for (Player player : server.getOnlinePlayers().values()) {
if (player.isOnline()) {
players.add(player);
}
}
this.players = players.toArray(new Player[players.size()]);
this.gameType = (server.getGamemode() & 0x01) == 0 ? "SMP" : "CMP";
this.version = server.getVersion();
this.server_engine = server.getName() + " " + server.getNukkitVersion();
this.map = server.getDefaultLevel() == null ? "unknown" : server.getDefaultLevel().getName();
this.numPlayers = this.players.length;
this.maxPlayers = server.getMaxPlayers();
this.whitelist = server.hasWhitelist() ? "on" : "off";
this.port = server.getPort();
this.ip = server.getIp();
}
示例7: enablePlugins
import cn.nukkit.plugin.Plugin; //导入依赖的package包/类
public void enablePlugins(PluginLoadOrder type) {
for (Plugin plugin : new ArrayList<>(this.pluginManager.getPlugins().values())) {
if (!plugin.isEnabled() && type == plugin.getDescription().getOrder()) {
this.enablePlugin(plugin);
}
}
if (type == PluginLoadOrder.POSTWORLD) {
this.commandMap.registerServerAliases();
DefaultPermissions.registerCorePermissions();
}
}
示例8: removeMetadata
import cn.nukkit.plugin.Plugin; //导入依赖的package包/类
public void removeMetadata(Object subject, String metadataKey, Plugin owningPlugin) {
if (owningPlugin == null) {
throw new PluginException("Plugin cannot be null");
}
String key = this.disambiguate((Metadatable) subject, metadataKey);
Map entry = this.metadataMap.get(key);
if (entry == null) {
return;
}
entry.remove(owningPlugin);
if (entry.isEmpty()) {
this.metadataMap.remove(key);
}
}
示例9: register
import cn.nukkit.plugin.Plugin; //导入依赖的package包/类
@Override
public <T> boolean register(Class<T> service, T provider, Plugin plugin, ServicePriority priority) {
Preconditions.checkNotNull(provider);
Preconditions.checkNotNull(priority);
Preconditions.checkNotNull(service);
// build-in service provider needn't plugin param
if (plugin == null && provider.getClass().getClassLoader() != Server.class.getClassLoader()) {
throw new NullPointerException("plugin");
}
return provide(service, provider, plugin, priority);
}
示例10: sendPluginList
import cn.nukkit.plugin.Plugin; //导入依赖的package包/类
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}));
}
示例11: getPluginEventTiming
import cn.nukkit.plugin.Plugin; //导入依赖的package包/类
public static Timing getPluginEventTiming(Class<? extends Event> event, Listener listener, EventExecutor executor, Plugin plugin) {
Timing group = TimingsManager.getTiming(plugin.getName(), "Combined Total", pluginEventTimer);
return TimingsManager.getTiming(plugin.getName(), "Event: " + listener.getClass().getName() + "."
+ (executor instanceof MethodEventExecutor ? ((MethodEventExecutor) executor).getMethod().getName() : "???")
+ " (" + event.getSimpleName() + ")", group);
}
示例12: removeMetadata
import cn.nukkit.plugin.Plugin; //导入依赖的package包/类
@Override
public void removeMetadata(Object block, String metadataKey, Plugin owningPlugin) {
if (!(block instanceof Block)) {
throw new IllegalArgumentException("Object must be a Block");
}
if (((Block) block).getLevel() == this.owningLevel) {
super.removeMetadata(block, metadataKey, owningPlugin);
} else {
throw new IllegalStateException("Block does not belong to world " + this.owningLevel.getName());
}
}
示例13: unregisterAll
import cn.nukkit.plugin.Plugin; //导入依赖的package包/类
public static void unregisterAll(Plugin plugin) {
synchronized (allLists) {
for (HandlerList h : allLists) {
h.unregister(plugin);
}
}
}
示例14: addAttachment
import cn.nukkit.plugin.Plugin; //导入依赖的package包/类
@Override
public PermissionAttachment addAttachment(Plugin plugin, String name, Boolean value) {
if (!plugin.isEnabled()) {
throw new PluginException("Plugin " + plugin.getDescription().getName() + " is disabled");
}
PermissionAttachment result = new PermissionAttachment(plugin, this.parent != null ? this.parent : this);
this.attachments.add(result);
if (name != null && value != null) {
result.setPermission(name, value);
}
this.recalculatePermissions();
return result;
}
示例15: TaskHandler
import cn.nukkit.plugin.Plugin; //导入依赖的package包/类
public TaskHandler(Plugin plugin, Runnable task, int taskId, boolean asynchronous) {
this.asynchronous = asynchronous;
this.plugin = plugin;
this.task = task;
this.taskId = taskId;
this.timing = Timings.getTaskTiming(this, period);
}