本文整理汇总了Java中cn.nukkit.utils.PluginException类的典型用法代码示例。如果您正苦于以下问题:Java PluginException类的具体用法?Java PluginException怎么用?Java PluginException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PluginException类属于cn.nukkit.utils包,在下文中一共展示了PluginException类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addTask
import cn.nukkit.utils.PluginException; //导入依赖的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;
}
示例2: addAttachment
import cn.nukkit.utils.PluginException; //导入依赖的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;
}
示例3: setMetadata
import cn.nukkit.utils.PluginException; //导入依赖的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);
}
示例4: addTask
import cn.nukkit.utils.PluginException; //导入依赖的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);
pending.offer(taskHandler);
taskMap.put(taskHandler.getTaskId(), taskHandler);
return taskHandler;
}
示例5: PermissionAttachment
import cn.nukkit.utils.PluginException; //导入依赖的package包/类
public PermissionAttachment(Plugin plugin, Permissible permissible) {
if (!plugin.isEnabled()) {
throw new PluginException("Plugin " + plugin.getDescription().getName() + " is disabled");
}
this.permissible = permissible;
this.plugin = plugin;
}
示例6: addAttachment
import cn.nukkit.utils.PluginException; //导入依赖的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;
}
示例7: registerEvent
import cn.nukkit.utils.PluginException; //导入依赖的package包/类
public void registerEvent(Class<? extends Event> event, Listener listener, EventPriority priority, EventExecutor executor, Plugin plugin, boolean ignoreCancelled) throws PluginException {
if (!plugin.isEnabled()) {
throw new PluginException("Plugin attempted to register " + event + " while not enabled");
}
try {
Timing timing = Timings.getPluginEventTiming(event, listener, executor, plugin);
this.getEventListeners(event).register(new RegisteredListener(listener, executor, priority, plugin, ignoreCancelled, timing));
} catch (IllegalAccessException e) {
Server.getInstance().getLogger().logException(e);
}
}
示例8: setMetadata
import cn.nukkit.utils.PluginException; //导入依赖的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);
}
示例9: removeMetadata
import cn.nukkit.utils.PluginException; //导入依赖的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);
}
}
示例10: invalidateAll
import cn.nukkit.utils.PluginException; //导入依赖的package包/类
public void invalidateAll(Plugin owningPlugin) {
if (owningPlugin == null) {
throw new PluginException("Plugin cannot be null");
}
for (Map value : this.metadataMap.values()) {
if (value.containsKey(owningPlugin)) {
((MetadataValue) value.get(owningPlugin)).invalidate();
}
}
}
示例11: removeMetadata
import cn.nukkit.utils.PluginException; //导入依赖的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 = (Map) this.metadataMap.get(key);
if (entry == null) {
return;
}
entry.remove(owningPlugin);
if (entry.isEmpty()) {
this.metadataMap.remove(key);
}
}