https://github.com/oczi/alfajor
ViaVersion hack to intercept protocol packet mappers
https://github.com/oczi/alfajor
minecraft viaversion
Last synced: 2 months ago
JSON representation
ViaVersion hack to intercept protocol packet mappers
- Host: GitHub
- URL: https://github.com/oczi/alfajor
- Owner: OcZi
- License: mit
- Created: 2022-10-17T19:52:29.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-11-10T19:22:01.000Z (over 2 years ago)
- Last Synced: 2023-07-14T07:37:43.560Z (almost 2 years ago)
- Topics: minecraft, viaversion
- Language: Java
- Homepage:
- Size: 94.7 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Alfajor
A ViaVersion hack library to intercept and override packet mappers of specific protocols.## Example code
```java
public class DemoBukkitPlugin extends JavaPlugin {@Override
public void onLoad() {
// Shortcut of Via.getManager().getProtocolManager().getProtocol();
Protocol1_9To1_8 proto = ViaAlfajor.getProtocol(Protocol1_9To1_8.class);
// Class to start the dirty tricks
ProtocolHandle handle = ProtocolHandle.wrap(protocol);
// Inject a PacketRemapper into spawn_mob remappers
// It wouldn't override any registered remapper
handle.injectClientbound(ClientboundPackets1_8.SPAWN_MOB,
remapper -> {
// Do whatever you want here
});// Inject a remapper for serverbound packets
handle.injectServerbound(ServerboundPackets1_9.VEHICLE_MOVE,
remapper -> {
//...
}
);// Inject a remapper overriding all the spawn_mob remappers.
handle.injectOverrideClientbound(ClientboundPackets1_8.SPAWN_MOB,
remapper -> {
// ...
});
}
}
```
**Note:**
- PacketRemapper needs to map their fields
- Be careful with adding remappers; fields and objects might already be consumed and will throw an exception
There is a [plugin example](https://github.com/OcZi/Alfajor/tree/master/plugin-example) of coloured beds for clients
that support it with a 1.8.8 server base.
## Dependency
### Maven:
```xml
unnamed-snapshots
https://repo.unnamed.team/repository/unnamed-snapshots/
me.oczi.alfajor
Alfajor-api
1.1-SNAPSHOT
compile```
### Gradle:
```groovy
repositories {
maven { url 'https://repo.unnamed.team/repository/unnamed-snapshots/' }
}compileOnly('me.oczi.alfajor:Alfajor-api:1.1-SNAPSHOT')
```## Build
The entire project is built with **JDK 8** using **ViaVersion 4.4.2** as the target.
The API is licensed under [The MIT License](LICENSE) and the plugin example is under [GPL v3 License](plugin-example/LICENSE).