mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-11-14 10:55:20 +01:00
Register tasks in the right place
This commit is contained in:
parent
0827b6f6bb
commit
2ce11704ba
@ -36,19 +36,13 @@ public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform {
|
|||||||
|
|
||||||
public BukkitPlugin() {
|
public BukkitPlugin() {
|
||||||
Via.getManager().addEnableListener(() -> init(new File(getDataFolder(), "config.yml")));
|
Via.getManager().addEnableListener(() -> init(new File(getDataFolder(), "config.yml")));
|
||||||
|
Via.getManager().addPostEnableListener(this::enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void enable() {
|
||||||
if (Via.getManager().getInjector().lateProtocolVersionSetting()) {
|
ViaBackwardsPlatform.super.enable();
|
||||||
// Enable in the next tick
|
|
||||||
Via.getPlatform().runSync(this::enable, 1);
|
|
||||||
} else {
|
|
||||||
enable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void enable() {
|
|
||||||
final ProtocolVersion protocolVersion = Via.getAPI().getServerVersion().highestSupportedProtocolVersion();
|
final ProtocolVersion protocolVersion = Via.getAPI().getServerVersion().highestSupportedProtocolVersion();
|
||||||
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_17)) {
|
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_17)) {
|
||||||
new PlayerItemDropListener(this).register();
|
new PlayerItemDropListener(this).register();
|
||||||
|
@ -55,6 +55,7 @@ import com.viaversion.viabackwards.protocol.v1_20_3to1_20_2.Protocol1_20_3To1_20
|
|||||||
import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.Protocol1_20_5To1_20_3;
|
import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.Protocol1_20_5To1_20_3;
|
||||||
import com.viaversion.viabackwards.protocol.v1_20_2to1_20.Protocol1_20_2To1_20;
|
import com.viaversion.viabackwards.protocol.v1_20_2to1_20.Protocol1_20_2To1_20;
|
||||||
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.Protocol1_21_2To1_21;
|
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.Protocol1_21_2To1_21;
|
||||||
|
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.task.PlayerPacketsTickTask;
|
||||||
import com.viaversion.viabackwards.protocol.v1_21to1_20_5.Protocol1_21To1_20_5;
|
import com.viaversion.viabackwards.protocol.v1_21to1_20_5.Protocol1_21To1_20_5;
|
||||||
import com.viaversion.viabackwards.protocol.v1_9_3to1_9_1.Protocol1_9_3To1_9_1;
|
import com.viaversion.viabackwards.protocol.v1_9_3to1_9_1.Protocol1_9_3To1_9_1;
|
||||||
import com.viaversion.viabackwards.protocol.v1_10to1_9_3.Protocol1_10To1_9_3;
|
import com.viaversion.viabackwards.protocol.v1_10to1_9_3.Protocol1_10To1_9_3;
|
||||||
@ -145,6 +146,13 @@ public interface ViaBackwardsPlatform {
|
|||||||
protocolManager.registerProtocol(new Protocol1_21_2To1_21(), ProtocolVersion.v1_21, ProtocolVersion.v1_21_2);
|
protocolManager.registerProtocol(new Protocol1_21_2To1_21(), ProtocolVersion.v1_21, ProtocolVersion.v1_21_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default void enable() {
|
||||||
|
final ProtocolVersion protocolVersion = Via.getAPI().getServerVersion().highestSupportedProtocolVersion();
|
||||||
|
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_21_2)) {
|
||||||
|
Via.getPlatform().runRepeatingSync(new PlayerPacketsTickTask(), 1L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logger provided by the platform.
|
* Logger provided by the platform.
|
||||||
*
|
*
|
||||||
|
@ -28,11 +28,8 @@ import com.viaversion.viabackwards.protocol.v1_21_2to1_21.storage.InventoryState
|
|||||||
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.storage.ItemTagStorage;
|
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.storage.ItemTagStorage;
|
||||||
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.storage.PlayerStorage;
|
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.storage.PlayerStorage;
|
||||||
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.storage.RecipeStorage;
|
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.storage.RecipeStorage;
|
||||||
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.task.PlayerPacketsTickTask;
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5;
|
||||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider;
|
import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider;
|
||||||
@ -149,11 +146,6 @@ public final class Protocol1_21_2To1_21 extends BackwardsProtocol<ClientboundPac
|
|||||||
wrapper.write(Types.VAR_INT, 0); // Particle status, assume 'all'
|
wrapper.write(Types.VAR_INT, 0); // Particle status, assume 'all'
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void register(final ViaProviders providers) {
|
|
||||||
Via.getPlatform().runRepeatingSync(new PlayerPacketsTickTask(), 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(final UserConnection user) {
|
public void init(final UserConnection user) {
|
||||||
addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_20_5.PLAYER));
|
addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_20_5.PLAYER));
|
||||||
|
@ -37,6 +37,7 @@ public final class PlayerPacketsTickTask implements Runnable {
|
|||||||
if (user.getProtocolInfo().getClientState() != State.PLAY || !user.getProtocolInfo().getPipeline().contains(Protocol1_21_2To1_21.class)) {
|
if (user.getProtocolInfo().getClientState() != State.PLAY || !user.getProtocolInfo().getPipeline().contains(Protocol1_21_2To1_21.class)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Channel channel = user.getChannel();
|
final Channel channel = user.getChannel();
|
||||||
channel.eventLoop().submit(() -> {
|
channel.eventLoop().submit(() -> {
|
||||||
if (!channel.isActive()) {
|
if (!channel.isActive()) {
|
||||||
|
@ -35,6 +35,7 @@ public class ViaFabricAddon implements ViaBackwardsPlatform, Runnable {
|
|||||||
Path configDirPath = FabricLoader.getInstance().getConfigDir().resolve("ViaBackwards");
|
Path configDirPath = FabricLoader.getInstance().getConfigDir().resolve("ViaBackwards");
|
||||||
configDir = configDirPath.toFile();
|
configDir = configDirPath.toFile();
|
||||||
this.init(new File(getDataFolder(), "config.yml"));
|
this.init(new File(getDataFolder(), "config.yml"));
|
||||||
|
this.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,6 +52,7 @@ public class VelocityPlugin implements ViaBackwardsPlatform {
|
|||||||
public void onProxyStart(ProxyInitializeEvent event) {
|
public void onProxyStart(ProxyInitializeEvent event) {
|
||||||
this.logger = new LoggerWrapper(loggerSlf4j);
|
this.logger = new LoggerWrapper(loggerSlf4j);
|
||||||
Via.getManager().addEnableListener(() -> this.init(new File(getDataFolder(), "config.yml")));
|
Via.getManager().addEnableListener(() -> this.init(new File(getDataFolder(), "config.yml")));
|
||||||
|
Via.getManager().addPostEnableListener(this::enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user