mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +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<>();
|
private final HashMap<String, Reconfigurable> RECONFIGURABLE = new HashMap<>();
|
||||||
|
|
||||||
public void registerReconfigurable(String name, Reconfigurable reconfigurable) {
|
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));
|
String.format("Reloadable has been already registered: '%s'", name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printHelp(String name) {
|
public void printHelp(String name) {
|
||||||
RECONFIGURABLE.get(name).printConfigHelp();
|
RECONFIGURABLE.get(name.toLowerCase()).printConfigHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void call(String name, String action, String[] args) {
|
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() {
|
public void printReconfigurables() {
|
||||||
|
|
|
@ -11,8 +11,8 @@ public class ReloadManager {
|
||||||
private final HashMap<String, Reloadable> RELOADABLES = new HashMap<>();
|
private final HashMap<String, Reloadable> RELOADABLES = new HashMap<>();
|
||||||
|
|
||||||
public void registerReloadable(String name, Reloadable reloadable) {
|
public void registerReloadable(String name, Reloadable reloadable) {
|
||||||
VerifyHelper.putIfAbsent(RELOADABLES, name, Objects.requireNonNull(reloadable, "adapter"),
|
VerifyHelper.putIfAbsent(RELOADABLES, name.toLowerCase(), Objects.requireNonNull(reloadable, "adapter"),
|
||||||
String.format("Reloadable has been already registered: '%s'", name));
|
String.format("Reloadable has been already registered: '%s'", name.toLowerCase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadAll() {
|
public void reloadAll() {
|
||||||
|
@ -26,7 +26,7 @@ public void reloadAll() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reload(String name) throws Exception {
|
public void reload(String name) throws Exception {
|
||||||
RELOADABLES.get(name).reload();
|
RELOADABLES.get(name.toLowerCase()).reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printReloadables() {
|
public void printReloadables() {
|
||||||
|
|
|
@ -21,6 +21,7 @@ public void eval(String line, boolean bell) {
|
||||||
String[] args;
|
String[] args;
|
||||||
try {
|
try {
|
||||||
args = CommonHelper.parseCommand(line);
|
args = CommonHelper.parseCommand(line);
|
||||||
|
if(args.length > 0) args[0] = args[0].toLowerCase();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogHelper.error(e);
|
LogHelper.error(e);
|
||||||
return;
|
return;
|
||||||
|
@ -72,8 +73,8 @@ private void readLoop() throws IOException {
|
||||||
|
|
||||||
public void registerCommand(String name, Command command) {
|
public void registerCommand(String name, Command command) {
|
||||||
VerifyHelper.verifyIDName(name);
|
VerifyHelper.verifyIDName(name);
|
||||||
VerifyHelper.putIfAbsent(commands, name, Objects.requireNonNull(command, "command"),
|
VerifyHelper.putIfAbsent(commands, name.toLowerCase(), Objects.requireNonNull(command, "command"),
|
||||||
String.format("Command has been already registered: '%s'", name));
|
String.format("Command has been already registered: '%s'", name.toLowerCase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue