Skip to content

Commit 4271dd5

Browse files
Update documentation
1 parent b22184e commit 4271dd5

File tree

1 file changed

+8
-42
lines changed

1 file changed

+8
-42
lines changed

README.md

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -54,51 +54,17 @@ If you just want the latest jar file you can download it from [GitHub Actions](h
5454

5555
## Usage
5656
ViaLegacy requires you to have an already functional ViaVersion implementation for your platform.
57-
If you don't have one you can check out [ViaLoader](https://github.com/ViaVersion/ViaLoader) for an abstracted and simplified, but still customizable implementation.
58-
You can also go to the other [ViaVersion](https://github.com/ViaVersion) repositories and look at their server and proxy implementations.
57+
If you don't have one you can check out [this documentation](https://github.com/ViaVersion/ViaVersion/wiki/Creating-a-new-ViaVersion-platform) in order to create one.
5958

6059
### Base Implementation
61-
Note: In case you use [ViaLoader](https://github.com/ViaVersion/ViaLoader) you can skip "ViaLegacy platform implementation" and "Loading the platform" as ViaLoader already does that for you.
6260

63-
#### ViaLegacy platform implementation
64-
To get started you should create a class which implements the ViaLegacy platform interface.
61+
To implement ViaLegacy you need to create a new instance of its platform implementation class ``ViaLegacyPlatformImpl`` when ViaVersion is being enabled.
6562
Here is an example:
6663
```java
67-
public class ViaLegacyPlatformImpl implements ViaLegacyPlatform {
68-
69-
public ViaLegacyPlatformImpl() {
70-
this.init(this.getDataFolder());
71-
}
72-
73-
@Override
74-
public Logger getLogger() {
75-
return Via.getPlatform().getLogger();
76-
}
77-
78-
@Override
79-
public File getDataFolder() {
80-
return Via.getPlatform().getDataFolder();
81-
}
82-
83-
}
84-
```
85-
This is a very basic implementation which just uses the ViaVersion logger and data folder.
86-
87-
#### Loading the platform
88-
After you have created your platform implementation you should load it in your ViaVersion implementation.
89-
Here is an example:
90-
```java
91-
Via.getManager().addEnableListener(ViaLegacyPlatformImpl::new);
64+
new ViaLegacyPlatformImpl();
9265
```
93-
Make sure to add the enable listener before the Via manager is initialized (``((ViaManagerImpl) Via.getManager()).init();``).
66+
This should be done in your ``ViaManagerImpl.initAndLoad()`` method call as enable listener (or otherwise after the Via manager is initialized).
9467

95-
It is also highly recommended to increase the max protocol path size of ViaVersion. The default value is 50 which means there can't be more than 50 protocols in one pipeline. This can get exceeded by ViaLegacy.
96-
You can increase the path size by adding the following lines after the Via manager is initialized:
97-
```java
98-
Via.getManager().getProtocolManager().setMaxProtocolPathSize(Integer.MAX_VALUE); // Allow Integer.MAX_VALUE protocols in the pipeline
99-
Via.getManager().getProtocolManager().setMaxPathDeltaIncrease(-1); // Allow unlimited protocol path size increase
100-
((ProtocolManagerImpl) Via.getManager().getProtocolManager()).refreshVersions(); // Refresh the version paths
101-
```
10268
#### Implementing the netty changes
10369
ViaLegacy requires you to make some changes to your netty pipeline where ViaVersion is being added into the pipeline.
10470
ViaLegacy needs to have custom netty handlers in the pipeline which handle <= 1.6.4 connections. This is required due to the way how <= 1.6.4 (called pre-netty protocol) protocol differs.
@@ -107,13 +73,13 @@ To implement the changes you should add something similar to the following lines
10773
```java
10874
if (serverTargetVersion.olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) { // Only add those handlers if the server version is <= 1.6.4
10975
// You can either add a codec (if your pipeline is built for that)
110-
channel.pipeline().addBefore("length-codec", "vialegacy-pre-netty-length-codec", new PreNettyLengthCodec(user));
76+
channel.pipeline().addBefore("length-codec", PreNettyLengthCodec.NAME, new PreNettyLengthCodec(user));
11177
// or two seperate netty handlers
112-
// channel.pipeline().addBefore("length-decoder", "vialegacy-pre-netty-length-prepender", new PreNettyLengthPrepender(user));
113-
// channel.pipeline().addBefore("length-encoder", "vialegacy-pre-netty-length-remover", new PreNettyLengthRemover(user));
78+
// channel.pipeline().addBefore("length-decoder", PreNettyLengthPrepender.NAME, new PreNettyLengthPrepender(user));
79+
// channel.pipeline().addBefore("length-encoder", PreNettyLengthRemover.NAME, new PreNettyLengthRemover(user));
11480
}
11581
```
116-
In case you use [ViaLoader](https://github.com/ViaVersion/ViaLoader) and the [VLPipeline](https://github.com/ViaVersion/ViaLoader/blob/main/src/main/java/net/raphimc/vialoader/netty/VLPipeline.java) (or the [VLLegacyPipeline](https://github.com/ViaVersion/ViaLoader/blob/main/src/main/java/net/raphimc/vialoader/netty/VLLegacyPipeline.java)), you don't need to make these modifications anymore, as the VLPipeline/VLLegacyPipeline already does it automatically.
82+
11783
### Implementing the platform specific providers
11884
The platform specific providers are all optional (except for ``EncryptionProvider`` and ``GameProfileFetcher``) and only required if you want to use the features which require them.
11985
To implement a provider you can simply call ``Via.getManager().getProviders().use(TheNameOfTheProvider.class, new YouImplementationOfThatProvider());`` after the Via manager is initialized.

0 commit comments

Comments
 (0)