3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 00:00:28 +01:00

Merge pull request #1339 from KennyTV/abstraction

Remove duplicated code in configs and EntityType
Dieser Commit ist enthalten in:
Myles 2019-05-21 17:49:53 +01:00 committet von GitHub
Commit b0fc69c308
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
28 geänderte Dateien mit 459 neuen und 1257 gelöschten Zeilen

Datei anzeigen

@ -1,9 +1,8 @@
package us.myles.ViaVersion.bukkit.platform; package us.myles.ViaVersion.bukkit.platform;
import us.myles.ViaVersion.AbstractViaConfig;
import us.myles.ViaVersion.ViaVersionPlugin; import us.myles.ViaVersion.ViaVersionPlugin;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.ViaVersionConfig;
import us.myles.ViaVersion.util.Config;
import java.io.File; import java.io.File;
import java.net.URL; import java.net.URL;
@ -11,8 +10,8 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class BukkitViaConfig extends Config implements ViaVersionConfig { public class BukkitViaConfig extends AbstractViaConfig {
private static List<String> UNSUPPORTED = Arrays.asList("bungee-ping-interval", "bungee-ping-save", "bungee-servers", "velocity-ping-interval", "velocity-ping-save", "velocity-servers"); private static final List<String> UNSUPPORTED = Arrays.asList("bungee-ping-interval", "bungee-ping-save", "bungee-servers", "velocity-ping-interval", "velocity-ping-save", "velocity-servers");
public BukkitViaConfig() { public BukkitViaConfig() {
super(new File(((ViaVersionPlugin) Via.getPlatform()).getDataFolder(), "config.yml")); super(new File(((ViaVersionPlugin) Via.getPlatform()).getDataFolder(), "config.yml"));
@ -20,176 +19,6 @@ public class BukkitViaConfig extends Config implements ViaVersionConfig {
reloadConfig(); reloadConfig();
} }
@Override
public boolean isCheckForUpdates() {
return getBoolean("checkforupdates", true);
}
@Override
public boolean isPreventCollision() {
return getBoolean("prevent-collision", true);
}
@Override
public boolean isNewEffectIndicator() {
return getBoolean("use-new-effect-indicator", true);
}
@Override
public boolean isShowNewDeathMessages() {
return getBoolean("use-new-deathmessages", true);
}
@Override
public boolean isSuppressMetadataErrors() {
return getBoolean("suppress-metadata-errors", false);
}
@Override
public boolean isShieldBlocking() {
return getBoolean("shield-blocking", true);
}
@Override
public boolean isHologramPatch() {
return getBoolean("hologram-patch", false);
}
@Override
public boolean isPistonAnimationPatch() {
return getBoolean("piston-animation-patch", false);
}
@Override
public boolean isBossbarPatch() {
return getBoolean("bossbar-patch", true);
}
@Override
public boolean isBossbarAntiflicker() {
return getBoolean("bossbar-anti-flicker", false);
}
@Override
public boolean isUnknownEntitiesSuppressed() {
return false;
}
@Override
public double getHologramYOffset() {
return getDouble("hologram-y", -0.96D);
}
@Override
public boolean isBlockBreakPatch() {
return false;
}
@Override
public int getMaxPPS() {
return getInt("max-pps", 800);
}
@Override
public String getMaxPPSKickMessage() {
return getString("max-pps-kick-msg", "Sending packets too fast? lag?");
}
@Override
public int getTrackingPeriod() {
return getInt("tracking-period", 6);
}
@Override
public int getWarningPPS() {
return getInt("tracking-warning-pps", 120);
}
@Override
public int getMaxWarnings() {
return getInt("tracking-max-warnings", 3);
}
@Override
public String getMaxWarningsKickMessage() {
return getString("tracking-max-kick-msg", "You are sending too many packets, :(");
}
@Override
public boolean isAntiXRay() {
return getBoolean("anti-xray-patch", true);
}
@Override
public boolean isSendSupportedVersions() {
return getBoolean("send-supported-versions", false);
}
@Override
public boolean isStimulatePlayerTick() {
return getBoolean("simulate-pt", true);
}
@Override
public boolean isItemCache() {
return getBoolean("item-cache", true);
}
@Override
public boolean isNMSPlayerTicking() {
return getBoolean("nms-player-ticking", true);
}
@Override
public boolean isReplacePistons() {
return getBoolean("replace-pistons", false);
}
@Override
public int getPistonReplacementId() {
return getInt("replacement-piston-id", 0);
}
public boolean isAutoTeam() {
// Collision has to be enabled first
return isPreventCollision() && getBoolean("auto-team", true);
}
@Override
public boolean isForceJsonTransform() {
return getBoolean("force-json-transform", false);
}
@Override
public boolean is1_12NBTArrayFix() {
return getBoolean("chat-nbt-fix", true);
}
@Override
public boolean is1_12QuickMoveActionFix() {
return getBoolean("quick-move-action-fix", false);
}
@Override
public List<Integer> getBlockedProtocols() {
return getIntegerList("block-protocols");
}
@Override
public String getBlockedDisconnectMsg() {
return getString("block-disconnect-msg", "You are using an unsupported Minecraft version!");
}
@Override
public String getReloadDisconnectMsg() {
return getString("reload-disconnect-msg", "Server reload, please rejoin!");
}
@Override
public boolean isMinimizeCooldown() {
return getBoolean("minimize-cooldown", true);
}
@Override @Override
public URL getDefaultConfigURL() { public URL getDefaultConfigURL() {
return BukkitViaConfig.class.getClassLoader().getResource("assets/viaversion/config.yml"); return BukkitViaConfig.class.getClassLoader().getResource("assets/viaversion/config.yml");
@ -197,76 +26,10 @@ public class BukkitViaConfig extends Config implements ViaVersionConfig {
@Override @Override
protected void handleConfig(Map<String, Object> config) { protected void handleConfig(Map<String, Object> config) {
// Nothing currently
} }
@Override @Override
public List<String> getUnsupportedOptions() { public List<String> getUnsupportedOptions() {
return UNSUPPORTED; return UNSUPPORTED;
} }
@Override
public boolean is1_13TeamColourFix() {
return getBoolean("team-colour-fix", true);
}
@Override
public boolean isSuppress1_13ConversionErrors() {
return getBoolean("suppress-1_13-conversion-errors", false);
}
@Override
public boolean isDisable1_13AutoComplete() {
return getBoolean("disable-1_13-auto-complete", false);
}
@Override
public boolean isServersideBlockConnections() {
return getBoolean("serverside-blockconnections", false);
}
@Override
public String getBlockConnectionMethod() {
return getString("blockconnection-method", "packet");
}
@Override
public boolean isReduceBlockStorageMemory() {
return getBoolean("reduce-blockstorage-memory", false);
}
@Override
public boolean isStemWhenBlockAbove() {
return getBoolean("flowerstem-when-block-above", false);
}
@Override
public boolean isSnowCollisionFix() {
return getBoolean("fix-low-snow-collision", false);
}
@Override
public int get1_13TabCompleteDelay() {
return getInt("1_13-tab-complete-delay", 0);
}
@Override
public boolean isTruncate1_14Books() {
return getBoolean("truncate-1_14-books", false);
}
@Override
public boolean isLeftHandedHandling() {
return getBoolean("left-handed-handling", true);
}
@Override
public boolean is1_9HitboxFix() {
return getBoolean("change-1_9-hitbox", false);
}
@Override
public boolean is1_14HitboxFix() {
return getBoolean("change-1_14-hitbox", false);
}
} }

Datei anzeigen

@ -11,11 +11,6 @@
<artifactId>viaversion-bungee</artifactId> <artifactId>viaversion-bungee</artifactId>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build> <build>
<resources> <resources>
<resource> <resource>

Datei anzeigen

@ -1,16 +1,15 @@
package us.myles.ViaVersion.bungee.platform; package us.myles.ViaVersion.bungee.platform;
import us.myles.ViaVersion.api.ViaVersionConfig; import us.myles.ViaVersion.AbstractViaConfig;
import us.myles.ViaVersion.api.protocol.ProtocolVersion; import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import us.myles.ViaVersion.bungee.providers.BungeeVersionProvider; import us.myles.ViaVersion.bungee.providers.BungeeVersionProvider;
import us.myles.ViaVersion.util.Config;
import java.io.File; import java.io.File;
import java.net.URL; import java.net.URL;
import java.util.*; import java.util.*;
public class BungeeViaConfig extends Config implements ViaVersionConfig { public class BungeeViaConfig extends AbstractViaConfig {
private static 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", "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");
public BungeeViaConfig(File configFile) { public BungeeViaConfig(File configFile) {
super(new File(configFile, "config.yml")); super(new File(configFile, "config.yml"));
@ -60,115 +59,11 @@ public class BungeeViaConfig extends Config implements ViaVersionConfig {
return UNSUPPORTED; return UNSUPPORTED;
} }
public boolean isCheckForUpdates() {
return getBoolean("checkforupdates", true);
}
@Override
public boolean isPreventCollision() {
return getBoolean("prevent-collision", true);
}
@Override
public boolean isNewEffectIndicator() {
return getBoolean("use-new-effect-indicator", true);
}
@Override
public boolean isShowNewDeathMessages() {
return getBoolean("use-new-deathmessages", true);
}
@Override
public boolean isSuppressMetadataErrors() {
return getBoolean("suppress-metadata-errors", false);
}
@Override
public boolean isShieldBlocking() {
return getBoolean("shield-blocking", true);
}
@Override
public boolean isHologramPatch() {
return getBoolean("hologram-patch", false);
}
@Override
public boolean isPistonAnimationPatch() {
return getBoolean("piston-animation-patch", false);
}
@Override
public boolean isBossbarPatch() {
return getBoolean("bossbar-patch", true);
}
@Override
public boolean isBossbarAntiflicker() {
return getBoolean("bossbar-anti-flicker", false);
}
@Override
public boolean isUnknownEntitiesSuppressed() {
return false;
}
@Override
public double getHologramYOffset() {
return getDouble("hologram-y", -0.96D);
}
@Override
public boolean isBlockBreakPatch() {
return false;
}
@Override
public int getMaxPPS() {
return getInt("max-pps", 800);
}
@Override
public String getMaxPPSKickMessage() {
return getString("max-pps-kick-msg", "Sending packets too fast? lag?");
}
@Override
public int getTrackingPeriod() {
return getInt("tracking-period", 6);
}
@Override
public int getWarningPPS() {
return getInt("tracking-warning-pps", 120);
}
@Override
public int getMaxWarnings() {
return getInt("tracking-max-warnings", 3);
}
@Override
public String getMaxWarningsKickMessage() {
return getString("tracking-max-kick-msg", "You are sending too many packets, :(");
}
@Override @Override
public boolean isAntiXRay() { public boolean isAntiXRay() {
return false; return false;
} }
@Override
public boolean isSendSupportedVersions() {
return getBoolean("send-supported-versions", false);
}
@Override
public boolean isStimulatePlayerTick() {
return getBoolean("simulate-pt", true);
}
@Override @Override
public boolean isItemCache() { public boolean isItemCache() {
return false; return false;
@ -179,54 +74,24 @@ public class BungeeViaConfig extends Config implements ViaVersionConfig {
return false; return false;
} }
@Override
public boolean isReplacePistons() {
return getBoolean("replace-pistons", false);
}
@Override
public int getPistonReplacementId() {
return getInt("replacement-piston-id", 0);
}
public boolean isAutoTeam() {
// Collision has to be enabled first
return isPreventCollision() && getBoolean("auto-team", true);
}
@Override
public boolean isForceJsonTransform() {
return getBoolean("force-json-transform", false);
}
@Override
public boolean is1_12NBTArrayFix() {
return getBoolean("chat-nbt-fix", true);
}
@Override @Override
public boolean is1_12QuickMoveActionFix() { public boolean is1_12QuickMoveActionFix() {
return false; return false;
} }
@Override @Override
public List<Integer> getBlockedProtocols() { public String getBlockConnectionMethod() {
return getIntegerList("block-protocols"); return "packet";
} }
@Override @Override
public String getBlockedDisconnectMsg() { public boolean is1_9HitboxFix() {
return getString("block-disconnect-msg", "You are using an unsupported Minecraft version!"); return false;
} }
@Override @Override
public String getReloadDisconnectMsg() { public boolean is1_14HitboxFix() {
return getString("reload-disconnect-msg", "Server reload, please rejoin!"); return false;
}
@Override
public boolean isMinimizeCooldown() {
return getBoolean("minimize-cooldown", true);
} }
/** /**
@ -257,69 +122,4 @@ public class BungeeViaConfig extends Config implements ViaVersionConfig {
public Map<String, Integer> getBungeeServerProtocols() { public Map<String, Integer> getBungeeServerProtocols() {
return get("bungee-servers", Map.class, new HashMap<>()); return get("bungee-servers", Map.class, new HashMap<>());
} }
@Override
public boolean is1_13TeamColourFix() {
return getBoolean("team-colour-fix", true);
}
@Override
public boolean isSuppress1_13ConversionErrors() {
return getBoolean("suppress-1_13-conversion-errors", false);
}
@Override
public boolean isDisable1_13AutoComplete() {
return getBoolean("disable-1_13-auto-complete", false);
}
@Override
public boolean isServersideBlockConnections() {
return getBoolean("serverside-blockconnections", false);
}
@Override
public String getBlockConnectionMethod() {
return "packet";
}
@Override
public boolean isReduceBlockStorageMemory() {
return getBoolean("reduce-blockstorage-memory", false);
}
@Override
public boolean isStemWhenBlockAbove() {
return getBoolean("flowerstem-when-block-above", false);
}
@Override
public boolean isSnowCollisionFix() {
return getBoolean("fix-low-snow-collision", false);
}
@Override
public int get1_13TabCompleteDelay() {
return getInt("1_13-tab-complete-delay", 0);
}
@Override
public boolean isTruncate1_14Books() {
return getBoolean("truncate-1_14-books", false);
}
@Override
public boolean isLeftHandedHandling() {
return getBoolean("left-handed-handling", true);
}
@Override
public boolean is1_9HitboxFix() {
return false;
}
@Override
public boolean is1_14HitboxFix() {
return false;
}
} }

Datei anzeigen

@ -0,0 +1,240 @@
package us.myles.ViaVersion;
import us.myles.ViaVersion.api.ViaVersionConfig;
import us.myles.ViaVersion.util.Config;
import java.io.File;
import java.util.List;
public abstract class AbstractViaConfig extends Config implements ViaVersionConfig {
public AbstractViaConfig(File configFile) {
super(configFile);
}
@Override
public boolean isCheckForUpdates() {
return getBoolean("checkforupdates", true);
}
@Override
public boolean isPreventCollision() {
return getBoolean("prevent-collision", true);
}
@Override
public boolean isNewEffectIndicator() {
return getBoolean("use-new-effect-indicator", true);
}
@Override
public boolean isShowNewDeathMessages() {
return getBoolean("use-new-deathmessages", true);
}
@Override
public boolean isSuppressMetadataErrors() {
return getBoolean("suppress-metadata-errors", false);
}
@Override
public boolean isShieldBlocking() {
return getBoolean("shield-blocking", true);
}
@Override
public boolean isHologramPatch() {
return getBoolean("hologram-patch", false);
}
@Override
public boolean isPistonAnimationPatch() {
return getBoolean("piston-animation-patch", false);
}
@Override
public boolean isBossbarPatch() {
return getBoolean("bossbar-patch", true);
}
@Override
public boolean isBossbarAntiflicker() {
return getBoolean("bossbar-anti-flicker", false);
}
@Override
public double getHologramYOffset() {
return getDouble("hologram-y", -0.96D);
}
@Override
public int getMaxPPS() {
return getInt("max-pps", 800);
}
@Override
public String getMaxPPSKickMessage() {
return getString("max-pps-kick-msg", "Sending packets too fast? lag?");
}
@Override
public int getTrackingPeriod() {
return getInt("tracking-period", 6);
}
@Override
public int getWarningPPS() {
return getInt("tracking-warning-pps", 120);
}
@Override
public int getMaxWarnings() {
return getInt("tracking-max-warnings", 3);
}
@Override
public String getMaxWarningsKickMessage() {
return getString("tracking-max-kick-msg", "You are sending too many packets, :(");
}
@Override
public boolean isAntiXRay() {
return getBoolean("anti-xray-patch", true);
}
@Override
public boolean isSendSupportedVersions() {
return getBoolean("send-supported-versions", false);
}
@Override
public boolean isStimulatePlayerTick() {
return getBoolean("simulate-pt", true);
}
@Override
public boolean isItemCache() {
return getBoolean("item-cache", true);
}
@Override
public boolean isNMSPlayerTicking() {
return getBoolean("nms-player-ticking", true);
}
@Override
public boolean isReplacePistons() {
return getBoolean("replace-pistons", false);
}
@Override
public int getPistonReplacementId() {
return getInt("replacement-piston-id", 0);
}
@Override
public boolean isAutoTeam() {
// Collision has to be enabled first
return isPreventCollision() && getBoolean("auto-team", true);
}
@Override
public boolean isForceJsonTransform() {
return getBoolean("force-json-transform", false);
}
@Override
public boolean is1_12NBTArrayFix() {
return getBoolean("chat-nbt-fix", true);
}
@Override
public boolean is1_12QuickMoveActionFix() {
return getBoolean("quick-move-action-fix", false);
}
@Override
public List<Integer> getBlockedProtocols() {
return getIntegerList("block-protocols");
}
@Override
public String getBlockedDisconnectMsg() {
return getString("block-disconnect-msg", "You are using an unsupported Minecraft version!");
}
@Override
public String getReloadDisconnectMsg() {
return getString("reload-disconnect-msg", "Server reload, please rejoin!");
}
@Override
public boolean isMinimizeCooldown() {
return getBoolean("minimize-cooldown", true);
}
@Override
public boolean is1_13TeamColourFix() {
return getBoolean("team-colour-fix", true);
}
@Override
public boolean isSuppress1_13ConversionErrors() {
return getBoolean("suppress-1_13-conversion-errors", false);
}
@Override
public boolean isDisable1_13AutoComplete() {
return getBoolean("disable-1_13-auto-complete", false);
}
@Override
public boolean isServersideBlockConnections() {
return getBoolean("serverside-blockconnections", false);
}
@Override
public String getBlockConnectionMethod() {
return getString("blockconnection-method", "packet");
}
@Override
public boolean isReduceBlockStorageMemory() {
return getBoolean("reduce-blockstorage-memory", false);
}
@Override
public boolean isStemWhenBlockAbove() {
return getBoolean("flowerstem-when-block-above", false);
}
@Override
public boolean isSnowCollisionFix() {
return getBoolean("fix-low-snow-collision", false);
}
@Override
public int get1_13TabCompleteDelay() {
return getInt("1_13-tab-complete-delay", 0);
}
@Override
public boolean isTruncate1_14Books() {
return getBoolean("truncate-1_14-books", false);
}
@Override
public boolean isLeftHandedHandling() {
return getBoolean("left-handed-handling", true);
}
@Override
public boolean is1_9HitboxFix() {
return getBoolean("change-1_9-hitbox", false);
}
@Override
public boolean is1_14HitboxFix() {
return getBoolean("change-1_14-hitbox", false);
}
}

Datei anzeigen

@ -75,14 +75,6 @@ public interface ViaVersionConfig {
*/ */
boolean isBossbarAntiflicker(); boolean isBossbarAntiflicker();
/**
* Get if unknown entity errors will be suppressed
*
* @return true if boss bar patching is enabled
*/
@Deprecated
boolean isUnknownEntitiesSuppressed();
/** /**
* Get the vertical offset armor stands are being moved with when the hologram patch is enabled * Get the vertical offset armor stands are being moved with when the hologram patch is enabled
* *
@ -97,14 +89,6 @@ public interface ViaVersionConfig {
*/ */
boolean isAutoTeam(); boolean isAutoTeam();
/**
* Get if our block break patch is enabled to prevent weird ghost glitches.
*
* @return true if it is enabled.
*/
@Deprecated
boolean isBlockBreakPatch();
/** /**
* Get the maximum number of packets a client can send per second. * Get the maximum number of packets a client can send per second.
* *

Datei anzeigen

@ -0,0 +1,100 @@
package us.myles.ViaVersion.api.data;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.util.GsonUtil;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Map;
public class MappingDataLoader {
public static JsonObject loadData(String name) {
InputStream stream = MappingDataLoader.class.getClassLoader().getResourceAsStream("assets/viaversion/data/" + name);
InputStreamReader reader = new InputStreamReader(stream);
try {
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
} finally {
try {
reader.close();
} catch (IOException ignored) {
// Ignored
}
}
}
public static void mapIdentifiers(Map<Integer, Integer> output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
if (value == null) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
}
continue;
}
output.put(Integer.parseInt(entry.getKey()), Integer.parseInt(value.getKey()));
}
}
public static void mapIdentifiers(short[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
if (value == null) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
}
continue;
}
output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey());
}
}
public static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers) {
for (int i = 0; i < oldIdentifiers.size(); i++) {
JsonElement v = oldIdentifiers.get(i);
Integer index = findIndex(newIdentifiers, v.getAsString());
if (index == null) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + v + " :( ");
}
continue;
}
output[i] = index.shortValue();
}
}
public static void mapIdentifiers(byte[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
Map.Entry<String, JsonElement> value = MappingDataLoader.findValue(newIdentifiers, entry.getValue().getAsString());
if (value == null) {
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
continue;
}
output[Integer.parseInt(entry.getKey())] = Byte.parseByte(value.getKey());
}
}
public static Map.Entry<String, JsonElement> findValue(JsonObject object, String needle) {
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
String value = entry.getValue().getAsString();
if (value.equals(needle)) {
return entry;
}
}
return null;
}
public static Integer findIndex(JsonArray array, String value) {
for (int i = 0; i < array.size(); i++) {
JsonElement v = array.get(i);
if (v.getAsString().equals(value)) {
return i;
}
}
return null;
}
}

Datei anzeigen

@ -0,0 +1,6 @@
package us.myles.ViaVersion.api.data;
public interface Mappings {
int getNewId(int old);
}

Datei anzeigen

@ -10,6 +10,7 @@ import java.util.Map;
// 1.11 Entity / Object ids TODO maybe in the future instead of copying it, some api. // 1.11 Entity / Object ids TODO maybe in the future instead of copying it, some api.
public class Entity1_11Types { public class Entity1_11Types {
public static EntityType getTypeFromId(int typeID, boolean isObject) { public static EntityType getTypeFromId(int typeID, boolean isObject) {
Optional<EntityType> type; Optional<EntityType> type;
@ -164,30 +165,6 @@ public class Entity1_11Types {
return Optional.absent(); return Optional.absent();
return Optional.fromNullable(TYPES.get(id)); return Optional.fromNullable(TYPES.get(id));
} }
public boolean is(EntityType... types) {
for (EntityType type : types)
if (is(type))
return true;
return false;
}
public boolean is(EntityType type) {
return this == type;
}
public boolean isOrHasParent(EntityType type) {
EntityType parent = this;
do {
if (parent.equals(type))
return true;
parent = parent.getParent();
} while (parent != null);
return false;
}
} }
@AllArgsConstructor @AllArgsConstructor

Datei anzeigen

@ -20,6 +20,7 @@ import java.util.Map;
// 1.12 Entity / Object taken from https://github.com/Matsv/ViaBackwards/blob/master/core/src/main/java/nl/matsv/viabackwards/api/entities/types/EntityType1_12.java // 1.12 Entity / Object taken from https://github.com/Matsv/ViaBackwards/blob/master/core/src/main/java/nl/matsv/viabackwards/api/entities/types/EntityType1_12.java
public class Entity1_12Types { public class Entity1_12Types {
public static EntityType getTypeFromId(int typeID, boolean isObject) { public static EntityType getTypeFromId(int typeID, boolean isObject) {
Optional<EntityType> type; Optional<EntityType> type;
@ -177,30 +178,6 @@ public class Entity1_12Types {
return Optional.absent(); return Optional.absent();
return Optional.fromNullable(TYPES.get(id)); return Optional.fromNullable(TYPES.get(id));
} }
public boolean is(EntityType... types) {
for (EntityType type : types)
if (is(type))
return true;
return false;
}
public boolean is(EntityType type) {
return this == type;
}
public boolean isOrHasParent(EntityType type) {
EntityType parent = this;
do {
if (parent.equals(type))
return true;
parent = parent.getParent();
} while (parent != null);
return false;
}
} }
@AllArgsConstructor @AllArgsConstructor

Datei anzeigen

@ -8,9 +8,9 @@ import us.myles.ViaVersion.api.Via;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
// TODO auto generate 18w11a with PAaaS // TODO auto generate 18w11a with PAaaS
public class Entity1_13Types { public class Entity1_13Types {
public static EntityType getTypeFromId(int typeID, boolean isObject) { public static EntityType getTypeFromId(int typeID, boolean isObject) {
Optional<EntityType> type; Optional<EntityType> type;
@ -220,30 +220,6 @@ public class Entity1_13Types {
return Optional.absent(); return Optional.absent();
return Optional.fromNullable(TYPES.get(id)); return Optional.fromNullable(TYPES.get(id));
} }
public boolean is(EntityType... types) {
for (EntityType type : types)
if (is(type))
return true;
return false;
}
public boolean is(EntityType type) {
return this == type;
}
public boolean isOrHasParent(EntityType type) {
EntityType parent = this;
do {
if (parent.equals(type))
return true;
parent = parent.getParent();
} while (parent != null);
return false;
}
} }
@AllArgsConstructor @AllArgsConstructor

Datei anzeigen

@ -10,6 +10,7 @@ import java.util.Map;
public class Entity1_14Types { public class Entity1_14Types {
public static EntityType getTypeFromId(int typeID) { public static EntityType getTypeFromId(int typeID) {
Optional<EntityType> type = Entity1_14Types.EntityType.findById(typeID); Optional<EntityType> type = Entity1_14Types.EntityType.findById(typeID);
@ -220,29 +221,5 @@ public class Entity1_14Types {
return Optional.absent(); return Optional.absent();
return Optional.fromNullable(TYPES.get(id)); return Optional.fromNullable(TYPES.get(id));
} }
public boolean is(EntityType... types) {
for (EntityType type : types)
if (is(type))
return true;
return false;
}
public boolean is(EntityType type) {
return this == type;
}
public boolean isOrHasParent(EntityType type) {
EntityType parent = this;
do {
if (parent == type)
return true;
parent = parent.getParent();
} while (parent != null);
return false;
}
} }
} }

Datei anzeigen

@ -6,4 +6,27 @@ public interface EntityType {
EntityType getParent(); EntityType getParent();
default boolean is(EntityType... types) {
for (EntityType type : types)
if (is(type))
return true;
return false;
}
default boolean is(EntityType type) {
return this == type;
}
default boolean isOrHasParent(EntityType type) {
EntityType parent = this;
do {
if (parent.equals(type))
return true;
parent = parent.getParent();
} while (parent != null);
return false;
}
} }

Datei anzeigen

@ -1159,7 +1159,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
} }
private int getNewSoundID(final int oldID) { private int getNewSoundID(final int oldID) {
return MappingData.soundMappings.getNewSound(oldID); return MappingData.soundMappings.getNewId(oldID);
} }
// Based on method from https://github.com/Bukkit/Bukkit/blob/master/src/main/java/org/bukkit/ChatColor.java // Based on method from https://github.com/Bukkit/Bukkit/blob/master/src/main/java/org/bukkit/ChatColor.java

Datei anzeigen

@ -5,6 +5,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.MappingDataLoader;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord; import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
import us.myles.ViaVersion.api.minecraft.BlockFace; import us.myles.ViaVersion.api.minecraft.BlockFace;
@ -15,7 +16,6 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.BlockConnectionProvider; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.BlockConnectionProvider;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.PacketBlockConnectionProvider; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.PacketBlockConnectionProvider;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -198,7 +198,7 @@ public class ConnectionData {
public static void init() { public static void init() {
if (!Via.getConfig().isServersideBlockConnections()) return; if (!Via.getConfig().isServersideBlockConnections()) return;
Via.getPlatform().getLogger().info("Loading block connection mappings ..."); Via.getPlatform().getLogger().info("Loading block connection mappings ...");
JsonObject mapping1_13 = MappingData.loadData("mapping-1.13.json"); JsonObject mapping1_13 = MappingDataLoader.loadData("mapping-1.13.json");
JsonObject blocks1_13 = mapping1_13.getAsJsonObject("blocks"); JsonObject blocks1_13 = mapping1_13.getAsJsonObject("blocks");
for (Entry<String, JsonElement> blockState : blocks1_13.entrySet()) { for (Entry<String, JsonElement> blockState : blocks1_13.entrySet()) {
Integer id = Integer.parseInt(blockState.getKey()); Integer id = Integer.parseInt(blockState.getKey());
@ -208,7 +208,7 @@ public class ConnectionData {
} }
if (!Via.getConfig().isReduceBlockStorageMemory()) { if (!Via.getConfig().isReduceBlockStorageMemory()) {
JsonObject mappingBlockConnections = MappingData.loadData("blockConnections.json"); JsonObject mappingBlockConnections = MappingDataLoader.loadData("blockConnections.json");
for (Entry<String, JsonElement> entry : mappingBlockConnections.entrySet()) { for (Entry<String, JsonElement> entry : mappingBlockConnections.entrySet()) {
int id = keyToId.get(entry.getKey()); int id = keyToId.get(entry.getKey());
BlockData blockData = new BlockData(); BlockData blockData = new BlockData();
@ -231,7 +231,7 @@ public class ConnectionData {
} }
} }
JsonObject blockData = MappingData.loadData("blockData.json"); JsonObject blockData = MappingDataLoader.loadData("blockData.json");
JsonArray occluding = blockData.getAsJsonArray("occluding"); JsonArray occluding = blockData.getAsJsonArray("occluding");
for (JsonElement jsonElement : occluding) { for (JsonElement jsonElement : occluding) {
occludingStates.add(keyToId.get(jsonElement.getAsString())); occludingStates.add(keyToId.get(jsonElement.getAsString()));

Datei anzeigen

@ -9,7 +9,7 @@ public class BlockConnectionProvider implements Provider {
public int getBlockdata(UserConnection connection, Position position) { public int getBlockdata(UserConnection connection, Position position) {
int oldId = getWorldBlockData(connection, position); int oldId = getWorldBlockData(connection, position);
return MappingData.blockMappings.getNewBlock(oldId); return MappingData.blockMappings.getNewId(oldId);
} }
public int getWorldBlockData(UserConnection connection, Position position) { public int getWorldBlockData(UserConnection connection, Position position) {

Datei anzeigen

@ -8,10 +8,11 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.MappingDataLoader;
import us.myles.ViaVersion.api.data.Mappings;
import us.myles.ViaVersion.util.GsonUtil; import us.myles.ViaVersion.util.GsonUtil;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -27,18 +28,18 @@ public class MappingData {
public static BiMap<Short, String> oldEnchantmentsIds = HashBiMap.create(); public static BiMap<Short, String> oldEnchantmentsIds = HashBiMap.create();
public static Map<String, String> translateMapping = new HashMap<>(); public static Map<String, String> translateMapping = new HashMap<>();
public static Map<String, String> mojangTranslation = new HashMap<>(); public static Map<String, String> mojangTranslation = new HashMap<>();
public static EnchantmentMappings enchantmentMappings; public static Mappings enchantmentMappings;
public static SoundMappings soundMappings; public static Mappings soundMappings;
public static BlockMappings blockMappings; public static Mappings blockMappings;
public static void init() { public static void init() {
JsonObject mapping1_12 = loadData("mapping-1.12.json"); JsonObject mapping1_12 = MappingDataLoader.loadData("mapping-1.12.json");
JsonObject mapping1_13 = loadData("mapping-1.13.json"); JsonObject mapping1_13 = MappingDataLoader.loadData("mapping-1.13.json");
Via.getPlatform().getLogger().info("Loading 1.12.2 -> 1.13 block mapping..."); Via.getPlatform().getLogger().info("Loading 1.12.2 -> 1.13 block mapping...");
blockMappings = new BlockMappingsShortArray(mapping1_12.getAsJsonObject("blocks"), mapping1_13.getAsJsonObject("blocks")); blockMappings = new BlockMappingsShortArray(mapping1_12.getAsJsonObject("blocks"), mapping1_13.getAsJsonObject("blocks"));
Via.getPlatform().getLogger().info("Loading 1.12.2 -> 1.13 item mapping..."); Via.getPlatform().getLogger().info("Loading 1.12.2 -> 1.13 item mapping...");
mapIdentifiers(oldToNewItems, mapping1_12.getAsJsonObject("items"), mapping1_13.getAsJsonObject("items")); MappingDataLoader.mapIdentifiers(oldToNewItems, mapping1_12.getAsJsonObject("items"), mapping1_13.getAsJsonObject("items"));
Via.getPlatform().getLogger().info("Loading new 1.13 tags..."); Via.getPlatform().getLogger().info("Loading new 1.13 tags...");
loadTags(blockTags, mapping1_13.getAsJsonObject("block_tags")); loadTags(blockTags, mapping1_13.getAsJsonObject("block_tags"));
loadTags(itemTags, mapping1_13.getAsJsonObject("item_tags")); loadTags(itemTags, mapping1_13.getAsJsonObject("item_tags"));
@ -55,7 +56,8 @@ public class MappingData {
MappingData.class.getClassLoader() MappingData.class.getClassLoader()
.getResourceAsStream("assets/viaversion/data/mapping-lang-1.12-1.13.json") .getResourceAsStream("assets/viaversion/data/mapping-lang-1.12-1.13.json")
), ),
(new TypeToken<Map<String, String>>(){}).getType()); (new TypeToken<Map<String, String>>() {
}).getType());
try { try {
String[] lines; String[] lines;
try (Reader reader = new InputStreamReader(MappingData.class.getClassLoader() try (Reader reader = new InputStreamReader(MappingData.class.getClassLoader()
@ -82,72 +84,6 @@ public class MappingData {
} }
} }
public static JsonObject loadData(String name) {
InputStream stream = MappingData.class.getClassLoader().getResourceAsStream("assets/viaversion/data/" + name);
InputStreamReader reader = new InputStreamReader(stream);
try {
JsonObject jsonObject = GsonUtil.getGson().fromJson(reader, JsonObject.class);
return jsonObject;
} finally {
try {
reader.close();
} catch (IOException ignored) {
// Ignored
}
}
}
private static void mapIdentifiers(Map<Integer, Integer> output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
if (value == null) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
}
continue;
}
output.put(Integer.parseInt(entry.getKey()), Integer.parseInt(value.getKey()));
}
}
private static void mapIdentifiers(short[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
if (value == null) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
}
continue;
}
output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey());
}
}
private static void mapIdentifiers(byte[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
if (value == null) {
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
continue;
}
output[Integer.parseInt(entry.getKey())] = Byte.parseByte(value.getKey());
}
}
private static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers) {
for (int i = 0; i < oldIdentifiers.size(); i++) {
JsonElement v = oldIdentifiers.get(i);
Integer index = findIndex(newIdentifiers, v.getAsString());
if (index == null) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + v + " :( ");
}
continue;
}
output[i] = index.shortValue();
}
}
private static void loadTags(Map<String, Integer[]> output, JsonObject newTags) { private static void loadTags(Map<String, Integer[]> output, JsonObject newTags) {
for (Map.Entry<String, JsonElement> entry : newTags.entrySet()) { for (Map.Entry<String, JsonElement> entry : newTags.entrySet()) {
JsonArray ids = entry.getValue().getAsJsonArray(); JsonArray ids = entry.getValue().getAsJsonArray();
@ -165,36 +101,12 @@ public class MappingData {
} }
} }
private static Map.Entry<String, JsonElement> findValue(JsonObject object, String needle) { private static class BlockMappingsShortArray implements Mappings {
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
String value = entry.getValue().getAsString();
if (value.equals(needle)) {
return entry;
}
}
return null;
}
private static Integer findIndex(JsonArray array, String value) {
for (int i = 0; i < array.size(); i++) {
JsonElement v = array.get(i);
if (v.getAsString().equals(value)) {
return i;
}
}
return null;
}
public interface BlockMappings {
int getNewBlock(int old);
}
private static class BlockMappingsShortArray implements BlockMappings {
private short[] oldToNew = new short[4084]; private short[] oldToNew = new short[4084];
private BlockMappingsShortArray(JsonObject mapping1_12, JsonObject mapping1_13) { private BlockMappingsShortArray(JsonObject mapping1_12, JsonObject mapping1_13) {
Arrays.fill(oldToNew, (short) -1); Arrays.fill(oldToNew, (short) -1);
mapIdentifiers(oldToNew, mapping1_12, mapping1_13); MappingDataLoader.mapIdentifiers(oldToNew, mapping1_12, mapping1_13);
// Map minecraft:snow[layers=1] of 1.12 to minecraft:snow[layers=2] in 1.13 // Map minecraft:snow[layers=1] of 1.12 to minecraft:snow[layers=2] in 1.13
if (Via.getConfig().isSnowCollisionFix()) { if (Via.getConfig().isSnowCollisionFix()) {
oldToNew[1248] = 3416; oldToNew[1248] = 3416;
@ -202,43 +114,35 @@ public class MappingData {
} }
@Override @Override
public int getNewBlock(int old) { public int getNewId(int old) {
return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1; return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1;
} }
} }
public interface SoundMappings { private static class SoundMappingShortArray implements Mappings {
int getNewSound(int old);
}
private static class SoundMappingShortArray implements SoundMappings {
private short[] oldToNew = new short[662]; private short[] oldToNew = new short[662];
private SoundMappingShortArray(JsonArray mapping1_12, JsonArray mapping1_13) { private SoundMappingShortArray(JsonArray mapping1_12, JsonArray mapping1_13) {
Arrays.fill(oldToNew, (short) -1); Arrays.fill(oldToNew, (short) -1);
mapIdentifiers(oldToNew, mapping1_12, mapping1_13); MappingDataLoader.mapIdentifiers(oldToNew, mapping1_12, mapping1_13);
} }
@Override @Override
public int getNewSound(int old) { public int getNewId(int old) {
return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1; return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1;
} }
} }
public interface EnchantmentMappings { private static class EnchantmentMappingByteArray implements Mappings {
int getNewEnchantment(int old);
}
private static class EnchantmentMappingByteArray implements EnchantmentMappings {
private byte[] oldToNew = new byte[72]; private byte[] oldToNew = new byte[72];
private EnchantmentMappingByteArray(JsonObject m1_12, JsonObject m1_13) { private EnchantmentMappingByteArray(JsonObject m1_12, JsonObject m1_13) {
Arrays.fill(oldToNew, (byte) -1); Arrays.fill(oldToNew, (byte) -1);
mapIdentifiers(oldToNew, m1_12, m1_13); MappingDataLoader.mapIdentifiers(oldToNew, m1_12, m1_13);
} }
@Override @Override
public int getNewEnchantment(int old) { public int getNewId(int old) {
return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1; return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1;
} }
} }

Datei anzeigen

@ -81,7 +81,7 @@ public class InventoryPackets {
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
short property = wrapper.get(Type.SHORT, 0); short property = wrapper.get(Type.SHORT, 0);
if (property >= 4 && property <= 6) { // Enchantment id if (property >= 4 && property <= 6) { // Enchantment id
wrapper.set(Type.SHORT, 1, (short) MappingData.enchantmentMappings.getNewEnchantment( wrapper.set(Type.SHORT, 1, (short) MappingData.enchantmentMappings.getNewId(
wrapper.get(Type.SHORT, 1) wrapper.get(Type.SHORT, 1)
)); ));
} }

Datei anzeigen

@ -496,11 +496,11 @@ public class WorldPackets {
if (oldId < 0) { if (oldId < 0) {
oldId = 0; // Some plugins use negative numbers to clear blocks, remap them to air. oldId = 0; // Some plugins use negative numbers to clear blocks, remap them to air.
} }
int newId = MappingData.blockMappings.getNewBlock(oldId); int newId = MappingData.blockMappings.getNewId(oldId);
if (newId != -1) { if (newId != -1) {
return newId; return newId;
} }
newId = MappingData.blockMappings.getNewBlock(oldId & ~0xF); // Remove data newId = MappingData.blockMappings.getNewId(oldId & ~0xF); // Remove data
if (newId != -1) { if (newId != -1) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) { if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Missing block " + oldId); Via.getPlatform().getLogger().warning("Missing block " + oldId);

Datei anzeigen

@ -28,7 +28,7 @@ public class BlockConnectionStorage extends StoredObject {
} }
reverseBlockMappings = new HashMap<>(); reverseBlockMappings = new HashMap<>();
for (int i = 0; i < 4096; i++) { for (int i = 0; i < 4096; i++) {
int newBlock = MappingData.blockMappings.getNewBlock(i); int newBlock = MappingData.blockMappings.getNewId(i);
if (newBlock != -1) reverseBlockMappings.put((short) newBlock, (short) i); if (newBlock != -1) reverseBlockMappings.put((short) newBlock, (short) i);
} }
} }

Datei anzeigen

@ -8,15 +8,15 @@ import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage.EntityTracker1
public class Protocol1_14_1To1_14 extends Protocol { public class Protocol1_14_1To1_14 extends Protocol {
@Override @Override
protected void registerPackets() { protected void registerPackets() {
put(new MetadataRewriter1_14_1To1_14()); put(new MetadataRewriter1_14_1To1_14());
EntityPackets.register(this); EntityPackets.register(this);
} }
@Override @Override
public void init(UserConnection userConnection) { public void init(UserConnection userConnection) {
userConnection.put(new EntityTracker1_14_1(userConnection)); userConnection.put(new EntityTracker1_14_1(userConnection));
} }
} }

Datei anzeigen

@ -296,7 +296,7 @@ public class Protocol1_14To1_13_2 extends Protocol {
} }
public static int getNewSoundId(int id) { public static int getNewSoundId(int id) {
int newId = MappingData.soundMappings.getNewSound(id); int newId = MappingData.soundMappings.getNewId(id);
if (newId == -1) { if (newId == -1) {
Via.getPlatform().getLogger().warning("Missing 1.14 sound for 1.13.2 sound " + id); Via.getPlatform().getLogger().warning("Missing 1.14 sound for 1.13.2 sound " + id);
return 0; return 0;
@ -305,7 +305,7 @@ public class Protocol1_14To1_13_2 extends Protocol {
} }
public static int getNewBlockStateId(int id) { public static int getNewBlockStateId(int id) {
int newId = MappingData.blockStateMappings.getNewBlock(id); int newId = MappingData.blockStateMappings.getNewId(id);
if (newId == -1) { if (newId == -1) {
Via.getPlatform().getLogger().warning("Missing 1.14 blockstate for 1.13.2 blockstate " + id); Via.getPlatform().getLogger().warning("Missing 1.14 blockstate for 1.13.2 blockstate " + id);
return 0; return 0;
@ -314,7 +314,7 @@ public class Protocol1_14To1_13_2 extends Protocol {
} }
public static int getNewBlockId(int id) { public static int getNewBlockId(int id) {
int newId = MappingData.blockMappings.getNewBlock(id); int newId = MappingData.blockMappings.getNewId(id);
if (newId == -1) { if (newId == -1) {
Via.getPlatform().getLogger().warning("Missing 1.14 block for 1.13.2 block " + id); Via.getPlatform().getLogger().warning("Missing 1.14 block for 1.13.2 block " + id);
return 0; return 0;

Datei anzeigen

@ -6,34 +6,28 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.util.GsonUtil; import us.myles.ViaVersion.api.data.MappingDataLoader;
import us.myles.ViaVersion.api.data.Mappings;
import java.io.IOException; import java.util.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class MappingData { public class MappingData {
public static BiMap<Integer, Integer> oldToNewItems = HashBiMap.create(); public static BiMap<Integer, Integer> oldToNewItems = HashBiMap.create();
public static BlockMappings blockStateMappings; public static Mappings blockStateMappings;
public static BlockMappings blockMappings; public static Mappings blockMappings;
public static SoundMappings soundMappings; public static Mappings soundMappings;
public static Set<Integer> motionBlocking; public static Set<Integer> motionBlocking;
public static void init() { public static void init() {
JsonObject mapping1_13_2 = loadData("mapping-1.13.2.json"); JsonObject mapping1_13_2 = MappingDataLoader.loadData("mapping-1.13.2.json");
JsonObject mapping1_14 = loadData("mapping-1.14.json"); JsonObject mapping1_14 = MappingDataLoader.loadData("mapping-1.14.json");
Via.getPlatform().getLogger().info("Loading 1.13.2 -> 1.14 blockstate mapping..."); Via.getPlatform().getLogger().info("Loading 1.13.2 -> 1.14 blockstate mapping...");
blockStateMappings = new BlockMappingsShortArray(mapping1_13_2.getAsJsonObject("blockstates"), mapping1_14.getAsJsonObject("blockstates")); blockStateMappings = new BlockMappingsShortArray(mapping1_13_2.getAsJsonObject("blockstates"), mapping1_14.getAsJsonObject("blockstates"));
Via.getPlatform().getLogger().info("Loading 1.13.2 -> 1.14 block mapping..."); Via.getPlatform().getLogger().info("Loading 1.13.2 -> 1.14 block mapping...");
blockMappings = new BlockMappingsShortArray(mapping1_13_2.getAsJsonObject("blocks"), mapping1_14.getAsJsonObject("blocks")); blockMappings = new BlockMappingsShortArray(mapping1_13_2.getAsJsonObject("blocks"), mapping1_14.getAsJsonObject("blocks"));
Via.getPlatform().getLogger().info("Loading 1.13.2 -> 1.14 item mapping..."); Via.getPlatform().getLogger().info("Loading 1.13.2 -> 1.14 item mapping...");
mapIdentifiers(oldToNewItems, mapping1_13_2.getAsJsonObject("items"), mapping1_14.getAsJsonObject("items")); MappingDataLoader.mapIdentifiers(oldToNewItems, mapping1_13_2.getAsJsonObject("items"), mapping1_14.getAsJsonObject("items"));
Via.getPlatform().getLogger().info("Loading 1.13.2 -> 1.14 sound mapping..."); Via.getPlatform().getLogger().info("Loading 1.13.2 -> 1.14 sound mapping...");
soundMappings = new SoundMappingShortArray(mapping1_13_2.getAsJsonArray("sounds"), mapping1_14.getAsJsonArray("sounds")); soundMappings = new SoundMappingShortArray(mapping1_13_2.getAsJsonArray("sounds"), mapping1_14.getAsJsonArray("sounds"));
@ -45,128 +39,46 @@ public class MappingData {
} }
Via.getPlatform().getLogger().info("Loading 1.14 heightmap data..."); Via.getPlatform().getLogger().info("Loading 1.14 heightmap data...");
JsonObject heightMapData = loadData("heightMapData-1.14.json"); JsonObject heightMapData = MappingDataLoader.loadData("heightMapData-1.14.json");
JsonArray motionBlocking = heightMapData.getAsJsonArray("MOTION_BLOCKING"); JsonArray motionBlocking = heightMapData.getAsJsonArray("MOTION_BLOCKING");
MappingData.motionBlocking = new HashSet<>(motionBlocking.size()); us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData.motionBlocking = new HashSet<>(motionBlocking.size());
for (JsonElement blockState : motionBlocking) { for (JsonElement blockState : motionBlocking) {
String key = blockState.getAsString(); String key = blockState.getAsString();
Integer id = blockStateMap.get(key); Integer id = blockStateMap.get(key);
if (id == null) { if (id == null) {
Via.getPlatform().getLogger().warning("Unknown blockstate " + key + " :("); Via.getPlatform().getLogger().warning("Unknown blockstate " + key + " :(");
} else { } else {
MappingData.motionBlocking.add(id); us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData.motionBlocking.add(id);
} }
} }
} }
public static JsonObject loadData(String name) { private static class SoundMappingShortArray implements Mappings {
InputStream stream = MappingData.class.getClassLoader().getResourceAsStream("assets/viaversion/data/" + name);
InputStreamReader reader = new InputStreamReader(stream);
try {
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
} finally {
try {
reader.close();
} catch (IOException ignored) {
// Ignored
}
}
}
private static void mapIdentifiers(Map<Integer, Integer> output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
if (value == null) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
}
continue;
}
output.put(Integer.parseInt(entry.getKey()), Integer.parseInt(value.getKey()));
}
}
private static void mapIdentifiers(short[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
if (value == null) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
}
continue;
}
output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey());
}
}
private static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers) {
for (int i = 0; i < oldIdentifiers.size(); i++) {
JsonElement v = oldIdentifiers.get(i);
Integer index = findIndex(newIdentifiers, v.getAsString());
if (index == null) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + v + " :( ");
}
continue;
}
output[i] = index.shortValue();
}
}
private static Map.Entry<String, JsonElement> findValue(JsonObject object, String needle) {
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
String value = entry.getValue().getAsString();
if (value.equals(needle)) {
return entry;
}
}
return null;
}
private static Integer findIndex(JsonArray array, String value) {
for (int i = 0; i < array.size(); i++) {
JsonElement v = array.get(i);
if (v.getAsString().equals(value)) {
return i;
}
}
return null;
}
public interface SoundMappings {
int getNewSound(int old);
}
private static class SoundMappingShortArray implements SoundMappings {
private short[] oldToNew; private short[] oldToNew;
private SoundMappingShortArray(JsonArray mapping1_13_2, JsonArray mapping1_14) { private SoundMappingShortArray(JsonArray mapping1_13_2, JsonArray mapping1_14) {
oldToNew = new short[mapping1_13_2.size()]; oldToNew = new short[mapping1_13_2.size()];
Arrays.fill(oldToNew, (short) -1); Arrays.fill(oldToNew, (short) -1);
mapIdentifiers(oldToNew, mapping1_13_2, mapping1_14); MappingDataLoader.mapIdentifiers(oldToNew, mapping1_13_2, mapping1_14);
} }
@Override @Override
public int getNewSound(int old) { public int getNewId(int old) {
return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1; return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1;
} }
} }
public interface BlockMappings { private static class BlockMappingsShortArray implements Mappings {
int getNewBlock(int old);
}
private static class BlockMappingsShortArray implements BlockMappings {
private short[] oldToNew; private short[] oldToNew;
private BlockMappingsShortArray(JsonObject mapping1_13_2, JsonObject mapping1_14) { private BlockMappingsShortArray(JsonObject mapping1_13_2, JsonObject mapping1_14) {
oldToNew = new short[mapping1_13_2.entrySet().size()]; oldToNew = new short[mapping1_13_2.entrySet().size()];
Arrays.fill(oldToNew, (short) -1); Arrays.fill(oldToNew, (short) -1);
mapIdentifiers(oldToNew, mapping1_13_2, mapping1_14); MappingDataLoader.mapIdentifiers(oldToNew, mapping1_13_2, mapping1_14);
} }
@Override @Override
public int getNewBlock(int old) { public int getNewId(int old) {
return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1; return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1;
} }
} }

Datei anzeigen

@ -23,9 +23,9 @@ import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class WorldPackets { public class WorldPackets {
private static final int AIR = MappingData.blockStateMappings.getNewBlock(0); private static final int AIR = MappingData.blockStateMappings.getNewId(0);
private static final int VOID_AIR = MappingData.blockStateMappings.getNewBlock(8591); private static final int VOID_AIR = MappingData.blockStateMappings.getNewId(8591);
private static final int CAVE_AIR = MappingData.blockStateMappings.getNewBlock(8592); private static final int CAVE_AIR = MappingData.blockStateMappings.getNewId(8592);
public static final int SERVERSIDE_VIEW_DISTANCE = 64; public static final int SERVERSIDE_VIEW_DISTANCE = 64;
public static void register(final Protocol protocol) { public static void register(final Protocol protocol) {

Datei anzeigen

@ -12,11 +12,6 @@
<artifactId>viaversion-sponge-legacy</artifactId> <artifactId>viaversion-sponge-legacy</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<repositories> <repositories>
<repository> <repository>
<id>sponge</id> <id>sponge</id>

Datei anzeigen

@ -11,11 +11,6 @@
<artifactId>viaversion-sponge</artifactId> <artifactId>viaversion-sponge</artifactId>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<repositories> <repositories>
<repository> <repository>
<id>sponge</id> <id>sponge</id>

Datei anzeigen

@ -2,8 +2,7 @@ package us.myles.ViaVersion.sponge.platform;
import org.spongepowered.api.asset.Asset; import org.spongepowered.api.asset.Asset;
import org.spongepowered.api.plugin.PluginContainer; import org.spongepowered.api.plugin.PluginContainer;
import us.myles.ViaVersion.api.ViaVersionConfig; import us.myles.ViaVersion.AbstractViaConfig;
import us.myles.ViaVersion.util.Config;
import java.io.File; import java.io.File;
import java.net.URL; import java.net.URL;
@ -12,8 +11,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class SpongeViaConfig extends Config implements ViaVersionConfig { public class SpongeViaConfig extends AbstractViaConfig {
private static List<String> UNSUPPORTED = Arrays.asList("anti-xray-patch", "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"); private static final List<String> UNSUPPORTED = Arrays.asList("anti-xray-patch", "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");
private final PluginContainer pluginContainer; private final PluginContainer pluginContainer;
public SpongeViaConfig(PluginContainer pluginContainer, File configFile) { public SpongeViaConfig(PluginContainer pluginContainer, File configFile) {
@ -34,7 +33,6 @@ public class SpongeViaConfig extends Config implements ViaVersionConfig {
@Override @Override
protected void handleConfig(Map<String, Object> config) { protected void handleConfig(Map<String, Object> config) {
// Nothing Currently
} }
@Override @Override
@ -42,230 +40,16 @@ public class SpongeViaConfig extends Config implements ViaVersionConfig {
return UNSUPPORTED; return UNSUPPORTED;
} }
public boolean isCheckForUpdates() {
return getBoolean("checkforupdates", true);
}
@Override
public boolean isPreventCollision() {
return getBoolean("prevent-collision", true);
}
@Override
public boolean isNewEffectIndicator() {
return getBoolean("use-new-effect-indicator", true);
}
@Override
public boolean isShowNewDeathMessages() {
return getBoolean("use-new-deathmessages", true);
}
@Override
public boolean isSuppressMetadataErrors() {
return getBoolean("suppress-metadata-errors", false);
}
@Override
public boolean isShieldBlocking() {
return getBoolean("shield-blocking", true);
}
@Override
public boolean isHologramPatch() {
return getBoolean("hologram-patch", false);
}
@Override
public boolean isPistonAnimationPatch() {
return getBoolean("piston-animation-patch", false);
}
@Override
public boolean isBossbarPatch() {
return getBoolean("bossbar-patch", true);
}
@Override
public boolean isBossbarAntiflicker() {
return getBoolean("bossbar-anti-flicker", false);
}
@Override
public boolean isUnknownEntitiesSuppressed() {
return false;
}
@Override
public double getHologramYOffset() {
return getDouble("hologram-y", -0.96D);
}
@Override
public boolean isBlockBreakPatch() {
return false;
}
@Override
public int getMaxPPS() {
return getInt("max-pps", 800);
}
@Override
public String getMaxPPSKickMessage() {
return getString("max-pps-kick-msg", "Sending packets too fast? lag?");
}
@Override
public int getTrackingPeriod() {
return getInt("tracking-period", 6);
}
@Override
public int getWarningPPS() {
return getInt("tracking-warning-pps", 120);
}
@Override
public int getMaxWarnings() {
return getInt("tracking-max-warnings", 3);
}
@Override
public String getMaxWarningsKickMessage() {
return getString("tracking-max-kick-msg", "You are sending too many packets, :(");
}
@Override @Override
public boolean isAntiXRay() { public boolean isAntiXRay() {
return false; return false;
} }
@Override
public boolean isSendSupportedVersions() {
return getBoolean("send-supported-versions", false);
}
@Override
public boolean isStimulatePlayerTick() {
return getBoolean("simulate-pt", true);
}
@Override
public boolean isItemCache() {
return getBoolean("item-cache", true);
}
@Override
public boolean isNMSPlayerTicking() {
return getBoolean("nms-player-ticking", true);
}
@Override
public boolean isReplacePistons() {
return getBoolean("replace-pistons", false);
}
@Override
public int getPistonReplacementId() {
return getInt("replacement-piston-id", 0);
}
public boolean isAutoTeam() {
// Collision has to be enabled first
return isPreventCollision() && getBoolean("auto-team", true);
}
@Override
public boolean isForceJsonTransform() {
return getBoolean("force-json-transform", false);
}
@Override
public boolean is1_12NBTArrayFix() {
return getBoolean("chat-nbt-fix", true);
}
@Override @Override
public boolean is1_12QuickMoveActionFix() { public boolean is1_12QuickMoveActionFix() {
return false; return false;
} }
@Override
public List<Integer> getBlockedProtocols() {
return getIntegerList("block-protocols");
}
@Override
public String getBlockedDisconnectMsg() {
return getString("block-disconnect-msg", "You are using an unsupported Minecraft version!");
}
@Override
public String getReloadDisconnectMsg() {
return getString("reload-disconnect-msg", "Server reload, please rejoin!");
}
@Override
public boolean isMinimizeCooldown() {
return getBoolean("minimize-cooldown", true);
}
@Override
public boolean is1_13TeamColourFix() {
return getBoolean("team-colour-fix", true);
}
@Override
public boolean isSuppress1_13ConversionErrors() {
return getBoolean("suppress-1_13-conversion-errors", false);
}
@Override
public boolean isDisable1_13AutoComplete() {
return getBoolean("disable-1_13-auto-complete", false);
}
@Override
public boolean isServersideBlockConnections() {
return getBoolean("serverside-blockconnections", false);
}
@Override
public String getBlockConnectionMethod() {
return getString("blockconnection-method", "packet");
}
@Override
public boolean isReduceBlockStorageMemory() {
return getBoolean("reduce-blockstorage-memory", false);
}
@Override
public boolean isStemWhenBlockAbove() {
return getBoolean("flowerstem-when-block-above", false);
}
@Override
public boolean isSnowCollisionFix() {
return getBoolean("fix-low-snow-collision", false);
}
@Override
public int get1_13TabCompleteDelay() {
return getInt("1_13-tab-complete-delay", 0);
}
@Override
public boolean isTruncate1_14Books() {
return getBoolean("truncate-1_14-books", false);
}
@Override
public boolean isLeftHandedHandling() {
return getBoolean("left-handed-handling", true);
}
@Override @Override
public boolean is1_9HitboxFix() { public boolean is1_9HitboxFix() {
return false; return false;

Datei anzeigen

@ -11,11 +11,6 @@
<artifactId>viaversion-velocity</artifactId> <artifactId>viaversion-velocity</artifactId>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<repositories> <repositories>
<repository> <repository>
<id>velocity</id> <id>velocity</id>

Datei anzeigen

@ -1,15 +1,14 @@
package us.myles.ViaVersion.velocity.platform; package us.myles.ViaVersion.velocity.platform;
import us.myles.ViaVersion.api.ViaVersionConfig; import us.myles.ViaVersion.AbstractViaConfig;
import us.myles.ViaVersion.api.protocol.ProtocolVersion; import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import us.myles.ViaVersion.util.Config;
import java.io.File; import java.io.File;
import java.net.URL; import java.net.URL;
import java.util.*; import java.util.*;
public class VelocityViaConfig extends Config implements ViaVersionConfig { public class VelocityViaConfig extends AbstractViaConfig {
private static 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", "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");
public VelocityViaConfig(File configFile) { public VelocityViaConfig(File configFile) {
super(new File(configFile, "config.yml")); super(new File(configFile, "config.yml"));
@ -65,115 +64,11 @@ public class VelocityViaConfig extends Config implements ViaVersionConfig {
return UNSUPPORTED; return UNSUPPORTED;
} }
public boolean isCheckForUpdates() {
return getBoolean("checkforupdates", true);
}
@Override
public boolean isPreventCollision() {
return getBoolean("prevent-collision", true);
}
@Override
public boolean isNewEffectIndicator() {
return getBoolean("use-new-effect-indicator", true);
}
@Override
public boolean isShowNewDeathMessages() {
return getBoolean("use-new-deathmessages", true);
}
@Override
public boolean isSuppressMetadataErrors() {
return getBoolean("suppress-metadata-errors", false);
}
@Override
public boolean isShieldBlocking() {
return getBoolean("shield-blocking", true);
}
@Override
public boolean isHologramPatch() {
return getBoolean("hologram-patch", false);
}
@Override
public boolean isPistonAnimationPatch() {
return getBoolean("piston-animation-patch", false);
}
@Override
public boolean isBossbarPatch() {
return getBoolean("bossbar-patch", true);
}
@Override
public boolean isBossbarAntiflicker() {
return getBoolean("bossbar-anti-flicker", false);
}
@Override
public boolean isUnknownEntitiesSuppressed() {
return false;
}
@Override
public double getHologramYOffset() {
return getDouble("hologram-y", -0.96D);
}
@Override
public boolean isBlockBreakPatch() {
return false;
}
@Override
public int getMaxPPS() {
return getInt("max-pps", 800);
}
@Override
public String getMaxPPSKickMessage() {
return getString("max-pps-kick-msg", "Sending packets too fast? lag?");
}
@Override
public int getTrackingPeriod() {
return getInt("tracking-period", 6);
}
@Override
public int getWarningPPS() {
return getInt("tracking-warning-pps", 120);
}
@Override
public int getMaxWarnings() {
return getInt("tracking-max-warnings", 3);
}
@Override
public String getMaxWarningsKickMessage() {
return getString("tracking-max-kick-msg", "You are sending too many packets, :(");
}
@Override @Override
public boolean isAntiXRay() { public boolean isAntiXRay() {
return false; return false;
} }
@Override
public boolean isSendSupportedVersions() {
return getBoolean("send-supported-versions", false);
}
@Override
public boolean isStimulatePlayerTick() {
return getBoolean("simulate-pt", true);
}
@Override @Override
public boolean isItemCache() { public boolean isItemCache() {
return false; return false;
@ -184,54 +79,24 @@ public class VelocityViaConfig extends Config implements ViaVersionConfig {
return false; return false;
} }
@Override
public boolean isReplacePistons() {
return getBoolean("replace-pistons", false);
}
@Override
public int getPistonReplacementId() {
return getInt("replacement-piston-id", 0);
}
public boolean isAutoTeam() {
// Collision has to be enabled first
return isPreventCollision() && getBoolean("auto-team", true);
}
@Override
public boolean isForceJsonTransform() {
return getBoolean("force-json-transform", false);
}
@Override
public boolean is1_12NBTArrayFix() {
return getBoolean("chat-nbt-fix", true);
}
@Override @Override
public boolean is1_12QuickMoveActionFix() { public boolean is1_12QuickMoveActionFix() {
return false; return false;
} }
@Override @Override
public List<Integer> getBlockedProtocols() { public String getBlockConnectionMethod() {
return getIntegerList("block-protocols"); return "packet";
} }
@Override @Override
public String getBlockedDisconnectMsg() { public boolean is1_9HitboxFix() {
return getString("block-disconnect-msg", "You are using an unsupported Minecraft version!"); return false;
} }
@Override @Override
public String getReloadDisconnectMsg() { public boolean is1_14HitboxFix() {
return getString("reload-disconnect-msg", "Server reload, please rejoin!"); return false;
}
@Override
public boolean isMinimizeCooldown() {
return getBoolean("minimize-cooldown", true);
} }
/** /**
@ -262,70 +127,4 @@ public class VelocityViaConfig extends Config implements ViaVersionConfig {
public Map<String, Integer> getVelocityServerProtocols() { public Map<String, Integer> getVelocityServerProtocols() {
return get("velocity-servers", Map.class, new HashMap<>()); return get("velocity-servers", Map.class, new HashMap<>());
} }
@Override
public boolean is1_13TeamColourFix() {
return getBoolean("team-colour-fix", true);
}
@Override
public boolean isSuppress1_13ConversionErrors() {
return getBoolean("suppress-1_13-conversion-errors", false);
}
@Override
public boolean isDisable1_13AutoComplete() {
return getBoolean("disable-1_13-auto-complete", false);
}
@Override
public boolean isServersideBlockConnections() {
return getBoolean("serverside-blockconnections", false);
}
@Override
public String getBlockConnectionMethod() {
return "packet";
}
@Override
public boolean isReduceBlockStorageMemory() {
return getBoolean("reduce-blockstorage-memory", false);
}
@Override
public boolean isStemWhenBlockAbove() {
return getBoolean("flowerstem-when-block-above", false);
}
@Override
public boolean isSnowCollisionFix() {
return getBoolean("fix-low-snow-collision", false);
}
@Override
public int get1_13TabCompleteDelay() {
return getInt("1_13-tab-complete-delay", 0);
}
@Override
public boolean isTruncate1_14Books() {
return getBoolean("truncate-1_14-books", false);
}
@Override
public boolean isLeftHandedHandling() {
return getBoolean("left-handed-handling", true);
}
@Override
public boolean is1_9HitboxFix() {
return false;
}
@Override
public boolean is1_14HitboxFix() {
return false;
}
} }