mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] Команды, Reload/Reconfigurable не зависят от регистра
This commit is contained in:
parent
3d82253308
commit
fee94ff368
3 changed files with 9 additions and 8 deletions
|
@ -11,16 +11,16 @@ public class ReconfigurableManager {
|
|||
private final HashMap<String, Reconfigurable> RECONFIGURABLE = new HashMap<>();
|
||||
|
||||
public void registerReconfigurable(String name, Reconfigurable reconfigurable) {
|
||||
VerifyHelper.putIfAbsent(RECONFIGURABLE, name, Objects.requireNonNull(reconfigurable, "adapter"),
|
||||
VerifyHelper.putIfAbsent(RECONFIGURABLE, name.toLowerCase(), Objects.requireNonNull(reconfigurable, "adapter"),
|
||||
String.format("Reloadable has been already registered: '%s'", name));
|
||||
}
|
||||
|
||||
public void printHelp(String name) {
|
||||
RECONFIGURABLE.get(name).printConfigHelp();
|
||||
RECONFIGURABLE.get(name.toLowerCase()).printConfigHelp();
|
||||
}
|
||||
|
||||
public void call(String name, String action, String[] args) {
|
||||
RECONFIGURABLE.get(name).reconfig(action, args);
|
||||
RECONFIGURABLE.get(name.toLowerCase()).reconfig(action.toLowerCase(), args);
|
||||
}
|
||||
|
||||
public void printReconfigurables() {
|
||||
|
|
|
@ -11,8 +11,8 @@ public class ReloadManager {
|
|||
private final HashMap<String, Reloadable> RELOADABLES = new HashMap<>();
|
||||
|
||||
public void registerReloadable(String name, Reloadable reloadable) {
|
||||
VerifyHelper.putIfAbsent(RELOADABLES, name, Objects.requireNonNull(reloadable, "adapter"),
|
||||
String.format("Reloadable has been already registered: '%s'", name));
|
||||
VerifyHelper.putIfAbsent(RELOADABLES, name.toLowerCase(), Objects.requireNonNull(reloadable, "adapter"),
|
||||
String.format("Reloadable has been already registered: '%s'", name.toLowerCase()));
|
||||
}
|
||||
|
||||
public void reloadAll() {
|
||||
|
@ -26,7 +26,7 @@ public void reloadAll() {
|
|||
}
|
||||
|
||||
public void reload(String name) throws Exception {
|
||||
RELOADABLES.get(name).reload();
|
||||
RELOADABLES.get(name.toLowerCase()).reload();
|
||||
}
|
||||
|
||||
public void printReloadables() {
|
||||
|
|
|
@ -21,6 +21,7 @@ public void eval(String line, boolean bell) {
|
|||
String[] args;
|
||||
try {
|
||||
args = CommonHelper.parseCommand(line);
|
||||
if(args.length > 0) args[0] = args[0].toLowerCase();
|
||||
} catch (Exception e) {
|
||||
LogHelper.error(e);
|
||||
return;
|
||||
|
@ -72,8 +73,8 @@ private void readLoop() throws IOException {
|
|||
|
||||
public void registerCommand(String name, Command command) {
|
||||
VerifyHelper.verifyIDName(name);
|
||||
VerifyHelper.putIfAbsent(commands, name, Objects.requireNonNull(command, "command"),
|
||||
String.format("Command has been already registered: '%s'", name));
|
||||
VerifyHelper.putIfAbsent(commands, name.toLowerCase(), Objects.requireNonNull(command, "command"),
|
||||
String.format("Command has been already registered: '%s'", name.toLowerCase()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue