diff options
-rw-r--r-- | src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java | 48 | ||||
-rw-r--r-- | src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java | 8 | ||||
-rw-r--r-- | src/main/resources/assets/skyblockhud/stats.png | bin | 6061 -> 13749 bytes |
3 files changed, 47 insertions, 9 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java index 223eaf0..a2d113d 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java @@ -1,10 +1,13 @@ package com.thatgravyboat.skyblockhud.location; +import com.thatgravyboat.skyblockhud.api.events.LocationChangeEvent; import com.thatgravyboat.skyblockhud.api.events.ProfileSwitchedEvent; import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent; import com.thatgravyboat.skyblockhud.utils.Utils; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import java.util.Locale; + public class IslandHandler { public static int flightTime; @@ -13,29 +16,42 @@ public class IslandHandler { public static int redstone; public static boolean hadRedstone; + public static float cleanupPercentage; + public static boolean hadCleanupPercentage; + @SubscribeEvent public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { hadFlightTime = checkFlightDuration(event.formattedLine); hadRedstone = checkRestone(event.formattedLine); + hadCleanupPercentage |= checkPlotClearPercentage(event.formattedLine); } @SubscribeEvent + public void onLocationChange(LocationChangeEvent event) { + hadCleanupPercentage = false; + } + + + @SubscribeEvent public void onProfileSwitch(ProfileSwitchedEvent event) { flightTime = 0; } public static boolean checkFlightDuration(String formatedScoreboardLine) { - if (LocationHandler.getCurrentLocation() == Locations.YOURISLAND && Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()).contains("flight duration:")) { + if (LocationHandler.getCurrentLocation().getCategory() == LocationCategory.ISLAND + && Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()).contains("flight duration:")) { String timeString = formatedScoreboardLine.toLowerCase().replace("flight duration:", "").replace(" ", ""); String[] times = timeString.split(":"); if (times.length == 2) { int s = 0; try { s += Integer.parseInt(times[0].replaceAll(",", "")) * 60; - } catch (NumberFormatException ignored) {} + } catch (NumberFormatException ignored) { + } try { s += Integer.parseInt(times[1].replaceAll(",", "")); - } catch (NumberFormatException ignored) {} + } catch (NumberFormatException ignored) { + } flightTime = s - 1; } else if (times.length == 3) { int s = 0; @@ -44,10 +60,12 @@ public class IslandHandler { } catch (NumberFormatException ignored) {} try { s += Integer.parseInt(times[1].replaceAll(",", "")) * 60; - } catch (NumberFormatException ignored) {} + } catch (NumberFormatException ignored) { + } try { s += Integer.parseInt(times[2].replaceAll(",", "")); - } catch (NumberFormatException ignored) {} + } catch (NumberFormatException ignored) { + } flightTime = s - 1; } return true; @@ -55,12 +73,28 @@ public class IslandHandler { return false; } + public static boolean checkPlotClearPercentage(String formatedScoreboardLine) { + if (LocationHandler.getCurrentLocation() == Locations.THEGARDEN) { + String lowered = formatedScoreboardLine.toLowerCase(Locale.ROOT); + if (lowered.contains("cleanup:")) { + try { + String s = Utils.removeWhiteSpaceAndRemoveWord(lowered, "cleanup:").replace("%", ""); + cleanupPercentage = Float.parseFloat(s); + return true; + } catch (Exception ignored) { + } + } + } + return false; + } + public static boolean checkRestone(String formatedScoreboardLine) { if (LocationHandler.getCurrentLocation() == Locations.YOURISLAND) { - if (formatedScoreboardLine.toLowerCase().contains("redstone:")) return true; try { redstone = formatedScoreboardLine.toLowerCase().contains("redstone:") ? Integer.parseInt(Utils.removeWhiteSpaceAndRemoveWord(formatedScoreboardLine, "redstone:").replaceAll(",", "")) : 0; - } catch (Exception ignored) {} + } catch (Exception ignored) { + } + return formatedScoreboardLine.toLowerCase().contains("redstone:"); } return false; } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java index 4efef81..73d16b5 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java @@ -55,7 +55,7 @@ public class OverlayHud extends Gui { drawSeasonAndDate(width, offset, mc); //REDSTONE PERCENT - drawRedstone(width, offset, mc); + drawIslandInformation(width, offset, mc); // LOCATION drawLocation(width, offset, mc); @@ -108,7 +108,7 @@ public class OverlayHud extends Gui { drawString(font, LocationHandler.getCurrentLocation().getDisplayName(), (width / 2) - 19 - (font.getStringWidth(LocationHandler.getCurrentLocation().getDisplayName())), offset + (bossBarVisible ? 23 : 6), 0xFFFFFF); } - public void drawRedstone(int width, int offset, Minecraft mc) { + public void drawIslandInformation(int width, int offset, Minecraft mc) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(Textures.texture.stats); int redstoneColor = IslandHandler.redstone > 90 ? 0xFF0000 : IslandHandler.redstone > 75 ? 0xC45B00 : IslandHandler.redstone > 50 ? 0xFFFF55 : 0x55FF55; @@ -116,6 +116,10 @@ public class OverlayHud extends Gui { drawTexturedModalRect((width / 2) - 15, offset + (bossBarVisible ? 51 : 34), 0, 48, 30, 18); drawTexturedModalRect((width / 2) - 4, offset + (bossBarVisible ? 51 : 34), 59, 0, 8, 8); drawCenteredString(mc.fontRendererObj, IslandHandler.redstone + "%", (width / 2), offset + (bossBarVisible ? 58 : 41), redstoneColor); + } else if (IslandHandler.hadCleanupPercentage && IslandHandler.cleanupPercentage < 100) { + drawTexturedModalRect((width / 2) - 15, offset + (bossBarVisible ? 51 : 34), 0, 48, 30, 18); + drawTexturedModalRect((width / 2) - 4, offset + (bossBarVisible ? 51 : 34), 187, 0, 8, 8); + drawCenteredString(mc.fontRendererObj, IslandHandler.cleanupPercentage + "%", (width / 2), offset + (bossBarVisible ? 58 : 41), 0xFFFF55); } } diff --git a/src/main/resources/assets/skyblockhud/stats.png b/src/main/resources/assets/skyblockhud/stats.png Binary files differindex b1133c7..49ccf7e 100644 --- a/src/main/resources/assets/skyblockhud/stats.png +++ b/src/main/resources/assets/skyblockhud/stats.png |