mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-18 15:17:36 +01:00
Optimized flags scheduler.
This commit is contained in:
parent
183f48a998
commit
d9136aa407
@ -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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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()) {
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
|
@ -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:
|
||||||
|
Loading…
Reference in New Issue
Block a user