Skip to content

Commit 55f872d

Browse files
Additional cleanup
1 parent 09325cf commit 55f872d

File tree

11 files changed

+46
-45
lines changed

11 files changed

+46
-45
lines changed

src/main/java/org/skriptlang/skriptworldguard/elements/conditions/CondCanBuildInRegions.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import ch.njol.skript.doc.Description;
66
import ch.njol.skript.doc.Example;
77
import ch.njol.skript.doc.Name;
8-
import ch.njol.skript.doc.RequiredPlugins;
98
import ch.njol.skript.doc.Since;
109
import ch.njol.skript.lang.Condition;
1110
import ch.njol.skript.lang.Expression;
@@ -34,15 +33,16 @@
3433
else:
3534
set the targeted block to the first argument
3635
""")
37-
@RequiredPlugins("WorldGuard 7")
3836
@Since("1.0")
3937
public class CondCanBuildInRegions extends Condition {
4038

4139
public static void register(SyntaxRegistry registry) {
4240
registry.register(SyntaxRegistry.CONDITION, SyntaxInfo.builder(CondCanBuildInRegions.class)
4341
.supplier(CondCanBuildInRegions::new)
44-
.addPatterns(PropertyCondition.getPatterns(PropertyType.BE, "allowed to build (%-directions% %-locations%|[in] %-worldguardregions%)", "players"))
45-
.addPatterns(PropertyCondition.getPatterns(PropertyType.CAN, "build (%-directions% %-locations%|[in] %-worldguardregions%)", "players"))
42+
.addPatterns(PropertyCondition.getPatterns(PropertyType.BE,
43+
"allowed to build (%-directions% %-locations%|[in] %-worldguardregions%)", "players"))
44+
.addPatterns(PropertyCondition.getPatterns(PropertyType.CAN,
45+
"build (%-directions% %-locations%|[in] %-worldguardregions%)", "players"))
4646
.build());
4747
}
4848

src/main/java/org/skriptlang/skriptworldguard/elements/conditions/CondIsRegionMemberOwner.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import ch.njol.skript.doc.Description;
66
import ch.njol.skript.doc.Example;
77
import ch.njol.skript.doc.Name;
8-
import ch.njol.skript.doc.RequiredPlugins;
98
import ch.njol.skript.doc.Since;
109
import ch.njol.skript.lang.Condition;
1110
import ch.njol.skript.lang.Expression;
@@ -29,7 +28,6 @@
2928
message "Welcome back to %region%"
3029
message "%player's name% just entered %region%" to the members of the region
3130
""")
32-
@RequiredPlugins("WorldGuard 7")
3331
@Since("1.0")
3432
public class CondIsRegionMemberOwner extends Condition {
3533

src/main/java/org/skriptlang/skriptworldguard/elements/conditions/CondIsValidRegionId.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import ch.njol.skript.doc.Description;
55
import ch.njol.skript.doc.Example;
66
import ch.njol.skript.doc.Name;
7-
import ch.njol.skript.doc.RequiredPlugins;
87
import ch.njol.skript.doc.Since;
98
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
109
import org.skriptlang.skript.registration.SyntaxRegistry;
@@ -20,7 +19,6 @@
2019
message "<red>'%text-argument%' is not a valid region ID")
2120
# here is where the rest of the command would go :)
2221
""")
23-
@RequiredPlugins("WorldGuard 7")
2422
@Since("1.0")
2523
public class CondIsValidRegionId extends PropertyCondition<String> {
2624

src/main/java/org/skriptlang/skriptworldguard/elements/effects/EffCreateRegion.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,15 @@
3535
"A global region is a region that has no boundaries, meaning it covers the entire world.",
3636
"A cuboid region is the traditional WorldGuard region. It has two points to determine the boundaries.",
3737
"A polygonal region comprises many points. These points are used to draw a two-dimensional shape." +
38-
" Then, with the provided heights, the shape is extended vertically to form the region." +
39-
" At least three points must be provided to create a polygonal region.",
40-
"NOTE: If you do not specify the world for a region, you must be sure that the locations provided all have the SAME world.",
41-
"NOTE: Region IDs are only valid if they contain letters, numbers, underscores, commas, single quotation marks, dashes, pluses, or forward slashes.",
42-
"NOTE: If you attempt to create a region in a world where a region with the same id already exists, that region will be replaced."
38+
" Then, with the provided heights, the shape is extended vertically to form the region." +
39+
" At least three points must be provided to create a polygonal region.",
40+
"Note that if you do not specify the world for a region, you must be sure that the locations provided all have the same world.",
41+
"Note that Region IDs are only valid if they contain letters, numbers, underscores, commas, single quotation marks, dashes, pluses, or forward slashes.",
42+
"Note that if you attempt to create a region in a world where a region with the same ID already exists, that region will be replaced."
4343
})
4444
@Example("create a temporary global region named \"temporary_global_region\" in the player's world")
4545
@Example("create region \"cuboid_region\" in player's world between the location (0, 60, 0) and the location (10, 70, 10)")
4646
@Example("create a polygonal region named \"polygonal_region\" with a minimum height of 10 and a maximum height of 20 with points {points::*}")
47-
@RequiredPlugins("WorldGuard 7")
4847
@Since("1.0")
4948
public class EffCreateRegion extends Effect {
5049

src/main/java/org/skriptlang/skriptworldguard/elements/events/EvtRegionEnterLeave.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@ public static void register(SyntaxRegistry registry) {
3232
"enter[ing] of " + regionPattern,
3333
"region (exit[ing]|leav(e|ing))",
3434
"exit[ing] of " + regionPattern)
35-
.addDescription("Called when a player enters or leaves a region (or the specified region(s))")
35+
.addDescription("Called when a player enters or leaves a region.")
3636
.addExample("""
3737
on region enter:
3838
send "You entered %region%"
3939
""")
40-
.addRequiredPlugin("WorldGuard 7")
4140
.addSince("1.0")
4241
.build());
4342
EventValues.registerEventValue(RegionEnterLeaveEvent.class, WorldGuardRegion.class, RegionEnterLeaveEvent::getRegion);

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@
33
import ch.njol.skript.doc.Description;
44
import ch.njol.skript.doc.Example;
55
import ch.njol.skript.doc.Name;
6-
import ch.njol.skript.doc.RequiredPlugins;
76
import ch.njol.skript.doc.Since;
87
import ch.njol.skript.expressions.base.PropertyExpression;
98
import ch.njol.skript.lang.Expression;
109
import ch.njol.skript.lang.SkriptParser.ParseResult;
1110
import ch.njol.util.Kleenean;
1211
import com.google.common.collect.Iterators;
12+
import org.jetbrains.annotations.NotNull;
1313
import org.jetbrains.annotations.Nullable;
1414
import org.skriptlang.skript.registration.SyntaxRegistry;
1515
import org.skriptlang.skriptworldguard.worldguard.RegionUtils;
1616
import org.skriptlang.skriptworldguard.worldguard.WorldGuardRegion;
1717
import org.bukkit.block.Block;
1818
import org.bukkit.event.Event;
1919

20+
import java.util.Collections;
2021
import java.util.Iterator;
2122

2223
@Name("Blocks of Region")
2324
@Description("An expression that returns all of the blocks in the given regions.")
2425
@Example("set the blocks of {arena} to air")
25-
@RequiredPlugins("WorldGuard 7")
2626
@Since("1.0")
2727
public class ExprBlocksInRegion extends PropertyExpression<WorldGuardRegion, Block> {
2828

@@ -43,9 +43,13 @@ protected Block[] get(Event event, WorldGuardRegion [] regions) {
4343
}
4444

4545
@Override
46-
public Iterator<? extends Block> iterator(Event event) {
46+
public @NotNull Iterator<? extends Block> iterator(Event event) {
4747
//noinspection unchecked
48-
return RegionUtils.getRegionBlockIterator((Iterator<WorldGuardRegion>) getExpr().iterator(event));
48+
Iterator<WorldGuardRegion> regionIterator = (Iterator<WorldGuardRegion>) getExpr().iterator(event);
49+
if (regionIterator == null) {
50+
return Collections.emptyIterator();
51+
}
52+
return RegionUtils.getRegionBlockIterator(regionIterator);
4953
}
5054

5155
@Override

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import ch.njol.skript.doc.Events;
55
import ch.njol.skript.doc.Example;
66
import ch.njol.skript.doc.Name;
7-
import ch.njol.skript.doc.RequiredPlugins;
87
import ch.njol.skript.doc.Since;
98
import ch.njol.skript.expressions.base.EventValueExpression;
109
import com.sk89q.worldguard.session.MoveType;
@@ -19,7 +18,6 @@
1918
if the movement type is swimming:
2019
message "You have swum into %region%!"
2120
""")
22-
@RequiredPlugins("WorldGuard 7")
2321
@Events("Region Enter/Leave")
2422
@Since("1.0")
2523
public class ExprMoveType extends EventValueExpression<MoveType> {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import ch.njol.skript.doc.Events;
55
import ch.njol.skript.doc.Example;
66
import ch.njol.skript.doc.Name;
7-
import ch.njol.skript.doc.RequiredPlugins;
87
import ch.njol.skript.doc.Since;
98
import ch.njol.skript.expressions.base.EventValueExpression;
109
import org.jetbrains.annotations.Nullable;
@@ -18,7 +17,6 @@
1817
on region enter:
1918
send "You have entered %region%"
2019
""")
21-
@RequiredPlugins("WorldGuard 7")
2220
@Events("Region Enter/Leave")
2321
@Since("1.0")
2422
public class ExprRegion extends EventValueExpression<WorldGuardRegion> {

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import ch.njol.skript.doc.Description;
55
import ch.njol.skript.doc.Example;
66
import ch.njol.skript.doc.Name;
7-
import ch.njol.skript.doc.RequiredPlugins;
87
import ch.njol.skript.doc.Since;
98
import ch.njol.skript.expressions.base.PropertyExpression;
109
import ch.njol.skript.lang.Expression;
@@ -34,15 +33,14 @@
3433
on region enter:
3534
message "You have entered %region%. It is owned by %owners of region%."
3635
""")
37-
@RequiredPlugins("WorldGuard 7")
3836
@Since("1.0")
3937
public class ExprRegionMembersOwners extends PropertyExpression<WorldGuardRegion, Object> {
4038

4139
public static void register(SyntaxRegistry registry) {
4240
registry.register(SyntaxRegistry.EXPRESSION, SyntaxInfo.Expression.builder(ExprRegionMembersOwners.class, Object.class)
4341
.priority(DEFAULT_PRIORITY)
44-
.addPatterns(getDefaultPatterns("player (members|:owners)", "worldguardregions"))
45-
.addPatterns(getDefaultPatterns("(member|:owner) groups", "worldguardregions"))
42+
.addPatterns(getPatterns("player (members|:owners)", "worldguardregions"))
43+
.addPatterns(getPatterns("(member|:owner) groups", "worldguardregions"))
4644
.build());
4745
}
4846

@@ -59,7 +57,7 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
5957
}
6058

