aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-10-16 15:50:41 -0400
committerGitHub <noreply@github.com>2021-10-16 15:50:41 -0400
commit7c00af18febf6c0b833c7633b4fb60a9a1bb93af (patch)
treef02de145362d6a1399651ade4a130d565d7f0ba3 /src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
parentb11742988dec635b5c5da7c2363803cbfafb37b1 (diff)
downloadnotenoughupdates-7c00af18febf6c0b833c7633b4fb60a9a1bb93af.tar.gz
notenoughupdates-7c00af18febf6c0b833c7633b4fb60a9a1bb93af.tar.bz2
notenoughupdates-7c00af18febf6c0b833c7633b4fb60a9a1bb93af.zip
Code Clean Up (#2)
* intellij code clean up * optimize imports * format * intellij suggestions * fix empty catch issues
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java55
1 files changed, 28 insertions, 27 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
index 9699f4ad..15906884 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
@@ -28,6 +28,7 @@ import java.util.regex.Pattern;
public class SBInfo {
private static final SBInfo INSTANCE = new SBInfo();
+
public static SBInfo getInstance() {
return INSTANCE;
}
@@ -59,9 +60,9 @@ public class SBInfo {
@SubscribeEvent
public void onGuiOpen(GuiOpenEvent event) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
- if(event.gui instanceof GuiChest) {
+ if (event.gui instanceof GuiChest) {
GuiChest chest = (GuiChest) event.gui;
ContainerChest container = (ContainerChest) chest.inventorySlots;
String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText();
@@ -87,7 +88,7 @@ public class SBInfo {
private static final Pattern JSON_BRACKET_PATTERN = Pattern.compile("\\{.+}");
public void onSendChatMessage(String msg) {
- if(msg.trim().startsWith("/locraw") || msg.trim().startsWith("/locraw ")) {
+ if (msg.trim().startsWith("/locraw") || msg.trim().startsWith("/locraw ")) {
lastManualLocRaw = System.currentTimeMillis();
}
}
@@ -95,24 +96,24 @@ public class SBInfo {
@SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
public void onChatMessage(ClientChatReceivedEvent event) {
Matcher matcher = JSON_BRACKET_PATTERN.matcher(event.message.getUnformattedText());
- if(matcher.find()) {
+ if (matcher.find()) {
try {
JsonObject obj = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(matcher.group(), JsonObject.class);
- if(obj.has("server")) {
- if(System.currentTimeMillis() - lastManualLocRaw > 5000) event.setCanceled(true);
- if(obj.has("gametype") && obj.has("mode") && obj.has("map")) {
+ if (obj.has("server")) {
+ if (System.currentTimeMillis() - lastManualLocRaw > 5000) event.setCanceled(true);
+ if (obj.has("gametype") && obj.has("mode") && obj.has("map")) {
locraw = obj;
mode = locraw.get("mode").getAsString();
}
}
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
}
public String getLocation() {
- if(mode == null) {
+ if (mode == null) {
return null;
}
return mode;
@@ -128,7 +129,7 @@ public class SBInfo {
long currentTime = System.currentTimeMillis();
- if(Minecraft.getMinecraft().thePlayer != null &&
+ if (Minecraft.getMinecraft().thePlayer != null &&
Minecraft.getMinecraft().theWorld != null &&
locraw == null &&
(currentTime - joinedWorld) > 1000 &&
@@ -138,22 +139,22 @@ public class SBInfo {
}
try {
- for(NetworkPlayerInfo info : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) {
+ for (NetworkPlayerInfo info : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) {
String name = Minecraft.getMinecraft().ingameGUI.getTabList().getPlayerName(info);
- if(name.startsWith(profilePrefix)) {
+ if (name.startsWith(profilePrefix)) {
currentProfile = Utils.cleanColour(name.substring(profilePrefix.length()));
- } else if(name.startsWith(skillsPrefix)) {
+ } else if (name.startsWith(skillsPrefix)) {
String levelInfo = name.substring(skillsPrefix.length()).trim();
Matcher matcher = SKILL_LEVEL_PATTERN.matcher(Utils.cleanColour(levelInfo).split(":")[0]);
- if(matcher.find()) {
+ if (matcher.find()) {
try {
int level = Integer.parseInt(matcher.group(2).trim());
XPInformation.getInstance().updateLevel(matcher.group(1).toLowerCase().trim(), level);
- } catch(Exception ignored) {}
+ } catch (Exception ignored) {}
}
}
}
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
@@ -165,36 +166,36 @@ public class SBInfo {
List<Score> scores = new ArrayList<>(scoreboard.getSortedScores(sidebarObjective));
List<String> lines = new ArrayList<>();
- for(int i=scores.size()-1; i>=0; i--) {
+ for (int i = scores.size() - 1; i >= 0; i--) {
Score score = scores.get(i);
ScorePlayerTeam scoreplayerteam1 = scoreboard.getPlayersTeam(score.getPlayerName());
String line = ScorePlayerTeam.formatPlayerName(scoreplayerteam1, score.getPlayerName());
line = Utils.cleanDuplicateColourCodes(line);
-
+
String cleanLine = Utils.cleanColour(line);
- if(cleanLine.contains("Dungeon") && cleanLine.contains("Cleared:") && cleanLine.contains("%")) {
+ if (cleanLine.contains("Dungeon") && cleanLine.contains("Cleared:") && cleanLine.contains("%")) {
tempIsInDungeon = true;
}
lines.add(line);
}
- isInDungeon= tempIsInDungeon;
+ isInDungeon = tempIsInDungeon;
- if(lines.size() >= 5) {
+ if (lines.size() >= 5) {
date = Utils.cleanColour(lines.get(1)).trim();
//§74:40am
Matcher matcher = timePattern.matcher(lines.get(2));
- if(matcher.find()) {
+ if (matcher.find()) {
time = Utils.cleanColour(matcher.group()).trim();
try {
String timeSpace = time.replace("am", " am").replace("pm", " pm");
SimpleDateFormat parseFormat = new SimpleDateFormat("hh:mm a");
currentTimeDate = parseFormat.parse(timeSpace);
- } catch (ParseException e) {}
+ } catch (ParseException ignored) {}
}
//Replaced with for loop because in crystal hollows with events the line it's on can shift.
- for (String line : lines){
+ for (String line : lines) {
if (line.contains("⏣")) {
location = Utils.cleanColour(line).replaceAll("[^A-Za-z0-9() ]", "").trim();
break;
@@ -204,14 +205,14 @@ public class SBInfo {
objective = null;
boolean objTextLast = false;
- for(String line : lines) {
- if(objTextLast) {
+ for (String line : lines) {
+ if (objTextLast) {
objective = line;
}
objTextLast = line.equals("Objective");
}
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}