本文整理匯總了Java中org.bukkit.event.server.PluginEnableEvent類的典型用法代碼示例。如果您正苦於以下問題:Java PluginEnableEvent類的具體用法?Java PluginEnableEvent怎麽用?Java PluginEnableEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PluginEnableEvent類屬於org.bukkit.event.server包,在下文中一共展示了PluginEnableEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: enablePlugin
import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
public void enablePlugin(final Plugin plugin) {
Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");
if (!plugin.isEnabled()) {
plugin.getLogger().info("Enabling " + plugin.getDescription().getFullName());
JavaPlugin jPlugin = (JavaPlugin) plugin;
String pluginName = jPlugin.getDescription().getName();
if (!loaders.containsKey(pluginName)) {
loaders.put(pluginName, (PluginClassLoader) jPlugin.getClassLoader());
}
try {
jPlugin.setEnabled(true);
} catch (Throwable ex) {
server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
}
// Perhaps abort here, rather than continue going, but as it stands,
// an abort is not possible the way it's currently written
server.getPluginManager().callEvent(new PluginEnableEvent(plugin));
}
}
示例2: loaderEnablePlugin
import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
private void loaderEnablePlugin(Plugin plugin) {
if (!plugin.isEnabled()) {
plugin.getLogger().info("Enabling " + plugin.getDescription().getFullName());
JavaPlugin jPlugin = (JavaPlugin) plugin;
try {
Field f = JavaPlugin.class.getDeclaredField("isEnabled");
f.setAccessible(true);
boolean enabled = f.getBoolean(jPlugin);
if (!enabled) {
f.setBoolean(jPlugin, true);
jPlugin.onEnable();
}
} catch (Throwable ex) {
server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
}
server.getPluginManager().callEvent(new PluginEnableEvent(plugin));
}
}
示例3: onPluginEnable
import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@EventHandler
public void onPluginEnable(PluginEnableEvent e) {
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(xEssentials.getPlugin(), new Runnable() {
long sec;
int ticks;
@Override
public void run() {
sec = System.currentTimeMillis() / 1000;
if (second == sec) {
ticks++;
} else {
second = sec;
tps = tps == 0 ? ticks : (tps + ticks) / 2;
ticks = 0;
}
}
}, 21, 1);
}
示例4: onPluginEnable
import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@EventHandler
public void onPluginEnable(final PluginEnableEvent e)
{
if (!e.getPlugin().getName().equalsIgnoreCase("Essentials"))
{
return;
}
Runnable r = new Runnable()
{
@Override
public void run()
{
inject(e.getPlugin());
}
};
Bukkit.getScheduler().runTask(BukkitPlugin.getInstance(), r);
}
示例5: onPluginEnable
import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@EventHandler
public void onPluginEnable(PluginEnableEvent e)
{
for (Map.Entry<Class<? extends Bridge>, String> entry : brigdesmap.entrySet())
{
try
{
Class.forName(entry.getValue());
for (Bridge b : bridges)
{
if (b.getClass().getName().equals(entry.getKey().getName()))
{
throw new Exception();
}
}
createBridge(entry.getKey(), entry.getValue()).enable();
}
catch (Exception ex)
{
}
}
}
示例6: onPluginEnable
import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if(permission == null){
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Xperms");
if(perms != null){
try{
if(Double.valueOf(perms.getDescription().getVersion()) < 1.1){
log.info(String.format("[%s] [Permission] %s Current version is not compatible with vault! Please Update!", plugin.getDescription().getName(), name));
}
} catch(NumberFormatException e){
// version is first release, numbered 1.0.0
log.info(String.format("[%s] [Permission] %s Current version is not compatibe with vault! Please Update!", plugin.getDescription().getName(), name));
}
permission.perms = (Main) perms;
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
示例7: onPluginEnable
import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (permission.permission == null) {
Plugin perms = plugin.getServer().getPluginManager().getPlugin("PermissionsEx");
if (perms != null) {
try {
if (Double.valueOf(perms.getDescription().getVersion()) < 1.16) {
log.info(String.format("[%s][Permission] %s below 1.16 is not compatible with Vault! Falling back to SuperPerms only mode. PLEASE UPDATE!", plugin.getDescription().getName(), name));
return;
}
} catch (NumberFormatException e) {
// Do nothing
}
permission.permission = (PermissionsEx) perms;
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), permission.name));
}
}
}
示例8: onPluginEnable
import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onPluginEnable(PluginEnableEvent event) {
// Make sure the plugin instance isn't null
if (event.getPlugin() == null) {
return;
}
final String pluginName = event.getPlugin().getName();
// Call the onPluginEnable method in the permissions manager
permissionsManager.onPluginEnable(pluginName);
if ("Essentials".equalsIgnoreCase(pluginName)) {
pluginHookService.tryHookToEssentials();
} else if ("Multiverse-Core".equalsIgnoreCase(pluginName)) {
pluginHookService.tryHookToMultiverse();
} else if ("EssentialsSpawn".equalsIgnoreCase(pluginName)) {
spawnLoader.loadEssentialsSpawn();
} else if ("CMI".equalsIgnoreCase(pluginName)) {
pluginHookService.tryHookToCmi();
spawnLoader.loadCmiSpawn();
} else if ("ProtocolLib".equalsIgnoreCase(pluginName)) {
protocolLibService.setup();
}
}
示例9: enablePlugin
import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@Override
public void enablePlugin(Plugin plugin) {
valid(plugin);
if (!plugin.isEnabled()) {
plugin.getLogger().info("Enabling " + plugin.getDescription().getFullName());
SubPlugin sub = (SubPlugin) plugin;
try {
sub.setEnabled(true);
} catch (Exception e) {
Bukkit.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", e);
}
Bukkit.getPluginManager().callEvent(new PluginEnableEvent(plugin));
}
}
示例10: onPluginEnable
import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
Plugin p = event.getPlugin();
String name = p.getDescription().getName();
if (name.equals("dynmap") || name.equals("WorldGuard")) {
if (this.cubitDynmap.dynmap.isEnabled() && CubitBukkitPlugin.inst().getWorldGuardPlugin().isEnabled())
this.cubitDynmap.initialize();
}
}
示例11: PluginHookMgr
import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
public PluginHookMgr(SuperVanish plugin) {
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
for (Plugin alreadyEnabledPlugin : Bukkit.getPluginManager().getPlugins())
if (alreadyEnabledPlugin.isEnabled())
onPluginEnable(new PluginEnableEvent(alreadyEnabledPlugin));
}
示例12: onPluginEnable
import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent e) {
if (e.getPlugin().getName().equals("PlaceholderAPI")) {
Bukkit.getLogger().info(consolePrefix + "Found PlaceholderAPI. Using custom chat format.");
placeholderAPIEnabled = true;
} else if (e.getPlugin().getName().equals("Importer")) {
Bukkit.getLogger().info(consolePrefix + "Found Importer. Enabling Importer integration.");
ImporterHook importerHook = new ImporterHook();
importerHook.hook(this);
}
}
示例13: onPluginEnable
import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@EventHandler(priority=EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
Plugin p = event.getPlugin();
String name = p.getDescription().getName();
if(name.equals("dynmap")) {
if(dynmap.isEnabled())
activate(dynmap);
}
}
示例14: onPluginEnable
import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onPluginEnable(final PluginEnableEvent event) {
final Plugin plugin = event.getPlugin();
if (!plugin.getName().equals("Vault")) return;
this.factionsHook.deinit();
this.factionsHook.init();
}
示例15: onPluginEnable
import org.bukkit.event.server.PluginEnableEvent; //導入依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onPluginEnable(final PluginEnableEvent event) {
final Plugin plugin = event.getPlugin();
if (!plugin.getName().equals("Vault")) return;
this.vaultHook.deinit();
this.vaultHook.init();
}