Skip to content

Commit

Permalink
Update to 3.0.4, Fix advanced channel ids
Browse files Browse the repository at this point in the history
Signed-off-by: ErdbeerbaerLP <[email protected]>
  • Loading branch information
ErdbeerbaerLP committed Nov 7, 2023
1 parent 520f4e7 commit 74175d7
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 473 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ apply plugin: 'org.spongepowered.mixin'


//Build variables
version = "3.0.3"
version = "3.0.4-SNAPSHOT"
group = "de.erdbeerbaerlp.dcintegration"
archivesBaseName = "dcintegration-forge"

Expand Down Expand Up @@ -94,7 +94,7 @@ configurations.all {
//Dependencies
dependencies {
// ========= Common =====================
embed('de.erdbeerbaerlp:dcintegration.common:3.0.3') {
embed('de.erdbeerbaerlp:dcintegration.common:3.0.4') {
changing = true
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
changelog=Large discord integration rewrite adding new features and fixing long existing bugs\nOld configuration can be used as-is\n\nAdded custom status\nAdded tellraw\nAdded option to disable chat message editing for compatibility reasons\nFixed lots of bugs
changelog=General system stability improvements to enhance the user's experience. (Bug fixes)
releaseType = BETA
mcVersion = 1.18.2
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,15 @@ public void playerJoin(final PlayerEvent.PlayerLoggedInEvent ev) {
.replace("%avatarURL%", avatarURL)
.replace("%playerColor%", "" + TextColors.generateFromUUID(p.getUUID()).getRGB())
);
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(b.build()));
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(b.build()),INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID));
} else {
final EmbedBuilder b = Configuration.instance().embedMode.playerJoinMessage.toEmbed();
b.setAuthor(ForgeMessageUtils.formatPlayerName(p), null, avatarURL)
.setDescription(Localization.instance().playerJoin.replace("%player%", ForgeMessageUtils.formatPlayerName(p)));
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(b.build()));
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(b.build()),INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID));
}
} else
DiscordIntegration.INSTANCE.sendMessage(Localization.instance().playerJoin.replace("%player%", ForgeMessageUtils.formatPlayerName(p)));
DiscordIntegration.INSTANCE.sendMessage(Localization.instance().playerJoin.replace("%player%", ForgeMessageUtils.formatPlayerName(p)),INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID));
}
// Fix link status (if user does not have role, give the role to the user, or vice versa)
WorkThread.executeJob(() -> {
Expand Down Expand Up @@ -199,7 +199,7 @@ public void advancement(AdvancementEvent ev) {
.replace("%avatarURL%", avatarURL)
.replace("%playerColor%", "" + TextColors.generateFromUUID(ev.getEntity().getUUID()).getRGB())
);
INSTANCE.sendMessage(new DiscordMessage(b.build()));
INSTANCE.sendMessage(new DiscordMessage(b.build()),INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID));
} else {
EmbedBuilder b = Configuration.instance().embedMode.advancementMessage.toEmbed();
b = b.setAuthor(ForgeMessageUtils.formatPlayerName(ev.getEntity()), null, avatarURL)
Expand All @@ -214,7 +214,7 @@ public void advancement(AdvancementEvent ev) {
.getDescription()
.getString()))
.replace("\\n", "\n"));
INSTANCE.sendMessage(new DiscordMessage(b.build()));
INSTANCE.sendMessage(new DiscordMessage(b.build()),INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID));
}
} else INSTANCE.sendMessage(Localization.instance().advancementMessage.replace("%player%",
ChatFormatting.stripFormatting(ForgeMessageUtils.formatPlayerName(ev.getEntity())))
Expand All @@ -228,7 +228,7 @@ public void advancement(AdvancementEvent ev) {
.getDisplay()
.getDescription()
.getString()))
.replace("\\n", "\n"));
.replace("\\n", "\n"),INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID));
}
}

