Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public void loadValues() {

verification.timeOfDay = clamp(generalConfig.getInt("verification.time-of-day"), 0, 24000);
verification.gamemode = Verification.Gamemode.valueOf(generalConfig.getString("verification.gamemode"));
verification.dimension = Verification.Dimension.valueOf(generalConfig.getString("verification.dimension"));
verification.validNameRegex = Pattern.compile(generalConfig.getString("verification.checks.valid-name-regex"));

verification.checkGeyser = generalConfig.getBoolean("verification.check-geyser-players");
Expand Down Expand Up @@ -405,6 +406,7 @@ public static final class Brand {
}

private Gamemode gamemode;
private Dimension dimension;

@Getter
@RequiredArgsConstructor
Expand All @@ -421,6 +423,16 @@ public boolean isSurvivalOrAdventure() {
}
}

@Getter
@RequiredArgsConstructor
public enum Dimension {
OVERWORLD("minecraft:overworld"),
THE_NETHER("minecraft:the_nether"),
THE_END("minecraft:the_end");

private final String key;
}

private int timeOfDay;
private boolean checkGeyser;
private boolean checkEagler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,16 @@ public void prepare() {
loginSuccess = new SonarPacketSnapshot(new LoginSuccessPacket(uuid, username, true));

// Prepare JoinGame packet
final SonarConfiguration.Verification.Dimension configDimension =
Sonar.get0().getConfig().getVerification().getDimension();
final DimensionType verificationDimension = DimensionType.valueOf(configDimension.name());
final String dimensionKey = configDimension.getKey();
joinGame = new SonarPacketSnapshot(new JoinGamePacket(PLAYER_ENTITY_ID,
Sonar.get0().getConfig().getVerification().getGamemode().getId(),
-1, 0, 0,
RANDOM.nextInt(3), 1, 0, 0,
new String[]{"minecraft:overworld"}, "minecraft:overworld", "flat",
DimensionType.OVERWORLD, RANDOM.nextLong() & 1337,
new String[]{dimensionKey}, dimensionKey, "flat",
verificationDimension, RANDOM.nextLong() & 1337,
false, true, false,
false, false, false, true));

Expand All @@ -177,7 +181,7 @@ public void prepare() {
// Set the dynamic block and collide Y position based on the maximum fall distance
dynamicSpawnYPosition = PLATFORM_Y_POSITION + (int) Math.ceil(fallDistance);
defaultSpawnPosition = new SonarPacketSnapshot(new SetDefaultSpawnPositionPacket(
"minecraft:overworld",
dimensionKey,
SPAWN_X_POSITION, IN_AIR_Y_POSITION, SPAWN_Z_POSITION));
spawnPosition = new SonarPacketSnapshot(new SetPlayerPositionRotationPacket(
SPAWN_X_POSITION, IN_AIR_Y_POSITION, SPAWN_Z_POSITION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void encode(final @NotNull ByteBuf byteBuf, final @NotNull ProtocolVersio
byteBuf.writeBoolean(limitedCrafting);

if (protocolVersion.greaterThanOrEquals(ProtocolVersion.MINECRAFT_1_20_5)) {
ProtocolUtil.writeVarInt(byteBuf, dimension.getId());
ProtocolUtil.writeVarInt(byteBuf, findDimensionId(getRegistryCodec(protocolVersion)));
} else {
ProtocolUtil.writeString(byteBuf, dimension.getKey());
}
Expand Down Expand Up @@ -173,6 +173,40 @@ public void encode(final @NotNull ByteBuf byteBuf, final @NotNull ProtocolVersio
}
}

private int findDimensionId(final @NotNull CompoundBinaryTag codec) {
final CompoundBinaryTag dimensionType = codec.getCompound("minecraft:dimension_type");
if (dimensionType == null) return dimension.getId();
final ListBinaryTag values = dimensionType.getList("value");
if (values == null) return dimension.getId();
for (int i = 0; i < values.size(); i++) {
final CompoundBinaryTag entry = (CompoundBinaryTag) values.get(i);
if (entry == null) continue;
if (levelName.equals(entry.getString("name"))) {
return entry.getInt("id");
}
}
return dimension.getId();
}

private static @NotNull CompoundBinaryTag getRegistryCodec(final @NotNull ProtocolVersion protocolVersion) {
if (protocolVersion.greaterThanOrEquals(ProtocolVersion.MINECRAFT_26_1)) {
return DimensionRegistry.CODEC_26_1;
} else if (protocolVersion.greaterThanOrEquals(ProtocolVersion.MINECRAFT_1_21_11)) {
return DimensionRegistry.CODEC_1_21_11;
} else if (protocolVersion.greaterThanOrEquals(ProtocolVersion.MINECRAFT_1_21_5)) {
return DimensionRegistry.CODEC_1_21_5;
} else if (protocolVersion.greaterThanOrEquals(ProtocolVersion.MINECRAFT_1_21_4)) {
return DimensionRegistry.CODEC_1_21_4;
} else if (protocolVersion.greaterThanOrEquals(ProtocolVersion.MINECRAFT_1_21_2)) {
return DimensionRegistry.CODEC_1_21_2;
} else if (protocolVersion.greaterThanOrEquals(ProtocolVersion.MINECRAFT_1_21)) {
return DimensionRegistry.CODEC_1_21;
} else if (protocolVersion.greaterThanOrEquals(ProtocolVersion.MINECRAFT_1_20_5)) {
return DimensionRegistry.CODEC_1_20_5;
}
return DimensionRegistry.CODEC_1_20;
}

private static CompoundBinaryTag getCodec(final @NotNull ProtocolVersion protocolVersion) {
if (protocolVersion.greaterThanOrEquals(ProtocolVersion.MINECRAFT_1_20)) {
return DimensionRegistry.CODEC_1_20;
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/resources/assets/config/cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ verification:
# na kterém proxy naslouchá (port "bind" v konfiguraci vašeho proxy).
destination-port: 25565

# Dimenze ověřovacího světa
# Typy: OVERWORLD, THE_NETHER, THE_END
dimension: OVERWORLD
# Gamemode hráče při verifikaci
# Typy: SURVIVAL, CREATIVE, ADVENTURE
# - SURVIVAL: všechny komponenty UI jsou zobrazeny
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/resources/assets/config/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ verification:
# den Port, auf dem der Proxy horcht (den "Bind"-Port in Ihrer Proxy-Konfiguration).
destination-port: 25565

# Die Dimension der Verifizierungswelt
# Mögliche Typen: OVERWORLD, THE_NETHER, THE_END
dimension: OVERWORLD
# Der Spielmodus des Spielers während der Überprüfung
# Mögliche Typen: SURVIVAL, CREATIVE, ADVENTURE
# - SURVIVAL: alle UI-Komponenten sind sichtbar
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/resources/assets/config/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ verification:
# the port the proxy is listening on (the "bind" port in your proxy config).
destination-port: 25565

# The dimension of the verification world
# Possible types: OVERWORLD, THE_NETHER, THE_END
dimension: OVERWORLD
# The gamemode of the player during verification
# Possible types: SURVIVAL, CREATIVE, ADVENTURE
# - SURVIVAL: all UI components are visible
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/resources/assets/config/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ verification:
# le port d'écoute du proxy (le port "bind" dans la configuration de votre proxy).
destination-port: 25565

# La dimension du monde de vérification
# Types possibles : OVERWORLD, THE_NETHER, THE_END
dimension: OVERWORLD
# Le mode de jeu du joueur pendant la vérification
# Types possibles : SURVIVAL, CREATIVE, ADVENTURE
# - SURVIVAL : tous les composants de l'interface utilisateur sont visibles
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/resources/assets/config/ka.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ verification:
# რომელზეც პროქსი უსმენს ("bind" პორტი თქვენი პროქსის კონფიგურაციაში).
destination-port: 25565

# გადამოწმების სამყაროს განზომილება
# შესაძლო ტიპები: OVERWORLD, THE_NETHER, THE_END
dimension: OVERWORLD
# მოთამაშის თამაშის რეჟიმი გადამოწმების დროს
# შესაძლო ტიპები: SURVIVAL, CREATIVE, ADVENTURE
# - SURVIVAL: ყველა UI კომპონენტი ჩანს
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/resources/assets/config/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ verification:
# de poort waarop de proxy luistert (de "bind"-poort in uw proxyconfiguratie).
destination-port: 25565

# De dimensie van de verificatiewereld
# Mogelijke typen: OVERWORLD, THE_NETHER, THE_END
dimension: OVERWORLD
# De spelmodus van de speler tijdens verificatie
# Mogelijke typen: SURVIVAL, CREATIVE, ADVENTURE
# - SURVIVAL: alle UI-componenten zijn zichtbaar
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/resources/assets/config/pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ verification:
# na którym nasłuchuje proxy (port "bind" w konfiguracji twojego proxy).
destination-port: 25565

# Wymiar świata weryfikacji
# Dostępne rodzaje: OVERWORLD, THE_NETHER, THE_END
dimension: OVERWORLD
# Tryb gry gracza (gamemode) podczas weryfikacji
# Dostępne rodzaje: SURVIVAL, CREATIVE, ADVENTURE
# - SURVIVAL: Wszystkie komponenty interfejsu są widoczne
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/resources/assets/config/pt-br.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ verification:
# a porta em que o proxy está ouvindo (a porta "bind" na configuração do seu proxy).
destination-port: 25565

# A dimensão do mundo de verificação
# Tipos possíveis: OVERWORLD, THE_NETHER, THE_END
dimension: OVERWORLD
# O modo de jogo do jogador durante a verificação
# Tipos possíveis: SURVIVAL, CREATIVE, ADVENTURE
# - SURVIVAL: todos os componentes da UI são visíveis
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/resources/assets/config/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ verification:
# на котором слушает прокси (порт "bind" в конфигурации вашего прокси).
destination-port: 25565

# Измерение мира проверки
# Возможные типы: OVERWORLD, THE_NETHER, THE_END
dimension: OVERWORLD
# Режим игрока во время проверки
# Возможные типы: SURVIVAL, CREATIVE, ADVENTURE
# - SURVIVAL: все компоненты пользовательского интерфейса видны
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/resources/assets/config/zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ verification:
# 代理服务器监听的端口 (代理配置中的 "bind" 端口)。
destination-port: 25565

# 验证世界的维度
# 可用类型: OVERWORLD, THE_NETHER, THE_END
dimension: OVERWORLD
# 玩家正在验证时所使用的游戏模式
# 可用类型: SURVIVAL, CREATIVE, ADVENTURE
# - SURVIVAL: 生存模式, 所有UI可见
Expand Down
Loading