Skip to content

Commit

Permalink
Removed unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Aug 15, 2023
1 parent a6b7ed2 commit 1a77095
Show file tree
Hide file tree
Showing 18 changed files with 86 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import de.gerrygames.viarewind.ViaRewind;
import de.gerrygames.viarewind.protocol.protocol1_7_0_5to1_7_6_10.Protocol1_7_0_5to1_7_6_10;
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10TO1_8;
import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9;
import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9;

import java.util.logging.Logger;

Expand All @@ -46,7 +46,7 @@ default void init(ViaRewindConfig config) {

final ProtocolManager protocolManager = Via.getManager().getProtocolManager();

protocolManager.registerProtocol(new Protocol1_8TO1_9(), ProtocolVersion.v1_8, ProtocolVersion.v1_9);
protocolManager.registerProtocol(new Protocol1_8To1_9(), ProtocolVersion.v1_8, ProtocolVersion.v1_9);
protocolManager.registerProtocol(new Protocol1_7_6_10TO1_8(), ProtocolVersion.v1_7_6, ProtocolVersion.v1_8);
protocolManager.registerProtocol(new Protocol1_7_0_5to1_7_6_10(), ProtocolVersion.v1_7_1, ProtocolVersion.v1_7_6);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage.*;
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10;
import de.gerrygames.viarewind.utils.ChatUtil;
import de.gerrygames.viarewind.utils.PacketUtil;
import de.gerrygames.viarewind.utils.Utils;
import de.gerrygames.viarewind.utils.math.AABB;
import de.gerrygames.viarewind.utils.math.Ray3d;
import de.gerrygames.viarewind.utils.math.RayTracing;
Expand Down Expand Up @@ -509,7 +507,7 @@ public void register() {
TitleRenderProvider titleRenderProvider = Via.getManager().getProviders().get(TitleRenderProvider.class);
if (titleRenderProvider == null) return;
int action = packetWrapper.read(Type.VAR_INT);
UUID uuid = Utils.getUUID(packetWrapper.user());
UUID uuid = packetWrapper.user().getProtocolInfo().getUuid();
switch (action) {
case 0:
titleRenderProvider.setTitle(uuid, packetWrapper.read(Type.STRING));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;

public class Protocol1_8TO1_9 extends AbstractProtocol<ClientboundPackets1_9, ClientboundPackets1_8,
ServerboundPackets1_9, ServerboundPackets1_8> {
public static final Timer TIMER = new Timer("ViaRewind-1_8TO1_9", true);
public class Protocol1_8To1_9 extends AbstractProtocol<ClientboundPackets1_9, ClientboundPackets1_8, ServerboundPackets1_9, ServerboundPackets1_8> {

public Queue<PacketWrapper> animationsToSend = new ConcurrentLinkedQueue<>();

Expand All @@ -64,7 +62,7 @@ public Byte transform(PacketWrapper packetWrapper, Float degrees) throws Excepti
VALID_ATTRIBUTES.add("zombie.spawnReinforcements");
}

public Protocol1_8TO1_9() {
public Protocol1_8To1_9() {
super(ClientboundPackets1_9.class, ClientboundPackets1_8.class, ServerboundPackets1_9.class, ServerboundPackets1_8.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package de.gerrygames.viarewind.protocol.protocol1_8to1_9.bossbar;

import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9;
import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.legacy.bossbar.BossBar;
import com.viaversion.viaversion.api.legacy.bossbar.BossColor;
Expand Down Expand Up @@ -200,7 +200,7 @@ private void spawnWither() {

packetWrapper.write(Types1_8.METADATA_LIST, metadata);

PacketUtil.sendPacket(packetWrapper, Protocol1_8TO1_9.class, true, false);
PacketUtil.sendPacket(packetWrapper, Protocol1_8To1_9.class, true, false);
}

private void updateLocation() {
Expand All @@ -213,7 +213,7 @@ private void updateLocation() {
packetWrapper.write(Type.BYTE, (byte)0);
packetWrapper.write(Type.BOOLEAN, false);

PacketUtil.sendPacket(packetWrapper, Protocol1_8TO1_9.class, true, false);
PacketUtil.sendPacket(packetWrapper, Protocol1_8To1_9.class, true, false);
}

private void updateMetadata() {
Expand All @@ -226,14 +226,14 @@ private void updateMetadata() {

packetWrapper.write(Types1_8.METADATA_LIST, metadata);

PacketUtil.sendPacket(packetWrapper, Protocol1_8TO1_9.class, true, false);
PacketUtil.sendPacket(packetWrapper, Protocol1_8To1_9.class, true, false);
}

private void despawnWither() {
PacketWrapper packetWrapper = PacketWrapper.create(0x13, null, this.connection);
packetWrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[] {entityId});

PacketUtil.sendPacket(packetWrapper, Protocol1_8TO1_9.class, true, false);
PacketUtil.sendPacket(packetWrapper, Protocol1_8To1_9.class, true, false);
}

public void setPlayerLocation(double posX, double posY, double posZ, float yaw, float pitch) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package de.gerrygames.viarewind.protocol.protocol1_8to1_9.entityreplacement;

import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9;
import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
Expand Down Expand Up @@ -53,14 +53,14 @@ protected void sendTeleport(int entityId, double locX, double locY, double locZ,
teleport.write(Type.BYTE, (byte) ((pitch / 360f) * 256));
teleport.write(Type.BOOLEAN, true);

PacketUtil.sendPacket(teleport, Protocol1_8TO1_9.class, true, true);
PacketUtil.sendPacket(teleport, Protocol1_8To1_9.class, true, true);
}

protected void sendHeadYaw(int entityId, float headYaw) {
PacketWrapper head = PacketWrapper.create(ClientboundPackets1_8.ENTITY_HEAD_LOOK, null, user);
head.write(Type.VAR_INT, entityId);
head.write(Type.BYTE, (byte) ((headYaw / 360f) * 256));
PacketUtil.sendPacket(head, Protocol1_8TO1_9.class, true, true);
PacketUtil.sendPacket(head, Protocol1_8To1_9.class, true, true);
}

protected void sendSpawn(int entityId, int type) {
Expand All @@ -79,7 +79,7 @@ protected void sendSpawn(int entityId, int type) {
List<Metadata> list = new ArrayList<>();
spawn.write(Types1_8.METADATA_LIST, list);

PacketUtil.sendPacket(spawn, Protocol1_8TO1_9.class, true, true);
PacketUtil.sendPacket(spawn, Protocol1_8To1_9.class, true, true);
}

protected void sendSpawnEntity(int entityId, int type) {
Expand All @@ -93,6 +93,6 @@ protected void sendSpawnEntity(int entityId, int type) {
spawn.write(Type.BYTE, (byte) 0);
spawn.write(Type.INT, 0);

PacketUtil.sendPacket(spawn, Protocol1_8TO1_9.class, true, true);
PacketUtil.sendPacket(spawn, Protocol1_8To1_9.class, true, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package de.gerrygames.viarewind.protocol.protocol1_8to1_9.entityreplacement;

import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9;
import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
Expand Down Expand Up @@ -88,7 +88,7 @@ public void despawn() {
PacketWrapper despawn = PacketWrapper.create(ClientboundPackets1_8.DESTROY_ENTITIES, null, user);
despawn.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{entityId});

PacketUtil.sendPacket(despawn, Protocol1_8TO1_9.class, true, true);
PacketUtil.sendPacket(despawn, Protocol1_8To1_9.class, true, true);
}

public int getEntityId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package de.gerrygames.viarewind.protocol.protocol1_8to1_9.entityreplacement;

import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9;
import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
Expand Down Expand Up @@ -92,7 +92,7 @@ public void updateMetadata() {

metadataPacket.write(Types1_8.METADATA_LIST, metadataList);

PacketUtil.sendPacket(metadataPacket, Protocol1_8TO1_9.class);
PacketUtil.sendPacket(metadataPacket, Protocol1_8To1_9.class);
}

@Override
Expand All @@ -106,7 +106,7 @@ public void despawn() {
PacketWrapper despawn = PacketWrapper.create(ClientboundPackets1_7.DESTROY_ENTITIES, null, user);
despawn.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{entityId});

PacketUtil.sendPacket(despawn, Protocol1_8TO1_9.class, true, true);
PacketUtil.sendPacket(despawn, Protocol1_8To1_9.class, true, true);
}

public int getEntityId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package de.gerrygames.viarewind.protocol.protocol1_8to1_9.items;

import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9;
import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.*;
import de.gerrygames.viarewind.utils.Enchantments;
Expand Down Expand Up @@ -223,7 +223,7 @@ public static Item toClient(Item item) {
for (int i = 0; i<attributes.size(); i++) {
CompoundTag attribute = attributes.get(i);
String name = (String) attribute.get("AttributeName").getValue();
if (!Protocol1_8TO1_9.VALID_ATTRIBUTES.contains(name)) {
if (!Protocol1_8To1_9.VALID_ATTRIBUTES.contains(name)) {
attributes.remove(attribute);
i--;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package de.gerrygames.viarewind.protocol.protocol1_8to1_9.packets;

import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9;
import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9;
import de.gerrygames.viarewind.protocol.protocol1_8to1_9.metadata.MetadataRewriter;
import de.gerrygames.viarewind.protocol.protocol1_8to1_9.storage.Cooldown;
import de.gerrygames.viarewind.protocol.protocol1_8to1_9.storage.EntityTracker;
Expand Down Expand Up @@ -104,7 +104,7 @@ public void register() {
secondPacket.write(Type.BYTE, (byte) moves[1].blockZ());
secondPacket.write(Type.BOOLEAN, onGround);

PacketUtil.sendPacket(secondPacket, Protocol1_8TO1_9.class);
PacketUtil.sendPacket(secondPacket, Protocol1_8To1_9.class);
}
});
}
Expand Down Expand Up @@ -156,7 +156,7 @@ public void register() {
secondPacket.write(Type.BYTE, pitch);
secondPacket.write(Type.BOOLEAN, onGround);

PacketUtil.sendPacket(secondPacket, Protocol1_8TO1_9.class);
PacketUtil.sendPacket(secondPacket, Protocol1_8To1_9.class);
}
});
}
Expand Down Expand Up @@ -205,11 +205,11 @@ public void register() {
if (vehicle == -1) packetWrapper.cancel();
packetWrapper.write(Type.VAR_INT, vehicle);
});
map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT);
map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT);
map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT);
map(Type.FLOAT, Protocol1_8TO1_9.DEGREES_TO_ANGLE);
map(Type.FLOAT, Protocol1_8TO1_9.DEGREES_TO_ANGLE);
map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT);
map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT);
map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT);
map(Type.FLOAT, Protocol1_8To1_9.DEGREES_TO_ANGLE);
map(Type.FLOAT, Protocol1_8To1_9.DEGREES_TO_ANGLE);
handler(packetWrapper -> {
if (packetWrapper.isCancelled()) return;
PlayerPosition position = packetWrapper.user().get(PlayerPosition.class);
Expand Down Expand Up @@ -359,7 +359,7 @@ public void register() {
detach.write(Type.INT, passenger);
detach.write(Type.INT, -1);
detach.write(Type.BOOLEAN, false);
PacketUtil.sendPacket(detach, Protocol1_8TO1_9.class);
PacketUtil.sendPacket(detach, Protocol1_8To1_9.class);
}
}
for (int i = 0; i < count; i++) {
Expand All @@ -369,7 +369,7 @@ public void register() {
attach.write(Type.INT, p);
attach.write(Type.INT, v);
attach.write(Type.BOOLEAN, false);
PacketUtil.sendPacket(attach, Protocol1_8TO1_9.class);
PacketUtil.sendPacket(attach, Protocol1_8To1_9.class);
}
});
}
Expand All @@ -382,9 +382,9 @@ public void register() {
@Override
public void register() {
map(Type.VAR_INT);
map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT);
map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT);
map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT);
map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT);
map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT);
map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT);
map(Type.BYTE);
map(Type.BYTE);
map(Type.BOOLEAN);
Expand Down Expand Up @@ -434,7 +434,7 @@ public void register() {
int removed = 0;
for (int i = 0; i < size; i++) {
String key = packetWrapper.read(Type.STRING);
boolean skip = !Protocol1_8TO1_9.VALID_ATTRIBUTES.contains(key);
boolean skip = !Protocol1_8To1_9.VALID_ATTRIBUTES.contains(key);
double value = packetWrapper.read(Type.DOUBLE);
int modifiersize = packetWrapper.read(Type.VAR_INT);
if (!skip) {
Expand Down
Loading

0 comments on commit 1a77095

Please sign in to comment.