Got rid of cancerous Cloneable interface and fixed possible NPE when cloning a Position Keyframe
This commit is contained in:
@@ -50,7 +50,7 @@ public class GuiEditKeyframe extends GuiScreen {
|
|||||||
|
|
||||||
public GuiEditKeyframe(Keyframe keyframe) {
|
public GuiEditKeyframe(Keyframe keyframe) {
|
||||||
this.keyframe = keyframe;
|
this.keyframe = keyframe;
|
||||||
this.keyframeBackup = (Keyframe)keyframe.clone();
|
this.keyframeBackup = keyframe.clone();
|
||||||
this.posKeyframe = keyframe instanceof PositionKeyframe;
|
this.posKeyframe = keyframe instanceof PositionKeyframe;
|
||||||
this.timeKeyframe = keyframe instanceof TimeKeyframe;
|
this.timeKeyframe = keyframe instanceof TimeKeyframe;
|
||||||
this.markerKeyframe = keyframe instanceof MarkerKeyframe;
|
this.markerKeyframe = keyframe instanceof MarkerKeyframe;
|
||||||
@@ -119,7 +119,7 @@ public class GuiEditKeyframe extends GuiScreen {
|
|||||||
inputs.addAll(posInputs);
|
inputs.addAll(posInputs);
|
||||||
} else if(markerKeyframe) {
|
} else if(markerKeyframe) {
|
||||||
markerNameInput = new GuiTextField(GuiConstants.KEYFRAME_REPOSTORY_NAME_INPUT, fontRendererObj, 0, 0, 300, 20);
|
markerNameInput = new GuiTextField(GuiConstants.KEYFRAME_REPOSTORY_NAME_INPUT, fontRendererObj, 0, 0, 300, 20);
|
||||||
markerNameInput.setText(((MarkerKeyframe)keyframe).getName());
|
markerNameInput.setText(((MarkerKeyframe)keyframe).getName() == null ? "" : ((MarkerKeyframe)keyframe).getName());
|
||||||
inputs.add(markerNameInput);
|
inputs.add(markerNameInput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
package eu.crushedpixel.replaymod.holders;
|
||||||
|
|
||||||
public class Keyframe implements Cloneable {
|
public class Keyframe {
|
||||||
|
|
||||||
private int realTimestamp;
|
private int realTimestamp;
|
||||||
|
|
||||||
@Override
|
public Keyframe clone() {
|
||||||
public Object clone() {
|
|
||||||
return new Keyframe(realTimestamp);
|
return new Keyframe(realTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class MarkerKeyframe extends Keyframe {
|
|||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object clone() {
|
public Keyframe clone() {
|
||||||
return new MarkerKeyframe(this.getPosition(), this.getRealTimestamp(), this.getName());
|
return new MarkerKeyframe(this.getPosition(), this.getRealTimestamp(), this.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ public class PositionKeyframe extends Keyframe {
|
|||||||
private Integer spectatedEntityID = null;
|
private Integer spectatedEntityID = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object clone() {
|
public Keyframe clone() {
|
||||||
return new PositionKeyframe(this.getRealTimestamp(), this.getPosition(), this.getSpectatedEntityID());
|
return new PositionKeyframe(getRealTimestamp(), position, spectatedEntityID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PositionKeyframe(int realTime, Position position) {
|
public PositionKeyframe(int realTime, Position position) {
|
||||||
@@ -17,7 +17,7 @@ public class PositionKeyframe extends Keyframe {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PositionKeyframe(int realTime, Position position, int spectatedEntityID) {
|
public PositionKeyframe(int realTime, Position position, Integer spectatedEntityID) {
|
||||||
super(realTime);
|
super(realTime);
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.spectatedEntityID = spectatedEntityID;
|
this.spectatedEntityID = spectatedEntityID;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ public class TimeKeyframe extends Keyframe {
|
|||||||
private final int timestamp;
|
private final int timestamp;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object clone() {
|
public Keyframe clone() {
|
||||||
return new TimeKeyframe(this.getRealTimestamp(), this.getTimestamp());
|
return new TimeKeyframe(this.getRealTimestamp(), this.getTimestamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user