Made prefixes configurable per server
This commit is contained in:
parent
3d950f5fee
commit
b3f9280822
|
|
@ -1,5 +1,6 @@
|
||||||
package com.alttd.proxydiscordlink.bot;
|
package com.alttd.proxydiscordlink.bot;
|
||||||
|
|
||||||
|
import com.alttd.proxydiscordlink.bot.commands.DiscordLink;
|
||||||
import com.alttd.proxydiscordlink.bot.commands.DiscordServerList;
|
import com.alttd.proxydiscordlink.bot.commands.DiscordServerList;
|
||||||
import com.alttd.proxydiscordlink.bot.commands.DiscordStaffList;
|
import com.alttd.proxydiscordlink.bot.commands.DiscordStaffList;
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
|
|
@ -23,7 +24,8 @@ public abstract class DiscordCommand {
|
||||||
commands = new ArrayList<>();
|
commands = new ArrayList<>();
|
||||||
|
|
||||||
loadCommand(new DiscordStaffList(),
|
loadCommand(new DiscordStaffList(),
|
||||||
new DiscordServerList()
|
new DiscordServerList(),
|
||||||
|
new DiscordLink()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,9 @@ import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class BotConfig {
|
public class BotConfig {
|
||||||
|
|
@ -184,6 +186,21 @@ public class BotConfig {
|
||||||
SL_CLICKCOMMAND = getString("commands.staff-list.click-command", SL_CLICKCOMMAND);
|
SL_CLICKCOMMAND = getString("commands.staff-list.click-command", SL_CLICKCOMMAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Map<Long, String> prefixMap = new HashMap<>();
|
||||||
|
|
||||||
|
private static void prefix() {
|
||||||
|
prefixMap.clear();
|
||||||
|
ConfigurationNode node = getNode("prefixes");
|
||||||
|
if (node.getChildrenMap().isEmpty()) {
|
||||||
|
ALogger.warn("No prefixes found in BotConfig, add them to use commands:\n" +
|
||||||
|
"prefixes:\n\t" +
|
||||||
|
"server_id: prefix");
|
||||||
|
}
|
||||||
|
node.getChildrenMap().forEach((key, value) -> {
|
||||||
|
prefixMap.put((Long) key, value.getString());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private static void roles() {
|
private static void roles() {
|
||||||
DiscordRole.cleanDiscordRoles();
|
DiscordRole.cleanDiscordRoles();
|
||||||
ConfigurationNode node = getNode("sync-roles");
|
ConfigurationNode node = getNode("sync-roles");
|
||||||
|
|
@ -195,18 +212,21 @@ public class BotConfig {
|
||||||
"luckperms-name: example\n\t\t" +
|
"luckperms-name: example\n\t\t" +
|
||||||
"display-name: Example Rank\n\t\t" +
|
"display-name: Example Rank\n\t\t" +
|
||||||
"update-to-minecraft: true\n\t\t" +
|
"update-to-minecraft: true\n\t\t" +
|
||||||
|
"update-to-discord: true\n\t\t" +
|
||||||
"announcement: <player> got example rank!");
|
"announcement: <player> got example rank!");
|
||||||
node.getChildrenMap().forEach((key, value) -> {
|
node.getChildrenMap().forEach((key, value) -> {
|
||||||
|
String internalName = value.getString();
|
||||||
long id = value.getNode("role-id").getLong(-1);
|
long id = value.getNode("role-id").getLong(-1);
|
||||||
String luckpermsName = value.getNode("luckperms-name").getString("example");
|
String luckpermsName = value.getNode("luckperms-name").getString("example");
|
||||||
String display_name = value.getNode("display-name").getString("Example");
|
String display_name = value.getNode("display-name").getString("Example");
|
||||||
boolean updateToMinecraft = value.getNode("update-to-minecraft").getBoolean(false);
|
boolean updateToMinecraft = value.getNode("update-to-minecraft").getBoolean(false);
|
||||||
|
boolean updateToDiscord = value.getNode("update-to-discord").getBoolean(false);
|
||||||
String announcement = value.getNode("announcement").getString("<player> got example rank!");
|
String announcement = value.getNode("announcement").getString("<player> got example rank!");
|
||||||
|
|
||||||
if (id == -1)
|
if (id == -1)
|
||||||
ALogger.error("Invalid id in BotConfig for roles.");
|
ALogger.error("Invalid id in BotConfig for roles.");
|
||||||
else
|
else
|
||||||
DiscordRole.addDiscordRole(new DiscordRole(id, luckpermsName, display_name, updateToMinecraft, announcement));
|
DiscordRole.addDiscordRole(new DiscordRole(internalName, id, luckpermsName, display_name, updateToMinecraft, updateToDiscord, announcement));
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user