mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Comments
This commit is contained in:
parent
c7c00021b2
commit
8fe610311d
@ -2,7 +2,6 @@ package com.fastasyncworldedit.bukkit.regions;
|
|||||||
|
|
||||||
import com.fastasyncworldedit.core.regions.FaweMask;
|
import com.fastasyncworldedit.core.regions.FaweMask;
|
||||||
import com.fastasyncworldedit.core.regions.RegionWrapper;
|
import com.fastasyncworldedit.core.regions.RegionWrapper;
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
@ -29,6 +28,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -73,6 +73,10 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener {
|
|||||||
return (WorldGuardPlugin) plugin;
|
return (WorldGuardPlugin) plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the WorldGuard regions a player is allowed in based on the current location, or if isWhitelist set to false, get the
|
||||||
|
* blacklisted regions for the world.
|
||||||
|
*/
|
||||||
public Set<ProtectedRegion> getRegions(LocalPlayer player, Location location, boolean isWhitelist) {
|
public Set<ProtectedRegion> getRegions(LocalPlayer player, Location location, boolean isWhitelist) {
|
||||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||||
if (container == null) {
|
if (container == null) {
|
||||||
@ -89,13 +93,13 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener {
|
|||||||
if (global != null && isAllowed(player, global) == isWhitelist) {
|
if (global != null && isAllowed(player, global) == isWhitelist) {
|
||||||
return Collections.singleton(global);
|
return Collections.singleton(global);
|
||||||
}
|
}
|
||||||
|
//Merge WorldGuardFlag
|
||||||
|
if (isWhitelist) {
|
||||||
final ApplicableRegionSet regions = manager.getApplicableRegions(BlockVector3.at(
|
final ApplicableRegionSet regions = manager.getApplicableRegions(BlockVector3.at(
|
||||||
location.getX(),
|
location.getX(),
|
||||||
location.getY(),
|
location.getY(),
|
||||||
location.getZ()
|
location.getZ()
|
||||||
));
|
));
|
||||||
//Merge WorldGuardFlag
|
|
||||||
if (isWhitelist) {
|
|
||||||
if (player.hasPermission("fawe.worldguardflag") && !regions.testState(
|
if (player.hasPermission("fawe.worldguardflag") && !regions.testState(
|
||||||
player,
|
player,
|
||||||
Flags.BUILD,
|
Flags.BUILD,
|
||||||
@ -112,14 +116,7 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener {
|
|||||||
}
|
}
|
||||||
return Collections.unmodifiableSet(protectedRegions);
|
return Collections.unmodifiableSet(protectedRegions);
|
||||||
} else {
|
} else {
|
||||||
if (player.hasPermission("fawe.worldguardflag") && !regions.testState(
|
final Collection<ProtectedRegion> regions = manager.getRegions().values();
|
||||||
player,
|
|
||||||
Flags.BUILD,
|
|
||||||
Flags.BLOCK_PLACE,
|
|
||||||
Flags.BLOCK_BREAK
|
|
||||||
)) {
|
|
||||||
return ImmutableSet.copyOf(regions.getRegions());
|
|
||||||
}
|
|
||||||
Set<ProtectedRegion> protectedRegions = new HashSet<>();
|
Set<ProtectedRegion> protectedRegions = new HashSet<>();
|
||||||
for (ProtectedRegion region : regions) {
|
for (ProtectedRegion region : regions) {
|
||||||
if (!isAllowed(player, region)) {
|
if (!isAllowed(player, region)) {
|
||||||
@ -161,19 +158,19 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener {
|
|||||||
final Set<ProtectedRegion> regions = this.getRegions(localplayer, location, isWhitelist);
|
final Set<ProtectedRegion> regions = this.getRegions(localplayer, location, isWhitelist);
|
||||||
if (!regions.isEmpty()) {
|
if (!regions.isEmpty()) {
|
||||||
Set<Region> result = new HashSet<>();
|
Set<Region> result = new HashSet<>();
|
||||||
for (ProtectedRegion myregion : regions) {
|
for (ProtectedRegion myRegion : regions) {
|
||||||
if (myregion.getId().equals("__global__")) {
|
if (myRegion.getId().equals("__global__")) {
|
||||||
return new FaweMask(RegionWrapper.GLOBAL()) {
|
return new FaweMask(RegionWrapper.GLOBAL()) {
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
|
public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
|
||||||
return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player)), myregion);
|
return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player)), myRegion);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
if (myregion instanceof ProtectedCuboidRegion) {
|
if (myRegion instanceof ProtectedCuboidRegion) {
|
||||||
result.add(new CuboidRegion(myregion.getMaximumPoint(), myregion.getMaximumPoint()));
|
result.add(new CuboidRegion(myRegion.getMaximumPoint(), myRegion.getMaximumPoint()));
|
||||||
} else {
|
} else {
|
||||||
result.add(adapt(myregion));
|
result.add(adapt(myRegion));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,8 +178,8 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
|
public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
|
||||||
final LocalPlayer localplayer = worldguard.wrapPlayer(BukkitAdapter.adapt(player));
|
final LocalPlayer localplayer = worldguard.wrapPlayer(BukkitAdapter.adapt(player));
|
||||||
for (ProtectedRegion myregion : regions) {
|
for (ProtectedRegion myRegion : regions) {
|
||||||
if (!isAllowed(localplayer, myregion)) {
|
if (!isAllowed(localplayer, myRegion)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ public class Settings extends Config {
|
|||||||
public String MODE = "MEMBER";
|
public String MODE = "MEMBER";
|
||||||
@Comment({
|
@Comment({
|
||||||
"Allow region blacklists.",
|
"Allow region blacklists.",
|
||||||
" - Currently only implemented for WorldGuard ",
|
" - Currently only implemented for WorldGuard",
|
||||||
" - see region-restrictions-options.worldguard-region-blacklist"
|
" - see region-restrictions-options.worldguard-region-blacklist"
|
||||||
})
|
})
|
||||||
public boolean ALLOW_BLACKLISTS = false;
|
public boolean ALLOW_BLACKLISTS = false;
|
||||||
|
@ -83,7 +83,7 @@ public class ProvideBindings extends Bindings {
|
|||||||
return regions(player, FaweMaskManager.MaskType.MEMBER);
|
return regions(player, FaweMaskManager.MaskType.MEMBER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Region[] regions(Player player, FaweMaskManager.MaskType type) {
|
private Region[] regions(Player player, FaweMaskManager.MaskType type) {
|
||||||
Region[] regions = player.getAllowedRegions(type);
|
Region[] regions = player.getAllowedRegions(type);
|
||||||
if (regions == null) {
|
if (regions == null) {
|
||||||
throw new IllegalArgumentException(Caption.toString(Caption.of("fawe.error.no.region")));
|
throw new IllegalArgumentException(Caption.toString(Caption.of("fawe.error.no.region")));
|
||||||
|
@ -6,7 +6,9 @@ import com.fastasyncworldedit.core.extent.processor.ProcessorScope;
|
|||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
Loading…
Reference in New Issue
Block a user