Premier commit - Inclusion dans le système git
This commit is contained in:
commit
2adde2ef3f
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
.classpath
|
||||
.settings
|
||||
.project
|
||||
bin/
|
||||
12
src/MyMessage.java
Normal file
12
src/MyMessage.java
Normal file
@ -0,0 +1,12 @@
|
||||
import com.bernard.juliaReact.ActionableMessage;
|
||||
|
||||
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent;
|
||||
|
||||
public class MyMessage extends ActionableMessage {
|
||||
|
||||
@ReAction(emotes = "", stackable = false)
|
||||
public void play(MessageReactionAddEvent e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
15
src/com/bernard/juliaReact/ActionableMessage.java
Normal file
15
src/com/bernard/juliaReact/ActionableMessage.java
Normal file
@ -0,0 +1,15 @@
|
||||
package com.bernard.juliaReact;
|
||||
|
||||
public abstract class ActionableMessage {
|
||||
|
||||
|
||||
public boolean isExclusive(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public static @interface ReAction{
|
||||
public boolean stackable();
|
||||
public String[] emotes();
|
||||
public int pos() default -1;
|
||||
}
|
||||
}
|
||||
72
src/com/bernard/juliaReact/ReactCommandRegistrar.java
Normal file
72
src/com/bernard/juliaReact/ReactCommandRegistrar.java
Normal file
@ -0,0 +1,72 @@
|
||||
package com.bernard.juliaReact;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.bernard.discord.api.Discord;
|
||||
|
||||
import net.dv8tion.jda.core.JDA;
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
import net.dv8tion.jda.core.entities.Message;
|
||||
import net.dv8tion.jda.core.entities.MessageReaction.ReactionEmote;
|
||||
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent;
|
||||
|
||||
public class ReactCommandRegistrar {
|
||||
|
||||
JDA api;
|
||||
|
||||
Set<Long> messagesToManage = new HashSet<>();
|
||||
|
||||
public ReactCommandRegistrar(JDA api) {
|
||||
|
||||
}
|
||||
|
||||
public void registerMessage(Message message, ActionableMessage action) {
|
||||
|
||||
//If message registered, unregister it
|
||||
|
||||
}
|
||||
|
||||
public void unregisterMessage(Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Discord(description = "Parse reaction from messageCommands")
|
||||
public void onReaction(MessageReactionAddEvent react) {
|
||||
if(!messagesToManage.contains(react.getMessageIdLong()))
|
||||
return;//Le message n'est pas géré, laissez les réactions tranquiles;
|
||||
}
|
||||
|
||||
public final ReactionEmote toReactionEmote(String s,Guild g) {
|
||||
Matcher m = Pattern.compile("$<:([a-z]+):([0-9]+)>^").matcher(s);
|
||||
if(m.find())
|
||||
return new ReactionEmote(g.getEmoteById(m.group(2)));
|
||||
else
|
||||
return new ReactionEmote(s, null, api);
|
||||
|
||||
}
|
||||
|
||||
public class ActionnableInfos{
|
||||
List<ReactionEmote> managed; //Liste des réactions posées par julia (seulement l'item selectionné pour les loop)
|
||||
List<Method> toLaunch;
|
||||
Set<ReactionEmote> unauthorized; // Liste des réactions non-autorisées (les items non-sélectionnés des loop)
|
||||
boolean exclusive;
|
||||
Map<Integer,List<ReactionEmote>> loops;// <PosInManaged, All the reactions in order (selected included)>
|
||||
|
||||
public ActionnableInfos(ActionableMessage m) {
|
||||
Class<? extends ActionableMessage> clazz = m.getClass();
|
||||
clazz.getName();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public boolean canReact(ReactionEmote e) {
|
||||
return !(unauthorized.contains(e) || exclusive && !managed.contains(e));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user