コード例 #1
0
ファイル: War.java プロジェクト: adegie/Towny
 public void remove(Town attacker, TownBlock townBlock) throws NotRegisteredException {
   townScored(attacker, TownySettings.getWarPointsForTownBlock());
   townBlock.getTown().addBonusBlocks(-1);
   attacker.addBonusBlocks(1);
   try {
     if (!townBlock
         .getTown()
         .payTo(TownySettings.getWartimeTownBlockLossPrice(), attacker, "War - TownBlock Loss")) {
       remove(townBlock.getTown());
       TownyMessaging.sendTownMessage(
           townBlock.getTown(), "Your town ran out of funds to support yourself in war.");
     } else
       TownyMessaging.sendTownMessage(
           townBlock.getTown(),
           "Your town lost "
               + TownySettings.getWartimeTownBlockLossPrice()
               + " "
               + TownyEconomyObject.getEconomyCurrency()
               + ".");
   } catch (EconomyException e) {
   }
   if (townBlock.getTown().isHomeBlock(townBlock)) remove(townBlock.getTown());
   else remove(townBlock.getWorldCoord());
   TownyUniverse.getDataSource().saveTown(townBlock.getTown());
   TownyUniverse.getDataSource().saveTown(attacker);
 }
コード例 #2
0
ファイル: TownyUniverse.java プロジェクト: MrNaikito/towny
 public List<Resident> getValidatedResidents(Object sender, String[] names) {
   List<Resident> invited = new ArrayList<Resident>();
   for (String name : names) {
     List<Player> matches = plugin.getServer().matchPlayer(name);
     if (matches.size() > 1) {
       String line = "Multiple players selected";
       for (Player p : matches) line += ", " + p.getName();
       TownyMessaging.sendErrorMsg(sender, line);
     } else if (matches.size() == 1) {
       // Match found online
       try {
         Resident target = getDataSource().getResident(matches.get(0).getName());
         invited.add(target);
       } catch (TownyException x) {
         TownyMessaging.sendErrorMsg(sender, x.getMessage());
       }
     } else {
       // No online matches so test for offline.
       Resident target;
       try {
         target = getDataSource().getResident(name);
         invited.add(target);
       } catch (NotRegisteredException x) {
         TownyMessaging.sendErrorMsg(sender, x.getMessage());
       }
     }
   }
   return invited;
 }
コード例 #3
0
  /**
   * Delete a resident and it's data file (if not online) Available Only to players with the
   * 'towny.admin' permission node.
   *
   * @param player
   * @param split
   */
  public void residentDelete(Player player, String[] split) {

    if (split.length == 0)
      TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_invalid_name"));
    else
      try {
        if (!TownyUniverse.getPermissionSource().isTownyAdmin(player))
          throw new TownyException(TownySettings.getLangString("msg_err_admin_only_delete"));

        for (String name : split) {
          try {
            Resident resident = TownyUniverse.getDataSource().getResident(name);
            if (!resident.isNPC() && !BukkitTools.isOnline(resident.getName())) {
              TownyUniverse.getDataSource().removeResident(resident);
              TownyUniverse.getDataSource().removeResidentList(resident);
              TownyMessaging.sendGlobalMessage(TownySettings.getDelResidentMsg(resident));
            } else
              TownyMessaging.sendErrorMsg(
                  player,
                  String.format(TownySettings.getLangString("msg_err_online_or_npc"), name));
          } catch (NotRegisteredException x) {
            // This name isn't registered as a resident
            TownyMessaging.sendErrorMsg(
                player, String.format(TownySettings.getLangString("msg_err_invalid_name"), name));
          }
        }
      } catch (TownyException x) {
        // Admin only escape
        TownyMessaging.sendErrorMsg(player, x.getMessage());
        return;
      }
  }
コード例 #4
0
ファイル: War.java プロジェクト: adegie/Towny
 public void eliminate(Town town) {
   remove(town);
   try {
     checkNation(town.getNation());
   } catch (NotRegisteredException e) {
     TownyMessaging.sendErrorMsg("[War] Error checking " + town.getName() + "'s nation.");
   }
   TownyMessaging.sendGlobalMessage(TownySettings.getWarTimeEliminatedMsg(town.getName()));
   checkEnd();
 }
コード例 #5
0
ファイル: War.java プロジェクト: adegie/Towny
 public void remove(WorldCoord worldCoord) {
   try {
     Town town = worldCoord.getTownBlock().getTown();
     TownyMessaging.sendGlobalMessage(
         TownySettings.getWarTimeLoseTownBlockMsg(worldCoord, town.getName()));
     warZone.remove(worldCoord);
   } catch (NotRegisteredException e) {
     TownyMessaging.sendGlobalMessage(TownySettings.getWarTimeLoseTownBlockMsg(worldCoord));
     warZone.remove(worldCoord);
   }
 }
コード例 #6
0
ファイル: TownyUniverse.java プロジェクト: MrNaikito/towny
  public void onLogin(Player player) throws AlreadyRegisteredException, NotRegisteredException {

    if (!player.isOnline()) return;

    // Test and kick any players with invalid names.
    if ((player.getName().trim() == null) || (player.getName().contains(" "))) {
      player.kickPlayer("Invalid name!");
      return;
    }

    Resident resident;

    if (!getDataSource().hasResident(player.getName())) {
      getDataSource().newResident(player.getName());
      resident = getDataSource().getResident(player.getName());

      TownyMessaging.sendMessage(player, TownySettings.getRegistrationMsg(player.getName()));
      resident.setRegistered(System.currentTimeMillis());
      if (!TownySettings.getDefaultTownName().equals(""))
        try {
          Town town = getDataSource().getTown(TownySettings.getDefaultTownName());
          town.addResident(resident);
          getDataSource().saveTown(town);
        } catch (NotRegisteredException e) {
        } catch (AlreadyRegisteredException e) {
        }

      getDataSource().saveResident(resident);
      getDataSource().saveResidentList();

    } else {
      resident = getDataSource().getResident(player.getName());
      resident.setLastOnline(System.currentTimeMillis());

      getDataSource().saveResident(resident);
    }

    try {
      TownyMessaging.sendTownBoard(player, resident.getTown());
    } catch (NotRegisteredException e) {
    }

    if (isWarTime()) getWarEvent().sendScores(player, 3);

    // Schedule to setup default modes when the player has finished loading
    if (getPlugin()
            .getServer()
            .getScheduler()
            .scheduleSyncDelayedTask(getPlugin(), new SetDefaultModes(this, player, false), 1)
        == -1)
      TownyMessaging.sendErrorMsg("Could not set default modes for " + player.getName() + ".");

    setChangedNotify(PLAYER_LOGIN);
  }
コード例 #7
0
ファイル: CachePermissions.java プロジェクト: pjsw007/Towny
  /**
   * getCachePermission
   *
   * <p>returns player cached permission for BUILD, DESTROY, SWITCH or ITEM_USE
   *
   * @param player
   * @param location
   * @param action
   * @return true if the player has permission.
   */
  public boolean getCachePermission(Player player, Location location, ActionType action) {

    WorldCoord worldCoord;

    try {
      worldCoord =
          new WorldCoord(
              TownyUniverse.getDataSource().getWorld(player.getWorld().getName()),
              Coord.parseCoord(location));
      PlayerCache cache = TownyUniverse.getPlugin().getCache(player);
      cache.updateCoord(worldCoord);

      TownyMessaging.sendDebugMsg(
          "Cache permissions for " + action.toString() + " : " + cache.getCachePermission(action));
      return cache.getCachePermission(
          action); // || plugin.isTownyAdmin(player); // Throws NullPointerException if the cache is
                   // empty

    } catch (NotRegisteredException e) {
      // World not known
      e.printStackTrace();
    } catch (NullPointerException e) {
      // New or old cache permission was null, update it

      try {
        worldCoord =
            new WorldCoord(
                TownyUniverse.getDataSource().getWorld(player.getWorld().getName()),
                Coord.parseCoord(location));

        TownBlockStatus status =
            cacheStatus(player, worldCoord, getStatusCache(player, worldCoord));
        // plugin.cacheBuild(player, worldCoord, plugin.getPermission(player, status, worldCoord,
        // action));
        triggerCacheCreate(player, location, worldCoord, status, action);

        PlayerCache cache = TownyUniverse.getPlugin().getCache(player);
        cache.updateCoord(worldCoord);

        TownyMessaging.sendDebugMsg(
            "New Cache permissions for "
                + action.toString()
                + " : "
                + cache.getCachePermission(action));
        return cache.getCachePermission(action); // || plugin.isTownyAdmin(player);

      } catch (NotRegisteredException e1) {
        // Will never get here.
      }
    }
    return false;
  }
