aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java
diff options
context:
space:
mode:
authorThatGravyBoat <thatgravyboat@gmail.com>2021-07-06 19:09:11 -0230
committerGitHub <noreply@github.com>2021-07-06 19:09:11 -0230
commit93248d28d6b314b42f6b0d82164975343b214ece (patch)
treee3e06c24454080f059355133d633e5a076d85ad3 /src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java
parent91464c8f433e8bf323932ac956678971207b607e (diff)
parent804767ebfc26e2a1252bc327def02389b35dfc6e (diff)
downloadSkyblockHud-Death-Defied-93248d28d6b314b42f6b0d82164975343b214ece.tar.gz
SkyblockHud-Death-Defied-93248d28d6b314b42f6b0d82164975343b214ece.tar.bz2
SkyblockHud-Death-Defied-93248d28d6b314b42f6b0d82164975343b214ece.zip
Merge pull request #2 from ThatGravyBoat/prettier
Add prettier settings and format code
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java44
1 files changed, 26 insertions, 18 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java
index d6ab81e..2e2fae1 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java
@@ -5,9 +5,8 @@ import com.thatgravyboat.skyblockhud.api.events.ProfileSwitchedEvent;
import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent;
import com.thatgravyboat.skyblockhud.api.events.SidebarPostEvent;
import com.thatgravyboat.skyblockhud.handlers.CurrencyHandler;
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-
import java.util.Arrays;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class IslandHandler {
@@ -15,33 +14,43 @@ public class IslandHandler {
public static boolean hadFlightTime;
public static int redstone;
- public static boolean hadRedstone;
+ public static boolean hadRedstone;
@SubscribeEvent
- public void onSidebarLineUpdate(SidebarLineUpdateEvent event){
+ public void onSidebarLineUpdate(SidebarLineUpdateEvent event) {
hadFlightTime = checkFlightDuration(event.formattedLine);
hadRedstone = checkRestone(event.formattedLine);
}
@SubscribeEvent
- public void onProfileSwitch(ProfileSwitchedEvent event){
+ 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:")){
+ public static boolean checkFlightDuration(String formatedScoreboardLine) {
+ if (LocationHandler.getCurrentLocation() == Locations.YOURISLAND && Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()).contains("flight duration:")) {
String timeString = formatedScoreboardLine.toLowerCase().replace("flight duration:", "").replace(" ", "");
String[] times = timeString.split(":");
- if (times.length == 2){
+ if (times.length == 2) {
int s = 0;
- try { s += Integer.parseInt(times[0]) * 60; } catch (NumberFormatException ignored){}
- try { s += Integer.parseInt(times[1]); } catch (NumberFormatException ignored){}
+ try {
+ s += Integer.parseInt(times[0]) * 60;
+ } catch (NumberFormatException ignored) {}
+ try {
+ s += Integer.parseInt(times[1]);
+ } catch (NumberFormatException ignored) {}
flightTime = s - 1;
- } else if (times.length == 3){
+ } else if (times.length == 3) {
int s = 0;
- try { s += Integer.parseInt(times[0]) * 3600; } catch (NumberFormatException ignored){}
- try { s += Integer.parseInt(times[1]) * 60; } catch (NumberFormatException ignored){}
- try { s += Integer.parseInt(times[2]); } catch (NumberFormatException ignored){}
+ try {
+ s += Integer.parseInt(times[0]) * 3600;
+ } catch (NumberFormatException ignored) {}
+ try {
+ s += Integer.parseInt(times[1]) * 60;
+ } catch (NumberFormatException ignored) {}
+ try {
+ s += Integer.parseInt(times[2]);
+ } catch (NumberFormatException ignored) {}
flightTime = s - 1;
}
return true;
@@ -49,13 +58,12 @@ public class IslandHandler {
return false;
}
- public static boolean checkRestone(String formatedScoreboardLine){
+ public static boolean checkRestone(String formatedScoreboardLine) {
if (LocationHandler.getCurrentLocation() == Locations.YOURISLAND) {
- if (formatedScoreboardLine.toLowerCase().contains("redstone:"))
- return true;
+ if (formatedScoreboardLine.toLowerCase().contains("redstone:")) return true;
try {
redstone = formatedScoreboardLine.toLowerCase().contains("redstone:") ? Integer.parseInt(Utils.removeWhiteSpaceAndRemoveWord(formatedScoreboardLine, "redstone:")) : 0;
- }catch (Exception ignored){}
+ } catch (Exception ignored) {}
}
return false;
}