Fix all warnings
Add and make use of Lombok Remove Mojang API Remove ZipFileUtils Remove StreamTools in favor of Apache IOUtils Keyframe should be abstract all derivatives final Replace clone in Keyframe with copy Move some constants from GuiReplaySetttings to GuiConstants
This commit is contained in:
@@ -1,33 +1,15 @@
|
||||
package eu.crushedpixel.replaymod.holders;
|
||||
|
||||
public class Keyframe {
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode
|
||||
@AllArgsConstructor
|
||||
public abstract class Keyframe {
|
||||
|
||||
private int realTimestamp;
|
||||
|
||||
public Keyframe clone() {
|
||||
return new Keyframe(realTimestamp);
|
||||
}
|
||||
|
||||
public Keyframe(int realTimestamp) {
|
||||
this.realTimestamp = realTimestamp;
|
||||
}
|
||||
|
||||
public int getRealTimestamp() {
|
||||
return realTimestamp;
|
||||
}
|
||||
|
||||
public void setRealTimestamp(int realTimestamp) { this.realTimestamp = realTimestamp; }
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o2) {
|
||||
if(o2 == null) return false;
|
||||
if(!(o2 instanceof Keyframe)) return false;
|
||||
Keyframe kf = (Keyframe)o2;
|
||||
return hashCode() == kf.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return realTimestamp;
|
||||
}
|
||||
public abstract Keyframe copy();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package eu.crushedpixel.replaymod.holders;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class KeyframeSet {
|
||||
@@ -40,8 +41,8 @@ public class KeyframeSet {
|
||||
|
||||
public Keyframe[] getKeyframes() {
|
||||
List<Keyframe> kfList = new ArrayList<Keyframe>();
|
||||
for(Keyframe kf : positionKeyframes) kfList.add(kf);
|
||||
for(Keyframe kf : timeKeyframes) kfList.add(kf);
|
||||
Collections.addAll(kfList, positionKeyframes);
|
||||
Collections.addAll(kfList, timeKeyframes);
|
||||
return kfList.toArray(new Keyframe[kfList.size()]);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,49 +1,23 @@
|
||||
package eu.crushedpixel.replaymod.holders;
|
||||
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
public class MarkerKeyframe extends Keyframe {
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class MarkerKeyframe extends Keyframe {
|
||||
|
||||
private Position position;
|
||||
private String name;
|
||||
|
||||
@Override
|
||||
public Keyframe clone() {
|
||||
return new MarkerKeyframe(this.getPosition(), this.getRealTimestamp(), this.getName());
|
||||
}
|
||||
|
||||
public MarkerKeyframe(Position position, int timestamp, String name) {
|
||||
super(timestamp);
|
||||
this.position = position;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Position getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o2) {
|
||||
if(o2 == null) return false;
|
||||
if(!(o2 instanceof MarkerKeyframe)) return false;
|
||||
MarkerKeyframe m2 = (MarkerKeyframe)o2;
|
||||
return hashCode() == m2.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder(17, 37)
|
||||
.append(position)
|
||||
.append(getRealTimestamp())
|
||||
.append(name)
|
||||
.toHashCode();
|
||||
public Keyframe copy() {
|
||||
return new MarkerKeyframe(position, getRealTimestamp(), name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,11 @@
|
||||
package eu.crushedpixel.replaymod.holders;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class PacketData {
|
||||
|
||||
private byte[] array;
|
||||
private byte[] byteArray;
|
||||
private int timestamp;
|
||||
|
||||
public PacketData(byte[] array, int timestamp) {
|
||||
this.array = array;
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public byte[] getByteArray() {
|
||||
return array;
|
||||
}
|
||||
|
||||
public void setByteArray(byte[] array) {
|
||||
this.array = array;
|
||||
}
|
||||
|
||||
public int getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(int timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
package eu.crushedpixel.replaymod.holders;
|
||||
|
||||
import java.util.Collection;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class PlayerVisibility {
|
||||
|
||||
public PlayerVisibility(Collection<UUID> hidden) {
|
||||
this.hidden = hidden.toArray(new UUID[hidden.size()]);
|
||||
}
|
||||
|
||||
private UUID[] hidden;
|
||||
|
||||
public UUID[] getHiddenPlayers() {
|
||||
return hidden;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package eu.crushedpixel.replaymod.holders;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class Position {
|
||||
|
||||
private double x, y, z;
|
||||
@@ -14,103 +17,17 @@ public class Position {
|
||||
}
|
||||
|
||||
public Position(Entity e) {
|
||||
this.x = e.posX;
|
||||
this.y = e.posY;
|
||||
this.z = e.posZ;
|
||||
this.pitch = e.rotationPitch;
|
||||
this.yaw = e.rotationYaw;
|
||||
}
|
||||
|
||||
public Position(double x, double y, double z, float pitch, float yaw, float roll) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.pitch = pitch;
|
||||
this.yaw = yaw;
|
||||
this.roll = roll;
|
||||
this(e.posX, e.posY, e.posZ, e.rotationPitch, e.rotationYaw);
|
||||
}
|
||||
|
||||
public Position(double x, double y, double z, float pitch, float yaw) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.pitch = pitch;
|
||||
this.yaw = yaw;
|
||||
this(x, y, z, pitch, yaw, 0);
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setZ(double z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public float getPitch() {
|
||||
return pitch;
|
||||
}
|
||||
|
||||
public void setPitch(float pitch) {
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
public float getYaw() {
|
||||
return yaw;
|
||||
}
|
||||
|
||||
public void setYaw(float yaw) {
|
||||
this.yaw = yaw;
|
||||
}
|
||||
|
||||
public float getRoll() { return roll; }
|
||||
|
||||
public void setRoll(float roll) { this.roll = roll; }
|
||||
|
||||
public double distanceSquared(double x, double y, double z) {
|
||||
double dx = this.x - x;
|
||||
double dy = this.y - y;
|
||||
double dz = this.z - z;
|
||||
return dx * dx + dy * dy + dz * dz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "X=" + x + ", Y=" + y + ", Z=" + z + ", Yaw=" + yaw + ", Pitch=" + pitch + ", Roll="+roll;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o2) {
|
||||
if(o2 == null) return false;
|
||||
if(!(o2 instanceof Position)) return false;
|
||||
Position pos2 = (Position)o2;
|
||||
return hashCode() == pos2.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder(17, 37)
|
||||
.append(x)
|
||||
.append(y)
|
||||
.append(z)
|
||||
.append(pitch)
|
||||
.append(yaw)
|
||||
.append(roll)
|
||||
.toHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
package eu.crushedpixel.replaymod.holders;
|
||||
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
public class PositionKeyframe extends Keyframe {
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class PositionKeyframe extends Keyframe {
|
||||
|
||||
private Position position;
|
||||
private Integer spectatedEntityID = null;
|
||||
|
||||
@Override
|
||||
public Keyframe clone() {
|
||||
return new PositionKeyframe(getRealTimestamp(), position, spectatedEntityID);
|
||||
}
|
||||
private Integer spectatedEntityID;
|
||||
|
||||
public PositionKeyframe(int realTime, Position position) {
|
||||
super(realTime);
|
||||
this.position = position;
|
||||
this(realTime, position, null);
|
||||
}
|
||||
|
||||
public PositionKeyframe(int realTime, Position position, Integer spectatedEntityID) {
|
||||
@@ -27,28 +24,8 @@ public class PositionKeyframe extends Keyframe {
|
||||
this(realTime, new Position(spectatedEntityID), spectatedEntityID);
|
||||
}
|
||||
|
||||
public Position getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setPosition(Position position) { this.position = position; }
|
||||
|
||||
public Integer getSpectatedEntityID() { return spectatedEntityID; }
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o2) {
|
||||
if(o2 == null) return false;
|
||||
if(!(o2 instanceof PositionKeyframe)) return false;
|
||||
PositionKeyframe kf = (PositionKeyframe)o2;
|
||||
return hashCode() == kf.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder(17, 37)
|
||||
.append(getPosition())
|
||||
.append(getRealTimestamp())
|
||||
.append(getSpectatedEntityID())
|
||||
.toHashCode();
|
||||
public Keyframe copy() {
|
||||
return new PositionKeyframe(getRealTimestamp(), position, spectatedEntityID);
|
||||
}
|
||||
}
|
||||
@@ -1,38 +1,21 @@
|
||||
package eu.crushedpixel.replaymod.holders;
|
||||
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
public class TimeKeyframe extends Keyframe {
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class TimeKeyframe extends Keyframe {
|
||||
|
||||
private final int timestamp;
|
||||
|
||||
@Override
|
||||
public Keyframe clone() {
|
||||
return new TimeKeyframe(this.getRealTimestamp(), this.getTimestamp());
|
||||
}
|
||||
|
||||
public TimeKeyframe(int realTime, int timestamp) {
|
||||
super(realTime);
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public int getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o2) {
|
||||
if(o2 == null) return false;
|
||||
if(!(o2 instanceof TimeKeyframe)) return false;
|
||||
TimeKeyframe kf = (TimeKeyframe)o2;
|
||||
return hashCode() == kf.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder(17, 37)
|
||||
.append(getTimestamp())
|
||||
.append(getRealTimestamp())
|
||||
.toHashCode();
|
||||
public Keyframe copy() {
|
||||
return new TimeKeyframe(getRealTimestamp(), getTimestamp());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user