Introduce 'suppress-1_13-conversion-errors' option

This commit is contained in:
Myles 2018-08-21 16:26:04 +01:00
parent e4a99c4a3d
commit 2510751fdf
10 changed files with 58 additions and 15 deletions

View File

@ -204,4 +204,9 @@ public class BukkitConfigAPI extends Config implements ViaVersionConfig {
public boolean is1_13TeamColourFix() {
return getBoolean("team-colour-fix", true);
}
@Override
public boolean isSuppress1_13ConversionErrors() {
return getBoolean("suppress-1_13-conversion-errors", false);
}
}

View File

@ -257,4 +257,9 @@ public class BungeeConfigAPI extends Config implements ViaVersionConfig {
public boolean is1_13TeamColourFix() {
return getBoolean("team-colour-fix", true);
}
@Override
public boolean isSuppress1_13ConversionErrors() {
return getBoolean("suppress-1_13-conversion-errors", false);
}
}

View File

@ -245,4 +245,11 @@ public interface ViaVersionConfig {
* @return Disconnect message
*/
String getReloadDisconnectMsg();
/**
* Should we hide errors that occur when trying to converting to 1.13 data?
*
* @return True if enabled
*/
boolean isSuppress1_13ConversionErrors();
}

View File

@ -10,7 +10,6 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.ParticleRewriter;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.WorldPackets;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import java.util.ArrayList;
import java.util.List;

View File

@ -63,7 +63,9 @@ public class MappingData {
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() + " :( ");
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()));
@ -74,7 +76,9 @@ public class MappingData {
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() + " :( ");
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());
@ -97,7 +101,9 @@ public class MappingData {
JsonElement v = oldIdentifiers.get(i);
Integer index = findIndex(newIdentifiers, v.getAsString());
if (index == null) {
Via.getPlatform().getLogger().warning("No key for " + v + " :( ");
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + v + " :( ");
}
continue;
}
output[i] = index.shortValue();

View File

@ -113,8 +113,11 @@ public class InventoryPackets {
flags |= 1;
Optional<SoundSource> finalSource = SoundSource.findBySource(originalSource);
if (!finalSource.isPresent()) {
Via.getPlatform().getLogger().info("Could not handle unknown sound source " + originalSource + " falling back to default: master");
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().info("Could not handle unknown sound source " + originalSource + " falling back to default: master");
}
finalSource = Optional.of(SoundSource.MASTER);
}
wrapper.write(Type.VAR_INT, finalSource.get().getId());
@ -165,7 +168,7 @@ public class InventoryPackets {
String rewritten = getNewPluginChannelId(channels[i]);
if (rewritten != null) {
rewrittenChannels.add(rewritten);
} else {
} else if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Ignoring plugin channel in REGISTER: " + channels[i]);
}
}
@ -244,7 +247,7 @@ public class InventoryPackets {
String rewritten = getOldPluginChannelId(channels[i]);
if (rewritten != null) {
rewrittenChannels.add(rewritten);
} else {
} else if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Ignoring plugin channel in REGISTER: " + channels[i]);
}
}
@ -408,7 +411,9 @@ public class InventoryPackets {
} else if (MappingData.oldToNewItems.containsKey(rawId & ~0xF)) {
rawId &= ~0xF; // Remove data
} else {
Via.getPlatform().getLogger().warning("Failed to get 1.13 item for " + item.getId());
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Failed to get 1.13 item for " + item.getId());
}
rawId = 16; // Stone
}
}
@ -489,7 +494,9 @@ public class InventoryPackets {
}
if (rawId == null) {
Via.getPlatform().getLogger().warning("Failed to get 1.12 item for " + item.getId());
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Failed to get 1.12 item for " + item.getId());
}
rawId = 0x10000; // Stone
}

View File

@ -28,7 +28,6 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class WorldPackets {
@ -72,7 +71,7 @@ public class WorldPackets {
Optional<Integer> id = provider.getIntByIdentifier(motive);
if (!id.isPresent()) {
if (!id.isPresent() && (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug())) {
Via.getPlatform().getLogger().warning("Could not find painting motive: " + motive + " falling back to default (0)");
}
wrapper.write(Type.VAR_INT, id.or(0));
@ -277,7 +276,9 @@ public class WorldPackets {
if (!validBiomes.contains(biome)) {
if (biome != 255 // is it generated naturally? *shrug*
&& latestBiomeWarn != biome) {
Via.getPlatform().getLogger().warning("Received invalid biome id " + biome);
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Received invalid biome id " + biome);
}
latestBiomeWarn = biome;
}
chunk.getBiomeData()[i] = 1; // Plains
@ -386,10 +387,14 @@ public class WorldPackets {
}
newId = MappingData.blockMappings.getNewBlock(oldId & ~0xF); // Remove data
if (newId != -1) {
Via.getPlatform().getLogger().warning("Missing block " + oldId);
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Missing block " + oldId);
}
return newId;
}
Via.getPlatform().getLogger().warning("Missing block completely " + oldId);
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Missing block completely " + oldId);
}
// Default stone
return 1;
}

View File

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

View File

@ -88,6 +88,8 @@ 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.9 & 1.10 CLIENTS ON 1.8 SERVERS OPTIONS #

View File

@ -210,4 +210,9 @@ public class SpongeConfigAPI extends Config implements ViaVersionConfig {
public boolean is1_13TeamColourFix() {
return getBoolean("team-colour-fix", true);
}
@Override
public boolean isSuppress1_13ConversionErrors() {
return getBoolean("suppress-1_13-conversion-errors", false);
}
}