From b06b9c69ca3bc7f0751d6bdc9c2ca72ab12a1100 Mon Sep 17 00:00:00 2001 From: KennyTV <28825609+KennyTV@users.noreply.github.com> Date: Wed, 22 Jan 2020 14:14:43 +0100 Subject: [PATCH 1/2] Do not unnecessarily register tasks/listeners --- .../bukkit/platform/BukkitViaLoader.java | 80 ++++++++++--------- bukkit/src/main/resources/plugin.yml | 1 + .../bungee/platform/BungeeViaLoader.java | 22 +++-- .../api/protocol/ProtocolRegistry.java | 2 +- .../sponge/platform/SpongeViaLoader.java | 60 ++++++++------ .../velocity/platform/VelocityViaLoader.java | 11 ++- 6 files changed, 103 insertions(+), 73 deletions(-) diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java index 0b2c1902c..8b0ef97a8 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java @@ -76,10 +76,11 @@ public class BukkitViaLoader implements ViaPlatformLoader { }); /* 1.9 client to 1.8 server */ - - storeListener(new ArmorListener(plugin)).register(); - storeListener(new DeathListener(plugin)).register(); - storeListener(new BlockListener(plugin)).register(); + if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId()) { + storeListener(new ArmorListener(plugin)).register(); + storeListener(new DeathListener(plugin)).register(); + storeListener(new BlockListener(plugin)).register(); + } if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_14.getId()) { boolean use1_9Fix = plugin.getConf().is1_9HitboxFix() && ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId(); @@ -106,42 +107,49 @@ public class BukkitViaLoader implements ViaPlatformLoader { } /* Providers */ - Via.getManager().getProviders().use(BulkChunkTranslatorProvider.class, new BukkitViaBulkChunkTranslator()); - Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BukkitViaMovementTransmitter()); - if (plugin.getConf().is1_12QuickMoveActionFix()) { - Via.getManager().getProviders().use(InventoryQuickMoveProvider.class, new BukkitInventoryQuickMoveProvider()); - } - if (Via.getConfig().getBlockConnectionMethod().equalsIgnoreCase("world")) { - Via.getManager().getProviders().use(BlockConnectionProvider.class, new BukkitBlockConnectionProvider()); - } - Via.getManager().getProviders().use(HandItemProvider.class, new HandItemProvider() { - @Override - public Item getHandItem(final UserConnection info) { - if (handItemCache != null) { - return handItemCache.getHandItem(info.get(ProtocolInfo.class).getUuid()); - } else { - try { - return Bukkit.getScheduler().callSyncMethod(Bukkit.getPluginManager().getPlugin("ViaVersion"), new Callable() { - @Override - public Item call() throws Exception { - UUID playerUUID = info.get(ProtocolInfo.class).getUuid(); - Player player = Bukkit.getPlayer(playerUUID); - if (player != null) { - return HandItemCache.convert(player.getItemInHand()); + if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId()) { + Via.getManager().getProviders().use(BulkChunkTranslatorProvider.class, new BukkitViaBulkChunkTranslator()); + Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BukkitViaMovementTransmitter()); + + Via.getManager().getProviders().use(HandItemProvider.class, new HandItemProvider() { + @Override + public Item getHandItem(final UserConnection info) { + if (handItemCache != null) { + return handItemCache.getHandItem(info.get(ProtocolInfo.class).getUuid()); + } else { + try { + return Bukkit.getScheduler().callSyncMethod(Bukkit.getPluginManager().getPlugin("ViaVersion"), new Callable() { + @Override + public Item call() throws Exception { + UUID playerUUID = info.get(ProtocolInfo.class).getUuid(); + Player player = Bukkit.getPlayer(playerUUID); + if (player != null) { + return HandItemCache.convert(player.getItemInHand()); + } + return null; } - return null; - } - }).get(10, TimeUnit.SECONDS); - } catch (Exception e) { - Via.getPlatform().getLogger().severe("Error fetching hand item: " + e.getClass().getName()); - if (Via.getManager().isDebug()) - e.printStackTrace(); - return null; + }).get(10, TimeUnit.SECONDS); + } catch (Exception e) { + Via.getPlatform().getLogger().severe("Error fetching hand item: " + e.getClass().getName()); + if (Via.getManager().isDebug()) + e.printStackTrace(); + return null; + } } } - } - }); + }); + } + if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_12.getId()) { + if (plugin.getConf().is1_12QuickMoveActionFix()) { + Via.getManager().getProviders().use(InventoryQuickMoveProvider.class, new BukkitInventoryQuickMoveProvider()); + } + } + if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_13.getId()) { + if (Via.getConfig().getBlockConnectionMethod().equalsIgnoreCase("world")) { + Via.getManager().getProviders().use(BlockConnectionProvider.class, new BukkitBlockConnectionProvider()); + } + } } @Override diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index c02b3a044..8aa3d4646 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -4,6 +4,7 @@ authors: [_MylesC, creeper123123321, Gerrygames, KennyTV, Matsv] version: ${project.version} description: ${project.description} load: postworld +api-version: 1.13 loadbefore: [ProtocolLib, ProxyPipe, SpigotLib, SkinRestorer] softdepend: [ProtocolSupport, PacketListenerApi] commands: diff --git a/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeViaLoader.java b/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeViaLoader.java index 1e0ffa437..9b6d5075f 100644 --- a/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeViaLoader.java +++ b/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeViaLoader.java @@ -6,6 +6,8 @@ import net.md_5.bungee.api.scheduler.ScheduledTask; import us.myles.ViaVersion.BungeePlugin; import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.platform.ViaPlatformLoader; +import us.myles.ViaVersion.api.protocol.ProtocolRegistry; +import us.myles.ViaVersion.api.protocol.ProtocolVersion; import us.myles.ViaVersion.bungee.handlers.BungeeServerHandler; import us.myles.ViaVersion.bungee.listeners.ElytraPatch; import us.myles.ViaVersion.bungee.listeners.UpdateListener; @@ -22,10 +24,10 @@ import java.util.Set; import java.util.concurrent.TimeUnit; public class BungeeViaLoader implements ViaPlatformLoader { - private BungeePlugin plugin; + private final BungeePlugin plugin; - private Set listeners = new HashSet<>(); - private Set tasks = new HashSet<>(); + private final Set listeners = new HashSet<>(); + private final Set tasks = new HashSet<>(); public BungeeViaLoader(BungeePlugin plugin) { this.plugin = plugin; @@ -42,14 +44,20 @@ public class BungeeViaLoader implements ViaPlatformLoader { registerListener(plugin); registerListener(new UpdateListener()); registerListener(new BungeeServerHandler()); - registerListener(new ElytraPatch()); + + if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId()) { + registerListener(new ElytraPatch()); + } // Providers - Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter()); Via.getManager().getProviders().use(VersionProvider.class, new BungeeVersionProvider()); Via.getManager().getProviders().use(EntityIdProvider.class, new BungeeEntityIdProvider()); - Via.getManager().getProviders().use(BossBarProvider.class, new BungeeBossBarProvider()); - Via.getManager().getProviders().use(MainHandProvider.class, new BungeeMainHandProvider()); + + if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId()) { + Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter()); + Via.getManager().getProviders().use(BossBarProvider.class, new BungeeBossBarProvider()); + Via.getManager().getProviders().use(MainHandProvider.class, new BungeeMainHandProvider()); + } if (plugin.getConf().getBungeePingInterval() > 0) { tasks.add(plugin.getProxy().getScheduler().schedule( diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java index 553cb11d0..4869f9e5c 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java @@ -104,7 +104,7 @@ public class ProtocolRegistry { for (Integer version : supported) { if (!registryMap.containsKey(version)) { - registryMap.put(version, new HashMap()); + registryMap.put(version, new HashMap<>()); } registryMap.get(version).put(output, protocol); diff --git a/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeViaLoader.java b/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeViaLoader.java index 9ac1e3ea7..cc8ecfe1d 100644 --- a/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeViaLoader.java +++ b/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeViaLoader.java @@ -7,6 +7,8 @@ import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.platform.TaskId; import us.myles.ViaVersion.api.platform.ViaPlatformLoader; +import us.myles.ViaVersion.api.protocol.ProtocolRegistry; +import us.myles.ViaVersion.api.protocol.ProtocolVersion; import us.myles.ViaVersion.protocols.base.ProtocolInfo; import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.BulkChunkTranslatorProvider; import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.HandItemProvider; @@ -26,10 +28,10 @@ import java.util.Set; public class SpongeViaLoader implements ViaPlatformLoader { - private SpongePlugin plugin; + private final SpongePlugin plugin; - private Set listeners = new HashSet<>(); - private Set tasks = new HashSet<>(); + private final Set listeners = new HashSet<>(); + private final Set tasks = new HashSet<>(); public SpongeViaLoader(SpongePlugin plugin) { this.plugin = plugin; @@ -50,34 +52,40 @@ public class SpongeViaLoader implements ViaPlatformLoader { registerListener(new UpdateListener()); /* Base Protocol */ registerListener(new ClientLeaveListener()); - /* 1.9 client to 1.8 server */ - try { - Class.forName("org.spongepowered.api.event.entity.DisplaceEntityEvent"); - storeListener(new Sponge4ArmorListener()).register(); - } catch (ClassNotFoundException e) { - storeListener(new Sponge5ArmorListener(plugin)).register(); - } - storeListener(new DeathListener(plugin)).register(); - storeListener(new BlockListener(plugin)).register(); - if (plugin.getConf().isItemCache()) { - tasks.add(Via.getPlatform().runRepeatingSync(new HandItemCache(), 2L)); // Updates players items :) - HandItemCache.CACHE = true; + /* 1.9 client to 1.8 server */ + if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId()) { + try { + Class.forName("org.spongepowered.api.event.entity.DisplaceEntityEvent"); + storeListener(new Sponge4ArmorListener()).register(); + } catch (ClassNotFoundException e) { + storeListener(new Sponge5ArmorListener(plugin)).register(); + } + storeListener(new DeathListener(plugin)).register(); + storeListener(new BlockListener(plugin)).register(); + + if (plugin.getConf().isItemCache()) { + tasks.add(Via.getPlatform().runRepeatingSync(new HandItemCache(), 2L)); // Updates players items :) + HandItemCache.CACHE = true; + } } /* Providers */ - Via.getManager().getProviders().use(BulkChunkTranslatorProvider.class, new SpongeViaBulkChunkTranslator()); - Via.getManager().getProviders().use(MovementTransmitterProvider.class, new SpongeViaMovementTransmitter()); - Via.getManager().getProviders().use(HandItemProvider.class, new HandItemProvider() { - @Override - public Item getHandItem(final UserConnection info) { - if (HandItemCache.CACHE) { - return HandItemCache.getHandItem(info.get(ProtocolInfo.class).getUuid()); - } else { - return super.getHandItem(info); // TODO: On API Docs write about this + if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId()) { + Via.getManager().getProviders().use(BulkChunkTranslatorProvider.class, new SpongeViaBulkChunkTranslator()); + Via.getManager().getProviders().use(MovementTransmitterProvider.class, new SpongeViaMovementTransmitter()); + + Via.getManager().getProviders().use(HandItemProvider.class, new HandItemProvider() { + @Override + public Item getHandItem(final UserConnection info) { + if (HandItemCache.CACHE) { + return HandItemCache.getHandItem(info.get(ProtocolInfo.class).getUuid()); + } else { + return super.getHandItem(info); + } } - } - }); + }); + } } public void unload() { diff --git a/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityViaLoader.java b/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityViaLoader.java index dcf4dc96f..90f77e048 100644 --- a/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityViaLoader.java +++ b/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityViaLoader.java @@ -4,6 +4,8 @@ import com.velocitypowered.api.plugin.PluginContainer; import us.myles.ViaVersion.VelocityPlugin; import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.platform.ViaPlatformLoader; +import us.myles.ViaVersion.api.protocol.ProtocolRegistry; +import us.myles.ViaVersion.api.protocol.ProtocolVersion; import us.myles.ViaVersion.protocols.base.VersionProvider; import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.BossBarProvider; import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider; @@ -21,15 +23,18 @@ public class VelocityViaLoader implements ViaPlatformLoader { Object plugin = VelocityPlugin.PROXY.getPluginManager() .getPlugin("viaversion").flatMap(PluginContainer::getInstance).get(); - Via.getManager().getProviders().use(MovementTransmitterProvider.class, new VelocityMovementTransmitter()); - Via.getManager().getProviders().use(BossBarProvider.class, new VelocityBossBarProvider()); + if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId()) { + Via.getManager().getProviders().use(MovementTransmitterProvider.class, new VelocityMovementTransmitter()); + Via.getManager().getProviders().use(BossBarProvider.class, new VelocityBossBarProvider()); + VelocityPlugin.PROXY.getEventManager().register(plugin, new ElytraPatch()); + } + Via.getManager().getProviders().use(VersionProvider.class, new VelocityVersionProvider()); // We probably don't need a EntityIdProvider because velocity sends a Join packet on server change // We don't need main hand patch because Join Game packet makes client send hand data again VelocityPlugin.PROXY.getEventManager().register(plugin, new UpdateListener()); VelocityPlugin.PROXY.getEventManager().register(plugin, new VelocityServerHandler()); - VelocityPlugin.PROXY.getEventManager().register(plugin, new ElytraPatch()); int pingInterval = ((VelocityViaConfig) Via.getPlatform().getConf()).getVelocityPingInterval(); if (pingInterval > 0) { From 598b51a4bf0eb483576f3294e4042835fee2c3ad Mon Sep 17 00:00:00 2001 From: KennyTV <28825609+KennyTV@users.noreply.github.com> Date: Wed, 22 Jan 2020 14:55:39 +0100 Subject: [PATCH 2/2] Do not unnecessarily register tasks/listeners --- .../bukkit/platform/BukkitViaLoader.java | 42 +++++++++---------- .../java/us/myles/ViaVersion/ViaManager.java | 14 +++++++ .../api/platform/ViaPlatformLoader.java | 1 + .../ChatItemRewriter.java | 2 +- .../Protocol1_13To1_12_2.java | 3 -- .../storage/BlockConnectionStorage.java | 4 +- .../protocol1_9to1_8/Protocol1_9To1_8.java | 3 -- 7 files changed, 37 insertions(+), 32 deletions(-) diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java index 8b0ef97a8..bc036be75 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java @@ -33,7 +33,6 @@ import java.util.HashSet; import java.util.Locale; import java.util.Set; import java.util.UUID; -import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; public class BukkitViaLoader implements ViaPlatformLoader { @@ -80,6 +79,11 @@ public class BukkitViaLoader implements ViaPlatformLoader { storeListener(new ArmorListener(plugin)).register(); storeListener(new DeathListener(plugin)).register(); storeListener(new BlockListener(plugin)).register(); + + if (plugin.getConf().isItemCache()) { + handItemCache = new HandItemCache(); + tasks.add(handItemCache.runTaskTimerAsynchronously(plugin, 2L, 2L)); // Updates player's items :) + } } if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_14.getId()) { @@ -101,10 +105,6 @@ public class BukkitViaLoader implements ViaPlatformLoader { plugin.getLogger().info("Enabling Paper/TacoSpigot/Torch patch: Fixes block placement."); storeListener(new PaperPatch(plugin)).register(); } - if (plugin.getConf().isItemCache()) { - handItemCache = new HandItemCache(); - tasks.add(handItemCache.runTaskTimerAsynchronously(plugin, 2L, 2L)); // Updates player's items :) - } /* Providers */ if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId()) { @@ -116,25 +116,21 @@ public class BukkitViaLoader implements ViaPlatformLoader { public Item getHandItem(final UserConnection info) { if (handItemCache != null) { return handItemCache.getHandItem(info.get(ProtocolInfo.class).getUuid()); - } else { - try { - return Bukkit.getScheduler().callSyncMethod(Bukkit.getPluginManager().getPlugin("ViaVersion"), new Callable() { - @Override - public Item call() throws Exception { - UUID playerUUID = info.get(ProtocolInfo.class).getUuid(); - Player player = Bukkit.getPlayer(playerUUID); - if (player != null) { - return HandItemCache.convert(player.getItemInHand()); - } - return null; - } - }).get(10, TimeUnit.SECONDS); - } catch (Exception e) { - Via.getPlatform().getLogger().severe("Error fetching hand item: " + e.getClass().getName()); - if (Via.getManager().isDebug()) - e.printStackTrace(); + } + try { + return Bukkit.getScheduler().callSyncMethod(Bukkit.getPluginManager().getPlugin("ViaVersion"), () -> { + UUID playerUUID = info.get(ProtocolInfo.class).getUuid(); + Player player = Bukkit.getPlayer(playerUUID); + if (player != null) { + return HandItemCache.convert(player.getItemInHand()); + } return null; - } + }).get(10, TimeUnit.SECONDS); + } catch (Exception e) { + Via.getPlatform().getLogger().severe("Error fetching hand item: " + e.getClass().getName()); + if (Via.getManager().isDebug()) + e.printStackTrace(); + return null; } } }); diff --git a/common/src/main/java/us/myles/ViaVersion/ViaManager.java b/common/src/main/java/us/myles/ViaVersion/ViaManager.java index 25563b050..515c1920b 100644 --- a/common/src/main/java/us/myles/ViaVersion/ViaManager.java +++ b/common/src/main/java/us/myles/ViaVersion/ViaManager.java @@ -3,6 +3,7 @@ package us.myles.ViaVersion; import lombok.Builder; import lombok.Getter; import lombok.Setter; +import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.platform.ViaInjector; import us.myles.ViaVersion.api.platform.ViaPlatform; @@ -12,6 +13,8 @@ import us.myles.ViaVersion.api.protocol.ProtocolRegistry; import us.myles.ViaVersion.api.protocol.ProtocolVersion; import us.myles.ViaVersion.commands.ViaCommandHandler; import us.myles.ViaVersion.protocols.base.ProtocolInfo; +import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.TabCompleteThread; +import us.myles.ViaVersion.protocols.protocol1_9to1_8.ViaIdleThread; import us.myles.ViaVersion.update.UpdateUtil; import java.util.Map; @@ -83,6 +86,17 @@ public class ViaManager { // Load Platform loader.load(); + // Common tasks + if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId()) { + if (Via.getConfig().isSimulatePlayerTick()) { + Via.getPlatform().runRepeatingSync(new ViaIdleThread(), 1L); + } + } + if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_13.getId()) { + if (Via.getConfig().get1_13TabCompleteDelay() > 0) { + Via.getPlatform().runRepeatingSync(new TabCompleteThread(), 1L); + } + } // Refresh Versions ProtocolRegistry.refreshVersions(); diff --git a/common/src/main/java/us/myles/ViaVersion/api/platform/ViaPlatformLoader.java b/common/src/main/java/us/myles/ViaVersion/api/platform/ViaPlatformLoader.java index 68930aebc..360cdc097 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/platform/ViaPlatformLoader.java +++ b/common/src/main/java/us/myles/ViaVersion/api/platform/ViaPlatformLoader.java @@ -1,6 +1,7 @@ package us.myles.ViaVersion.api.platform; public interface ViaPlatformLoader { + /** * Initialise the loading for a platform, eg. registering listeners / providers / events etc. */ diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/ChatItemRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/ChatItemRewriter.java index 422976c97..3f3963ea1 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/ChatItemRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/ChatItemRewriter.java @@ -9,7 +9,7 @@ import us.myles.ViaVersion.api.data.UserConnection; import java.util.regex.Pattern; public class ChatItemRewriter { - private static Pattern indexRemoval = Pattern.compile("\\d+:(?=([^\"\\\\]*(\\\\.|\"([^\"\\\\]*\\\\.)*[^\"\\\\]*\"))*[^\"]*$)"); + private static final Pattern indexRemoval = Pattern.compile("\\d+:(?=([^\"\\\\]*(\\\\.|\"([^\"\\\\]*\\\\.)*[^\"\\\\]*\"))*[^\"]*$)"); // Taken from https://stackoverflow.com/questions/6462578/alternative-to-regex-match-all-instances-not-inside-quotes public static void toClient(JsonElement element, UserConnection user) { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java index e697f538c..974ee6fb4 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java @@ -1167,9 +1167,6 @@ public class Protocol1_13To1_12_2 extends Protocol { protected void register(ViaProviders providers) { providers.register(BlockEntityProvider.class, new BlockEntityProvider()); providers.register(PaintingProvider.class, new PaintingProvider()); - if (Via.getConfig().get1_13TabCompleteDelay() > 0) { - Via.getPlatform().runRepeatingSync(new TabCompleteThread(), 1L); - } } private int getNewSoundID(final int oldID) { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/storage/BlockConnectionStorage.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/storage/BlockConnectionStorage.java index 8845822f2..56ccd68fd 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/storage/BlockConnectionStorage.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/storage/BlockConnectionStorage.java @@ -15,10 +15,10 @@ import java.util.HashMap; import java.util.Map; public class BlockConnectionStorage extends StoredObject { - private Map> blockStorage = createLongObjectMap(); + private final Map> blockStorage = createLongObjectMap(); + private static final Map reverseBlockMappings; private static Constructor fastUtilLongObjectHashMap; - private static HashMap reverseBlockMappings; static { try { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/Protocol1_9To1_8.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/Protocol1_9To1_8.java index ac4cd7c77..0861ee7c1 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/Protocol1_9To1_8.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/Protocol1_9To1_8.java @@ -100,9 +100,6 @@ public class Protocol1_9To1_8 extends Protocol { providers.register(BossBarProvider.class, new BossBarProvider()); providers.register(MainHandProvider.class, new MainHandProvider()); providers.require(MovementTransmitterProvider.class); - if (Via.getConfig().isSimulatePlayerTick()) { - Via.getPlatform().runRepeatingSync(new ViaIdleThread(), 1L); - } } @Override