Skip to content

Commit d43b23e

Browse files
committed
Add maxArgForAware flag to gamerule commands for improved argument handling
1 parent 9fa4772 commit d43b23e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/java/org/mvplugins/multiverse/core/command/context/issueraware/IssuerAwareContextBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ private <I extends IssuerAwareValue> I resolveValue(BukkitCommandExecutionContex
174174

175175
int maxArgForAware = context.getFlagValue("maxArgForAware", Integer.MAX_VALUE);
176176
long argLengthWithoutFlags = context.getArgs().stream()
177-
.takeWhile(value -> !value.startsWith("--") && !value.isEmpty())
177+
.takeWhile(value -> !value.startsWith("-") && !value.isEmpty()) // ignore the flags
178178
.count();
179179

180180
if (resolve.equals("issuerAware") && argLengthWithoutFlags <= maxArgForAware) {

src/main/java/org/mvplugins/multiverse/core/commands/GameruleCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void onGameruleSetCommand(
6767
@Description("{@@mv-core.gamerule.set.value.description}")
6868
GameRuleValue gameRuleValue,
6969

70-
@Flags("resolve=issuerAware")
70+
@Flags("resolve=issuerAware,maxArgForAware=2")
7171
@Syntax("[World or *]")
7272
@Description("{@@mv-core.gamerule.set.world.description}")
7373
LoadedMultiverseWorld[] worlds) {
@@ -114,7 +114,7 @@ void onGameruleResetCommand(
114114
@Description("{@@mv-core.gamerule.reset.gamerule.description}")
115115
GameRule gamerule,
116116

117-
@Flags("resolve=issuerAware")
117+
@Flags("resolve=issuerAware,maxArgForAware=1")
118118
@Syntax("[World or *]")
119119
@Description("{@@mv-core.gamerule.reset.world.description}")
120120
LoadedMultiverseWorld[] worlds) {
@@ -152,7 +152,7 @@ void onGameruleResetCommand(
152152
void onGameruleListCommand(
153153
MVCommandIssuer issuer,
154154

155-
@Flags("resolve=issuerAware")
155+
@Flags("resolve=issuerAware,maxArgForAware=0")
156156
@Syntax("<world>")
157157
@Description("{@@mv-core.gamerule.list.description.world}")
158158
LoadedMultiverseWorld world,

0 commit comments

Comments
 (0)