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();
for (Player player : players) {
WorldStateManager worldConfig = config.get(player.getWorld());
if (!worldConfig.useRegions) {
continue;
}
PlayerFlagState state;
synchronized (this) {
@ -71,17 +77,13 @@ public void run() {
}
}
WorldStateManager worldConfig = config.get(player.getWorld());
Vector playerLocation = toVector(player.getLocation());
RegionManager regionManager = plugin.getGlobalRegionManager()
.get(player.getWorld());
ApplicableRegionSet applicable = regionManager
.getApplicableRegions(playerLocation);
if (worldConfig.useRegions) {
Vector playerLocation = toVector(player.getLocation());
RegionManager regionManager = plugin.getGlobalRegionManager()
.get(player.getWorld());
ApplicableRegionSet applicable = regionManager
.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>();
public boolean suppressTickSyncWarnings;
public boolean useRegionsScheduler;
/**
* Construct the object.
@ -83,6 +84,8 @@ public void load() {
suppressTickSyncWarnings = config.getBoolean(
"suppress-tick-sync-warnings", false);
useRegionsScheduler = config.getBoolean(
"regions.use-scheduler", true);
// Load configurations for each world
for (World world : plugin.getServer().getWorlds()) {

View File

@ -140,8 +140,11 @@ public void onEnable() {
(new WorldGuardWeatherListener(this)).registerEvents();
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) {
Logger.getLogger("Minecraft").setFilter(
@ -210,6 +213,7 @@ public GlobalRegionManager getGlobalRegionManager() {
* @return
* @deprecated Use {@link #getGlobalStateManager()} instead
*/
@Deprecated
public GlobalStateManager getGlobalConfiguration() {
return getGlobalStateManager();
}

View File

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