Optimized flags scheduler.

This commit is contained in:
sk89q 2011-06-05 16:38:28 -07:00
parent 183f48a998
commit d9136aa407
4 changed files with 25 additions and 13 deletions

View File

@ -60,6 +60,12 @@ public void run() {
GlobalStateManager config = plugin.getGlobalStateManager(); GlobalStateManager config = plugin.getGlobalStateManager();
for (Player player : players) { for (Player player : players) {
WorldStateManager worldConfig = config.get(player.getWorld());
if (!worldConfig.useRegions) {
continue;
}
PlayerFlagState state; PlayerFlagState state;
synchronized (this) { synchronized (this) {
@ -70,18 +76,14 @@ public void run() {
states.put(player.getName(), state); states.put(player.getName(), state);
} }
} }
WorldStateManager worldConfig = config.get(player.getWorld());
if (worldConfig.useRegions) { Vector playerLocation = toVector(player.getLocation());
Vector playerLocation = toVector(player.getLocation()); RegionManager regionManager = plugin.getGlobalRegionManager()
RegionManager regionManager = plugin.getGlobalRegionManager() .get(player.getWorld());
.get(player.getWorld()); ApplicableRegionSet applicable = regionManager
ApplicableRegionSet applicable = regionManager .getApplicableRegions(playerLocation);
.getApplicableRegions(playerLocation);
processHeal(applicable, player, state);
processHeal(applicable, player, state);
}
} }
} }

View File

@ -59,6 +59,7 @@ public class GlobalStateManager {
private Set<String> hasAmphibious = new HashSet<String>(); private Set<String> hasAmphibious = new HashSet<String>();
public boolean suppressTickSyncWarnings; public boolean suppressTickSyncWarnings;
public boolean useRegionsScheduler;
/** /**
* Construct the object. * Construct the object.
@ -83,6 +84,8 @@ public void load() {
suppressTickSyncWarnings = config.getBoolean( suppressTickSyncWarnings = config.getBoolean(
"suppress-tick-sync-warnings", false); "suppress-tick-sync-warnings", false);
useRegionsScheduler = config.getBoolean(
"regions.use-scheduler", true);
// Load configurations for each world // Load configurations for each world
for (World world : plugin.getServer().getWorlds()) { for (World world : plugin.getServer().getWorlds()) {

View File

@ -140,8 +140,11 @@ public void onEnable() {
(new WorldGuardWeatherListener(this)).registerEvents(); (new WorldGuardWeatherListener(this)).registerEvents();
flagScheduler = new FlagScheduler(this); flagScheduler = new FlagScheduler(this);
getServer().getScheduler().scheduleAsyncRepeatingTask(this,
flagScheduler, FlagScheduler.RUN_DELAY, FlagScheduler.RUN_DELAY); if (configuration.useRegionsScheduler) {
getServer().getScheduler().scheduleAsyncRepeatingTask(this,
flagScheduler, FlagScheduler.RUN_DELAY, FlagScheduler.RUN_DELAY);
}
if (configuration.suppressTickSyncWarnings) { if (configuration.suppressTickSyncWarnings) {
Logger.getLogger("Minecraft").setFilter( Logger.getLogger("Minecraft").setFilter(
@ -210,6 +213,7 @@ public GlobalRegionManager getGlobalRegionManager() {
* @return * @return
* @deprecated Use {@link #getGlobalStateManager()} instead * @deprecated Use {@link #getGlobalStateManager()} instead
*/ */
@Deprecated
public GlobalStateManager getGlobalConfiguration() { public GlobalStateManager getGlobalConfiguration() {
return getGlobalStateManager(); return getGlobalStateManager();
} }

View File

@ -18,7 +18,10 @@
# Remember to check the compatibility spreadsheet for WorldGuard to see # Remember to check the compatibility spreadsheet for WorldGuard to see
# if any features are currently broken in your version of Bukkit. # if any features are currently broken in your version of Bukkit.
# #
suppress-tick-sync-warnings: false suppress-tick-sync-warnings: false
regions:
use-scheduler: true
# For permissions, see http://wiki.sk89q.com/wiki/WorldGuard/Permissions/Bukkit # For permissions, see http://wiki.sk89q.com/wiki/WorldGuard/Permissions/Bukkit
permissions: permissions: