Merge pull request #403 from EngineHub/feature/we-piston-commands-compat

WE Piston Compat
This commit is contained in:
wizjany 2019-05-01 00:34:50 -04:00 committed by GitHub
commit fc4c67ff29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 201 additions and 164 deletions

View File

@ -19,12 +19,12 @@
package com.sk89q.worldguard.commands;
import com.google.common.base.Function;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.serializer.legacy.LegacyComponentSerializer;
import javax.annotation.Nullable;
import java.util.function.Function;
/**
* Command-related utility methods.
@ -105,8 +105,8 @@ public static String getOwnerName(@Nullable Object owner) {
* @param sender the sender
* @return a function
*/
public static java.util.function.Function<String, ?> messageFunction(final Actor sender) {
return (Function<String, Object>) s -> {
public static Function<String, ?> messageFunction(final Actor sender) {
return s -> {
sender.printRaw(s);
return null;
};
@ -119,8 +119,8 @@ public static String getOwnerName(@Nullable Object owner) {
* @param sender the sender
* @return a function
*/
public static java.util.function.Function<TextComponent, ?> messageComponentFunction(final Actor sender) {
return (Function<TextComponent, Object>) s -> {
public static Function<TextComponent, ?> messageComponentFunction(final Actor sender) {
return s -> {
sender.print(s);
return null;
};

View File

@ -32,7 +32,6 @@
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.util.DomainInputResolver;
@ -59,8 +58,6 @@ public void addMember(CommandContext args, Actor sender) throws CommandException
RegionManager manager = checkRegionManager(world);
ProtectedRegion region = checkExistingRegion(manager, id, true);
id = region.getId();
// Check permissions
if (!getPermissionModel(sender).mayAddMembers(region)) {
throw new CommandPermissionsException();
@ -109,7 +106,6 @@ public void addOwner(CommandContext args, Actor sender) throws CommandException,
if (player != null) {
if (owners != null && owners.size() == 0) {
// TODO: Move this to an event
if (!sender.hasPermission("worldguard.region.unlimited")) {
int maxRegionCount = WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(world).getMaxRegionCount(player);
if (maxRegionCount >= 0 && manager.getRegionCountOfPlayer(player)

View File

@ -37,10 +37,12 @@
import com.sk89q.worldedit.util.formatting.component.ErrorFormat;
import com.sk89q.worldedit.util.formatting.component.LabelFormat;
import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.util.formatting.text.format.TextDecoration;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.WorldGuard;
@ -416,9 +418,9 @@ public void list(CommandContext args, Actor sender) throws CommandException {
String ownedBy;
// Get page
int page = args.getInteger(0, 1) - 1;
if (page < 0) {
page = 0;
int page = args.getInteger(0, 1);
if (page < 1) {
page = 1;
}
// -p flag to lookup a player's regions
@ -515,6 +517,8 @@ public void flag(CommandContext args, Actor sender) throws CommandException {
Collections.sort(flagList);
// TODO paginationbox + descs etc
final TextComponent.Builder builder = TextComponent.builder("Available flags: ");
final HoverEvent clickToSet = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to set"));
@ -533,6 +537,35 @@ public void flag(CommandContext args, Actor sender) throws CommandException {
sender.print(builder.build());
return;
} else {
if (foundFlag == Flags.BUILD || foundFlag == Flags.BLOCK_BREAK || foundFlag == Flags.BLOCK_PLACE) {
sender.print(Component.empty().append(TextComponent.of("WARNING:", TextColor.RED).decoration(TextDecoration.BOLD, true))
.append(ErrorFormat.wrap(" Setting the " + foundFlag.getName() + " flag is not required for protection."))
.append(Component.newline())
.append(TextComponent.of("Setting this flag will completely override default protection, and apply" +
" to members, non-members, pistons, and everything else that can modify blocks."))
.append(Component.newline())
.append(TextComponent.of("Only set this flag if you are sure you know what you are doing. See ")
.append(TextComponent.of("[this documentation page]", TextColor.AQUA)
.clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,
"https://worldguard.readthedocs.io/en/latest/regions/flags/#protection-related")))
.append(TextComponent.of(" for more info."))));
if (!sender.isPlayer()) {
sender.printRaw("https://worldguard.readthedocs.io/en/latest/regions/flags/#protection-related");
}
} else if (foundFlag == Flags.PASSTHROUGH) {
sender.print(Component.empty().append(TextComponent.of("WARNING:", TextColor.RED).decoration(TextDecoration.BOLD, true))
.append(ErrorFormat.wrap(" This flag is unrelated to moving through regions."))
.append(Component.newline())
.append(TextComponent.of("It overrides build checks. If you're unsure what this means, see ")
.append(TextComponent.of("[this documentation page]", TextColor.AQUA)
.clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,
"https://worldguard.readthedocs.io/en/latest/regions/flags/#overrides")))
.append(TextComponent.of(" for more info."))));
if (!sender.isPlayer()) {
sender.printRaw("https://worldguard.readthedocs.io/en/latest/regions/flags/#overrides");
}
}
}
// Also make sure that we can use this flag
@ -694,13 +727,13 @@ public void setParent(CommandContext args, Actor sender) throws CommandException
// Tell the user the current inheritance
RegionPrintoutBuilder printout = new RegionPrintoutBuilder(world.getName(), child, null, sender);
printout.append(LabelFormat.wrap("Inheritance set for region '", child.getId(), "'."));
printout.append(TextComponent.of(" [Undo]").clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
"/rg setparent -w " + world.getName() + " " + child.getId() + (parent != null ? " " + parent.getId() : ""))));
if (parent != null) {
printout.newline();
printout.append(SubtleFormat.wrap("(Current inheritance:")).newline();
printout.appendParentTree(true);
printout.append(SubtleFormat.wrap(")"));
} else {
printout.append(LabelFormat.wrap(" Region is now orphaned."));
}
printout.send(sender);
}

View File

@ -297,8 +297,9 @@ protected static void warnAboutSaveFailures(Actor sender) {
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
Set<RegionManager> failures = container.getSaveFailures();
if (failures.size() > 0) {
String failingList = Joiner.on(", ").join(failures.stream().map(regionManager -> "'" + regionManager.getName() + "'").collect(Collectors.toList()));
if (!failures.isEmpty()) {
String failingList = Joiner.on(", ").join(failures.stream()
.map(regionManager -> "'" + regionManager.getName() + "'").collect(Collectors.toList()));
sender.print(TextComponent.of("(Warning: The background saving of region data is failing for these worlds: " + failingList + ". " +
"Your changes are getting lost. See the server log for more information.)", TextColor.GOLD));

View File

@ -22,8 +22,10 @@
import com.sk89q.squirrelid.cache.ProfileCache;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.component.ErrorFormat;
import com.sk89q.worldedit.util.formatting.component.LabelFormat;
import com.sk89q.worldedit.util.formatting.component.MessageBox;
import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
import com.sk89q.worldedit.util.formatting.component.TextComponentProducer;
import com.sk89q.worldedit.util.formatting.text.Component;
@ -142,8 +144,8 @@ public void appendFlagsList(boolean useColors) {
flagString = flag.getName() + " -g " + group + ": ";
}
TextComponent flagText = TextComponent.of(flagString, useColors ? TextColor.YELLOW : TextColor.WHITE)
.append(TextComponent.of(String.valueOf(val)));
TextComponent flagText = TextComponent.of(flagString, useColors ? TextColor.GOLD : TextColor.WHITE)
.append(TextComponent.of(String.valueOf(val), useColors? TextColor.YELLOW : TextColor.WHITE));
if (perms != null && perms.maySetFlag(region, flag)) {
flagText = flagText.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to set flag")))
.clickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND,
@ -206,9 +208,9 @@ public void appendParentTree(boolean useColors) {
// Put symbol for child
if (indent != 0) {
for (int i = 0; i < indent; i++) {
namePrefix.append(" ");
namePrefix.append(" ");
}
namePrefix.append("\u2517"); //
namePrefix.append("\u2937"); //
}
// Put name
@ -230,8 +232,8 @@ public void appendParentTree(boolean useColors) {
if (last != null && cur.equals(region) && perms != null && perms.maySetParent(cur, last)) {
builder.append(Component.space());
builder.append(TextComponent.of("[X]", TextColor.RED)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to remove parent")))
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/rg setparent -w " + world + " " + cur.getId())));
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to unlink parent")))
.clickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/rg setparent -w " + world + " " + cur.getId())));
}
last = cur;
@ -300,11 +302,16 @@ public void appendBounds() {
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/rg select " + region.getId()));
}
builder.append(bound);
if (perms != null && perms.mayTeleportTo(region) && region.getFlag(Flags.TELE_LOC) != null) {
builder.append(Component.space()).append(TextComponent.of("[Teleport]", TextColor.GRAY)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to teleport")))
final Location teleFlag = region.getFlag(Flags.TELE_LOC);
if (perms != null && perms.mayTeleportTo(region) && teleFlag != null) {
builder.append(Component.space().append(TextComponent.of("[Teleport]", TextColor.GRAY)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
TextComponent.of("Click to teleport").append(Component.newline()).append(
TextComponent.of(teleFlag.getBlockY() + ", "
+ teleFlag.getBlockY() + ", "
+ teleFlag.getBlockZ()))))
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
"/rg tp -w " + world + " " + region.getId())));
"/rg tp -w " + world + " " + region.getId()))));
}
newline();
@ -322,13 +329,6 @@ private void appendPriorityComponent(ProtectedRegion rg) {
}
private void appendRegionInformation() {
TextComponent format = SubtleFormat.wrap(
"\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550",
" Region Info ",
"\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550"
);
builder.append(format);
newline();
appendBasics();
appendFlags();
appendParents();
@ -342,8 +342,9 @@ private void appendRegionInformation() {
@Override
public TextComponent call() {
MessageBox box = new MessageBox("Region Info", builder);
appendRegionInformation();
return toComponent();
return box.create();
}
/**

View File

@ -23,8 +23,8 @@
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.squirrelid.Profile;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
@ -33,7 +33,6 @@
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.internal.permission.RegionPermissionModel;
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
@ -56,6 +55,8 @@ public class RegionLister implements Callable<Integer> {
private final String world;
private OwnerMatcher ownerMatcher;
private int page;
private String playerName;
private boolean nameOnly;
public RegionLister(RegionManager manager, Actor sender, String world) {
checkNotNull(manager);
@ -75,21 +76,9 @@ public void setPage(int page) {
this.page = page;
}
public void filterOwnedByPlayer(final Player player) {
ownerMatcher = new OwnerMatcher() {
@Override
public String getName() {
return player.getName();
}
@Override
public boolean isContainedWithin(DefaultDomain domain) throws CommandException {
return domain.contains(player.getUniqueId());
}
};
}
public void filterOwnedByName(String name, boolean nameOnly) {
this.playerName = name;
this.nameOnly = nameOnly;
if (nameOnly) {
filterOwnedByName(name);
} else {
@ -105,7 +94,7 @@ public String getName() {
}
@Override
public boolean isContainedWithin(DefaultDomain domain) throws CommandException {
public boolean isContainedWithin(DefaultDomain domain) {
return domain.contains(name);
}
};
@ -158,59 +147,41 @@ public Integer call() throws Exception {
// Build a list of regions to show
List<RegionListEntry> entries = new ArrayList<>();
int index = 0;
for (Map.Entry<String, ProtectedRegion> rg : regions.entrySet()) {
RegionListEntry entry = new RegionListEntry(rg.getValue(), index++);
// Filtering by owner?
if (ownerMatcher != null) {
ProtectedRegion region = rg.getValue();
entry.isOwner = ownerMatcher.isContainedWithin(region.getOwners());
entry.isMember = ownerMatcher.isContainedWithin(region.getMembers());
if (!entry.isOwner && !entry.isMember) {
continue; // Skip
}
if (rg.getKey().equals("__global__")) {
continue;
}
entries.add(entry);
}
Collections.sort(entries);
final int totalSize = entries.size();
final int pageSize = 10;
final int pages = (int) Math.ceil(totalSize / (float) pageSize);
sender.print((ownerMatcher == null ? "Regions (page " : "Regions for " + ownerMatcher.getName() + " (page ")
+ (page + 1) + " of " + pages + "):");
RegionPermissionModel perms = new RegionPermissionModel(sender);
if (page < pages) {
// Print
for (int i = page * pageSize; i < page * pageSize + pageSize; i++) {
if (i >= totalSize) {
break;
}
final RegionListEntry entry = entries.get(i);
final TextComponent.Builder builder = TextComponent.builder(entry.toString());
if (perms.mayLookup(entry.region)) {
builder.append(Component.space().append(TextComponent.of("[Info]", TextColor.GRAY)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click for info")))
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
"/rg info -w " + world + " " + entry.region.getId()))));
}
if (perms.mayTeleportTo(entry.region) && entry.region.getFlag(Flags.TELE_LOC) != null) {
builder.append(Component.space().append(TextComponent.of("[Teleport]", TextColor.GRAY)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to teleport")))
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
"/rg tp -w " + world + " " + entry.region.getId()))));
}
sender.print(builder.build());
final ProtectedRegion region = rg.getValue();
final RegionListEntry entry = new RegionListEntry(region);
if (entry.matches(ownerMatcher)) {
entries.add(entry);
}
}
if (ownerMatcher == null) {
Collections.sort(entries);
}
// insert global on top
if (regions.containsKey("__global__")) {
final RegionListEntry entry = new RegionListEntry(regions.get("__global__"));
if (entry.matches(ownerMatcher)) {
entries.add(0, entry);
}
}
// unless we're matching owners, then sort by ownership
if (ownerMatcher != null) {
Collections.sort(entries);
}
RegionPermissionModel perms = sender.isPlayer() ? new RegionPermissionModel(sender) : null;
String title = ownerMatcher == null ? "Regions" : "Regions for " + ownerMatcher.getName();
String cmd = "/rg list -w " + world
+ (playerName != null ? " -p " + playerName : "")
+ (nameOnly ? " -n" : "")
+ " %page%";
PaginationBox box = new RegionListBox(title, cmd, perms, entries, world);
sender.print(box.create(page));
return page;
}
@ -220,37 +191,81 @@ private interface OwnerMatcher {
boolean isContainedWithin(DefaultDomain domain) throws CommandException;
}
private class RegionListEntry implements Comparable<RegionListEntry> {
private static final class RegionListEntry implements Comparable<RegionListEntry> {
private final ProtectedRegion region;
private final int index;
boolean isOwner;
boolean isMember;
private boolean isOwner;
private boolean isMember;
private RegionListEntry(ProtectedRegion rg, int index) {
private RegionListEntry(ProtectedRegion rg) {
this.region = rg;
this.index = index;
}
public boolean matches(OwnerMatcher matcher) throws CommandException {
return matcher == null
|| (isOwner = matcher.isContainedWithin(region.getOwners()))
|| (isMember = matcher.isContainedWithin(region.getMembers()));
}
public ProtectedRegion getRegion() {
return region;
}
public boolean isOwner() {
return isOwner;
}
public boolean isMember() {
return isMember;
}
@Override
public int compareTo(RegionListEntry o) {
if (isOwner != o.isOwner) {
return isOwner ? 1 : -1;
return isOwner ? -1 : 1;
}
if (isMember != o.isMember) {
return isMember ? 1 : -1;
return isMember ? -1 : 1;
}
return region.getId().compareTo(o.region.getId());
}
}
private static class RegionListBox extends PaginationBox {
private final RegionPermissionModel perms;
private final List<RegionListEntry> entries;
private String world;
RegionListBox(String title, String cmd, RegionPermissionModel perms, List<RegionListEntry> entries, String world) {
super(title, cmd);
this.perms = perms;
this.entries = entries;
this.world = world;
}
@Override
public String toString() {
if (isOwner) {
return (index + 1) + ". +" + region.getId();
} else if (isMember) {
return (index + 1) + ". -" + region.getId();
} else {
return (index + 1) + ". " + region.getId();
public Component getComponent(int number) {
final RegionListEntry entry = entries.get(number);
final TextComponent.Builder builder = TextComponent.builder(number + 1 + ".").color(TextColor.LIGHT_PURPLE);
if (entry.isOwner()) {
builder.append(Component.space()).append(TextComponent.of("+", TextColor.DARK_AQUA)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Region Owner", TextColor.GOLD))));
} else if (entry.isMember()) {
builder.append(Component.space()).append(TextComponent.of("-", TextColor.AQUA)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Region Member", TextColor.GOLD))));
}
builder.append(Component.space()).append(TextComponent.of(entry.getRegion().getId(), TextColor.GOLD));
if (perms != null && perms.mayLookup(entry.region)) {
builder.append(Component.space().append(TextComponent.of("[Info]", TextColor.GRAY)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click for info")))
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
"/rg info -w " + world + " " + entry.region.getId()))));
}
return builder.build();
}
@Override
public int getComponentsSize() {
return entries.size();
}
}
}

View File

@ -171,13 +171,13 @@ public final class Flags {
private Flags() {
}
public static <T extends Flag> T register(final T flag) throws FlagConflictException {
private static <T extends Flag<?>> T register(final T flag) throws FlagConflictException {
WorldGuard.getInstance().getFlagRegistry().register(flag);
return flag;
}
@Nullable
public static Flag get(final String id) {
public static Flag<?> get(final String id) {
return WorldGuard.getInstance().getFlagRegistry().get(id);
}
@ -189,8 +189,9 @@ public static Flag get(final String id) {
* @return a flag, or null
*/
public static Flag<?> fuzzyMatchFlag(FlagRegistry flagRegistry, String id) {
final String compId = id.replace("-", "");
for (Flag<?> flag : flagRegistry) {
if (flag.getName().replace("-", "").equalsIgnoreCase(id.replace("-", ""))) {
if (flag.getName().replace("-", "").equalsIgnoreCase(compId)) {
return flag;
}
}

View File

@ -19,12 +19,15 @@
package com.sk89q.worldguard.protection.flags;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.NullWorld;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldguard.WorldGuard;
import javax.annotation.Nullable;
import java.util.Optional;
/**
* A location that stores the name of the world in case the world is unloaded.
@ -38,16 +41,26 @@ private static World findWorld(String worldName) {
return WorldGuard.getInstance().getPlatform().getMatcher().getWorldByName(worldName);
}
public LazyLocation(String worldName, Vector3 position, float yaw, float pitch) {
super(findWorld(worldName), position, yaw, pitch);
LazyLocation(String worldName, Vector3 position, float yaw, float pitch) {
super(Optional.ofNullable(findWorld(worldName)).orElse(NullWorld.getInstance()), position, yaw, pitch);
this.worldName = worldName;
}
public LazyLocation(String worldName, Vector3 position) {
super(findWorld(worldName), position);
LazyLocation(String worldName, Vector3 position) {
super(Optional.ofNullable(findWorld(worldName)).orElse(NullWorld.getInstance()), position);
this.worldName = worldName;
}
@Override
public Extent getExtent() {
if (super.getExtent() != NullWorld.getInstance()) {
return super.getExtent();
}
// try loading the world again now
// if it fails it will throw an error later (presumably when trying to teleport someone there)
return Optional.ofNullable(findWorld(getWorldName())).orElse(NullWorld.getInstance());
}
public String getWorldName() {
return worldName;
}
@ -56,6 +69,7 @@ public LazyLocation setAngles(float yaw, float pitch) {
return new LazyLocation(worldName, toVector(), yaw, pitch);
}
@Override
public LazyLocation setPosition(Vector3 position) {
return new LazyLocation(worldName, position, getYaw(), getPitch());
}
@ -71,10 +85,12 @@ public LazyLocation add(double x, double y, double z) {
@Override
public String toString() {
if (getPitch() == 0 && getYaw() == 0) {
return String.join(", ", "World=" + worldName, "X=" + getX(), "Y=" + getY(), "Z=" + getZ());
return String.join(", ", worldName,
String.valueOf((int) getX()), String.valueOf((int) getY()), String.valueOf((int) getZ()));
} else {
return String.join(", ", "World=" + worldName, "X=" + getX(), "Y=" + getY(),
"Z=" + getZ(), "Pitch=" + getPitch(), "Yaw=" + getYaw());
return String.join(", ", worldName,
String.valueOf((int) getX()), String.valueOf((int) getY()), String.valueOf((int) getZ()),
String.valueOf((int) getPitch()), String.valueOf((int) getYaw()));
}
}
}

View File

@ -261,32 +261,11 @@ public ProtectedRegion getRegion(String id) {
}
/**
* Matches a region using either the pattern {@code #{region_index}} or
* simply by the exact name of the region.
*
* @param pattern the pattern
* @return a region
* @deprecated Use exact ids with {@link #getRegion}
*/
@Nullable
@Deprecated
public ProtectedRegion matchRegion(String pattern) {
checkNotNull(pattern);
if (pattern.startsWith("#")) {
int index;
try {
index = Integer.parseInt(pattern.substring(1)) - 1;
} catch (NumberFormatException e) {
return null;
}
for (ProtectedRegion region : this.index.values()) {
if (index == 0) {
return region;
}
--index;
}
return null;
}
return getRegion(pattern);
}

View File

@ -140,22 +140,16 @@ public DefaultDomain call() throws UnresolvedNamesException {
}
public Function<DefaultDomain, DefaultDomain> createAddAllFunction(final DefaultDomain target) {
return new Function<DefaultDomain, DefaultDomain>() {
@Override
public DefaultDomain apply(@Nullable DefaultDomain domain) {
target.addAll(domain);
return domain;
}
return domain -> {
target.addAll(domain);
return domain;
};
}
public Function<DefaultDomain, DefaultDomain> createRemoveAllFunction(final DefaultDomain target) {
return new Function<DefaultDomain, DefaultDomain>() {
@Override
public DefaultDomain apply(@Nullable DefaultDomain domain) {
target.removeAll(domain);
return domain;
}
return domain -> {
target.removeAll(domain);
return domain;
};
}

View File

@ -23,9 +23,9 @@
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.internal.command.exception.ExceptionConverterHelper;
import com.sk89q.worldedit.internal.command.exception.ExceptionMatch;
import com.sk89q.worldedit.util.auth.AuthorizationException;
import com.sk89q.worldedit.util.command.parametric.ExceptionConverterHelper;
import com.sk89q.worldedit.util.command.parametric.ExceptionMatch;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.managers.storage.StorageException;
import com.sk89q.worldguard.protection.util.UnresolvedNamesException;

View File

@ -27,6 +27,7 @@
import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.weather.WeatherType;
@ -43,11 +44,11 @@ public class TestPlayer extends AbstractPlayerActor implements LocalPlayer {
private final UUID uuid = UUID.randomUUID();
private final String name;
private final Set<String> groups = new HashSet<>();
public TestPlayer(String name) {
this.name = name;
}
public void addGroup(String group) {
groups.add(group.toLowerCase());
}
@ -193,7 +194,7 @@ public void printError(String msg) {
}
@Override
public void print(TextComponent component) {
public void print(Component component) {
}