Event Waiter
This commit is contained in:
parent
5ce89ae72e
commit
8d26f6969c
3 changed files with 12 additions and 4 deletions
|
|
@ -4,6 +4,7 @@ import com.bbn.hadder.Rethink;
|
||||||
import com.bbn.hadder.commands.general.HelpCommand;
|
import com.bbn.hadder.commands.general.HelpCommand;
|
||||||
import com.bbn.hadder.core.CommandHandler;
|
import com.bbn.hadder.core.CommandHandler;
|
||||||
import com.bbn.hadder.core.Config;
|
import com.bbn.hadder.core.Config;
|
||||||
|
import com.bbn.hadder.utils.EventWaiter;
|
||||||
import com.bbn.hadder.utils.MessageEditor;
|
import com.bbn.hadder.utils.MessageEditor;
|
||||||
import net.dv8tion.jda.api.JDA;
|
import net.dv8tion.jda.api.JDA;
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
|
|
@ -18,14 +19,16 @@ public class CommandEvent extends MessageReceivedEvent {
|
||||||
private CommandHandler commandHandler;
|
private CommandHandler commandHandler;
|
||||||
private HelpCommand helpCommand;
|
private HelpCommand helpCommand;
|
||||||
private MessageEditor messageEditor;
|
private MessageEditor messageEditor;
|
||||||
|
private EventWaiter eventWaiter;
|
||||||
|
|
||||||
public CommandEvent(@Nonnull JDA api, long responseNumber, @Nonnull Message message, Rethink rethink, Config config, CommandHandler commandHandler, HelpCommand helpCommand, MessageEditor messageEditor) {
|
public CommandEvent(@Nonnull JDA api, long responseNumber, @Nonnull Message message, Rethink rethink, Config config, CommandHandler commandHandler, HelpCommand helpCommand, MessageEditor messageEditor, EventWaiter eventWaiter) {
|
||||||
super(api, responseNumber, message);
|
super(api, responseNumber, message);
|
||||||
this.rethink = rethink;
|
this.rethink = rethink;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.commandHandler = commandHandler;
|
this.commandHandler = commandHandler;
|
||||||
this.helpCommand = helpCommand;
|
this.helpCommand = helpCommand;
|
||||||
this.messageEditor = messageEditor;
|
this.messageEditor = messageEditor;
|
||||||
|
this.eventWaiter = eventWaiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rethink getRethink() {
|
public Rethink getRethink() {
|
||||||
|
|
@ -47,4 +50,8 @@ public class CommandEvent extends MessageReceivedEvent {
|
||||||
public MessageEditor getMessageEditor() {
|
public MessageEditor getMessageEditor() {
|
||||||
return messageEditor;
|
return messageEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EventWaiter getEventWaiter() {
|
||||||
|
return eventWaiter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,8 @@ public class EditRulesCommand implements Command {
|
||||||
.build()).queue();
|
.build()).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, event);
|
}, event.getJDA(), event.getAuthor());
|
||||||
}, event);
|
}, event.getJDA(), event.getAuthor());
|
||||||
} else {
|
} else {
|
||||||
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
|
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
|
||||||
"commands.moderation.editrules.error.title", "",
|
"commands.moderation.editrules.error.title", "",
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.bbn.hadder.Rethink;
|
||||||
import com.bbn.hadder.commands.Command;
|
import com.bbn.hadder.commands.Command;
|
||||||
import com.bbn.hadder.commands.CommandEvent;
|
import com.bbn.hadder.commands.CommandEvent;
|
||||||
import com.bbn.hadder.commands.general.HelpCommand;
|
import com.bbn.hadder.commands.general.HelpCommand;
|
||||||
|
import com.bbn.hadder.utils.EventWaiter;
|
||||||
import com.bbn.hadder.utils.MessageEditor;
|
import com.bbn.hadder.utils.MessageEditor;
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
|
@ -34,7 +35,7 @@ public class CommandHandler {
|
||||||
if (args.length > 0 && args[0].equals("")) args = new String[0];
|
if (args.length > 0 && args[0].equals("")) args = new String[0];
|
||||||
|
|
||||||
CommandEvent commandEvent = new CommandEvent(event.getJDA(), event.getResponseNumber(), event.getMessage(), rethink,
|
CommandEvent commandEvent = new CommandEvent(event.getJDA(), event.getResponseNumber(), event.getMessage(), rethink,
|
||||||
config, this, helpCommand, new MessageEditor(rethink, event.getAuthor()));
|
config, this, helpCommand, new MessageEditor(rethink, event.getAuthor()), new EventWaiter());
|
||||||
if (cmd.getClass().getAnnotations().length > 0 && !Arrays.asList(cmd.getClass().getAnnotations()).contains(Perms.class)) {
|
if (cmd.getClass().getAnnotations().length > 0 && !Arrays.asList(cmd.getClass().getAnnotations()).contains(Perms.class)) {
|
||||||
for (Perm perm : cmd.getClass().getAnnotation(Perms.class).value()) {
|
for (Perm perm : cmd.getClass().getAnnotation(Perms.class).value()) {
|
||||||
if (!perm.check(commandEvent)) {
|
if (!perm.check(commandEvent)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue