Ejemplo n.º 1
0
 /**
  * Removes a WorldGuard/GriefPrevention safezone from the database.<br>
  * Do not use this method in a loop. It will cause ConcurrentModificationExceptions.
  *
  * @return True if the removal succeeded. False otherwise.
  */
 public static boolean removeSafeZone(TRSafeZone zone) {
   return TRSafeZone.removeSafeZone(zone);
 }
Ejemplo n.º 2
0
 /**
  * Searches for a WorldGuard safezone in the database for the given location. If checkGP is true,
  * it will also check for GriefPrevention Safezones.
  *
  * @return "" if none is found. A message with more information about the safezone otherwise.
  */
 public static String getSafeZoneByLocation(Location location, boolean checkGP) {
   return TRSafeZone.getSafeZoneByLocation(location, checkGP);
 }
Ejemplo n.º 3
0
 /**
  * @param player This player is used for the location and for the permissions checks.<br>
  *     If the player is not allowed to build in a WorldGuard region, or if he is not on the
  *     managers list in a GriefPrevention claim, it will return with NoPermission. <br>
  *     <br>
  * @param pluginName The name of the plugin you want to use to create the safezone.<br>
  *     Can be "griefprevention" or "worldguard". (Case Insensitive) <br>
  *     <br>
  * @param zoneName The name you want the safeZone to have.<br>
  *     Duplicate names are not allowed. (Will return SafeZoneCreate.AlreadyExists) <br>
  *     <br>
  * @return The reason why the creation succeeded or failed.
  */
 public static SafeZoneCreate createSafeZone(Player player, String pluginName, String zoneName) {
   return TRSafeZone.addSafeZone(player, pluginName, zoneName);
 }
Ejemplo n.º 4
0
  @Override
  public void onEnable() {
    ttt = new TRThread();
    try {
      Assigner.assign(); // Register the required listeners
    } catch (Exception ex) {
      Warning.load("A severe error occurred: Unable to start listeners!", true);
      Log.Exception(ex, true);
    }

    TRSafeZone.init();

    TRLimiter.init();

    getCommand("tekkitrestrict").setExecutor(new TRCommandTR());
    getCommand("openalc").setExecutor(new TRCommandAlc());
    getCommand("tpic").setExecutor(new TRCommandTPIC());
    getCommand("checklimits").setExecutor(new TRCommandCheck());

    // determine if EE2 is enabled by using pluginmanager
    PluginManager pm = this.getServer().getPluginManager();

    tekkitrestrict.EEEnabled = pm.isPluginEnabled("mod_EE");

    try {
      if (pm.isPluginEnabled("PermissionsEx")) {
        TRPermHandler.permEx = ru.tehkode.permissions.bukkit.PermissionsEx.getPermissionManager();
        log.info("PEX is enabled!");
      }
    } catch (Exception ex) {
      log.info("Linking with Pex Failed!");
      // Was not able to load permissionsEx
    }

    try {
      ttt.init();
    } catch (Exception ex) {
      Warning.loadWarnings.add("An error occurred: Unable to start threads!");
      Log.Exception(ex, true);
    }

    try {
      initHeartBeat();
    } catch (Exception ex) {
      Warning.load("An error occurred: Unable to initiate Limiter Manager correctly!", false);
      Log.Exception(ex, false);
    }

    if (linkEEPatch()) {
      boolean success = true;
      try {
        Assigner.assignEEPatch();
      } catch (Exception ex) {
        success = false;
      }

      if (success) log.info("Linked with EEPatch for extended functionality!");
      else Warning.other("Linking with EEPatch Failed!", true);

    } else {
      log.info("EEPatch is not available. Extended EE integration disabled.");
    }

    Bukkit.getScheduler()
        .scheduleAsyncDelayedTask(
            this,
            new Runnable() {
              public void run() {
                if (config.getBoolean2(ConfigFile.General, "Auto-Update", true)) {
                  // updater = new Updater_Old(this, "tekkit-restrict", this.getFile(),
                  // Updater_Old.UpdateType.DEFAULT, true);
                  updater2 =
                      new Updater(
                          tekkitrestrict.this,
                          44061,
                          tekkitrestrict.this.getFile(),
                          Updater.UpdateType.DEFAULT,
                          true);
                } else if (config.getBoolean2(
                    ConfigFile.General, "CheckForUpdateOnStartup", true)) {
                  // updater = new Updater_Old(this, "tekkit-restrict", this.getFile(),
                  // Updater_Old.UpdateType.NO_DOWNLOAD, true);
                  updater2 =
                      new Updater(
                          tekkitrestrict.this,
                          44061,
                          tekkitrestrict.this.getFile(),
                          Updater.UpdateType.NO_DOWNLOAD,
                          true);
                  // if (updater.getResult() == UpdateResult.UPDATE_AVAILABLE)
                  // log.info(ChatColor.GREEN + "There is an update available: " +
                  // updater.getLatestVersionString() + ". Use /tr admin update ingame to update.");
                  if (updater2.getResult() == Updater.UpdateResult.UPDATE_AVAILABLE)
                    log.info(
                        ChatColor.GREEN
                            + "There is an update available: "
                            + updater2.getLatestName()
                            + ". Use /tr admin update ingame to update.");
                }
              }
            });

    // ##################### Log Filter ####################
    if (config.getBoolean2(ConfigFile.Logging, "FilterLogs", true)
        || config.getBoolean2(ConfigFile.Logging, "SplitLogs", true)) {
      Enumeration<String> cc = LogManager.getLogManager().getLoggerNames();
      filter = new TRLogFilter();
      while (cc.hasMoreElements()) {
        Logger.getLogger(cc.nextElement()).setFilter(filter);
      }
    }
    // #####################################################

    initMetrics();
    tmetrics =
        new TMetrics(this, config.getBoolean2(ConfigFile.General, "ShowTMetricsWarnings", true));

    if (config.getBoolean2(ConfigFile.General, "UseTMetrics", true)) {
      tmetrics.start();
    }

    Bukkit.getScheduler()
        .scheduleSyncDelayedTask(
            this,
            new Runnable() {
              @Override
              public void run() {
                if (!Warning.loadWarnings.isEmpty()) {
                  log.warning("There were some warnings while loading TekkitRestrict!");
                  log.warning(
                      "Use /tr warnings load to view them again (in case you missed them).");
                } else if (!Warning.dbWarnings.isEmpty()) {
                  log.warning("There were some database warnings while loading TekkitRestrict!");
                  log.warning("Use /tr warnings db to view them again (in case you missed them).");
                }
              }
            });

    log.info("TekkitRestrict v" + version.fullVer + " Enabled!");
  }