Improved CommandsManager to use CompositeCommand

This removes the requirement for addons to cast to CompositeCommand when
getting commands from the CommandsManager.

Removed unused imports.
This commit is contained in:
Tastybento 2018-02-14 22:38:43 -08:00
parent 4aaf559704
commit 80c2f4178d
5 changed files with 16 additions and 10 deletions

View File

@ -7,8 +7,8 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Optional;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;

View File

@ -1,7 +1,11 @@
package us.tastybento.bskyblock.database.objects;
import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;

View File

@ -1,6 +1,10 @@
package us.tastybento.bskyblock.database.objects;
import java.util.*;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;

View File

@ -4,15 +4,16 @@ import java.lang.reflect.Field;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
public final class CommandsManager {
private static final boolean DEBUG = false;
private HashMap<String, Command> commands = new HashMap<>();
private HashMap<String, CompositeCommand> commands = new HashMap<>();
public void registerCommand(Command command) {
public void registerCommand(CompositeCommand command) {
if (DEBUG) {
Bukkit.getLogger().info("DEBUG: registering command - " + command.getLabel());
}
@ -29,7 +30,7 @@ public final class CommandsManager {
}
}
public Command getCommand(String command) {
public CompositeCommand getCommand(String command) {
return commands.get(command);
}

View File

@ -5,15 +5,12 @@ package us.tastybento.bskyblock.managers;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import org.junit.Before;
import org.junit.Test;