Expand All @@ -255,11 +255,11 @@ public void serverStarted(final ServerStartedEvent ev) {
if (Configuration.instance().embedMode.enabled && Configuration.instance().embedMode.startMessages.asEmbed) {
if (!Configuration.instance().embedMode.startMessages.customJSON.isBlank()) {
final EmbedBuilder b = Configuration.instance().embedMode.startMessages.toEmbedJson(Configuration.instance().embedMode.startMessages.customJSON);
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(b.build()));
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(b.build()),INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID));
} else
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(Configuration.instance().embedMode.startMessages.toEmbed().setDescription(Localization.instance().serverStarted).build()));
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(Configuration.instance().embedMode.startMessages.toEmbed().setDescription(Localization.instance().serverStarted).build()),INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID));
} else
DiscordIntegration.INSTANCE.sendMessage(Localization.instance().serverStarted);
DiscordIntegration.INSTANCE.sendMessage(Localization.instance().serverStarted,INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID));
}
INSTANCE.startThreads();
}
Expand Down Expand Up @@ -401,20 +401,20 @@ public void serverStopping(ServerStoppedEvent ev) {
if (Configuration.instance().embedMode.enabled && Configuration.instance().embedMode.stopMessages.asEmbed) {
if (!Configuration.instance().embedMode.stopMessages.customJSON.isBlank()) {
final EmbedBuilder b = Configuration.instance().embedMode.stopMessages.toEmbedJson(Configuration.instance().embedMode.stopMessages.customJSON);
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(b.build()));
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(b.build()),INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID));
} else
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(Configuration.instance().embedMode.stopMessages.toEmbed().setDescription(Localization.instance().serverStopped).build()));
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(Configuration.instance().embedMode.stopMessages.toEmbed().setDescription(Localization.instance().serverStopped).build()),INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID));
} else
DiscordIntegration.INSTANCE.sendMessage(Localization.instance().serverStopped);
DiscordIntegration.INSTANCE.sendMessage(Localization.instance().serverStopped,INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID));
else if (ev.getServer().isRunning() && !Localization.instance().serverCrash.isBlank()) {
if (Configuration.instance().embedMode.enabled && Configuration.instance().embedMode.stopMessages.asEmbed) {
if (!Configuration.instance().embedMode.stopMessages.customJSON.isBlank()) {
final EmbedBuilder b = Configuration.instance().embedMode.stopMessages.toEmbedJson(Configuration.instance().embedMode.stopMessages.customJSON);
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(b.build()));
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(b.build()),INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID));
} else
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(Configuration.instance().embedMode.stopMessages.toEmbed().setDescription(Localization.instance().serverStopped).build()));
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(Configuration.instance().embedMode.stopMessages.toEmbed().setDescription(Localization.instance().serverStopped).build()),INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID));
} else
DiscordIntegration.INSTANCE.sendMessage(Localization.instance().serverCrash);
DiscordIntegration.INSTANCE.sendMessage(Localization.instance().serverCrash,INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID));
}
INSTANCE.kill(false);
INSTANCE = null;
Expand Down Expand Up @@ -455,14 +455,14 @@ public void chat(ServerChatEvent ev) {
.replace("%msg%", text)
.replace("%playerColor%", "" + TextColors.generateFromUUID(ev.getPlayer().getUUID()).getRGB())
);
INSTANCE.sendMessage(new DiscordMessage(b.build()));
INSTANCE.sendMessage(new DiscordMessage(b.build()),channel);
} else {
EmbedBuilder b = Configuration.instance().embedMode.chatMessages.toEmbed();
if (Configuration.instance().embedMode.chatMessages.generateUniqueColors)
b = b.setColor(TextColors.generateFromUUID(ev.getPlayer().getUUID()));
b = b.setAuthor(ForgeMessageUtils.formatPlayerName(ev.getPlayer()), null, avatarURL)
.setDescription(text);
INSTANCE.sendMessage(new DiscordMessage(b.build()));
INSTANCE.sendMessage(new DiscordMessage(b.build()),channel);
}
} else
INSTANCE.sendMessage(ForgeMessageUtils.formatPlayerName(ev.getPlayer()), ev.getPlayer().getUUID().toString(), new DiscordMessage(embed, text, true), channel);
Expand All @@ -487,8 +487,8 @@ public void death(LivingDeathEvent ev) {
final MessageEmbed embed = ForgeMessageUtils.genItemStackEmbedIfAvailable(deathMessage);
if (Configuration.instance().embedMode.enabled && Configuration.instance().embedMode.deathMessage.asEmbed) {
final String avatarURL = Configuration.instance().webhook.playerAvatarURL.replace("%uuid%", ev.getEntity().getUUID().toString()).replace("%uuid_dashless%", ev.getEntity().getUUID().toString().replace("-", "")).replace("%name%", ev.getEntity().getName().getString()).replace("%randomUUID%", UUID.randomUUID().toString());
if (!Configuration.instance().embedMode.playerJoinMessage.customJSON.isBlank()) {
final EmbedBuilder b = Configuration.instance().embedMode.playerJoinMessage.toEmbedJson(Configuration.instance().embedMode.playerJoinMessage.customJSON
if (!Configuration.instance().embedMode.deathMessage.customJSON.isBlank()) {
final EmbedBuilder b = Configuration.instance().embedMode.deathMessage.toEmbedJson(Configuration.instance().embedMode.deathMessage.customJSON
.replace("%uuid%", ev.getEntity().getUUID().toString())
.replace("%uuid_dashless%", ev.getEntity().getUUID().toString().replace("-", ""))
.replace("%name%", ForgeMessageUtils.formatPlayerName(ev.getEntity()))
Expand All @@ -501,7 +501,7 @@ public void death(LivingDeathEvent ev) {
b.addBlankField(false);
b.addField(embed.getTitle() + " *(" + embed.getFooter().getText() + ")*", embed.getDescription(), false);
}
INSTANCE.sendMessage(new DiscordMessage(b.build()));
INSTANCE.sendMessage(new DiscordMessage(b.build()),INSTANCE.getChannel(Configuration.instance().advanced.deathsChannelID));
} else {
final EmbedBuilder b = Configuration.instance().embedMode.deathMessage.toEmbed();
b.setDescription(":skull: " + Localization.instance().playerDeath.replace("%player%", ForgeMessageUtils.formatPlayerName(ev.getEntity())).replace("%msg%", ChatFormatting.stripFormatting(deathMessage.getString()).replace(ForgeMessageUtils.formatPlayerName(ev.getEntity()) + " ", "")));
Expand Down Expand Up @@ -540,7 +540,7 @@ public void playerLeave(PlayerEvent.PlayerLoggedOutEvent ev) {
EmbedBuilder b = Configuration.instance().embedMode.playerLeaveMessages.toEmbed();
b = b.setAuthor(ForgeMessageUtils.formatPlayerName(player), null, avatarURL)
.setDescription(Localization.instance().playerLeave.replace("%player%", ForgeMessageUtils.formatPlayerName(player)));
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(b.build()));
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(b.build()),INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID));
}
} else
DiscordIntegration.INSTANCE.sendMessage(Localization.instance().playerLeave.replace("%player%", ForgeMessageUtils.formatPlayerName(player)));
Expand All @@ -551,9 +551,9 @@ public void playerLeave(PlayerEvent.PlayerLoggedOutEvent ev) {
EmbedBuilder b = Configuration.instance().embedMode.playerLeaveMessages.toEmbed();
b = b.setAuthor(ForgeMessageUtils.formatPlayerName(player), null, avatarURL)
.setDescription(Localization.instance().playerTimeout.replace("%player%", ForgeMessageUtils.formatPlayerName(player)));
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(b.build()));
DiscordIntegration.INSTANCE.sendMessage(new DiscordMessage(b.build()),INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID));
} else
DiscordIntegration.INSTANCE.sendMessage(Localization.instance().playerTimeout.replace("%player%", ForgeMessageUtils.formatPlayerName(player)));
DiscordIntegration.INSTANCE.sendMessage(Localization.instance().playerTimeout.replace("%player%", ForgeMessageUtils.formatPlayerName(player)),INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID));
}
DiscordIntegrationMod.timeouts.remove(player.getUUID());
}
Expand Down
Loading

0 comments on commit 74175d7

Please sign in to comment.