unfinished commit, may be broken
Signed-off-by: deepCurse <leverplays@gmail.com>
This commit is contained in:
parent
168e45d745
commit
22837cf438
10 changed files with 74 additions and 71 deletions
|
@ -30,7 +30,7 @@ public interface CommandInterface { // TODO rewrite to implement type args?
|
||||||
public abstract HelpPage getHelpPage();
|
public abstract HelpPage getHelpPage();
|
||||||
|
|
||||||
public enum HelpPage {
|
public enum HelpPage {
|
||||||
General, DEV, EGG, Moderation, Fun, Info
|
General, Moderation, Fun, Info, Extra, TESTING, DEV, EGG
|
||||||
}
|
}
|
||||||
|
|
||||||
public default String getHelp() {
|
public default String getHelp() {
|
||||||
|
@ -63,8 +63,7 @@ public interface CommandInterface { // TODO rewrite to implement type args?
|
||||||
runDualCommand(new CommandBlob(blob), argumentMap);
|
runDualCommand(new CommandBlob(blob), argumentMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runDualCommand(CommandBlob blob, HashMap<String, Argument> argumentMap)
|
public void runDualCommand(CommandBlob blob, HashMap<String, Argument> argumentMap) throws Exception;
|
||||||
throws Exception;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package pkg.deepCurse.nopalmo.command.commands;
|
package pkg.deepCurse.nopalmo.command.commands.info;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package pkg.deepCurse.nopalmo.command.commands;
|
package pkg.deepCurse.nopalmo.command.commands.info;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
|
@ -1,30 +1,18 @@
|
||||||
package pkg.deepCurse.nopalmo.command.commands;
|
package pkg.deepCurse.nopalmo.command.commands.info;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.MessageChannel;
|
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||||
import pkg.deepCurse.nopalmo.command.CommandInterface.DirectCommandInterface;
|
import pkg.deepCurse.nopalmo.command.CommandInterface.DualCommandInterface;
|
||||||
import pkg.deepCurse.nopalmo.command.CommandInterface.GuildCommandInterface;
|
|
||||||
import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Global;
|
import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Global;
|
||||||
import pkg.deepCurse.nopalmo.manager.Argument;
|
import pkg.deepCurse.nopalmo.manager.Argument;
|
||||||
import pkg.deepCurse.nopalmo.manager.CommandBlob;
|
import pkg.deepCurse.nopalmo.manager.CommandBlob;
|
||||||
import pkg.deepCurse.nopalmo.manager.DirectCommandBlob;
|
|
||||||
import pkg.deepCurse.nopalmo.manager.GuildCommandBlob;
|
|
||||||
import pkg.deepCurse.nopalmo.utils.UptimePing;
|
import pkg.deepCurse.nopalmo.utils.UptimePing;
|
||||||
|
|
||||||
public class Ping implements GuildCommandInterface, DirectCommandInterface {
|
public class Ping implements DualCommandInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runGuildCommand(GuildCommandBlob blob, HashMap<String, Argument> argumentMap) throws Exception {
|
public void runDualCommand(CommandBlob blob, HashMap<String, Argument> argumentMap) throws Exception {
|
||||||
dualCommand(new CommandBlob(blob), argumentMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void runDirectCommand(DirectCommandBlob blob, HashMap<String, Argument> argumentMap) throws Exception {
|
|
||||||
dualCommand(new CommandBlob(blob), argumentMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void dualCommand(CommandBlob blob, HashMap<String, Argument> argumentMap) throws Exception {
|
|
||||||
|
|
||||||
MessageChannel channel = blob.getChannel();
|
MessageChannel channel = blob.getChannel();
|
||||||
|
|
35
src/pkg/deepCurse/nopalmo/command/commands/info/Prefix.java
Normal file
35
src/pkg/deepCurse/nopalmo/command/commands/info/Prefix.java
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
package pkg.deepCurse.nopalmo.command.commands.info;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import pkg.deepCurse.nopalmo.command.CommandInterface.GuildCommandInterface;
|
||||||
|
import pkg.deepCurse.nopalmo.manager.Argument;
|
||||||
|
import pkg.deepCurse.nopalmo.manager.GuildCommandBlob;
|
||||||
|
|
||||||
|
public class Prefix implements GuildCommandInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getCommandCalls() {
|
||||||
|
return new String[] { "prefix", };
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HelpPage getHelpPage() {
|
||||||
|
return HelpPage.General;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void runGuildCommand(GuildCommandBlob blob, HashMap<String, Argument> argumentList) throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<String, Argument> getArguments() {
|
||||||
|
HashMap<String, Argument> args = new HashMap<String, Argument>();
|
||||||
|
|
||||||
|
args.put("prefix", new Argument("prefix").setIsWildcard(true));
|
||||||
|
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,6 +8,8 @@ public class Reactions {
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
insert("galaxyThumb", 801657838358495232L);
|
insert("galaxyThumb", 801657838358495232L);
|
||||||
|
insert("kirbo_wadafuq", 799633705068003338L);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void insert(String input, long id) {
|
public static void insert(String input, long id) {
|
||||||
|
|
|
@ -21,6 +21,8 @@ public class Argument {
|
||||||
private String argName = null;
|
private String argName = null;
|
||||||
private Argument[] subArgs = null;
|
private Argument[] subArgs = null;
|
||||||
private boolean requiresPrefix = false;
|
private boolean requiresPrefix = false;
|
||||||
|
private Boolean isWildcard;
|
||||||
|
|
||||||
public static final String argumentPrefix = "-"; // This exists for the sole reason of customization and will
|
public static final String argumentPrefix = "-"; // This exists for the sole reason of customization and will
|
||||||
// generally not change, ever, its recommended you keep it to
|
// generally not change, ever, its recommended you keep it to
|
||||||
// something other than empty to help ensure that what the user
|
// something other than empty to help ensure that what the user
|
||||||
|
@ -109,6 +111,15 @@ public class Argument {
|
||||||
this.requiresPrefix = bool;
|
this.requiresPrefix = bool;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Argument setIsWildcard(Boolean bool) {
|
||||||
|
this.isWildcard = bool;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getIsWildcard() {
|
||||||
|
return isWildcard;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getPrefixRequirement() {
|
public boolean getPrefixRequirement() {
|
||||||
return this.requiresPrefix;
|
return this.requiresPrefix;
|
||||||
|
@ -116,7 +127,7 @@ public class Argument {
|
||||||
|
|
||||||
public interface RunnableArg {
|
public interface RunnableArg {
|
||||||
|
|
||||||
public void run();
|
public void run(Argument[] argArray);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package pkg.deepCurse.nopalmo.manager;
|
package pkg.deepCurse.nopalmo.manager;
|
||||||
|
|
||||||
public abstract class CommandManager {
|
public abstract class CommandManager {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import pkg.deepCurse.nopalmo.command.CommandInterface.DirectCommandInterface;
|
import pkg.deepCurse.nopalmo.command.CommandInterface.DirectCommandInterface;
|
||||||
import pkg.deepCurse.nopalmo.command.commands.Ping;
|
import pkg.deepCurse.nopalmo.command.commands.info.Ping;
|
||||||
import pkg.deepCurse.nopalmo.core.Boot;
|
import pkg.deepCurse.nopalmo.core.Boot;
|
||||||
import pkg.deepCurse.nopalmo.database.DatabaseTools;
|
import pkg.deepCurse.nopalmo.database.DatabaseTools;
|
||||||
import pkg.deepCurse.nopalmo.global.Tools;
|
import pkg.deepCurse.nopalmo.global.Tools;
|
||||||
|
@ -29,7 +29,6 @@ public class DirectCommandManager extends CommandManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
|
|
||||||
addCommand(new Ping());
|
addCommand(new Ping());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -113,25 +112,6 @@ public class DirectCommandManager extends CommandManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// if (guildCommand.getArguments() != null) {
|
|
||||||
//
|
|
||||||
// String newArg = x;
|
|
||||||
//
|
|
||||||
// if (!newArg.startsWith(Argument.argumentPrefix)) {
|
|
||||||
// if (guildCommand.getArguments().get(newArg)!=null) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (guildCommand.getArguments().containsKey(newArg)) {
|
|
||||||
//
|
|
||||||
// argumentList.put(guildCommand.getArguments().get(newArg).getArgName(),
|
|
||||||
// guildCommand.getArguments().get(newArg));
|
|
||||||
// } else
|
|
||||||
//
|
|
||||||
// argumentList.put(newArg, new Argument(newArg));
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,10 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
import pkg.deepCurse.nopalmo.command.CommandInterface.GuildCommandInterface;
|
import pkg.deepCurse.nopalmo.command.CommandInterface.GuildCommandInterface;
|
||||||
import pkg.deepCurse.nopalmo.command.commands.Git;
|
import pkg.deepCurse.nopalmo.command.commands.info.Git;
|
||||||
import pkg.deepCurse.nopalmo.command.commands.Help;
|
import pkg.deepCurse.nopalmo.command.commands.info.Help;
|
||||||
import pkg.deepCurse.nopalmo.command.commands.Ping;
|
import pkg.deepCurse.nopalmo.command.commands.info.Ping;
|
||||||
|
import pkg.deepCurse.nopalmo.command.commands.info.Prefix;
|
||||||
import pkg.deepCurse.nopalmo.core.Boot;
|
import pkg.deepCurse.nopalmo.core.Boot;
|
||||||
import pkg.deepCurse.nopalmo.database.DatabaseTools;
|
import pkg.deepCurse.nopalmo.database.DatabaseTools;
|
||||||
import pkg.deepCurse.nopalmo.global.Tools;
|
import pkg.deepCurse.nopalmo.global.Tools;
|
||||||
|
@ -34,6 +35,7 @@ public class GuildCommandManager extends CommandManager {
|
||||||
addCommand(new Help(this));
|
addCommand(new Help(this));
|
||||||
addCommand(new Ping());
|
addCommand(new Ping());
|
||||||
addCommand(new Git());
|
addCommand(new Git());
|
||||||
|
addCommand(new Prefix());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCommand(GuildCommandInterface c) {
|
private void addCommand(GuildCommandInterface c) {
|
||||||
|
@ -81,8 +83,10 @@ public class GuildCommandManager extends CommandManager {
|
||||||
boolean printTime = false;
|
boolean printTime = false;
|
||||||
byte argSkipCount = 0;
|
byte argSkipCount = 0;
|
||||||
boolean remainsValid = true;
|
boolean remainsValid = true;
|
||||||
|
boolean isWildCard = false;
|
||||||
|
|
||||||
for (String x : args) {
|
for (String x : args) {
|
||||||
|
boolean taken = false;
|
||||||
x = x.toLowerCase();
|
x = x.toLowerCase();
|
||||||
switch (x) {
|
switch (x) {
|
||||||
case "\\time":
|
case "\\time":
|
||||||
|
@ -102,47 +106,33 @@ public class GuildCommandManager extends CommandManager {
|
||||||
if (x.startsWith(Argument.argumentPrefix)) {
|
if (x.startsWith(Argument.argumentPrefix)) {
|
||||||
|
|
||||||
String pre = x.substring(Argument.argumentPrefix.length());
|
String pre = x.substring(Argument.argumentPrefix.length());
|
||||||
|
|
||||||
if (guildCommand.getArguments().keySet().contains(pre)) {
|
if (guildCommand.getArguments().keySet().contains(pre)) {
|
||||||
argumentList.put(pre, guildCommand.getArguments().get(pre));
|
argumentList.put(pre, guildCommand.getArguments().get(pre));
|
||||||
|
taken = true;
|
||||||
} else {
|
} else {
|
||||||
Tools.wrongUsage(guildMessage.getChannel(), guildCommand);
|
Tools.wrongUsage(guildMessage.getChannel(), guildCommand);
|
||||||
remainsValid = false;
|
remainsValid = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// if (!guildCommand.getArguments().get(x).getIsWildcard()) {
|
||||||
if (guildCommand.getArguments().get(x).getPrefixRequirement()) {
|
if (guildCommand.getArguments().get(x).getPrefixRequirement()) {
|
||||||
Tools.wrongUsage(guildMessage.getChannel(), guildCommand);
|
Tools.wrongUsage(guildMessage.getChannel(), guildCommand);
|
||||||
remainsValid = false;
|
remainsValid = false;
|
||||||
} else {
|
} else {
|
||||||
argumentList.put(x, guildCommand.getArguments().get(x));
|
argumentList.put(x, guildCommand.getArguments().get(x));
|
||||||
|
taken = true;
|
||||||
}
|
}
|
||||||
|
// } else {
|
||||||
|
// argumentList.put(x, guildCommand.getArguments().get(x));
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// if (guildCommand.getArguments() != null) {
|
|
||||||
//
|
|
||||||
// String newArg = x;
|
|
||||||
//
|
|
||||||
// if (!newArg.startsWith(Argument.argumentPrefix)) {
|
|
||||||
// if (guildCommand.getArguments().get(newArg)!=null) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (guildCommand.getArguments().containsKey(newArg)) {
|
|
||||||
//
|
|
||||||
// argumentList.put(guildCommand.getArguments().get(newArg).getArgName(),
|
|
||||||
// guildCommand.getArguments().get(newArg));
|
|
||||||
// } else
|
|
||||||
//
|
|
||||||
// argumentList.put(newArg, new Argument(newArg));
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
commandBlob.setCommandManager(this);
|
commandBlob.setCommandManager(this);
|
||||||
|
|
||||||
if (remainsValid) {
|
if (remainsValid) {
|
||||||
guildCommand.runGuildCommand(commandBlob, argumentList);
|
guildCommand.runGuildCommand(commandBlob, argumentList);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue