Beispiel #1
0
  @SuppressWarnings("static-access")
  public boolean checkEssentialsTeleport(Player player) {
    if (!TownySettings.isUsingEssentials()) return true;

    Plugin test = getServer().getPluginManager().getPlugin("Essentials");
    if (test == null) return true;
    Essentials essentials = (Essentials) test;
    essentials.loadClasses();
    sendDebugMsg("Using Essenitials");

    test = getServer().getPluginManager().getPlugin("EssentialsTele");
    if (test == null) return true;
    sendDebugMsg("Using EssenitialsTele");

    try {
      User user = User.get(player, getServer());
      user.teleportCooldown();
      user.charge("tp");
    } catch (Exception e) {
      sendErrorMsg(player, "Error: " + e.getMessage());
      return false;
    }

    return true;
  }
 private void checkPermLag(long start, String summary) {
   final long elapsed = System.nanoTime() - start;
   if (elapsed > ess.getSettings().getPermissionsLagWarning()) {
     ess.getLogger()
         .log(
             Level.WARNING,
             String.format(
                 "Permissions lag notice with (%s). Response took %fms. Summary: %s",
                 getName(), elapsed / 1000000.0, summary));
   }
 }
  /**
   * Method to grab Essentials internal altCommands hash. This is ugly code but Essentials offers no
   * external APIs to make this any cleaner.
   *
   * @throws NoSuchFieldException
   * @throws SecurityException
   * @throws IllegalAccessException
   * @throws IllegalArgumentException
   */
  @SuppressWarnings("unchecked")
  private void grabInternalAltCommands()
      throws SecurityException, NoSuchFieldException, IllegalArgumentException,
          IllegalAccessException {
    Essentials pluginObject = (Essentials) essentialsPlugin;
    Field commandHandler = pluginObject.getClass().getDeclaredField("alternativeCommandsHandler");
    commandHandler.setAccessible(true);
    AlternativeCommandsHandler ach = (AlternativeCommandsHandler) commandHandler.get(pluginObject);
    Field altCommandsField = ach.getClass().getDeclaredField("altcommands");
    altCommandsField.setAccessible(true);
    altcommands = (HashMap<String, List<PluginCommand>>) altCommandsField.get(ach);

    log.debug("altcommands = {}", altcommands);
  }
 public void checkPermissions() {
   // load and assign a handler
   List<Class<? extends SuperpermsHandler>> providerClazz =
       Arrays.asList(
           BPermissions2Handler.class,
           GroupManagerHandler.class,
           PermissionsExHandler.class,
           PrivilegesHandler.class,
           SimplyPermsHandler.class,
           GenericVaultHandler.class,
           SuperpermsHandler.class);
   for (Class<? extends IPermissionsHandler> providerClass : providerClazz) {
     try {
       IPermissionsHandler provider = providerClass.newInstance();
       if (provider.tryProvider()) {
         this.handler = provider;
         break;
       }
     } catch (Throwable ignored) {
     }
   }
   if (handler == null) {
     handler = new ConfigPermissionsHandler(ess);
   }
   if (useSuperperms && handler instanceof ConfigPermissionsHandler) {
     handler = new SuperpermsHandler();
   }
   // output handler info
   if (handler instanceof GenericVaultHandler) {
     String enabledPermsPlugin = ((GenericVaultHandler) handler).getEnabledPermsPlugin();
     if (enabledPermsPlugin == null) enabledPermsPlugin = "generic";
     ess.getLogger().info("Using Vault based permissions (" + enabledPermsPlugin + ")");
   } else if (handler.getClass() == SuperpermsHandler.class) {
     if (handler.tryProvider()) {
       ess.getLogger()
           .warning(
               "Detected supported permissions plugin "
                   + ((SuperpermsHandler) handler).getEnabledPermsPlugin()
                   + " without Vault installed.");
       ess.getLogger()
           .warning(
               "Features such as chat prefixes/suffixes and group-related functionality will not "
                   + "work until you install Vault.");
     }
     ess.getLogger().info("Using superperms-based permissions.");
   } else if (handler.getClass() == ConfigPermissionsHandler.class) {
     ess.getLogger().info("Using config file enhanced permissions.");
     ess.getLogger().info("Permissions listed in as player-commands will be given to all users.");
   }
 }
  public void essentialsCheck() {
    if (this.ess != null) {
      ISettings settings = this.ess.getSettings();
      if (settings == null) {
        this.ess = null;
        return;
      }
      if (!settings.areSignsDisabled()) {
        SignShop.log("Essentials signs are enabled, will conflict with SignShop", Level.WARNING);
        FileConfiguration config = this.ess.getConfig();
        if (config == null) {
          this.ess = null;
          return;
        }

        try {
          FileReader reader = new FileReader(ess.getDataFolder() + "/config.yml");
          if (reader == null) return;
          BufferedReader buffreader = new BufferedReader(reader);
          String line;
          File newFile = new File(ess.getDataFolder(), "config_2.yml");
          if (!newFile.exists()) newFile.createNewFile();
          FileWriter writer = new FileWriter(ess.getDataFolder() + "/config_2.yml");
          boolean doComment = false;
          while ((line = buffreader.readLine()) != null) {
            if (line.contains("signs-disabled")) line = line.replace("false", "true");
            if (doComment && line.contains(":")) doComment = false;
            if (line.contains("enabledSigns")) doComment = true;
            if (doComment && !line.contains("#") && line.contains("-"))
              writer.write("# " + line + "\n");
            else writer.write(line + "\n");
          }
          writer.close();
          reader.close();
          File oldFile = new File(ess.getDataFolder(), "config.yml");
          File bakFile = new File(ess.getDataFolder(), "config.bak");
          if (bakFile.exists()) bakFile.delete();
          oldFile.renameTo(bakFile);
          if (!newFile.renameTo(oldFile)) return;
        } catch (IOException IOex) {
          return;
        }
        SignShop.log(
            "Disabled Essentials signs through Essentials' config.yml, reloading config now.",
            Level.INFO);
        this.ess.reload();
      }
    }
  }
Beispiel #6
0
  public void onEnable() {
    final PluginManager pluginManager = getServer().getPluginManager();

    EssentialsChatPlayerListener.checkFactions(pluginManager);

    final EssentialsChatPlayerListener playerListener =
        new EssentialsChatPlayerListener(getServer());
    pluginManager.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Lowest, this);
    pluginManager.registerEvent(Type.PLAYER_CHAT, playerListener, Priority.Highest, this);
    if (!this.getDescription()
        .getVersion()
        .equals(Essentials.getStatic().getDescription().getVersion())) {
      LOGGER.log(Level.WARNING, Util.i18n("versionMismatchAll"));
    }
    LOGGER.info(
        Util.format(
            "loadinfo",
            this.getDescription().getName(),
            this.getDescription().getVersion(),
            Essentials.AUTHORS));
  }