3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-03 01:50:07 +01:00

Don't allow edits on plots when owner is offline and player is only added (#1313)

Dieser Commit ist enthalten in:
dordsor21 2021-10-04 13:34:40 +01:00 committet von GitHub
Ursprung d44f297068
Commit 6895234815
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
11 geänderte Dateien mit 156 neuen und 55 gelöschten Zeilen

Datei anzeigen

@ -1,6 +1,7 @@
package com.fastasyncworldedit.bukkit.regions.plotsquared;
import com.fastasyncworldedit.core.FaweAPI;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.regions.FaweMask;
import com.fastasyncworldedit.core.regions.FaweMaskManager;
import com.fastasyncworldedit.core.regions.filter.RegionFilter;
@ -24,6 +25,7 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionIntersection;
import com.sk89q.worldedit.world.World;
import org.apache.logging.log4j.Logger;
import org.bukkit.Bukkit;
import java.util.List;
import java.util.Locale;
@ -68,10 +70,57 @@ public class PlotSquaredFeature extends FaweMaskManager {
return false;
}
UUID uid = player.getUniqueId();
return !plot.getFlag(NoWorldeditFlag.class) && (plot.isOwner(uid) || type == MaskType.MEMBER && (
plot.getTrusted().contains(uid) || plot.getTrusted().contains(DBFunc.EVERYONE)
|| (plot.getMembers().contains(uid) || plot.getMembers().contains(DBFunc.EVERYONE)) && player
.hasPermission("fawe.plotsquared.member")) || player.hasPermission("fawe.plotsquared.admin"));
if (plot.getFlag(NoWorldeditFlag.class)) {
player.print(Caption.of(
"fawe.cancel.reason.no.region.reason",
Caption.of("fawe.cancel.reason.no.region.plot.noworldeditflag")
));
return false;
}
if (plot.isOwner(uid) || player.hasPermission("fawe.plotsquared.admin")) {
return true;
}
if (type != MaskType.MEMBER) {
player.print(Caption.of(
"fawe.cancel.reason.no.region.reason",
Caption.of("fawe.cancel.reason.no.region.plot.owner.only")
));
return false;
}
if (plot.getTrusted().contains(uid) || plot.getTrusted().contains(DBFunc.EVERYONE)) {
return true;
}
if (plot.getMembers().contains(uid) || plot.getMembers().contains(DBFunc.EVERYONE)) {
if (!player.hasPermission("fawe.plotsquared.member")) {
player.print(Caption.of(
"fawe.cancel.reason.no.region.reason",
Caption.of("fawe.error.no-perm", "fawe.plotsquared.member")
));
return false;
}
if (!plot.getOwners().isEmpty() && plot.getOwners().stream().anyMatch(this::playerOnline)) {
return true;
} else {
player.print(Caption.of(
"fawe.cancel.reason.no.region.reason",
Caption.of("fawe.cancel.reason.no.region.plot.owner.offline")
));
return false;
}
}
player.print(Caption.of(
"fawe.cancel.reason.no.region.reason",
Caption.of("fawe.cancel.reason.no.region.not.added")
));
return false;
}
private boolean playerOnline(UUID uuid) {
if (uuid == null) {
return false;
}
org.bukkit.entity.Player player = Bukkit.getPlayer(uuid);
return player != null && player.isOnline();
}
@Override

Datei anzeigen

