Skip to content

Commit

Permalink
inline command registration
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Jan 27, 2024
1 parent 26ca07c commit f5073b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

public interface AnarchyExploitFixesCommand {

Expand All @@ -12,15 +11,15 @@ public interface AnarchyExploitFixesCommand {
static void registerCommands() {
try {
CommandManager commandManager = new CommandManager();

List<AnarchyExploitFixesCommand> allCommands = new ArrayList<>(4);
allCommands.add(new AEFCommand());
allCommands.add(new HelpCommand());
allCommands.add(new SayCommand());
allCommands.add(new ToggleConnectionMsgsCommand());

allCommands.forEach(toParse -> {
if (toParse.shouldRegister()) commandManager.parser().parse(toParse);
Set.of(
new AEFCommand(),
new HelpCommand(),
new SayCommand(),
new ToggleConnectionMsgsCommand()
).forEach(toParse -> {
if (toParse.shouldRegister()) {
commandManager.parser().parse(toParse);
}
});
} catch (Exception e) {
AnarchyExploitFixes.getLog().severe("Failed to create command manager! - " + e.getLocalizedMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;

import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;

public interface AnarchyExploitFixesCommand {

Expand All @@ -12,15 +11,15 @@ public interface AnarchyExploitFixesCommand {
static void registerCommands() {
try {
CommandManager commandManager = new CommandManager();

List<AnarchyExploitFixesCommand> allCommands = new ArrayList<>(4);
allCommands.add(new AEFCommand());
allCommands.add(new HelpCommand());
allCommands.add(new SayCommand());
allCommands.add(new ToggleConnectionMsgsCommand());

allCommands.forEach(toParse -> {
if (toParse.shouldRegister()) commandManager.parser().parse(toParse);
Arrays.asList(
new AEFCommand(),
new HelpCommand(),
new SayCommand(),
new ToggleConnectionMsgsCommand()
).forEach(toParse -> {
if (toParse.shouldRegister()) {
commandManager.parser().parse(toParse);
}
});
} catch (Exception e) {
AnarchyExploitFixes.getLog().severe("Failed to create command manager! - " + e.getLocalizedMessage());
Expand Down

0 comments on commit f5073b8

Please sign in to comment.