Update D4J & role debug refined & fixed a )

PLW tested and confirmed working
Moved a ) to fix #105
This commit is contained in:
Norbi Peti 2019-08-26 00:57:16 +02:00
parent 91f1c8c4f7
commit e4d5dcd0a2
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
3 changed files with 8 additions and 8 deletions

View file

@ -193,7 +193,7 @@
<dependency>
<groupId>com.discord4j</groupId>
<artifactId>discord4j-core</artifactId>
<version>3.0.6</version>
<version>3.0.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-jdk14 -->
<dependency>

View file

@ -233,8 +233,8 @@ public class MCChatListener implements Listener {
timings.printElapsed("Filter 1");
return !(ev.getMessage().getChannelId().asLong() != module.chatChannel().get().asLong()
&& !(channel instanceof PrivateChannel
&& author.map(u -> MCChatPrivate.isMinecraftChatEnabled(u.getId().asString())).orElse(false)
&& !hasCustomChat)); //Chat isn't enabled on this channel
&& author.map(u -> MCChatPrivate.isMinecraftChatEnabled(u.getId().asString())).orElse(false))
&& !hasCustomChat); //Chat isn't enabled on this channel
}).filter(channel -> {
timings.printElapsed("Filter 2");
return !(channel instanceof PrivateChannel //Only in private chat

View file

@ -27,7 +27,7 @@ public class GameRoleModule extends Component<DiscordPlugin> {
@Override
protected void enable() {
getPlugin().getManager().registerCommand(new RoleCommand(this));
GameRoles = DiscordPlugin.mainServer.getRoles().filterWhen(this::isGameRole).map(Role::getName).collect(Collectors.toList()).block();
GameRoles = DiscordPlugin.mainServer.getRoles().filterWhen(r -> isGameRole(r, false)).map(Role::getName).collect(Collectors.toList()).block();
}
@Override
@ -47,7 +47,7 @@ public class GameRoleModule extends Component<DiscordPlugin> {
if (roleEvent instanceof RoleCreateEvent) {
Bukkit.getScheduler().runTaskLaterAsynchronously(DiscordPlugin.plugin, () -> {
Role role=((RoleCreateEvent) roleEvent).getRole();
grm.isGameRole(role).flatMap(b -> {
grm.isGameRole(role, false).flatMap(b -> {
if (!b)
return Mono.empty(); //Deleted or not a game role
GameRoles.add(role.getName());
@ -68,7 +68,7 @@ public class GameRoleModule extends Component<DiscordPlugin> {
return;
}
Role or=event.getOld().get();
grm.isGameRole(event.getCurrent()).flatMap(b -> {
grm.isGameRole(event.getCurrent(), true).flatMap(b -> {
if (!b) {
if (GameRoles.remove(or.getName()) && logChannel != null)
return logChannel.flatMap(ch -> ch.createMessage("Removed " + or.getName() + " as a game role because it's color changed."));
@ -89,8 +89,8 @@ public class GameRoleModule extends Component<DiscordPlugin> {
}
}
private Mono<Boolean> isGameRole(Role r) {
boolean debug = r.getName().equalsIgnoreCase("Minecraft");
private Mono<Boolean> isGameRole(Role r, boolean debugMC) {
boolean debug = debugMC && r.getName().equalsIgnoreCase("Minecraft");
if (debug) TBMCCoreAPI.sendDebugMessage("Checking if Minecraft is a game role...");
if (r.getGuildId().asLong() != DiscordPlugin.mainServer.getId().asLong()) {
if (debug) TBMCCoreAPI.sendDebugMessage("Not in the main server: " + r.getGuildId().asString());