aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-10-16 15:50:41 -0400
committerGitHub <noreply@github.com>2021-10-16 15:50:41 -0400
commit7c00af18febf6c0b833c7633b4fb60a9a1bb93af (patch)
treef02de145362d6a1399651ade4a130d565d7f0ba3 /src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java
parentb11742988dec635b5c5da7c2363803cbfafb37b1 (diff)
downloadnotenoughupdates-7c00af18febf6c0b833c7633b4fb60a9a1bb93af.tar.gz
notenoughupdates-7c00af18febf6c0b833c7633b4fb60a9a1bb93af.tar.bz2
notenoughupdates-7c00af18febf6c0b833c7633b4fb60a9a1bb93af.zip
Code Clean Up (#2)
* intellij code clean up * optimize imports * format * intellij suggestions * fix empty catch issues
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java243
1 files changed, 119 insertions, 124 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java
index 4bbcdbdd..6ba0b34b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java
@@ -5,17 +5,14 @@ import com.google.common.collect.Lists;
import com.google.gson.*;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger;
-import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
@@ -34,8 +31,6 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_tex;
-
public class GuiEnchantColour extends GuiScreen {
public static final ResourceLocation custom_ench_colour = new ResourceLocation("notenoughupdates:custom_ench_colour.png");
@@ -51,34 +46,34 @@ public class GuiEnchantColour extends GuiScreen {
public static final Splitter splitter = Splitter.on(":").limit(5);
- private HashMap<Integer, String> comparators = new HashMap<>();
- private HashMap<Integer, String> modifiers = new HashMap<>();
- private List<GuiElementTextField[]> guiElementTextFields = new ArrayList<>();
+ private final HashMap<Integer, String> comparators = new HashMap<>();
+ private final HashMap<Integer, String> modifiers = new HashMap<>();
+ private final List<GuiElementTextField[]> guiElementTextFields = new ArrayList<>();
private List<String> enchantNamesPretty = null;
- private JsonArray enchantPresets = null;
+ private final JsonArray enchantPresets = null;
- private LerpingInteger scroll = new LerpingInteger(0, 100);
- private LerpingInteger scrollSideBar = new LerpingInteger(0, 100);
+ private final LerpingInteger scroll = new LerpingInteger(0, 100);
+ private final LerpingInteger scrollSideBar = new LerpingInteger(0, 100);
public static int BOLD_MODIFIER = 0b1;
public static int ITALIC_MODIFIER = 0b10;
public static int OBFUSCATED_MODIFIER = 0b100;
public static int UNDERLINE_MODIFIER = 0b1000;
public static int STRIKETHROUGH_MODIFIER = 0b10000;
- private Gson gson = new Gson();
+ private final Gson gson = new Gson();
private static final Pattern settingPattern = Pattern.compile(".*:[>=<]:[0-9]+:[a-zA-Z0-9]+(:[a-zA-Z0-9])?");
private List<String> getEnchantNamesPretty() {
- if(enchantNamesPretty == null) {
+ if (enchantNamesPretty == null) {
JsonObject enchantsJson = Constants.ENCHANTS;
- if(!enchantsJson.has("enchants_pretty")) {
+ if (!enchantsJson.has("enchants_pretty")) {
return Lists.newArrayList("ERROR");
} else {
JsonArray pretty = enchantsJson.getAsJsonArray("enchants_pretty");
enchantNamesPretty = new ArrayList<>();
- for(int i=0; i<pretty.size(); i++) {
+ for (int i = 0; i < pretty.size(); i++) {
enchantNamesPretty.add(pretty.get(i).getAsString());
}
}
@@ -96,11 +91,10 @@ public class GuiEnchantColour extends GuiScreen {
List<String> enchantColours = getEnchantColours();
- ySize = 53+25*enchantColours.size();
- guiLeft = (width-xSize)/2;
-
+ ySize = 53 + 25 * enchantColours.size();
+ guiLeft = (width - xSize) / 2;
- if(ySize > height) {
+ if (ySize > height) {
if (scroll.getTarget() > 0) {
scroll.setTarget(0);
@@ -111,28 +105,28 @@ public class GuiEnchantColour extends GuiScreen {
guiTop = scroll.getValue();
} else {
- guiTop = (height-ySize)/2;
+ guiTop = (height - ySize) / 2;
scroll.setValue(0);
scroll.resetTimer();
}
Minecraft.getMinecraft().getTextureManager().bindTexture(custom_ench_colour);
- Utils.drawTexturedRect(guiLeft, guiTop, xSize, 21, 0, 1, 0, 21/78f, GL11.GL_NEAREST);
- Utils.drawTexturedRect(guiLeft, guiTop+ySize-32, xSize, 32, 0, 1, 46/78f, 1, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(guiLeft, guiTop, xSize, 21, 0, 1, 0, 21 / 78f, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(guiLeft, guiTop + ySize - 32, xSize, 32, 0, 1, 46 / 78f, 1, GL11.GL_NEAREST);
- fontRendererObj.drawString("Ench Name", guiLeft+10, guiTop+7, 4210752);
- fontRendererObj.drawString("CMP", guiLeft+86, guiTop+7, 4210752);
- fontRendererObj.drawString("LVL", guiLeft+111, guiTop+7, 4210752);
- fontRendererObj.drawString("COL", guiLeft+136, guiTop+7, 4210752);
- fontRendererObj.drawString("DEL", guiLeft+161, guiTop+7, 4210752);
+ fontRendererObj.drawString("Ench Name", guiLeft + 10, guiTop + 7, 4210752);
+ fontRendererObj.drawString("CMP", guiLeft + 86, guiTop + 7, 4210752);
+ fontRendererObj.drawString("LVL", guiLeft + 111, guiTop + 7, 4210752);
+ fontRendererObj.drawString("COL", guiLeft + 136, guiTop + 7, 4210752);
+ fontRendererObj.drawString("DEL", guiLeft + 161, guiTop + 7, 4210752);
- Utils.drawStringCentered("Add Ench Colour", fontRendererObj, guiLeft+xSize/2+1, guiTop+ySize-20, false, 4210752);
+ Utils.drawStringCentered("Add Ench Colour", fontRendererObj, guiLeft + xSize / 2 + 1, guiTop + ySize - 20, false, 4210752);
int yIndex = 0;
- for(String str : enchantColours) {
+ for (String str : enchantColours) {
Minecraft.getMinecraft().getTextureManager().bindTexture(custom_ench_colour);
GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft, guiTop+21+yIndex*25, xSize, 25, 0, 1, 21/78f, 46/78f, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(guiLeft, guiTop + 21 + yIndex * 25, xSize, 25, 0, 1, 21 / 78f, 46 / 78f, GL11.GL_NEAREST);
List<String> colourOps = splitter.splitToList(str);
String enchantName = getColourOpIndex(colourOps, 0);
@@ -142,24 +136,24 @@ public class GuiEnchantColour extends GuiScreen {
String modifier = getColourOpIndex(colourOps, 4);
modifiers.put(yIndex, modifier);
- if(colourCode.length() > 1) colourCode = String.valueOf(colourCode.toLowerCase().charAt(0));
- if(comparator.length() > 1) comparator = String.valueOf(comparator.toLowerCase().charAt(0));
+ if (colourCode.length() > 1) colourCode = String.valueOf(colourCode.toLowerCase().charAt(0));
+ if (comparator.length() > 1) comparator = String.valueOf(comparator.toLowerCase().charAt(0));
- Utils.drawStringCentered(comparator, fontRendererObj, guiLeft+96, guiTop+33+25*yIndex, false, 4210752);
+ Utils.drawStringCentered(comparator, fontRendererObj, guiLeft + 96, guiTop + 33 + 25 * yIndex, false, 4210752);
- if(guiElementTextFields.size() <= yIndex) {
+ if (guiElementTextFields.size() <= yIndex) {
guiElementTextFields.add(new GuiElementTextField[3]);
}
- if(guiElementTextFields.get(yIndex)[0] == null) {
+ if (guiElementTextFields.get(yIndex)[0] == null) {
guiElementTextFields.get(yIndex)[0] = new GuiElementTextField(enchantName, GuiElementTextField.SCALE_TEXT);
guiElementTextFields.get(yIndex)[0].setSize(75, 20);
}
- if(guiElementTextFields.get(yIndex)[1] == null) {
+ if (guiElementTextFields.get(yIndex)[1] == null) {
guiElementTextFields.get(yIndex)[1] = new GuiElementTextField(comparison,
- GuiElementTextField.SCALE_TEXT|GuiElementTextField.NUM_ONLY|GuiElementTextField.NO_SPACE);
+ GuiElementTextField.SCALE_TEXT | GuiElementTextField.NUM_ONLY | GuiElementTextField.NO_SPACE);
guiElementTextFields.get(yIndex)[1].setSize(20, 20);
}
- if(guiElementTextFields.get(yIndex)[2] == null) {
+ if (guiElementTextFields.get(yIndex)[2] == null) {
guiElementTextFields.get(yIndex)[2] = new GuiElementTextField(colourCode, GuiElementTextField.SCALE_TEXT);
guiElementTextFields.get(yIndex)[2].setSize(20, 20);
}
@@ -168,22 +162,22 @@ public class GuiEnchantColour extends GuiScreen {
comparators.put(yIndex, comparator);
guiElementTextFields.get(yIndex)[2].setText(colourCode);
- guiElementTextFields.get(yIndex)[0].render(guiLeft+7, guiTop+23+25*yIndex);
- guiElementTextFields.get(yIndex)[1].render(guiLeft+110, guiTop+23+25*yIndex);
- guiElementTextFields.get(yIndex)[2].render(guiLeft+135, guiTop+23+25*yIndex);
+ guiElementTextFields.get(yIndex)[0].render(guiLeft + 7, guiTop + 23 + 25 * yIndex);
+ guiElementTextFields.get(yIndex)[1].render(guiLeft + 110, guiTop + 23 + 25 * yIndex);
+ guiElementTextFields.get(yIndex)[2].render(guiLeft + 135, guiTop + 23 + 25 * yIndex);
int modifierI = getIntModifier(modifier);
- if((modifierI & GuiEnchantColour.BOLD_MODIFIER) != 0) {
- Minecraft.getMinecraft().fontRendererObj.drawString("\u00a7l\u2713", guiLeft+181, guiTop+23+25*yIndex-2, 0xff202020, true);
+ if ((modifierI & GuiEnchantColour.BOLD_MODIFIER) != 0) {
+ Minecraft.getMinecraft().fontRendererObj.drawString("\u00a7l\u2713", guiLeft + 181, guiTop + 23 + 25 * yIndex - 2, 0xff202020, true);
}
- if((modifierI & GuiEnchantColour.ITALIC_MODIFIER) != 0) {
- Minecraft.getMinecraft().fontRendererObj.drawString("\u00a7l\u2713", guiLeft+181, guiTop+23+25*yIndex+10, 0xff202020, true);
+ if ((modifierI & GuiEnchantColour.ITALIC_MODIFIER) != 0) {
+ Minecraft.getMinecraft().fontRendererObj.drawString("\u00a7l\u2713", guiLeft + 181, guiTop + 23 + 25 * yIndex + 10, 0xff202020, true);
}
- if((modifierI & GuiEnchantColour.UNDERLINE_MODIFIER) != 0) {
- Minecraft.getMinecraft().fontRendererObj.drawString("\u00a7l\u2713", guiLeft+196, guiTop+23+25*yIndex-2, 0xff202020, true);
+ if ((modifierI & GuiEnchantColour.UNDERLINE_MODIFIER) != 0) {
+ Minecraft.getMinecraft().fontRendererObj.drawString("\u00a7l\u2713", guiLeft + 196, guiTop + 23 + 25 * yIndex - 2, 0xff202020, true);
}
- if((modifierI & GuiEnchantColour.STRIKETHROUGH_MODIFIER) != 0) {
- Minecraft.getMinecraft().fontRendererObj.drawString("\u00a7l\u2713", guiLeft+196, guiTop+23+25*yIndex+10, 0xff202020, true);
+ if ((modifierI & GuiEnchantColour.STRIKETHROUGH_MODIFIER) != 0) {
+ Minecraft.getMinecraft().fontRendererObj.drawString("\u00a7l\u2713", guiLeft + 196, guiTop + 23 + 25 * yIndex + 10, 0xff202020, true);
}
yIndex++;
@@ -191,10 +185,10 @@ public class GuiEnchantColour extends GuiScreen {
renderSideBar(mouseX, mouseY, partialTicks);
}
- private void renderSideBar(int mouseX, int mouseY, float partialTicks){
- ySizeSidebar = 24*(2);
+ private void renderSideBar(int mouseX, int mouseY, float partialTicks) {
+ ySizeSidebar = 24 * (2);
- if(ySizeSidebar > height) {
+ if (ySizeSidebar > height) {
if (scrollSideBar.getTarget() > 0) {
scrollSideBar.setTarget(0);
@@ -206,52 +200,52 @@ public class GuiEnchantColour extends GuiScreen {
guiTopSidebar = scrollSideBar.getValue();
} else {
- guiTopSidebar = (height-ySizeSidebar)/2;
+ guiTopSidebar = (height - ySizeSidebar) / 2;
scrollSideBar.setValue(0);
scrollSideBar.resetTimer();
}
Minecraft.getMinecraft().getTextureManager().bindTexture(custom_ench_colour);
GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft+xSize+3, guiTopSidebar+2, 88, 20, 64/217f, 152/217f, 48/78f, 68/78f, GL11.GL_NEAREST);
- Utils.drawTexturedRect(guiLeft+xSize+3, guiTopSidebar+2+24, 88, 20, 64/217f, 152/217f, 48/78f, 68/78f, GL11.GL_NEAREST);
- Utils.drawTexturedRect(guiLeft+xSize+3, guiTopSidebar+2+24*2, 88, 20, 64/217f, 152/217f, 48/78f, 68/78f, GL11.GL_NEAREST);
- Utils.drawStringCenteredScaledMaxWidth("Load preset", fontRendererObj, guiLeft+xSize+4+44, guiTopSidebar+8, false, 86, 4210752);
- Utils.drawStringCenteredScaledMaxWidth("from Clipboard", fontRendererObj, guiLeft+xSize+4+44, guiTopSidebar+16, false, 86, 4210752);
- Utils.drawStringCenteredScaledMaxWidth("Save preset", fontRendererObj, guiLeft+xSize+4+44, guiTopSidebar+8+24, false, 86, 4210752);
- Utils.drawStringCenteredScaledMaxWidth("to Clipboard", fontRendererObj, guiLeft+xSize+4+44, guiTopSidebar+16+24, false, 86, 4210752);
- Utils.drawStringCenteredScaledMaxWidth("Reset Config", fontRendererObj, guiLeft+xSize+4+44, guiTopSidebar+12+24*2, false, 86, 4210752);
-
- if(!validShareContents()) {
- Gui.drawRect(guiLeft+xSize+3, guiTopSidebar+2, guiLeft+xSize+3+88, guiTopSidebar+2+20, 0x80000000);
+ Utils.drawTexturedRect(guiLeft + xSize + 3, guiTopSidebar + 2, 88, 20, 64 / 217f, 152 / 217f, 48 / 78f, 68 / 78f, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(guiLeft + xSize + 3, guiTopSidebar + 2 + 24, 88, 20, 64 / 217f, 152 / 217f, 48 / 78f, 68 / 78f, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(guiLeft + xSize + 3, guiTopSidebar + 2 + 24 * 2, 88, 20, 64 / 217f, 152 / 217f, 48 / 78f, 68 / 78f, GL11.GL_NEAREST);
+ Utils.drawStringCenteredScaledMaxWidth("Load preset", fontRendererObj, guiLeft + xSize + 4 + 44, guiTopSidebar + 8, false, 86, 4210752);
+ Utils.drawStringCenteredScaledMaxWidth("from Clipboard", fontRendererObj, guiLeft + xSize + 4 + 44, guiTopSidebar + 16, false, 86, 4210752);
+ Utils.drawStringCenteredScaledMaxWidth("Save preset", fontRendererObj, guiLeft + xSize + 4 + 44, guiTopSidebar + 8 + 24, false, 86, 4210752);
+ Utils.drawStringCenteredScaledMaxWidth("to Clipboard", fontRendererObj, guiLeft + xSize + 4 + 44, guiTopSidebar + 16 + 24, false, 86, 4210752);
+ Utils.drawStringCenteredScaledMaxWidth("Reset Config", fontRendererObj, guiLeft + xSize + 4 + 44, guiTopSidebar + 12 + 24 * 2, false, 86, 4210752);
+
+ if (!validShareContents()) {
+ Gui.drawRect(guiLeft + xSize + 3, guiTopSidebar + 2, guiLeft + xSize + 3 + 88, guiTopSidebar + 2 + 20, 0x80000000);
}
}
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
super.keyTyped(typedChar, keyCode);
- for(int yIndex=0; yIndex<guiElementTextFields.size(); yIndex++) {
- for(int i=0; i<3; i++) {
+ for (int yIndex = 0; yIndex < guiElementTextFields.size(); yIndex++) {
+ for (int i = 0; i < 3; i++) {
guiElementTextFields.get(yIndex)[i].keyTyped(typedChar, keyCode);
- if(guiElementTextFields.get(yIndex)[i].getFocus()) {
+ if (guiElementTextFields.get(yIndex)[i].getFocus()) {
int addOffset = 0;
- if(keyCode == Keyboard.KEY_UP) {
+ if (keyCode == Keyboard.KEY_UP) {
addOffset -= 1;
- } else if(keyCode == Keyboard.KEY_DOWN) {
+ } else if (keyCode == Keyboard.KEY_DOWN) {
addOffset += 1;
}
NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.remove(yIndex);
- if(yIndex+addOffset < 0) {
+ if (yIndex + addOffset < 0) {
addOffset = -yIndex;
- } else if(yIndex+addOffset > NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.size()) {
- addOffset = NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.size()-yIndex;
+ } else if (yIndex + addOffset > NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.size()) {
+ addOffset = NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.size() - yIndex;
}
- NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.add(yIndex+addOffset,
+ NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.add(yIndex + addOffset,
getEnchantOpString(guiElementTextFields.get(yIndex), comparators.get(yIndex), modifiers.get(yIndex)));
- if(addOffset != 0) {
+ if (addOffset != 0) {
GuiElementTextField[] guiElementTextFieldArray = guiElementTextFields.remove(yIndex);
- guiElementTextFields.add(yIndex+addOffset, guiElementTextFieldArray);
+ guiElementTextFields.add(yIndex + addOffset, guiElementTextFieldArray);
}
return;
}
@@ -279,7 +273,7 @@ public class GuiEnchantColour extends GuiScreen {
int dWheel = Mouse.getEventDWheel();
int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
- if(mouseX > guiLeft && mouseX < guiLeft + xSize) {
+ if (mouseX > guiLeft && mouseX < guiLeft + xSize) {
if (dWheel < 0) {
scroll.setTarget(scroll.getTarget() - 50);
scroll.resetTimer();
@@ -287,7 +281,7 @@ public class GuiEnchantColour extends GuiScreen {
scroll.setTarget(scroll.getTarget() + 50);
scroll.resetTimer();
}
- } else if(mouseX > guiLeft+xSize && mouseX < guiLeft + xSize+ 100) {
+ } else if (mouseX > guiLeft + xSize && mouseX < guiLeft + xSize + 100) {
if (dWheel < 0) {
scrollSideBar.setTarget(scrollSideBar.getTarget() - 50);
scrollSideBar.resetTimer();
@@ -302,20 +296,20 @@ public class GuiEnchantColour extends GuiScreen {
public static int getIntModifier(String modifier) {
try {
return Integer.parseInt(modifier);
- } catch(NumberFormatException e) {
+ } catch (NumberFormatException e) {
return 0;
}
}
private boolean validShareContents() {
try {
- String base64 = (String)Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
+ String base64 = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
- if(base64.length() <= sharePrefix.length()) return false;
+ if (base64.length() <= sharePrefix.length()) return false;
try {
return new String(Base64.getDecoder().decode(base64)).startsWith(sharePrefix);
- } catch (IllegalArgumentException e){
+ } catch (IllegalArgumentException e) {
return false;
}
} catch (HeadlessException | IOException | UnsupportedFlavorException | IllegalStateException e) {
@@ -326,16 +320,16 @@ public class GuiEnchantColour extends GuiScreen {
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
- for(int yIndex=0; yIndex<guiElementTextFields.size(); yIndex++) {
- for(int i=0; i<3; i++) {
- int x = guiLeft+7;
- if(i == 1) x+=103;
- else if(i == 2) x+=128;
-
- if(mouseX > x && mouseX < x+guiElementTextFields.get(yIndex)[i].getWidth()) {
- if(mouseY > guiTop+23+25*yIndex && mouseY < guiTop+23+25*yIndex+20) {
+ for (int yIndex = 0; yIndex < guiElementTextFields.size(); yIndex++) {
+ for (int i = 0; i < 3; i++) {
+ int x = guiLeft + 7;
+ if (i == 1) x += 103;
+ else if (i == 2) x += 128;
+
+ if (mouseX > x && mouseX < x + guiElementTextFields.get(yIndex)[i].getWidth()) {
+ if (mouseY > guiTop + 23 + 25 * yIndex && mouseY < guiTop + 23 + 25 * yIndex + 20) {
guiElementTextFields.get(yIndex)[i].mouseClicked(mouseX, mouseY, mouseButton);
- if(mouseButton == 1) {
+ if (mouseButton == 1) {
NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.remove(yIndex);
NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.add(yIndex,
getEnchantOpString(guiElementTextFields.get(yIndex), comparators.get(yIndex), modifiers.get(yIndex)));
@@ -347,26 +341,26 @@ public class GuiEnchantColour extends GuiScreen {
}
comparators.putIfAbsent(yIndex, ">");
modifiers.putIfAbsent(yIndex, "0");
- if(mouseX >= guiLeft+180 && mouseX <= guiLeft+210 &&
- mouseY >= guiTop+23+25*yIndex && mouseY <= guiTop+23+25*yIndex+20) {
+ if (mouseX >= guiLeft + 180 && mouseX <= guiLeft + 210 &&
+ mouseY >= guiTop + 23 + 25 * yIndex && mouseY <= guiTop + 23 + 25 * yIndex + 20) {
int modifierI = getIntModifier(modifiers.get(yIndex));
int selectedModifier = -1;
- if(mouseX < guiLeft+195) {
- if(mouseY < guiTop+23+25*yIndex+10) {
+ if (mouseX < guiLeft + 195) {
+ if (mouseY < guiTop + 23 + 25 * yIndex + 10) {
selectedModifier = BOLD_MODIFIER;
} else {
selectedModifier = ITALIC_MODIFIER;
}
} else {
- if(mouseY < guiTop+23+25*yIndex+10) {
+ if (mouseY < guiTop + 23 + 25 * yIndex + 10) {
selectedModifier = UNDERLINE_MODIFIER;
} else {
selectedModifier = STRIKETHROUGH_MODIFIER;
}
}
- if(selectedModifier != -1) {
+ if (selectedModifier != -1) {
int modifierMasked = (modifierI & selectedModifier);
int modifierMaskedInverted = selectedModifier - modifierMasked;
@@ -374,27 +368,30 @@ public class GuiEnchantColour extends GuiScreen {
int finalModifier = (modifierI & modifierInverted) | modifierMaskedInverted;
- modifiers.put(yIndex, ""+finalModifier);
+ modifiers.put(yIndex, "" + finalModifier);
NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.remove(yIndex);
NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.add(yIndex,
getEnchantOpString(guiElementTextFields.get(yIndex), comparators.get(yIndex), modifiers.get(yIndex)));
}
}
- if(mouseY > guiTop+23+25*yIndex && mouseY < guiTop+23+25*yIndex+20) {
- if(mouseX > guiLeft+86 && mouseX < guiLeft+86+20) {
+ if (mouseY > guiTop + 23 + 25 * yIndex && mouseY < guiTop + 23 + 25 * yIndex + 20) {
+ if (mouseX > guiLeft + 86 && mouseX < guiLeft + 86 + 20) {
switch (comparators.get(yIndex)) {
case ">":
- comparators.put(yIndex, "="); break;
+ comparators.put(yIndex, "=");
+ break;
case "=":
- comparators.put(yIndex, "<"); break;
+ comparators.put(yIndex, "<");
+ break;
default:
- comparators.put(yIndex, ">"); break;
+ comparators.put(yIndex, ">");
+ break;
}
NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.remove(yIndex);
NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.add(yIndex,
getEnchantOpString(guiElementTextFields.get(yIndex), comparators.get(yIndex), modifiers.get(yIndex)));
- } else if(mouseX > guiLeft+160 && mouseX < guiLeft+160+20) {
+ } else if (mouseX > guiLeft + 160 && mouseX < guiLeft + 160 + 20) {
NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.remove(yIndex);
guiElementTextFields.remove(yIndex);
comparators.remove(yIndex);
@@ -402,79 +399,77 @@ public class GuiEnchantColour extends GuiScreen {
}
}
}
- if(mouseX >= guiLeft+57 && mouseX <= guiLeft+xSize-57) {
- if(mouseY >= guiTop+ySize-30 && mouseY <= guiTop+ySize-10) {
+ if (mouseX >= guiLeft + 57 && mouseX <= guiLeft + xSize - 57) {
+ if (mouseY >= guiTop + ySize - 30 && mouseY <= guiTop + ySize - 10) {
NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.add("[a-zA-Z\\- ]+:>:5:9:0");
}
}
- if(mouseX > guiLeft+xSize+3 && mouseX< guiLeft+xSize+3+88){
- if(mouseY > guiTopSidebar+2 && mouseY < guiTopSidebar+20+2){
+ if (mouseX > guiLeft + xSize + 3 && mouseX < guiLeft + xSize + 3 + 88) {
+ if (mouseY > guiTopSidebar + 2 && mouseY < guiTopSidebar + 20 + 2) {
String base64;
try {
- base64 = (String)Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
+ base64 = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
} catch (HeadlessException | IOException | UnsupportedFlavorException e) {
return;
}
- if(base64.length() <= sharePrefix.length()) return;
+ if (base64.length() <= sharePrefix.length()) return;
String jsonString;
try {
jsonString = new String(Base64.getDecoder().decode(base64));
- if(!jsonString.startsWith(sharePrefix)) return;
+ if (!jsonString.startsWith(sharePrefix)) return;
jsonString = jsonString.substring(sharePrefix.length());
- } catch (IllegalArgumentException e){
+ } catch (IllegalArgumentException e) {
return;
}
System.out.println(jsonString);
JsonArray presetArray;
- try{
+ try {
presetArray = new JsonParser().parse(jsonString).getAsJsonArray();
- } catch (IllegalStateException | JsonParseException e){
+ } catch (IllegalStateException | JsonParseException e) {
return;
}
ArrayList<String> presetList = new ArrayList<>();
-
for (int i = 0; i < presetArray.size(); i++) {
if (presetArray.get(i).isJsonPrimitive()) {
String test = presetArray.get(i).getAsString();
Matcher matcher = settingPattern.matcher(test);
- if(matcher.matches()) {
+ if (matcher.matches()) {
presetList.add(presetArray.get(i).getAsString());
}
}
}
- if(presetList.size() != 0) {
+ if (presetList.size() != 0) {
NotEnoughUpdates.INSTANCE.config.hidden.enchantColours = presetList;
}
-
- } else if(mouseY > guiTopSidebar+2+24 && mouseY < guiTopSidebar+20+24+2){
+ } else if (mouseY > guiTopSidebar + 2 + 24 && mouseY < guiTopSidebar + 20 + 24 + 2) {
ArrayList<String> result = NotEnoughUpdates.INSTANCE.config.hidden.enchantColours;
JsonArray jsonArray = new JsonArray();
- for (int i = 0; i < result.size(); i++) {
- jsonArray.add(new JsonPrimitive(result.get(i)));
+ for (String s : result) {
+ jsonArray.add(new JsonPrimitive(s));
}
- String base64String = Base64.getEncoder().encodeToString((sharePrefix+jsonArray).getBytes(StandardCharsets.UTF_8));
+ String base64String = Base64.getEncoder().encodeToString((sharePrefix + jsonArray).getBytes(StandardCharsets.UTF_8));
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(base64String), null);
- } else if(mouseY > guiTopSidebar+2+(24*2) && mouseY < guiTopSidebar+20+2+24*2){
+ } else if (mouseY > guiTopSidebar + 2 + (24 * 2) && mouseY < guiTopSidebar + 20 + 2 + 24 * 2) {
NotEnoughUpdates.INSTANCE.config.hidden.enchantColours = NEUConfig.createDefaultEnchantColours();
}
}
}
public static String getColourOpIndex(List<String> colourOps, int index) {
- if(colourOps.size() > index) {
+ if (colourOps.size() > index) {
return colourOps.get(index);
} else {
- switch(index) {
+ switch (index) {
case 0:
return "[a-zA-Z\\- ]+";
case 1: