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:
johni0702
2015-06-29 21:45:37 +02:00
parent 3122c0a71e
commit a058497727
110 changed files with 487 additions and 1921 deletions

View File

@@ -5,22 +5,10 @@ import net.minecraft.client.gui.GuiButton;
public class GuiAdvancedButton extends GuiButton implements GuiElement {
public GuiAdvancedButton(int x, int y, String buttonText) {
this(0, x, y, buttonText);
}
public GuiAdvancedButton(int x, int y, int widthIn, int heightIn, String buttonText) {
this(0, x, y, widthIn, heightIn, buttonText);
}
public GuiAdvancedButton(int id, int x, int y, String buttonText) {
super(id, x, y, buttonText);
}
public GuiAdvancedButton(int id, int x, int y, int widthIn, int heightIn, String buttonText) {
super(id, x, y, widthIn, heightIn, buttonText);
}
@Override
public void draw(Minecraft mc, int mouseX, int mouseY) {
drawButton(mc, mouseX, mouseY);

View File

@@ -8,7 +8,7 @@ import java.awt.*;
public class GuiArrowButton extends GuiButton {
public enum Direction {
UP, DOWN, RIGHT, LEFT;
UP, DOWN, RIGHT, LEFT
}
private Direction dir;

View File

@@ -134,11 +134,11 @@ public class GuiDropdown<T> extends GuiTextField {
@Override
public void mouseClicked(int xPos, int yPos, int mouseButton) {
mouseClickedResult(xPos, yPos, mouseButton);
mouseClickedResult(xPos, yPos);
}
public boolean mouseClickedResult(int xPos, int yPos, int mouseButton) {
public boolean mouseClickedResult(int xPos, int yPos) {
boolean success = false;
if(xPos > xPosition + width - height && xPos < xPosition + width && yPos > yPosition && yPos < yPosition + height) {
open = !open;
@@ -146,8 +146,7 @@ public class GuiDropdown<T> extends GuiTextField {
if(xPos > xPosition && xPos < xPosition + width && open) {
int requiredHeight = Math.min(maxDropoutHeight, elements.size() * dropoutElementHeight);
if(yPos > yPosition + height && yPos < yPosition + height + requiredHeight) {
int clickedIndex = (int) Math.floor((yPos - (yPosition + height)) / dropoutElementHeight) + upperIndex;
this.selectionIndex = clickedIndex;
this.selectionIndex = (int) Math.floor((yPos - (yPosition + height)) / dropoutElementHeight) + upperIndex;
success = true;
fireSelectionChangeEvent();
}
@@ -217,10 +216,6 @@ public class GuiDropdown<T> extends GuiTextField {
this.selectionListeners.add(listener);
}
public void removeSelectionListener(SelectionListener listener) {
this.selectionListeners.remove(listener);
}
public boolean isExpanded() {
return open;
}

View File

@@ -118,11 +118,6 @@ public class GuiEntryList<T> extends GuiTextField {
}
}
public void clearElements() {
this.elements = new ArrayList<T>();
selectionIndex = -1;
}
public void addElement(T element) {
this.elements.add(element);
if(selectionIndex == -1) {
@@ -172,8 +167,4 @@ public class GuiEntryList<T> extends GuiTextField {
this.selectionListeners.add(listener);
}
public void removeSelectionListener(SelectionListener listener) {
this.selectionListeners.remove(listener);
}
}

View File

@@ -185,11 +185,8 @@ public class GuiKeyframeTimeline extends GuiTimeline {
//Draw Keyframe logos
ListIterator<Keyframe> iterator = ReplayHandler.getKeyframes().listIterator();
while(iterator.hasNext()) {
Keyframe kf = iterator.next();
if(kf != null && !kf.equals(ReplayHandler.getSelectedKeyframe()))
for (Keyframe kf : ReplayHandler.getKeyframes()) {
if (kf != null && !kf.equals(ReplayHandler.getSelectedKeyframe()))
drawKeyframe(kf, bodyWidth, leftTime, rightTime, segmentLength);
}

View File

@@ -8,7 +8,6 @@ import java.awt.*;
public class GuiLoadingListEntry implements IGuiListEntry {
boolean registered = false;
private final Minecraft mc = Minecraft.getMinecraft();
private final String message = I18n.format("replaymod.gui.loading")+"...";

View File

@@ -26,7 +26,7 @@ public class GuiNumberInput extends GuiTextField {
public GuiNumberInput(int id, FontRenderer fontRenderer,
int xPos, int yPos, int width, int minimum, int maximum, int defaultValue, boolean acceptFloats) {
this(id, fontRenderer, xPos, yPos, width, new Double(minimum), new Double(maximum), new Double(defaultValue), acceptFloats);
this(id, fontRenderer, xPos, yPos, width, (double) minimum, (double) maximum, (double) defaultValue, acceptFloats);
}
@Override
@@ -42,15 +42,12 @@ public class GuiNumberInput extends GuiTextField {
} else {
val = Integer.valueOf(getText());
}
if(minimum != null && val < minimum) {
setText(acceptFloats ? minimum.toString() : new Integer((int)Math.round(minimum)).toString());
return;
}
if(maximum != null && val > maximum) {
setText(acceptFloats ? maximum.toString() : new Integer((int)Math.round(maximum)).toString());
return;
}
if(minimum != null && val < minimum) {
setText(acceptFloats ? minimum.toString() : Integer.toString((int) Math.round(minimum)));
} else if(maximum != null && val > maximum) {
setText(acceptFloats ? maximum.toString() : Integer.toString((int) Math.round(maximum)));
}
} catch(NumberFormatException e) {
setText(textBefore);
setCursorPosition(cursorPositionBefore);
@@ -81,12 +78,4 @@ public class GuiNumberInput extends GuiTextField {
}
}
public Double getPreciseValueNullable() {
try {
return Double.valueOf(getText());
} catch(Exception e) {
return null;
}
}
}

View File

@@ -6,10 +6,6 @@ public class GuiOnOffButton extends GuiToggleButton {
private static final String[] values = new String[] {I18n.format("options.on"), I18n.format("options.off")};
public GuiOnOffButton(int buttonId, int x, int y, String buttonText) {
super(buttonId, x, y, buttonText, values);
}
public GuiOnOffButton(int buttonId, int x, int y, int width, int height, String buttonText) {
super(buttonId, x, y, width, height, buttonText, values);
}

View File

@@ -29,7 +29,6 @@ public class GuiReplayListEntry implements IGuiListEntry {
private ResourceLocation textureResource;
private DynamicTexture dynTex = null;
private File imageFile;
private BufferedImage image = null;
private GuiReplayListExtended parent;
public GuiReplayListEntry(GuiReplayListExtended parent, FileInfo fileInfo, File imageFile) {
@@ -60,13 +59,13 @@ public class GuiReplayListEntry implements IGuiListEntry {
registered = false;
ResourceHelper.freeResource(textureResource);
textureResource = null;
image = null;
dynTex = null;
}
return;
} else {
if(!registered) {
textureResource = new ResourceLocation("thumbs/" + fileInfo.getName() + fileInfo.getId());
BufferedImage image;
if(imageFile == null) {
image = ResourceHelper.getDefaultThumbnail();
} else {
@@ -122,7 +121,9 @@ public class GuiReplayListEntry implements IGuiListEntry {
if(online) {
Category category = Category.fromId(fileInfo.getCategory());
if (category == null) {
category = Category.MISCELLANEOUS;
}
mc.fontRendererObj.drawStringWithShadow(ChatFormatting.ITALIC.toString()+category.toNiceString(), x + 3, y + slotHeight - mc.fontRendererObj.FONT_HEIGHT, Color.GRAY.getRGB());
}

View File

@@ -11,7 +11,7 @@ public class GuiSettingsOnOffButton extends GuiOnOffButton {
super(buttonId, x, y, width, height, toChange.getName()+": ");
this.toChange = toChange;
if(toChange.getValue() instanceof Boolean) {
this.setValue((Boolean) toChange.getValue() == true ? 0 : 1);
this.setValue((Boolean) toChange.getValue() ? 0 : 1);
}
}
@@ -19,7 +19,7 @@ public class GuiSettingsOnOffButton extends GuiOnOffButton {
super(buttonId, x, y, width, height, toChange.getName()+": ", onValue, offValue);
this.toChange = toChange;
if(toChange.getValue() instanceof Boolean) {
this.setValue((Boolean) toChange.getValue() == true ? 0 : 1);
this.setValue((Boolean) toChange.getValue() ? 0 : 1);
}
}

View File

@@ -16,11 +16,6 @@ public class GuiTexturedButton extends GuiButton implements GuiElement {
private final Runnable action;
private final String hoverText;
public GuiTexturedButton(int buttonId, int x, int y, int width, int height, ResourceLocation texture,
int u, int v, int textureWidth, int textureHeight, Runnable action) {
this(buttonId, x, y, width, height, texture, u, v, textureWidth, textureHeight, action, null);
}
public GuiTexturedButton(int buttonId, int x, int y, int width, int height, ResourceLocation texture,
int u, int v, int textureWidth, int textureHeight, Runnable action, String hoverText) {
super(buttonId, x, y, width, height, "");

View File

@@ -212,7 +212,6 @@ public class GuiTimeline extends Gui implements GuiElement {
int distance;
int smallDistance;
int maximum = 10;
MarkerType(int minimum, int smallDistance) {
this.distance = minimum;