コード例 #8
0
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {

    this.sender = sender;

    if (sender instanceof Player) {
      player = (Player) sender;
      isConsole = false;
      System.out.println(
          "[PLAYER_COMMAND] "
              + player.getName()
              + ": /"
              + commandLabel
              + " "
              + StringMgmt.join(args));

    } else {
      isConsole = true;
      this.player = null;
    }

    try {
      return parseTownyAdminCommand(args);
    } catch (TownyException e) {
      TownyMessaging.sendErrorMsg(sender, e.getMessage());
    }

    return true;
  }
コード例 #9
0
  private void giveBonus(String[] split) throws TownyException {

    Town town;

    try {
      if (split.length != 2)
        throw new TownyException(
            String.format(
                TownySettings.getLangString("msg_err_invalid_input"),
                "Eg: givebonus [town/player] [n]"));
      try {
        town = TownyUniverse.getDataSource().getTown(split[0]);
      } catch (NotRegisteredException e) {
        town = TownyUniverse.getDataSource().getResident(split[0]).getTown();
      }
      try {
        town.setBonusBlocks(town.getBonusBlocks() + Integer.parseInt(split[1].trim()));
        TownyMessaging.sendMsg(
            getSender(),
            String.format(
                TownySettings.getLangString("msg_give_total"),
                town.getName(),
                split[1],
                town.getBonusBlocks()));
      } catch (NumberFormatException nfe) {
        throw new TownyException(TownySettings.getLangString("msg_error_must_be_int"));
      }
      TownyUniverse.getDataSource().saveTown(town);
    } catch (TownyException e) {
      throw new TownyException(e.getMessage());
    }
  }
コード例 #10
0
  public void parseAdminUnclaimCommand(String[] split) {

    if (split.length == 1 && split[0].equalsIgnoreCase("?")) {
      for (String line : ta_unclaim) ((CommandSender) getSender()).sendMessage(line);
    } else {

      if (isConsole) {
        sender.sendMessage("[Towny] InputError: This command was designed for use in game only.");
        return;
      }

      try {
        if (TownyUniverse.isWarTime())
          throw new TownyException(TownySettings.getLangString("msg_war_cannot_do"));

        List<WorldCoord> selection;
        selection =
            AreaSelectionUtil.selectWorldCoordArea(
                null, new WorldCoord(player.getWorld().getName(), Coord.parseCoord(player)), split);
        selection = AreaSelectionUtil.filterWildernessBlocks(selection);

        new TownClaim(plugin, player, null, selection, false, false, true).start();

      } catch (TownyException x) {
        TownyMessaging.sendErrorMsg(player, x.getMessage());
        return;
      }
    }
  }
コード例 #11
0
ファイル: CachePermissions.java プロジェクト: pjsw007/Towny
  public void cacheItemUse(Player player, WorldCoord worldCoord, boolean itemUseRight) {
    PlayerCache cache = TownyUniverse.getPlugin().getCache(player);
    cache.updateCoord(worldCoord);
    cache.setItemUsePermission(itemUseRight);

    TownyMessaging.sendDebugMsg(
        player.getName() + " (" + worldCoord.toString() + ") Cached Item Use: " + itemUseRight);
  }
