Skip to content

Commit b10689f

Browse files
authored
Fix modded console Discord to Minecraft chat (#70)
1 parent 4c8d1c6 commit b10689f

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

modded/src/main/java/com/discordsrv/modded/ModdedComponentFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.discordsrv.api.component.MinecraftComponent;
2222
import com.discordsrv.common.core.component.ComponentFactory;
2323
import com.discordsrv.common.util.ComponentUtil;
24+
import com.discordsrv.modded.command.game.sender.ModdedCommandSender;
2425
import com.google.common.base.Suppliers;
2526
import com.discordsrv.unrelocate.com.google.gson.Gson;
2627
import com.discordsrv.unrelocate.com.google.gson.JsonElement;
@@ -29,7 +30,6 @@
2930
import net.kyori.adventure.audience.Audience;
3031
import net.kyori.adventure.text.Component;
3132
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
32-
import net.minecraft.commands.CommandSourceStack;
3333
import net.minecraft.core.HolderLookup;
3434
import net.minecraft.core.RegistryAccess;
3535
import org.jetbrains.annotations.NotNull;
@@ -84,11 +84,11 @@ public MinecraftComponent toAPI(net.minecraft.network.chat.Component text) {
8484
return toAPI(fromNative(text));
8585
}
8686

87-
public Audience audience(@NotNull CommandSourceStack source) {
87+
public Audience audience(@NotNull ModdedCommandSender sender) {
8888
return new Audience() {
8989
@Override
9090
public void sendMessage(@NotNull Component message) {
91-
source.sendSystemMessage(serialize(message));
91+
sender.commandSource.sendSystemMessage(serialize(message));
9292
}
9393
};
9494
}

modded/src/main/java/com/discordsrv/modded/command/game/sender/ModdedCommandSender.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@
3434
public class ModdedCommandSender implements ICommandSender {
3535

3636
protected final ModdedDiscordSRV discordSRV;
37-
protected CommandSourceStack commandSource;
3837
protected Audience audience;
3938

39+
public CommandSourceStack commandSource;
40+
4041
public ModdedCommandSender(ModdedDiscordSRV discordSRV, CommandSourceStack commandSource) {
4142
this.discordSRV = discordSRV;
4243
this.commandSource = commandSource;
43-
this.audience = discordSRV.componentFactory().audience(commandSource);
44+
this.audience = discordSRV.componentFactory().audience(this);
4445
}
4546

4647
@Override

0 commit comments

Comments
 (0)