Skip to content

Commit 8725858

Browse files
committed
remove unused boolean return in action
1 parent f68db0d commit 8725858

File tree

8 files changed

+46
-55
lines changed

8 files changed

+46
-55
lines changed

editor-extra/src/main/java/io/github/projectunified/minigamecore/editor/extra/action/BooleanAction.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ public List<String> complete(EditorActor actor, String[] args) {
3030
* @param actor the actor
3131
* @param value the value
3232
* @param args the arguments
33-
* @return true if the action is executed successfully
3433
*/
35-
public abstract boolean execute(EditorActor actor, boolean value, String[] args);
34+
public abstract void execute(EditorActor actor, boolean value, String[] args);
3635

3736
@Override
38-
public boolean execute(EditorActor actor, String[] args) {
37+
public void execute(EditorActor actor, String[] args) {
3938
if (args.length < 1) {
40-
return actor.sendUsage(this);
39+
actor.sendUsage(this);
40+
return;
4141
}
42-
return execute(actor, Boolean.parseBoolean(args[0]), Arrays.copyOfRange(args, 1, args.length));
42+
execute(actor, Boolean.parseBoolean(args[0]), Arrays.copyOfRange(args, 1, args.length));
4343
}
4444
}

editor-extra/src/main/java/io/github/projectunified/minigamecore/editor/extra/action/EnumAction.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ public EnumAction(Class<T> enumClass) {
3232
* @param actor the actor
3333
* @param value the value
3434
* @param args the arguments
35-
* @return true if the action is executed successfully
3635
*/
37-
public abstract boolean execute(EditorActor actor, T value, String[] args);
36+
public abstract void execute(EditorActor actor, T value, String[] args);
3837

3938
@Override
4039
public String usage() {
@@ -50,16 +49,16 @@ public List<String> complete(EditorActor actor, String[] args) {
5049
}
5150

5251
@Override
53-
public boolean execute(EditorActor actor, String[] args) {
52+
public void execute(EditorActor actor, String[] args) {
5453
if (args.length < 1) {
55-
return actor.sendUsage(this);
54+
actor.sendUsage(this);
55+
return;
5656
}
5757
try {
5858
T value = Enum.valueOf(enumClass, args[0].toUpperCase(Locale.ROOT));
59-
return execute(actor, value, args);
59+
execute(actor, value, args);
6060
} catch (IllegalArgumentException e) {
6161
actor.sendMessage("Invalid value: " + args[0], false);
62-
return false;
6362
}
6463
}
6564
}

editor-extra/src/main/java/io/github/projectunified/minigamecore/editor/extra/action/NumberAction.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ public List<String> complete(EditorActor actor, String[] args) {
3434
* @param actor the actor
3535
* @param value the value
3636
* @param args the arguments
37-
* @return true if the action is executed successfully
3837
*/
39-
public abstract boolean execute(EditorActor actor, Number value, String[] args);
38+
public abstract void execute(EditorActor actor, Number value, String[] args);
4039

4140
/**
4241
* Get number suggestions
@@ -49,16 +48,16 @@ public Stream<? extends Number> valueComplete(EditorActor actor) {
4948
}
5049

5150
@Override
52-
public boolean execute(EditorActor actor, String[] args) {
51+
public void execute(EditorActor actor, String[] args) {
5352
if (args.length < 1) {
54-
return actor.sendUsage(this);
53+
actor.sendUsage(this);
54+
return;
5555
}
5656
String value = args[0];
5757
try {
58-
return execute(actor, Double.parseDouble(value), Arrays.copyOfRange(args, 1, args.length));
58+
execute(actor, Double.parseDouble(value), Arrays.copyOfRange(args, 1, args.length));
5959
} catch (NumberFormatException e) {
6060
actor.sendMessage("Invalid Number: " + value, false);
61-
return false;
6261
}
6362
}
6463
}

editor-extra/src/main/java/io/github/projectunified/minigamecore/editor/extra/editor/ListEditor.java

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@ protected ListEditor() {
2424
this.actionMap = new HashMap<>();
2525
this.actionMap.put("add", new EditorAction() {
2626
@Override
27-
public boolean execute(EditorActor actor, String[] args) {
27+
public void execute(EditorActor actor, String[] args) {
2828
T value = create(actor, args);
2929
if (value == null) {
3030
actor.sendMessage("Cannot create (" + Arrays.toString(args) + ")", false);
31-
return false;
31+
return;
3232
}
3333
list.add(value);
3434
actor.sendMessage("Added (" + Arrays.toString(args) + ") at index " + (list.size() - 1), true);
35-
return true;
3635
}
3736

3837
@Override
@@ -52,32 +51,31 @@ public String usage() {
5251
});
5352
this.actionMap.put("edit", new EditorAction() {
5453
@Override
55-
public boolean execute(EditorActor actor, String[] args) {
54+
public void execute(EditorActor actor, String[] args) {
5655
if (args.length < 1) {
57-
return false;
56+
return;
5857
}
5958
int index;
6059
try {
6160
index = Integer.parseInt(args[0]);
6261
} catch (NumberFormatException e) {
6362
actor.sendMessage("Invalid index: " + args[0], false);
64-
return false;
63+
return;
6564
}
6665
if (index < 0 || index >= list.size()) {
6766
actor.sendMessage("Index out of bounds: " + index, false);
68-
return false;
67+
return;
6968
}
7069
T value = list.get(index);
7170
T edited = edit(value, actor, Arrays.copyOfRange(args, 1, args.length));
7271
if (edited == null) {
7372
actor.sendMessage("Cannot edit (" + Arrays.toString(args) + ")", false);
74-
return false;
73+
return;
7574
}
7675
if (edited != value) {
7776
list.set(index, edited);
7877
}
7978
actor.sendMessage("Edited (" + Arrays.toString(args) + ")", true);
80-
return true;
8179
}
8280

8381
@Override
@@ -115,24 +113,23 @@ public String usage() {
115113
});
116114
this.actionMap.put("remove", new EditorAction() {
117115
@Override
118-
public boolean execute(EditorActor actor, String[] args) {
116+
public void execute(EditorActor actor, String[] args) {
119117
if (args.length < 1) {
120-
return false;
118+
return;
121119
}
122120
int index;
123121
try {
124122
index = Integer.parseInt(args[0]);
125123
} catch (NumberFormatException e) {
126124
actor.sendMessage("Invalid index: " + args[0], false);
127-
return false;
125+
return;
128126
}
129127
if (index < 0 || index >= list.size()) {
130128
actor.sendMessage("Index out of bounds: " + index, false);
131-
return false;
129+
return;
132130
}
133131
list.remove(index);
134132
actor.sendMessage("Removed element at index " + index, true);
135-
return true;
136133
}
137134

138135
@Override
@@ -157,42 +154,41 @@ public String usage() {
157154
});
158155
this.actionMap.put("move", new EditorAction() {
159156
@Override
160-
public boolean execute(EditorActor actor, String[] args) {
157+
public void execute(EditorActor actor, String[] args) {
161158
if (args.length < 2) {
162-
return false;
159+
return;
163160
}
164161

165162
int index;
166163
try {
167164
index = Integer.parseInt(args[0]);
168165
} catch (NumberFormatException e) {
169166
actor.sendMessage("Invalid index: " + args[0], false);
170-
return false;
167+
return;
171168
}
172169

173170
int newIndex;
174171
try {
175172
newIndex = Integer.parseInt(args[1]);
176173
} catch (NumberFormatException e) {
177174
actor.sendMessage("Invalid new index: " + args[1], false);
178-
return false;
175+
return;
179176
}
180177

181178
if (index < 0 || index >= list.size()) {
182179
actor.sendMessage("Index out of bounds: " + index, false);
183-
return false;
180+
return;
184181
}
185182

186183
if (newIndex < 0 || newIndex >= list.size()) {
187184
actor.sendMessage("New index out of bounds: " + newIndex, false);
188-
return false;
185+
return;
189186
}
190187

191188
T value = list.get(index);
192189
list.remove(index);
193190
list.add(newIndex, value);
194191
actor.sendMessage("Moved element at index " + index + " to index " + newIndex, true);
195-
return true;
196192
}
197193

198194
@Override

editor-extra/src/main/java/io/github/projectunified/minigamecore/editor/extra/editor/ValueEditor.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ protected ValueEditor() {
2222
this.actionMap = new HashMap<>();
2323
this.actionMap.put("set", new EditorAction() {
2424
@Override
25-
public boolean execute(EditorActor actor, String[] args) {
25+
public void execute(EditorActor actor, String[] args) {
2626
T value = create(actor, args);
2727
if (value == null) {
2828
actor.sendMessage("Cannot create (" + Arrays.toString(args) + ")", false);
29-
return false;
29+
return;
3030
}
3131
ValueEditor.this.value = value;
3232
actor.sendMessage("Set (" + Arrays.toString(args) + ")", true);
33-
return true;
3433
}
3534

3635
@Override
@@ -50,20 +49,19 @@ public Collection<String> complete(EditorActor actor, String[] args) {
5049
});
5150
this.actionMap.put("edit", new EditorAction() {
5251
@Override
53-
public boolean execute(EditorActor actor, String[] args) {
52+
public void execute(EditorActor actor, String[] args) {
5453
if (value == null) {
55-
return false;
54+
return;
5655
}
5756
T edited = edit(value, actor, args);
5857
if (edited == null) {
5958
actor.sendMessage("Cannot edit (" + Arrays.toString(args) + ")", false);
60-
return false;
59+
return;
6160
}
6261
if (edited != value) {
6362
value = edited;
6463
}
6564
actor.sendMessage("Edited (" + Arrays.toString(args) + ")", true);
66-
return true;
6765
}
6866

6967
@Override

editor/src/main/java/io/github/projectunified/minigamecore/editor/Editor.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,19 @@ default Collection<String> complete(EditorActor actor, String[] args) {
7575
}
7676

7777
@Override
78-
default boolean execute(EditorActor actor, String[] args) {
78+
default void execute(EditorActor actor, String[] args) {
7979
if (args.length == 0) {
80-
return actor.sendUsage(this);
80+
actor.sendUsage(this);
81+
return;
8182
}
8283
String command = args[0];
8384
EditorAction action = actions().get(command);
8485
if (action == null) {
85-
return false;
86+
actor.sendMessage("Invalid action: " + command, false);
87+
return;
8688
}
8789
String[] subArgs = new String[args.length - 1];
8890
System.arraycopy(args, 1, subArgs, 0, args.length - 1);
89-
return action.execute(actor, subArgs);
91+
action.execute(actor, subArgs);
9092
}
9193
}

editor/src/main/java/io/github/projectunified/minigamecore/editor/EditorAction.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ public interface EditorAction {
1212
*
1313
* @param actor the actor
1414
* @param args the arguments
15-
* @return true if the action is executed successfully
1615
*/
17-
boolean execute(EditorActor actor, String[] args);
16+
void execute(EditorActor actor, String[] args);
1817

1918
/**
2019
* Get the description of the action

editor/src/main/java/io/github/projectunified/minigamecore/editor/EditorActor.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ public interface EditorActor {
1616
* Send the usage of the action
1717
*
1818
* @param action the action
19-
* @return true if the usage is sent successfully
2019
*/
21-
boolean sendUsage(EditorAction action);
20+
void sendUsage(EditorAction action);
2221

2322
/**
2423
* Send the usage of the editor
2524
*
2625
* @param editor the editor
27-
* @return true if the usage is sent successfully
2826
*/
29-
boolean sendUsage(Editor<?> editor);
27+
void sendUsage(Editor<?> editor);
3028
}

0 commit comments

Comments
 (0)