Skip to content

Instantly share code, notes, and snippets.

@kennytv
Last active June 8, 2021 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kennytv/3778685985ddc45bd99e003191ff02eb to your computer and use it in GitHub Desktop.
Save kennytv/3778685985ddc45bd99e003191ff02eb to your computer and use it in GitHub Desktop.
ViaVersion 4.0.0 update notes

In order to prepare for the next major ViaVersion update, you have to do the following things:

Update the dependency by changing

  • the group id to com.viaversion,
  • the version to 4.0.0,
  • the artifact id, depending on your needs, either to viaversion-api or viaversion.

Instead of reimporting or renaming each and every class used, it's easiest to just take a few minutes to do project wide replacements (e.g. Ctrl+Shift+R in IntelliJ).

Replace the base package: us.myles.ViaVersion -> com.viaversion.viaversion

From here, replace these amazing classes and packages:

  • com.viaversion.viaversion.api.protocol.ProtocolVersion -> com.viaversion.viaversion.api.protocol.version.ProtocolVersion
  • com.viaversion.viaversion.api.data.UserConnection -> com.viaversion.viaversion.api.connection.UserConnection
  • com.viaversion.viaversion.api.PacketWrapper -> com.viaversion.viaversion.api.protocol.packet.PacketWrapper
  • .get(ProtocolInfo.class) -> .getProtocolInfo()
  • new PacketWrapper( -> PacketWrapper.create(
  • com.viaversion.viaversion.api.protocol.ClientboundPacketType -> com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType
  • com.viaversion.viaversion.api.protocol.ServerboundPacketType -> com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType
  • com.viaversion.viaversion.packets. -> com.viaversion.viaversion.api.protocol.packet.
  • Calls to ProtocolVersion#getId() -> ProtocolVersion#getVersion()
  • Getting UserConnection instances: Via.getManager().getConnectionManager().getConnectedClient(UUID).
  • ProtocolRegistry.SERVER_PROTOCOL -> Via.getManager().getProtocolManager().getServerProtocolVersion().lowestSupportedVersion() (or the shortcut Via.getAPI().getServerVersion().lowestSupportedVersion())
  • Other methods from ProtocolRegistry -> Identical methods under Via.getManager().getProtocolManager()
  • Any ValueCreator instance creation and its write(PacketWrapper) method -> the usual PacketHandler and handle(PacketWrapper)

More internal classes/packages:

  • If you use the send or sendToServer methods in UserConnection, you have to update their usages (see their javadocs for more detail)
  • extends SimpleProtocol -> extends AbstractSimpleProtocol
  • extends Protocol -> extends AbstractProtocol (except for wilcard cases like List<? extends Protocol>)
  • General terminology: "outgoing" -> "clientbound", "incoming" -> "serverbound"
    • registerIncoming( -> registerServerbound(
    • registerOutgoing( -> registerClientbound(
    • cancelIncoming( -> cancelServerbound(
    • cancelOutgoing( -> cancelClientbound(
    • Direction.INCOMING -> Direction.SERVERBOUND
    • Direction.OUTGOING -> Direction.CLIENTBOUND
  • com.viaversion.viaversion.api.rewriters. -> com.viaversion.viaversion.rewriter.
  • com.viaversion.viaversion.api.remapper. -> com.viaversion.viaversion.api.protocol.remapper.
  • com.viaversion.viaversion.api.data.StoredObject -> com.viaversion.viaversion.api.connection.StoredObject
  • com.viaversion.viaversion.api.entities. -> com.viaversion.viaversion.api.minecraft.entities.
  • com.viaversion.viaversion.api.Pair -> com.viaversion.viaversion.util.Pair
  • new UserConnection( -> new UserConnectionImpl(
  • new ProtocolPipeline( -> new ProtocolPipelineImpl(
  • GsonUtil.getJsonParser().parse( -> JsonParser.parseString(
  • TaskId -> PlatformTask (make sure you don't accidentally replace something else with this)
  • Renames in Item: getAmount() -> amount(), getData() -> data(), getTag() -> tag(), and new Item( -> new DataItem(

To preserve compatibility with old plugins only using basic API, we have kept the following classes in a legacy api module under the old packages: Via, ViaAPI, ProtocolRegistry, ProtocolVersion, and Bossbar classes.

If you need to, a plain and simple approach to checking for 4.0.0+ versions before calling Via API would be a class check: Class.forName("com.viaversion.viaversion.api.ViaManager").

Via.getAPI().apiVersion() has been added and provides an integer you can check against in case future breakage happens.

Make sure you do not call the deprecated legacy api classes we kept unter us.myles.ViaVersion
Make sure you do not use the Bukkit platform's ViaVersionPlugin to get the general API; instead, use Via

If you have any other questions, feel free to ask in the support channel on our Discord. :)

@kolakz
Copy link

kolakz commented Jun 8, 2021

Thanks for the detailed guide!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment