mirror of
https://github.com/ViaVersion/ViaLoader.git
synced 2024-09-30 04:37:54 +02:00
Compare commits
171 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
b8391d95db | ||
|
0a16f4860a | ||
|
01bcca033e | ||
|
65fd9eedb0 | ||
|
177766a4f8 | ||
|
333310a95b | ||
|
0b20982f01 | ||
|
0826d40d2b | ||
|
33a63f55fb | ||
|
02d1aba173 | ||
|
e0b65fa306 | ||
|
e7e5837f16 | ||
|
449bc09dff | ||
|
90e43b9da1 | ||
|
bc19b524b0 | ||
|
8f00ca5790 | ||
|
0f4b188643 | ||
|
acb70286ea | ||
|
eca9c3cf72 | ||
|
cc28ced45a | ||
|
8fd51bbb21 | ||
|
48e384f236 | ||
|
60a387e932 | ||
|
7c14ba2d43 | ||
|
a13a5deb71 | ||
|
4961bcf382 | ||
|
7caa8bef89 | ||
|
b486165fc2 | ||
|
3accd385ea | ||
|
054ec1004d | ||
|
0f877cffc6 | ||
|
f41ccdd676 | ||
|
533021d185 | ||
|
97936ab215 | ||
|
45f0bac9fb | ||
|
756330f333 | ||
|
921b361361 | ||
|
ca7e9c879e | ||
|
5bb37829d0 | ||
|
22737ef569 | ||
|
1125600dbe | ||
|
eb09342e0e | ||
|
02044a0511 | ||
|
4279e089b7 | ||
|
d71ea30670 | ||
|
986431417b | ||
|
cf72f8db79 | ||
|
5c854370eb | ||
|
d99bc1ae6a | ||
|
daddc6d675 | ||
|
bd381cf483 | ||
|
273abf8190 | ||
|
1cfd131406 | ||
|
1608cedd92 | ||
|
1081f19bba | ||
|
f31433ee73 | ||
|
a1f2e24c04 | ||
|
280179a370 | ||
|
d2b45fd415 | ||
|
64d0ad1a14 | ||
|
d6a1f08290 | ||
|
b30cef9227 | ||
|
e58f763d26 | ||
|
8fc2b95736 | ||
|
3fa9af0b04 | ||
|
053a50c120 | ||
|
bea9562ec9 | ||
|
72dcde02cb | ||
|
98ac0333f3 | ||
|
94c10dbb1a | ||
|
e65e30a976 | ||
|
6b87889907 | ||
|
f61031a33a | ||
|
a4b35aca78 | ||
|
728f571fbc | ||
|
e60ec0c24d | ||
|
a73f6c99d1 | ||
|
2af017b4ec | ||
|
f976ac3b85 | ||
|
2c4770ab69 | ||
|
b565635aa6 | ||
|
5754b07583 | ||
|
289f5656b8 | ||
|
d8aff7f979 | ||
|
164f229aa0 | ||
|
e5138149b8 | ||
|
65b9a0bd64 | ||
|
2b44f2bf6f | ||
|
b0ee047bd0 | ||
|
b3c439e0fe | ||
|
57bb44dfa5 | ||
|
2a813208a7 | ||
|
70adf63f2c | ||
|
18d8ef9117 | ||
|
57fcbe7725 | ||
|
26e981a94d | ||
|
bec10b1569 | ||
|
428a2aad8f | ||
|
d9116788c9 | ||
|
3c2b445934 | ||
|
cb32d8b264 | ||
|
6e806dd31e | ||
|
492f973e59 | ||
|
a83a50d2b7 | ||
|
ff5da9ed21 | ||
|
fa96c19326 | ||
|
c11aabae47 | ||
|
cbfa134a6e | ||
|
b42553d6fe | ||
|
08a8106330 | ||
|
001b540eb4 | ||
|
c0e411bc14 | ||
|
337c355866 | ||
|
03fd2473e9 | ||
|
1a1e1deeda | ||
|
b25f99f1f4 | ||
|
d3b829f25c | ||
|
9e90d1f098 | ||
|
50c7f623a6 | ||
|
e0dfc6556e | ||
|
0e09507ede | ||
|
f4bcebe13e | ||
|
d9aaeb1bc6 | ||
|
07224d93a2 | ||
|
6fd4382d44 | ||
|
727a7359be | ||
|
041b7a86f7 | ||
|
05c5cc1725 | ||
|
0ac5893da4 | ||
|
67b6ca444c | ||
|
e46d9be16a | ||
|
bd1801e3aa | ||
|
24f97129e0 | ||
|
9f670cf50d | ||
|
26fb7deeb0 | ||
|
949d5e9275 | ||
|
8af1db5e89 | ||
|
f41de68c55 | ||
|
c6d543be31 | ||
|
91cee66bb3 | ||
|
1728fc2037 | ||
|
d985f1548c | ||
|
af77d74421 | ||
|
a26929a511 | ||
|
87d80dea5c | ||
|
4aa03b5441 | ||
|
d66f12b4c7 | ||
|
389e54505b | ||
|
e30cd6f23b | ||
|
9e1ead2829 | ||
|
9bcf32381e | ||
|
2b000be0f6 | ||
|
8da024be6b | ||
|
ec9786cdf8 | ||
|
4ffa6e3c60 | ||
|
b7ae73a28d | ||
|
03a93c8ba3 | ||
|
c571fbb335 | ||
|
ee37b3a7e5 | ||
|
08b13e5faa | ||
|
f1b7e9edfd | ||
|
57178ef77b | ||
|
7fb8546fbb | ||
|
a63f0d17b5 | ||
|
8b628cad9f | ||
|
008ab37003 | ||
|
8b4c11975e | ||
|
ff65f86a95 | ||
|
a30937c339 | ||
|
dafa55e202 | ||
|
dd8860f31e |
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
ko_fi: rk_01
|
4
.github/dependabot.yml
vendored
4
.github/dependabot.yml
vendored
@ -4,3 +4,7 @@ updates:
|
|||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
25
.github/workflows/build.yml
vendored
Normal file
25
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
name: build
|
||||||
|
on: [push, pull_request, workflow_dispatch]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Validate Gradle Wrapper
|
||||||
|
uses: gradle/actions/wrapper-validation@v4
|
||||||
|
- name: Set up JDK 21
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: 21
|
||||||
|
check-latest: true
|
||||||
|
- name: Build with Gradle
|
||||||
|
run: ./gradlew build
|
||||||
|
- name: Upload Artifacts to GitHub
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: Artifacts
|
||||||
|
path: build/libs/
|
20
.github/workflows/update-gradle-wrapper.yml
vendored
Normal file
20
.github/workflows/update-gradle-wrapper.yml
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
name: update-gradle-wrapper
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 0 * * 0"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-gradle-wrapper:
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up JDK 21
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: 21
|
||||||
|
check-latest: true
|
||||||
|
- name: Update Gradle Wrapper
|
||||||
|
uses: gradle-update/update-gradle-wrapper-action@v2
|
@ -1,6 +1,6 @@
|
|||||||
<component name="CopyrightManager">
|
<component name="CopyrightManager">
|
||||||
<copyright>
|
<copyright>
|
||||||
<option name="notice" value="This file is part of ViaProtocolHack - https://github.com/RaphiMC/ViaProtocolHack Copyright (C) &#36;today.year RK_01/RaphiMC and contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>." />
|
<option name="notice" value="This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader Copyright (C) 2020-&#36;today.year RK_01/RaphiMC and contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>." />
|
||||||
<option name="myName" value="GPL-3.0" />
|
<option name="myName" value="GPL-3.0" />
|
||||||
</copyright>
|
</copyright>
|
||||||
</component>
|
</component>
|
110
README.md
110
README.md
@ -1,11 +1,11 @@
|
|||||||
# ViaLoader
|
# ViaLoader
|
||||||
Easy to use ViaVersion, (and optional ViaBackwards, ViaRewind, ViaLegacy and ViaAprilFools) platform implementation.
|
Easy to use ViaVersion, (and optional ViaBackwards, ViaRewind, ViaLegacy, ViaAprilFools and ViaBedrock) platform implementation.
|
||||||
|
|
||||||
ViaLoader is not usable by itself as a standalone software, as it is an implementation of a ViaVersion platform.
|
ViaLoader is not usable by itself as a standalone software, as it is an implementation of a ViaVersion platform.
|
||||||
|
|
||||||
### Projects implementing ViaLoader
|
### Projects implementing ViaLoader
|
||||||
- [ViaProxy](https://github.com/ViaVersion/ViaProxy): Standalone proxy which allows players to join EVERY Minecraft server version (Classic, Alpha, Beta, Release, Bedrock).
|
- [ViaProxy](https://github.com/ViaVersion/ViaProxy): Standalone proxy which allows players to join EVERY Minecraft server version (Classic, Alpha, Beta, Release, Bedrock).
|
||||||
- [ViaForge](https://github.com/ViaVersion/ViaForge): Clientside ViaVersion, ViaBackwards and ViaRewind implementation for Forge.
|
- [ViaForge](https://github.com/ViaVersion/ViaForge): Client-side Implementation of ViaVersion, ViaBackwards and ViaRewind for Legacy Minecraft Forge.
|
||||||
- [ViaFabricPlus](https://github.com/ViaVersion/ViaFabricPlus): Fabric mod to connect to EVERY Minecraft server version (Release, Beta, Alpha, Classic, Snapshots, Bedrock) with QoL fixes to the gameplay.
|
- [ViaFabricPlus](https://github.com/ViaVersion/ViaFabricPlus): Fabric mod to connect to EVERY Minecraft server version (Release, Beta, Alpha, Classic, Snapshots, Bedrock) with QoL fixes to the gameplay.
|
||||||
|
|
||||||
## Releases
|
## Releases
|
||||||
@ -17,7 +17,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("net.raphimc:ViaLoader:2.2.5-SNAPSHOT") // Get latest version from releases
|
implementation("net.raphimc:ViaLoader:x.x.x") // Get latest version from releases
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -33,42 +33,41 @@ dependencies {
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.raphimc</groupId>
|
<groupId>net.raphimc</groupId>
|
||||||
<artifactId>ViaLoader</artifactId>
|
<artifactId>ViaLoader</artifactId>
|
||||||
<version>2.2.5</version> <!-- Get latest version from releases -->
|
<version>x.x.x</version> <!-- Get latest version from releases -->
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Jar File
|
### Jar File
|
||||||
If you just want the latest jar file you can download it from this [Jenkins](https://ci.viaversion.com/view/All/job/ViaLoader/).
|
If you just want the latest jar file you can download it from [GitHub Actions](https://github.com/RaphiMC/ViaLoader/actions/workflows/build.yml) or the [ViaVersion Jenkins](https://ci.viaversion.com/view/All/job/ViaLoader/).
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
To use ViaLoader in your project you need to decide what components of Via* you want to use.
|
To use ViaLoader in your project you need to decide what components of Via* you want to use.
|
||||||
ViaLoader is split into 5 different components:
|
ViaLoader is split into 6 different components:
|
||||||
- ViaVersion (Is the base component of ViaLoader [required])
|
- ViaVersion (Is the base component of ViaLoader [required])
|
||||||
- ViaBackwards (Allows older clients to join to newer server versions [needs ViaVersion])
|
- ViaBackwards (Allows older clients to join to newer server versions [needs ViaVersion])
|
||||||
- ViaRewind (Allows 1.8.x and 1.7.x clients to join to 1.9+ servers [needs ViaBackwards])
|
- ViaRewind (Allows 1.8.x and 1.7.x clients to join to 1.9+ servers [needs ViaBackwards])
|
||||||
- ViaLegacy (Allows clients to join to <= 1.7.10 servers [needs ViaVersion])
|
- ViaLegacy (Allows clients to join to <= 1.7.10 servers [needs ViaVersion])
|
||||||
- ViaAprilFools (Allows clients to join to some notable Minecraft snapshots [needs ViaBackwards])
|
- ViaAprilFools (Allows clients to join to some notable Minecraft snapshots [needs ViaBackwards])
|
||||||
|
- ViaBedrock (Allows clients to join to Bedrock edition servers [needs ViaVersion])
|
||||||
|
|
||||||
To include the subcomponents you have to add the ViaVersion maven repository to your build script:
|
In case you want to include ViaBedrock, you have to add the Lenni0451 maven repository to your build script:
|
||||||
```groovy
|
```groovy
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
name = "ViaVersion"
|
name = "Lenni0451"
|
||||||
url "https://repo.viaversion.com"
|
url = "https://maven.lenni0451.net/everything"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
Here is an example dependency configuration for all components:
|
Here is an example dependency configuration for all components:
|
||||||
```groovy
|
```groovy
|
||||||
implementation "com.viaversion:viaversion:4.7.0"
|
implementation "com.viaversion:viaversion:5.0.3"
|
||||||
implementation("com.viaversion:viabackwards-common:4.7.0") {
|
implementation "com.viaversion:viabackwards-common:5.0.3"
|
||||||
exclude group: "com.viaversion", module: "viaversion" // Exclude transitive dependency. Include manually for more control
|
implementation "com.viaversion:viarewind-common:4.0.2"
|
||||||
exclude group: "io.netty", module: "netty-all" // Don't include the outdated netty version
|
implementation "net.raphimc:ViaLegacy:3.0.2"
|
||||||
}
|
implementation "net.raphimc:ViaAprilFools:3.0.1"
|
||||||
implementation "com.viaversion:viarewind-core:2.0.4-SNAPSHOT"
|
implementation "net.raphimc:ViaBedrock:0.0.10-SNAPSHOT"
|
||||||
implementation "net.raphimc:ViaLegacy:2.2.17"
|
|
||||||
implementation "net.raphimc:ViaAprilFools:2.0.7"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Implementation
|
## Implementation
|
||||||
@ -77,51 +76,112 @@ ViaLoader provides a wrapper class with default values for that. To use a defaul
|
|||||||
If you want to change the default value you should create your own class which extends the base class and overrides the methods you want to change.
|
If you want to change the default value you should create your own class which extends the base class and overrides the methods you want to change.
|
||||||
|
|
||||||
The only default value you have to change is the ``VLLoader`` argument. The loader is used to register all the providers for the Via* platforms.
|
The only default value you have to change is the ``VLLoader`` argument. The loader is used to register all the providers for the Via* platforms.
|
||||||
To override the default you first create a new class which extends ``VLLoader`` and overrides the ``load`` method (Make sure to call the super method).
|
Providers are used to provide information about the platform to ViaVersion when it's (almost) impossible to get them ourselves.
|
||||||
|
|
||||||
|
To override the default you first create a new class which extends ``VLLoader`` and overrides the ``load`` method.
|
||||||
Within the ``load`` method you have to register a ``VersionProvider`` implementation which will be used to determine the target server version of a given connection.
|
Within the ``load`` method you have to register a ``VersionProvider`` implementation which will be used to determine the target server version of a given connection.
|
||||||
Here is an example implementation:
|
Here is an example implementation:
|
||||||
```java
|
```java
|
||||||
|
public class CustomVLLoaderImpl extends VLLoader {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load() {
|
||||||
|
super.load();
|
||||||
|
|
||||||
Via.getManager().getProviders().use(VersionProvider.class, new BaseVersionProvider() {
|
Via.getManager().getProviders().use(VersionProvider.class, new BaseVersionProvider() {
|
||||||
@Override
|
@Override
|
||||||
public int getClosestServerProtocol(UserConnection connection) {
|
public ProtocolVersion getClosestServerProtocol(UserConnection connection) {
|
||||||
return ProtocolVersion.v1_8.getVersion(); // Change the logic here to select the target server version
|
// Change the logic here to select the target server version
|
||||||
|
return ProtocolVersion.v1_8;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
Then you have to create a new instance of your loader class and pass it to the ``ViaLoader.init`` call.
|
Then you have to create a new instance of your loader class and pass it to the ``ViaLoader.init`` call.
|
||||||
|
|
||||||
To do this you can call the ``ViaLoader.init()`` method somewhere suitable in your project (You can do that async) with your desired argument values:
|
To do this you can call the ``ViaLoader.init()`` method somewhere suitable in your project (You can do that async) with your desired argument values:
|
||||||
```java
|
```java
|
||||||
ViaLoader.init(null/*ViaPlatform*/, new CustomVLLoaderImpl(), null/*ViaInjector*/, null/*ViaCommandHandler*/, ViaBackwardsPlatformImpl::new, ViaLegacyPlatformImpl::new, ViaAprilFoolsPlatformImpl::new);
|
ViaLoader.init(null/*ViaPlatform*/, new CustomVLLoaderImpl(), null/*ViaInjector*/, null/*ViaCommandHandler*/, ViaBackwardsPlatformImpl::new, ViaRewindPlatforImpl::new, ViaLegacyPlatformImpl::new, ViaAprilFoolsPlatformImpl::new, ViaBedrockPlatformImpl::new);
|
||||||
```
|
```
|
||||||
|
Make sure to have all platform impls you need added to the init call. Every platform added there needs to be in your dependencies.
|
||||||
|
|
||||||
After you have initialized the Via* platforms you can start implementing ViaLoader into your project.
|
After you have initialized the Via* platforms you can start implementing ViaLoader into your project.
|
||||||
|
|
||||||
|
### Netty modifications
|
||||||
|
|
||||||
The most important part is the modification of your netty pipeline. This is needed for ViaVersion to translate the packets in both ways.
|
The most important part is the modification of your netty pipeline. This is needed for ViaVersion to translate the packets in both ways.
|
||||||
|
|
||||||
|
Our recommended way is to use the `VLPipeline` (for codec based pipelines) or the `VLLegacyPipeline` (for decoder/encoder pipelines) as it
|
||||||
|
automatically handles the modifications required for all Via* platforms.
|
||||||
|
|
||||||
Here is an example implementation:
|
Here is an example implementation:
|
||||||
```java
|
```java
|
||||||
final UserConnection user = new UserConnectionImpl(channel, true);
|
public class CustomVLPipeline extends VLPipeline {
|
||||||
|
|
||||||
|
public CustomVLPipeline(UserConnection user) {
|
||||||
|
super(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace these with the names of your pipeline components
|
||||||
|
@Override
|
||||||
|
protected String compressionCodecName() {
|
||||||
|
return "compression_codec";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String packetCodecName() {
|
||||||
|
return "packet_codec";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String lengthCodecName() {
|
||||||
|
return "length_codec";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
The same can be done for the `VLLegacyPipeline` with similar functions for the decoder/encoder pairs.
|
||||||
|
|
||||||
|
Then you can add the Via* pipeline to your netty pipeline:
|
||||||
|
```java
|
||||||
|
final UserConnection user = new UserConnectionImpl(channel, true/*clientside or serverside*/);
|
||||||
new ProtocolPipelineImpl(user);
|
new ProtocolPipelineImpl(user);
|
||||||
|
|
||||||
|
channel.pipeline().addLast(new CustomVLPipeline(user));
|
||||||
|
```
|
||||||
|
|
||||||
|
Both `VLPipeline` and `VLLegacyPipeline` contain various functions allowing you to modify/wrap the existing pipeline elements,
|
||||||
|
if you need a more complex/dynamic pipeline setup you can also manually add the Via* handlers to the pipeline.
|
||||||
|
Here is an example implementation:
|
||||||
|
```java
|
||||||
|
final UserConnection user = new UserConnectionImpl(channel, true/*clientside or serverside*/);
|
||||||
|
new ProtocolPipelineImpl(user);
|
||||||
|
|
||||||
|
//channel.pipeline().addBefore("packet_decoder", VLLegacyPipeline.VIA_DECODER_NAME, new ViaDecoder(user));
|
||||||
|
//channel.pipeline().addBefore("packet_encoder", VLLegacyPipeline.VIA_ENCODER_NAME, new ViaEncoder(user));
|
||||||
channel.pipeline().addBefore("packet_codec", VLPipeline.VIA_CODEC_NAME, new ViaCodec(user));
|
channel.pipeline().addBefore("packet_codec", VLPipeline.VIA_CODEC_NAME, new ViaCodec(user));
|
||||||
```
|
```
|
||||||
If you are using ViaLegacy, you should read its README to see what changes you need to make to the netty pipeline for it to work.
|
If you are using ViaLegacy, you should read its [README](https://github.com/ViaVersion/ViaLegacy?tab=readme-ov-file#vialegacy) to see what changes you need to make to the netty pipeline for it to work.
|
||||||
|
|
||||||
Depending on where you are implementing ViaLoader you might need to ensure that the pipeline is held in the correct order.
|
Depending on where you are implementing ViaLoader you might need to ensure that the pipeline is held in the correct order.
|
||||||
Minecraft clients modify the pipeline order when adding the compression handlers. You have to ensure that the Via* handlers are always on their correct location.
|
Minecraft clients modify the pipeline order when adding the compression handlers. You have to ensure that the Via* handlers are always on their correct location.
|
||||||
|
|
||||||
|
If you are using the `VLPipeline` or `VLLegacyPipeline` you can fire the `CompressionReorderEvent` once the compression handler is added to the pipeline.
|
||||||
|
|
||||||
Now you should have a working protocol translator implementation in your project.
|
Now you should have a working protocol translator implementation in your project.
|
||||||
|
|
||||||
## Configuring the protocol translation
|
## Configuring the protocol translation
|
||||||
To change the protocol translation settings/features you can look into the ViaLoader folder.
|
To change the protocol translation settings/features you can look into the ViaLoader folder.
|
||||||
You can find 5 config files there depending on the platforms loaded:
|
You can find 5 config files there depending on the platforms loaded:
|
||||||
- viaversion.yml (ViaVersion)
|
- viaversion.yml (ViaVersion)
|
||||||
- config.yml (ViaBackwards)
|
- viabackwards.yml (ViaBackwards)
|
||||||
- viarewind.yml (ViaRewind)
|
- viarewind.yml (ViaRewind)
|
||||||
- vialegacy.yml (ViaLegacy)
|
- vialegacy.yml (ViaLegacy)
|
||||||
- viabedrock.yml (ViaBedrock)
|
- viabedrock.yml (ViaBedrock)
|
||||||
|
|
||||||
## Contact
|
## Contact
|
||||||
If you encounter any issues, please report them on the
|
If you encounter any issues, please report them on the
|
||||||
[issue tracker](https://github.com/RaphiMC/ViaLoader/issues).
|
[issue tracker](https://github.com/ViaVersion/ViaLoader/issues).
|
||||||
If you just want to talk or need help implementing ViaLoader feel free to join the ViaVersion
|
If you just want to talk or need help implementing ViaLoader feel free to join the ViaVersion
|
||||||
[Discord](https://discord.gg/viaversion).
|
[Discord](https://discord.gg/viaversion).
|
||||||
|
91
build.gradle
91
build.gradle
@ -1,25 +1,27 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "java-library"
|
id "java-library"
|
||||||
id "maven-publish"
|
id "maven-publish"
|
||||||
id "net.kyori.blossom" version "1.3.1"
|
id "net.raphimc.class-token-replacer" version "1.1.3"
|
||||||
}
|
}
|
||||||
|
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
|
base {
|
||||||
|
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||||
compileJava.options.encoding = compileTestJava.options.encoding = javadoc.options.encoding = "UTF-8"
|
compileJava.options.encoding = compileTestJava.options.encoding = javadoc.options.encoding = "UTF-8"
|
||||||
|
|
||||||
group = project.maven_group
|
group = project.maven_group ?: rootProject.maven_group
|
||||||
archivesBaseName = project.maven_name
|
archivesName = project.maven_name ?: rootProject.maven_name
|
||||||
version = project.maven_version
|
version = project.maven_version ?: rootProject.maven_version
|
||||||
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven {
|
maven {
|
||||||
name = "Lenni0451"
|
name = "ViaVersion"
|
||||||
url "https://maven.lenni0451.net/releases"
|
url = "https://repo.viaversion.com"
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
name = "Lenni0451 Snapshots"
|
name = "Lenni0451"
|
||||||
url "https://maven.lenni0451.net/snapshots"
|
url = "https://maven.lenni0451.net/everything"
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
name = "OpenCollab Releases"
|
name = "OpenCollab Releases"
|
||||||
@ -30,39 +32,51 @@ repositories {
|
|||||||
url = "https://repo.opencollab.dev/maven-snapshots/"
|
url = "https://repo.opencollab.dev/maven-snapshots/"
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
name = "ViaVersion"
|
name = "Minecraft Libraries"
|
||||||
url "https://repo.viaversion.com"
|
url = "https://libraries.minecraft.net"
|
||||||
|
|
||||||
|
content {
|
||||||
|
includeGroup "com.mojang"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
name = "Jitpack"
|
||||||
|
url = "https://jitpack.io"
|
||||||
|
|
||||||
|
content {
|
||||||
|
includeGroup "com.github.Oryxel"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly "com.viaversion:viaversion:4.7.0"
|
compileOnly "com.viaversion:viaversion-common:5.0.4-SNAPSHOT"
|
||||||
compileOnly("com.viaversion:viabackwards-common:4.7.0") {
|
compileOnly "com.viaversion:viabackwards-common:5.0.4-SNAPSHOT"
|
||||||
exclude group: "com.viaversion", module: "viaversion"
|
compileOnly "com.viaversion:viarewind-common:4.0.3-SNAPSHOT"
|
||||||
exclude group: "io.netty", module: "netty-all"
|
compileOnly "net.raphimc:ViaLegacy:3.0.3-SNAPSHOT"
|
||||||
}
|
compileOnly "net.raphimc:viaaprilfools-common:3.0.2-SNAPSHOT"
|
||||||
compileOnly "com.viaversion:viarewind-core:2.0.4-SNAPSHOT"
|
compileOnly "net.raphimc:ViaBedrock:0.0.12-SNAPSHOT"
|
||||||
compileOnly "net.raphimc:ViaLegacy:2.2.17"
|
compileOnly "org.cloudburstmc.netty:netty-transport-raknet:1.0.0.CR3-SNAPSHOT"
|
||||||
compileOnly "net.raphimc:ViaAprilFools:2.0.7"
|
|
||||||
compileOnly "net.raphimc:ViaBedrock:0.0.2-SNAPSHOT"
|
|
||||||
compileOnly "org.cloudburstmc.netty:netty-transport-raknet:1.0.0.CR1-SNAPSHOT"
|
|
||||||
|
|
||||||
api "org.slf4j:slf4j-api:2.0.7"
|
api "com.google.guava:guava:33.3.1-jre"
|
||||||
api "org.yaml:snakeyaml:2.0"
|
api "org.slf4j:slf4j-api:2.0.16"
|
||||||
}
|
}
|
||||||
|
|
||||||
blossom {
|
sourceSets {
|
||||||
replaceToken("\${version}", project.version, "src/main/java/net/raphimc/vialoader/ViaLoader.java")
|
main {
|
||||||
|
classTokenReplacer {
|
||||||
|
property("\${version}", project.version)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
withJavadocJar()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
from("LICENSE") {
|
from("LICENSE") {
|
||||||
rename { "${it}_${project.archivesBaseName}" }
|
rename { "${it}_${project.name ?: rootProject.name}" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,6 +85,7 @@ publishing {
|
|||||||
maven {
|
maven {
|
||||||
name = "Via"
|
name = "Via"
|
||||||
url = "https://repo.viaversion.com/"
|
url = "https://repo.viaversion.com/"
|
||||||
|
|
||||||
credentials(PasswordCredentials)
|
credentials(PasswordCredentials)
|
||||||
authentication {
|
authentication {
|
||||||
basic(BasicAuthentication)
|
basic(BasicAuthentication)
|
||||||
@ -84,6 +99,28 @@ publishing {
|
|||||||
version = project.maven_version
|
version = project.maven_version
|
||||||
|
|
||||||
from components.java
|
from components.java
|
||||||
|
|
||||||
|
pom {
|
||||||
|
name = "ViaLoader"
|
||||||
|
description = "Implementation of a ViaVersion based protocol translator platform"
|
||||||
|
url = "https://github.com/ViaVersion/ViaLoader"
|
||||||
|
licenses {
|
||||||
|
license {
|
||||||
|
name = "GPL-3.0 License"
|
||||||
|
url = "https://github.com/ViaVersion/ViaLoader/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
developers {
|
||||||
|
developer {
|
||||||
|
id = "RK_01"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scm {
|
||||||
|
connection = "scm:git:git://github.com/ViaVersion/ViaLoader.git"
|
||||||
|
developerConnection = "scm:git:ssh://github.com/ViaVersion/ViaLoader.git"
|
||||||
|
url = "https://github.com/ViaVersion/ViaLoader.git"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
# Gradle properties
|
|
||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
org.gradle.configureondemand=true
|
org.gradle.configureondemand=true
|
||||||
|
|
||||||
# Project properties
|
|
||||||
maven_name=ViaLoader
|
|
||||||
maven_group=net.raphimc
|
maven_group=net.raphimc
|
||||||
maven_version=2.2.5
|
maven_name=ViaLoader
|
||||||
|
maven_version=3.0.3-SNAPSHOT
|
||||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
5
gradle/wrapper/gradle-wrapper.properties
vendored
5
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,8 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
distributionSha256Sum=31c55713e40233a8303827ceb42ca48a47267a0ad4bab9177123121e71524c26
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
38
gradlew
vendored
Normal file → Executable file
38
gradlew
vendored
Normal file → Executable file
@ -15,6 +15,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
@ -55,7 +57,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
@ -80,13 +82,12 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
' "$PWD" ) || exit
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
@ -133,22 +134,29 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
@ -193,11 +201,15 @@ if "$cygwin" || "$msys" ; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
# double quotes to make sure that they get re-expanded; and
|
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
23
gradlew.bat
vendored
23
gradlew.bat
vendored
@ -13,6 +13,8 @@
|
|||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@ -26,6 +28,7 @@ if "%OS%"=="Windows_NT" setlocal
|
|||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%"=="" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@ -42,11 +45,11 @@ set JAVA_EXE=java.exe
|
|||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if %ERRORLEVEL% equ 0 goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
@ -56,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
@ -5,4 +5,8 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id "org.gradle.toolchains.foojay-resolver-convention" version "0.8.0"
|
||||||
|
}
|
||||||
|
|
||||||
rootProject.name = "ViaLoader"
|
rootProject.name = "ViaLoader"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -55,6 +55,8 @@ public class ViaLoader {
|
|||||||
.commandHandler(commandHandler)
|
.commandHandler(commandHandler)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
|
Via.getConfig().reload();
|
||||||
|
|
||||||
if (platformSuppliers != null) {
|
if (platformSuppliers != null) {
|
||||||
Via.getManager().addEnableListener(() -> {
|
Via.getManager().addEnableListener(() -> {
|
||||||
for (Supplier<?> additionalPlatformSupplier : platformSuppliers) {
|
for (Supplier<?> additionalPlatformSupplier : platformSuppliers) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package net.raphimc.vialoader.commands.subs;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
|
||||||
import com.viaversion.viaversion.api.command.ViaSubCommand;
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class ConnectionsSubCommand extends ViaSubCommand {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String name() {
|
|
||||||
return "connections";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String description() {
|
|
||||||
return "Shows a list of all connections";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean execute(ViaCommandSender viaCommandSender, String[] strings) {
|
|
||||||
final Set<UserConnection> users = Via.getManager().getConnectionManager().getConnections();
|
|
||||||
sendMessage(viaCommandSender, "&a--- Connected users ---");
|
|
||||||
for (UserConnection user : users) {
|
|
||||||
sendMessage(viaCommandSender, "&7[&6" + user.getProtocolInfo().getUsername() + "&7] UUID: &5" + user.getProtocolInfo().getUuid() + " &7Client-Protocol: &5" + ProtocolVersion.getProtocol(user.getProtocolInfo().getProtocolVersion()).getName() + " &7Server-Protocol: &5" + ProtocolVersion.getProtocol(user.getProtocolInfo().getServerProtocolVersion()).getName());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package net.raphimc.vialoader.commands.subs;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
|
||||||
import com.viaversion.viaversion.api.command.ViaSubCommand;
|
|
||||||
import io.netty.util.ResourceLeakDetector;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class LeakDetectSubCommand extends ViaSubCommand {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String name() {
|
|
||||||
return "leakdetect";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String description() {
|
|
||||||
return "Sets ResourceLeakDetector level";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean execute(ViaCommandSender viaCommandSender, String[] strings) {
|
|
||||||
if (strings.length == 1) {
|
|
||||||
try {
|
|
||||||
ResourceLeakDetector.Level level = ResourceLeakDetector.Level.valueOf(strings[0]);
|
|
||||||
ResourceLeakDetector.setLevel(level);
|
|
||||||
viaCommandSender.sendMessage("Set leak detector level to " + level);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
viaCommandSender.sendMessage("Invalid level (" + Arrays.toString(ResourceLeakDetector.Level.values()) + ")");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
viaCommandSender.sendMessage("Current leak detection level is " + ResourceLeakDetector.getLevel());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(ViaCommandSender sender, String[] args) {
|
|
||||||
if (args.length == 1) {
|
|
||||||
return Arrays.stream(ResourceLeakDetector.Level.values())
|
|
||||||
.map(Enum::name)
|
|
||||||
.filter(it -> it.startsWith(args[0]))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
return super.onTabComplete(sender, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -30,7 +30,7 @@ public class ViaAprilFoolsPlatformImpl implements ViaAprilFoolsPlatform {
|
|||||||
private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaAprilFools"));
|
private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaAprilFools"));
|
||||||
|
|
||||||
public ViaAprilFoolsPlatformImpl() {
|
public ViaAprilFoolsPlatformImpl() {
|
||||||
this.init(this.getDataFolder());
|
this.init(new File(this.getDataFolder(), "viaaprilfools.yml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -30,7 +30,7 @@ public class ViaBackwardsPlatformImpl implements ViaBackwardsPlatform {
|
|||||||
private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaBackwards"));
|
private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaBackwards"));
|
||||||
|
|
||||||
public ViaBackwardsPlatformImpl() {
|
public ViaBackwardsPlatformImpl() {
|
||||||
this.init(this.getDataFolder());
|
this.init(new File(this.getDataFolder(), "viabackwards.yml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -30,7 +30,7 @@ public class ViaBedrockPlatformImpl implements ViaBedrockPlatform {
|
|||||||
private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaBedrock"));
|
private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaBedrock"));
|
||||||
|
|
||||||
public ViaBedrockPlatformImpl() {
|
public ViaBedrockPlatformImpl() {
|
||||||
this.init(this.getDataFolder());
|
this.init(new File(this.getDataFolder(), "viabedrock.yml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -30,7 +30,7 @@ public class ViaLegacyPlatformImpl implements ViaLegacyPlatform {
|
|||||||
private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaLegacy"));
|
private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaLegacy"));
|
||||||
|
|
||||||
public ViaLegacyPlatformImpl() {
|
public ViaLegacyPlatformImpl() {
|
||||||
this.init(this.getDataFolder());
|
this.init(new File(this.getDataFolder(), "vialegacy.yml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -17,9 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
package net.raphimc.vialoader.impl.platform;
|
package net.raphimc.vialoader.impl.platform;
|
||||||
|
|
||||||
|
import com.viaversion.viarewind.api.ViaRewindPlatform;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import de.gerrygames.viarewind.api.ViaRewindConfigImpl;
|
|
||||||
import de.gerrygames.viarewind.api.ViaRewindPlatform;
|
|
||||||
import net.raphimc.vialoader.util.JLoggerToSLF4J;
|
import net.raphimc.vialoader.util.JLoggerToSLF4J;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -31,9 +30,7 @@ public class ViaRewindPlatformImpl implements ViaRewindPlatform {
|
|||||||
private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaRewind"));
|
private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaRewind"));
|
||||||
|
|
||||||
public ViaRewindPlatformImpl() {
|
public ViaRewindPlatformImpl() {
|
||||||
final ViaRewindConfigImpl config = new ViaRewindConfigImpl(new File(Via.getPlatform().getDataFolder(), "viarewind.yml"));
|
this.init(new File(getDataFolder(), "viarewind.yml"));
|
||||||
config.reloadConfig();
|
|
||||||
this.init(config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -41,4 +38,9 @@ public class ViaRewindPlatformImpl implements ViaRewindPlatform {
|
|||||||
return LOGGER;
|
return LOGGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File getDataFolder() {
|
||||||
|
return Via.getPlatform().getDataFolder();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -20,8 +20,8 @@ package net.raphimc.vialoader.impl.platform;
|
|||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.ViaAPI;
|
import com.viaversion.viaversion.api.ViaAPI;
|
||||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||||
import com.viaversion.viaversion.api.configuration.ConfigurationProvider;
|
|
||||||
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
|
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
|
||||||
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.platform.ViaPlatform;
|
import com.viaversion.viaversion.api.platform.ViaPlatform;
|
||||||
import com.viaversion.viaversion.configuration.AbstractViaConfig;
|
import com.viaversion.viaversion.configuration.AbstractViaConfig;
|
||||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||||
@ -39,13 +39,13 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class ViaVersionPlatformImpl implements ViaPlatform<UUID> {
|
public class ViaVersionPlatformImpl implements ViaPlatform<UserConnection> {
|
||||||
|
|
||||||
private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaVersion"));
|
private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaVersion"));
|
||||||
|
|
||||||
private final File dataFolder;
|
private final File dataFolder;
|
||||||
private final AbstractViaConfig config;
|
private final AbstractViaConfig config;
|
||||||
private final ViaAPI<UUID> api;
|
private final ViaAPI<UserConnection> api;
|
||||||
|
|
||||||
public ViaVersionPlatformImpl(final File rootFolder) {
|
public ViaVersionPlatformImpl(final File rootFolder) {
|
||||||
this.dataFolder = new File(rootFolder, "ViaLoader");
|
this.dataFolder = new File(rootFolder, "ViaLoader");
|
||||||
@ -70,7 +70,7 @@ public class ViaVersionPlatformImpl implements ViaPlatform<UUID> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPluginVersion() {
|
public String getPluginVersion() {
|
||||||
return VersionInfo.VERSION;
|
return VersionInfo.getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -123,13 +123,13 @@ public class ViaVersionPlatformImpl implements ViaPlatform<UUID> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOldClientsAllowed() {
|
public boolean hasPlugin(String s) {
|
||||||
return true;
|
return false; // Used for ViaPlatform#getUnsupportedSoftwareClasses
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPlugin(String s) {
|
public boolean couldBeReloading() {
|
||||||
return s.equalsIgnoreCase("ViaVersion") || s.equalsIgnoreCase("ViaBackwards") || s.equalsIgnoreCase("ViaRewind");
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -138,7 +138,7 @@ public class ViaVersionPlatformImpl implements ViaPlatform<UUID> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ViaAPI<UUID> getApi() {
|
public ViaAPI<UserConnection> getApi() {
|
||||||
return this.api;
|
return this.api;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,11 +147,6 @@ public class ViaVersionPlatformImpl implements ViaPlatform<UUID> {
|
|||||||
return this.config;
|
return this.config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConfigurationProvider getConfigurationProvider() {
|
|
||||||
return this.config;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File getDataFolder() {
|
public File getDataFolder() {
|
||||||
return this.dataFolder;
|
return this.dataFolder;
|
||||||
@ -167,12 +162,10 @@ public class ViaVersionPlatformImpl implements ViaPlatform<UUID> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractViaConfig createConfig() {
|
protected AbstractViaConfig createConfig() {
|
||||||
final AbstractViaConfig config = new VLViaConfig(new File(this.dataFolder, "viaversion.yml"));
|
return new VLViaConfig(new File(this.dataFolder, "viaversion.yml"), this.getLogger());
|
||||||
config.reloadConfig();
|
|
||||||
return config;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ViaAPI<UUID> createApi() {
|
protected ViaAPI<UserConnection> createApi() {
|
||||||
return new VLApiBase();
|
return new VLApiBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package net.raphimc.vialoader.impl.providers;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.MovementTracker;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public class VLMovementTransmitterProvider extends MovementTransmitterProvider {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getFlyingPacket() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getGroundPacket() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendPlayer(UserConnection user) {
|
|
||||||
if (user.getProtocolInfo().getState() != State.PLAY) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (user.getEntityTracker(Protocol1_9To1_8.class).clientEntityId() == -1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final MovementTracker movementTracker = user.get(MovementTracker.class);
|
|
||||||
movementTracker.incrementIdlePacket();
|
|
||||||
|
|
||||||
try {
|
|
||||||
final PacketWrapper playerMovement = PacketWrapper.create(ServerboundPackets1_8.PLAYER_MOVEMENT, user);
|
|
||||||
playerMovement.write(Type.BOOLEAN, movementTracker.isGround()); // on ground
|
|
||||||
playerMovement.scheduleSendToServer(Protocol1_9To1_8.class);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
Via.getPlatform().getLogger().log(Level.WARNING, "Failed to send player movement packet", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -18,9 +18,20 @@
|
|||||||
package net.raphimc.vialoader.impl.viaversion;
|
package net.raphimc.vialoader.impl.viaversion;
|
||||||
|
|
||||||
import com.viaversion.viaversion.ViaAPIBase;
|
import com.viaversion.viaversion.ViaAPIBase;
|
||||||
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
import java.util.UUID;
|
public class VLApiBase extends ViaAPIBase<UserConnection> {
|
||||||
|
|
||||||
public class VLApiBase extends ViaAPIBase<UUID> {
|
@Override
|
||||||
|
public ProtocolVersion getPlayerProtocolVersion(final UserConnection player) {
|
||||||
|
return player.getProtocolInfo().protocolVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendRawPacket(final UserConnection player, final ByteBuf packet) {
|
||||||
|
player.scheduleSendRawPacket(packet);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -18,14 +18,11 @@
|
|||||||
package net.raphimc.vialoader.impl.viaversion;
|
package net.raphimc.vialoader.impl.viaversion;
|
||||||
|
|
||||||
import com.viaversion.viaversion.commands.ViaCommandHandler;
|
import com.viaversion.viaversion.commands.ViaCommandHandler;
|
||||||
import net.raphimc.vialoader.commands.subs.ConnectionsSubCommand;
|
|
||||||
import net.raphimc.vialoader.commands.subs.LeakDetectSubCommand;
|
|
||||||
|
|
||||||
public class VLCommandHandler extends ViaCommandHandler {
|
public class VLCommandHandler extends ViaCommandHandler {
|
||||||
|
|
||||||
public VLCommandHandler() {
|
public VLCommandHandler() {
|
||||||
this.registerSubCommand(new LeakDetectSubCommand());
|
this.removeSubCommand("dontbugme");
|
||||||
this.registerSubCommand(new ConnectionsSubCommand());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -18,11 +18,12 @@
|
|||||||
package net.raphimc.vialoader.impl.viaversion;
|
package net.raphimc.vialoader.impl.viaversion;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.platform.ViaInjector;
|
import com.viaversion.viaversion.api.platform.ViaInjector;
|
||||||
import com.viaversion.viaversion.libs.fastutil.ints.IntLinkedOpenHashSet;
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import com.viaversion.viaversion.libs.fastutil.ints.IntSortedSet;
|
import com.viaversion.viaversion.libs.fastutil.objects.ObjectLinkedOpenHashSet;
|
||||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||||
import net.raphimc.vialoader.netty.VLPipeline;
|
import net.raphimc.vialoader.netty.VLPipeline;
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
public class VLInjector implements ViaInjector {
|
public class VLInjector implements ViaInjector {
|
||||||
|
|
||||||
@ -35,16 +36,14 @@ public class VLInjector implements ViaInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getServerProtocolVersion() {
|
public ProtocolVersion getServerProtocolVersion() {
|
||||||
return this.getServerProtocolVersions().firstInt();
|
return this.getServerProtocolVersions().first();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IntSortedSet getServerProtocolVersions() {
|
public SortedSet<ProtocolVersion> getServerProtocolVersions() {
|
||||||
final IntSortedSet versions = new IntLinkedOpenHashSet();
|
final SortedSet<ProtocolVersion> versions = new ObjectLinkedOpenHashSet<>();
|
||||||
for (VersionEnum version : VersionEnum.OFFICIAL_SUPPORTED_PROTOCOLS) {
|
versions.addAll(ProtocolVersion.getProtocols());
|
||||||
versions.add(version.getOriginalVersion());
|
|
||||||
}
|
|
||||||
return versions;
|
return versions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -17,16 +17,12 @@
|
|||||||
*/
|
*/
|
||||||
package net.raphimc.vialoader.impl.viaversion;
|
package net.raphimc.vialoader.impl.viaversion;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import com.viaversion.viaversion.api.platform.ViaPlatformLoader;
|
import com.viaversion.viaversion.api.platform.ViaPlatformLoader;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
|
||||||
import net.raphimc.vialoader.impl.providers.VLMovementTransmitterProvider;
|
|
||||||
|
|
||||||
public class VLLoader implements ViaPlatformLoader {
|
public class VLLoader implements ViaPlatformLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new VLMovementTransmitterProvider());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -17,28 +17,22 @@
|
|||||||
*/
|
*/
|
||||||
package net.raphimc.vialoader.impl.viaversion;
|
package net.raphimc.vialoader.impl.viaversion;
|
||||||
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.viaversion.viaversion.configuration.AbstractViaConfig;
|
import com.viaversion.viaversion.configuration.AbstractViaConfig;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collections;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.logging.Logger;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class VLViaConfig extends AbstractViaConfig {
|
public class VLViaConfig extends AbstractViaConfig {
|
||||||
|
|
||||||
protected final List<String> UNSUPPORTED = Lists.newArrayList(
|
protected final List<String> UNSUPPORTED = new ArrayList<>();
|
||||||
"checkforupdates", "bungee-ping-interval", "bungee-ping-save", "bungee-servers",
|
|
||||||
"velocity-ping-interval", "velocity-ping-save", "velocity-servers",
|
|
||||||
"block-protocols", "block-disconnect-msg", "reload-disconnect-msg", "max-pps",
|
|
||||||
"max-pps-kick-msg", "tracking-period", "tracking-warning-pps", "tracking-max-warnings", "tracking-max-kick-msg",
|
|
||||||
"blockconnection-method", "quick-move-action-fix", "item-cache", "change-1_9-hitbox", "change-1_14-hitbox",
|
|
||||||
"use-new-deathmessages", "nms-player-ticking"
|
|
||||||
);
|
|
||||||
|
|
||||||
public VLViaConfig(final File configFile) {
|
public VLViaConfig(final File configFile, final Logger logger) {
|
||||||
super(configFile);
|
super(configFile, logger);
|
||||||
|
|
||||||
|
UNSUPPORTED.addAll(BUKKIT_ONLY_OPTIONS);
|
||||||
|
UNSUPPORTED.addAll(VELOCITY_ONLY_OPTIONS);
|
||||||
|
UNSUPPORTED.add("check-for-updates");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -55,39 +49,4 @@ public class VLViaConfig extends AbstractViaConfig {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getBlockConnectionMethod() {
|
|
||||||
return "packet";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean is1_12QuickMoveActionFix() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isItemCache() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean is1_9HitboxFix() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean is1_14HitboxFix() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isShowNewDeathMessages() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isNMSPlayerTicking() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -17,19 +17,20 @@
|
|||||||
*/
|
*/
|
||||||
package net.raphimc.vialoader.netty;
|
package net.raphimc.vialoader.netty;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.VersionType;
|
||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||||
import net.raphimc.viabedrock.netty.BatchLengthCodec;
|
import net.raphimc.viabedrock.netty.BatchLengthCodec;
|
||||||
import net.raphimc.viabedrock.netty.PacketEncapsulationCodec;
|
import net.raphimc.viabedrock.netty.PacketEncapsulationCodec;
|
||||||
import net.raphimc.viabedrock.protocol.BedrockBaseProtocol;
|
|
||||||
import net.raphimc.vialegacy.netty.PreNettyLengthPrepender;
|
import net.raphimc.vialegacy.netty.PreNettyLengthPrepender;
|
||||||
import net.raphimc.vialegacy.netty.PreNettyLengthRemover;
|
import net.raphimc.vialegacy.netty.PreNettyLengthRemover;
|
||||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.baseprotocols.PreNettyBaseProtocol;
|
|
||||||
import net.raphimc.vialoader.netty.viabedrock.DisconnectHandler;
|
import net.raphimc.vialoader.netty.viabedrock.DisconnectHandler;
|
||||||
import net.raphimc.vialoader.netty.viabedrock.RakMessageEncapsulationCodec;
|
import net.raphimc.vialoader.netty.viabedrock.RakMessageEncapsulationCodec;
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
|
||||||
|
|
||||||
public abstract class VLLegacyPipeline extends ChannelInboundHandlerAdapter {
|
public abstract class VLLegacyPipeline extends ChannelInboundHandlerAdapter {
|
||||||
|
|
||||||
@ -44,9 +45,14 @@ public abstract class VLLegacyPipeline extends ChannelInboundHandlerAdapter {
|
|||||||
public static final String VIABEDROCK_PACKET_ENCAPSULATION_HANDLER_NAME = "viabedrock-packet-encapsulation";
|
public static final String VIABEDROCK_PACKET_ENCAPSULATION_HANDLER_NAME = "viabedrock-packet-encapsulation";
|
||||||
|
|
||||||
protected final UserConnection user;
|
protected final UserConnection user;
|
||||||
protected final VersionEnum version;
|
protected final ProtocolVersion version;
|
||||||
|
|
||||||
public VLLegacyPipeline(final UserConnection user, final VersionEnum version) {
|
public VLLegacyPipeline(final UserConnection user) {
|
||||||
|
this(user, Via.getManager().getProviders().get(VersionProvider.class).getServerProtocol(user));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public VLLegacyPipeline(final UserConnection user, final ProtocolVersion version) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
@ -56,12 +62,11 @@ public abstract class VLLegacyPipeline extends ChannelInboundHandlerAdapter {
|
|||||||
ctx.pipeline().addBefore(this.packetDecoderName(), VIA_DECODER_NAME, this.createViaDecoder());
|
ctx.pipeline().addBefore(this.packetDecoderName(), VIA_DECODER_NAME, this.createViaDecoder());
|
||||||
ctx.pipeline().addBefore(this.packetEncoderName(), VIA_ENCODER_NAME, this.createViaEncoder());
|
ctx.pipeline().addBefore(this.packetEncoderName(), VIA_ENCODER_NAME, this.createViaEncoder());
|
||||||
|
|
||||||
if (this.version.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
final ProtocolVersion r1_6_4 = ProtocolVersion.getProtocol(VersionType.RELEASE_INITIAL, 78);
|
||||||
this.user.getProtocolInfo().getPipeline().add(PreNettyBaseProtocol.INSTANCE);
|
if (r1_6_4.isKnown() && this.version.olderThanOrEqualTo(r1_6_4)) {
|
||||||
ctx.pipeline().addBefore(this.lengthSplitterName(), VIALEGACY_PRE_NETTY_LENGTH_PREPENDER_NAME, this.createViaLegacyPreNettyLengthPrepender());
|
ctx.pipeline().addBefore(this.lengthSplitterName(), VIALEGACY_PRE_NETTY_LENGTH_PREPENDER_NAME, this.createViaLegacyPreNettyLengthPrepender());
|
||||||
ctx.pipeline().addBefore(this.lengthPrependerName(), VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, this.createViaLegacyPreNettyLengthRemover());
|
ctx.pipeline().addBefore(this.lengthPrependerName(), VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, this.createViaLegacyPreNettyLengthRemover());
|
||||||
} else if (this.version.equals(VersionEnum.bedrockLatest)) {
|
} else if (this.version.getName().startsWith("Bedrock")) {
|
||||||
this.user.getProtocolInfo().getPipeline().add(BedrockBaseProtocol.INSTANCE);
|
|
||||||
ctx.pipeline().addBefore(this.lengthSplitterName(), VIABEDROCK_DISCONNECT_HANDLER_NAME, this.createViaBedrockDisconnectHandler());
|
ctx.pipeline().addBefore(this.lengthSplitterName(), VIABEDROCK_DISCONNECT_HANDLER_NAME, this.createViaBedrockDisconnectHandler());
|
||||||
ctx.pipeline().addBefore(this.lengthSplitterName(), VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, this.createViaBedrockFrameEncapsulationHandler());
|
ctx.pipeline().addBefore(this.lengthSplitterName(), VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, this.createViaBedrockFrameEncapsulationHandler());
|
||||||
this.replaceLengthSplitter(ctx, this.createViaBedrockBatchLengthCodec());
|
this.replaceLengthSplitter(ctx, this.createViaBedrockBatchLengthCodec());
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -17,19 +17,20 @@
|
|||||||
*/
|
*/
|
||||||
package net.raphimc.vialoader.netty;
|
package net.raphimc.vialoader.netty;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.VersionType;
|
||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||||
import io.netty.channel.ChannelPipeline;
|
import io.netty.channel.ChannelPipeline;
|
||||||
import net.raphimc.viabedrock.netty.BatchLengthCodec;
|
import net.raphimc.viabedrock.netty.BatchLengthCodec;
|
||||||
import net.raphimc.viabedrock.netty.PacketEncapsulationCodec;
|
import net.raphimc.viabedrock.netty.PacketEncapsulationCodec;
|
||||||
import net.raphimc.viabedrock.protocol.BedrockBaseProtocol;
|
|
||||||
import net.raphimc.vialegacy.netty.PreNettyLengthCodec;
|
import net.raphimc.vialegacy.netty.PreNettyLengthCodec;
|
||||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.baseprotocols.PreNettyBaseProtocol;
|
|
||||||
import net.raphimc.vialoader.netty.viabedrock.DisconnectHandler;
|
import net.raphimc.vialoader.netty.viabedrock.DisconnectHandler;
|
||||||
import net.raphimc.vialoader.netty.viabedrock.RakMessageEncapsulationCodec;
|
import net.raphimc.vialoader.netty.viabedrock.RakMessageEncapsulationCodec;
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
|
||||||
|
|
||||||
public abstract class VLPipeline extends ChannelInboundHandlerAdapter {
|
public abstract class VLPipeline extends ChannelInboundHandlerAdapter {
|
||||||
|
|
||||||
@ -42,9 +43,14 @@ public abstract class VLPipeline extends ChannelInboundHandlerAdapter {
|
|||||||
public static final String VIABEDROCK_PACKET_ENCAPSULATION_HANDLER_NAME = "viabedrock-packet-encapsulation";
|
public static final String VIABEDROCK_PACKET_ENCAPSULATION_HANDLER_NAME = "viabedrock-packet-encapsulation";
|
||||||
|
|
||||||
protected final UserConnection user;
|
protected final UserConnection user;
|
||||||
protected final VersionEnum version;
|
protected final ProtocolVersion version;
|
||||||
|
|
||||||
public VLPipeline(final UserConnection user, final VersionEnum version) {
|
public VLPipeline(final UserConnection user) {
|
||||||
|
this(user, Via.getManager().getProviders().get(VersionProvider.class).getServerProtocol(user));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public VLPipeline(final UserConnection user, final ProtocolVersion version) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
@ -53,11 +59,10 @@ public abstract class VLPipeline extends ChannelInboundHandlerAdapter {
|
|||||||
public void handlerAdded(ChannelHandlerContext ctx) {
|
public void handlerAdded(ChannelHandlerContext ctx) {
|
||||||
ctx.pipeline().addBefore(this.packetCodecName(), VIA_CODEC_NAME, this.createViaCodec());
|
ctx.pipeline().addBefore(this.packetCodecName(), VIA_CODEC_NAME, this.createViaCodec());
|
||||||
|
|
||||||
if (this.version.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
final ProtocolVersion r1_6_4 = ProtocolVersion.getProtocol(VersionType.RELEASE_INITIAL, 78);
|
||||||
this.user.getProtocolInfo().getPipeline().add(PreNettyBaseProtocol.INSTANCE);
|
if (r1_6_4.isKnown() && this.version.olderThanOrEqualTo(r1_6_4)) {
|
||||||
ctx.pipeline().addBefore(this.lengthCodecName(), VIALEGACY_PRE_NETTY_LENGTH_CODEC_NAME, this.createViaLegacyPreNettyLengthCodec());
|
ctx.pipeline().addBefore(this.lengthCodecName(), VIALEGACY_PRE_NETTY_LENGTH_CODEC_NAME, this.createViaLegacyPreNettyLengthCodec());
|
||||||
} else if (this.version.equals(VersionEnum.bedrockLatest)) {
|
} else if (this.version.getName().startsWith("Bedrock")) {
|
||||||
this.user.getProtocolInfo().getPipeline().add(BedrockBaseProtocol.INSTANCE);
|
|
||||||
ctx.pipeline().addBefore(this.lengthCodecName(), VIABEDROCK_DISCONNECT_HANDLER_NAME, this.createViaBedrockDisconnectHandler());
|
ctx.pipeline().addBefore(this.lengthCodecName(), VIABEDROCK_DISCONNECT_HANDLER_NAME, this.createViaBedrockDisconnectHandler());
|
||||||
ctx.pipeline().addBefore(this.lengthCodecName(), VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, this.createViaBedrockFrameEncapsulationHandler());
|
ctx.pipeline().addBefore(this.lengthCodecName(), VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, this.createViaBedrockFrameEncapsulationHandler());
|
||||||
this.replaceLengthCodec(ctx, this.createViaBedrockBatchLengthCodec());
|
this.replaceLengthCodec(ctx, this.createViaBedrockBatchLengthCodec());
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -21,6 +21,7 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import io.netty.buffer.CompositeByteBuf;
|
import io.netty.buffer.CompositeByteBuf;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.handler.codec.MessageToMessageCodec;
|
import io.netty.handler.codec.MessageToMessageCodec;
|
||||||
|
import net.raphimc.viabedrock.ViaBedrock;
|
||||||
import org.cloudburstmc.netty.channel.raknet.RakReliability;
|
import org.cloudburstmc.netty.channel.raknet.RakReliability;
|
||||||
import org.cloudburstmc.netty.channel.raknet.packet.RakMessage;
|
import org.cloudburstmc.netty.channel.raknet.packet.RakMessage;
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ public class RakMessageEncapsulationCodec extends MessageToMessageCodec<RakMessa
|
|||||||
try {
|
try {
|
||||||
buf.addComponent(true, ctx.alloc().ioBuffer(1).writeByte(FRAME_ID));
|
buf.addComponent(true, ctx.alloc().ioBuffer(1).writeByte(FRAME_ID));
|
||||||
buf.addComponent(true, msg.retainedSlice());
|
buf.addComponent(true, msg.retainedSlice());
|
||||||
out.add(buf.retain());
|
out.add(new RakMessage(buf.retain()));
|
||||||
} finally {
|
} finally {
|
||||||
buf.release();
|
buf.release();
|
||||||
}
|
}
|
||||||
@ -52,8 +53,9 @@ public class RakMessageEncapsulationCodec extends MessageToMessageCodec<RakMessa
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final int id = in.readUnsignedByte();
|
final int id = in.readUnsignedByte();
|
||||||
if (id != FRAME_ID) {
|
if (id != FRAME_ID) { // Mojang client seems to ignore invalid frames
|
||||||
throw new IllegalStateException("Invalid frame ID: " + id);
|
ViaBedrock.getPlatform().getLogger().warning("Received invalid RakNet frame id: " + id);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
out.add(in.readRetainedSlice(in.readableBytes()));
|
out.add(in.readRetainedSlice(in.readableBytes()));
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package net.raphimc.vialoader.util;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ProtocolVersionList {
|
||||||
|
|
||||||
|
public static List<ProtocolVersion> getProtocolsNewToOld() {
|
||||||
|
final List<ProtocolVersion> protocolVersions = new ArrayList<>(ProtocolVersion.getProtocols());
|
||||||
|
Collections.reverse(protocolVersions);
|
||||||
|
return Collections.unmodifiableList(protocolVersions);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -19,28 +19,12 @@ package net.raphimc.vialoader.util;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.platform.PlatformTask;
|
import com.viaversion.viaversion.api.platform.PlatformTask;
|
||||||
import com.viaversion.viaversion.api.scheduler.Task;
|
import com.viaversion.viaversion.api.scheduler.Task;
|
||||||
import com.viaversion.viaversion.api.scheduler.TaskStatus;
|
|
||||||
|
|
||||||
public class VLTask implements PlatformTask<Task> {
|
public record VLTask(Task task) implements PlatformTask<Task> {
|
||||||
|
|
||||||
private final Task task;
|
|
||||||
|
|
||||||
public VLTask(final Task task) {
|
|
||||||
this.task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Task getObject() {
|
|
||||||
return this.task;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
this.task.cancel();
|
this.task.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TaskStatus getStatus() {
|
|
||||||
return this.task.status();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,303 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package net.raphimc.vialoader.util;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public enum VersionEnum {
|
|
||||||
|
|
||||||
c0_0_15a_1(getViaLegacyProtocol("c0_0_15a_1")),
|
|
||||||
c0_0_16a_02(getViaLegacyProtocol("c0_0_16a_02")),
|
|
||||||
c0_0_18a_02(getViaLegacyProtocol("c0_0_18a_02")),
|
|
||||||
c0_0_19a_06(getViaLegacyProtocol("c0_0_19a_06")),
|
|
||||||
c0_0_20ac0_27(getViaLegacyProtocol("c0_0_20ac0_27")),
|
|
||||||
c0_30cpe(getViaLegacyProtocol("c0_30cpe")),
|
|
||||||
c0_28toc0_30(getViaLegacyProtocol("c0_28toc0_30")),
|
|
||||||
a1_0_15(getViaLegacyProtocol("a1_0_15")),
|
|
||||||
a1_0_16toa1_0_16_2(getViaLegacyProtocol("a1_0_16toa1_0_16_2")),
|
|
||||||
a1_0_17toa1_0_17_4(getViaLegacyProtocol("a1_0_17toa1_0_17_4")),
|
|
||||||
a1_1_0toa1_1_2_1(getViaLegacyProtocol("a1_1_0toa1_1_2_1")),
|
|
||||||
a1_2_0toa1_2_1_1(getViaLegacyProtocol("a1_2_0toa1_2_1_1")),
|
|
||||||
a1_2_2(getViaLegacyProtocol("a1_2_2")),
|
|
||||||
a1_2_3toa1_2_3_4(getViaLegacyProtocol("a1_2_3toa1_2_3_4")),
|
|
||||||
a1_2_3_5toa1_2_6(getViaLegacyProtocol("a1_2_3_5toa1_2_6")),
|
|
||||||
b1_0tob1_1_1(getViaLegacyProtocol("b1_0tob1_1_1")),
|
|
||||||
b1_1_2(getViaLegacyProtocol("b1_1_2")),
|
|
||||||
b1_2_0tob1_2_2(getViaLegacyProtocol("b1_2_0tob1_2_2")),
|
|
||||||
b1_3tob1_3_1(getViaLegacyProtocol("b1_3tob1_3_1")),
|
|
||||||
b1_4tob1_4_1(getViaLegacyProtocol("b1_4tob1_4_1")),
|
|
||||||
b1_5tob1_5_2(getViaLegacyProtocol("b1_5tob1_5_2")),
|
|
||||||
b1_6tob1_6_6(getViaLegacyProtocol("b1_6tob1_6_6")),
|
|
||||||
b1_7tob1_7_3(getViaLegacyProtocol("b1_7tob1_7_3")),
|
|
||||||
b1_8tob1_8_1(getViaLegacyProtocol("b1_8tob1_8_1")),
|
|
||||||
r1_0_0tor1_0_1(getViaLegacyProtocol("r1_0_0tor1_0_1")),
|
|
||||||
r1_1(getViaLegacyProtocol("r1_1")),
|
|
||||||
r1_2_1tor1_2_3(getViaLegacyProtocol("r1_2_1tor1_2_3")),
|
|
||||||
r1_2_4tor1_2_5(getViaLegacyProtocol("r1_2_4tor1_2_5")),
|
|
||||||
r1_3_1tor1_3_2(getViaLegacyProtocol("r1_3_1tor1_3_2")),
|
|
||||||
r1_4_2(getViaLegacyProtocol("r1_4_2")),
|
|
||||||
r1_4_4tor1_4_5(getViaLegacyProtocol("r1_4_4tor1_4_5")),
|
|
||||||
r1_4_6tor1_4_7(getViaLegacyProtocol("r1_4_6tor1_4_7")),
|
|
||||||
r1_5tor1_5_1(getViaLegacyProtocol("r1_5tor1_5_1")),
|
|
||||||
r1_5_2(getViaLegacyProtocol("r1_5_2")),
|
|
||||||
r1_6_1(getViaLegacyProtocol("r1_6_1")),
|
|
||||||
r1_6_2(getViaLegacyProtocol("r1_6_2")),
|
|
||||||
r1_6_4(getViaLegacyProtocol("r1_6_4")),
|
|
||||||
r1_7_2tor1_7_5(ProtocolVersion.v1_7_1),
|
|
||||||
r1_7_6tor1_7_10(ProtocolVersion.v1_7_6),
|
|
||||||
r1_8(ProtocolVersion.v1_8),
|
|
||||||
r1_9(ProtocolVersion.v1_9),
|
|
||||||
r1_9_1(ProtocolVersion.v1_9_1),
|
|
||||||
r1_9_2(ProtocolVersion.v1_9_2),
|
|
||||||
r1_9_3tor1_9_4(ProtocolVersion.v1_9_3),
|
|
||||||
r1_10(ProtocolVersion.v1_10),
|
|
||||||
r1_11(ProtocolVersion.v1_11),
|
|
||||||
r1_11_1to1_11_2(ProtocolVersion.v1_11_1),
|
|
||||||
r1_12(ProtocolVersion.v1_12),
|
|
||||||
r1_12_1(ProtocolVersion.v1_12_1),
|
|
||||||
r1_12_2(ProtocolVersion.v1_12_2),
|
|
||||||
r1_13(ProtocolVersion.v1_13),
|
|
||||||
r1_13_1(ProtocolVersion.v1_13_1),
|
|
||||||
r1_13_2(ProtocolVersion.v1_13_2),
|
|
||||||
s3d_shareware(getViaAprilFoolsProtocol("s3d_shareware")),
|
|
||||||
r1_14(ProtocolVersion.v1_14),
|
|
||||||
r1_14_1(ProtocolVersion.v1_14_1),
|
|
||||||
r1_14_2(ProtocolVersion.v1_14_2),
|
|
||||||
r1_14_3(ProtocolVersion.v1_14_3),
|
|
||||||
r1_14_4(ProtocolVersion.v1_14_4),
|
|
||||||
r1_15(ProtocolVersion.v1_15),
|
|
||||||
r1_15_1(ProtocolVersion.v1_15_1),
|
|
||||||
r1_15_2(ProtocolVersion.v1_15_2),
|
|
||||||
s20w14infinite(getViaAprilFoolsProtocol("s20w14infinite")),
|
|
||||||
r1_16(ProtocolVersion.v1_16),
|
|
||||||
r1_16_1(ProtocolVersion.v1_16_1),
|
|
||||||
sCombatTest8c(getViaAprilFoolsProtocol("sCombatTest8c")),
|
|
||||||
r1_16_2(ProtocolVersion.v1_16_2),
|
|
||||||
r1_16_3(ProtocolVersion.v1_16_3),
|
|
||||||
r1_16_4tor1_16_5(ProtocolVersion.v1_16_4),
|
|
||||||
r1_17(ProtocolVersion.v1_17),
|
|
||||||
r1_17_1(ProtocolVersion.v1_17_1),
|
|
||||||
r1_18tor1_18_1(ProtocolVersion.v1_18),
|
|
||||||
r1_18_2(ProtocolVersion.v1_18_2),
|
|
||||||
r1_19(ProtocolVersion.v1_19),
|
|
||||||
r1_19_1tor1_19_2(ProtocolVersion.v1_19_1),
|
|
||||||
r1_19_3(ProtocolVersion.v1_19_3),
|
|
||||||
bedrockLatest(getViaBedrockProtocol("bedrockLatest")),
|
|
||||||
r1_19_4(ProtocolVersion.v1_19_4),
|
|
||||||
r1_20(ProtocolVersion.v1_20),
|
|
||||||
|
|
||||||
//
|
|
||||||
UNKNOWN(ProtocolVersion.unknown), // Not in Registry
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
private static final Map<ProtocolVersion, VersionEnum> VERSION_REGISTRY = new HashMap<>();
|
|
||||||
public static final List<VersionEnum> SORTED_VERSIONS = new ArrayList<>();
|
|
||||||
public static final List<VersionEnum> OFFICIAL_SUPPORTED_PROTOCOLS = new ArrayList<>();
|
|
||||||
|
|
||||||
static {
|
|
||||||
for (VersionEnum version : VersionEnum.values()) {
|
|
||||||
if (version == UNKNOWN) continue;
|
|
||||||
if (!version.protocolVersion.isKnown()) continue;
|
|
||||||
VERSION_REGISTRY.put(version.protocolVersion, version);
|
|
||||||
}
|
|
||||||
for (VersionEnum version : VersionEnum.getAllVersions()) {
|
|
||||||
if (version.isNewerThan(VersionEnum.r1_6_4) && version != VersionEnum.s3d_shareware && version != VersionEnum.s20w14infinite && version != VersionEnum.sCombatTest8c && version != VersionEnum.bedrockLatest) {
|
|
||||||
OFFICIAL_SUPPORTED_PROTOCOLS.add(version);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SORTED_VERSIONS.add(r1_20);
|
|
||||||
SORTED_VERSIONS.add(r1_19_4);
|
|
||||||
SORTED_VERSIONS.add(r1_19_3);
|
|
||||||
SORTED_VERSIONS.add(r1_19_1tor1_19_2);
|
|
||||||
SORTED_VERSIONS.add(r1_19);
|
|
||||||
SORTED_VERSIONS.add(r1_18_2);
|
|
||||||
SORTED_VERSIONS.add(r1_18tor1_18_1);
|
|
||||||
SORTED_VERSIONS.add(r1_17_1);
|
|
||||||
SORTED_VERSIONS.add(r1_17);
|
|
||||||
SORTED_VERSIONS.add(r1_16_4tor1_16_5);
|
|
||||||
SORTED_VERSIONS.add(r1_16_3);
|
|
||||||
SORTED_VERSIONS.add(r1_16_2);
|
|
||||||
SORTED_VERSIONS.add(r1_16_1);
|
|
||||||
SORTED_VERSIONS.add(r1_16);
|
|
||||||
SORTED_VERSIONS.add(r1_15_2);
|
|
||||||
SORTED_VERSIONS.add(r1_15_1);
|
|
||||||
SORTED_VERSIONS.add(r1_15);
|
|
||||||
SORTED_VERSIONS.add(r1_14_4);
|
|
||||||
SORTED_VERSIONS.add(r1_14_3);
|
|
||||||
SORTED_VERSIONS.add(r1_14_2);
|
|
||||||
SORTED_VERSIONS.add(r1_14_1);
|
|
||||||
SORTED_VERSIONS.add(r1_14);
|
|
||||||
SORTED_VERSIONS.add(r1_13_2);
|
|
||||||
SORTED_VERSIONS.add(r1_13_1);
|
|
||||||
SORTED_VERSIONS.add(r1_13);
|
|
||||||
SORTED_VERSIONS.add(r1_12_2);
|
|
||||||
SORTED_VERSIONS.add(r1_12_1);
|
|
||||||
SORTED_VERSIONS.add(r1_12);
|
|
||||||
SORTED_VERSIONS.add(r1_11_1to1_11_2);
|
|
||||||
SORTED_VERSIONS.add(r1_11);
|
|
||||||
SORTED_VERSIONS.add(r1_10);
|
|
||||||
SORTED_VERSIONS.add(r1_9_3tor1_9_4);
|
|
||||||
SORTED_VERSIONS.add(r1_9_2);
|
|
||||||
SORTED_VERSIONS.add(r1_9_1);
|
|
||||||
SORTED_VERSIONS.add(r1_9);
|
|
||||||
SORTED_VERSIONS.add(r1_8);
|
|
||||||
SORTED_VERSIONS.add(r1_7_6tor1_7_10);
|
|
||||||
SORTED_VERSIONS.add(r1_7_2tor1_7_5);
|
|
||||||
SORTED_VERSIONS.add(r1_6_4);
|
|
||||||
SORTED_VERSIONS.add(r1_6_2);
|
|
||||||
SORTED_VERSIONS.add(r1_6_1);
|
|
||||||
SORTED_VERSIONS.add(r1_5_2);
|
|
||||||
SORTED_VERSIONS.add(r1_5tor1_5_1);
|
|
||||||
SORTED_VERSIONS.add(r1_4_6tor1_4_7);
|
|
||||||
SORTED_VERSIONS.add(r1_4_4tor1_4_5);
|
|
||||||
SORTED_VERSIONS.add(r1_4_2);
|
|
||||||
SORTED_VERSIONS.add(r1_3_1tor1_3_2);
|
|
||||||
SORTED_VERSIONS.add(r1_2_4tor1_2_5);
|
|
||||||
SORTED_VERSIONS.add(r1_2_1tor1_2_3);
|
|
||||||
SORTED_VERSIONS.add(r1_1);
|
|
||||||
SORTED_VERSIONS.add(r1_0_0tor1_0_1);
|
|
||||||
SORTED_VERSIONS.add(b1_8tob1_8_1);
|
|
||||||
SORTED_VERSIONS.add(b1_7tob1_7_3);
|
|
||||||
SORTED_VERSIONS.add(b1_6tob1_6_6);
|
|
||||||
SORTED_VERSIONS.add(b1_5tob1_5_2);
|
|
||||||
SORTED_VERSIONS.add(b1_4tob1_4_1);
|
|
||||||
SORTED_VERSIONS.add(b1_3tob1_3_1);
|
|
||||||
SORTED_VERSIONS.add(b1_2_0tob1_2_2);
|
|
||||||
SORTED_VERSIONS.add(b1_1_2);
|
|
||||||
SORTED_VERSIONS.add(b1_0tob1_1_1);
|
|
||||||
SORTED_VERSIONS.add(a1_2_3_5toa1_2_6);
|
|
||||||
SORTED_VERSIONS.add(a1_2_3toa1_2_3_4);
|
|
||||||
SORTED_VERSIONS.add(a1_2_2);
|
|
||||||
SORTED_VERSIONS.add(a1_2_0toa1_2_1_1);
|
|
||||||
SORTED_VERSIONS.add(a1_1_0toa1_1_2_1);
|
|
||||||
SORTED_VERSIONS.add(a1_0_17toa1_0_17_4);
|
|
||||||
SORTED_VERSIONS.add(a1_0_16toa1_0_16_2);
|
|
||||||
SORTED_VERSIONS.add(a1_0_15);
|
|
||||||
SORTED_VERSIONS.add(c0_28toc0_30);
|
|
||||||
SORTED_VERSIONS.add(c0_0_20ac0_27);
|
|
||||||
SORTED_VERSIONS.add(c0_0_19a_06);
|
|
||||||
SORTED_VERSIONS.add(c0_0_18a_02);
|
|
||||||
SORTED_VERSIONS.add(c0_0_16a_02);
|
|
||||||
SORTED_VERSIONS.add(c0_0_15a_1);
|
|
||||||
SORTED_VERSIONS.add(bedrockLatest);
|
|
||||||
SORTED_VERSIONS.add(sCombatTest8c);
|
|
||||||
SORTED_VERSIONS.add(s20w14infinite);
|
|
||||||
SORTED_VERSIONS.add(s3d_shareware);
|
|
||||||
SORTED_VERSIONS.add(c0_30cpe);
|
|
||||||
|
|
||||||
SORTED_VERSIONS.removeIf(v -> !v.protocolVersion.isKnown());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static VersionEnum fromProtocolVersion(final ProtocolVersion protocolVersion) {
|
|
||||||
if (!protocolVersion.isKnown()) return UNKNOWN;
|
|
||||||
return VERSION_REGISTRY.getOrDefault(protocolVersion, UNKNOWN);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static VersionEnum fromProtocolId(final int protocolId) {
|
|
||||||
return fromProtocolVersion(ProtocolVersion.getProtocol(protocolId));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static VersionEnum fromUserConnection(final UserConnection userConnection) {
|
|
||||||
return fromUserConnection(userConnection, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static VersionEnum fromUserConnection(final UserConnection userConnection, final boolean serverProtocol) {
|
|
||||||
return fromProtocolId(serverProtocol ? userConnection.getProtocolInfo().getServerProtocolVersion() : userConnection.getProtocolInfo().getProtocolVersion());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Collection<VersionEnum> getAllVersions() {
|
|
||||||
return VERSION_REGISTRY.values();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ProtocolVersion getViaLegacyProtocol(final String name) {
|
|
||||||
try {
|
|
||||||
return (ProtocolVersion) Class.forName("net.raphimc.vialegacy.api.LegacyProtocolVersion").getField(name).get(null);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
return ProtocolVersion.unknown;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ProtocolVersion getViaAprilFoolsProtocol(final String name) {
|
|
||||||
try {
|
|
||||||
return (ProtocolVersion) Class.forName("net.raphimc.viaaprilfools.api.AprilFoolsProtocolVersion").getField(name).get(null);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
return ProtocolVersion.unknown;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ProtocolVersion getViaBedrockProtocol(final String name) {
|
|
||||||
try {
|
|
||||||
return (ProtocolVersion) Class.forName("net.raphimc.viabedrock.api.BedrockProtocolVersion").getField(name).get(null);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
return ProtocolVersion.unknown;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private final ProtocolVersion protocolVersion;
|
|
||||||
|
|
||||||
VersionEnum(final ProtocolVersion protocolVersion) {
|
|
||||||
this.protocolVersion = protocolVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProtocolVersion getProtocol() {
|
|
||||||
return this.protocolVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return this.protocolVersion.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getVersion() {
|
|
||||||
return this.protocolVersion.getVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getOriginalVersion() {
|
|
||||||
return this.protocolVersion.getOriginalVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOlderThan(final VersionEnum other) {
|
|
||||||
return this.ordinal() < other.ordinal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOlderThanOrEqualTo(final VersionEnum other) {
|
|
||||||
return this.ordinal() <= other.ordinal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isNewerThan(final VersionEnum other) {
|
|
||||||
return this.ordinal() > other.ordinal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isNewerThanOrEqualTo(final VersionEnum other) {
|
|
||||||
return this.ordinal() >= other.ordinal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isBetweenInclusive(final VersionEnum min, final VersionEnum max) {
|
|
||||||
return this.isNewerThanOrEqualTo(min) && this.isOlderThanOrEqualTo(max);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isBetweenExclusive(final VersionEnum min, final VersionEnum max) {
|
|
||||||
return this.isNewerThan(min) && this.isOlderThan(max);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -17,44 +17,120 @@
|
|||||||
*/
|
*/
|
||||||
package net.raphimc.vialoader.util;
|
package net.raphimc.vialoader.util;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class VersionRange {
|
public class VersionRange {
|
||||||
|
|
||||||
private final VersionEnum lowerBound;
|
private final ProtocolVersion min;
|
||||||
private final VersionEnum upperBound;
|
private final ProtocolVersion max;
|
||||||
|
private final List<VersionRange> ranges;
|
||||||
|
|
||||||
public VersionRange(VersionEnum lowerBound, VersionEnum upperBound) {
|
private VersionRange(final ProtocolVersion min, final ProtocolVersion max) {
|
||||||
if (lowerBound == null && upperBound == null) {
|
this.min = min;
|
||||||
throw new RuntimeException("Invalid protocol range");
|
this.max = max;
|
||||||
}
|
this.ranges = new ArrayList<>();
|
||||||
this.lowerBound = lowerBound;
|
|
||||||
this.upperBound = upperBound;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VersionRange andNewer(final VersionEnum version) {
|
public static VersionRange andNewer(final ProtocolVersion version) {
|
||||||
return new VersionRange(null, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static VersionRange singleton(final VersionEnum version) {
|
|
||||||
return new VersionRange(version, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static VersionRange andOlder(final VersionEnum version) {
|
|
||||||
return new VersionRange(version, null);
|
return new VersionRange(version, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(final VersionEnum protocolVersion) {
|
public static VersionRange single(final ProtocolVersion version) {
|
||||||
if (this.lowerBound != null && lowerBound.isOlderThan(protocolVersion)) return false;
|
return new VersionRange(version, version);
|
||||||
|
}
|
||||||
|
|
||||||
return this.upperBound == null || upperBound.isOlderThanOrEqualTo(protocolVersion);
|
public static VersionRange andOlder(final ProtocolVersion version) {
|
||||||
|
return new VersionRange(null, version);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static VersionRange of(final ProtocolVersion min, final ProtocolVersion max) {
|
||||||
|
return new VersionRange(min, max);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static VersionRange all() {
|
||||||
|
return new VersionRange(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VersionRange add(final VersionRange range) {
|
||||||
|
this.ranges.add(range);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean contains(final ProtocolVersion version) {
|
||||||
|
for (VersionRange range : this.ranges) {
|
||||||
|
if (range.contains(version)) return true;
|
||||||
|
}
|
||||||
|
if (this.min == null && this.max == null) return true;
|
||||||
|
else if (this.min == null) return version.olderThanOrEqualTo(this.max);
|
||||||
|
else if (this.max == null) return version.newerThanOrEqualTo(this.min);
|
||||||
|
return version.newerThanOrEqualTo(this.min) && version.olderThanOrEqualTo(this.max);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProtocolVersion getMin() {
|
||||||
|
return this.min;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProtocolVersion getMax() {
|
||||||
|
return this.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (lowerBound == null) return upperBound.getName() + "+";
|
if (this.min == null && this.max == null) return "*";
|
||||||
if (upperBound == null) return lowerBound.getName() + "-";
|
else {
|
||||||
if (lowerBound == upperBound) return lowerBound.getName();
|
StringBuilder rangeString = new StringBuilder();
|
||||||
|
if (!this.ranges.isEmpty()) {
|
||||||
|
for (VersionRange range : this.ranges) rangeString.append(", ").append(range.toString());
|
||||||
|
}
|
||||||
|
if (this.min == null) return "<= " + this.max.getName() + rangeString;
|
||||||
|
else if (this.max == null) return ">= " + this.min.getName() + rangeString;
|
||||||
|
else if (Objects.equals(this.min, this.max)) return this.min.getName();
|
||||||
|
else return this.min.getName() + " - " + this.max.getName() + rangeString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return lowerBound.getName() + " - " + upperBound.getName();
|
@Override
|
||||||
|
public boolean equals(Object object) {
|
||||||
|
if (this == object) return true;
|
||||||
|
if (object == null || getClass() != object.getClass()) return false;
|
||||||
|
VersionRange that = (VersionRange) object;
|
||||||
|
return min == that.min && max == that.max && Objects.equals(ranges, that.ranges);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(min, max, ranges);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static VersionRange fromString(String str) {
|
||||||
|
if ("*".equals(str)) return all();
|
||||||
|
else if (str.contains(",")) {
|
||||||
|
String[] rangeParts = str.split(", ");
|
||||||
|
VersionRange versionRange = null;
|
||||||
|
|
||||||
|
for (String part : rangeParts) {
|
||||||
|
if (versionRange == null) versionRange = parseSinglePart(part);
|
||||||
|
else versionRange.add(parseSinglePart(part));
|
||||||
|
}
|
||||||
|
return versionRange;
|
||||||
|
} else {
|
||||||
|
return parseSinglePart(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static VersionRange parseSinglePart(String part) {
|
||||||
|
if (part.startsWith("<= ")) return andOlder(ProtocolVersion.getClosest(part.substring(3)));
|
||||||
|
else if (part.startsWith(">= ")) return andNewer(ProtocolVersion.getClosest(part.substring(3)));
|
||||||
|
else if (part.contains(" - ")) {
|
||||||
|
String[] rangeParts = part.split(" - ");
|
||||||
|
ProtocolVersion min = ProtocolVersion.getClosest(rangeParts[0]);
|
||||||
|
ProtocolVersion max = ProtocolVersion.getClosest(rangeParts[1]);
|
||||||
|
return of(min, max);
|
||||||
|
} else return single(ProtocolVersion.getClosest(part));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user