diff --git a/api/src/main/java/com/viaversion/viaversion/api/configuration/ViaVersionConfig.java b/api/src/main/java/com/viaversion/viaversion/api/configuration/ViaVersionConfig.java index bad8c22c2..fbb45f95d 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/configuration/ViaVersionConfig.java +++ b/api/src/main/java/com/viaversion/viaversion/api/configuration/ViaVersionConfig.java @@ -186,13 +186,6 @@ public interface ViaVersionConfig { */ String getMaxWarningsKickMessage(); - /** - * Is anti-xray enabled? - * - * @return A boolean - */ - boolean isAntiXRay(); - /** * Send supported versions in the status response packet * diff --git a/api/src/main/java/com/viaversion/viaversion/api/data/MappingDataLoader.java b/api/src/main/java/com/viaversion/viaversion/api/data/MappingDataLoader.java index 49e5876f8..454f3da79 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/data/MappingDataLoader.java +++ b/api/src/main/java/com/viaversion/viaversion/api/data/MappingDataLoader.java @@ -41,7 +41,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.checkerframework.checker.nullness.qual.Nullable; -public class MappingDataLoader { +public final class MappingDataLoader { private static final Map MAPPINGS_CACHE = new ConcurrentHashMap<>(); private static boolean cacheJsonMappings; @@ -77,7 +77,9 @@ public class MappingDataLoader { */ public static @Nullable JsonObject loadFromDataDir(String name) { File file = new File(Via.getPlatform().getDataFolder(), name); - if (!file.exists()) return loadData(name); + if (!file.exists()) { + return loadData(name); + } // Load the file from the platform's directory if present try (FileReader reader = new FileReader(file)) { diff --git a/bukkit/src/main/java/com/viaversion/viaversion/ViaVersionPlugin.java b/bukkit/src/main/java/com/viaversion/viaversion/ViaVersionPlugin.java index 3a2da22bb..db64e088f 100644 --- a/bukkit/src/main/java/com/viaversion/viaversion/ViaVersionPlugin.java +++ b/bukkit/src/main/java/com/viaversion/viaversion/ViaVersionPlugin.java @@ -55,7 +55,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform private final ViaAPI api = new BukkitViaAPI(this); private final List queuedTasks = new ArrayList<>(); private final List asyncQueuedTasks = new ArrayList<>(); - private final boolean protocolSupport; + private boolean protocolSupport; private boolean lateBind; public ViaVersionPlugin() { @@ -66,7 +66,6 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform // Init platform BukkitViaInjector injector = new BukkitViaInjector(); - Via.init(ViaManagerImpl.builder() .platform(this) .commandHandler(commandHandler) @@ -76,17 +75,16 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform // Config magic conf = new BukkitViaConfig(); - - // Check if we're using protocol support too - protocolSupport = Bukkit.getPluginManager().getPlugin("ProtocolSupport") != null; } @Override public void onLoad() { - if (getServer().getPluginManager().getPlugin("ViaBackwards") != null) { + if (hasPaperPluginLoader()) { + // Paper's plugin loader constructs plugin only once they're actually loaded and there's no place for VB to enable caching before the protocols are initialized MappingDataLoader.enableMappingsCache(); } + protocolSupport = Bukkit.getPluginManager().getPlugin("ProtocolSupport") != null; lateBind = !((BukkitViaInjector) Via.getManager().getInjector()).isBinded(); getLogger().info("ViaVersion " + getDescription().getVersion() + " is now loaded" + (lateBind ? ", waiting for boot. (late-bind)" : ", injecting!")); @@ -95,6 +93,15 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform } } + private boolean hasPaperPluginLoader() { + try { + Class.forName("io.papermc.paper.plugin.configuration.PluginMeta"); + return true; + } catch (final ClassNotFoundException e) { + return false; + } + } + @Override public void onEnable() { if (lateBind) { @@ -104,11 +111,6 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform getCommand("viaversion").setExecutor(commandHandler); getCommand("viaversion").setTabCompleter(commandHandler); - // Warn them if they have anti-xray on and they aren't using spigot - if (conf.isAntiXRay() && !isSpigot()) { - getLogger().info("You have anti-xray on in your config, since you're not using spigot it won't fix xray!"); - } - // Run queued tasks for (Runnable r : queuedTasks) { Bukkit.getScheduler().runTask(this, r); @@ -279,15 +281,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform return protocolSupport; } - private boolean isSpigot() { - try { - Class.forName("org.spigotmc.SpigotConfig"); - } catch (ClassNotFoundException e) { - return false; - } - return true; - } - + @Deprecated/*(forRemoval = true)*/ public static ViaVersionPlugin getInstance() { return instance; } diff --git a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/platform/BukkitViaConfig.java b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/platform/BukkitViaConfig.java index 0a68e22e6..439587e3c 100644 --- a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/platform/BukkitViaConfig.java +++ b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/platform/BukkitViaConfig.java @@ -27,7 +27,6 @@ import org.bukkit.plugin.Plugin; public class BukkitViaConfig extends AbstractViaConfig { private static final List UNSUPPORTED = Arrays.asList("bungee-ping-interval", "bungee-ping-save", "bungee-servers", "velocity-ping-interval", "velocity-ping-save", "velocity-servers"); - private boolean antiXRay; private boolean quickMoveActionFix; private boolean hitboxFix1_9; private boolean hitboxFix1_14; @@ -42,7 +41,6 @@ public class BukkitViaConfig extends AbstractViaConfig { @Override protected void loadFields() { super.loadFields(); - antiXRay = getBoolean("anti-xray-patch", true); quickMoveActionFix = getBoolean("quick-move-action-fix", false); hitboxFix1_9 = getBoolean("change-1_9-hitbox", false); hitboxFix1_14 = getBoolean("change-1_14-hitbox", false); @@ -54,11 +52,6 @@ public class BukkitViaConfig extends AbstractViaConfig { protected void handleConfig(Map config) { } - @Override - public boolean isAntiXRay() { - return antiXRay; - } - @Override public boolean is1_12QuickMoveActionFix() { return quickMoveActionFix; diff --git a/bungee/src/main/java/com/viaversion/viaversion/BungeePlugin.java b/bungee/src/main/java/com/viaversion/viaversion/BungeePlugin.java index 6c1005891..1a90ab2eb 100644 --- a/bungee/src/main/java/com/viaversion/viaversion/BungeePlugin.java +++ b/bungee/src/main/java/com/viaversion/viaversion/BungeePlugin.java @@ -23,7 +23,6 @@ import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.ViaAPI; import com.viaversion.viaversion.api.command.ViaCommandSender; import com.viaversion.viaversion.api.configuration.ConfigurationProvider; -import com.viaversion.viaversion.api.data.MappingDataLoader; import com.viaversion.viaversion.api.platform.PlatformTask; import com.viaversion.viaversion.api.platform.UnsupportedSoftware; import com.viaversion.viaversion.api.platform.ViaServerProxyPlatform; @@ -86,11 +85,6 @@ public class BungeePlugin extends Plugin implements ViaServerProxyPlatform UNSUPPORTED = Arrays.asList("nms-player-ticking", "item-cache", "anti-xray-patch", "quick-move-action-fix", "velocity-ping-interval", "velocity-ping-save", "velocity-servers", "blockconnection-method", "change-1_9-hitbox", "change-1_14-hitbox"); + private static final List UNSUPPORTED = Arrays.asList("nms-player-ticking", "item-cache", "quick-move-action-fix", "velocity-ping-interval", "velocity-ping-save", "velocity-servers", "blockconnection-method", "change-1_9-hitbox", "change-1_14-hitbox"); private int bungeePingInterval; private boolean bungeePingSave; private Map bungeeServerProtocols; diff --git a/common/src/main/java/com/viaversion/viaversion/configuration/AbstractViaConfig.java b/common/src/main/java/com/viaversion/viaversion/configuration/AbstractViaConfig.java index b32ea3272..623aa6934 100644 --- a/common/src/main/java/com/viaversion/viaversion/configuration/AbstractViaConfig.java +++ b/common/src/main/java/com/viaversion/viaversion/configuration/AbstractViaConfig.java @@ -332,11 +332,6 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf return maxPPSWarningsKickMessage; } - @Override - public boolean isAntiXRay() { - return false; - } - @Override public boolean isSendSupportedVersions() { return sendSupportedVersions; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_4to1_19_3/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_4to1_19_3/packets/EntityPackets.java index 21bd2ba01..5dd70dcba 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_4to1_19_3/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_4to1_19_3/packets/EntityPackets.java @@ -150,6 +150,11 @@ public final class EntityPackets extends EntityRewriter { + final int blockState = meta.value(); + meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState)); + }); + filter().filterFamily(Entity1_19_4Types.ABSTRACT_HORSE).removeIndex(18); // Owner UUID } diff --git a/common/src/main/resources/assets/viaversion/config.yml b/common/src/main/resources/assets/viaversion/config.yml index 69dbda161..90a5bed66 100644 --- a/common/src/main/resources/assets/viaversion/config.yml +++ b/common/src/main/resources/assets/viaversion/config.yml @@ -210,8 +210,6 @@ use-new-effect-indicator: true use-new-deathmessages: true # Should we cache our items, this will prevent server from being lagged out, however the cost is a constant task caching items item-cache: true -# Patch the anti xray to work on 1.9+ (If your server is 1.8) This can cost more performance, so disable it if you don't use it. -anti-xray-patch: true # Should we replace extended pistons to fix 1.10.1 (Only on chunk load) replace-pistons: false # What id should we replace with, default is air. (careful of players getting stuck standing on them) diff --git a/sponge/src/main/java/com/viaversion/viaversion/SpongePlugin.java b/sponge/src/main/java/com/viaversion/viaversion/SpongePlugin.java index 80de4c58c..91687eabc 100644 --- a/sponge/src/main/java/com/viaversion/viaversion/SpongePlugin.java +++ b/sponge/src/main/java/com/viaversion/viaversion/SpongePlugin.java @@ -22,7 +22,6 @@ import com.google.inject.Inject; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.command.ViaCommandSender; import com.viaversion.viaversion.api.configuration.ConfigurationProvider; -import com.viaversion.viaversion.api.data.MappingDataLoader; import com.viaversion.viaversion.api.platform.PlatformTask; import com.viaversion.viaversion.api.platform.ViaPlatform; import com.viaversion.viaversion.dump.PluginInfo; @@ -89,7 +88,6 @@ public class SpongePlugin implements ViaPlatform { public void constructPlugin(ConstructPluginEvent event) { // Setup Plugin conf = new SpongeViaConfig(configDir.toFile()); - logger.info("ViaVersion " + getPluginVersion() + " is now loaded!"); // Init platform Via.init(ViaManagerImpl.builder() @@ -104,13 +102,6 @@ public class SpongePlugin implements ViaPlatform { public void onServerStart(StartingEngineEvent event) { // Can't use the command register event for raw commands... Sponge.server().commandManager().registrar(Command.Raw.class).get().register(container, (Command.Raw) Via.getManager().getCommandHandler(), "viaversion", "viaver", "vvsponge"); - - if (game.pluginManager().plugin("viabackwards").isPresent()) { - MappingDataLoader.enableMappingsCache(); - } - - // Inject! - logger.info("ViaVersion is injecting!"); ((ViaManagerImpl) Via.getManager()).init(); } diff --git a/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaConfig.java b/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaConfig.java index f3e73c87f..c02ca6785 100644 --- a/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaConfig.java +++ b/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaConfig.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.Map; public class SpongeViaConfig extends AbstractViaConfig { - private static final List UNSUPPORTED = Arrays.asList("anti-xray-patch", "bungee-ping-interval", + private static final List UNSUPPORTED = Arrays.asList("bungee-ping-interval", "bungee-ping-save", "bungee-servers", "velocity-ping-interval", "velocity-ping-save", "velocity-servers", "quick-move-action-fix", "change-1_9-hitbox", "change-1_14-hitbox", "blockconnection-method"); diff --git a/velocity/src/main/java/com/viaversion/viaversion/VelocityPlugin.java b/velocity/src/main/java/com/viaversion/viaversion/VelocityPlugin.java index d82c1792e..d3d632e7e 100644 --- a/velocity/src/main/java/com/viaversion/viaversion/VelocityPlugin.java +++ b/velocity/src/main/java/com/viaversion/viaversion/VelocityPlugin.java @@ -30,7 +30,6 @@ import com.velocitypowered.api.proxy.ProxyServer; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.command.ViaCommandSender; import com.viaversion.viaversion.api.configuration.ConfigurationProvider; -import com.viaversion.viaversion.api.data.MappingDataLoader; import com.viaversion.viaversion.api.platform.PlatformTask; import com.viaversion.viaversion.api.platform.ViaServerProxyPlatform; import com.viaversion.viaversion.dump.PluginInfo; @@ -105,10 +104,6 @@ public class VelocityPlugin implements ViaServerProxyPlatform { .commandHandler(commandHandler) .loader(new VelocityViaLoader()) .injector(new VelocityViaInjector()).build()); - - if (proxy.getPluginManager().getPlugin("viabackwards").isPresent()) { - MappingDataLoader.enableMappingsCache(); - } } @Subscribe(order = PostOrder.LAST) diff --git a/velocity/src/main/java/com/viaversion/viaversion/velocity/platform/VelocityViaConfig.java b/velocity/src/main/java/com/viaversion/viaversion/velocity/platform/VelocityViaConfig.java index 51a3f1e4d..6426e6bf9 100644 --- a/velocity/src/main/java/com/viaversion/viaversion/velocity/platform/VelocityViaConfig.java +++ b/velocity/src/main/java/com/viaversion/viaversion/velocity/platform/VelocityViaConfig.java @@ -27,7 +27,7 @@ import java.util.List; import java.util.Map; public class VelocityViaConfig extends AbstractViaConfig { - private static final List UNSUPPORTED = Arrays.asList("nms-player-ticking", "item-cache", "anti-xray-patch", "quick-move-action-fix", "bungee-ping-interval", "bungee-ping-save", "bungee-servers", "blockconnection-method", "change-1_9-hitbox", "change-1_14-hitbox"); + private static final List UNSUPPORTED = Arrays.asList("nms-player-ticking", "item-cache", "quick-move-action-fix", "bungee-ping-interval", "bungee-ping-save", "bungee-servers", "blockconnection-method", "change-1_9-hitbox", "change-1_14-hitbox"); private int velocityPingInterval; private boolean velocityPingSave; private Map velocityServerProtocols;