@EventHandler(priority = EventPriority.MONITOR) public void onPluginEnable(PluginEnableEvent event) { if (event.getPlugin().getDescription().getName().equals("Register") && packageExists("com.nijikokun.register.payment.Methods")) { if (!Methods.hasMethod()) { try { Method m = Methods.class.getMethod("addMethod", Methods.class); m.setAccessible(true); m.invoke(null, "Vault", new net.milkbowl.vault.VaultEco()); if (!Methods.setPreferred("Vault")) { log.info("Unable to hook register"); } else { log.info("[Vault] - Successfully injected Vault methods into Register."); } } catch (SecurityException e) { log.info("Unable to hook register"); } catch (NoSuchMethodException e) { log.info("Unable to hook register"); } catch (IllegalArgumentException e) { log.info("Unable to hook register"); } catch (IllegalAccessException e) { log.info("Unable to hook register"); } catch (InvocationTargetException e) { log.info("Unable to hook register"); } } } }
/** Setups all event handlers, used by this plugin. */ private void setupEventHandler() { // Listen to plugins enabling, used for finding an economy plugin. Methods.setMethod(getServer().getPluginManager()); // Remove player information on quit. getServer().getPluginManager().registerEvents(playerListener, this); // Update player information controlled by an scheduler. int locationUpdateInterval = getConfig().getInt("location-update-interval", 60); getServer() .getScheduler() .scheduleSyncRepeatingTask( this, new Runnable() { public void run() { playerListener.onPlayerLocationUpdate(); } }, locationUpdateInterval * 3, locationUpdateInterval); // Register commands. getCommand("port").setExecutor(new PortCommandExecutor(this)); getCommand("depart").setExecutor(new DepartCommandExecutor(this)); }
/** @return the payment method. */ public Method getPaymentMethod() { return Methods.getMethod(); }
/** @return true, if there is at least one payment method! */ public boolean hasPaymentMethods() { return Methods.hasMethod(); }