Better handle disabling of the regions feature.

This commit is contained in:
sk89q 2014-08-22 16:18:05 -07:00
parent b43bc4a57a
commit 88c0bdfffb
2 changed files with 13 additions and 1 deletions

View File

@ -182,6 +182,11 @@ public void reload() {
private RegionManager load(World world) {
checkNotNull(world);
WorldConfiguration config = plugin.getGlobalStateManager().get(world);
if (!config.useRegions) {
return null;
}
RegionManager manager;
synchronized (lock) {

View File

@ -247,9 +247,16 @@ protected static void checkRegionDoesNotExist(RegionManager manager, String id,
* @throws CommandException thrown if the manager is null
*/
protected static RegionManager checkRegionManager(WorldGuardPlugin plugin, World world) throws CommandException {
if (!plugin.getGlobalStateManager().get(world).useRegions) {
throw new CommandException("Region support is disabled in the target world. " +
"It can be enabled per-world in WorldGuard's configuration files. " +
"However, you may need to restart your server afterwards.");
}
RegionManager manager = plugin.getRegionContainer().get(world);
if (manager == null) {
throw new CommandException("Either region support is disabled or region data failed to load in the target world.");
throw new CommandException("Region data failed to load for this world. " +
"Please ask a server administrator to read the logs to identify the reason.");
}
return manager;
}