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() { public boolean is1_13TeamColourFix() {
return getBoolean("team-colour-fix", true); 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() { public boolean is1_13TeamColourFix() {
return getBoolean("team-colour-fix", true); 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 * @return Disconnect message
*/ */
String getReloadDisconnectMsg(); 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.data.ParticleRewriter;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets; 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_13to1_12_2.packets.WorldPackets;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View File

@ -63,7 +63,9 @@ public class MappingData {
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) { for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString()); Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
if (value == null) { 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; continue;
} }
output.put(Integer.parseInt(entry.getKey()), Integer.parseInt(value.getKey())); 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()) { for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString()); Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
if (value == null) { 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; continue;
} }
output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey()); output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey());
@ -97,7 +101,9 @@ public class MappingData {
JsonElement v = oldIdentifiers.get(i); JsonElement v = oldIdentifiers.get(i);
Integer index = findIndex(newIdentifiers, v.getAsString()); Integer index = findIndex(newIdentifiers, v.getAsString());
if (index == null) { 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; continue;
} }
output[i] = index.shortValue(); output[i] = index.shortValue();

View File

@ -113,8 +113,11 @@ public class InventoryPackets {
flags |= 1; flags |= 1;
Optional<SoundSource> finalSource = SoundSource.findBySource(originalSource); Optional<SoundSource> finalSource = SoundSource.findBySource(originalSource);
if (!finalSource.isPresent()) { 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); finalSource = Optional.of(SoundSource.MASTER);
} }
wrapper.write(Type.VAR_INT, finalSource.get().getId()); wrapper.write(Type.VAR_INT, finalSource.get().getId());
@ -165,7 +168,7 @@ public class InventoryPackets {
String rewritten = getNewPluginChannelId(channels[i]); String rewritten = getNewPluginChannelId(channels[i]);
if (rewritten != null) { if (rewritten != null) {
rewrittenChannels.add(rewritten); rewrittenChannels.add(rewritten);
} else { } else if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Ignoring plugin channel in REGISTER: " + channels[i]); Via.getPlatform().getLogger().warning("Ignoring plugin channel in REGISTER: " + channels[i]);
} }
} }
@ -244,7 +247,7 @@ public class InventoryPackets {
String rewritten = getOldPluginChannelId(channels[i]); String rewritten = getOldPluginChannelId(channels[i]);
if (rewritten != null) { if (rewritten != null) {
rewrittenChannels.add(rewritten); rewrittenChannels.add(rewritten);
} else { } else if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Ignoring plugin channel in REGISTER: " + channels[i]); 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)) { } else if (MappingData.oldToNewItems.containsKey(rawId & ~0xF)) {
rawId &= ~0xF; // Remove data rawId &= ~0xF; // Remove data
} else { } 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 rawId = 16; // Stone
} }
} }
@ -489,7 +494,9 @@ public class InventoryPackets {
} }
if (rawId == null) { 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 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.HashSet;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
public class WorldPackets { public class WorldPackets {
@ -72,7 +71,7 @@ public class WorldPackets {
Optional<Integer> id = provider.getIntByIdentifier(motive); 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)"); Via.getPlatform().getLogger().warning("Could not find painting motive: " + motive + " falling back to default (0)");
} }
wrapper.write(Type.VAR_INT, id.or(0)); wrapper.write(Type.VAR_INT, id.or(0));
@ -277,7 +276,9 @@ public class WorldPackets {
if (!validBiomes.contains(biome)) { if (!validBiomes.contains(biome)) {
if (biome != 255 // is it generated naturally? *shrug* if (biome != 255 // is it generated naturally? *shrug*
&& latestBiomeWarn != biome) { && 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; latestBiomeWarn = biome;
} }
chunk.getBiomeData()[i] = 1; // Plains chunk.getBiomeData()[i] = 1; // Plains
@ -386,10 +387,14 @@ public class WorldPackets {
} }
newId = MappingData.blockMappings.getNewBlock(oldId & ~0xF); // Remove data newId = MappingData.blockMappings.getNewBlock(oldId & ~0xF); // Remove data
if (newId != -1) { 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; 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 // Default stone
return 1; return 1;
} }

View File

@ -61,7 +61,9 @@ public class FlowerPotHandler implements BlockEntityProvider.BlockEntityHandler
} else if (flowersNumberId.containsKey(pair)) { } else if (flowersNumberId.containsKey(pair)) {
return flowersNumberId.get(pair); return flowersNumberId.get(pair);
} else { } 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; return -1;

View File

@ -88,6 +88,8 @@ chat-nbt-fix: true
quick-move-action-fix: false quick-move-action-fix: false
# Should we use prefix for team colour on 1.13 and above clients # Should we use prefix for team colour on 1.13 and above clients
team-colour-fix: true 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 # # 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() { public boolean is1_13TeamColourFix() {
return getBoolean("team-colour-fix", true); return getBoolean("team-colour-fix", true);
} }
@Override
public boolean isSuppress1_13ConversionErrors() {
return getBoolean("suppress-1_13-conversion-errors", false);
}
} }