mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-12-22 16:38:20 +01:00
Small random cleanup
This commit is contained in:
parent
c7265abfe9
commit
cfc048ba53
@ -106,7 +106,7 @@ public class CollisionChecker {
|
||||
}
|
||||
|
||||
private static class DummyList<T> extends AbstractList<T> {
|
||||
private boolean any = false;
|
||||
private boolean any;
|
||||
|
||||
@Override
|
||||
public T get(int index) {
|
||||
|
@ -199,10 +199,6 @@ public class BukkitInventoryQuickMoveProvider extends InventoryQuickMoveProvider
|
||||
|
||||
private boolean isSupported() {
|
||||
int protocolId = Via.getAPI().getServerVersion().lowestSupportedVersion();
|
||||
if (protocolId >= ProtocolVersion.v1_8.getVersion() && protocolId <= ProtocolVersion.v1_11_1.getVersion()) {
|
||||
return true; // 1.8-1.11.2
|
||||
}
|
||||
// this is not needed on 1.12+ servers
|
||||
return false;
|
||||
return protocolId >= ProtocolVersion.v1_8.getVersion() && protocolId <= ProtocolVersion.v1_11_1.getVersion(); // 1.8-1.11.2, not needed with 1.12
|
||||
}
|
||||
}
|
@ -31,6 +31,7 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -56,7 +57,7 @@ public class CommonBoss implements BossBar {
|
||||
this.color = color == null ? BossColor.PURPLE : color;
|
||||
this.style = style == null ? BossStyle.SOLID : style;
|
||||
this.connections = new MapMaker().weakValues().makeMap();
|
||||
this.flags = new HashSet<>();
|
||||
this.flags = EnumSet.noneOf(BossFlag.class);
|
||||
this.visible = true;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ import com.google.common.collect.HashBiMap;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
|
||||
public class BlockEntityRewriter {
|
||||
private static BiMap<String, String> oldToNewNames = HashBiMap.create();
|
||||
private static final BiMap<String, String> OLD_TO_NEW_NAMES = HashBiMap.create();
|
||||
|
||||
// Source: https://www.minecraftforum.net/forums/minecraft-java-edition/redstone-discussion-and/commands-command-blocks-and/2724507-1-11-nbt-changes-and-additions#AllTiles
|
||||
static {
|
||||
@ -52,15 +52,15 @@ public class BlockEntityRewriter {
|
||||
}
|
||||
|
||||
private static void rewrite(String oldName, String newName) {
|
||||
oldToNewNames.put(oldName, Key.namespaced(newName));
|
||||
OLD_TO_NEW_NAMES.put(oldName, Key.namespaced(newName));
|
||||
}
|
||||
|
||||
public static BiMap<String, String> inverse() {
|
||||
return oldToNewNames.inverse();
|
||||
return OLD_TO_NEW_NAMES.inverse();
|
||||
}
|
||||
|
||||
public static String toNewIdentifier(String oldId) {
|
||||
String newName = oldToNewNames.get(oldId);
|
||||
String newName = OLD_TO_NEW_NAMES.get(oldId);
|
||||
if (newName != null) {
|
||||
return newName;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public abstract class AbstractFenceConnectionHandler extends ConnectionHandler {
|
||||
Arrays.fill(connectedBlockStates, -1);
|
||||
}
|
||||
|
||||
public ConnectionData.ConnectorInitAction getInitAction(final String key) {
|
||||
ConnectionData.ConnectorInitAction getInitAction(final String key) {
|
||||
final AbstractFenceConnectionHandler handler = this;
|
||||
return blockData -> {
|
||||
if (key.equals(blockData.getMinecraftKey())) {
|
||||
|
@ -38,7 +38,7 @@ public abstract class AbstractStempConnectionHandler extends ConnectionHandler {
|
||||
this.baseStateId = ConnectionData.getId(baseStateId);
|
||||
}
|
||||
|
||||
public ConnectionData.ConnectorInitAction getInitAction(final String blockId, final String toKey) {
|
||||
ConnectionData.ConnectorInitAction getInitAction(final String blockId, final String toKey) {
|
||||
final AbstractStempConnectionHandler handler = this;
|
||||
return blockData -> {
|
||||
if (blockData.getSavedBlockStateId() == baseStateId || blockId.equals(blockData.getMinecraftKey())) {
|
||||
|
@ -39,7 +39,7 @@ public class ChorusPlantConnectionHandler extends AbstractFenceConnectionHandler
|
||||
endstone = ConnectionData.getId("minecraft:end_stone");
|
||||
}
|
||||
|
||||
public ConnectionData.ConnectorInitAction getExtraAction() {
|
||||
private ConnectionData.ConnectorInitAction getExtraAction() {
|
||||
return blockData -> {
|
||||
if (blockData.getMinecraftKey().equals("minecraft:chorus_flower")) {
|
||||
getBlockStates().add(blockData.getSavedBlockStateId());
|
||||
|
@ -59,13 +59,12 @@ public class RedstoneConnectionHandler extends ConnectionHandler {
|
||||
private static int getState(String value) {
|
||||
switch (value) {
|
||||
case "none":
|
||||
default:
|
||||
return 0;
|
||||
case "side":
|
||||
return 1;
|
||||
case "up":
|
||||
return 2;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ public class ParticleRewriter {
|
||||
}
|
||||
|
||||
NewParticle rewrite = particles.get(particleId);
|
||||
return rewrite.handle(new Particle(rewrite.getId()), data);
|
||||
return rewrite.handle(new Particle(rewrite.id()), data);
|
||||
}
|
||||
|
||||
private static void add(int newId) {
|
||||
@ -157,6 +157,7 @@ public class ParticleRewriter {
|
||||
};
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
interface ParticleDataHandler {
|
||||
Particle handler(Particle particle, Integer[] data);
|
||||
}
|
||||
@ -176,11 +177,11 @@ public class ParticleRewriter {
|
||||
return particle;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
public int id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public ParticleDataHandler getHandler() {
|
||||
public ParticleDataHandler handler() {
|
||||
return handler;
|
||||
}
|
||||
}
|
||||
|
@ -31,20 +31,16 @@ public class RecipeData {
|
||||
public static void init() {
|
||||
InputStream stream = MappingData.class.getClassLoader()
|
||||
.getResourceAsStream("assets/viaversion/data/itemrecipes1_12_2to1_13.json");
|
||||
InputStreamReader reader = new InputStreamReader(stream);
|
||||
try {
|
||||
try (InputStreamReader reader = new InputStreamReader(stream)) {
|
||||
recipes = GsonUtil.getGson().fromJson(
|
||||
reader,
|
||||
new TypeToken<Map<String, Recipe>>() {
|
||||
}.getType()
|
||||
);
|
||||
} finally {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException ignored) {
|
||||
// Ignored
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
// Ignored
|
||||
}
|
||||
|
||||
public static class Recipe {
|
||||
|
@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_16to1_15_2.storage;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public class InventoryTracker1_16 implements StorableObject {
|
||||
private boolean inventoryOpen = false;
|
||||
private boolean inventoryOpen;
|
||||
|
||||
public boolean isInventoryOpen() {
|
||||
return inventoryOpen;
|
||||
|
@ -61,7 +61,7 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
||||
}
|
||||
|
||||
public static boolean isTextComponentNull(final JsonElement element) {
|
||||
return element == null || element.isJsonNull() || (element.isJsonArray() && element.getAsJsonArray().size() == 0);
|
||||
return element == null || element.isJsonNull() || (element.isJsonArray() && element.getAsJsonArray().isEmpty());
|
||||
}
|
||||
|
||||
public static JsonElement mapTextComponentIfNull(JsonElement component) {
|
||||
@ -126,9 +126,7 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
||||
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_18.STATISTICS);
|
||||
|
||||
final PacketHandler singleNullTextComponentMapper = wrapper -> {
|
||||
wrapper.write(Type.COMPONENT, mapTextComponentIfNull(wrapper.read(Type.COMPONENT)));
|
||||
};
|
||||
final PacketHandler singleNullTextComponentMapper = wrapper -> wrapper.write(Type.COMPONENT, mapTextComponentIfNull(wrapper.read(Type.COMPONENT)));
|
||||
registerClientbound(ClientboundPackets1_18.TITLE_TEXT, singleNullTextComponentMapper);
|
||||
registerClientbound(ClientboundPackets1_18.TITLE_SUBTITLE, singleNullTextComponentMapper);
|
||||
registerClientbound(ClientboundPackets1_18.ACTIONBAR, singleNullTextComponentMapper);
|
||||
|
@ -98,13 +98,16 @@ public class Protocol1_9To1_8 extends AbstractProtocol<ClientboundPackets1_8, Cl
|
||||
}
|
||||
|
||||
public static boolean isSword(int id) {
|
||||
if (id == 267) return true; // Iron
|
||||
if (id == 268) return true; // Wood
|
||||
if (id == 272) return true; // Stone
|
||||
if (id == 276) return true; // Diamond
|
||||
if (id == 283) return true; // Gold
|
||||
|
||||
return false;
|
||||
switch (id) {
|
||||
case 267: // Iron sword
|
||||
case 268: // Wooden sword
|
||||
case 272: // Stone sword
|
||||
case 276: // Diamond sword
|
||||
case 283: // Gold sword
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,7 +72,7 @@ public class MetadataRewriter1_9To1_8 extends EntityRewriter<ClientboundPackets1
|
||||
}
|
||||
// After writing the last one
|
||||
if (metaIndex == MetaIndex.ENTITY_STATUS && type == EntityTypes1_10.EntityType.PLAYER) {
|
||||
Byte val = 0;
|
||||
byte val = 0;
|
||||
if ((((Byte) value) & 0x10) == 0x10) { // Player eating/aiming/drinking
|
||||
val = 1;
|
||||
}
|
||||
|
@ -253,8 +253,6 @@ public class PlayerPackets {
|
||||
String displayName = wrapper.read(Type.OPTIONAL_STRING);
|
||||
wrapper.write(Type.OPTIONAL_COMPONENT, displayName != null ?
|
||||
Protocol1_9To1_8.FIX_JSON.transform(wrapper, displayName) : null);
|
||||
} else if (action == 4) { // remove player
|
||||
// no fields
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -160,7 +160,7 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
||||
slot = wrapper.passthrough(Type.BYTE);
|
||||
// & 0x7F into an extra variable if slot is needed
|
||||
handleItemToClient(wrapper.passthrough(itemType));
|
||||
} while ((slot & 0xFFFFFF80) != 0);
|
||||
} while (slot < 0);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -76,7 +76,6 @@ public class SpongePlugin implements ViaPlatform<Player> {
|
||||
@ConfigDir(sharedRoot = false)
|
||||
private Path configDir;
|
||||
|
||||
@SuppressWarnings("SpongeInjection")
|
||||
@Inject
|
||||
SpongePlugin(final PluginContainer container, final Game game, final org.apache.logging.log4j.Logger logger) {
|
||||
this.container = container;
|
||||
|
@ -52,7 +52,7 @@ public class SpongeChannelInitializer extends ChannelInitializer<Channel> implem
|
||||
// Ensure ViaVersion is loaded
|
||||
if (Via.getAPI().getServerVersion().isKnown()
|
||||
&& channel instanceof SocketChannel) { // channel can be LocalChannel on internal server
|
||||
UserConnection info = new UserConnectionImpl((SocketChannel) channel);
|
||||
UserConnection info = new UserConnectionImpl(channel);
|
||||
// init protocol
|
||||
new ProtocolPipelineImpl(info);
|
||||
// Add originals
|
||||
|
Loading…
Reference in New Issue
Block a user