@ -1,6 +1,7 @@
package com.fastasyncworldedit.bukkit.regions.plotsquaredv4;
import com.fastasyncworldedit.core.FaweAPI;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.regions.FaweMask;
import com.fastasyncworldedit.core.regions.FaweMaskManager;
import com.fastasyncworldedit.core.regions.RegionWrapper;
@ -25,6 +26,7 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionIntersection;
import com.sk89q.worldedit.world.World;
import org.apache.logging.log4j.Logger;
import org.bukkit.Bukkit;
import java.util.HashSet;
import java.util.List;
@ -96,12 +98,57 @@ public class PlotSquaredFeature extends FaweMaskManager {
return false;
}
UUID uid = player.getUniqueId();
return !Flags.NO_WORLDEDIT.isTrue(plot) && (plot.isOwner(uid)
|| type == MaskType.MEMBER && (plot.getTrusted().contains(uid) || plot.getTrusted()
.contains(DBFunc.EVERYONE)
|| (plot.getMembers().contains(uid) || plot.getMembers().contains(DBFunc.EVERYONE))
&& player.hasPermission("fawe.plotsquared.member")) || player
.hasPermission("fawe.plotsquared.admin"));
if (Flags.NO_WORLDEDIT.isTrue(plot)) {
player.print(Caption.of(
"fawe.cancel.reason.no.region.reason",
Caption.of("fawe.cancel.reason.no.region.plot.noworldeditflag")
));
return false;
}
if (plot.isOwner(uid) || player.hasPermission("fawe.plotsquared.admin")) {
return true;
}
if (type != MaskType.MEMBER) {
player.print(Caption.of(
"fawe.cancel.reason.no.region.reason",
Caption.of("fawe.cancel.reason.no.region.plot.owner.only")
));
return false;
}
if (plot.getTrusted().contains(uid) || plot.getTrusted().contains(DBFunc.EVERYONE)) {
return true;
}
if (plot.getMembers().contains(uid) || plot.getMembers().contains(DBFunc.EVERYONE)) {
if (!player.hasPermission("fawe.plotsquared.member")) {
player.print(Caption.of(
"fawe.cancel.reason.no.region.reason",
Caption.of("fawe.error.no-perm", "fawe.plotsquared.member")
));
return false;
}
if (!plot.getOwners().isEmpty() && plot.getOwners().stream().anyMatch(this::playerOnline)) {
return true;
} else {
player.print(Caption.of(
"fawe.cancel.reason.no.region.reason",
Caption.of("fawe.cancel.reason.no.region.plot.owner.offline")
));
return false;
}
}
player.print(Caption.of(
"fawe.cancel.reason.no.region.reason",
Caption.of("fawe.cancel.reason.no.region.not.added")
));
return false;
}
private boolean playerOnline(UUID uuid) {
if (uuid == null) {
return false;
}
org.bukkit.entity.Player player = Bukkit.getPlayer(uuid);
return player != null && player.isOnline();
}
@Override

Datei anzeigen

@ -134,52 +134,52 @@ public enum FaweCache implements Trimable {
*/
public static final FaweBlockBagException BLOCK_BAG = new FaweBlockBagException();
public static final FaweException MANUAL = new FaweException(
Caption.of("fawe.cancel.worldedit.cancel.reason.manual"),
Caption.of("fawe.cancel.reason.manual"),
Type.MANUAL
);
public static final FaweException NO_REGION = new FaweException(
Caption.of("fawe.cancel.worldedit.cancel.reason.no.region"),
Caption.of("fawe.cancel.reason.no.region"),
Type.NO_REGION
);
public static final FaweException OUTSIDE_REGION = new FaweException(
Caption.of(
"fawe.cancel.worldedit.cancel.reason.outside.region"),
"fawe.cancel.reason.outside.region"),
Type.OUTSIDE_REGION
);
public static final FaweException MAX_CHECKS = new FaweException(
Caption.of("fawe.cancel.worldedit.cancel.reason.max" + ".checks"),
Caption.of("fawe.cancel.reason.max" + ".checks"),
Type.MAX_CHECKS
);
public static final FaweException MAX_CHANGES = new FaweException(
Caption.of("fawe.cancel.worldedit.cancel.reason.max" + ".changes"),
Caption.of("fawe.cancel.reason.max" + ".changes"),
Type.MAX_CHANGES
);
public static final FaweException LOW_MEMORY = new FaweException(
Caption.of("fawe.cancel.worldedit.cancel.reason.low" + ".memory"),
Caption.of("fawe.cancel.reason.low" + ".memory"),
Type.LOW_MEMORY
);
public static final FaweException MAX_ENTITIES = new FaweException(
Caption.of(
"fawe.cancel.worldedit.cancel.reason.max.entities"),
"fawe.cancel.reason.max.entities"),
Type.MAX_ENTITIES
);
public static final FaweException MAX_TILES = new FaweException(Caption.of(
"fawe.cancel.worldedit.cancel.reason.max.tiles",
"fawe.cancel.reason.max.tiles",
Type.MAX_TILES
));
public static final FaweException MAX_ITERATIONS = new FaweException(
Caption.of(
"fawe.cancel.worldedit.cancel.reason.max.iterations"),
"fawe.cancel.reason.max.iterations"),
Type.MAX_ITERATIONS
);
public static final FaweException PLAYER_ONLY = new FaweException(
Caption.of(
"fawe.cancel.worldedit.cancel.reason.player-only"),
"fawe.cancel.reason.player-only"),
Type.PLAYER_ONLY
);
public static final FaweException ACTOR_REQUIRED = new FaweException(
Caption.of(
"fawe.cancel.worldedit.cancel.reason.actor-required"),
"fawe.cancel.reason.actor-required"),
Type.ACTOR_REQUIRED
);

Datei anzeigen

