Ejemplo n.º 1
0
 @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");
       }
     }
   }
 }
Ejemplo n.º 2
0
  /** 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));
  }
Ejemplo n.º 3
0
 /** @return the payment method. */
 public Method getPaymentMethod() {
   return Methods.getMethod();
 }
Ejemplo n.º 4
0
 /** @return true, if there is at least one payment method! */
 public boolean hasPaymentMethods() {
   return Methods.hasMethod();
 }