Code cleanup

This commit is contained in:
FlorianMichael 2024-07-25 17:32:23 +02:00
parent dbb6e5a393
commit a7984797d9
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
9 changed files with 18 additions and 18 deletions

View File

@ -105,7 +105,7 @@ public class Protocolc0_30cpeToc0_28_30 extends StatelessProtocol<ClientboundPac
if (extension != null) {
protocolMetadataStorage.addServerExtension(extension, extensionVersion);
} else {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
ViaLegacy.getPlatform().getLogger().warning("Received unknown classic protocol extension: (" + extensionName + " v" + extensionVersion + ")");
}
}

View File

@ -445,7 +445,7 @@ public class Protocolr1_2_4_5Tor1_3_1_2 extends StatelessProtocol<ClientboundPac
wrapper.user().get(ChestStateTracker.class).unload(chunk.getX(), chunk.getZ());
if (chunk.isFullChunk() && chunk.getBitmask() == 0) { // Remap to empty chunk
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
ViaLegacy.getPlatform().getLogger().warning("Received empty 1.2.5 chunk packet");
}
chunk = ChunkUtil.createEmptyChunk(chunk.getX(), chunk.getZ());

View File

@ -227,7 +227,7 @@ public class Protocolr1_3_1_2Tor1_4_2 extends StatelessProtocol<ClientboundPacke
String newSound = SoundRewriter.map(oldSound);
if (oldSound.isEmpty()) newSound = "";
if (newSound == null) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
ViaLegacy.getPlatform().getLogger().warning("Unable to map 1.3.2 sound '" + oldSound + "'");
}
newSound = "";
@ -289,7 +289,7 @@ public class Protocolr1_3_1_2Tor1_4_2 extends StatelessProtocol<ClientboundPacke
length = (short) PacketUtil.calculateLength(wrapper);
}
} catch (Exception e) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
Via.getPlatform().getLogger().log(Level.WARNING, "Failed to handle packet", e);
}
wrapper.cancel();

View File

@ -253,7 +253,7 @@ public class Protocolr1_5_2Tor1_6_1 extends StatelessProtocol<ClientboundPackets
String newSound = SoundRewriter.map(oldSound);
if (oldSound.isEmpty()) newSound = "";
if (newSound == null) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
ViaLegacy.getPlatform().getLogger().warning("Unable to map 1.5.2 sound '" + oldSound + "'");
}
newSound = "";
@ -322,7 +322,7 @@ public class Protocolr1_5_2Tor1_6_1 extends StatelessProtocol<ClientboundPackets
length = (short) PacketUtil.calculateLength(wrapper);
}
} catch (Exception e) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
Via.getPlatform().getLogger().log(Level.WARNING, "Failed to handle packet", e);
}
wrapper.cancel();

View File

@ -48,14 +48,14 @@ public class EntityDataRewriter {
case ITEM, STRING, BLOCK_POSITION -> {
}
default -> {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
ViaLegacy.getPlatform().getLogger().warning("1.5.2 EntityDataRewriter: Unhandled Type: " + entityDataIndex.getNewType() + " " + entry);
}
list.remove(entry);
}
}
} catch (Throwable e) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
ViaLegacy.getPlatform().getLogger().log(Level.WARNING, "Error rewriting entity data entry for " + type.name() + ": " + entry, e);
}
list.remove(entry);

View File

@ -490,7 +490,7 @@ public class Protocolr1_6_4Tor1_7_2_5 extends StatelessTransitionProtocol<Client
String newSound = SoundRewriter.map(oldSound);
if (oldSound.isEmpty()) newSound = "";
if (newSound == null) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
ViaLegacy.getPlatform().getLogger().warning("Unable to map 1.6.4 sound '" + oldSound + "'");
}
newSound = "";
@ -767,7 +767,7 @@ public class Protocolr1_6_4Tor1_7_2_5 extends StatelessTransitionProtocol<Client
length = PacketUtil.calculateLength(wrapper);
}
} catch (Exception e) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
Via.getPlatform().getLogger().log(Level.WARNING, "Failed to handle packet", e);
}
wrapper.cancel();

View File

@ -776,7 +776,7 @@ public class Protocolr1_7_6_10Tor1_8 extends AbstractProtocol<ClientboundPackets
Particle1_7_6 particle = Particle1_7_6.find(parts[0]);
if (particle == null) {
particle = Particle1_7_6.BARRIER;
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
ViaLegacy.getPlatform().getLogger().warning("Could not find 1.8 particle for " + Arrays.toString(parts));
}
}
@ -1350,7 +1350,7 @@ public class Protocolr1_7_6_10Tor1_8 extends AbstractProtocol<ClientboundPackets
final String channel = wrapper.read(Types.STRING); // channel
if (ViaLegacy.getConfig().isIgnoreLong1_8ChannelNames() && channel.length() > 16) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
ViaLegacy.getPlatform().getLogger().warning("Ignoring serverbound plugin channel, as it is longer than 16 characters: '" + channel + "'");
}
wrapper.cancel();
@ -1376,7 +1376,7 @@ public class Protocolr1_7_6_10Tor1_8 extends AbstractProtocol<ClientboundPackets
} else if (type == 1) {
wrapper.passthrough(Types.INT); // entity id
} else {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
ViaLegacy.getPlatform().getLogger().warning("Unknown 1.8 command block type: " + type);
}
wrapper.cancel();
@ -1393,7 +1393,7 @@ public class Protocolr1_7_6_10Tor1_8 extends AbstractProtocol<ClientboundPackets
final List<String> validChannels = new ArrayList<>(registeredChannels.length);
for (String registeredChannel : registeredChannels) {
if (registeredChannel.length() > 16) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
ViaLegacy.getPlatform().getLogger().warning("Ignoring serverbound plugin channel register of '" + registeredChannel + "', as it is longer than 16 characters");
}
continue;

View File

@ -45,7 +45,7 @@ public class EntityDataRewriter {
final EntityDataIndex1_7_6 entityDataIndex = EntityDataIndex1_7_6.searchIndex(type, entry.id());
try {
if (entityDataIndex == null) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
ViaLegacy.getPlatform().getLogger().warning("Could not find valid entity data index entry for " + type.name() + ": " + entry);
}
list.remove(entry);
@ -95,14 +95,14 @@ public class EntityDataRewriter {
case STRING, BLOCK_POSITION, ROTATIONS -> {
}
default -> {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
ViaLegacy.getPlatform().getLogger().warning("1.7.10 EntityDataRewriter: Unhandled Type: " + entityDataIndex.getNewType() + " " + entry);
}
list.remove(entry);
}
}
} catch (Throwable e) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
ViaLegacy.getPlatform().getLogger().log(Level.WARNING, "Error rewriting entity data entry for " + type.name() + ": " + entry, e);
}
list.remove(entry);

View File

@ -468,7 +468,7 @@ public class TextRewriter {
c.getStyle().setHoverEvent(new TextHoverEvent(textHoverEvent.getAction(), new StringComponent(SNbtSerializer.V1_8.serialize(tag))));
} catch (Throwable e) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
ViaLegacy.getPlatform().getLogger().log(Level.WARNING, "Error remapping NBT in show_item:" + textHoverEvent.getText().asUnformattedString(), e);
}
c.getStyle().setHoverEvent(new TextHoverEvent(textHoverEvent.getAction(), new StringComponent())); // Invalid item