[NOJANG] Allow commands to send feedback as chat messages, if command feedback is disabled
This commit is contained in:
@@ -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));
|
||||||
|
@@ -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
|
Reference in New Issue
Block a user