Skip to content

Commit 6526446

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 67f4a39 + 113bf1e commit 6526446

File tree

409 files changed

+17015
-4015
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

409 files changed

+17015
-4015
lines changed

.editorconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ ij_java_class_count_to_use_import_on_demand = 999999
1010
ij_java_names_count_to_use_import_on_demand = 999999
1111
ij_java_imports_layout = *,|,$*
1212
ij_java_generate_final_locals = true
13-
ij_java_generate_final_parameters = true
13+
ij_java_generate_final_parameters = true
14+
15+
[{*.json,*.yml}]
16+
indent_size = 2

.github/workflows/gradle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Checkout Repository
1414
uses: actions/checkout@v4
1515
- name: Validate Gradle Wrapper
16-
uses: gradle/wrapper-validation-action@v1
16+
uses: gradle/wrapper-validation-action@v2
1717
- name: Set up JDK 17
1818
uses: actions/setup-java@v4
1919
with:

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Checkout Repository
1414
uses: actions/checkout@v4
1515
- name: Validate Gradle Wrapper
16-
uses: gradle/wrapper-validation-action@v1
16+
uses: gradle/wrapper-validation-action@v2
1717
- name: Set up JDK 17
1818
uses: actions/setup-java@v4
1919
with:

api-legacy/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
package us.myles.ViaVersion.api.protocol;
2424

