Search in sources :

Example 1 with MappingData

use of com.viaversion.viaversion.api.data.MappingData in project Geyser by GeyserMC.

the class GeyserSpigotPlugin method isViaVersionNeeded.

/**
 * This function should not run unless ViaVersion is installed on the server.
 *
 * @return true if there is any block mappings difference between the server and client.
 */
private boolean isViaVersionNeeded() {
    ProtocolVersion serverVersion = getServerProtocolVersion();
    List<ProtocolPathEntry> protocolList = Via.getManager().getProtocolManager().getProtocolPath(MinecraftProtocol.getJavaProtocolVersion(), serverVersion.getVersion());
    if (protocolList == null) {
        // No translation needed!
        return false;
    }
    for (int i = protocolList.size() - 1; i >= 0; i--) {
        MappingData mappingData = protocolList.get(i).getProtocol().getMappingData();
        if (mappingData != null) {
            return true;
        }
    }
    // All mapping data is null, which means client and server block states are the same
    return false;
}
Also used : ProtocolPathEntry(com.viaversion.viaversion.api.protocol.ProtocolPathEntry) MappingData(com.viaversion.viaversion.api.data.MappingData) ProtocolVersion(com.viaversion.viaversion.api.protocol.version.ProtocolVersion)

Aggregations

MappingData (com.viaversion.viaversion.api.data.MappingData)1 ProtocolPathEntry (com.viaversion.viaversion.api.protocol.ProtocolPathEntry)1 ProtocolVersion (com.viaversion.viaversion.api.protocol.version.ProtocolVersion)1