@ -23,8 +23,8 @@ public class MemoryCheckingExtent extends PassthroughExtent {
if (MemUtil.isMemoryLimited()) {
if (this.actor != null) {
actor.print(Caption.of(
"fawe.cancel.worldedit.cancel.reason",
Caption.of("fawe.cancel.worldedit.cancel.reason.low.memory")
"fawe.cancel.reason",
Caption.of("fawe.cancel.reason.low.memory")
));
if (Permission.hasPermission(this.actor, "worldedit.fast")) {
this.actor.print(Caption.of("fawe.info.worldedit.oom.admin"));

Datei anzeigen

@ -1337,9 +1337,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
if (used.MAX_CHANGES > 0 || used.MAX_ENTITIES > 0) {
actor.print(Caption.of("fawe.error.worldedit.some.fails", used.MAX_FAILS));
} else if (new ExtentTraverser<>(getExtent()).findAndGet(FaweRegionExtent.class) != null) {
actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.outside.region"));
actor.print(Caption.of("fawe.cancel.reason.outside.region"));
} else {
actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.outside.level"));
actor.print(Caption.of("fawe.cancel.reason.outside.level"));
}
}
if (wnaMode) {

Datei anzeigen

@ -944,7 +944,7 @@ public class SchematicCommands {
}
LOGGER.info(actor.getName() + " saved " + file.getCanonicalPath());
} else {
actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.manual"));
actor.print(Caption.of("fawe.cancel.reason.manual"));
}
}
//FAWE end

Datei anzeigen

@ -206,9 +206,9 @@ public class UtilityCommands {
desc = "Cancel your current command"
)
@CommandPermissions(value = "fawe.cancel", queued = false)
public void cancel(Actor actor) {
int cancelled = actor.cancel(false);
actor.print(Caption.of("fawe.cancel.worldedit.cancel.count", cancelled));
public void cancel(Player player) {
int cancelled = player.cancel(false);
player.print(Caption.of("fawe.cancel.count", cancelled));
}
@Command(

Datei anzeigen

@ -61,7 +61,7 @@ public @interface Confirm {
* (long) value;
long max = 2 << 18;
if (max != -1 && area > max) {
actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.confirm.region",
actor.print(Caption.of("fawe.cancel.reason.confirm.region",
pos1, pos2, getArgs(context), region.getHeight() * area
));
return confirm(actor, context);
@ -77,7 +77,7 @@ public @interface Confirm {
}
int max = WorldEdit.getInstance().getConfiguration().maxRadius;
if (max != -1 && value > max) {
actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.confirm.radius",
actor.print(Caption.of("fawe.cancel.reason.confirm.radius",
value, max, getArgs(context)
));
return confirm(actor, context);
@ -93,7 +93,7 @@ public @interface Confirm {
}
int max = 50; //TODO configurable, get Key.of(Method.class) @Limit
if (max != -1 && value > max) {
actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.confirm.limit",
actor.print(Caption.of("fawe.cancel.reason.confirm.limit",
value, max, getArgs(context)
));
return confirm(actor, context);
@ -107,7 +107,7 @@ public @interface Confirm {
if (checkExisting(context)) {
return true;
}
actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.confirm", Processor.getArgs(context)));
actor.print(Caption.of("fawe.cancel.reason.confirm", Processor.getArgs(context)));
return confirm(actor, context);
}
};

Datei anzeigen

@ -763,7 +763,7 @@ public final class PlatformCommandManager {
actor.print(e.getRichMessage());
}
} catch (FaweException e) {
actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason", e.getComponent()));
actor.print(Caption.of("fawe.cancel.reason", e.getComponent()));
} catch (UsageException e) {
ImmutableList<Command> cmd = e.getCommands();
if (!cmd.isEmpty()) {
@ -777,7 +777,7 @@ public final class PlatformCommandManager {
handleUnknownException(actor, e.getCause());
} catch (CommandException e) {
if (e.getCause() instanceof FaweException) {
actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason", ((FaweException) e.getCause()).getComponent()));
actor.print(Caption.of("fawe.cancel.reason", ((FaweException) e.getCause()).getComponent()));
} else {
Component msg = e.getRichMessage();
if (msg == TextComponent.empty()) {

Datei anzeigen

@ -445,7 +445,7 @@ public class PlatformManager {
public void handleThrowable(Throwable e, Actor actor) {
FaweException faweException = FaweException.get(e);
if (faweException != null) {
actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason", faweException.getComponent()));
actor.print(Caption.of("fawe.cancel.reason", faweException.getComponent()));
} else {
actor.print(Caption.of("worldedit.command.error.report"));
actor.print(Caption.of(e.getClass().getName(), TextComponent.of(": "), TextComponent.of(e.getMessage())));
@ -499,7 +499,7 @@ public class PlatformManager {
} catch (Throwable e) {
FaweException faweException = FaweException.get(e);
if (faweException != null) {
player.print(Caption.of("fawe.cancel.worldedit.cancel.reason", faweException.getComponent()));
player.print(Caption.of("fawe.cancel.reason", faweException.getComponent()));
} else {
player.print(Caption.of("worldedit.command.error.report"));
player.print(Caption.of(e.getClass().getName() + ": " + e.getMessage()));

Datei anzeigen

@ -149,24 +149,29 @@
"fawe.error.clipboard.load.failure": "Could not load clipboard. Possible that the clipboard is still being written to from another server?!",
"fawe.error.clipboard.on.disk.version.mismatch": "Clipboard version mismatch. Please delete your clipboards folder and restart the server.",
"fawe.cancel.worldedit.cancel.count": "Cancelled {0} edits.",
"fawe.cancel.worldedit.cancel.reason.confirm": "Use //confirm to execute {0}",
"fawe.cancel.worldedit.cancel.reason.confirm.region": "Your selection is large ({0} -> {1}, containing {3} blocks). Use //confirm to execute {2}",
"fawe.cancel.worldedit.cancel.reason.confirm.radius": "Your radius is large ({0} > {1}). Use //confirm to execute {2}",
"fawe.cancel.worldedit.cancel.reason.confirm.limit": "You're exceeding your limit for this action ({0} > {1}). Use //confirm to execute {2}",
"fawe.cancel.worldedit.cancel.reason": "Your WorldEdit action was cancelled: {0}.",
"fawe.cancel.worldedit.cancel.reason.manual": "Manual cancellation",
"fawe.cancel.worldedit.cancel.reason.low.memory": "Low memory",
"fawe.cancel.worldedit.cancel.reason.max.changes": "Too many blocks changed",
"fawe.cancel.worldedit.cancel.reason.max.checks": "Too many block checks",
"fawe.cancel.worldedit.cancel.reason.max.tiles": "Too many block entities",
"fawe.cancel.worldedit.cancel.reason.max.entities": "Too many entities",
"fawe.cancel.worldedit.cancel.reason.max.iterations": "Max iterations",
"fawe.cancel.worldedit.cancel.reason.outside.level": "Outside world",
"fawe.cancel.worldedit.cancel.reason.outside.region": "Outside allowed region (bypass with /wea, or disable `region-restrictions` in config.yml)",
"fawe.cancel.worldedit.cancel.reason.no.region": "No allowed region (bypass with /wea, or disable `region-restrictions` in config.yml)",
"fawe.cancel.worldedit.cancel.reason.player-only": "This operation requires a player, and cannot be executed from console, or without an actor.",
"fawe.cancel.worldedit.cancel.reason.actor-required": "This operation requires an actor.",
"fawe.cancel.count": "Cancelled {0} edits.",
"fawe.cancel.reason.confirm": "Use //confirm to execute {0}",
"fawe.cancel.reason.confirm.region": "Your selection is large ({0} -> {1}, containing {3} blocks). Use //confirm to execute {2}",
"fawe.cancel.reason.confirm.radius": "Your radius is large ({0} > {1}). Use //confirm to execute {2}",
"fawe.cancel.reason.confirm.limit": "You're exceeding your limit for this action ({0} > {1}). Use //confirm to execute {2}",
"fawe.cancel.reason": "Your WorldEdit action was cancelled: {0}.",
"fawe.cancel.reason.manual": "Manual cancellation",
"fawe.cancel.reason.low.memory": "Low memory",
"fawe.cancel.reason.max.changes": "Too many blocks changed",
"fawe.cancel.reason.max.checks": "Too many block checks",
"fawe.cancel.reason.max.tiles": "Too many block entities",
"fawe.cancel.reason.max.entities": "Too many entities",
"fawe.cancel.reason.max.iterations": "Max iterations",
"fawe.cancel.reason.outside.level": "Outside world",
"fawe.cancel.reason.outside.region": "Outside allowed region (bypass with /wea, or disable `region-restrictions` in config.yml)",
"fawe.cancel.reason.no.region": "No allowed region (bypass with /wea, or disable `region-restrictions` in config.yml)",
"fawe.cancel.reason.no.region.reason": "No allowed region: {0}",
"fawe.cancel.reason.no.region.plot.noworldeditflag": "Plot flag NoWorldeditFlag set",
"fawe.cancel.reason.no.region.plot.owner.offline": "Region owner offline",
"fawe.cancel.reason.no.region.plot.owner.only": "Only region owners may edit them",
"fawe.cancel.reason.no.region.not.added": "Not added to region",
"fawe.cancel.reason.player-only": "This operation requires a player, and cannot be executed from console, or without an actor.",
"fawe.cancel.reason.actor-required": "This operation requires an actor.",
"fawe.cancel.worldedit.failed.load.chunk": "Skipped loading chunk: {0};{1}. Try increasing chunk-wait.",
"fawe.navigation.no.block": "No block in sight! (or too far)",