mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-13 06:15:09 +01:00
Allows claimed regions to inherit from a template region (#1864)
* Allows claimed regions to inherit from a template region * Replace template-when-claiming with set-parent-on-claim * Make the set-parent-on-claim option check secure
This commit is contained in:
parent
46251f5ffa
commit
b59da5992f
@ -281,6 +281,7 @@ public void loadConfiguration() {
|
||||
regionWand = convertLegacyItem(getString("regions.wand", ItemTypes.LEATHER.getId()));
|
||||
maxClaimVolume = getInt("regions.max-claim-volume", 30000);
|
||||
claimOnlyInsideExistingRegions = getBoolean("regions.claim-only-inside-existing-regions", false);
|
||||
setParentOnClaim = getString("regions.set-parent-on-claim", "");
|
||||
boundedLocationFlags = getBoolean("regions.location-flags-only-inside-regions", false);
|
||||
|
||||
maxRegionCountPerPlayer = getInt("regions.max-region-count-per-player.default", 7);
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
@ -281,7 +282,7 @@ public void claim(CommandContext args, Actor sender) throws CommandException {
|
||||
}
|
||||
}
|
||||
|
||||
// We have to check whether this region violates the space of any other reion
|
||||
// We have to check whether this region violates the space of any other region
|
||||
ApplicableRegionSet regions = manager.getApplicableRegions(region);
|
||||
|
||||
// Check if this region overlaps any other region
|
||||
@ -314,6 +315,18 @@ public void claim(CommandContext args, Actor sender) throws CommandException {
|
||||
}
|
||||
}
|
||||
|
||||
// Inherit from a template region
|
||||
if (!Strings.isNullOrEmpty(wcfg.setParentOnClaim)) {
|
||||
ProtectedRegion templateRegion = manager.getRegion(wcfg.setParentOnClaim);
|
||||
if (templateRegion != null) {
|
||||
try {
|
||||
region.setParent(templateRegion);
|
||||
} catch (CircularInheritanceException e) {
|
||||
throw new CommandException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RegionAdder task = new RegionAdder(manager, region);
|
||||
task.setLocatorPolicy(UserLocatorPolicy.UUID_ONLY);
|
||||
task.setOwnersInput(new String[]{player.getName()});
|
||||
|
@ -129,6 +129,7 @@ public abstract class WorldConfiguration {
|
||||
public boolean allowTamedSpawns;
|
||||
public int maxClaimVolume;
|
||||
public boolean claimOnlyInsideExistingRegions;
|
||||
public String setParentOnClaim;
|
||||
public int maxRegionCountPerPlayer;
|
||||
public boolean antiWolfDumbness;
|
||||
public boolean signChestProtection;
|
||||
|
Loading…
Reference in New Issue
Block a user