[NOJANG] Allow commands to send feedback as chat messages, if command feedback is disabled

This commit is contained in:
2025-04-28 14:01:14 +02:00
parent c6e5549fa9
commit 4a0314462e
2 changed files with 15 additions and 2 deletions

View File

@@ -8,14 +8,24 @@ import net.minecraft.commands.CommandSourceStack;
import java.util.function.Supplier; import java.util.function.Supplier;
import static net.minecraft.world.level.GameRules.RULE_SENDCOMMANDFEEDBACK;
@RequiredArgsConstructor(staticName = "of") @RequiredArgsConstructor(staticName = "of")
public class BridgedCommandSourceStack { public class BridgedCommandSourceStack {
private final CommandSourceStack internal; private final CommandSourceStack internal;
public void sendSuccess(Supplier<Component> supplier, boolean bl) { public void sendSuccess(Supplier<Component> supplier, boolean bl) {
if (!internal.getServer().getGameRules().getBoolean(RULE_SENDCOMMANDFEEDBACK)) {
internal.sendSystemMessage(ChatUtils.adventureToMojang(supplier.get()));
} else {
internal.sendSuccess(() -> ChatUtils.adventureToMojang(supplier.get()), bl); internal.sendSuccess(() -> ChatUtils.adventureToMojang(supplier.get()), bl);
} }
}
public void sendMessage(Component text) {
internal.sendSystemMessage(ChatUtils.adventureToMojang(text));
}
public void sendFailure(Component text) { public void sendFailure(Component text) {
internal.sendFailure(ChatUtils.adventureToMojang(text)); internal.sendFailure(ChatUtils.adventureToMojang(text));

View File

@@ -1,4 +1,7 @@
**Bug Fixes**: **Bug Fixes**:
- Fix Adventure Serializer failing completely when serialization fails, causing game glitches - Fix Adventure Serializer failing completely when serialization fails, causing game glitches
-
**New Features**:
- Allow commands to send feedback as chat messages, if command feedback is disabled