diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/DefenitlyNotAJoikedInstallerFrame.java | 682 | ||||
-rw-r--r-- | src/main/java/me/Danker/commands/DisplayCommand.java | 11 | ||||
-rw-r--r-- | src/main/java/me/Danker/commands/ToggleCommand.java | 24 | ||||
-rw-r--r-- | src/main/java/me/Danker/features/AutoDisplay.java | 3 | ||||
-rw-r--r-- | src/main/java/me/Danker/features/loot/LootDisplay.java | 30 | ||||
-rw-r--r-- | src/main/java/me/Danker/features/loot/LootTracker.java | 56 | ||||
-rw-r--r-- | src/main/java/me/Danker/gui/DisplayGui.java | 8 | ||||
-rw-r--r-- | src/main/java/me/Danker/handlers/ConfigHandler.java | 12 |
8 files changed, 815 insertions, 11 deletions
diff --git a/src/main/java/DefenitlyNotAJoikedInstallerFrame.java b/src/main/java/DefenitlyNotAJoikedInstallerFrame.java new file mode 100644 index 0000000..e4c9b64 --- /dev/null +++ b/src/main/java/DefenitlyNotAJoikedInstallerFrame.java @@ -0,0 +1,682 @@ +import javax.imageio.ImageIO; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.image.BufferedImage; +import java.io.*; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.util.Locale; +import java.util.Objects; +import java.util.jar.JarFile; +import java.util.regex.Pattern; +import java.util.zip.ZipEntry; + +public class DefenitlyNotAJoikedInstallerFrame 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 = 442; //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 DefenitlyNotAJoikedInstallerFrame() { + try { + setName("DankersSkyblockModInstallerFrame"); + setTitle("DSM 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()); + DefenitlyNotAJoikedInstallerFrame frame = new DefenitlyNotAJoikedInstallerFrame(); + 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(Objects.requireNonNull(getClass().getClassLoader() + .getResourceAsStream("assets/dsm/icons/logo.png"), "Logo not found.")); + 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(w, h)); + + y += h; + } catch (Throwable ivjExc) { + showErrorPopup(ivjExc); + } + } + return logo; + } + + private JLabel getVersionInfo() { + if (versionInfo == null) { + try { + h = 47; //34 + + versionInfo = new JLabel(); + versionInfo.setName("LabelMcVersion"); + versionInfo.setBounds(x, y+1, w, h); + versionInfo.setFont(new Font(Font.DIALOG, Font.BOLD, 14)); + versionInfo.setHorizontalAlignment(SwingConstants.CENTER); + versionInfo.setPreferredSize(new Dimension(w, h)); + versionInfo.setText("<html><body>Danker's Skyblock Mod - Installer by Biscuit <br><center> for Minecraft 1.8.9</center></body></html>"); + + y += h-5; + } catch (Throwable ivjExc) { + showErrorPopup(ivjExc); + } + } + return versionInfo; + } + + + private JTextArea getTextArea() { + if (descriptionText == null) { + try { + h = 60; + margin = 10; + + descriptionText = new JTextArea(); + descriptionText.setName("TextArea"); + setTextAreaProperties(descriptionText); + descriptionText.setText("This installer will copy Danker's Skyblock Mod 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 void setTextAreaProperties(JTextArea textArea) { + textArea.setBounds(x+margin, y+margin, w-margin*2, h-margin); + textArea.setEditable(false); + textArea.setHighlighter(null); + textArea.setEnabled(true); + textArea.setFont(new Font(Font.DIALOG, Font.PLAIN, 12)); + textArea.setLineWrap(true); + textArea.setOpaque(false); + textArea.setPreferredSize(new Dimension(w-margin*2, h-margin)); + } + + private JTextArea getForgeTextArea() { + if (forgeDescriptionText == null) { + try { + h = 55; + margin = 10; + + forgeDescriptionText = new JTextArea(); + forgeDescriptionText.setName("TextAreaForge"); + + + setTextAreaProperties(forgeDescriptionText); + + + + + + 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(Objects.requireNonNull(getClass().getClassLoader() + .getResourceAsStream("assets/dsm/icons/folder.png"), "Folder icon not found.")); + 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 = false; + if (IN_MODS_SUBFOLDER.matcher(modsFolder.getPath()).find()) { + inSubFolder = true; + } + + File newFile = new File(modsFolder, "Danker's Skyblock Mod-"+getVersionFromMcmodInfo()+".jar"); + if (thisFile.equals(newFile)) { + showErrorMessage("You are opening this file from where the file should be installed... there's nothing to be done!"); + return; + } + + boolean deletingFailure = false; + if (modsFolder.isDirectory()) { // Delete in this current folder. + boolean failed = findDSMAndDelete(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 = findDSMAndDelete(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 = findDSMAndDelete(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(), newFile.toPath()); + } catch (Exception ex) { + showErrorPopup(ex); + return; + } + + showMessage("Danker's SkyblockMod has been successfully installed into your mods folder."); + dispose(); + System.exit(0); + } + } + + private boolean findDSMAndDelete(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("Danker's Skyblock Mod")) { + 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 DSM 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, "Danker's Skyblock Mod", JOptionPane.INFORMATION_MESSAGE); + } + + public void showErrorMessage(String message) { + JOptionPane.showMessageDialog(null, message, "Danker's Skyblock Mod - 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(Objects.requireNonNull(getClass(). + getClassLoader().getResourceAsStream("mcmod.info"), "mcmod.info not found."))); + 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(DefenitlyNotAJoikedInstallerFrame.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) {} +} diff --git a/src/main/java/me/Danker/commands/DisplayCommand.java b/src/main/java/me/Danker/commands/DisplayCommand.java index 74f142a..7760ec9 100644 --- a/src/main/java/me/Danker/commands/DisplayCommand.java +++ b/src/main/java/me/Danker/commands/DisplayCommand.java @@ -21,7 +21,7 @@ public class DisplayCommand extends CommandBase { @Override public String getCommandUsage(ICommandSender arg0) { - return "/" + getCommandName() + " <zombie/spider/wolf/fishing/catacombs/mythological/auto/off> [winter/festival/spooky/session/f(1-7)]"; + return "/" + getCommandName() + " <zombie/spider/wolf/fishing/catacombs/mythological/ghost/auto/off> [winter/festival/spooky/session/f(1-7)]"; } @Override @@ -32,7 +32,7 @@ public class DisplayCommand extends CommandBase { @Override public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { if (args.length == 1) { - return getListOfStringsMatchingLastWord(args, "wolf", "spider", "zombie", "fishing", "catacombs", "mythological", "auto", "off"); + return getListOfStringsMatchingLastWord(args, "wolf", "spider", "zombie", "fishing", "catacombs", "mythological", "ghost", "auto", "off"); } else if (args.length == 2 && args[0].equalsIgnoreCase("fishing")) { return getListOfStringsMatchingLastWord(args, "winter", "festival", "spooky", "session"); } else if (args.length == 2 && args[0].equalsIgnoreCase("catacombs")) { @@ -192,6 +192,13 @@ public class DisplayCommand extends CommandBase { return; } break; + case "ghost": + if (showSession) { + LootDisplay.display = "ghost_session"; + } else { + LootDisplay.display = "ghost"; + } + case "auto": LootDisplay.auto = true; player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Display set to " + DankersSkyblockMod.SECONDARY_COLOUR + "auto" + DankersSkyblockMod.MAIN_COLOUR + ".")); diff --git a/src/main/java/me/Danker/commands/ToggleCommand.java b/src/main/java/me/Danker/commands/ToggleCommand.java index e44f8ce..ebe957a 100644 --- a/src/main/java/me/Danker/commands/ToggleCommand.java +++ b/src/main/java/me/Danker/commands/ToggleCommand.java @@ -18,6 +18,7 @@ public class ToggleCommand extends CommandBase implements ICommand { public static boolean goldenToggled; public static boolean slayerCountTotal; public static boolean rngesusAlerts; + public static boolean ghostDisplay; public static boolean splitFishing; public static boolean chatMaddoxToggled; public static boolean spiritBearAlerts; @@ -26,6 +27,7 @@ public class ToggleCommand extends CommandBase implements ICommand { public static boolean shadowFuryToggled; public static boolean petColoursToggled; public static boolean dungeonTimerToggled; + public static boolean ghostTimerToggled; public static boolean golemAlertToggled; public static boolean expertiseLoreToggled; public static boolean skill50DisplayToggled; @@ -81,15 +83,14 @@ public class ToggleCommand extends CommandBase implements ICommand { @Override public String getCommandUsage(ICommandSender arg0) { - return "/" + getCommandName() + " <gparty/coords/golden/slayercount/rngesusalerts/splitfishing/chatmaddox/spiritbearalert/" + - "aotd/lividdagger/shadowfury/flowerweapons/sceptremessages/petcolors/dungeontimer/golemalerts/expertiselore/" + + return "/" + getCommandName() + " <gparty/coords/golden/slayercount/rngesusalerts/splitfishing/ghostdisplay/chatmaddox/spiritbearalert/" + + "aotd/lividdagger/shadowfury/flowerweapons/sceptremessages/petcolors/dungeontimer/golemalerts/expertiselore/" + //ghosttimer "skill50display/outlinetext/midasstaffmessages/implosionmessages/healmessages/cooldownmessages/" + "manamessages/killcombomessages/caketimer/lowhealthnotify/lividsolver/stopsalvagestarred/" + "notifyslayerslain/necronnotifications/bonzotimer/threemanpuzzle/oruopuzzle/blazepuzzle/" + "creeperpuzzle/waterpuzzle/tictactoepuzzle/boulderpuzzle/silverfishpuzzle/watchermessage/" + "startswithterminal/selectallterminal/clickinorderterminal/blockwrongterminalclicks/" + - "itemframeonsealanterns/ultrasequencer/chronomatron/superpairs/hidetooltipsinaddons/pickblock/ " + - "/specialhoe/melodytooltips/list>"; + "itemframeonsealanterns/ultrasequencer/chronomatron/superpairs/hidetooltipsinaddons/pickblock/list>"; } @Override @@ -100,9 +101,9 @@ public class ToggleCommand extends CommandBase implements ICommand { @Override public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { if (args.length == 1) { - return getListOfStringsMatchingLastWord(args, "gparty", "coords", "golden", "slayercount", "rngesusalerts", + return getListOfStringsMatchingLastWord(args, "gparty", "coords", "golden", "slayercount", "rngesusalerts", "ghostdisplay", "splitfishing", "chatmaddox", "spiritbearalerts", "aotd", "lividdagger", "shadowfury", - "flowerweapons", "sceptremessages", "petcolors", "dungeontimer", "golemalerts", + "flowerweapons", "sceptremessages", "petcolors", "dungeontimer", /*"ghosttimer",*/"golemalerts", "expertiselore", "skill50display", "outlinetext", "midasstaffmessages", "implosionmessages", "healmessages", "cooldownmessages", "manamessages", "killcombomessages", "caketimer", "lowhealthnotify", "autoskilltracker", "lividsolver", @@ -152,6 +153,11 @@ public class ToggleCommand extends CommandBase implements ICommand { ConfigHandler.writeBooleanConfig("toggles", "RNGesusAlerts", rngesusAlerts); player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Slayer RNGesus alerts has been set to " + DankersSkyblockMod.SECONDARY_COLOUR + rngesusAlerts + DankersSkyblockMod.MAIN_COLOUR + ".")); break; + case "ghostDisplay": + ghostDisplay = !ghostDisplay; + ConfigHandler.writeBooleanConfig("toggles", "GhostDisplay", ghostDisplay); + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Ghost Display has been set to " + DankersSkyblockMod.SECONDARY_COLOUR + ghostDisplay + DankersSkyblockMod.MAIN_COLOUR + ".")); + break; case "splitfishing": splitFishing = !splitFishing; ConfigHandler.writeBooleanConfig("toggles", "SplitFishing", splitFishing); @@ -233,6 +239,11 @@ public class ToggleCommand extends CommandBase implements ICommand { ConfigHandler.writeBooleanConfig("toggles", "DungeonTimer", dungeonTimerToggled); player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Dungeon timer has been set to " + DankersSkyblockMod.SECONDARY_COLOUR + dungeonTimerToggled + DankersSkyblockMod.MAIN_COLOUR + ".")); break; + /*case "ghostTimer": + ghostTimerToggled = !ghostTimerToggled; + ConfigHandler.writeBooleanConfig("toggles", "GhostTimer", ghostTimerToggled); + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Ghost timer has been set to " + DankersSkyblockMod.SECONDARY_COLOUR + ghostTimerToggled + DankersSkyblockMod.MAIN_COLOUR + ".")); + break; */ case "golemalerts": golemAlertToggled = !golemAlertToggled; ConfigHandler.writeBooleanConfig("toggles", "GolemAlerts", golemAlertToggled); @@ -416,6 +427,7 @@ public class ToggleCommand extends CommandBase implements ICommand { DankersSkyblockMod.TYPE_COLOUR + " Heal messages: " + DankersSkyblockMod.VALUE_COLOUR + healMessages + "\n" + DankersSkyblockMod.TYPE_COLOUR + " Ability cooldown messages: " + DankersSkyblockMod.VALUE_COLOUR + cooldownMessages + "\n" + DankersSkyblockMod.TYPE_COLOUR + " Out of mana messages: " + DankersSkyblockMod.VALUE_COLOUR + manaMessages + "\n" + + DankersSkyblockMod.TYPE_COLOUR + " Kill combo messages: " + DankersSkyblockMod.VALUE_COLOUR + killComboMessages + "\n" + DankersSkyblockMod.TYPE_COLOUR + " Pet colours: " + DankersSkyblockMod.VALUE_COLOUR + petColoursToggled + "\n" + DankersSkyblockMod.TYPE_COLOUR + " Dungeon timer: " + DankersSkyblockMod.VALUE_COLOUR + dungeonTimerToggled + "\n" + DankersSkyblockMod.TYPE_COLOUR + " Golem spawn alerts: " + DankersSkyblockMod.VALUE_COLOUR + golemAlertToggled + "\n" + diff --git a/src/main/java/me/Danker/features/AutoDisplay.java b/src/main/java/me/Danker/features/AutoDisplay.java index 876fb6a..182c0b4 100644 --- a/src/main/java/me/Danker/features/AutoDisplay.java +++ b/src/main/java/me/Danker/features/AutoDisplay.java @@ -37,6 +37,9 @@ public class AutoDisplay { } else if (sCleaned.contains("Revenant Horror")) { LootDisplay.display = "zombie"; found = true; + } else if (sCleaned.contains("The Mist")){ + LootDisplay.display = "ghost"; + found = true; } else if (sCleaned.contains("The Catacombs (")) { if (sCleaned.contains("F1")) { LootDisplay.display = "catacombs_floor_one"; diff --git a/src/main/java/me/Danker/features/loot/LootDisplay.java b/src/main/java/me/Danker/features/loot/LootDisplay.java index 363b70c..e3f43e8 100644 --- a/src/main/java/me/Danker/features/loot/LootDisplay.java +++ b/src/main/java/me/Danker/features/loot/LootDisplay.java @@ -892,6 +892,36 @@ public class LootDisplay { EnumChatFormatting.AQUA + Utils.getMoneySpent(LootTracker.f7CoinsSpentSession) + "\n" + EnumChatFormatting.AQUA + Utils.getTimeBetween(0, LootTracker.f7TimeSpentSession); break; + case "ghost_session": + dropsText = EnumChatFormatting.GOLD + "Bags of Cash:\n" + + EnumChatFormatting.BLUE + "Sorrows:\n" + + EnumChatFormatting.DARK_PURPLE + "Ghosty Boots:\n" + + EnumChatFormatting.DARK_PURPLE + "Voltas:\n" + + EnumChatFormatting.DARK_PURPLE + "Plasmas:" ; // + \n + // EnumChatFormatting.AQUA + "Time Spent:" + + countText = EnumChatFormatting.GOLD + nf.format(LootTracker.bagOfCashSession) + "\n" + + EnumChatFormatting.BLUE + nf.format(LootTracker.sorrowSession) + "\n" + + EnumChatFormatting.DARK_PURPLE + nf.format(LootTracker.ghostlyBootsSession) + "\n" + + EnumChatFormatting.DARK_PURPLE + nf.format(LootTracker.voltaSession) + "\n" + + EnumChatFormatting.DARK_PURPLE + nf.format(LootTracker.plasmaSession); //+ "\n" + + // EnumChatFormatting.AQUA + nf.format(LootTracker.ghostsTimeSpentSession); + break; + case "ghost": + dropsText = EnumChatFormatting.GOLD + "Bags of Cash:\n" + + EnumChatFormatting.BLUE + "Sorrows:\n" + + EnumChatFormatting.DARK_PURPLE + "Ghosty Boots:\n" + + EnumChatFormatting.DARK_PURPLE + "Voltas:\n" + + EnumChatFormatting.DARK_PURPLE + "Plasmas:" ; // + \n + // EnumChatFormatting.AQUA + "Time Spent:" + + countText = EnumChatFormatting.GOLD + nf.format(LootTracker.bagOfCashSession) + "\n" + + EnumChatFormatting.BLUE + nf.format(LootTracker.sorrowSession) + "\n" + + EnumChatFormatting.DARK_PURPLE + nf.format(LootTracker.ghostlyBootsSession) + "\n" + + EnumChatFormatting.DARK_PURPLE + nf.format(LootTracker.voltaSession) + "\n" + + EnumChatFormatting.DARK_PURPLE + nf.format(LootTracker.plasmaSession); //+ "\n" + + // EnumChatFormatting.AQUA + nf.format(LootTracker.ghostsTimeSpentSession); + break; + + default: System.out.println("Display was an unknown value, turning off."); display = "off"; diff --git a/src/main/java/me/Danker/features/loot/LootTracker.java b/src/main/java/me/Danker/features/loot/LootTracker.java index f7f7044..6430bc2 100644 --- a/src/main/java/me/Danker/features/loot/LootTracker.java +++ b/src/main/java/me/Danker/features/loot/LootTracker.java @@ -176,6 +176,15 @@ public class LootTracker { public static int witherBoots; public static double f7CoinsSpent; public static double f7TimeSpent; + // Ghosts + public static int sorrows = 0; + public static int bagOfCashs = 0; + public static int voltas = 0; + public static int plasmas = 0; + public static int ghostlyBoots = 0; + // public static double ghostsTimeSpent = -1; + + // Single sessions (No config saves) // Wolf @@ -336,6 +345,14 @@ public class LootTracker { public static int witherBootsSession = 0; public static double f7CoinsSpentSession = 0; public static double f7TimeSpentSession = 0; + // Ghosts + public static int sorrowSession = 0; + public static int bagOfCashSession = 0; + public static int voltaSession = 0; + public static int plasmaSession = 0; + public static int ghostlyBootsSession = 0; + // public static double ghostsSecondsSinceStarts = 0; + static double checkItemsNow = 0; static double itemsChecked = 0; @@ -344,6 +361,7 @@ public class LootTracker { public void onChat(ClientChatReceivedEvent event) { String message = StringUtils.stripControlCodes(event.message.getUnformattedText()); + if (!Utils.inSkyblock) return; if (event.type == 2) return; if (message.contains(":")) return; @@ -352,6 +370,8 @@ public class LootTracker { boolean spiderRNG = false; boolean zombieRNG = false; + + // Slayer tracker // T6 books if (message.contains("VERY RARE DROP! (Enchanted Book)") || message.contains("CRAZY RARE DROP! (Enchanted Book)")) { @@ -369,6 +389,7 @@ public class LootTracker { zombieBooks++; ConfigHandler.writeIntConfig("zombie", "book", zombieBooks); } + } } @@ -957,6 +978,41 @@ public class LootTracker { ConfigHandler.writeIntConfig("mythological", "minosInquisitor", minosInquisitors); } } + + + if (message.contains("RARE DROP!")) { + if (message.contains("Sorrow")) { + sorrows++; + sorrowSession++; + ConfigHandler.writeIntConfig("ghosts", "sorrow", sorrows); + } + if (message.contains("Volta")) { + voltas++; + voltaSession++; + ConfigHandler.writeIntConfig("ghosts", "volta", voltas); + } + if (message.contains("Plasma")) { + plasmas++; + plasmaSession++; + ConfigHandler.writeIntConfig("ghosts", "plasma", plasmas); + } + if (message.contains("Ghostly Boots")) { + ghostlyBoots++; + ghostlyBootsSession++; + ConfigHandler.writeIntConfig("ghosts", "ghostlyBoots", ghostlyBoots); + } + if (message.contains("Bag of Cash")) { + bagOfCashs++; + bagOfCashSession++; + ConfigHandler.writeIntConfig("ghosts", "bagOfCash", bagOfCashs); + } + + + + } + + + } @SubscribeEvent diff --git a/src/main/java/me/Danker/gui/DisplayGui.java b/src/main/java/me/Danker/gui/DisplayGui.java index ceda556..f38c29e 100644 --- a/src/main/java/me/Danker/gui/DisplayGui.java +++ b/src/main/java/me/Danker/gui/DisplayGui.java @@ -33,6 +33,7 @@ public class DisplayGui extends GuiScreen { private GuiButton catacombsF5; private GuiButton catacombsF6; private GuiButton catacombsF7; + private GuiButton ghost; @Override public boolean doesGuiPauseGame() { @@ -58,7 +59,7 @@ public class DisplayGui extends GuiScreen { fishingWinter = new GuiButton(0, width / 2 - 110, (int) (height * 0.4), 100, 20, "Fishing Winter"); fishingFestival = new GuiButton(0, width / 2 + 10, (int) (height * 0.4), 100, 20, "Fishing Festival"); fishingSpooky = new GuiButton(0, width / 2 + 130, (int) (height * 0.4), 100, 20, "Fishing Spooky"); - mythological = new GuiButton(0, width / 2 - 100, (int) (height * 0.5), 200, 20, "Mythological"); + mythological = new GuiButton(0, width / 2 - 100, (int) (height * 0.5), 95, 20, "Mythological"); catacombsF1 = new GuiButton(0, width / 2 - 205, (int) (height * 0.65), 50, 20, "F1"); catacombsF2 = new GuiButton(0, width / 2 - 145, (int) (height * 0.65), 50, 20, "F2"); catacombsF3 = new GuiButton(0, width / 2 - 85, (int) (height * 0.65), 50, 20, "F3"); @@ -66,6 +67,7 @@ public class DisplayGui extends GuiScreen { catacombsF5 = new GuiButton(0, width / 2 + 35, (int) (height * 0.65), 50, 20, "F5"); catacombsF6 = new GuiButton(0, width / 2 + 95, (int) (height * 0.65), 50, 20, "F6"); catacombsF7 = new GuiButton(0, width / 2 + 155, (int) (height * 0.65), 50, 20, "F7"); + ghost = new GuiButton(0, width / 2 + 5, (int) (height * 0.5), 95, 20, "Ghost"); this.buttonList.add(showSession); this.buttonList.add(off); @@ -85,6 +87,7 @@ public class DisplayGui extends GuiScreen { this.buttonList.add(catacombsF5); this.buttonList.add(catacombsF6); this.buttonList.add(catacombsF7); + this.buttonList.add(ghost); this.buttonList.add(goBack); } @@ -151,7 +154,8 @@ public class DisplayGui extends GuiScreen { setDisplay("catacombs_floor_six", false); } else if (button == catacombsF7) { setDisplay("catacombs_floor_seven", false); - } + } else if (button == ghost) + setDisplay("ghost",false); } public void setDisplay(String display, boolean forceNoSession) { diff --git a/src/main/java/me/Danker/handlers/ConfigHandler.java b/src/main/java/me/Danker/handlers/ConfigHandler.java index 892f231..491ae36 100644 --- a/src/main/java/me/Danker/handlers/ConfigHandler.java +++ b/src/main/java/me/Danker/handlers/ConfigHandler.java @@ -214,6 +214,8 @@ public class ConfigHandler { ToggleCommand.goldenToggled = initBoolean("toggles", "Golden", false); ToggleCommand.slayerCountTotal = initBoolean("toggles", "SlayerCount", true); ToggleCommand.rngesusAlerts = initBoolean("toggles", "RNGesusAlerts", false); + ToggleCommand.ghostDisplay = initBoolean("toggles", "GhostDisplay", true); + ToggleCommand.dungeonTimerToggled = initBoolean("toggles", "GhostTimer", false); ToggleCommand.splitFishing = initBoolean("toggles", "SplitFishing", true); ToggleCommand.chatMaddoxToggled = initBoolean("toggles", "ChatMaddox", false); ToggleCommand.spiritBearAlerts = initBoolean("toggles", "SpiritBearAlerts", false); @@ -437,7 +439,15 @@ public class ConfigHandler { LootTracker.witherBoots = initInt("catacombs", "witherBoot", 0); LootTracker.f7CoinsSpent = initDouble("catacombs", "floorSevenCoins", 0); LootTracker.f7TimeSpent = initDouble("catacombs", "floorSevenTime", 0); - + + // Ghost + LootTracker.sorrows = initInt("ghosts", "sorrow", 0); + LootTracker.voltas = initInt("ghosts", "volta", 0); + LootTracker.plasmas = initInt("ghosts", "plasma", 0); + LootTracker.ghostlyBoots = initInt("ghosts", "ghostlyBoots", 0); + LootTracker.bagOfCashs = initInt("ghosts", "bagOfCash", 0); + + // Misc LootDisplay.display = initString("misc", "display", "off"); LootDisplay.auto = initBoolean("misc", "autoDisplay", false); |