(update) allow /player and /track to be used in playground.
This commit is contained in:
1 file changed
+7
-7
@@ -21,7 +21,6 @@ import net.fabricmc.fabric.api.util.TriState;
|
|||||||
import net.minecraft.command.CommandRegistryAccess;
|
import net.minecraft.command.CommandRegistryAccess;
|
||||||
import net.minecraft.command.CommandSource;
|
import net.minecraft.command.CommandSource;
|
||||||
import net.minecraft.network.packet.s2c.play.TeamS2CPacket;
|
import net.minecraft.network.packet.s2c.play.TeamS2CPacket;
|
||||||
import net.minecraft.registry.RegistryKey;
|
|
||||||
import net.minecraft.scoreboard.Team;
|
import net.minecraft.scoreboard.Team;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.command.CommandManager;
|
import net.minecraft.server.command.CommandManager;
|
||||||
@@ -30,16 +29,17 @@ import net.minecraft.server.network.ServerPlayNetworkHandler;
|
|||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Colors;
|
import net.minecraft.util.Colors;
|
||||||
import net.minecraft.world.chunk.ChunkStatus;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class CreativeRoomModule extends ServerModule {
|
public class CreativeRoomModule extends ServerModule {
|
||||||
private static final Set<String> ALLOWED_VANILLA_COMMANDS = Set.of(
|
private static final Set<String> BYPASS_PERMISSIONS = Set.of(
|
||||||
"minecraft.command.weather",
|
"minecraft.command.weather",
|
||||||
"minecraft.command.time",
|
"minecraft.command.time",
|
||||||
"minecraft.command.gamerule");
|
"minecraft.command.gamerule",
|
||||||
|
"carpet.command.player",
|
||||||
|
"carpet.command.track");
|
||||||
@Inject
|
@Inject
|
||||||
private RoomRegistry roomRegistry;
|
private RoomRegistry roomRegistry;
|
||||||
@Inject
|
@Inject
|
||||||
@@ -58,7 +58,7 @@ public class CreativeRoomModule extends ServerModule {
|
|||||||
ServerPlayConnectionEvents.JOIN.register(this::onJoin);
|
ServerPlayConnectionEvents.JOIN.register(this::onJoin);
|
||||||
ServerPlayConnectionEvents.DISCONNECT.register(this::onDisconnect);
|
ServerPlayConnectionEvents.DISCONNECT.register(this::onDisconnect);
|
||||||
PermissionCheckEvent.EVENT.register(this::onWorldEdit);
|
PermissionCheckEvent.EVENT.register(this::onWorldEdit);
|
||||||
PermissionCheckEvent.EVENT.register(this::onVanillaCommands);
|
PermissionCheckEvent.EVENT.register(this::onOtherCommands);
|
||||||
SFCallbacks.PLAYER_AFK.register(this::onAFK);
|
SFCallbacks.PLAYER_AFK.register(this::onAFK);
|
||||||
room = new CreativeSpaceRoom();
|
room = new CreativeSpaceRoom();
|
||||||
roomRegistry.registerRoomType(CreativeSpaceRoom.class, CreativeSpaceRoom.WORLD, new CreativeSpaceFactory(room));
|
roomRegistry.registerRoomType(CreativeSpaceRoom.class, CreativeSpaceRoom.WORLD, new CreativeSpaceFactory(room));
|
||||||
@@ -66,11 +66,11 @@ public class CreativeRoomModule extends ServerModule {
|
|||||||
roomModule.enqueuePregen(CreativeSpaceRoom.WORLD, CreativeSpaceRoom.SPAWN_POS);
|
roomModule.enqueuePregen(CreativeSpaceRoom.WORLD, CreativeSpaceRoom.SPAWN_POS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull TriState onVanillaCommands(@NotNull CommandSource commandSource, @NotNull String s) {
|
private @NotNull TriState onOtherCommands(@NotNull CommandSource commandSource, @NotNull String s) {
|
||||||
if (commandSource instanceof ServerCommandSource source && source.getPlayer() != null) {
|
if (commandSource instanceof ServerCommandSource source && source.getPlayer() != null) {
|
||||||
var p = source.getPlayer();
|
var p = source.getPlayer();
|
||||||
if (p.getServerWorld().getRegistryKey().equals(CreativeSpaceRoom.WORLD)) {
|
if (p.getServerWorld().getRegistryKey().equals(CreativeSpaceRoom.WORLD)) {
|
||||||
if (ALLOWED_VANILLA_COMMANDS.contains(s)) {
|
if (BYPASS_PERMISSIONS.contains(s)) {
|
||||||
return TriState.TRUE;
|
return TriState.TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user