Remove unused config option, hotfix mapping data cache

This commit is contained in:
Nassim Jahnke 2023-02-20 13:19:10 +01:00
parent 7b5cb92982
commit 1157029f23
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
13 changed files with 26 additions and 66 deletions

View File

@ -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
*

View File

@ -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<String, JsonObject> 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)) {

View File

@ -55,7 +55,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform<Player>
private final ViaAPI<Player> api = new BukkitViaAPI(this);
private final List<Runnable> queuedTasks = new ArrayList<>();
private final List<Runnable> 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<Player>
// 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<Player>
// 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<Player>
}
}
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<Player>
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<Player>
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;
}

View File

@ -27,7 +27,6 @@ import org.bukkit.plugin.Plugin;
public class BukkitViaConfig extends AbstractViaConfig {
private static final List<String> 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<String, Object> config) {
}
@Override
public boolean isAntiXRay() {
return antiXRay;
}
@Override
public boolean is1_12QuickMoveActionFix() {
return quickMoveActionFix;

View File

@ -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<Proxi
@Override
public void onEnable() {
if (ProxyServer.getInstance().getPluginManager().getPlugin("ViaBackwards") != null) {
MappingDataLoader.enableMappingsCache();
}
// Inject
((ViaManagerImpl) Via.getManager()).init();
}

View File

@ -28,7 +28,7 @@ import java.util.List;
import java.util.Map;
public class BungeeViaConfig extends AbstractViaConfig {
private static final List<String> 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<String> 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<String, Integer> bungeeServerProtocols;

View File

@ -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;

View File

@ -150,6 +150,11 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_3
});
registerMetaTypeHandler(Types1_19_4.META_TYPES.itemType, Types1_19_4.META_TYPES.blockStateType, Types1_19_4.META_TYPES.particleType);
filter().filterFamily(Entity1_19_4Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
final int blockState = meta.value();
meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState));
});
filter().filterFamily(Entity1_19_4Types.ABSTRACT_HORSE).removeIndex(18); // Owner UUID
}

View File

@ -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)

View File

@ -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<Player> {
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<Player> {
public void onServerStart(StartingEngineEvent<Server> 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();
}

View File

@ -24,7 +24,7 @@ import java.util.List;
import java.util.Map;
public class SpongeViaConfig extends AbstractViaConfig {
private static final List<String> UNSUPPORTED = Arrays.asList("anti-xray-patch", "bungee-ping-interval",
private static final List<String> 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");

View File

@ -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<Player> {
.commandHandler(commandHandler)
.loader(new VelocityViaLoader())
.injector(new VelocityViaInjector()).build());
if (proxy.getPluginManager().getPlugin("viabackwards").isPresent()) {
MappingDataLoader.enableMappingsCache();
}
}
@Subscribe(order = PostOrder.LAST)

View File

@ -27,7 +27,7 @@ import java.util.List;
import java.util.Map;
public class VelocityViaConfig extends AbstractViaConfig {
private static final List<String> 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<String> 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<String, Integer> velocityServerProtocols;