diff options
author | TymanWasTaken <tyman@tyman.tech> | 2021-07-06 17:13:01 -0400 |
---|---|---|
committer | TymanWasTaken <tyman@tyman.tech> | 2021-07-06 17:13:01 -0400 |
commit | bb75fd7b83b238f1f922ffc64b2a0a535c5524b7 (patch) | |
tree | 617c91cced71f672662bddea6c540939cb9a3953 /src/main/java/com/thatgravyboat/skyblockhud/seasons | |
parent | 91464c8f433e8bf323932ac956678971207b607e (diff) | |
download | SkyblockHud-Death-Defied-bb75fd7b83b238f1f922ffc64b2a0a535c5524b7.tar.gz SkyblockHud-Death-Defied-bb75fd7b83b238f1f922ffc64b2a0a535c5524b7.tar.bz2 SkyblockHud-Death-Defied-bb75fd7b83b238f1f922ffc64b2a0a535c5524b7.zip |
Format
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/seasons')
-rw-r--r-- | src/main/java/com/thatgravyboat/skyblockhud/seasons/Season.java | 93 | ||||
-rw-r--r-- | src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java | 126 |
2 files changed, 135 insertions, 84 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/seasons/Season.java b/src/main/java/com/thatgravyboat/skyblockhud/seasons/Season.java index e55c0fa..61524ee 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/seasons/Season.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/seasons/Season.java @@ -1,50 +1,53 @@ package com.thatgravyboat.skyblockhud.seasons; public enum Season { - EARLYSPRING("earlyspring", "Early Spring", 34, 0), - SPRING("spring", "Spring", 34, 31), - LATESPRING("latespring", "Late Spring", 34, 62), - EARLYSUMMER("earlysummer", "Early Summer", 42, 93), - SUMMER("summer", "Summer", 42, 124), - LATESUMMER("latesummer", "Late Summer", 42, 155), - EARLYAUTUMN("earlyautumn", "Early Autumn", 50, 186), - AUTUMN("autumn", "Autumn", 50, 217), - LATEAUTUMN("lateautumn", "Late Autumn", 50, 248), - EARLYWINTER("earlywinter", "Early Winter", 58, 279), - WINTER("winter", "Winter", 58, 310), - LATEWINTER("latewinter", "Late Winter", 58, 341), - ERROR("error", "Error", 0, -1); - - - - - private final String name; - private final String displayName; - private final int textureX; - private final int yearStartDay; - - Season(String name, String displayName, int textureX, int yearStartDay){ - this.name = name; - this.displayName = displayName; - this.textureX = textureX; - this.yearStartDay = yearStartDay; + EARLYSPRING("earlyspring", "Early Spring", 34, 0), + SPRING("spring", "Spring", 34, 31), + LATESPRING("latespring", "Late Spring", 34, 62), + EARLYSUMMER("earlysummer", "Early Summer", 42, 93), + SUMMER("summer", "Summer", 42, 124), + LATESUMMER("latesummer", "Late Summer", 42, 155), + EARLYAUTUMN("earlyautumn", "Early Autumn", 50, 186), + AUTUMN("autumn", "Autumn", 50, 217), + LATEAUTUMN("lateautumn", "Late Autumn", 50, 248), + EARLYWINTER("earlywinter", "Early Winter", 58, 279), + WINTER("winter", "Winter", 58, 310), + LATEWINTER("latewinter", "Late Winter", 58, 341), + ERROR("error", "Error", 0, -1); + + private final String name; + private final String displayName; + private final int textureX; + private final int yearStartDay; + + Season(String name, String displayName, int textureX, int yearStartDay) { + this.name = name; + this.displayName = displayName; + this.textureX = textureX; + this.yearStartDay = yearStartDay; + } + + public String getName() { + return this.name; + } + + public String getDisplayName() { + return this.displayName; + } + + public int getTextureX() { + return this.textureX; + } + + public int getYearStartDay() { + return yearStartDay; + } + + public static Season get(String id) { + try { + return Season.valueOf(id); + } catch (IllegalArgumentException ex) { + return ERROR; } - - public String getName(){ - return this.name; - } - public String getDisplayName(){ - return this.displayName; - } - public int getTextureX() { return this.textureX; } - public int getYearStartDay() { return yearStartDay; } - - public static Season get(String id) { - try { - return Season.valueOf(id); - } catch (IllegalArgumentException ex) { - return ERROR; - } - } - + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java index 1e22afc..06b7009 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java @@ -2,56 +2,104 @@ package com.thatgravyboat.skyblockhud.seasons; import com.thatgravyboat.skyblockhud.Utils; import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - import java.util.regex.Pattern; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class SeasonDateHandler { - private static Season currentSeason = Season.ERROR; - private static int currentDate = 1; - private static String currentEvent = ""; - private static String eventTime = ""; + private static Season currentSeason = Season.ERROR; + private static int currentDate = 1; + private static String currentEvent = ""; + private static String eventTime = ""; - - @SubscribeEvent - public void onSidebarLineUpdate(SidebarLineUpdateEvent event){ - if (Season.get(SeasonDateHandler.removeDate(event.formattedLine.toLowerCase()).toUpperCase()) != Season.ERROR) { - SeasonDateHandler.setCurrentDateAndSeason(SeasonDateHandler.removeSeason(Utils.removeColor(event.formattedLine.toLowerCase().trim())), SeasonDateHandler.removeDate(Utils.removeColor(event.formattedLine.toLowerCase().trim())).toUpperCase()); - } + @SubscribeEvent + public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { + if ( + Season.get( + SeasonDateHandler + .removeDate(event.formattedLine.toLowerCase()) + .toUpperCase() + ) != + Season.ERROR + ) { + SeasonDateHandler.setCurrentDateAndSeason( + SeasonDateHandler.removeSeason( + Utils.removeColor(event.formattedLine.toLowerCase().trim()) + ), + SeasonDateHandler + .removeDate( + Utils.removeColor(event.formattedLine.toLowerCase().trim()) + ) + .toUpperCase() + ); } + } - public static void setCurrentDateAndSeason(int date, String season){ - currentDate = date; - currentSeason = Season.get(season); - } - public static void setCurrentEvent(String event, String time){ - currentEvent = event; - eventTime = time; - } + public static void setCurrentDateAndSeason(int date, String season) { + currentDate = date; + currentSeason = Season.get(season); + } + public static void setCurrentEvent(String event, String time) { + currentEvent = event; + eventTime = time; + } - public static Season getCurrentSeason(){ return currentSeason; } - public static int getCurrentDate(){ return currentDate; } - private static String getDataSuffix(int date) { - if (date > 10 && date < 14) return "th"; - switch (date % 10){ - case 1: return "st"; - case 2: return "nd"; - case 3: return "rd"; - default: return "th"; - } - } + public static Season getCurrentSeason() { + return currentSeason; + } - public static String getFancySeasonAndDate(){ return currentSeason.getDisplayName() + " " + currentDate + getDataSuffix(currentDate); } - public static String getCurrentEvent() { return currentEvent; } - public static String getCurrentEventTime() { return eventTime; } + public static int getCurrentDate() { + return currentDate; + } - public static String removeDate(String seasonDate){ - return Pattern.compile("[^a-zA-Z]").matcher(seasonDate.toLowerCase()).replaceAll("").replaceAll("st|nd|rd|th", "").trim(); + private static String getDataSuffix(int date) { + if (date > 10 && date < 14) return "th"; + switch (date % 10) { + case 1: + return "st"; + case 2: + return "nd"; + case 3: + return "rd"; + default: + return "th"; } + } - public static int removeSeason(String seasonDate){ - return Integer.parseInt(Pattern.compile("[^0-9]").matcher(seasonDate.toLowerCase()).replaceAll("").trim()); - } + public static String getFancySeasonAndDate() { + return ( + currentSeason.getDisplayName() + + " " + + currentDate + + getDataSuffix(currentDate) + ); + } + + public static String getCurrentEvent() { + return currentEvent; + } + + public static String getCurrentEventTime() { + return eventTime; + } + + public static String removeDate(String seasonDate) { + return Pattern + .compile("[^a-zA-Z]") + .matcher(seasonDate.toLowerCase()) + .replaceAll("") + .replaceAll("st|nd|rd|th", "") + .trim(); + } + + public static int removeSeason(String seasonDate) { + return Integer.parseInt( + Pattern + .compile("[^0-9]") + .matcher(seasonDate.toLowerCase()) + .replaceAll("") + .trim() + ); + } } |