Skip to content

Commit 1d09b0d

Browse files
committed
ViaVersion 4.0 support
1 parent 4fa4574 commit 1d09b0d

File tree

12 files changed

+112
-91
lines changed

12 files changed

+112
-91
lines changed

.github/workflows/build.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
java-version: [1.8, 11]
15+
java-version: [8, 11]
1616

1717
steps:
1818
- name: Checkout repository
1919
uses: actions/checkout@v2
2020

2121
- name: Setup JDK ${{ matrix.java-version }}
22-
uses: actions/setup-java@v1
22+
uses: actions/setup-java@v2
2323
with:
24+
distribution: 'adopt'
2425
java-version: ${{ matrix.java-version }}
2526

2627
- name: Build

README.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Java CI](https://github.com/MrMicky-FR/ViaChatFixer/actions/workflows/build.yml/badge.svg)](https://github.com/MrMicky-FR/ViaChatFixer/actions/workflows/build.yml)
44

5-
ViaChatFixer is a Spigot plugin that allow 1.11+ players to have longer chat messages on 1.8-1.10 servers with ViaVersion
5+
ViaChatFixer is a Bukkit and Sponge plugin that allows 1.11+ players to have longer chat messages on 1.8-1.10 servers with ViaVersion
66

77
In Minecraft 1.11, the maximum messages length has gone from 100 characters to 256 characters. So if your server is under 1.11, 1.11 and higher
88
players will have their chat messages cut at 100 characters.
@@ -17,7 +17,7 @@ You can download releases and find more information on [SpigotMC](https://www.sp
1717

1818
Just put the ViaChatFixer jar in your plugins folder.
1919

20-
ViaChatFixer currently supports ViaVersion v3.0 or higher.
20+
ViaChatFixer currently supports ViaVersion v4.0 or higher.
2121

2222
All players online during a reload will not be able to have longer chat messages until they reconnect.
2323

@@ -26,3 +26,10 @@ All players online during a reload will not be able to have longer chat messages
2626
ViaChatFixer can be installed on Bukkit/Spigot/Paper servers or on Sponge servers.
2727

2828
If you are using a proxy, ViaVersion and ViaChatFixer must be installed on the backend servers.
29+
30+
### Versions compatibility
31+
32+
| ViaChatFixer | ViaVersion |
33+
| ------------ | ---------- |
34+
| v1.0.0 | v3.x |
35+
| v1.1.x | v4.x |

bukkit/pom.xml

+8-8
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,13 @@
77
<parent>
88
<groupId>fr.mrmicky</groupId>
99
<artifactId>viachatfixer</artifactId>
10-
<version>1.0.0</version>
10+
<version>1.1.0</version>
1111
</parent>
1212

1313
<artifactId>viachatfixer-bukkit</artifactId>
1414

1515
<name>ViaChatFixerBukkit</name>
1616

17-
<repositories>
18-
<repository>
19-
<id>spigotmc-repo</id>
20-
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
21-
</repository>
22-
</repositories>
23-
2417
<dependencies>
2518
<dependency>
2619
<groupId>fr.mrmicky</groupId>
@@ -36,4 +29,11 @@
3629
</dependency>
3730
</dependencies>
3831

32+
<repositories>
33+
<repository>
34+
<id>spigotmc-repo</id>
35+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
36+
</repository>
37+
</repositories>
38+
3939
</project>

bukkit/src/main/java/fr/mrmicky/viachatfixer/bukkit/ViaChatFixerBukkit.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313

1414
public final class ViaChatFixerBukkit extends JavaPlugin implements Listener, ViaChatFixerPlatform {
1515

16-
private final ChatHandler chatHandler = new ChatHandler(this);
17-
1816
private LoggerAdapter logger;
17+
private ChatHandler chatHandler;
1918

2019
@Override
2120
public void onLoad() {
@@ -24,12 +23,17 @@ public void onLoad() {
2423

2524
@Override
2625
public void onEnable() {
27-
if (getServer().getPluginManager().getPlugin("ViaVersion") == null) {
28-
this.logger.error("You need to install ViaVersion to use ViaChatFixer");
26+
try {
27+
Class.forName("com.viaversion.viaversion.api.ViaManager");
28+
} catch (ClassNotFoundException e) {
29+
this.logger.error("You need to install ViaVersion v4.0.0 or higher to use this version of ViaChatFixer.");
30+
this.logger.error("If you can't update ViaVersion, you can use an older ViaChatFixer versions.");
2931
getServer().getPluginManager().disablePlugin(this);
3032
return;
3133
}
3234

35+
this.chatHandler = new ChatHandler(this);
36+
3337
// Only load when ViaVersion is loaded
3438
getServer().getScheduler().runTask(this, () -> {
3539
try {

common/pom.xml

+10-10
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@
77
<parent>
88
<groupId>fr.mrmicky</groupId>
99
<artifactId>viachatfixer</artifactId>
10-
<version>1.0.0</version>
10+
<version>1.1.0</version>
1111
</parent>
1212

1313
<artifactId>viachatfixer-common</artifactId>
1414

1515
<name>ViaChatFixerCommon</name>
1616

17+
<dependencies>
18+
<dependency>
19+
<groupId>com.viaversion</groupId>
20+
<artifactId>viaversion-common</artifactId>
21+
<version>4.0.0</version>
22+
<scope>provided</scope>
23+
</dependency>
24+
</dependencies>
25+
1726
<repositories>
1827
<repository>
1928
<id>viaversion-repo</id>
2029
<url>https://repo.viaversion.com/</url>
2130
</repository>
2231
</repositories>
2332

24-
<dependencies>
25-
<dependency>
26-
<groupId>us.myles</groupId>
27-
<artifactId>viaversion</artifactId>
28-
<version>3.0.0</version>
29-
<scope>provided</scope>
30-
</dependency>
31-
</dependencies>
32-
3333
</project>

common/src/main/java/fr/mrmicky/viachatfixer/common/ChatHandler.java

+12-15
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
package fr.mrmicky.viachatfixer.common;
22

3-
import us.myles.ViaVersion.api.Via;
4-
import us.myles.ViaVersion.api.data.UserConnection;
5-
import us.myles.ViaVersion.api.protocol.Protocol;
6-
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
7-
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
8-
import us.myles.ViaVersion.api.remapper.PacketRemapper;
9-
import us.myles.ViaVersion.api.type.Type;
10-
import us.myles.ViaVersion.packets.State;
11-
import us.myles.ViaVersion.protocols.protocol1_11to1_10.Protocol1_11To1_10;
12-
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
3+
import com.viaversion.viaversion.api.Via;
4+
import com.viaversion.viaversion.api.connection.UserConnection;
5+
import com.viaversion.viaversion.api.protocol.Protocol;
6+
import com.viaversion.viaversion.api.protocol.packet.State;
7+
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
8+
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
9+
import com.viaversion.viaversion.api.type.Type;
10+
import com.viaversion.viaversion.protocols.protocol1_11to1_10.Protocol1_11To1_10;
1311

1412
import java.util.HashSet;
1513
import java.util.Set;
@@ -28,19 +26,18 @@ public ChatHandler(ViaChatFixerPlatform platform) {
2826
}
2927

3028
public void init() {
31-
if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.v1_11.getId()) {
29+
if (Via.getAPI().getServerVersion().lowestSupportedVersion() >= ProtocolVersion.v1_11.getVersion()) {
3230
this.platform.getLoggerAdapter().warn("This plugin is not required on 1.11+ servers, you can just remove it.");
3331
return;
3432
}
3533

36-
//noinspection unchecked
37-
Protocol<?, ?, ?, ServerboundPackets1_9_3> protocol = ProtocolRegistry.getProtocol(Protocol1_11To1_10.class);
34+
Protocol<?, ?, ?, ?> protocol = Via.getManager().getProtocolManager().getProtocol(Protocol1_11To1_10.class);
3835

3936
if (protocol == null) {
4037
throw new IllegalStateException("Protocol 1_11To1_10 not found");
4138
}
4239

43-
protocol.registerIncoming(State.PLAY, 0x02, 0x02, new PacketRemapper() {
40+
protocol.registerServerbound(State.PLAY, 0x02, 0x02, new PacketRemapper() {
4441
@Override
4542
public void registerMap() {
4643
map(Type.STRING); // 0 - Message
@@ -94,7 +91,7 @@ public String handle(UUID uuid) {
9491
}
9592

9693
private ChatTracker getChatTracker(UUID uuid) {
97-
UserConnection connection = Via.getManager().getConnection(uuid);
94+
UserConnection connection = Via.getManager().getConnectionManager().getConnectedClient(uuid);
9895

9996
if (connection == null) {
10097
if (this.unknownPlayers.add(uuid)) {

common/src/main/java/fr/mrmicky/viachatfixer/common/ChatTracker.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package fr.mrmicky.viachatfixer.common;
22

3-
import us.myles.ViaVersion.api.data.StoredObject;
4-
import us.myles.ViaVersion.api.data.UserConnection;
3+
import com.viaversion.viaversion.api.connection.StoredObject;
4+
import com.viaversion.viaversion.api.connection.UserConnection;
55

66
public class ChatTracker extends StoredObject {
77

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>fr.mrmicky</groupId>
88
<artifactId>viachatfixer</artifactId>
9-
<version>1.0.0</version>
9+
<version>1.1.0</version>
1010
<packaging>pom</packaging>
1111

1212
<name>ViaChatFixer</name>
@@ -27,7 +27,7 @@
2727
<plugin>
2828
<groupId>org.apache.maven.plugins</groupId>
2929
<artifactId>maven-compiler-plugin</artifactId>
30-
<version>3.7.0</version>
30+
<version>3.8.1</version>
3131
<configuration>
3232
<source>1.8</source>
3333
<target>1.8</target>

sponge/pom.xml

+23-23
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,35 @@
77
<parent>
88
<groupId>fr.mrmicky</groupId>
99
<artifactId>viachatfixer</artifactId>
10-
<version>1.0.0</version>
10+
<version>1.1.0</version>
1111
</parent>
1212

1313
<artifactId>viachatfixer-sponge</artifactId>
1414

1515
<name>ViaChatFixerSponge</name>
1616

17+
<dependencies>
18+
<dependency>
19+
<groupId>fr.mrmicky</groupId>
20+
<artifactId>viachatfixer-common</artifactId>
21+
<version>${project.version}</version>
22+
<scope>compile</scope>
23+
</dependency>
24+
<dependency>
25+
<groupId>org.spongepowered</groupId>
26+
<artifactId>spongeapi</artifactId>
27+
<version>5.1.0</version>
28+
<scope>provided</scope>
29+
</dependency>
30+
</dependencies>
31+
32+
<repositories>
33+
<repository>
34+
<id>sponge-repo</id>
35+
<url>https://repo.spongepowered.org/maven/</url>
36+
</repository>
37+
</repositories>
38+
1739
<build>
1840
<plugins>
1941
<plugin>
@@ -32,26 +54,4 @@
3254
</plugins>
3355
</build>
3456

35-
<repositories>
36-
<repository>
37-
<id>sponge-repo</id>
38-
<url>https://repo.spongepowered.org/maven/</url>
39-
</repository>
40-
</repositories>
41-
42-
<dependencies>
43-
<dependency>
44-
<groupId>fr.mrmicky</groupId>
45-
<artifactId>viachatfixer-common</artifactId>
46-
<version>${project.version}</version>
47-
<scope>compile</scope>
48-
</dependency>
49-
<dependency>
50-
<groupId>org.spongepowered</groupId>
51-
<artifactId>spongeapi</artifactId>
52-
<version>5.1.0</version>
53-
<scope>provided</scope>
54-
</dependency>
55-
</dependencies>
56-
5757
</project>

sponge/src/main/java-templates/fr/mrmicky/viachatfixer/sponge/ViaChatFixerVersion.java

+3
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ public final class ViaChatFixerVersion {
44

55
public static final String VERSION = "${project.version}";
66

7+
private ViaChatFixerVersion() {
8+
throw new UnsupportedOperationException();
9+
}
710
}

sponge/src/main/java/fr/mrmicky/viachatfixer/sponge/ViaChatFixerSponge.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@
2626
)
2727
public final class ViaChatFixerSponge implements ViaChatFixerPlatform {
2828

29-
private final ChatHandler chatHandler = new ChatHandler(this);
30-
3129
private final SpongeLogger logger;
3230

31+
private ChatHandler chatHandler;
3332
private Field chatRawMessageField;
3433
private boolean chatRawMessageFieldInitialized;
3534

@@ -40,6 +39,16 @@ public ViaChatFixerSponge(SpongeLogger logger) {
4039

4140
@Listener
4241
public void onServerStart(GameStartedServerEvent event) {
42+
try {
43+
Class.forName("com.viaversion.viaversion.api.ViaManager");
44+
} catch (ClassNotFoundException e) {
45+
this.logger.error("You need to install ViaVersion v4.0.0 or higher to use this version of ViaChatFixer.");
46+
this.logger.error("If you can't update ViaVersion, you can use an older ViaChatFixer version.");
47+
return;
48+
}
49+
50+
this.chatHandler = new ChatHandler(this);
51+
4352
try {
4453
this.chatHandler.init();
4554
} catch (Exception e) {

universal/pom.xml

+21-21
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,13 @@
77
<parent>
88
<groupId>fr.mrmicky</groupId>
99
<artifactId>viachatfixer</artifactId>
10-
<version>1.0.0</version>
10+
<version>1.1.0</version>
1111
</parent>
1212

1313
<artifactId>viachatfixer-universal</artifactId>
1414

1515
<name>ViaChatFixerUniversal</name>
1616

17-
<build>
18-
<finalName>${project.parent.name}-${project.version}</finalName>
19-
<defaultGoal>clean package</defaultGoal>
20-
<plugins>
21-
<plugin>
22-
<groupId>org.apache.maven.plugins</groupId>
23-
<artifactId>maven-shade-plugin</artifactId>
24-
<version>3.1.0</version>
25-
<executions>
26-
<execution>
27-
<phase>package</phase>
28-
<goals>
29-
<goal>shade</goal>
30-
</goals>
31-
</execution>
32-
</executions>
33-
</plugin>
34-
</plugins>
35-
</build>
36-
3717
<dependencies>
3818
<dependency>
3919
<groupId>fr.mrmicky</groupId>
@@ -55,4 +35,24 @@
5535
</dependency>
5636
</dependencies>
5737

38+
<build>
39+
<finalName>${project.parent.name}-${project.version}</finalName>
40+
<defaultGoal>clean package</defaultGoal>
41+
<plugins>
42+
<plugin>
43+
<groupId>org.apache.maven.plugins</groupId>
44+
<artifactId>maven-shade-plugin</artifactId>
45+
<version>3.2.4</version>
46+
<executions>
47+
<execution>
48+
<phase>package</phase>
49+
<goals>
50+
<goal>shade</goal>
51+
</goals>
52+
</execution>
53+
</executions>
54+
</plugin>
55+
</plugins>
56+
</build>
57+
5858
</project>

0 commit comments

Comments
 (0)