2525
import com.google.common.base.Preconditions;
26-
import com.viaversion.viaversion.api.protocol.version.VersionRange;
26+
import com.viaversion.viaversion.api.protocol.version.SubVersionRange;
2727
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
2828
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
2929
import java.util.ArrayList;
@@ -42,23 +42,23 @@ public class ProtocolVersion {
4242
private static final Int2ObjectMap<ProtocolVersion> versions = new Int2ObjectOpenHashMap<>();
4343
private static final List<ProtocolVersion> versionList = new ArrayList<>();
4444

45-
public static final ProtocolVersion v1_4_6 = register(51, "1.4.6/7", new VersionRange("1.4", 6, 7));
45+
public static final ProtocolVersion v1_4_6 = register(51, "1.4.6/7", new SubVersionRange("1.4", 6, 7));
4646
public static final ProtocolVersion v1_5_1 = register(60, "1.5.1");
4747
public static final ProtocolVersion v1_5_2 = register(61, "1.5.2");
4848
public static final ProtocolVersion v_1_6_1 = register(73, "1.6.1");
4949
public static final ProtocolVersion v_1_6_2 = register(74, "1.6.2");
5050
public static final ProtocolVersion v_1_6_3 = register(77, "1.6.3");
5151
public static final ProtocolVersion v_1_6_4 = register(78, "1.6.4");
52-
public static final ProtocolVersion v1_7_1 = register(4, "1.7-1.7.5", new VersionRange("1.7", 0, 5));
53-
public static final ProtocolVersion v1_7_6 = register(5, "1.7.6-1.7.10", new VersionRange("1.7", 6, 10));
52+
public static final ProtocolVersion v1_7_1 = register(4, "1.7-1.7.5", new SubVersionRange("1.7", 0, 5));
53+
public static final ProtocolVersion v1_7_6 = register(5, "1.7.6-1.7.10", new SubVersionRange("1.7", 6, 10));
5454
public static final ProtocolVersion v1_8 = register(47, "1.8.x");
5555
public static final ProtocolVersion v1_9 = register(107, "1.9");
5656
public static final ProtocolVersion v1_9_1 = register(108, "1.9.1");
5757
public static final ProtocolVersion v1_9_2 = register(109, "1.9.2");
58-
public static final ProtocolVersion v1_9_3 = register(110, "1.9.3/4", new VersionRange("1.9", 3, 4));
58+
public static final ProtocolVersion v1_9_3 = register(110, "1.9.3/1.9.4", new SubVersionRange("1.9", 3, 4));
5959
public static final ProtocolVersion v1_10 = register(210, "1.10.x");
6060
public static final ProtocolVersion v1_11 = register(315, "1.11");
61-
public static final ProtocolVersion v1_11_1 = register(316, "1.11.1/2", new VersionRange("1.11", 1, 2));
61+
public static final ProtocolVersion v1_11_1 = register(316, "1.11.1/1.11.2", new SubVersionRange("1.11", 1, 2));
6262
public static final ProtocolVersion v1_12 = register(335, "1.12");
6363
public static final ProtocolVersion v1_12_1 = register(338, "1.12.1");
6464
public static final ProtocolVersion v1_12_2 = register(340, "1.12.2");
@@ -77,18 +77,19 @@ public class ProtocolVersion {
7777
public static final ProtocolVersion v1_16_1 = register(736, "1.16.1");
7878
public static final ProtocolVersion v1_16_2 = register(751, "1.16.2");
7979
public static final ProtocolVersion v1_16_3 = register(753, "1.16.3");
80-
public static final ProtocolVersion v1_16_4 = register(754, "1.16.4/5", new VersionRange("1.16", 4, 5));
80+
public static final ProtocolVersion v1_16_4 = register(754, "1.16.4/1.16.5", new SubVersionRange("1.16", 4, 5));
8181
public static final ProtocolVersion v1_17 = register(755, "1.17");
8282
public static final ProtocolVersion v1_17_1 = register(756, "1.17.1");
83-
public static final ProtocolVersion v1_18 = register(757, "1.18/1.18.1", new VersionRange("1.18", 0, 1));
83+
public static final ProtocolVersion v1_18 = register(757, "1.18/1.18.1", new SubVersionRange("1.18", 0, 1));
8484
public static final ProtocolVersion v1_18_2 = register(758, "1.18.2");
8585
public static final ProtocolVersion v1_19 = register(759, "1.19");
86-
public static final ProtocolVersion v1_19_1 = register(760, "1.19.1/2", new VersionRange("1.19", 1, 2));
86+
public static final ProtocolVersion v1_19_1 = register(760, "1.19.1/1.19.2", new SubVersionRange("1.19", 1, 2));
8787
public static final ProtocolVersion v1_19_3 = register(761, "1.19.3");
8888
public static final ProtocolVersion v1_19_4 = register(762, "1.19.4");
89-
public static final ProtocolVersion v1_20 = register(763, "1.20/1.20.1", new VersionRange("1.20", 0, 1));
89+
public static final ProtocolVersion v1_20 = register(763, "1.20/1.20.1", new SubVersionRange("1.20", 0, 1));
9090
public static final ProtocolVersion v1_20_2 = register(764, "1.20.2");
91-
public static final ProtocolVersion v1_20_3 = register(765, "1.20.3");
91+
public static final ProtocolVersion v1_20_3 = register(765, "1.20.3/1.20.4", new SubVersionRange("1.20", 3, 4));
92+
public static final ProtocolVersion v1_20_5 = register(766, "1.20.5");
9293
public static final ProtocolVersion unknown = register(-1, "UNKNOWN");
9394

9495
public static ProtocolVersion register(int version, String name) {
@@ -99,11 +100,11 @@ public static ProtocolVersion register(int version, int snapshotVersion, String
99100
return register(version, snapshotVersion, name, null);
100101
}
101102

102-
public static ProtocolVersion register(int version, String name, @Nullable VersionRange versionRange) {
103+
public static ProtocolVersion register(int version, String name, @Nullable SubVersionRange versionRange) {
103104
return register(version, -1, name, versionRange);
104105
}
105106

106-
public static ProtocolVersion register(int version, int snapshotVersion, String name, @Nullable VersionRange versionRange) {
107+
public static ProtocolVersion register(int version, int snapshotVersion, String name, @Nullable SubVersionRange versionRange) {
107108
ProtocolVersion protocol = new ProtocolVersion(version, snapshotVersion, name, versionRange);
108109
versionList.add(protocol);
109110
versions.put(protocol.getVersion(), protocol);
@@ -166,7 +167,7 @@ public ProtocolVersion(int version, String name) {
166167
this(version, -1, name, null);
167168
}
168169

169-
public ProtocolVersion(int version, int snapshotVersion, String name, @Nullable VersionRange versionRange) {
170+
public ProtocolVersion(int version, int snapshotVersion, String name, @Nullable SubVersionRange versionRange) {
170171
this.version = version;
171172
this.snapshotVersion = snapshotVersion;
172173
this.name = name;

api/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ sourceSets {
1616

1717
dependencies {
1818
api(libs.fastutil)
19-
api(libs.flare)
20-
api(libs.flareFastutil)
2119
api(libs.vianbt)
2220
api(libs.gson)
2321
implementation(rootProject.libs.text) {

api/src/main/java/com/viaversion/viaversion/api/ViaAPI.java

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@
2727
import com.viaversion.viaversion.api.legacy.LegacyViaAPI;
2828
import com.viaversion.viaversion.api.platform.ViaPlatform;
2929
import com.viaversion.viaversion.api.protocol.ProtocolManager;
30+
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
3031
import com.viaversion.viaversion.api.protocol.version.ServerProtocolVersion;
3132
import io.netty.buffer.ByteBuf;
3233
import java.util.SortedSet;
34+
import java.util.TreeSet;
3335
import java.util.UUID;
36+
import java.util.stream.Collectors;
3437
import org.checkerframework.checker.nullness.qual.Nullable;
3538

3639
/**
@@ -63,7 +66,7 @@ default int majorVersion() {
6366
* @return API version incremented with meaningful API changes
6467
*/
6568
default int apiVersion() {
66-
return 23;
69+
return 26;
6770
}
6871

6972
/**
@@ -80,15 +83,38 @@ default int apiVersion() {
8083
* @param player the platform's player object, e.g. Bukkit this is Player
8184
* @return protocol version, for example (47=1.8-1.8.8, 107=1.9, 108=1.9.1), or -1 if no longer connected
8285
*/
83-
int getPlayerVersion(T player);
86+
default int getPlayerVersion(T player) {
87+
return getPlayerProtocolVersion(player).getVersion();
88+
}
89+
90+
/**
91+
* Returns the protocol version of a player.
92+
* This will also retrieve the version from ProtocolSupport if it's being used.
93+
*
94+
* @param player the platform's player object, e.g. Bukkit this is Player
95+
* @return the protocol version object (see {@link ProtocolVersion}), or ProtocolVersion.unknown if not connected
96+
*/
97+
ProtocolVersion getPlayerProtocolVersion(T player);
8498

8599
/**
86100
* Returns the protocol version of a player.
87101
*
88102
* @param uuid UUID of a player
89103
* @return protocol version, for example (47=1.8-1.8.8, 107=1.9, 108=1.9.1), or -1 if not connected
90104
*/
91-
int getPlayerVersion(UUID uuid);
105+
default int getPlayerVersion(UUID uuid) {
106+
return getPlayerProtocolVersion(uuid).getVersion();
107+
}
108+
109+
110+
/**
111+
* Returns the protocol version of a player.
112+
* This will also retrieve the version from ProtocolSupport if it's being used.
113+
*
114+
* @param uuid UUID of a player
115+
* @return the protocol version object (see {@link ProtocolVersion}), or ProtocolVersion.unknown if not connected
116+
*/
117+
ProtocolVersion getPlayerProtocolVersion(UUID uuid);
92118

93119
/**
94120
* Returns whether Via injected into this player connection.
@@ -131,21 +157,32 @@ default int apiVersion() {
131157
*/
132158
void sendRawPacket(UUID uuid, ByteBuf packet);
133159

160+
@Deprecated
161+
default SortedSet<Integer> getSupportedVersions() {
162+
return getSupportedProtocolVersions().stream().map(ProtocolVersion::getVersion).collect(Collectors.toCollection(TreeSet::new));
163+
}
164+
165+
@Deprecated
166+
default SortedSet<Integer> getFullSupportedVersions() {
167+
return getFullSupportedProtocolVersions().stream().map(ProtocolVersion::getVersion).collect(Collectors.toCollection(TreeSet::new));
168+
}
169+
134170
/**
135171
* Returns the supported protocol versions.
136172
* This method removes any blocked protocol versions.
137173
*
138174
* @return a sorted set of protocol versions
139175
* @see #getFullSupportedVersions() for a full list
140176
*/
141-
SortedSet<Integer> getSupportedVersions();
177+
SortedSet<ProtocolVersion> getSupportedProtocolVersions();
178+
142179

143180
/**
144181
* Returns the supported protocol versions, including blocked protocols.
145182
*
146183
* @return a sorted set of protocol versions
147184
*/
148-
SortedSet<Integer> getFullSupportedVersions();
185+
SortedSet<ProtocolVersion> getFullSupportedProtocolVersions();
149186

150187
/**
151188
* Returns legacy api only applicable on/to legacy versions.

api/src/main/java/com/viaversion/viaversion/api/configuration/ViaVersionConfig.java

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import com.viaversion.viaversion.api.connection.UserConnection;
2828
import com.viaversion.viaversion.api.minecraft.WorldIdentifiers;
2929
import com.viaversion.viaversion.api.protocol.version.BlockedProtocolVersions;
30-
import it.unimi.dsi.fastutil.ints.IntSet;
31-
import org.checkerframework.checker.nullness.qual.Nullable;
3230

3331
public interface ViaVersionConfig extends Config {
3432

@@ -235,13 +233,6 @@ public interface ViaVersionConfig extends Config {
235233
*/
236234
boolean isChunkBorderFix();
237235

238-
/**
239-
* Force json transform
240-
*
241-
* @return true if enabled
242-
*/
243-
boolean isForceJsonTransform();
244-
245236
/**
246237
* Should we fix nbt array's in json chat messages for 1.12 clients
247238
*
@@ -272,17 +263,6 @@ public interface ViaVersionConfig extends Config {
272263
*/
273264
BlockedProtocolVersions blockedProtocolVersions();
274265

275-
/**
276-
* Get the blocked protocols
277-
*
278-
* @return An Integer list
279-
* @deprecated use {@link #blockedProtocolVersions()}
280-
*/
281-
@Deprecated/*(forRemoval = true)*/
282-
default IntSet getBlockedProtocols() {
283-
return blockedProtocolVersions().singleBlockedVersions();
284-
}
285-
286266
/**
287267
* Get the custom disconnect message
288268
*
@@ -463,4 +443,18 @@ default IntSet getBlockedProtocols() {
463443
* @return true if enabled
464444
*/
465445
boolean isArmorToggleFix();
446+
447+
/**
448+
* If disabled, tamed cats will be displayed as ocelots to 1.14+ clients on 1.13 servers. Otherwise, ocelots (tamed and untamed) will be displayed as cats.
449+
*
450+
* @return true if enabled
451+
*/
452+
boolean translateOcelotToCat();
453+
454+
/**
455+
* Returns the value of the "enforce secure chat" setting sent to 1.19+ clients on join.
456+
*
457+
* @return the value sent to 1.19+ clients on join
458+
*/
459+
boolean enforceSecureChat();
466460
}

api/src/main/java/com/viaversion/viaversion/api/connection/ProtocolInfo.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.viaversion.viaversion.api.protocol.ProtocolPipeline;
2626
import com.viaversion.viaversion.api.protocol.packet.Direction;
2727
import com.viaversion.viaversion.api.protocol.packet.State;
28+
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
2829
import java.util.UUID;
2930
import org.checkerframework.checker.nullness.qual.Nullable;
3031

@@ -93,24 +94,36 @@ default void setState(final State state) {
9394
void setServerState(State serverState);
9495

9596
/**
96-
* Returns the user's protocol version, or -1 if not set.
97+
* Returns the user's protocol version, or null if not set.
9798
* This is set during the {@link State#HANDSHAKE} state.
9899
*
99-
* @return protocol version, or -1 if not set
100+
* @return protocol version, may be unknown
101+
* @see ProtocolVersion#isKnown()
100102
*/
101-
int getProtocolVersion();
103+
ProtocolVersion protocolVersion();
102104

103-
void setProtocolVersion(int protocolVersion);
105+
void setProtocolVersion(ProtocolVersion protocolVersion);
104106

105107
/**
106-
* Returns the server protocol version the user is connected to, or -1 if not set.
108+
* Returns the server protocol version the user is connected to.
107109
* This is set during the {@link State#HANDSHAKE} state.
108110
*
109-
* @return server protocol version, or -1 if not set
111+
* @return the server protocol version the user is connected to, may be unknown
112+
* @see ProtocolVersion#isKnown()
110113
*/
111-
int getServerProtocolVersion();
114+
ProtocolVersion serverProtocolVersion();
112115

113-
void setServerProtocolVersion(int serverProtocolVersion);
116+
void setServerProtocolVersion(ProtocolVersion protocolVersion);
117+
118+
@Deprecated
119+
default int getProtocolVersion() {
120+
return protocolVersion() != null ? protocolVersion().getVersion() : -1;
121+
}
122+
123+
@Deprecated
124+
default int getServerProtocolVersion() {
125+
return serverProtocolVersion() != null ? serverProtocolVersion().getVersion() : -1;
126+
}
114127

115128
/**
116129
* Returns the username associated with this connection.

api/src/main/java/com/viaversion/viaversion/api/data/FullMappings.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/**
2828
* Mappings containing the full string identifier mappings.
2929
*/
30-
public interface FullMappings extends Mappings {
30+
public interface FullMappings extends BiMappings {
3131

3232
/**
3333
* Returns the unmapped integer id for the given identifier, or -1 if not found.
@@ -49,17 +49,17 @@ public interface FullMappings extends Mappings {
4949
* Returns the unmapped string identifier for the given mapped id.
5050
*
5151
* @param id unmapped id
52-
* @return unmapped string identifier
52+
* @return unmapped string identifier, or null if out of bounds
5353
*/
54-
String identifier(int id);
54+
@Nullable String identifier(int id);
5555

5656
/**
5757
* Returns the mapped string identifier for the given mapped id.
5858
*
5959
* @param mappedId mapped id
60-
* @return mapped string identifier
60+
* @return mapped string identifier, or null if out of bounds
6161
*/
62-
String mappedIdentifier(int mappedId);
62+
@Nullable String mappedIdentifier(int mappedId);
6363

6464
/**
6565
* Returns the mapped string identifier for the given unmapped identifier.

0 commit comments

Comments
 (0)