6159
@Override
62-
protected Object [] get(Event event, WorldGuardRegion [] regions) {
60+
protected Object[] get(Event event, WorldGuardRegion[] regions) {
6361
List<DefaultDomain> domains = new ArrayList<>();
6462
if (isOwners) {
6563
for (WorldGuardRegion region : regions) {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import ch.njol.skript.doc.Description;
44
import ch.njol.skript.doc.Example;
55
import ch.njol.skript.doc.Name;
6-
import ch.njol.skript.doc.RequiredPlugins;
76
import ch.njol.skript.doc.Since;
87
import ch.njol.skript.lang.Expression;
98
import ch.njol.skript.lang.SkriptParser.ParseResult;
@@ -22,7 +21,10 @@
2221
import java.util.List;
2322

2423
@Name("Regions At")
25-
@Description("An expression that returns the regions at the given locations")
24+
@Description({
25+
"An expression to obtain the regions at a specific location.",
26+
"Note that the regions will be returned in ascending order by priority."
27+
})
2628
@Example("""
2729
on right click:
2830
the clicked block is tagged with minecraft tag "all_signs"
@@ -33,7 +35,6 @@
3335
else:
3436
message "You are in: %{_regions::*}%."
3537
""")
36-
@RequiredPlugins("WorldGuard 7")
3738
@Since("1.0")
3839
public class ExprRegionsAt extends SimpleExpression<WorldGuardRegion> {
3940

0 commit comments

Comments
 (0)