From b09f774d422263ce15b97d6d0804beddf856176d Mon Sep 17 00:00:00 2001
From: IRONM00N <64110067+IRONM00N@users.noreply.github.com>
Date: Sun, 27 Feb 2022 11:53:57 -0500
Subject: feat: improve formating :)
---
.gitignore | 3 +-
.idea/codeStyles/Project.xml | 55 +
.idea/codeStyles/codeStyleConfig.xml | 5 +
src/main/java/NotSkyblockAddonsInstallerFrame.java | 1303 +--
.../moulberry/notenoughupdates/CustomItems.java | 175 +-
.../notenoughupdates/ItemPriceInformation.java | 571 +-
.../github/moulberry/notenoughupdates/NEUApi.java | 8 +-
.../notenoughupdates/NEUEventListener.java | 5082 +++++------
.../moulberry/notenoughupdates/NEUManager.java | 2913 ++++---
.../moulberry/notenoughupdates/NEUOverlay.java | 5411 ++++++------
.../notenoughupdates/NotEnoughUpdates.java | 666 +-
.../notenoughupdates/auction/APIManager.java | 1790 ++--
.../notenoughupdates/auction/CustomAH.java | 3814 ++++----
.../notenoughupdates/auction/CustomAHGui.java | 12 +-
.../collectionlog/CollectionConstant.java | 12 +-
.../collectionlog/GuiCollectionLog.java | 181 +-
.../commands/ClientCommandBase.java | 32 +-
.../notenoughupdates/commands/Commands.java | 78 +-
.../notenoughupdates/commands/ScreenCommand.java | 26 +-
.../commands/dev/DevTestCommand.java | 283 +-
.../commands/dev/DungeonWinTestCommand.java | 20 +-
.../commands/dev/NullzeeSphereCommand.java | 53 +-
.../commands/dev/PackDevCommand.java | 73 +-
.../commands/dev/StatsCommand.java | 270 +-
.../commands/dungeon/DhCommand.java | 14 +-
.../commands/dungeon/DnCommand.java | 17 +-
.../commands/dungeon/JoinDungeonCommand.java | 51 +-
.../commands/dungeon/MapCommand.java | 215 +-
.../commands/help/FeaturesCommand.java | 60 +-
.../commands/help/HelpCommand.java | 113 +-
.../commands/help/LinksCommand.java | 33 +-
.../commands/help/SettingsCommand.java | 31 +-
.../commands/help/StorageViewerWhyCommand.java | 29 +-
.../notenoughupdates/commands/misc/AhCommand.java | 41 +-
.../commands/misc/ButtonsCommand.java | 12 +-
.../commands/misc/CalendarCommand.java | 18 +-
.../commands/misc/CollectionLogCommand.java | 14 +-
.../commands/misc/CosmeticsCommand.java | 22 +-
.../commands/misc/CustomizeCommand.java | 42 +-
.../commands/misc/GamemodesCommand.java | 16 +-
.../commands/profile/CataCommand.java | 16 +-
.../commands/profile/PeekCommand.java | 481 +-
.../commands/profile/PvCommand.java | 22 +-
.../commands/profile/ViewProfileCommand.java | 114 +-
.../commands/repo/ReloadRepoCommand.java | 34 +-
.../commands/repo/RepoModeCommand.java | 19 +-
.../commands/repo/ResetRepoCommand.java | 14 +-
.../notenoughupdates/core/BackgroundBlur.java | 481 +-
.../notenoughupdates/core/ChromaColour.java | 172 +-
.../notenoughupdates/core/GlScissorStack.java | 132 +-
.../notenoughupdates/core/GuiElement.java | 6 +-
.../notenoughupdates/core/GuiElementBoolean.java | 202 +-
.../notenoughupdates/core/GuiElementColour.java | 785 +-
.../notenoughupdates/core/GuiElementTextField.java | 1162 +--
.../core/GuiScreenElementWrapper.java | 42 +-
.../notenoughupdates/core/config/Config.java | 2 +-
.../core/config/GuiPositionEditor.java | 212 +-
.../core/config/KeybindHelper.java | 76 +-
.../notenoughupdates/core/config/Position.java | 364 +-
.../notenoughupdates/core/config/PositionNew.java | 330 +-
.../core/config/annotations/Category.java | 4 +-
.../core/config/annotations/ConfigAccordionId.java | 2 +-
.../config/annotations/ConfigEditorAccordion.java | 2 +-
.../config/annotations/ConfigEditorButton.java | 4 +-
.../annotations/ConfigEditorDraggableList.java | 2 +-
.../config/annotations/ConfigEditorDropdown.java | 4 +-
.../core/config/annotations/ConfigEditorFSR.java | 4 +-
.../config/annotations/ConfigEditorKeybind.java | 2 +-
.../config/annotations/ConfigEditorSlider.java | 6 +-
.../core/config/annotations/ConfigOption.java | 6 +-
.../core/config/gui/GuiOptionEditor.java | 73 +-
.../core/config/gui/GuiOptionEditorAccordion.java | 113 +-
.../core/config/gui/GuiOptionEditorBoolean.java | 60 +-
.../core/config/gui/GuiOptionEditorButton.java | 102 +-
.../core/config/gui/GuiOptionEditorColour.java | 90 +-
.../config/gui/GuiOptionEditorDraggableList.java | 552 +-
.../core/config/gui/GuiOptionEditorDropdown.java | 307 +-
.../core/config/gui/GuiOptionEditorFSR.java | 97 +-
.../core/config/gui/GuiOptionEditorKeybind.java | 131 +-
.../core/config/gui/GuiOptionEditorSlider.java | 239 +-
.../core/config/gui/GuiOptionEditorText.java | 144 +-
.../core/config/gui/GuiPositionEditor.java | 328 +-
.../core/config/struct/ConfigProcessor.java | 351 +-
.../core/util/GuiElementSlider.java | 213 +-
.../notenoughupdates/core/util/MiscUtils.java | 158 +-
.../notenoughupdates/core/util/Splitters.java | 2 +-
.../notenoughupdates/core/util/StringUtils.java | 54 +-
.../notenoughupdates/core/util/lerp/LerpUtils.java | 32 +-
.../core/util/lerp/LerpingFloat.java | 98 +-
.../core/util/lerp/LerpingInteger.java | 142 +-
.../core/util/render/RenderUtils.java | 772 +-
.../core/util/render/TextRenderUtils.java | 507 +-
.../notenoughupdates/cosmetics/CapeManager.java | 651 +-
.../notenoughupdates/cosmetics/CapeNode.java | 708 +-
.../notenoughupdates/cosmetics/GuiCosmetics.java | 1180 +--
.../notenoughupdates/cosmetics/NEUCape.java | 2548 +++---
.../notenoughupdates/cosmetics/ShaderManager.java | 277 +-
.../notenoughupdates/dungeons/DungeonBlocks.java | 495 +-
.../notenoughupdates/dungeons/DungeonMap.java | 3051 +++----
.../notenoughupdates/dungeons/DungeonWin.java | 834 +-
.../dungeons/GuiDungeonMapEditor.java | 1525 ++--
.../notenoughupdates/events/NEUEvent.java | 8 +-
.../events/OnBlockBreakSoundEffect.java | 60 +-
.../notenoughupdates/gamemodes/GuiGamemodes.java | 589 +-
.../notenoughupdates/gamemodes/SBGamemodes.java | 637 +-
.../infopanes/CollectionLogInfoPane.java | 951 +-
.../notenoughupdates/infopanes/DevInfoPane.java | 1767 ++--
.../infopanes/FlipperInfoPane.java | 187 +-
.../notenoughupdates/infopanes/HTMLInfoPane.java | 716 +-
.../notenoughupdates/infopanes/InfoPane.java | 90 +-
.../infopanes/ScrollableInfoPane.java | 40 +-
.../notenoughupdates/infopanes/TextInfoPane.java | 105 +-
.../notenoughupdates/itemeditor/GuiElement.java | 14 +-
.../itemeditor/GuiElementButton.java | 46 +-
.../itemeditor/GuiElementText.java | 66 +-
.../itemeditor/GuiElementTextField.java | 1009 +--
.../notenoughupdates/itemeditor/NEUItemEditor.java | 747 +-
.../notenoughupdates/mbgui/MBAnchorPoint.java | 94 +-
.../notenoughupdates/mbgui/MBDeserializer.java | 10 +-
.../notenoughupdates/mbgui/MBGuiElement.java | 14 +-
.../notenoughupdates/mbgui/MBGuiGroup.java | 104 +-
.../notenoughupdates/mbgui/MBGuiGroupAligned.java | 96 +-
.../notenoughupdates/mbgui/MBGuiGroupFloating.java | 239 +-
.../miscfeatures/AuctionBINWarning.java | 478 +-
.../miscfeatures/AuctionSortModeWarning.java | 92 +-
.../miscfeatures/BetterContainers.java | 959 +-
.../miscfeatures/CollectionLogManager.java | 56 +-
.../miscfeatures/CrystalMetalDetectorSolver.java | 298 +-
.../miscfeatures/CrystalOverlay.java | 758 +-
.../miscfeatures/CustomItemEffects.java | 2434 +++---
.../miscfeatures/CustomSkulls.java | 569 +-
.../miscfeatures/DamageCommas.java | 170 +-
.../miscfeatures/DwarvenMinesWaypoints.java | 425 +-
.../miscfeatures/EnchantingSolvers.java | 1052 +--
.../notenoughupdates/miscfeatures/FairySouls.java | 587 +-
.../miscfeatures/FancyPortals.java | 512 +-
.../miscfeatures/FishingHelper.java | 1164 +--
.../miscfeatures/ItemCooldowns.java | 370 +-
.../miscfeatures/ItemCustomizeManager.java | 500 +-
.../miscfeatures/ItemRarityHalo.java | 518 +-
.../notenoughupdates/miscfeatures/MiningStuff.java | 350 +-
.../miscfeatures/NPCRetexturing.java | 112 +-
.../miscfeatures/NullzeeSphere.java | 514 +-
.../miscfeatures/PetInfoOverlay.java | 2189 ++---
.../notenoughupdates/miscfeatures/SlotLocking.java | 1237 +--
.../miscfeatures/StorageManager.java | 1280 +--
.../miscfeatures/StreamerMode.java | 52 +-
.../notenoughupdates/miscfeatures/SunTzu.java | 137 +-
.../customblockzones/CrystalHollowsTextures.java | 32 +-
.../customblockzones/CustomBiomes.java | 255 +-
.../customblockzones/CustomBlockSounds.java | 156 +-
.../customblockzones/DwarvenMinesTextures.java | 321 +-
.../customblockzones/IslandZoneSubdivider.java | 2 +-
.../customblockzones/LocationChangeEvent.java | 14 +-
.../customblockzones/SpecialBlockZone.java | 113 +-
.../miscgui/AccessoryBagOverlay.java | 1990 +++--
.../notenoughupdates/miscgui/CalendarOverlay.java | 2742 +++---
.../notenoughupdates/miscgui/GuiCustomEnchant.java | 3426 ++++----
.../notenoughupdates/miscgui/GuiEnchantColour.java | 1131 +--
.../miscgui/GuiInvButtonEditor.java | 1600 ++--
.../notenoughupdates/miscgui/GuiItemCustomize.java | 779 +-
.../notenoughupdates/miscgui/GuiItemRecipe.java | 403 +-
.../notenoughupdates/miscgui/GuiPriceGraph.java | 919 +-
.../miscgui/InventoryStorageSelector.java | 901 +-
.../notenoughupdates/miscgui/KatSitterOverlay.java | 124 +-
.../miscgui/NEUOverlayPlacements.java | 426 +-
.../notenoughupdates/miscgui/StorageOverlay.java | 4270 ++++-----
.../notenoughupdates/miscgui/TradeWindow.java | 2132 ++---
.../miscgui/tutorials/NeuConfigTutorial.java | 6 +-
.../miscgui/tutorials/NeuTutorial.java | 251 +-
.../miscgui/tutorials/TutorialBase.java | 640 +-
.../mixins/MixinAbstractClientPlayer.java | 46 +-
.../notenoughupdates/mixins/MixinContainer.java | 8 +-
.../mixins/MixinEffectRenderer.java | 26 +-
.../notenoughupdates/mixins/MixinEntity.java | 24 +-
.../mixins/MixinEntityAgeable.java | 16 +-
.../notenoughupdates/mixins/MixinEntityPlayer.java | 74 +-
.../mixins/MixinEntityPlayerSP.java | 24 +-
.../mixins/MixinEntityRenderer.java | 267 +-
.../notenoughupdates/mixins/MixinGuiChest.java | 82 +-
.../notenoughupdates/mixins/MixinGuiContainer.java | 546 +-
.../notenoughupdates/mixins/MixinGuiIngame.java | 67 +-
.../notenoughupdates/mixins/MixinGuiInventory.java | 14 +-
.../notenoughupdates/mixins/MixinGuiScreen.java | 8 +-
.../mixins/MixinInventoryEffectRenderer.java | 18 +-
.../mixins/MixinInventoryPlayer.java | 20 +-
.../mixins/MixinItemCameraTransforms.java | 8 +-
.../notenoughupdates/mixins/MixinItemRenderer.java | 20 +-
.../notenoughupdates/mixins/MixinItemStack.java | 69 +-
.../mixins/MixinLayerArmorBase.java | 84 +-
.../mixins/MixinLayerCustomHead.java | 92 +-
.../mixins/MixinLoadingScreenRenderer.java | 12 +-
.../notenoughupdates/mixins/MixinMinecraft.java | 10 +-
.../notenoughupdates/mixins/MixinMouseHelper.java | 14 +-
.../mixins/MixinNetHandlerPlayClient.java | 150 +-
.../mixins/MixinPlayerControllerMP.java | 31 +-
.../notenoughupdates/mixins/MixinRender.java | 24 +-
.../notenoughupdates/mixins/MixinRenderFish.java | 271 +-
.../notenoughupdates/mixins/MixinRenderGlobal.java | 164 +-
.../notenoughupdates/mixins/MixinRenderItem.java | 353 +-
.../notenoughupdates/mixins/MixinRenderList.java | 16 +-
.../mixins/MixinRendererLivingEntity.java | 35 +-
.../mixins/MixinTextureManager.java | 12 +-
.../mixins/MixinTileEntitySkullRenderer.java | 25 +-
.../mixins/MixinTileEntitySpecialRenderer.java | 40 +-
.../mixins/MixinVboRenderList.java | 16 +-
.../notenoughupdates/mixins/MixinWorld.java | 36 +-
.../notenoughupdates/mixins/MixinWorldClient.java | 16 +-
.../notenoughupdates/options/NEUConfig.java | 1095 +--
.../notenoughupdates/options/NEUConfigEditor.java | 1540 ++--
.../options/seperateSections/AHGraph.java | 136 +-
.../options/seperateSections/AHTweaks.java | 158 +-
.../options/seperateSections/AccessoryBag.java | 14 +-
.../options/seperateSections/ApiKey.java | 14 +-
.../options/seperateSections/Calendar.java | 80 +-
.../options/seperateSections/CustomArmour.java | 46 +-
.../options/seperateSections/DungeonMapConfig.java | 266 +-
.../options/seperateSections/Dungeons.java | 443 +-
.../options/seperateSections/Enchanting.java | 358 +-
.../options/seperateSections/Fishing.java | 400 +-
.../options/seperateSections/ImprovedSBMenu.java | 72 +-
.../options/seperateSections/InventoryButtons.java | 46 +-
.../options/seperateSections/ItemOverlays.java | 685 +-
.../options/seperateSections/Itemlist.java | 186 +-
.../options/seperateSections/LocationEdit.java | 358 +-
.../options/seperateSections/Mining.java | 1221 +--
.../options/seperateSections/Misc.java | 272 +-
.../options/seperateSections/MiscOverlays.java | 636 +-
.../options/seperateSections/NeuAuctionHouse.java | 66 +-
.../options/seperateSections/Notifications.java | 44 +-
.../options/seperateSections/PetOverlay.java | 190 +-
.../options/seperateSections/SkillOverlays.java | 559 +-
.../options/seperateSections/SlayerOverlay.java | 117 +-
.../options/seperateSections/SlotLocking.java | 130 +-
.../options/seperateSections/StorageGUI.java | 456 +-
.../options/seperateSections/Toolbar.java | 170 +-
.../options/seperateSections/TooltipTweaks.java | 258 +-
.../options/seperateSections/TradeMenu.java | 32 +-
.../overlays/AuctionSearchOverlay.java | 1124 +--
.../overlays/BonemerangOverlay.java | 187 +-
.../overlays/CombatSkillOverlay.java | 461 +-
.../overlays/CrystalHollowOverlay.java | 810 +-
.../notenoughupdates/overlays/FarmingOverlay.java | 963 ++-
.../overlays/FishingSkillOverlay.java | 674 +-
.../notenoughupdates/overlays/FuelBar.java | 308 +-
.../notenoughupdates/overlays/MiningOverlay.java | 1321 +--
.../overlays/MiningSkillOverlay.java | 662 +-
.../notenoughupdates/overlays/OverlayManager.java | 524 +-
.../overlays/RancherBootOverlay.java | 288 +-
.../notenoughupdates/overlays/SlayerOverlay.java | 428 +-
.../notenoughupdates/overlays/TextOverlay.java | 321 +-
.../overlays/TextOverlayStyle.java | 8 +-
.../notenoughupdates/overlays/TimersOverlay.java | 1244 +--
.../profileviewer/GuiProfileViewer.java | 9145 +++++++++++---------
.../notenoughupdates/profileviewer/Panorama.java | 303 +-
.../profileviewer/PlayerStats.java | 1227 +--
.../profileviewer/ProfileViewer.java | 2470 +++---
.../notenoughupdates/recipes/CraftingOverlay.java | 242 +-
.../notenoughupdates/recipes/CraftingRecipe.java | 252 +-
.../notenoughupdates/recipes/ForgeRecipe.java | 437 +-
.../notenoughupdates/recipes/Ingredient.java | 126 +-
.../notenoughupdates/recipes/NeuRecipe.java | 58 +-
.../notenoughupdates/recipes/RecipeGenerator.java | 314 +-
.../notenoughupdates/recipes/RecipeSlot.java | 34 +-
.../recipes/VillagerTradeRecipe.java | 251 +-
.../notenoughupdates/util/AllowEmptyHTMLTag.java | 112 +-
.../moulberry/notenoughupdates/util/Constants.java | 106 +-
.../moulberry/notenoughupdates/util/Debouncer.java | 38 +-
.../util/DiscordMarkdownBuilder.java | 34 +-
.../notenoughupdates/util/GuiTextures.java | 230 +-
.../notenoughupdates/util/HastebinUploader.java | 86 +-
.../notenoughupdates/util/HotmInformation.java | 323 +-
.../notenoughupdates/util/HypixelApi.java | 316 +-
.../notenoughupdates/util/LerpingFloat.java | 98 +-
.../notenoughupdates/util/NEUResourceManager.java | 48 +-
.../notenoughupdates/util/ProfileApiSyncer.java | 129 +-
.../util/RequestFocusListener.java | 72 +-
.../util/ReverseWorldRenderer.java | 1069 +--
.../moulberry/notenoughupdates/util/SBInfo.java | 661 +-
.../notenoughupdates/util/SpecialColour.java | 172 +-
.../moulberry/notenoughupdates/util/TexLoc.java | 88 +-
.../moulberry/notenoughupdates/util/Utils.java | 3159 +++----
.../notenoughupdates/util/XPInformation.java | 445 +-
283 files changed, 71301 insertions(+), 63988 deletions(-)
create mode 100644 .idea/codeStyles/Project.xml
create mode 100644 .idea/codeStyles/codeStyleConfig.xml
diff --git a/.gitignore b/.gitignore
index e5ac9893..a7b89d94 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,7 +11,8 @@ out
*.ipr
*.iws
*.iml
-.idea
+.idea/*
+!.idea/codeStyles
# gradle
build
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 00000000..6cedf3ff
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 00000000..79ee123c
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/NotSkyblockAddonsInstallerFrame.java b/src/main/java/NotSkyblockAddonsInstallerFrame.java
index 322555c8..e6543617 100644
--- a/src/main/java/NotSkyblockAddonsInstallerFrame.java
+++ b/src/main/java/NotSkyblockAddonsInstallerFrame.java
@@ -16,648 +16,663 @@ import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
public class NotSkyblockAddonsInstallerFrame extends JFrame implements ActionListener, MouseListener {
- private static final Pattern IN_MODS_SUBFOLDER = Pattern.compile("1\\.8\\.9[/\\\\]?$");
-
- private JLabel logo = null;
- private JLabel versionInfo = null;
- private JLabel labelFolder = null;
-
- private JPanel panelCenter = null;
- private JPanel panelBottom = null;
- private JPanel totalContentPane = null;
-
- private JTextArea descriptionText = null;
- private JTextArea forgeDescriptionText = null;
-
- private JTextField textFieldFolderLocation = null;
- private JButton buttonChooseFolder = null;
-
- private JButton buttonInstall = null;
- private JButton buttonOpenFolder = null;
- private JButton buttonClose = null;
-
- private static final int TOTAL_HEIGHT = 435;
- private static final int TOTAL_WIDTH = 404;
-
- private int x = 0;
- private int y = 0;
-
- private int w = TOTAL_WIDTH;
- private int h;
- private int margin;
-
- public NotSkyblockAddonsInstallerFrame() {
- try {
- setName("NotEnoughUpdatesInstallerFrame");
- setTitle("NotEnoughUpdates Installer");
- setResizable(false);
- setSize(TOTAL_WIDTH, TOTAL_HEIGHT);
- setContentPane(getPanelContentPane());
-
- getButtonFolder().addActionListener(this);
- getButtonInstall().addActionListener(this);
- getButtonOpenFolder().addActionListener(this);
- getButtonClose().addActionListener(this);
- getForgeTextArea().addMouseListener(this);
-
- pack();
- setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
-
- getFieldFolder().setText(getModsFolder().getPath());
- getButtonInstall().setEnabled(true);
- getButtonInstall().requestFocus();
- } catch (Exception ex) {
- showErrorPopup(ex);
- }
- }
-
- public static void main(String[] args) {
- try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- NotSkyblockAddonsInstallerFrame frame = new NotSkyblockAddonsInstallerFrame();
- frame.centerFrame(frame);
- frame.show();
-
- } catch (Exception ex) {
- showErrorPopup(ex);
- }
- }
-
- private JPanel getPanelContentPane() {
- if (totalContentPane == null) {
- try {
- totalContentPane = new JPanel();
- totalContentPane.setName("PanelContentPane");
- totalContentPane.setLayout(new BorderLayout(5, 5));
- totalContentPane.setPreferredSize(new Dimension(TOTAL_WIDTH, TOTAL_HEIGHT));
- totalContentPane.add(getPanelCenter(), "Center");
- totalContentPane.add(getPanelBottom(), "South");
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return totalContentPane;
- }
-
- private JPanel getPanelCenter() {
- if (panelCenter == null) {
- try {
- (panelCenter = new JPanel()).setName("PanelCenter");
- panelCenter.setLayout(null);
- panelCenter.add(getPictureLabel(), getPictureLabel().getName());
- panelCenter.add(getVersionInfo(), getVersionInfo().getName());
- panelCenter.add(getTextArea(), getTextArea().getName());
- panelCenter.add(getForgeTextArea(), getForgeTextArea().getName());
- panelCenter.add(getLabelFolder(), getLabelFolder().getName());
- panelCenter.add(getFieldFolder(), getFieldFolder().getName());
- panelCenter.add(getButtonFolder(), getButtonFolder().getName());
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return panelCenter;
- }
-
- private JLabel getPictureLabel() {
- if (logo == null) {
- try {
- h = w / 2;
- margin = 5;
-
- BufferedImage myPicture = ImageIO.read(getClass().getClassLoader().getResourceAsStream("assets/notenoughupdates/logo.png"));
- Image scaled = myPicture.getScaledInstance(w - margin * 2, h - margin, Image.SCALE_SMOOTH);
- logo = new JLabel(new ImageIcon(scaled));
- logo.setName("Logo");
- logo.setBounds(x + margin, y + margin, w - margin * 2, h - margin);
- logo.setFont(new Font(Font.DIALOG, Font.BOLD, 18));
- logo.setHorizontalAlignment(SwingConstants.CENTER);
- logo.setPreferredSize(new Dimension(h * 742 / 537, h));
-
- y += h;
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return logo;
- }
-
- private JLabel getVersionInfo() {
- if (versionInfo == null) {
- try {
- h = 25;
-
- versionInfo = new JLabel();
- versionInfo.setName("LabelMcVersion");
- versionInfo.setBounds(x, y, w, h);
- versionInfo.setFont(new Font(Font.DIALOG, Font.BOLD, 14));
- versionInfo.setHorizontalAlignment(SwingConstants.CENTER);
- versionInfo.setPreferredSize(new Dimension(w, h));
- versionInfo.setText("NEU by Moulberry, Installer by Biscuit - for Minecraft 1.8.9");
-
- y += h;
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return versionInfo;
- }
-
- private JTextArea getTextArea() {
- if (descriptionText == null) {
- try {
- h = 60;
- margin = 10;
-
- descriptionText = new JTextArea();
- descriptionText.setName("TextArea");
- descriptionText.setBounds(x + margin, y + margin, w - margin * 2, h - margin);
- descriptionText.setEditable(false);
- descriptionText.setHighlighter(null);
- descriptionText.setEnabled(true);
- descriptionText.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
- descriptionText.setLineWrap(true);
- descriptionText.setOpaque(false);
- descriptionText.setPreferredSize(new Dimension(w - margin * 2, h - margin));
- descriptionText.setText("This installer will copy NotEnoughUpdates into your forge mods folder for you, and replace any old versions that already exist. " +
- "Close this if you prefer to do this yourself!");
- descriptionText.setWrapStyleWord(true);
-
- y += h;
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return descriptionText;
- }
-
- private JTextArea getForgeTextArea() {
- if (forgeDescriptionText == null) {
- try {
- h = 55;
- margin = 10;
-
- forgeDescriptionText = new JTextArea();
- forgeDescriptionText.setName("TextAreaForge");
- forgeDescriptionText.setBounds(x + margin, y + margin, w - margin * 2, h - margin);
- forgeDescriptionText.setEditable(false);
- forgeDescriptionText.setHighlighter(null);
- forgeDescriptionText.setEnabled(true);
- forgeDescriptionText.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
- forgeDescriptionText.setLineWrap(true);
- forgeDescriptionText.setOpaque(false);
- forgeDescriptionText.setPreferredSize(new Dimension(w - margin * 2, h - margin));
- forgeDescriptionText.setText("However, you still need to install Forge client in order to be able to run this mod. Click here to visit the download page for Forge 1.8.9!");
- forgeDescriptionText.setForeground(Color.BLUE.darker());
- forgeDescriptionText.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
- forgeDescriptionText.setWrapStyleWord(true);
-
- y += h;
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return forgeDescriptionText;
- }
-
- private JLabel getLabelFolder() {
- if (labelFolder == null) {
- h = 16;
- w = 65;
-
- x += 10; // Padding
-
- try {
- labelFolder = new JLabel();
- labelFolder.setName("LabelFolder");
- labelFolder.setBounds(x, y + 2, w, h);
- labelFolder.setPreferredSize(new Dimension(w, h));
- labelFolder.setText("Mods Folder");
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
-
- x += w;
- }
- return labelFolder;
- }
-
- private JTextField getFieldFolder() {
- if (textFieldFolderLocation == null) {
- h = 20;
- w = 287;
-
- try {
- textFieldFolderLocation = new JTextField();
- textFieldFolderLocation.setName("FieldFolder");
- textFieldFolderLocation.setBounds(x, y, w, h);
- textFieldFolderLocation.setEditable(false);
- textFieldFolderLocation.setPreferredSize(new Dimension(w, h));
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
-
- x += w;
- }
- return textFieldFolderLocation;
- }
-
- private JButton getButtonFolder() {
- if (buttonChooseFolder == null) {
- h = 20;
- w = 25;
-
- x += 10; // Padding
-
- try {
- BufferedImage myPicture = ImageIO.read(getClass().getClassLoader().getResourceAsStream("assets/notenoughupdates/folder.png"));
- Image scaled = myPicture.getScaledInstance(w - 8, h - 6, Image.SCALE_SMOOTH);
- buttonChooseFolder = new JButton(new ImageIcon(scaled));
- buttonChooseFolder.setName("ButtonFolder");
- buttonChooseFolder.setBounds(x, y, w, h);
- buttonChooseFolder.setPreferredSize(new Dimension(w, h));
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return buttonChooseFolder;
- }
-
- private JPanel getPanelBottom() {
- if (panelBottom == null) {
- try {
- panelBottom = new JPanel();
- panelBottom.setName("PanelBottom");
- panelBottom.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 10));
- panelBottom.setPreferredSize(new Dimension(390, 55));
- panelBottom.add(getButtonInstall(), getButtonInstall().getName());
- panelBottom.add(getButtonOpenFolder(), getButtonOpenFolder().getName());
- panelBottom.add(getButtonClose(), getButtonClose().getName());
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return panelBottom;
- }
-
- private JButton getButtonInstall() {
- if (buttonInstall == null) {
- w = 100;
- h = 26;
-
- try {
- buttonInstall = new JButton();
- buttonInstall.setName("ButtonInstall");
- buttonInstall.setPreferredSize(new Dimension(w, h));
- buttonInstall.setText("Install");
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return buttonInstall;
- }
-
- private JButton getButtonOpenFolder() {
- if (buttonOpenFolder == null) {
- w = 130;
- h = 26;
-
- try {
- buttonOpenFolder = new JButton();
- buttonOpenFolder.setName("ButtonOpenFolder");
- buttonOpenFolder.setPreferredSize(new Dimension(w, h));
- buttonOpenFolder.setText("Open Mods Folder");
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return buttonOpenFolder;
- }
-
- private JButton getButtonClose() {
- if (buttonClose == null) {
- w = 100;
- h = 26;
-
- try {
- (buttonClose = new JButton()).setName("ButtonClose");
- buttonClose.setPreferredSize(new Dimension(w, h));
- buttonClose.setText("Cancel");
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return buttonClose;
- }
-
- public void onFolderSelect() {
- File currentDirectory = new File(getFieldFolder().getText());
-
- JFileChooser jFileChooser = new JFileChooser(currentDirectory);
- jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
- jFileChooser.setAcceptAllFileFilterUsed(false);
- if (jFileChooser.showOpenDialog(this) == 0) {
- File newDirectory = jFileChooser.getSelectedFile();
- getFieldFolder().setText(newDirectory.getPath());
- }
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- if (e.getSource() == getButtonClose()) {
- dispose();
- System.exit(0);
- }
- if (e.getSource() == getButtonFolder()) {
- onFolderSelect();
- }
- if (e.getSource() == getButtonInstall()) {
- onInstall();
- }
- if (e.getSource() == getButtonOpenFolder()) {
- onOpenFolder();
- }
- }
-
- @Override
- public void mouseClicked(MouseEvent e) {
- if (e.getSource() == getForgeTextArea()) {
- try {
- Desktop.getDesktop().browse(new URI("http://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.8.9.html"));
- } catch (IOException | URISyntaxException ex) {
- showErrorPopup(ex);
- }
- }
- }
-
- public void onInstall() {
- try {
- File modsFolder = new File(getFieldFolder().getText());
- if (!modsFolder.exists()) {
- showErrorMessage("Folder not found: " + modsFolder.getPath());
- return;
- }
- if (!modsFolder.isDirectory()) {
- showErrorMessage("Not a folder: " + modsFolder.getPath());
- return;
- }
- tryInstall(modsFolder);
- } catch (Exception e) {
- showErrorPopup(e);
- }
- }
-
- private void tryInstall(File modsFolder) {
- File thisFile = getThisFile();
-
- if (thisFile != null) {
- boolean inSubFolder = IN_MODS_SUBFOLDER.matcher(modsFolder.getPath()).find();
-
- boolean deletingFailure = false;
- if (modsFolder.isDirectory()) { // Delete in this current folder.
- boolean failed = findSkyblockAddonsAndDelete(modsFolder.listFiles());
- if (failed) deletingFailure = true;
- }
- if (inSubFolder) { // We are in the 1.8.9 folder, delete in the parent folder as well.
- if (modsFolder.getParentFile().isDirectory()) {
- boolean failed = findSkyblockAddonsAndDelete(modsFolder.getParentFile().listFiles());
- if (failed) deletingFailure = true;
- }
- } else { // We are in the main mods folder, but the 1.8.9 subfolder exists... delete in there too.
- File subFolder = new File(modsFolder, "1.8.9");
- if (subFolder.exists() && subFolder.isDirectory()) {
- boolean failed = findSkyblockAddonsAndDelete(subFolder.listFiles());
- if (failed) deletingFailure = true;
- }
- }
-
- if (deletingFailure) return;
-
- if (thisFile.isDirectory()) {
- showErrorMessage("This file is a directory... Are we in a development environment?");
- return;
- }
-
- try {
- Files.copy(thisFile.toPath(), new File(modsFolder, thisFile.getName()).toPath());
- } catch (Exception ex) {
- showErrorPopup(ex);
- return;
- }
-
- showMessage("NotEnoughUpdates has been successfully installed into your mods folder.");
- dispose();
- System.exit(0);
- }
- }
-
- private boolean findSkyblockAddonsAndDelete(File[] files) {
- if (files == null) return false;
-
- for (File file : files) {
- if (!file.isDirectory() && file.getPath().endsWith(".jar")) {
- try {
- JarFile jarFile = new JarFile(file);
- ZipEntry mcModInfo = jarFile.getEntry("mcmod.info");
- if (mcModInfo != null) {
- InputStream inputStream = jarFile.getInputStream(mcModInfo);
- String modID = getModIDFromInputStream(inputStream);
- if (modID.equals("notenoughupdates")) {
- jarFile.close();
- try {
- boolean deleted = file.delete();
- if (!deleted) {
- throw new Exception();
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- showErrorMessage("Was not able to delete the other NotEnoughUpdates files found in your mods folder!" + System.lineSeparator() +
- "Please make sure that your minecraft is currently closed and try again, or feel" + System.lineSeparator() +
- "free to open your mods folder and delete those files manually.");
- return true;
- }
- continue;
- }
- }
- jarFile.close();
- } catch (Exception ex) {
- // Just don't check the file I guess, move on to the next...
- }
- }
- }
- return false;
- }
-
- public void onOpenFolder() {
- try {
- Desktop.getDesktop().open(getModsFolder());
- } catch (Exception e) {
- showErrorPopup(e);
- }
- }
-
- public File getModsFolder() {
- String userHome = System.getProperty("user.home", ".");
-
- File modsFolder = getFile(userHome, "minecraft/mods/1.8.9");
- if (!modsFolder.exists()) {
- modsFolder = getFile(userHome, "minecraft/mods");
- }
-
- if (!modsFolder.exists() && !modsFolder.mkdirs()) {
- throw new RuntimeException("The working directory could not be created: " + modsFolder);
- }
- return modsFolder;
- }
-
- public File getFile(String userHome, String minecraftPath) {
- File workingDirectory;
- switch (getOperatingSystem()) {
- case LINUX:
- case SOLARIS: {
- workingDirectory = new File(userHome, '.' + minecraftPath + '/');
- break;
- }
- case WINDOWS: {
- String applicationData = System.getenv("APPDATA");
- if (applicationData != null) {
- workingDirectory = new File(applicationData, "." + minecraftPath + '/');
- break;
- }
- workingDirectory = new File(userHome, '.' + minecraftPath + '/');
- break;
- }
- case MACOS: {
- workingDirectory = new File(userHome, "Library/Application Support/" + minecraftPath);
- break;
- }
- default: {
- workingDirectory = new File(userHome, minecraftPath + '/');
- break;
- }
- }
- return workingDirectory;
- }
-
- public OperatingSystem getOperatingSystem() {
- String osName = System.getProperty("os.name").toLowerCase(Locale.US);
- if (osName.contains("win")) {
- return OperatingSystem.WINDOWS;
-
- } else if (osName.contains("mac")) {
- return OperatingSystem.MACOS;
-
- } else if (osName.contains("solaris") || osName.contains("sunos")) {
-
- return OperatingSystem.SOLARIS;
- } else if (osName.contains("linux") || osName.contains("unix")) {
-
- return OperatingSystem.LINUX;
- }
- return OperatingSystem.UNKNOWN;
- }
-
- public void centerFrame(JFrame frame) {
- Rectangle rectangle = frame.getBounds();
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- Rectangle screenRectangle = new Rectangle(0, 0, screenSize.width, screenSize.height);
-
- int newX = screenRectangle.x + (screenRectangle.width - rectangle.width) / 2;
- int newY = screenRectangle.y + (screenRectangle.height - rectangle.height) / 2;
-
- if (newX < 0) newX = 0;
- if (newY < 0) newY = 0;
-
- frame.setBounds(newX, newY, rectangle.width, rectangle.height);
- }
-
- public void showMessage(String message) {
- JOptionPane.showMessageDialog(null, message, "NotEnoughUpdates", JOptionPane.INFORMATION_MESSAGE);
- }
-
- public void showErrorMessage(String message) {
- JOptionPane.showMessageDialog(null, message, "NotEnoughUpdates - Error", JOptionPane.ERROR_MESSAGE);
- }
-
- public enum OperatingSystem {
- LINUX,
- SOLARIS,
- WINDOWS,
- MACOS,
- UNKNOWN
- }
-
- private static String getStacktraceText(Throwable ex) {
- StringWriter stringWriter = new StringWriter();
- ex.printStackTrace(new PrintWriter(stringWriter));
- return stringWriter.toString().replace("\t", " ");
- }
-
- private static void showErrorPopup(Throwable ex) {
- ex.printStackTrace();
-
- JTextArea textArea = new JTextArea(getStacktraceText(ex));
- textArea.setEditable(false);
- Font currentFont = textArea.getFont();
- Font newFont = new Font(Font.MONOSPACED, currentFont.getStyle(), currentFont.getSize());
- textArea.setFont(newFont);
-
- JScrollPane errorScrollPane = new JScrollPane(textArea);
- errorScrollPane.setPreferredSize(new Dimension(600, 400));
- JOptionPane.showMessageDialog(null, errorScrollPane, "Error", JOptionPane.ERROR_MESSAGE);
- }
-
- private String getVersionFromMcmodInfo() {
- String version = "";
- try {
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("mcmod.info")));
- while ((version = bufferedReader.readLine()) != null) {
- if (version.contains("\"version\": \"")) {
- version = version.split(Pattern.quote("\"version\": \""))[1];
- version = version.substring(0, version.length() - 2);
- break;
- }
- }
- } catch (Exception ex) {
- // It's okay, I guess just don't use the version lol.
- }
- return version;
- }
-
- private String getModIDFromInputStream(InputStream inputStream) {
- String version = "";
- try {
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
- while ((version = bufferedReader.readLine()) != null) {
- if (version.contains("\"modid\": \"")) {
- version = version.split(Pattern.quote("\"modid\": \""))[1];
- version = version.substring(0, version.length() - 2);
- break;
- }
- }
- } catch (Exception ex) {
- // RIP, couldn't find the modid...
- }
- return version;
- }
-
- private File getThisFile() {
- try {
- return new File(NotSkyblockAddonsInstallerFrame.class.getProtectionDomain().getCodeSource().getLocation().toURI());
- } catch (URISyntaxException ex) {
- showErrorPopup(ex);
- }
- return null;
- }
-
- @Override
- public void mousePressed(MouseEvent e) {}
-
- @Override
- public void mouseReleased(MouseEvent e) {}
-
- @Override
- public void mouseEntered(MouseEvent e) {}
-
- @Override
- public void mouseExited(MouseEvent e) {}
+ private static final Pattern IN_MODS_SUBFOLDER = Pattern.compile("1\\.8\\.9[/\\\\]?$");
+
+ private JLabel logo = null;
+ private JLabel versionInfo = null;
+ private JLabel labelFolder = null;
+
+ private JPanel panelCenter = null;
+ private JPanel panelBottom = null;
+ private JPanel totalContentPane = null;
+
+ private JTextArea descriptionText = null;
+ private JTextArea forgeDescriptionText = null;
+
+ private JTextField textFieldFolderLocation = null;
+ private JButton buttonChooseFolder = null;
+
+ private JButton buttonInstall = null;
+ private JButton buttonOpenFolder = null;
+ private JButton buttonClose = null;
+
+ private static final int TOTAL_HEIGHT = 435;
+ private static final int TOTAL_WIDTH = 404;
+
+ private int x = 0;
+ private int y = 0;
+
+ private int w = TOTAL_WIDTH;
+ private int h;
+ private int margin;
+
+ public NotSkyblockAddonsInstallerFrame() {
+ try {
+ setName("NotEnoughUpdatesInstallerFrame");
+ setTitle("NotEnoughUpdates Installer");
+ setResizable(false);
+ setSize(TOTAL_WIDTH, TOTAL_HEIGHT);
+ setContentPane(getPanelContentPane());
+
+ getButtonFolder().addActionListener(this);
+ getButtonInstall().addActionListener(this);
+ getButtonOpenFolder().addActionListener(this);
+ getButtonClose().addActionListener(this);
+ getForgeTextArea().addMouseListener(this);
+
+ pack();
+ setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+
+ getFieldFolder().setText(getModsFolder().getPath());
+ getButtonInstall().setEnabled(true);
+ getButtonInstall().requestFocus();
+ } catch (Exception ex) {
+ showErrorPopup(ex);
+ }
+ }
+
+ public static void main(String[] args) {
+ try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ NotSkyblockAddonsInstallerFrame frame = new NotSkyblockAddonsInstallerFrame();
+ frame.centerFrame(frame);
+ frame.show();
+
+ } catch (Exception ex) {
+ showErrorPopup(ex);
+ }
+ }
+
+ private JPanel getPanelContentPane() {
+ if (totalContentPane == null) {
+ try {
+ totalContentPane = new JPanel();
+ totalContentPane.setName("PanelContentPane");
+ totalContentPane.setLayout(new BorderLayout(5, 5));
+ totalContentPane.setPreferredSize(new Dimension(TOTAL_WIDTH, TOTAL_HEIGHT));
+ totalContentPane.add(getPanelCenter(), "Center");
+ totalContentPane.add(getPanelBottom(), "South");
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return totalContentPane;
+ }
+
+ private JPanel getPanelCenter() {
+ if (panelCenter == null) {
+ try {
+ (panelCenter = new JPanel()).setName("PanelCenter");
+ panelCenter.setLayout(null);
+ panelCenter.add(getPictureLabel(), getPictureLabel().getName());
+ panelCenter.add(getVersionInfo(), getVersionInfo().getName());
+ panelCenter.add(getTextArea(), getTextArea().getName());
+ panelCenter.add(getForgeTextArea(), getForgeTextArea().getName());
+ panelCenter.add(getLabelFolder(), getLabelFolder().getName());
+ panelCenter.add(getFieldFolder(), getFieldFolder().getName());
+ panelCenter.add(getButtonFolder(), getButtonFolder().getName());
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return panelCenter;
+ }
+
+ private JLabel getPictureLabel() {
+ if (logo == null) {
+ try {
+ h = w / 2;
+ margin = 5;
+
+ BufferedImage myPicture = ImageIO.read(getClass()
+ .getClassLoader()
+ .getResourceAsStream("assets/notenoughupdates/logo.png"));
+ Image scaled = myPicture.getScaledInstance(w - margin * 2, h - margin, Image.SCALE_SMOOTH);
+ logo = new JLabel(new ImageIcon(scaled));
+ logo.setName("Logo");
+ logo.setBounds(x + margin, y + margin, w - margin * 2, h - margin);
+ logo.setFont(new Font(Font.DIALOG, Font.BOLD, 18));
+ logo.setHorizontalAlignment(SwingConstants.CENTER);
+ logo.setPreferredSize(new Dimension(h * 742 / 537, h));
+
+ y += h;
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return logo;
+ }
+
+ private JLabel getVersionInfo() {
+ if (versionInfo == null) {
+ try {
+ h = 25;
+
+ versionInfo = new JLabel();
+ versionInfo.setName("LabelMcVersion");
+ versionInfo.setBounds(x, y, w, h);
+ versionInfo.setFont(new Font(Font.DIALOG, Font.BOLD, 14));
+ versionInfo.setHorizontalAlignment(SwingConstants.CENTER);
+ versionInfo.setPreferredSize(new Dimension(w, h));
+ versionInfo.setText("NEU by Moulberry, Installer by Biscuit - for Minecraft 1.8.9");
+
+ y += h;
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return versionInfo;
+ }
+
+ private JTextArea getTextArea() {
+ if (descriptionText == null) {
+ try {
+ h = 60;
+ margin = 10;
+
+ descriptionText = new JTextArea();
+ descriptionText.setName("TextArea");
+ descriptionText.setBounds(x + margin, y + margin, w - margin * 2, h - margin);
+ descriptionText.setEditable(false);
+ descriptionText.setHighlighter(null);
+ descriptionText.setEnabled(true);
+ descriptionText.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
+ descriptionText.setLineWrap(true);
+ descriptionText.setOpaque(false);
+ descriptionText.setPreferredSize(new Dimension(w - margin * 2, h - margin));
+ descriptionText.setText(
+ "This installer will copy NotEnoughUpdates into your forge mods folder for you, and replace any old versions that already exist. " +
+ "Close this if you prefer to do this yourself!");
+ descriptionText.setWrapStyleWord(true);
+
+ y += h;
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return descriptionText;
+ }
+
+ private JTextArea getForgeTextArea() {
+ if (forgeDescriptionText == null) {
+ try {
+ h = 55;
+ margin = 10;
+
+ forgeDescriptionText = new JTextArea();
+ forgeDescriptionText.setName("TextAreaForge");
+ forgeDescriptionText.setBounds(x + margin, y + margin, w - margin * 2, h - margin);
+ forgeDescriptionText.setEditable(false);
+ forgeDescriptionText.setHighlighter(null);
+ forgeDescriptionText.setEnabled(true);
+ forgeDescriptionText.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
+ forgeDescriptionText.setLineWrap(true);
+ forgeDescriptionText.setOpaque(false);
+ forgeDescriptionText.setPreferredSize(new Dimension(w - margin * 2, h - margin));
+ forgeDescriptionText.setText(
+ "However, you still need to install Forge client in order to be able to run this mod. Click here to visit the download page for Forge 1.8.9!");
+ forgeDescriptionText.setForeground(Color.BLUE.darker());
+ forgeDescriptionText.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+ forgeDescriptionText.setWrapStyleWord(true);
+
+ y += h;
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return forgeDescriptionText;
+ }
+
+ private JLabel getLabelFolder() {
+ if (labelFolder == null) {
+ h = 16;
+ w = 65;
+
+ x += 10; // Padding
+
+ try {
+ labelFolder = new JLabel();
+ labelFolder.setName("LabelFolder");
+ labelFolder.setBounds(x, y + 2, w, h);
+ labelFolder.setPreferredSize(new Dimension(w, h));
+ labelFolder.setText("Mods Folder");
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+
+ x += w;
+ }
+ return labelFolder;
+ }
+
+ private JTextField getFieldFolder() {
+ if (textFieldFolderLocation == null) {
+ h = 20;
+ w = 287;
+
+ try {
+ textFieldFolderLocation = new JTextField();
+ textFieldFolderLocation.setName("FieldFolder");
+ textFieldFolderLocation.setBounds(x, y, w, h);
+ textFieldFolderLocation.setEditable(false);
+ textFieldFolderLocation.setPreferredSize(new Dimension(w, h));
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+
+ x += w;
+ }
+ return textFieldFolderLocation;
+ }
+
+ private JButton getButtonFolder() {
+ if (buttonChooseFolder == null) {
+ h = 20;
+ w = 25;
+
+ x += 10; // Padding
+
+ try {
+ BufferedImage myPicture = ImageIO.read(getClass()
+ .getClassLoader()
+ .getResourceAsStream("assets/notenoughupdates/folder.png"));
+ Image scaled = myPicture.getScaledInstance(w - 8, h - 6, Image.SCALE_SMOOTH);
+ buttonChooseFolder = new JButton(new ImageIcon(scaled));
+ buttonChooseFolder.setName("ButtonFolder");
+ buttonChooseFolder.setBounds(x, y, w, h);
+ buttonChooseFolder.setPreferredSize(new Dimension(w, h));
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return buttonChooseFolder;
+ }
+
+ private JPanel getPanelBottom() {
+ if (panelBottom == null) {
+ try {
+ panelBottom = new JPanel();
+ panelBottom.setName("PanelBottom");
+ panelBottom.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 10));
+ panelBottom.setPreferredSize(new Dimension(390, 55));
+ panelBottom.add(getButtonInstall(), getButtonInstall().getName());
+ panelBottom.add(getButtonOpenFolder(), getButtonOpenFolder().getName());
+ panelBottom.add(getButtonClose(), getButtonClose().getName());
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return panelBottom;
+ }
+
+ private JButton getButtonInstall() {
+ if (buttonInstall == null) {
+ w = 100;
+ h = 26;
+
+ try {
+ buttonInstall = new JButton();
+ buttonInstall.setName("ButtonInstall");
+ buttonInstall.setPreferredSize(new Dimension(w, h));
+ buttonInstall.setText("Install");
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return buttonInstall;
+ }
+
+ private JButton getButtonOpenFolder() {
+ if (buttonOpenFolder == null) {
+ w = 130;
+ h = 26;
+
+ try {
+ buttonOpenFolder = new JButton();
+ buttonOpenFolder.setName("ButtonOpenFolder");
+ buttonOpenFolder.setPreferredSize(new Dimension(w, h));
+ buttonOpenFolder.setText("Open Mods Folder");
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return buttonOpenFolder;
+ }
+
+ private JButton getButtonClose() {
+ if (buttonClose == null) {
+ w = 100;
+ h = 26;
+
+ try {
+ (buttonClose = new JButton()).setName("ButtonClose");
+ buttonClose.setPreferredSize(new Dimension(w, h));
+ buttonClose.setText("Cancel");
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return buttonClose;
+ }
+
+ public void onFolderSelect() {
+ File currentDirectory = new File(getFieldFolder().getText());
+
+ JFileChooser jFileChooser = new JFileChooser(currentDirectory);
+ jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ jFileChooser.setAcceptAllFileFilterUsed(false);
+ if (jFileChooser.showOpenDialog(this) == 0) {
+ File newDirectory = jFileChooser.getSelectedFile();
+ getFieldFolder().setText(newDirectory.getPath());
+ }
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (e.getSource() == getButtonClose()) {
+ dispose();
+ System.exit(0);
+ }
+ if (e.getSource() == getButtonFolder()) {
+ onFolderSelect();
+ }
+ if (e.getSource() == getButtonInstall()) {
+ onInstall();
+ }
+ if (e.getSource() == getButtonOpenFolder()) {
+ onOpenFolder();
+ }
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ if (e.getSource() == getForgeTextArea()) {
+ try {
+ Desktop.getDesktop().browse(new URI(
+ "http://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.8.9.html"));
+ } catch (IOException | URISyntaxException ex) {
+ showErrorPopup(ex);
+ }
+ }
+ }
+
+ public void onInstall() {
+ try {
+ File modsFolder = new File(getFieldFolder().getText());
+ if (!modsFolder.exists()) {
+ showErrorMessage("Folder not found: " + modsFolder.getPath());
+ return;
+ }
+ if (!modsFolder.isDirectory()) {
+ showErrorMessage("Not a folder: " + modsFolder.getPath());
+ return;
+ }
+ tryInstall(modsFolder);
+ } catch (Exception e) {
+ showErrorPopup(e);
+ }
+ }
+
+ private void tryInstall(File modsFolder) {
+ File thisFile = getThisFile();
+
+ if (thisFile != null) {
+ boolean inSubFolder = IN_MODS_SUBFOLDER.matcher(modsFolder.getPath()).find();
+
+ boolean deletingFailure = false;
+ if (modsFolder.isDirectory()) { // Delete in this current folder.
+ boolean failed = findSkyblockAddonsAndDelete(modsFolder.listFiles());
+ if (failed) deletingFailure = true;
+ }
+ if (inSubFolder) { // We are in the 1.8.9 folder, delete in the parent folder as well.
+ if (modsFolder.getParentFile().isDirectory()) {
+ boolean failed = findSkyblockAddonsAndDelete(modsFolder.getParentFile().listFiles());
+ if (failed) deletingFailure = true;
+ }
+ } else { // We are in the main mods folder, but the 1.8.9 subfolder exists... delete in there too.
+ File subFolder = new File(modsFolder, "1.8.9");
+ if (subFolder.exists() && subFolder.isDirectory()) {
+ boolean failed = findSkyblockAddonsAndDelete(subFolder.listFiles());
+ if (failed) deletingFailure = true;
+ }
+ }
+
+ if (deletingFailure) return;
+
+ if (thisFile.isDirectory()) {
+ showErrorMessage("This file is a directory... Are we in a development environment?");
+ return;
+ }
+
+ try {
+ Files.copy(thisFile.toPath(), new File(modsFolder, thisFile.getName()).toPath());
+ } catch (Exception ex) {
+ showErrorPopup(ex);
+ return;
+ }
+
+ showMessage("NotEnoughUpdates has been successfully installed into your mods folder.");
+ dispose();
+ System.exit(0);
+ }
+ }
+
+ private boolean findSkyblockAddonsAndDelete(File[] files) {
+ if (files == null) return false;
+
+ for (File file : files) {
+ if (!file.isDirectory() && file.getPath().endsWith(".jar")) {
+ try {
+ JarFile jarFile = new JarFile(file);
+ ZipEntry mcModInfo = jarFile.getEntry("mcmod.info");
+ if (mcModInfo != null) {
+ InputStream inputStream = jarFile.getInputStream(mcModInfo);
+ String modID = getModIDFromInputStream(inputStream);
+ if (modID.equals("notenoughupdates")) {
+ jarFile.close();
+ try {
+ boolean deleted = file.delete();
+ if (!deleted) {
+ throw new Exception();
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ showErrorMessage("Was not able to delete the other NotEnoughUpdates files found in your mods folder!" +
+ System.lineSeparator() +
+ "Please make sure that your minecraft is currently closed and try again, or feel" +
+ System.lineSeparator() +
+ "free to open your mods folder and delete those files manually.");
+ return true;
+ }
+ continue;
+ }
+ }
+ jarFile.close();
+ } catch (Exception ex) {
+ // Just don't check the file I guess, move on to the next...
+ }
+ }
+ }
+ return false;
+ }
+
+ public void onOpenFolder() {
+ try {
+ Desktop.getDesktop().open(getModsFolder());
+ } catch (Exception e) {
+ showErrorPopup(e);
+ }
+ }
+
+ public File getModsFolder() {
+ String userHome = System.getProperty("user.home", ".");
+
+ File modsFolder = getFile(userHome, "minecraft/mods/1.8.9");
+ if (!modsFolder.exists()) {
+ modsFolder = getFile(userHome, "minecraft/mods");
+ }
+
+ if (!modsFolder.exists() && !modsFolder.mkdirs()) {
+ throw new RuntimeException("The working directory could not be created: " + modsFolder);
+ }
+ return modsFolder;
+ }
+
+ public File getFile(String userHome, String minecraftPath) {
+ File workingDirectory;
+ switch (getOperatingSystem()) {
+ case LINUX:
+ case SOLARIS: {
+ workingDirectory = new File(userHome, '.' + minecraftPath + '/');
+ break;
+ }
+ case WINDOWS: {
+ String applicationData = System.getenv("APPDATA");
+ if (applicationData != null) {
+ workingDirectory = new File(applicationData, "." + minecraftPath + '/');
+ break;
+ }
+ workingDirectory = new File(userHome, '.' + minecraftPath + '/');
+ break;
+ }
+ case MACOS: {
+ workingDirectory = new File(userHome, "Library/Application Support/" + minecraftPath);
+ break;
+ }
+ default: {
+ workingDirectory = new File(userHome, minecraftPath + '/');
+ break;
+ }
+ }
+ return workingDirectory;
+ }
+
+ public OperatingSystem getOperatingSystem() {
+ String osName = System.getProperty("os.name").toLowerCase(Locale.US);
+ if (osName.contains("win")) {
+ return OperatingSystem.WINDOWS;
+
+ } else if (osName.contains("mac")) {
+ return OperatingSystem.MACOS;
+
+ } else if (osName.contains("solaris") || osName.contains("sunos")) {
+
+ return OperatingSystem.SOLARIS;
+ } else if (osName.contains("linux") || osName.contains("unix")) {
+
+ return OperatingSystem.LINUX;
+ }
+ return OperatingSystem.UNKNOWN;
+ }
+
+ public void centerFrame(JFrame frame) {
+ Rectangle rectangle = frame.getBounds();
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ Rectangle screenRectangle = new Rectangle(0, 0, screenSize.width, screenSize.height);
+
+ int newX = screenRectangle.x + (screenRectangle.width - rectangle.width) / 2;
+ int newY = screenRectangle.y + (screenRectangle.height - rectangle.height) / 2;
+
+ if (newX < 0) newX = 0;
+ if (newY < 0) newY = 0;
+
+ frame.setBounds(newX, newY, rectangle.width, rectangle.height);
+ }
+
+ public void showMessage(String message) {
+ JOptionPane.showMessageDialog(null, message, "NotEnoughUpdates", JOptionPane.INFORMATION_MESSAGE);
+ }
+
+ public void showErrorMessage(String message) {
+ JOptionPane.showMessageDialog(null, message, "NotEnoughUpdates - Error", JOptionPane.ERROR_MESSAGE);
+ }
+
+ public enum OperatingSystem {
+ LINUX,
+ SOLARIS,
+ WINDOWS,
+ MACOS,
+ UNKNOWN
+ }
+
+ private static String getStacktraceText(Throwable ex) {
+ StringWriter stringWriter = new StringWriter();
+ ex.printStackTrace(new PrintWriter(stringWriter));
+ return stringWriter.toString().replace("\t", " ");
+ }
+
+ private static void showErrorPopup(Throwable ex) {
+ ex.printStackTrace();
+
+ JTextArea textArea = new JTextArea(getStacktraceText(ex));
+ textArea.setEditable(false);
+ Font currentFont = textArea.getFont();
+ Font newFont