Skip to content

Commit 95d790b

Browse files
Rework "all regions"
Expect users to be explicit with "all regions in all worlds"
1 parent 971d5e7 commit 95d790b

File tree

1 file changed

+5
-13
lines changed
  • src/main/java/org/skriptlang/skriptworldguard/elements/expressions

1 file changed

+5
-13
lines changed

src/main/java/org/skriptlang/skriptworldguard/elements/expressions/ExprRegions.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
@Name("Regions")
2525
@Description({
26-
"An expression to obtain the regions of all worlds, a specific world, or the region with a specific name in a world.",
26+
"An expression to obtain all regions of a specific world or the region with a specific name in a world.",
2727
"Please note that region names (IDs) are case insensitive."
2828
})
2929
@Example("the region \"region\" in world(\"world\"")
@@ -36,12 +36,12 @@ public static void register(SyntaxRegistry registry) {
3636
.supplier(ExprRegions::new)
3737
.addPatterns("[the] [worldguard] region[s] [named] %strings% [(in|of) %world%]",
3838
"[the] [worldguard] region[s] with [the] (name[s]|id[s]) %strings% [(in|of) %world%]",
39-
"[all [[of] the]|the] [worldguard] regions [(in|of) %-worlds%]")
39+
"[all [[of] the]|the] [worldguard] regions [(in|of) %worlds%]")
4040
.build());
4141
}
4242

4343
private @Nullable Expression<String> ids;
44-
private @Nullable Expression<World> worlds;
44+
private Expression<World> worlds;
4545

4646
@Override
4747
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
@@ -58,13 +58,7 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
5858
protected WorldGuardRegion [] get(Event event) {
5959
List<WorldGuardRegion> regions = new ArrayList<>();
6060
if (ids == null) {
61-
World[] worlds;
62-
if (this.worlds == null) {
63-
worlds = Bukkit.getWorlds().toArray(new World[0]);
64-
} else {
65-
worlds = this.worlds.getArray(event);
66-
}
67-
for (World world : worlds) {
61+
for (World world : this.worlds.getArray(event)) {
6862
regions.addAll(RegionUtils.getRegions(world));
6963
}
7064
} else {
@@ -112,9 +106,7 @@ public String toString(@Nullable Event event, boolean debug) {
112106
}
113107
builder.append(ids);
114108
}
115-
if (worlds != null) {
116-
builder.append("in", worlds);
117-
}
109+
builder.append("in", worlds);
118110
return builder.toString();
119111
}
120112

0 commit comments

Comments
 (0)