mirror of
https://github.com/ViaVersion/ViaForge.git
synced 2025-01-23 21:51:28 +01:00
Outsource providers
This commit is contained in:
parent
b5be55a0c8
commit
484c8ba9a8
@ -24,6 +24,7 @@ dependencies {
|
||||
include "com.viaversion:viaversion:${project.viaversion_version}"
|
||||
include "com.viaversion:viabackwards:${project.viabackwards_version}"
|
||||
include "com.viaversion:viarewind-universal:${project.viarewind_version}"
|
||||
|
||||
include "org.yaml:snakeyaml:${project.snake_yml_version}"
|
||||
|
||||
include "net.raphimc:ViaLoader:${project.vialoader_version}"
|
||||
|
@ -9,9 +9,11 @@ maven_group=de.florianmichael
|
||||
|
||||
# ViaVersion
|
||||
vialoader_version=2.2.11-SNAPSHOT
|
||||
|
||||
viaversion_version=4.9.0-23w42a-SNAPSHOT
|
||||
viabackwards_version=4.9.0-23w42a-SNAPSHOT
|
||||
viarewind_version=3.0.3-SNAPSHOT
|
||||
|
||||
snake_yml_version=2.2
|
||||
|
||||
# Misc Libraries
|
||||
|
@ -24,6 +24,6 @@ include "viaforge-mc117"
|
||||
include "viaforge-mc118"
|
||||
include "viaforge-mc119"
|
||||
include "viaforge-mc120"
|
||||
include 'viaforge-mc115'
|
||||
include 'viaforge-mc114'
|
||||
include "viaforge-mc115"
|
||||
include "viaforge-mc114"
|
||||
|
||||
|
@ -18,10 +18,9 @@
|
||||
package de.florianmichael.viaforge.common.protocolhack;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
||||
import com.viaversion.viaversion.protocols.base.BaseVersionProvider;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.protocolhack.provider.ViaForgeVersionProvider;
|
||||
import net.raphimc.vialoader.impl.viaversion.VLLoader;
|
||||
|
||||
public class ViaForgeVLLoader extends VLLoader {
|
||||
@ -30,15 +29,8 @@ public class ViaForgeVLLoader extends VLLoader {
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
Via.getManager().getProviders().use(VersionProvider.class, new BaseVersionProvider() {
|
||||
@Override
|
||||
public int getClosestServerProtocol(UserConnection connection) throws Exception {
|
||||
if (connection.isClientSide() && !ViaForgeCommon.getManager().getPlatform().isSingleplayer().get()) {
|
||||
return ViaForgeCommon.getManager().getTargetVersion().getVersion();
|
||||
}
|
||||
final ViaProviders providers = Via.getManager().getProviders();
|
||||
|
||||
return super.getClosestServerProtocol(connection);
|
||||
}
|
||||
});
|
||||
providers.use(VersionProvider.class, new ViaForgeVersionProvider());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge.common.protocolhack.provider;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.protocols.base.BaseVersionProvider;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
|
||||
public class ViaForgeVersionProvider extends BaseVersionProvider {
|
||||
|
||||
@Override
|
||||
public int getClosestServerProtocol(UserConnection connection) throws Exception {
|
||||
if (connection.isClientSide() && !ViaForgeCommon.getManager().getPlatform().isSingleplayer().get()) {
|
||||
return ViaForgeCommon.getManager().getTargetVersion().getVersion();
|
||||
}
|
||||
|
||||
return super.getClosestServerProtocol(connection);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user