コード例 #12
0
ファイル: CachePermissions.java プロジェクト: pjsw007/Towny
  public void cacheBuild(Player player, WorldCoord worldCoord, boolean buildRight) {
    PlayerCache cache = TownyUniverse.getPlugin().getCache(player);
    cache.updateCoord(worldCoord);
    cache.setBuildPermission(buildRight);

    TownyMessaging.sendDebugMsg(
        player.getName() + " (" + worldCoord.toString() + ") Cached Build: " + buildRight);
  }
コード例 #13
0
ファイル: CachePermissions.java プロジェクト: pjsw007/Towny
  public void cacheSwitch(Player player, WorldCoord worldCoord, boolean switchRight) {
    PlayerCache cache = TownyUniverse.getPlugin().getCache(player);
    cache.updateCoord(worldCoord);
    cache.setSwitchPermission(switchRight);

    TownyMessaging.sendDebugMsg(
        player.getName() + " (" + worldCoord.toString() + ") Cached Switch: " + switchRight);
  }
コード例 #14
0
ファイル: CachePermissions.java プロジェクト: pjsw007/Towny
  public void cacheDestroy(Player player, WorldCoord worldCoord, boolean destroyRight) {
    PlayerCache cache = TownyUniverse.getPlugin().getCache(player);
    cache.updateCoord(worldCoord);
    cache.setDestroyPermission(destroyRight);

    TownyMessaging.sendDebugMsg(
        player.getName() + " (" + worldCoord.toString() + ") Cached Destroy: " + destroyRight);
  }
コード例 #15
0
ファイル: War.java プロジェクト: adegie/Towny
  public void start() {
    warTime = true;

    // Announce

    // Seed spoils of war
    try {
      warSpoils.pay(TownySettings.getBaseSpoilsOfWar(), "Start of War - Base Spoils");
      TownyMessaging.sendMsg(
          "[War] Seeding spoils of war with " + TownySettings.getBaseSpoilsOfWar());
    } catch (EconomyException e) {
      TownyMessaging.sendErrorMsg("[War] Could not seed spoils of war.");
    }

    // Gather all nations at war
    for (Nation nation : TownyUniverse.getDataSource().getNations()) {
      if (!nation.isNeutral()) {
        add(nation);
        TownyMessaging.sendGlobalMessage(
            String.format(TownySettings.getLangString("msg_war_join_nation"), nation.getName()));
      } else if (!TownySettings.isDeclaringNeutral()) {
        try {
          nation.setNeutral(false);
          add(nation);
          TownyMessaging.sendGlobalMessage(
              String.format(TownySettings.getLangString("msg_war_join_forced"), nation.getName()));
        } catch (TownyException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    }
    // warTimer.scheduleAtFixedRate(new WarTimerTask(this), 0, 1000);
    int id =
        plugin
            .getServer()
            .getScheduler()
            .scheduleAsyncRepeatingTask(
                getPlugin(), new WarTimerTask(this), 0, TimeTools.convertToTicks(5));
    if (id == -1) {
      TownyMessaging.sendErrorMsg("Could not schedule war event loop.");
      end();
    } else addTaskId(id);
    checkEnd();
  }
コード例 #16
0
ファイル: TownyUniverse.java プロジェクト: MrNaikito/towny
 public List<Resident> getOnlineResidents(Player player, String[] names) {
   List<Resident> invited = new ArrayList<Resident>();
   for (String name : names) {
     List<Player> matches = plugin.getServer().matchPlayer(name);
     if (matches.size() > 1) {
       String line = "Multiple players selected";
       for (Player p : matches) line += ", " + p.getName();
       TownyMessaging.sendErrorMsg(player, line);
     } else if (matches.size() == 1)
       try {
         Resident target = getDataSource().getResident(matches.get(0).getName());
         invited.add(target);
       } catch (TownyException x) {
         TownyMessaging.sendErrorMsg(player, x.getMessage());
       }
   }
   return invited;
 }
コード例 #17
0
ファイル: War.java プロジェクト: adegie/Towny
 public void add(Town town) {
   TownyMessaging.sendTownMessage(town, TownySettings.getJoinWarMsg(town));
   townScores.put(town, 0);
   warringTowns.add(town);
   for (TownBlock townBlock : town.getTownBlocks())
     if (town.isHomeBlock(townBlock))
       warZone.put(townBlock.getWorldCoord(), TownySettings.getWarzoneHomeBlockHealth());
     else warZone.put(townBlock.getWorldCoord(), TownySettings.getWarzoneTownBlockHealth());
 }
コード例 #18
0
ファイル: TownyUniverse.java プロジェクト: MrNaikito/towny
 public void newDay() {
   if (!isDailyTimerRunning()) toggleDailyTimer(true);
   // dailyTimer.schedule(new DailyTimerTask(this), 0);
   if (getPlugin()
           .getServer()
           .getScheduler()
           .scheduleAsyncDelayedTask(getPlugin(), new DailyTimerTask(this))
       == -1) TownyMessaging.sendErrorMsg("Could not schedule newDay.");
   setChangedNotify(NEW_DAY);
 }
コード例 #19
0
ファイル: TownyUniverse.java プロジェクト: MrNaikito/towny
  public void requestTeleport(Player player, Town town, double cost) {
    try {
      TeleportWarmupTimerTask.requestTeleport(
          getDataSource().getResident(player.getName().toLowerCase()), town, cost);
    } catch (TownyException x) {
      TownyMessaging.sendErrorMsg(player, x.getMessage());
    }

    setChangedNotify(TELEPORT_REQUEST);
  }
コード例 #20
0
ファイル: CachePermissions.java プロジェクト: pjsw007/Towny
  public TownBlockStatus cacheStatus(
      Player player, WorldCoord worldCoord, TownBlockStatus townBlockStatus) {
    PlayerCache cache = TownyUniverse.getPlugin().getCache(player);
    cache.updateCoord(worldCoord);
    cache.setStatus(townBlockStatus);

    TownyMessaging.sendDebugMsg(
        player.getName() + " (" + worldCoord.toString() + ") Cached Status: " + townBlockStatus);
    return townBlockStatus;
  }
コード例 #21
0
ファイル: JoinTownTask.java プロジェクト: stpinker/Towny
  @Override
  public void run() {
    try {
      town.addResident(resident);
      towny.deleteCache(resident.getName());
      TownyUniverse.getDataSource().saveResident(resident);
      TownyUniverse.getDataSource().saveTown(town);

      TownyMessaging.sendTownMessage(
          town,
          ChatTools.color(
              String.format(TownySettings.getLangString("msg_join_town"), resident.getName())));
    } catch (AlreadyRegisteredException e) {
      try {
        TownyMessaging.sendResidentMessage(resident, e.getMessage());
      } catch (TownyException e1) {
      }
    }
  }
コード例 #22
0
ファイル: TownyUniverse.java プロジェクト: MrNaikito/towny
 public void toggleDailyTimer(boolean on) {
   if (on && !isDailyTimerRunning()) {
     long timeTillNextDay = TownyUtil.townyTime();
     TownyMessaging.sendMsg(
         "Time until a New Day: " + TimeMgmt.formatCountdownTime(timeTillNextDay));
     dailyTask =
         getPlugin()
             .getServer()
             .getScheduler()
             .scheduleAsyncRepeatingTask(
                 getPlugin(),
                 new DailyTimerTask(this),
                 MinecraftTools.convertToTicks(timeTillNextDay),
                 MinecraftTools.convertToTicks(TownySettings.getDayInterval()));
     if (dailyTask == -1) TownyMessaging.sendErrorMsg("Could not schedule new day loop.");
   } else if (!on && isDailyTimerRunning()) {
     getPlugin().getServer().getScheduler().cancelTask(dailyTask);
     dailyTask = -1;
   }
   setChangedNotify(TOGGLE_DAILY_TIMER);
 }
コード例 #23
0
ファイル: War.java プロジェクト: adegie/Towny
  public void end() {
    for (Player player : TownyUniverse.getOnlinePlayers()) sendStats(player);
    double halfWinnings;
    try {
      // Transactions might leave 1 coin. (OH noez!)
      halfWinnings = getWarSpoils().getHoldingBalance() / 2.0;

      try {
        double nationWinnings = halfWinnings / warringNations.size(); // Again, might leave residue.
        for (Nation winningNation : warringNations) {
          getWarSpoils().payTo(nationWinnings, winningNation, "War - Nation Winnings");
          TownyMessaging.sendGlobalMessage(
              winningNation.getName()
                  + " won "
                  + nationWinnings
                  + " "
                  + TownyEconomyObject.getEconomyCurrency()
                  + ".");
        }
      } catch (ArithmeticException e) {
        // A war ended with 0 nations.
      }

      try {
        KeyValue<Town, Integer> winningTownScore = getWinningTownScore();
        getWarSpoils().payTo(halfWinnings, winningTownScore.key, "War - Nation Winnings");
        TownyMessaging.sendGlobalMessage(
            winningTownScore.key.getName()
                + " won "
                + halfWinnings
                + " "
                + TownyEconomyObject.getEconomyCurrency()
                + " with the score "
                + winningTownScore.value
                + ".");
      } catch (TownyException e) {
      }
    } catch (EconomyException e1) {
    }
  }
コード例 #24
0
ファイル: TownyUniverse.java プロジェクト: MrNaikito/towny
  /**
   * getTownBlock
   *
   * <p>returns TownBlock this location lies within if no block is registered it returns null
   *
   * @param loc
   * @return TownBlock at this location, or null for none.
   */
  public TownBlock getTownBlock(Location loc) {

    TownyMessaging.sendDebugMsg("Fetching TownBlock");

    try {
      WorldCoord worldCoord =
          new WorldCoord(getDataSource().getWorld(loc.getWorld().getName()), Coord.parseCoord(loc));
      return worldCoord.getTownBlock();
    } catch (NotRegisteredException e) {
      // No data so return null
      return null;
    }
  }
コード例 #25
0
ファイル: War.java プロジェクト: adegie/Towny
 public void setupDelay(int delay) {
   if (delay <= 0) start();
   else {
     for (Long t : TimeMgmt.getCountdownDelays(delay, TimeMgmt.defaultCountdownDelays)) {
       // Schedule the warnings leading up to the start of the war event
       // warTimer.schedule(
       //              new ServerBroadCastTimerTask(plugin,
       //                              String.format("War starts in %s",
       // TimeMgmt.formatCountdownTime(t))),
       //                              (delay-t)*1000);
       int id =
           plugin
               .getServer()
               .getScheduler()
               .scheduleAsyncDelayedTask(
                   getPlugin(),
                   new ServerBroadCastTimerTask(
                       plugin, String.format("War starts in %s", TimeMgmt.formatCountdownTime(t))),
                   TimeTools.convertToTicks((delay - t)));
       if (id == -1) {
         TownyMessaging.sendErrorMsg("Could not schedule a countdown message for war event.");
         end();
       } else addTaskId(id);
     }
     // warTimer.schedule(new StartWarTimerTask(universe), delay*1000);
     int id =
         plugin
             .getServer()
             .getScheduler()
             .scheduleAsyncDelayedTask(
                 getPlugin(), new StartWarTimerTask(universe), TimeTools.convertToTicks(delay));
     if (id == -1) {
       TownyMessaging.sendErrorMsg("Could not schedule setup delay for war event.");
       end();
     } else addTaskId(id);
   }
 }
コード例 #26
0
ファイル: TownyUniverse.java プロジェクト: MrNaikito/towny
 public void toggleTeleportWarmup(boolean on) {
   if (on && !isTeleportWarmupRunning()) {
     teleportWarmupTask =
         getPlugin()
             .getServer()
             .getScheduler()
             .scheduleSyncRepeatingTask(getPlugin(), new TeleportWarmupTimerTask(this), 0, 20);
     if (teleportWarmupTask == -1)
       TownyMessaging.sendErrorMsg("Could not schedule teleport warmup loop.");
   } else if (!on && isTeleportWarmupRunning()) {
     getPlugin().getServer().getScheduler().cancelTask(teleportWarmupTask);
     teleportWarmupTask = -1;
   }
   setChangedNotify(TOGGLE_TELEPORT_WARMUP);
 }
コード例 #27
0
  public void reloadTowny(Boolean reset) {

    if (reset) {
      TownyUniverse.getDataSource().deleteFile(plugin.getConfigPath());
    }
    TownyLogger.shutDown();
    if (plugin.load()) {

      // Register all child permissions for ranks
      TownyPerms.registerPermissionNodes();

      // Update permissions for all online players
      TownyPerms.updateOnlinePerms();
    }

    TownyMessaging.sendMsg(sender, TownySettings.getLangString("msg_reloaded"));
    // TownyMessaging.sendMsg(TownySettings.getLangString("msg_reloaded"));
  }
コード例 #28
0
ファイル: TownyUniverse.java プロジェクト: MrNaikito/towny
 public void toggleMobRemoval(boolean on) {
   if (on && !isMobRemovalRunning()) {
     mobRemoveTask =
         getPlugin()
             .getServer()
             .getScheduler()
             .scheduleSyncRepeatingTask(
                 getPlugin(),
                 new MobRemovalTimerTask(this, plugin.getServer()),
                 0,
                 MinecraftTools.convertToTicks(TownySettings.getMobRemovalSpeed()));
     if (mobRemoveTask == -1) TownyMessaging.sendErrorMsg("Could not schedule mob removal loop.");
   } else if (!on && isMobRemovalRunning()) {
     getPlugin().getServer().getScheduler().cancelTask(mobRemoveTask);
     mobRemoveTask = -1;
   }
   setChangedNotify(TOGGLE_MOB_REMOVAL);
 }
コード例 #29
0
ファイル: TownyUniverse.java プロジェクト: MrNaikito/towny
 public void toggleTownyRepeatingTimer(boolean on) {
   if (on && !isTownyRepeatingTaskRunning()) {
     townyRepeatingTask =
         getPlugin()
             .getServer()
             .getScheduler()
             .scheduleSyncRepeatingTask(
                 getPlugin(),
                 new RepeatingTimerTask(this),
                 0,
                 MinecraftTools.convertToTicks(TownySettings.getPlotManagementSpeed()));
     if (townyRepeatingTask == -1)
       TownyMessaging.sendErrorMsg("Could not schedule Towny Timer Task.");
   } else if (!on && isTownyRepeatingTaskRunning()) {
     getPlugin().getServer().getScheduler().cancelTask(townyRepeatingTask);
     townyRepeatingTask = -1;
   }
   setChanged();
 }
コード例 #30
0
ファイル: TownyUniverse.java プロジェクト: MrNaikito/towny
 public void toggleHealthRegen(boolean on) {
   if (on && !isHealthRegenRunning()) {
     healthRegenTask =
         getPlugin()
             .getServer()
             .getScheduler()
             .scheduleSyncRepeatingTask(
                 getPlugin(),
                 new HealthRegenTimerTask(this, plugin.getServer()),
                 0,
                 MinecraftTools.convertToTicks(TownySettings.getHealthRegenSpeed()));
     if (healthRegenTask == -1)
       TownyMessaging.sendErrorMsg("Could not schedule health regen loop.");
   } else if (!on && isHealthRegenRunning()) {
     getPlugin().getServer().getScheduler().cancelTask(healthRegenTask);
     healthRegenTask = -1;
   }
   setChangedNotify(TOGGLE_HEALTH_REGEN);
 }