Skip to content

Commit

Permalink
fix mc2discord messages
Browse files Browse the repository at this point in the history
closes #16
  • Loading branch information
MelanX committed Jul 12, 2023
1 parent 3a42123 commit 53bf667
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/java/de/melanx/simplebackups/BackupThread.java
Expand Up @@ -20,6 +20,7 @@
import org.slf4j.LoggerFactory;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -170,15 +171,17 @@ private void broadcast(String message, Style style, Object... parameters) {
});

if (Mc2DiscordCompat.isLoaded() && CommonConfig.mc2discord()) {
Mc2DiscordCompat.announce(Component.translatable(message, parameters));
Mc2DiscordCompat.announce(BackupThread.component(null, message, parameters));
}
}
}

public static MutableComponent component(ServerPlayer player, String key, Object... parameters) {
ConnectionData data = NetworkHooks.getConnectionData(player.connection.connection);
if (data != null && data.getModList().contains(SimpleBackups.MODID)) {
return Component.translatable(key, parameters);
public static MutableComponent component(@Nullable ServerPlayer player, String key, Object... parameters) {
if (player != null) {
ConnectionData data = NetworkHooks.getConnectionData(player.connection.connection);
if (data != null && data.getModList().contains(SimpleBackups.MODID)) {
return Component.translatable(key, parameters);
}
}

return Component.literal(String.format(ForgeI18n.getPattern(key), parameters));
Expand Down

0 comments on commit 53bf667

Please sign in to comment.