A ViaVersion hack library to intercept and override packet mappers of specific protocols.
public class DemoBukkitPlugin extends JavaPlugin {
@Override
public void onLoad() {
// Shortcut of Via.getManager().getProtocolManager().getProtocol();
Protocol1_8To1_9 protocol = ViaAlfajor.getProtocol(Protocol1_8To1_9.class);
// Class to start the dirty tricks
ProtocolHandle<ClientboundPackets1_8, ServerboundPackets1_9> handle = ProtocolHandle.wrap(protocol);
// Append a PacketHandlers to the add_mob mapping
// It wouldn't override any registered handler, only run after it
handle.injectClientbound(ClientboundPackets1_8.ADD_MOB,
remapper -> {
// Do whatever you want here
});
// Append a handler for serverbound packets
handle.injectServerbound(ServerboundPackets1_9.MOVE_VEHICLE,
remapper -> {
//...
}
);
// Replace the whole add_mob handler chain.
handle.injectOverrideClientbound(ClientboundPackets1_8.ADD_MOB,
remapper -> {
// ...
});
}
}Note:
- The
remapperin every callback is aPacketHandlersinstance; use.map(...)/.handler(...)on it to build the field mapping, same as when writing a ViaVersionProtocolyourself - Be careful with adding handlers; fields and objects might already be consumed and will throw an exception
There is a plugin example of coloured beds for clients
that support it with a 1.8.8 server base.
<repositories>
<repository>
<id>unnamed-snapshots</id>
<url>https://repo.unnamed.team/repository/unnamed-snapshots/</url>
</repository>
</repositories>
<dependency>
<groupId>me.oczi.alfajor</groupId>
<artifactId>Alfajor-api</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>repositories {
maven { url 'https://repo.unnamed.team/repository/unnamed-snapshots/' }
}
compileOnly('me.oczi.alfajor:Alfajor-api:1.1-SNAPSHOT')The entire project is built with JDK 17 using ViaVersion 5.11.0 as the target.
The API is licensed under The MIT License and the plugin example is under GPL v3 License.
