Merge pull request #1528 from KennyTV/abstraction

Hold config values in fields, add extra mappings constructor, other fixes
This commit is contained in:
Myles 2019-12-08 23:08:52 +00:00 committed by GitHub
commit 459871257e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 290 additions and 181 deletions

View File

@ -1,7 +1,7 @@
package us.myles.ViaVersion.bukkit.platform;
import org.bukkit.plugin.Plugin;
import us.myles.ViaVersion.AbstractViaConfig;
import us.myles.ViaVersion.ViaVersionPlugin;
import us.myles.ViaVersion.api.Via;
import java.io.File;
@ -12,13 +12,27 @@ import java.util.Map;
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;
private String blockConnectionMethod;
public BukkitViaConfig() {
super(new File(((ViaVersionPlugin) Via.getPlatform()).getDataFolder(), "config.yml"));
// Load config
super(new File(((Plugin) Via.getPlatform()).getDataFolder(), "config.yml"));
reloadConfig();
}
@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);
blockConnectionMethod = getString("blockconnection-method", "packet");
}
@Override
public URL getDefaultConfigURL() {
return BukkitViaConfig.class.getClassLoader().getResource("assets/viaversion/config.yml");
@ -28,6 +42,31 @@ 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;
}
@Override
public boolean is1_9HitboxFix() {
return hitboxFix1_9;
}
@Override
public boolean is1_14HitboxFix() {
return hitboxFix1_14;
}
@Override
public String getBlockConnectionMethod() {
return blockConnectionMethod;
}
@Override
public List<String> getUnsupportedOptions() {
return UNSUPPORTED;

View File

@ -10,13 +10,23 @@ import java.util.*;
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 int bungeePingInterval;
private boolean bungeePingSave;
private Map<String, Integer> bungeeServerProtocols;
public BungeeViaConfig(File configFile) {
super(new File(configFile, "config.yml"));
// Load config
reloadConfig();
}
@Override
protected void loadFields() {
super.loadFields();
bungeePingInterval = getInt("bungee-ping-interval", 60);
bungeePingSave = getBoolean("bungee-ping-save", true);
bungeeServerProtocols = get("bungee-servers", Map.class, new HashMap<>());
}
@Override
public URL getDefaultConfigURL() {
return BungeeViaConfig.class.getClassLoader().getResource("assets/viaversion/config.yml");
@ -59,11 +69,6 @@ public class BungeeViaConfig extends AbstractViaConfig {
return UNSUPPORTED;
}
@Override
public boolean isAntiXRay() {
return false;
}
@Override
public boolean isItemCache() {
return false;
@ -74,26 +79,6 @@ public class BungeeViaConfig extends AbstractViaConfig {
return false;
}
@Override
public boolean is1_12QuickMoveActionFix() {
return false;
}
@Override
public String getBlockConnectionMethod() {
return "packet";
}
@Override
public boolean is1_9HitboxFix() {
return false;
}
@Override
public boolean is1_14HitboxFix() {
return false;
}
/**
* What is the interval for checking servers via ping
* -1 for disabled
@ -101,7 +86,7 @@ public class BungeeViaConfig extends AbstractViaConfig {
* @return Ping interval in seconds
*/
public int getBungeePingInterval() {
return getInt("bungee-ping-interval", 60);
return bungeePingInterval;
}
/**
@ -110,7 +95,7 @@ public class BungeeViaConfig extends AbstractViaConfig {
* @return True if it should save
*/
public boolean isBungeePingSave() {
return getBoolean("bungee-ping-save", true);
return bungeePingSave;
}
/**
@ -120,6 +105,6 @@ public class BungeeViaConfig extends AbstractViaConfig {
* @return Map of String, Integer
*/
public Map<String, Integer> getBungeeServerProtocols() {
return get("bungee-servers", Map.class, new HashMap<>());
return bungeeServerProtocols;
}
}

View File

@ -4,252 +4,349 @@ import us.myles.ViaVersion.api.ViaVersionConfig;
import us.myles.ViaVersion.util.Config;
import java.io.File;
import java.util.List;
import java.util.HashSet;
import java.util.Set;
public abstract class AbstractViaConfig extends Config implements ViaVersionConfig {
private boolean checkForUpdates;
private boolean preventCollision;
private boolean useNewEffectIndicator;
private boolean useNewDeathmessages;
private boolean suppressMetadataErrors;
private boolean shieldBlocking;
private boolean hologramPatch;
private boolean pistonAnimationPatch;
private boolean bossbarPatch;
private boolean bossbarAntiFlicker;
private double hologramOffset;
private int maxPPS;
private String maxPPSKickMessage;
private int trackingPeriod;
private int warningPPS;
private int maxPPSWarnings;
private String maxPPSWarningsKickMessage;
private boolean sendSupportedVersions;
private boolean simulatePlayerTick;
private boolean itemCache;
private boolean nmsPlayerTicking;
private boolean replacePistons;
private int pistonReplacementId;
private boolean autoTeam;
private boolean forceJsonTransform;
private boolean nbtArrayFix;
private Set<Integer> blockedProtocols;
private String blockedDisconnectMessage;
private String reloadDisconnectMessage;
private boolean suppressConversionWarnings;
private boolean disable1_13TabComplete;
private boolean minimizeCooldown;
private boolean teamColourFix;
private boolean serversideBlockConnections;
private boolean reduceBlockStorageMemory;
private boolean flowerStemWhenBlockAbove;
private boolean snowCollisionFix;
private int tabCompleteDelay;
private boolean truncate1_14Books;
private boolean leftHandedHandling;
private boolean fullBlockLightFix;
private boolean healthNaNFix;
private boolean instantRespawn;
protected AbstractViaConfig(File configFile) {
super(configFile);
}
@Override
public void reloadConfig() {
super.reloadConfig();
loadFields();
}
protected void loadFields() {
checkForUpdates = getBoolean("checkforupdates", true);
preventCollision = getBoolean("prevent-collision", true);
useNewEffectIndicator = getBoolean("use-new-effect-indicator", true);
useNewDeathmessages = getBoolean("use-new-deathmessages", true);
suppressMetadataErrors = getBoolean("suppress-metadata-errors", false);
shieldBlocking = getBoolean("shield-blocking", true);
hologramPatch = getBoolean("hologram-patch", false);
pistonAnimationPatch = getBoolean("piston-animation-patch", false);
bossbarPatch = getBoolean("bossbar-patch", true);
bossbarAntiFlicker = getBoolean("bossbar-anti-flicker", false);
hologramOffset = getDouble("hologram-y", -0.96D);
maxPPS = getInt("max-pps", 800);
maxPPSKickMessage = getString("max-pps-kick-msg", "Sending packets too fast? lag?");
trackingPeriod = getInt("tracking-period", 6);
warningPPS = getInt("tracking-warning-pps", 120);
maxPPSWarnings = getInt("tracking-max-warnings", 3);
maxPPSWarningsKickMessage = getString("tracking-max-kick-msg", "You are sending too many packets, :(");
sendSupportedVersions = getBoolean("send-supported-versions", false);
simulatePlayerTick = getBoolean("simulate-pt", true);
itemCache = getBoolean("item-cache", true);
nmsPlayerTicking = getBoolean("nms-player-ticking", true);
replacePistons = getBoolean("replace-pistons", false);
pistonReplacementId = getInt("replacement-piston-id", 0);
autoTeam = getBoolean("auto-team", true);
forceJsonTransform = getBoolean("force-json-transform", false);
nbtArrayFix = getBoolean("chat-nbt-fix", true);
blockedProtocols = new HashSet<>(getIntegerList("block-protocols"));
blockedDisconnectMessage = getString("block-disconnect-msg", "You are using an unsupported Minecraft version!");
reloadDisconnectMessage = getString("reload-disconnect-msg", "Server reload, please rejoin!");
minimizeCooldown = getBoolean("minimize-cooldown", true);
teamColourFix = getBoolean("team-colour-fix", true);
suppressConversionWarnings = getBoolean("suppress-conversion-warnings", false);
disable1_13TabComplete = getBoolean("disable-1_13-auto-complete", false);
serversideBlockConnections = getBoolean("serverside-blockconnections", false);
reduceBlockStorageMemory = getBoolean("reduce-blockstorage-memory", false);
flowerStemWhenBlockAbove = getBoolean("flowerstem-when-block-above", false);
snowCollisionFix = getBoolean("fix-low-snow-collision", false);
tabCompleteDelay = getInt("1_13-tab-complete-delay", 0);
truncate1_14Books = getBoolean("truncate-1_14-books", false);
leftHandedHandling = getBoolean("left-handed-handling", true);
fullBlockLightFix = getBoolean("fix-non-full-blocklight", false);
healthNaNFix = getBoolean("fix-1_14-health-nan", true);
instantRespawn = getBoolean("use-1_15-instant-respawn", false);
}
@Override
public boolean isCheckForUpdates() {
return getBoolean("checkforupdates", true);
return checkForUpdates;
}
@Override
public boolean isPreventCollision() {
return getBoolean("prevent-collision", true);
return preventCollision;
}
@Override
public boolean isNewEffectIndicator() {
return getBoolean("use-new-effect-indicator", true);
return useNewEffectIndicator;
}
@Override
public boolean isShowNewDeathMessages() {
return getBoolean("use-new-deathmessages", true);
return useNewDeathmessages;
}
@Override
public boolean isSuppressMetadataErrors() {
return getBoolean("suppress-metadata-errors", false);
return suppressMetadataErrors;
}
@Override
public boolean isShieldBlocking() {
return getBoolean("shield-blocking", true);
return shieldBlocking;
}
@Override
public boolean isHologramPatch() {
return getBoolean("hologram-patch", false);
return hologramPatch;
}
@Override
public boolean isPistonAnimationPatch() {
return getBoolean("piston-animation-patch", false);
return pistonAnimationPatch;
}
@Override
public boolean isBossbarPatch() {
return getBoolean("bossbar-patch", true);
return bossbarPatch;
}
@Override
public boolean isBossbarAntiflicker() {
return getBoolean("bossbar-anti-flicker", false);
return bossbarAntiFlicker;
}
@Override
public double getHologramYOffset() {
return getDouble("hologram-y", -0.96D);
return hologramOffset;
}
@Override
public int getMaxPPS() {
return getInt("max-pps", 800);
return maxPPS;
}
@Override
public String getMaxPPSKickMessage() {
return getString("max-pps-kick-msg", "Sending packets too fast? lag?");
return maxPPSKickMessage;
}
@Override
public int getTrackingPeriod() {
return getInt("tracking-period", 6);
return trackingPeriod;
}
@Override
public int getWarningPPS() {
return getInt("tracking-warning-pps", 120);
return warningPPS;
}
@Override
public int getMaxWarnings() {
return getInt("tracking-max-warnings", 3);
return maxPPSWarnings;
}
@Override
public String getMaxWarningsKickMessage() {
return getString("tracking-max-kick-msg", "You are sending too many packets, :(");
return maxPPSWarningsKickMessage;
}
@Override
public boolean isAntiXRay() {
return getBoolean("anti-xray-patch", true);
return false;
}
@Override
public boolean isSendSupportedVersions() {
return getBoolean("send-supported-versions", false);
return sendSupportedVersions;
}
@Override
public boolean isStimulatePlayerTick() {
return getBoolean("simulate-pt", true);
public boolean isSimulatePlayerTick() {
return simulatePlayerTick;
}
@Override
public boolean isItemCache() {
return getBoolean("item-cache", true);
return itemCache;
}
@Override
public boolean isNMSPlayerTicking() {
return getBoolean("nms-player-ticking", true);
return nmsPlayerTicking;
}
@Override
public boolean isReplacePistons() {
return getBoolean("replace-pistons", false);
return replacePistons;
}
@Override
public int getPistonReplacementId() {
return getInt("replacement-piston-id", 0);
return pistonReplacementId;
}
@Override
public boolean isAutoTeam() {
// Collision has to be enabled first
return isPreventCollision() && getBoolean("auto-team", true);
return isPreventCollision() && autoTeam;
}
@Override
public boolean isForceJsonTransform() {
return getBoolean("force-json-transform", false);
return forceJsonTransform;
}
@Override
public boolean is1_12NBTArrayFix() {
return getBoolean("chat-nbt-fix", true);
return nbtArrayFix;
}
@Override
public boolean is1_12QuickMoveActionFix() {
return getBoolean("quick-move-action-fix", false);
return false;
}
@Override
public List<Integer> getBlockedProtocols() {
return getIntegerList("block-protocols");
public Set<Integer> getBlockedProtocols() {
return blockedProtocols;
}
@Override
public String getBlockedDisconnectMsg() {
return getString("block-disconnect-msg", "You are using an unsupported Minecraft version!");
return blockedDisconnectMessage;
}
@Override
public String getReloadDisconnectMsg() {
return getString("reload-disconnect-msg", "Server reload, please rejoin!");
return reloadDisconnectMessage;
}
@Override
public boolean isMinimizeCooldown() {
return getBoolean("minimize-cooldown", true);
return minimizeCooldown;
}
@Override
public boolean is1_13TeamColourFix() {
return getBoolean("team-colour-fix", true);
return teamColourFix;
}
@Override
public boolean isSuppress1_13ConversionErrors() {
return getBoolean("suppress-1_13-conversion-errors", false);
public boolean isSuppressConversionWarnings() {
return suppressConversionWarnings;
}
@Override
public boolean isDisable1_13AutoComplete() {
return getBoolean("disable-1_13-auto-complete", false);
return disable1_13TabComplete;
}
@Override
public boolean isServersideBlockConnections() {
return getBoolean("serverside-blockconnections", false);
return serversideBlockConnections;
}
@Override
public String getBlockConnectionMethod() {
return getString("blockconnection-method", "packet");
return "packet";
}
@Override
public boolean isReduceBlockStorageMemory() {
return getBoolean("reduce-blockstorage-memory", false);
return reduceBlockStorageMemory;
}
@Override
public boolean isStemWhenBlockAbove() {
return getBoolean("flowerstem-when-block-above", false);
return flowerStemWhenBlockAbove;
}
@Override
public boolean isSnowCollisionFix() {
return getBoolean("fix-low-snow-collision", false);
return snowCollisionFix;
}
@Override
public int get1_13TabCompleteDelay() {
return getInt("1_13-tab-complete-delay", 0);
return tabCompleteDelay;
}
@Override
public boolean isTruncate1_14Books() {
return getBoolean("truncate-1_14-books", false);
return truncate1_14Books;
}
@Override
public boolean isLeftHandedHandling() {
return getBoolean("left-handed-handling", true);
return leftHandedHandling;
}
@Override
public boolean is1_9HitboxFix() {
return getBoolean("change-1_9-hitbox", false);
return false;
}
@Override
public boolean is1_14HitboxFix() {
return getBoolean("change-1_14-hitbox", false);
return false;
}
@Override
public boolean isNonFullBlockLightFix() {
return getBoolean("fix-non-full-blocklight", false);
return fullBlockLightFix;
}
@Override
public boolean is1_14HealthNaNFix() {
return getBoolean("fix-1_14-health-nan", true);
return healthNaNFix;
}
@Override
public boolean is1_15InstantRespawn() {
return getBoolean("use-1_15-instant-respawn", false);
return instantRespawn;
}
}

View File

@ -1,6 +1,6 @@
package us.myles.ViaVersion.api;
import java.util.List;
import java.util.Set;
public interface ViaVersionConfig {
@ -150,7 +150,7 @@ public interface ViaVersionConfig {
*
* @return if true, enabled
*/
boolean isStimulatePlayerTick();
boolean isSimulatePlayerTick();
/**
* Use the item cache to prevent high resource usage
@ -213,7 +213,7 @@ public interface ViaVersionConfig {
*
* @return An Integer list
*/
List<Integer> getBlockedProtocols();
Set<Integer> getBlockedProtocols();
/**
* Get the custom disconnect message
@ -231,11 +231,11 @@ public interface ViaVersionConfig {
String getReloadDisconnectMsg();
/**
* Should we hide errors that occur when trying to converting to 1.13 data?
* Should we hide errors that occur when trying to convert block and item data over versions?
*
* @return True if enabled
*/
boolean isSuppress1_13ConversionErrors();
boolean isSuppressConversionWarnings();
/**
* Should we disable the 1.13 auto-complete feature to stop spam kicks? (for any server lower than 1.13)

View File

@ -31,7 +31,7 @@ public class MappingDataLoader {
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()) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
}
continue;
@ -53,7 +53,7 @@ public class MappingDataLoader {
value = findValue(newIdentifiers, diffIdentifiers.get(entry.getKey()).getAsString());
}
if (value == null) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
}
continue;
@ -68,7 +68,7 @@ public class MappingDataLoader {
JsonElement v = oldIdentifiers.get(i);
Integer index = findIndex(newIdentifiers, v.getAsString());
if (index == null) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + v + " :( ");
}
continue;

View File

@ -8,13 +8,17 @@ import java.util.Arrays;
public class Mappings {
protected final short[] oldToNew;
protected Mappings(short[] oldToNew) {
this.oldToNew = oldToNew;
}
/**
* Maps old identifiers to the new ones.
* If an old value cannot be found in the new mappings, the diffmapping will be checked for the given entry.
*
* @param size set size of the underlying short array
* @param oldMapping mappings to map from
* @param newMapping mappings to map to
* @param size set size of the underlying short array
* @param oldMapping mappings to map from
* @param newMapping mappings to map to
* @param diffMapping extra mappings that will be used/scanned when an entry cannot be found
*/
public Mappings(int size, JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping) {
@ -30,7 +34,7 @@ public class Mappings {
/**
* Maps old identifiers to the new ones.
*
* @param size set size of the underlying short array
* @param size set size of the underlying short array
* @param oldMapping mappings to map from
* @param newMapping mappings to map to
*/
@ -47,7 +51,7 @@ public class Mappings {
/**
* Maps old identifiers to the new ones.
*
* @param size set size of the underlying short array
* @param size set size of the underlying short array
* @param oldMapping mappings to map from
* @param newMapping mappings to map to
*/

View File

@ -20,7 +20,7 @@ public class Entity1_10Types {
type = EntityType.findById(typeID);
if (!type.isPresent()) {
Via.getPlatform().getLogger().severe("Could not find type id " + typeID + " isObject=" + isObject);
Via.getPlatform().getLogger().severe("Could not find 1.10 type id " + typeID + " isObject=" + isObject);
return EntityType.ENTITY; // Fall back to the basic ENTITY
}

View File

@ -20,7 +20,7 @@ public class Entity1_11Types {
type = EntityType.findById(typeID);
if (!type.isPresent()) {
Via.getPlatform().getLogger().severe("Could not find type id " + typeID + " isObject=" + isObject);
Via.getPlatform().getLogger().severe("Could not find 1.11 type id " + typeID + " isObject=" + isObject);
return EntityType.ENTITY; // Fall back to the basic ENTITY
}

View File

@ -30,7 +30,7 @@ public class Entity1_12Types {
type = EntityType.findById(typeID);
if (!type.isPresent()) {
Via.getPlatform().getLogger().severe("Could not find type id " + typeID + " isObject=" + isObject);
Via.getPlatform().getLogger().severe("Could not find 1.12 type id " + typeID + " isObject=" + isObject);
return EntityType.ENTITY; // Fall back to the basic ENTITY
}

View File

@ -20,7 +20,7 @@ public class Entity1_13Types {
type = EntityType.findById(typeID);
if (!type.isPresent()) {
Via.getPlatform().getLogger().severe("Could not find type id " + typeID + " isObject=" + isObject);
Via.getPlatform().getLogger().severe("Could not find 1.13 type id " + typeID + " isObject=" + isObject);
return EntityType.ENTITY; // Fall back to the basic ENTITY
}

View File

@ -15,7 +15,7 @@ public class Entity1_14Types {
Optional<EntityType> type = EntityType.findById(typeID);
if (!type.isPresent()) {
Via.getPlatform().getLogger().severe("Could not find type id " + typeID);
Via.getPlatform().getLogger().severe("Could not find 1.14 type id " + typeID);
return EntityType.ENTITY; // Fall back to the basic ENTITY
}

View File

@ -15,7 +15,7 @@ public class Entity1_15Types {
Optional<EntityType> type = EntityType.findById(typeID);
if (!type.isPresent()) {
Via.getPlatform().getLogger().severe("Could not find type id " + typeID);
Via.getPlatform().getLogger().severe("Could not find 1.15 type id " + typeID);
return EntityType.ENTITY; // Fall back to the basic ENTITY
}
@ -104,7 +104,7 @@ public class Entity1_15Types {
// Monsters
ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE),
BLAZE(4, ABSTRACT_MONSTER),
BLAZE(5, ABSTRACT_MONSTER),
CREEPER(12, ABSTRACT_MONSTER),
ENDERMITE(21, ABSTRACT_MONSTER),
ENDERMAN(20, ABSTRACT_MONSTER),

View File

@ -85,6 +85,18 @@ public class ItemRewriter {
});
}
public void registerSetCooldown(int oldPacketId, int newPacketId, ItemIdRewriteFunction itemIDRewriteFunction) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
int itemId = wrapper.read(Type.VAR_INT);
wrapper.write(Type.VAR_INT, itemIDRewriteFunction.rewrite(itemId));
});
}
});
}
// Only sent to the client
public PacketHandler itemArrayHandler(Type<Item[]> type) {
return wrapper -> {
@ -108,4 +120,10 @@ public class ItemRewriter {
void rewrite(Item item);
}
@FunctionalInterface
public interface ItemIdRewriteFunction {
int rewrite(int itemId);
}
}

View File

@ -18,7 +18,7 @@ public class ByteArrayType extends Type<byte[]> {
@Override
public byte[] read(ByteBuf buffer) throws Exception {
int length = Type.VAR_INT.read(buffer);
Preconditions.checkArgument(!buffer.isReadable(length), "Length is fewer than readable bytes");
Preconditions.checkArgument(buffer.isReadable(length), "Length is fewer than readable bytes");
byte[] array = new byte[length];
buffer.readBytes(array);
return array;

View File

@ -100,7 +100,7 @@ public class InventoryPackets {
flags |= 1;
Optional<SoundSource> finalSource = SoundSource.findBySource(originalSource);
if (!finalSource.isPresent()) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().info("Could not handle unknown sound source " + originalSource + " falling back to default: master");
}
finalSource = Optional.of(SoundSource.MASTER);
@ -147,7 +147,7 @@ public class InventoryPackets {
String old = channel;
channel = getNewPluginChannelId(channel);
if (channel == null) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Ignoring outgoing plugin message with channel: " + old);
}
wrapper.cancel();
@ -159,7 +159,7 @@ public class InventoryPackets {
String rewritten = getNewPluginChannelId(channels[i]);
if (rewritten != null) {
rewrittenChannels.add(rewritten);
} else if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
} else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Ignoring plugin channel in outgoing REGISTER: " + channels[i]);
}
}
@ -218,7 +218,7 @@ public class InventoryPackets {
String old = channel;
channel = getOldPluginChannelId(channel);
if (channel == null) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Ignoring incoming plugin message with channel: " + old);
}
wrapper.cancel();
@ -230,7 +230,7 @@ public class InventoryPackets {
String rewritten = getOldPluginChannelId(channels[i]);
if (rewritten != null) {
rewrittenChannels.add(rewritten);
} else if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
} else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Ignoring plugin channel in incoming REGISTER: " + channels[i]);
}
}
@ -431,7 +431,7 @@ public class InventoryPackets {
} else if (MappingData.oldToNewItems.containsKey(rawId & ~0xF)) {
rawId &= ~0xF; // Remove data
} else {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Failed to get 1.13 item for " + item.getIdentifier());
}
rawId = 16; // Stone
@ -518,7 +518,7 @@ public class InventoryPackets {
}
if (rawId == null) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Failed to get 1.12 item for " + item.getIdentifier());
}
rawId = 0x10000; // Stone

View File

@ -73,7 +73,7 @@ public class WorldPackets {
Optional<Integer> id = provider.getIntByIdentifier(motive);
if (!id.isPresent() && (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug())) {
if (!id.isPresent() && (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug())) {
Via.getPlatform().getLogger().warning("Could not find painting motive: " + motive + " falling back to default (0)");
}
wrapper.write(Type.VAR_INT, id.orElse(0));
@ -374,7 +374,7 @@ public class WorldPackets {
if (!validBiomes.contains(biome)) {
if (biome != 255 // is it generated naturally? *shrug*
&& latestBiomeWarn != biome) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Received invalid biome id " + biome);
}
latestBiomeWarn = biome;
@ -502,12 +502,12 @@ public class WorldPackets {
}
newId = MappingData.blockMappings.getNewId(oldId & ~0xF); // Remove data
if (newId != -1) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Missing block " + oldId);
}
return newId;
}
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Missing block completely " + oldId);
}
// Default stone

View File

@ -61,7 +61,7 @@ public class FlowerPotHandler implements BlockEntityProvider.BlockEntityHandler
} else if (flowersNumberId.containsKey(pair)) {
return flowersNumberId.get(pair);
} else {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Could not find flowerpot content " + item + " for " + tag);
}
}

View File

@ -201,7 +201,6 @@ public class Protocol1_15To1_14_4 extends Protocol {
registerOutgoing(State.PLAY, 0x34, 0x35);
registerOutgoing(State.PLAY, 0x35, 0x36);
registerOutgoing(State.PLAY, 0x36, 0x37);
registerOutgoing(State.PLAY, 0x37, 0x38);
registerOutgoing(State.PLAY, 0x38, 0x39);
registerOutgoing(State.PLAY, 0x39, 0x3A);
registerOutgoing(State.PLAY, 0x3B, 0x3C);

View File

@ -115,6 +115,8 @@ public class EntityPackets {
// Metadata packet
metadataRewriter.registerMetadataRewriter(0x43, 0x44, Types1_14.METADATA_LIST);
metadataRewriter.registerEntityDestroy(0x37, 0x38);
}
public static int getNewEntityId(int oldId) {

View File

@ -31,6 +31,16 @@ public class Chunk1_15Type extends PartialType<Chunk, ClientWorld> {
boolean groundUp = input.readBoolean();
int primaryBitmask = Type.VAR_INT.read(input);
CompoundTag heightMap = Type.NBT.read(input);
int[] biomeData = groundUp ? new int[256] : null;
if (groundUp) {
//TODO Why 1024 ints?
for (int i = 0; i < 1024; i++) {
//biomeData[i] = input.readInt();
input.readInt();
}
}
Type.VAR_INT.read(input);
BitSet usedSections = new BitSet(16);
@ -42,15 +52,6 @@ public class Chunk1_15Type extends PartialType<Chunk, ClientWorld> {
}
}
int[] biomeData = groundUp ? new int[256] : null;
if (groundUp) {
//TODO Why 1024 ints?
for (int i = 0; i < 1024; i++) {
//biomeData[i] = input.readInt();
input.readInt();
}
}
// Read sections
for (int i = 0; i < 16; i++) {
if (!usedSections.get(i)) continue; // Section not set

View File

@ -100,7 +100,7 @@ public class Protocol1_9To1_8 extends Protocol {
providers.register(BossBarProvider.class, new BossBarProvider());
providers.register(MainHandProvider.class, new MainHandProvider());
providers.require(MovementTransmitterProvider.class);
if (Via.getConfig().isStimulatePlayerTick()) {
if (Via.getConfig().isSimulatePlayerTick()) {
Via.getPlatform().runRepeatingSync(new ViaIdleThread(), 1L);
}
}

View File

@ -24,7 +24,7 @@ public abstract class Config implements ConfigurationProvider {
private final CommentStore commentStore = new CommentStore('.', 2);
private final File configFile;
private ConcurrentSkipListMap<String, Object> config;
private Map<String, Object> config;
/**
* Create a new Config instance, this will *not* load the config by default.

View File

@ -22,6 +22,8 @@ block-disconnect-msg: "You are using an unsupported Minecraft version!"
# (We don't suggest using reload either, use a plugin manager)
# You can customise the message we kick people with if you use ProtocolLib here.
reload-disconnect-msg: "Server reload, please rejoin!"
# We warn when there's a error converting item and block data over versions, should we suppress these? (Only suggested if spamming)
suppress-conversion-warnings: false
#
#----------------------------------------------------------#
# BUNGEE OPTIONS #
@ -110,8 +112,6 @@ chat-nbt-fix: true
quick-move-action-fix: false
# Should we use prefix for team colour on 1.13 and above clients
team-colour-fix: true
# We warn when there's a error converting from pre-1.13 to 1.13, should we suppress these? (Only suggested if spamming)
suppress-1_13-conversion-errors: false
# 1.13 introduced new auto complete which can trigger "Kicked for spamming" for servers older than 1.13, the following option will disable it completely.
disable-1_13-auto-complete: false
# The following option will delay the tab complete request in x ticks if greater than 0, if other tab-complete is received, the previous is cancelled

View File

@ -18,7 +18,6 @@ public class SpongeViaConfig extends AbstractViaConfig {
public SpongeViaConfig(PluginContainer pluginContainer, File configFile) {
super(new File(configFile, "config.yml"));
this.pluginContainer = pluginContainer;
// Load config
reloadConfig();
}
@ -39,24 +38,4 @@ public class SpongeViaConfig extends AbstractViaConfig {
public List<String> getUnsupportedOptions() {
return UNSUPPORTED;
}
@Override
public boolean isAntiXRay() {
return false;
}
@Override
public boolean is1_12QuickMoveActionFix() {
return false;
}
@Override
public boolean is1_9HitboxFix() {
return false;
}
@Override
public boolean is1_14HitboxFix() {
return false;
}
}

View File

@ -9,13 +9,23 @@ import java.util.*;
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 int velocityPingInterval;
private boolean velocityPingSave;
private Map<String, Integer> velocityServerProtocols;
public VelocityViaConfig(File configFile) {
super(new File(configFile, "config.yml"));
// Load config
reloadConfig();
}
@Override
protected void loadFields() {
super.loadFields();
velocityPingInterval = getInt("velocity-ping-interval", 60);
velocityPingSave = getBoolean("velocity-ping-save", true);
velocityServerProtocols = get("velocity-servers", Map.class, new HashMap<>());
}
@Override
public URL getDefaultConfigURL() {
return getClass().getClassLoader().getResource("assets/viaversion/config.yml");
@ -64,11 +74,6 @@ public class VelocityViaConfig extends AbstractViaConfig {
return UNSUPPORTED;
}
@Override
public boolean isAntiXRay() {
return false;
}
@Override
public boolean isItemCache() {
return false;
@ -79,26 +84,6 @@ public class VelocityViaConfig extends AbstractViaConfig {
return false;
}
@Override
public boolean is1_12QuickMoveActionFix() {
return false;
}
@Override
public String getBlockConnectionMethod() {
return "packet";
}
@Override
public boolean is1_9HitboxFix() {
return false;
}
@Override
public boolean is1_14HitboxFix() {
return false;
}
/**
* What is the interval for checking servers via ping
* -1 for disabled
@ -106,7 +91,7 @@ public class VelocityViaConfig extends AbstractViaConfig {
* @return Ping interval in seconds
*/
public int getVelocityPingInterval() {
return getInt("velocity-ping-interval", 60);
return velocityPingInterval;
}
/**
@ -115,7 +100,7 @@ public class VelocityViaConfig extends AbstractViaConfig {
* @return True if it should save
*/
public boolean isVelocityPingSave() {
return getBoolean("velocity-ping-save", true);
return velocityPingSave;
}
/**
@ -125,6 +110,6 @@ public class VelocityViaConfig extends AbstractViaConfig {
* @return Map of String, Integer
*/
public Map<String, Integer> getVelocityServerProtocols() {
return get("velocity-servers", Map.class, new HashMap<>());
return velocityServerProtocols;
}
}