Config conversion
This commit is contained in:
parent
fdcab1acb2
commit
7866ddbe06
16 changed files with 87 additions and 128 deletions
|
@ -115,7 +115,7 @@ public final class DPUtils {
|
||||||
*/
|
*/
|
||||||
public static String botmention() {
|
public static String botmention() {
|
||||||
if (DiscordPlugin.plugin == null) return "#bot";
|
if (DiscordPlugin.plugin == null) return "#bot";
|
||||||
return channelMention(DiscordPlugin.plugin.commandChannel().get());
|
return channelMention(DiscordPlugin.plugin.commandChannel.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -88,28 +88,28 @@ public abstract class DiscordConnectedPlayer extends DiscordSenderBase implement
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean teleport(Location location) {
|
public boolean teleport(Location location) {
|
||||||
if (module.allowFakePlayerTeleports().get())
|
if (module.allowFakePlayerTeleports.get())
|
||||||
this.location = location;
|
this.location = location;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
|
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
|
||||||
if (module.allowFakePlayerTeleports().get())
|
if (module.allowFakePlayerTeleports.get())
|
||||||
this.location = location;
|
this.location = location;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean teleport(Entity destination) {
|
public boolean teleport(Entity destination) {
|
||||||
if (module.allowFakePlayerTeleports().get())
|
if (module.allowFakePlayerTeleports.get())
|
||||||
this.location = destination.getLocation();
|
this.location = destination.getLocation();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean teleport(Entity destination, PlayerTeleportEvent.TeleportCause cause) {
|
public boolean teleport(Entity destination, PlayerTeleportEvent.TeleportCause cause) {
|
||||||
if (module.allowFakePlayerTeleports().get())
|
if (module.allowFakePlayerTeleports.get())
|
||||||
this.location = destination.getLocation();
|
this.location = destination.getLocation();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -227,6 +227,7 @@ public abstract class DiscordConnectedPlayer extends DiscordSenderBase implement
|
||||||
return GameMode.SPECTATOR;
|
return GameMode.SPECTATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
private final Player.Spigot spigot = new Player.Spigot() {
|
private final Player.Spigot spigot = new Player.Spigot() {
|
||||||
@Override
|
@Override
|
||||||
public InetSocketAddress getRawAddress() {
|
public InetSocketAddress getRawAddress() {
|
||||||
|
|
|
@ -52,13 +52,11 @@ public class DiscordPlugin extends ButtonPlugin {
|
||||||
/**
|
/**
|
||||||
* The prefix to use with Discord commands like /role. It only works in the bot channel.
|
* The prefix to use with Discord commands like /role. It only works in the bot channel.
|
||||||
*/
|
*/
|
||||||
private ConfigData<Character> prefix() {
|
private final ConfigData<Character> prefix = getIConfig().getData("prefix", '/', str -> ((String) str).charAt(0), Object::toString);
|
||||||
return getIConfig().getData("prefix", '/', str -> ((String) str).charAt(0), Object::toString);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static char getPrefix() {
|
public static char getPrefix() {
|
||||||
if (plugin == null) return '/';
|
if (plugin == null) return '/';
|
||||||
return plugin.prefix().get();
|
return plugin.prefix.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,23 +77,21 @@ public class DiscordPlugin extends ButtonPlugin {
|
||||||
/**
|
/**
|
||||||
* The (bot) channel to use for Discord commands like /role.
|
* The (bot) channel to use for Discord commands like /role.
|
||||||
*/
|
*/
|
||||||
public ConfigData<Snowflake> commandChannel() {
|
public ConfigData<Snowflake> commandChannel = DPUtils.snowflakeData(getIConfig(), "commandChannel", 0L);
|
||||||
return DPUtils.snowflakeData(getIConfig(), "commandChannel", 0L);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The role that allows using mod-only Discord commands.
|
* The role that allows using mod-only Discord commands.
|
||||||
* If empty (''), then it will only allow for the owner.
|
* If empty (''), then it will only allow for the owner.
|
||||||
*/
|
*/
|
||||||
public ConfigData<Mono<Role>> modRole() {
|
public ConfigData<Mono<Role>> modRole;
|
||||||
return DPUtils.roleData(getIConfig(), "modRole", "Moderator");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The invite link to show by /discord invite. If empty, it defaults to the first invite if the bot has access.
|
* The invite link to show by /discord invite. If empty, it defaults to the first invite if the bot has access.
|
||||||
*/
|
*/
|
||||||
public ConfigData<String> inviteLink() {
|
public ConfigData<String> inviteLink = getIConfig().getData("inviteLink", "");
|
||||||
return getIConfig().getData("inviteLink", "");
|
|
||||||
|
private void setupConfig() {
|
||||||
|
modRole = DPUtils.roleData(getIConfig(), "modRole", "Moderator");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -175,7 +171,8 @@ public class DiscordPlugin extends ButtonPlugin {
|
||||||
mainServer().set(Optional.of(mainServer)); //Save in config
|
mainServer().set(Optional.of(mainServer)); //Save in config
|
||||||
}
|
}
|
||||||
SafeMode = false;
|
SafeMode = false;
|
||||||
DPUtils.disableIfConfigErrorRes(null, commandChannel(), DPUtils.getMessageChannel(commandChannel()));
|
setupConfig();
|
||||||
|
DPUtils.disableIfConfigErrorRes(null, commandChannel, DPUtils.getMessageChannel(commandChannel));
|
||||||
//Won't disable, just prints the warning here
|
//Won't disable, just prints the warning here
|
||||||
|
|
||||||
CommonListeners.register(dc.getEventDispatcher());
|
CommonListeners.register(dc.getEventDispatcher());
|
||||||
|
|
|
@ -27,48 +27,36 @@ public class AnnouncerModule extends Component<DiscordPlugin> {
|
||||||
/**
|
/**
|
||||||
* Channel to post new posts.
|
* Channel to post new posts.
|
||||||
*/
|
*/
|
||||||
public ReadOnlyConfigData<Mono<MessageChannel>> channel() {
|
public final ReadOnlyConfigData<Mono<MessageChannel>> channel = DPUtils.channelData(getConfig(), "channel");
|
||||||
return DPUtils.channelData(getConfig(), "channel");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Channel where distinguished (moderator) posts go.
|
* Channel where distinguished (moderator) posts go.
|
||||||
*/
|
*/
|
||||||
private ReadOnlyConfigData<Mono<MessageChannel>> modChannel() {
|
private final ReadOnlyConfigData<Mono<MessageChannel>> modChannel = DPUtils.channelData(getConfig(), "modChannel");
|
||||||
return DPUtils.channelData(getConfig(), "modChannel");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically unpins all messages except the last few. Set to 0 or >50 to disable
|
* Automatically unpins all messages except the last few. Set to 0 or >50 to disable
|
||||||
*/
|
*/
|
||||||
private ConfigData<Short> keepPinned() {
|
private final ConfigData<Short> keepPinned = getConfig().getData("keepPinned", (short) 40);
|
||||||
return getConfig().getData("keepPinned", (short) 40);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ConfigData<Long> lastAnnouncementTime() {
|
private final ConfigData<Long> lastAnnouncementTime = getConfig().getData("lastAnnouncementTime", 0L);
|
||||||
return getConfig().getData("lastAnnouncementTime", 0L);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ConfigData<Long> lastSeenTime() {
|
private final ConfigData<Long> lastSeenTime = getConfig().getData("lastSeenTime", 0L);
|
||||||
return getConfig().getData("lastSeenTime", 0L);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The subreddit to pull the posts from
|
* The subreddit to pull the posts from
|
||||||
*/
|
*/
|
||||||
private ConfigData<String> subredditURL() {
|
private final ConfigData<String> subredditURL = getConfig().getData("subredditURL", "https://www.reddit.com/r/ChromaGamers");
|
||||||
return getConfig().getData("subredditURL", "https://www.reddit.com/r/ChromaGamers");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean stop = false;
|
private static boolean stop = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void enable() {
|
protected void enable() {
|
||||||
if (DPUtils.disableIfConfigError(this, channel(), modChannel())) return;
|
if (DPUtils.disableIfConfigError(this, channel, modChannel)) return;
|
||||||
stop = false; //If not the first time
|
stop = false; //If not the first time
|
||||||
val keepPinned = keepPinned().get();
|
val kp = keepPinned.get();
|
||||||
if (keepPinned == 0) return;
|
if (kp == 0) return;
|
||||||
Flux<Message> msgs = channel().get().flatMapMany(MessageChannel::getPinnedMessages);
|
Flux<Message> msgs = channel.get().flatMapMany(MessageChannel::getPinnedMessages).takeLast(kp);
|
||||||
msgs.subscribe(Message::unpin);
|
msgs.subscribe(Message::unpin);
|
||||||
new Thread(this::AnnouncementGetterThreadMethod).start();
|
new Thread(this::AnnouncementGetterThreadMethod).start();
|
||||||
}
|
}
|
||||||
|
@ -86,12 +74,12 @@ public class AnnouncerModule extends Component<DiscordPlugin> {
|
||||||
Thread.sleep(10000);
|
Thread.sleep(10000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String body = TBMCCoreAPI.DownloadString(subredditURL().get() + "/new/.json?limit=10");
|
String body = TBMCCoreAPI.DownloadString(subredditURL.get() + "/new/.json?limit=10");
|
||||||
JsonArray json = new JsonParser().parse(body).getAsJsonObject().get("data").getAsJsonObject()
|
JsonArray json = new JsonParser().parse(body).getAsJsonObject().get("data").getAsJsonObject()
|
||||||
.get("children").getAsJsonArray();
|
.get("children").getAsJsonArray();
|
||||||
StringBuilder msgsb = new StringBuilder();
|
StringBuilder msgsb = new StringBuilder();
|
||||||
StringBuilder modmsgsb = new StringBuilder();
|
StringBuilder modmsgsb = new StringBuilder();
|
||||||
long lastanntime = lastAnnouncementTime().get();
|
long lastanntime = lastAnnouncementTime.get();
|
||||||
for (int i = json.size() - 1; i >= 0; i--) {
|
for (int i = json.size() - 1; i >= 0; i--) {
|
||||||
JsonObject item = json.get(i).getAsJsonObject();
|
JsonObject item = json.get(i).getAsJsonObject();
|
||||||
final JsonObject data = item.get("data").getAsJsonObject();
|
final JsonObject data = item.get("data").getAsJsonObject();
|
||||||
|
@ -104,9 +92,10 @@ public class AnnouncerModule extends Component<DiscordPlugin> {
|
||||||
distinguished = distinguishedjson.getAsString();
|
distinguished = distinguishedjson.getAsString();
|
||||||
String permalink = "https://www.reddit.com" + data.get("permalink").getAsString();
|
String permalink = "https://www.reddit.com" + data.get("permalink").getAsString();
|
||||||
long date = data.get("created_utc").getAsLong();
|
long date = data.get("created_utc").getAsLong();
|
||||||
if (date > lastSeenTime().get())
|
if (date > lastSeenTime.get())
|
||||||
lastSeenTime().set(date);
|
lastSeenTime.set(date);
|
||||||
else if (date > lastAnnouncementTime().get()) {
|
else if (date > lastAnnouncementTime.get()) {
|
||||||
|
//noinspection ConstantConditions
|
||||||
do {
|
do {
|
||||||
val reddituserclass = ChromaGamerBase.getTypeForFolder("reddit");
|
val reddituserclass = ChromaGamerBase.getTypeForFolder("reddit");
|
||||||
if (reddituserclass == null)
|
if (reddituserclass == null)
|
||||||
|
@ -125,13 +114,13 @@ public class AnnouncerModule extends Component<DiscordPlugin> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (msgsb.length() > 0)
|
if (msgsb.length() > 0)
|
||||||
channel().get().flatMap(ch -> ch.createMessage(msgsb.toString()))
|
channel.get().flatMap(ch -> ch.createMessage(msgsb.toString()))
|
||||||
.flatMap(Message::pin).subscribe();
|
.flatMap(Message::pin).subscribe();
|
||||||
if (modmsgsb.length() > 0)
|
if (modmsgsb.length() > 0)
|
||||||
modChannel().get().flatMap(ch -> ch.createMessage(modmsgsb.toString()))
|
modChannel.get().flatMap(ch -> ch.createMessage(modmsgsb.toString()))
|
||||||
.flatMap(Message::pin).subscribe();
|
.flatMap(Message::pin).subscribe();
|
||||||
if (lastAnnouncementTime().get() != lastanntime)
|
if (lastAnnouncementTime.get() != lastanntime)
|
||||||
lastAnnouncementTime().set(lastanntime); // If sending succeeded
|
lastAnnouncementTime.set(lastanntime); // If sending succeeded
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class DebugCommand extends ICommand2DC {
|
||||||
.switchIfEmpty(sender.getMessage().getAuthor() //Support DMs
|
.switchIfEmpty(sender.getMessage().getAuthor() //Support DMs
|
||||||
.map(u -> u.asMember(DiscordPlugin.mainServer.getId()))
|
.map(u -> u.asMember(DiscordPlugin.mainServer.getId()))
|
||||||
.orElse(Mono.empty()))
|
.orElse(Mono.empty()))
|
||||||
.flatMap(m -> DiscordPlugin.plugin.modRole().get()
|
.flatMap(m -> DiscordPlugin.plugin.modRole.get()
|
||||||
.map(mr -> m.getRoleIds().stream().anyMatch(r -> r.equals(mr.getId())))
|
.map(mr -> m.getRoleIds().stream().anyMatch(r -> r.equals(mr.getId())))
|
||||||
.switchIfEmpty(Mono.fromSupplier(() -> DiscordPlugin.mainServer.getOwnerId().asLong() == m.getId().asLong()))) //Role not found
|
.switchIfEmpty(Mono.fromSupplier(() -> DiscordPlugin.mainServer.getOwnerId().asLong() == m.getId().asLong()))) //Role not found
|
||||||
.onErrorReturn(false).subscribe(success -> {
|
.onErrorReturn(false).subscribe(success -> {
|
||||||
|
|
|
@ -83,16 +83,14 @@ public class ExceptionListenerModule extends Component<DiscordPlugin> implements
|
||||||
private static ExceptionListenerModule instance;
|
private static ExceptionListenerModule instance;
|
||||||
|
|
||||||
public static Mono<MessageChannel> getChannel() {
|
public static Mono<MessageChannel> getChannel() {
|
||||||
if (instance != null) return instance.channel().get();
|
if (instance != null) return instance.channel.get();
|
||||||
return Mono.empty();
|
return Mono.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The channel to post the errors to.
|
* The channel to post the errors to.
|
||||||
*/
|
*/
|
||||||
private ReadOnlyConfigData<Mono<MessageChannel>> channel() {
|
private final ReadOnlyConfigData<Mono<MessageChannel>> channel = DPUtils.channelData(getConfig(), "channel");
|
||||||
return DPUtils.channelData(getConfig(), "channel");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The role to ping if an error occurs. Set to empty ('') to disable.
|
* The role to ping if an error occurs. Set to empty ('') to disable.
|
||||||
|
@ -103,7 +101,7 @@ public class ExceptionListenerModule extends Component<DiscordPlugin> implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void enable() {
|
protected void enable() {
|
||||||
if (DPUtils.disableIfConfigError(this, channel())) return;
|
if (DPUtils.disableIfConfigError(this, channel)) return;
|
||||||
instance = this;
|
instance = this;
|
||||||
Bukkit.getPluginManager().registerEvents(new ExceptionListenerModule(), getPlugin());
|
Bukkit.getPluginManager().registerEvents(new ExceptionListenerModule(), getPlugin());
|
||||||
TBMCCoreAPI.RegisterEventsForExceptions(new DebugMessageListener(), getPlugin());
|
TBMCCoreAPI.RegisterEventsForExceptions(new DebugMessageListener(), getPlugin());
|
||||||
|
|
|
@ -54,25 +54,21 @@ public class FunModule extends Component<DiscordPlugin> implements Listener {
|
||||||
/**
|
/**
|
||||||
* Questions that the bot will choose a random answer to give to.
|
* Questions that the bot will choose a random answer to give to.
|
||||||
*/
|
*/
|
||||||
private ConfigData<String[]> serverReady() {
|
private final ConfigData<String[]> serverReady = getConfig().getData("serverReady", () -> new String[]{
|
||||||
return getConfig().getData("serverReady", () -> new String[]{"when will the server be open",
|
"when will the server be open", "when will the server be ready", "when will the server be done",
|
||||||
"when will the server be ready", "when will the server be done", "when will the server be complete",
|
"when will the server be complete", "when will the server be finished", "when's the server ready",
|
||||||
"when will the server be finished", "when's the server ready", "when's the server open",
|
"when's the server open", "vhen vill ze server be open?"});
|
||||||
"vhen vill ze server be open?"});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Answers for a recognized question. Selected randomly.
|
* Answers for a recognized question. Selected randomly.
|
||||||
*/
|
*/
|
||||||
private ConfigData<ArrayList<String>> serverReadyAnswers() {
|
private final ConfigData<ArrayList<String>> serverReadyAnswers = getConfig().getData("serverReadyAnswers", () -> Lists.newArrayList(serverReadyStrings));
|
||||||
return getConfig().getData("serverReadyAnswers", () -> Lists.newArrayList(serverReadyStrings));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Random serverReadyRandom = new Random();
|
private static final Random serverReadyRandom = new Random();
|
||||||
private static final ArrayList<Short> usableServerReadyStrings = new ArrayList<>(0);
|
private static final ArrayList<Short> usableServerReadyStrings = new ArrayList<>(0);
|
||||||
|
|
||||||
private void createUsableServerReadyStrings() {
|
private void createUsableServerReadyStrings() {
|
||||||
IntStream.range(0, serverReadyAnswers().get().size())
|
IntStream.range(0, serverReadyAnswers.get().size())
|
||||||
.forEach(i -> FunModule.usableServerReadyStrings.add((short) i));
|
.forEach(i -> FunModule.usableServerReadyStrings.add((short) i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,12 +105,12 @@ public class FunModule extends Component<DiscordPlugin> implements Listener {
|
||||||
}
|
}
|
||||||
lastlistp = (short) Bukkit.getOnlinePlayers().size(); //Didn't handle
|
lastlistp = (short) Bukkit.getOnlinePlayers().size(); //Didn't handle
|
||||||
if (!TBMCCoreAPI.IsTestServer()
|
if (!TBMCCoreAPI.IsTestServer()
|
||||||
&& Arrays.stream(fm.serverReady().get()).anyMatch(msglowercased::contains)) {
|
&& Arrays.stream(fm.serverReady.get()).anyMatch(msglowercased::contains)) {
|
||||||
int next;
|
int next;
|
||||||
if (usableServerReadyStrings.size() == 0)
|
if (usableServerReadyStrings.size() == 0)
|
||||||
fm.createUsableServerReadyStrings();
|
fm.createUsableServerReadyStrings();
|
||||||
next = usableServerReadyStrings.remove(serverReadyRandom.nextInt(usableServerReadyStrings.size()));
|
next = usableServerReadyStrings.remove(serverReadyRandom.nextInt(usableServerReadyStrings.size()));
|
||||||
DPUtils.reply(message, Mono.empty(), fm.serverReadyAnswers().get().get(next)).subscribe();
|
DPUtils.reply(message, Mono.empty(), fm.serverReadyAnswers.get().get(next)).subscribe();
|
||||||
return false; //Still process it as a command/mcchat if needed
|
return false; //Still process it as a command/mcchat if needed
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -136,9 +132,7 @@ public class FunModule extends Component<DiscordPlugin> implements Listener {
|
||||||
/**
|
/**
|
||||||
* The channel to post the full house to.
|
* The channel to post the full house to.
|
||||||
*/
|
*/
|
||||||
private ReadOnlyConfigData<Mono<MessageChannel>> fullHouseChannel() {
|
private final ReadOnlyConfigData<Mono<MessageChannel>> fullHouseChannel = DPUtils.channelData(getConfig(), "fullHouseChannel");
|
||||||
return DPUtils.channelData(getConfig(), "fullHouseChannel");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static long lasttime = 0;
|
private static long lasttime = 0;
|
||||||
|
|
||||||
|
@ -146,7 +140,7 @@ public class FunModule extends Component<DiscordPlugin> implements Listener {
|
||||||
val fm = ComponentManager.getIfEnabled(FunModule.class);
|
val fm = ComponentManager.getIfEnabled(FunModule.class);
|
||||||
if (fm == null) return;
|
if (fm == null) return;
|
||||||
if (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) % 5 != 0) return;
|
if (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) % 5 != 0) return;
|
||||||
fm.fullHouseChannel().get()
|
fm.fullHouseChannel.get()
|
||||||
.filter(ch -> ch instanceof GuildChannel)
|
.filter(ch -> ch instanceof GuildChannel)
|
||||||
.flatMap(channel -> fm.fullHouseDevRole(((GuildChannel) channel).getGuild()).get()
|
.flatMap(channel -> fm.fullHouseDevRole(((GuildChannel) channel).getGuild()).get()
|
||||||
.filter(role -> event.getOld().map(p -> p.getStatus().equals(Status.OFFLINE)).orElse(false))
|
.filter(role -> event.getOld().map(p -> p.getStatus().equals(Status.OFFLINE)).orElse(false))
|
||||||
|
|
|
@ -42,8 +42,8 @@ public class CommonListeners {
|
||||||
return def;
|
return def;
|
||||||
if (FunModule.executeMemes(event.getMessage()))
|
if (FunModule.executeMemes(event.getMessage()))
|
||||||
return def;
|
return def;
|
||||||
val commandChannel = DiscordPlugin.plugin.commandChannel().get();
|
val commandChannel = DiscordPlugin.plugin.commandChannel.get();
|
||||||
val commandCh = DPUtils.getMessageChannel(DiscordPlugin.plugin.commandChannel());
|
val commandCh = DPUtils.getMessageChannel(DiscordPlugin.plugin.commandChannel);
|
||||||
return commandCh.filterWhen(ch -> event.getMessage().getChannel().map(mch ->
|
return commandCh.filterWhen(ch -> event.getMessage().getChannel().map(mch ->
|
||||||
(commandChannel != null && mch.getId().asLong() == commandChannel.asLong()) //If mentioned, that's higher than chat
|
(commandChannel != null && mch.getId().asLong() == commandChannel.asLong()) //If mentioned, that's higher than chat
|
||||||
|| mch instanceof PrivateChannel
|
|| mch instanceof PrivateChannel
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class ChannelconCommand extends ICommand2DC {
|
||||||
@Command2.Subcommand
|
@Command2.Subcommand
|
||||||
public boolean def(Command2DCSender sender, String channelID) {
|
public boolean def(Command2DCSender sender, String channelID) {
|
||||||
val message = sender.getMessage();
|
val message = sender.getMessage();
|
||||||
if (!module.allowCustomChat().get()) {
|
if (!module.allowCustomChat.get()) {
|
||||||
sender.sendMessage("channel connection is not allowed on this Minecraft server.");
|
sender.sendMessage("channel connection is not allowed on this Minecraft server.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public class ChannelconCommand extends ICommand2DC {
|
||||||
if (checkPerms(message, channel)) return true;
|
if (checkPerms(message, channel)) return true;
|
||||||
if (MCChatCustom.hasCustomChat(message.getChannelId()))
|
if (MCChatCustom.hasCustomChat(message.getChannelId()))
|
||||||
return respond(sender, "this channel is already connected to a Minecraft channel. Use `@ChromaBot channelcon remove` to remove it.");
|
return respond(sender, "this channel is already connected to a Minecraft channel. Use `@ChromaBot channelcon remove` to remove it.");
|
||||||
val chan = Channel.getChannels().filter(ch -> ch.ID.equalsIgnoreCase(channelID) || (Arrays.stream(ch.IDs().get()).anyMatch(cid -> cid.equalsIgnoreCase(channelID)))).findAny();
|
val chan = Channel.getChannels().filter(ch -> ch.ID.equalsIgnoreCase(channelID) || (Arrays.stream(ch.IDs.get()).anyMatch(cid -> cid.equalsIgnoreCase(channelID)))).findAny();
|
||||||
if (!chan.isPresent()) { //TODO: Red embed that disappears over time (kinda like the highlight messages in OW)
|
if (!chan.isPresent()) { //TODO: Red embed that disappears over time (kinda like the highlight messages in OW)
|
||||||
DPUtils.reply(message, channel, "MC channel with ID '" + channelID + "' not found! The ID is the command for it without the /.").subscribe();
|
DPUtils.reply(message, channel, "MC channel with ID '" + channelID + "' not found! The ID is the command for it without the /.").subscribe();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class MCChatCommand extends ICommand2DC {
|
||||||
|
|
||||||
@Command2.Subcommand
|
@Command2.Subcommand
|
||||||
public boolean def(Command2DCSender sender) {
|
public boolean def(Command2DCSender sender) {
|
||||||
if (!module.allowPrivateChat().get()) {
|
if (!module.allowPrivateChat.get()) {
|
||||||
sender.sendMessage("using the private chat is not allowed on this Minecraft server.");
|
sender.sendMessage("using the private chat is not allowed on this Minecraft server.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,14 +77,14 @@ public class MCChatListener implements Listener {
|
||||||
e = se.getKey();
|
e = se.getKey();
|
||||||
time = se.getValue();
|
time = se.getValue();
|
||||||
|
|
||||||
final String authorPlayer = "[" + DPUtils.sanitizeStringNoEscape(e.getChannel().DisplayName().get()) + "] " //
|
final String authorPlayer = "[" + DPUtils.sanitizeStringNoEscape(e.getChannel().DisplayName.get()) + "] " //
|
||||||
+ ("Minecraft".equals(e.getOrigin()) ? "" : "[" + e.getOrigin().charAt(0) + "]") //
|
+ ("Minecraft".equals(e.getOrigin()) ? "" : "[" + e.getOrigin().charAt(0) + "]") //
|
||||||
+ (DPUtils.sanitizeStringNoEscape(ChromaUtils.getDisplayName(e.getSender())));
|
+ (DPUtils.sanitizeStringNoEscape(ChromaUtils.getDisplayName(e.getSender())));
|
||||||
val color = e.getChannel().Color().get();
|
val color = e.getChannel().Color.get();
|
||||||
final Consumer<EmbedCreateSpec> embed = ecs -> {
|
final Consumer<EmbedCreateSpec> embed = ecs -> {
|
||||||
ecs.setDescription(e.getMessage()).setColor(Color.of(color.getRed(),
|
ecs.setDescription(e.getMessage()).setColor(Color.of(color.getRed(),
|
||||||
color.getGreen(), color.getBlue()));
|
color.getGreen(), color.getBlue()));
|
||||||
String url = module.profileURL().get();
|
String url = module.profileURL.get();
|
||||||
if (e.getSender() instanceof Player)
|
if (e.getSender() instanceof Player)
|
||||||
DPUtils.embedWithHead(ecs, authorPlayer, e.getSender().getName(),
|
DPUtils.embedWithHead(ecs, authorPlayer, e.getSender().getName(),
|
||||||
url.length() > 0 ? url + "?type=minecraft&id="
|
url.length() > 0 ? url + "?type=minecraft&id="
|
||||||
|
@ -121,7 +121,7 @@ public class MCChatListener implements Listener {
|
||||||
|| ((DiscordSenderBase) e.getSender()).getChannel().getId().asLong() != id.asLong();
|
|| ((DiscordSenderBase) e.getSender()).getChannel().getId().asLong() != id.asLong();
|
||||||
|
|
||||||
if (e.getChannel().isGlobal()
|
if (e.getChannel().isGlobal()
|
||||||
&& (e.isFromCommand() || isdifferentchannel.test(module.chatChannel().get())))
|
&& (e.isFromCommand() || isdifferentchannel.test(module.chatChannel.get())))
|
||||||
doit.accept(MCChatUtils.lastmsgdata == null
|
doit.accept(MCChatUtils.lastmsgdata == null
|
||||||
? MCChatUtils.lastmsgdata = new MCChatUtils.LastMsgData(module.chatChannelMono().block(), null)
|
? MCChatUtils.lastmsgdata = new MCChatUtils.LastMsgData(module.chatChannelMono().block(), null)
|
||||||
: MCChatUtils.lastmsgdata);
|
: MCChatUtils.lastmsgdata);
|
||||||
|
@ -238,7 +238,7 @@ public class MCChatListener implements Listener {
|
||||||
var prefix = DiscordPlugin.getPrefix();
|
var prefix = DiscordPlugin.getPrefix();
|
||||||
return ev.getMessage().getChannel().filter(channel -> {
|
return ev.getMessage().getChannel().filter(channel -> {
|
||||||
timings.printElapsed("Filter 1");
|
timings.printElapsed("Filter 1");
|
||||||
return !(ev.getMessage().getChannelId().asLong() != module.chatChannel().get().asLong()
|
return !(ev.getMessage().getChannelId().asLong() != module.chatChannel.get().asLong()
|
||||||
&& !(channel instanceof PrivateChannel
|
&& !(channel instanceof PrivateChannel
|
||||||
&& author.map(u -> MCChatPrivate.isMinecraftChatEnabled(u.getId().asString())).orElse(false))
|
&& author.map(u -> MCChatPrivate.isMinecraftChatEnabled(u.getId().asString())).orElse(false))
|
||||||
&& !hasCustomChat); //Chat isn't enabled on this channel
|
&& !hasCustomChat); //Chat isn't enabled on this channel
|
||||||
|
@ -383,7 +383,7 @@ public class MCChatListener implements Listener {
|
||||||
return;
|
return;
|
||||||
try {
|
try {
|
||||||
String mcpackage = Bukkit.getServer().getClass().getPackage().getName();
|
String mcpackage = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
if (!module.enableVanillaCommands().get())
|
if (!module.enableVanillaCommands.get())
|
||||||
Bukkit.dispatchCommand(dsender, cmd);
|
Bukkit.dispatchCommand(dsender, cmd);
|
||||||
else if (mcpackage.contains("1_12"))
|
else if (mcpackage.contains("1_12"))
|
||||||
VanillaCommandListener.runBukkitOrVanillaCommand(dsender, cmd);
|
VanillaCommandListener.runBukkitOrVanillaCommand(dsender, cmd);
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class MCChatUtils {
|
||||||
|
|
||||||
public static void updatePlayerList() {
|
public static void updatePlayerList() {
|
||||||
val mod = getModule();
|
val mod = getModule();
|
||||||
if (mod == null || !mod.showPlayerListOnDC().get()) return;
|
if (mod == null || !mod.showPlayerListOnDC.get()) return;
|
||||||
if (lastmsgdata != null)
|
if (lastmsgdata != null)
|
||||||
updatePL(lastmsgdata);
|
updatePL(lastmsgdata);
|
||||||
MCChatCustom.lastmsgCustom.forEach(MCChatUtils::updatePL);
|
MCChatCustom.lastmsgCustom.forEach(MCChatUtils::updatePL);
|
||||||
|
@ -254,7 +254,7 @@ public class MCChatUtils {
|
||||||
*/
|
*/
|
||||||
public static void resetLastMessage(Channel channel) {
|
public static void resetLastMessage(Channel channel) {
|
||||||
if (notEnabled()) return;
|
if (notEnabled()) return;
|
||||||
if (channel.getId().asLong() == module.chatChannel().get().asLong()) {
|
if (channel.getId().asLong() == module.chatChannel.get().asLong()) {
|
||||||
(lastmsgdata == null ? lastmsgdata = new LastMsgData(module.chatChannelMono().block(), null)
|
(lastmsgdata == null ? lastmsgdata = new LastMsgData(module.chatChannelMono().block(), null)
|
||||||
: lastmsgdata).message = null;
|
: lastmsgdata).message = null;
|
||||||
return;
|
return;
|
||||||
|
@ -277,7 +277,7 @@ public class MCChatUtils {
|
||||||
public static void callEventExcludingSome(Event event) {
|
public static void callEventExcludingSome(Event event) {
|
||||||
if (notEnabled()) return;
|
if (notEnabled()) return;
|
||||||
val second = staticExcludedPlugins.get(event.getClass());
|
val second = staticExcludedPlugins.get(event.getClass());
|
||||||
String[] first = module.excludedPlugins().get();
|
String[] first = module.excludedPlugins.get();
|
||||||
String[] both = second == null ? first
|
String[] both = second == null ? first
|
||||||
: Arrays.copyOf(first, first.length + second.size());
|
: Arrays.copyOf(first, first.length + second.size());
|
||||||
int i = first.length;
|
int i = first.length;
|
||||||
|
|
|
@ -9,7 +9,6 @@ import buttondevteam.lib.player.TBMCYEEHAWEvent;
|
||||||
import com.earth2me.essentials.CommandSource;
|
import com.earth2me.essentials.CommandSource;
|
||||||
import discord4j.common.util.Snowflake;
|
import discord4j.common.util.Snowflake;
|
||||||
import discord4j.core.object.entity.Role;
|
import discord4j.core.object.entity.Role;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import net.ess3.api.events.AfkStatusChangeEvent;
|
import net.ess3.api.events.AfkStatusChangeEvent;
|
||||||
import net.ess3.api.events.MuteStatusChangeEvent;
|
import net.ess3.api.events.MuteStatusChangeEvent;
|
||||||
|
@ -30,9 +29,14 @@ import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
class MCListener implements Listener {
|
class MCListener implements Listener {
|
||||||
private final MinecraftChatModule module;
|
private final MinecraftChatModule module;
|
||||||
|
private final ConfigData<Mono<Role>> muteRole;
|
||||||
|
|
||||||
|
public MCListener(MinecraftChatModule module) {
|
||||||
|
this.module = module;
|
||||||
|
muteRole = DPUtils.roleData(module.getConfig(), "muteRole", "Muted");
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerLogin(PlayerLoginEvent e) {
|
public void onPlayerLogin(PlayerLoginEvent e) {
|
||||||
|
@ -105,13 +109,9 @@ class MCListener implements Listener {
|
||||||
MCChatUtils.forAllowedCustomAndAllMCChat(MCChatUtils.send(msg), base, ChannelconBroadcast.AFK, false).subscribe();
|
MCChatUtils.forAllowedCustomAndAllMCChat(MCChatUtils.send(msg), base, ChannelconBroadcast.AFK, false).subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConfigData<Mono<Role>> muteRole() {
|
|
||||||
return DPUtils.roleData(module.getConfig(), "muteRole", "Muted");
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerMute(MuteStatusChangeEvent e) {
|
public void onPlayerMute(MuteStatusChangeEvent e) {
|
||||||
final Mono<Role> role = muteRole().get();
|
final Mono<Role> role = muteRole.get();
|
||||||
if (role == null) return;
|
if (role == null) return;
|
||||||
final CommandSource source = e.getAffected().getSource();
|
final CommandSource source = e.getAffected().getSource();
|
||||||
if (!source.isPlayer())
|
if (!source.isPlayer())
|
||||||
|
@ -126,7 +126,7 @@ class MCListener implements Listener {
|
||||||
user.addRole(r.getId());
|
user.addRole(r.getId());
|
||||||
else
|
else
|
||||||
user.removeRole(r.getId());
|
user.removeRole(r.getId());
|
||||||
val modlog = module.modlogChannel().get();
|
val modlog = module.modlogChannel.get();
|
||||||
String msg = (e.getValue() ? "M" : "Unm") + "uted user: " + user.getUsername() + "#" + user.getDiscriminator();
|
String msg = (e.getValue() ? "M" : "Unm") + "uted user: " + user.getUsername() + "#" + user.getDiscriminator();
|
||||||
module.log(msg);
|
module.log(msg);
|
||||||
if (modlog != null)
|
if (modlog != null)
|
||||||
|
|
|
@ -49,36 +49,28 @@ public class MinecraftChatModule extends Component<DiscordPlugin> {
|
||||||
/**
|
/**
|
||||||
* The channel to use as the public Minecraft chat - everything public gets broadcasted here
|
* The channel to use as the public Minecraft chat - everything public gets broadcasted here
|
||||||
*/
|
*/
|
||||||
public ReadOnlyConfigData<Snowflake> chatChannel() {
|
public ReadOnlyConfigData<Snowflake> chatChannel = DPUtils.snowflakeData(getConfig(), "chatChannel", 0L);
|
||||||
return DPUtils.snowflakeData(getConfig(), "chatChannel", 0L);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Mono<MessageChannel> chatChannelMono() {
|
public Mono<MessageChannel> chatChannelMono() {
|
||||||
return DPUtils.getMessageChannel(chatChannel().getPath(), chatChannel().get());
|
return DPUtils.getMessageChannel(chatChannel.getPath(), chatChannel.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The channel where the plugin can log when it mutes a player on Discord because of a Minecraft mute
|
* The channel where the plugin can log when it mutes a player on Discord because of a Minecraft mute
|
||||||
*/
|
*/
|
||||||
public ReadOnlyConfigData<Mono<MessageChannel>> modlogChannel() {
|
public ReadOnlyConfigData<Mono<MessageChannel>> modlogChannel = DPUtils.channelData(getConfig(), "modlogChannel");
|
||||||
return DPUtils.channelData(getConfig(), "modlogChannel");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The plugins to exclude from fake player events used for the 'mcchat' command - some plugins may crash, add them here
|
* The plugins to exclude from fake player events used for the 'mcchat' command - some plugins may crash, add them here
|
||||||
*/
|
*/
|
||||||
public ConfigData<String[]> excludedPlugins() {
|
public ConfigData<String[]> excludedPlugins = getConfig().getData("excludedPlugins", new String[]{"ProtocolLib", "LibsDisguises", "JourneyMapServer"});
|
||||||
return getConfig().getData("excludedPlugins", new String[]{"ProtocolLib", "LibsDisguises", "JourneyMapServer"});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this setting is on then players logged in through the 'mcchat' command will be able to teleport using plugin commands.
|
* If this setting is on then players logged in through the 'mcchat' command will be able to teleport using plugin commands.
|
||||||
* They can then use commands like /tpahere to teleport others to that place.<br />
|
* They can then use commands like /tpahere to teleport others to that place.<br />
|
||||||
* If this is off, then teleporting will have no effect.
|
* If this is off, then teleporting will have no effect.
|
||||||
*/
|
*/
|
||||||
public ConfigData<Boolean> allowFakePlayerTeleports() {
|
public ConfigData<Boolean> allowFakePlayerTeleports = getConfig().getData("allowFakePlayerTeleports", false);
|
||||||
return getConfig().getData("allowFakePlayerTeleports", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this is on, each chat channel will have a player list in their description.
|
* If this is on, each chat channel will have a player list in their description.
|
||||||
|
@ -86,40 +78,30 @@ public class MinecraftChatModule extends Component<DiscordPlugin> {
|
||||||
* Note that it will replace <b>everything</b> above the first and below the last "----" but it will only detect exactly four dashes.
|
* Note that it will replace <b>everything</b> above the first and below the last "----" but it will only detect exactly four dashes.
|
||||||
* So if you want to use dashes for something else in the description, make sure it's either less or more dashes in one line.
|
* So if you want to use dashes for something else in the description, make sure it's either less or more dashes in one line.
|
||||||
*/
|
*/
|
||||||
public ConfigData<Boolean> showPlayerListOnDC() {
|
public ConfigData<Boolean> showPlayerListOnDC = getConfig().getData("showPlayerListOnDC", true);
|
||||||
return getConfig().getData("showPlayerListOnDC", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This setting controls whether custom chat connections can be <i>created</i> (existing connections will always work).
|
* This setting controls whether custom chat connections can be <i>created</i> (existing connections will always work).
|
||||||
* Custom chat connections can be created using the channelcon command and they allow players to display town chat in a Discord channel for example.
|
* Custom chat connections can be created using the channelcon command and they allow players to display town chat in a Discord channel for example.
|
||||||
* See the channelcon command for more details.
|
* See the channelcon command for more details.
|
||||||
*/
|
*/
|
||||||
public ConfigData<Boolean> allowCustomChat() {
|
public ConfigData<Boolean> allowCustomChat = getConfig().getData("allowCustomChat", true);
|
||||||
return getConfig().getData("allowCustomChat", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This setting allows you to control if players can DM the bot to log on the server from Discord.
|
* This setting allows you to control if players can DM the bot to log on the server from Discord.
|
||||||
* This allows them to both chat and perform any command they can in-game.
|
* This allows them to both chat and perform any command they can in-game.
|
||||||
*/
|
*/
|
||||||
public ConfigData<Boolean> allowPrivateChat() {
|
public ConfigData<Boolean> allowPrivateChat = getConfig().getData("allowPrivateChat", true);
|
||||||
return getConfig().getData("allowPrivateChat", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If set, message authors appearing on Discord will link to this URL. A 'type' and 'id' parameter will be added with the user's platform (Discord, Minecraft, ...) and ID.
|
* If set, message authors appearing on Discord will link to this URL. A 'type' and 'id' parameter will be added with the user's platform (Discord, Minecraft, ...) and ID.
|
||||||
*/
|
*/
|
||||||
public ConfigData<String> profileURL() {
|
public ConfigData<String> profileURL = getConfig().getData("profileURL", "");
|
||||||
return getConfig().getData("profileURL", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables support for running vanilla commands through Discord, if you ever need it.
|
* Enables support for running vanilla commands through Discord, if you ever need it.
|
||||||
*/
|
*/
|
||||||
public ConfigData<Boolean> enableVanillaCommands() {
|
public ConfigData<Boolean> enableVanillaCommands = getConfig().getData("enableVanillaCommands", true);
|
||||||
return getConfig().getData("enableVanillaCommands", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether players logged on from Discord (mcchat command) should be recognised by other plugins. Some plugins might break if it's turned off.
|
* Whether players logged on from Discord (mcchat command) should be recognised by other plugins. Some plugins might break if it's turned off.
|
||||||
|
@ -134,7 +116,7 @@ public class MinecraftChatModule extends Component<DiscordPlugin> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void enable() {
|
protected void enable() {
|
||||||
if (DPUtils.disableIfConfigErrorRes(this, chatChannel(), chatChannelMono()))
|
if (DPUtils.disableIfConfigErrorRes(this, chatChannel, chatChannelMono()))
|
||||||
return;
|
return;
|
||||||
listener = new MCChatListener(this);
|
listener = new MCChatListener(this);
|
||||||
TBMCCoreAPI.RegisterEventsForExceptions(listener, getPlugin());
|
TBMCCoreAPI.RegisterEventsForExceptions(listener, getPlugin());
|
||||||
|
@ -268,6 +250,6 @@ public class MinecraftChatModule extends Component<DiscordPlugin> {
|
||||||
*/
|
*/
|
||||||
private void sendStateMessage(Color color, String message, String extra) {
|
private void sendStateMessage(Color color, String message, String extra) {
|
||||||
MCChatUtils.forCustomAndAllMCChat(chan -> chan.flatMap(ch -> ch.createEmbed(ecs -> ecs.setColor(color)
|
MCChatUtils.forCustomAndAllMCChat(chan -> chan.flatMap(ch -> ch.createEmbed(ecs -> ecs.setColor(color)
|
||||||
.setTitle(message).setDescription(extra))), ChannelconBroadcast.RESTART, false).block();
|
.setTitle(message).setDescription(extra)).onErrorResume(t -> Mono.empty())), ChannelconBroadcast.RESTART, false).block();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class DiscordMCCommand extends ICommand2MC {
|
||||||
})
|
})
|
||||||
public void invite(CommandSender sender) {
|
public void invite(CommandSender sender) {
|
||||||
if (checkSafeMode(sender)) return;
|
if (checkSafeMode(sender)) return;
|
||||||
String invi = DiscordPlugin.plugin.inviteLink().get();
|
String invi = DiscordPlugin.plugin.inviteLink.get();
|
||||||
if (invi.length() > 0) {
|
if (invi.length() > 0) {
|
||||||
sender.sendMessage("§bInvite link: " + invi);
|
sender.sendMessage("§bInvite link: " + invi);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -42,9 +42,7 @@ public class GameRoleModule extends Component<DiscordPlugin> {
|
||||||
/**
|
/**
|
||||||
* The channel where the bot logs when it detects a role change that results in a new game role or one being removed.
|
* The channel where the bot logs when it detects a role change that results in a new game role or one being removed.
|
||||||
*/
|
*/
|
||||||
private ReadOnlyConfigData<Mono<MessageChannel>> logChannel() {
|
private ReadOnlyConfigData<Mono<MessageChannel>> logChannel = DPUtils.channelData(getConfig(), "logChannel");
|
||||||
return DPUtils.channelData(getConfig(), "logChannel");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The role color that is used by game roles.
|
* The role color that is used by game roles.
|
||||||
|
@ -59,7 +57,7 @@ public class GameRoleModule extends Component<DiscordPlugin> {
|
||||||
val grm = ComponentManager.getIfEnabled(GameRoleModule.class);
|
val grm = ComponentManager.getIfEnabled(GameRoleModule.class);
|
||||||
if (grm == null) return;
|
if (grm == null) return;
|
||||||
val GameRoles = grm.GameRoles;
|
val GameRoles = grm.GameRoles;
|
||||||
val logChannel = grm.logChannel().get();
|
val logChannel = grm.logChannel.get();
|
||||||
Predicate<Role> notMainServer = r -> r.getGuildId().asLong() != DiscordPlugin.mainServer.getId().asLong();
|
Predicate<Role> notMainServer = r -> r.getGuildId().asLong() != DiscordPlugin.mainServer.getId().asLong();
|
||||||
if (roleEvent instanceof RoleCreateEvent) {
|
if (roleEvent instanceof RoleCreateEvent) {
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(DiscordPlugin.plugin, () -> {
|
Bukkit.getScheduler().runTaskLaterAsynchronously(DiscordPlugin.plugin, () -> {
|
||||||
|
|
Loading…
Reference in a new issue