aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.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/miscfeatures/FairySouls.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/miscfeatures/FairySouls.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java114
1 files changed, 57 insertions, 57 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java
index ac1d2fd9..95dde052 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java
@@ -8,11 +8,11 @@ import io.github.moulberry.notenoughupdates.commands.SimpleCommand;
import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.SBInfo;
-import io.github.moulberry.notenoughupdates.util.SpecialColour;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.command.ICommandSender;
-import net.minecraft.util.*;
+import net.minecraft.util.BlockPos;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.event.world.WorldEvent;
@@ -36,21 +36,21 @@ public class FairySouls {
}
public static void load(File file, Gson gson) {
- if(file.exists()) {
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
+ if (file.exists()) {
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
HashMap<String, List<Number>> foundSoulsList = gson.fromJson(reader, HashMap.class);
foundSouls = new HashMap<>();
- for(Map.Entry<String, List<Number>> entry : foundSoulsList.entrySet()) {
+ for (Map.Entry<String, List<Number>> entry : foundSoulsList.entrySet()) {
HashSet<Integer> set = new HashSet<>();
- for(Number n : entry.getValue()) {
+ for (Number n : entry.getValue()) {
set.add(n.intValue());
}
foundSouls.put(entry.getKey(), set);
}
return;
- } catch(Exception e) {}
+ } catch (Exception ignored) {}
}
foundSouls = new HashMap<>();
}
@@ -59,34 +59,34 @@ public class FairySouls {
try {
file.createNewFile();
- try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
+ try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
writer.write(gson.toJson(foundSouls));
}
- } catch(IOException ignored) {}
+ } catch (IOException ignored) {}
}
@SubscribeEvent
public void onChatReceived(ClientChatReceivedEvent event) {
- if(currentSoulList == null) return;
+ if (currentSoulList == null) return;
- if(event.message.getFormattedText().equals("\u00A7r\u00A7dYou have already found that Fairy Soul!\u00A7r") ||
+ if (event.message.getFormattedText().equals("\u00A7r\u00A7dYou have already found that Fairy Soul!\u00A7r") ||
event.message.getFormattedText().equals("\u00A7d\u00A7lSOUL! \u00A7fYou found a \u00A7r\u00A7dFairy Soul\u00A7r\u00A7f!\u00A7r")) {
String location = SBInfo.getInstance().getLocation();
- if(location == null) return;
+ if (location == null) return;
int closestIndex = -1;
- double closestDistSq = 10*10;
- for(int i=0; i<currentSoulList.size(); i++) {
+ double closestDistSq = 10 * 10;
+ for (int i = 0; i < currentSoulList.size(); i++) {
BlockPos pos = currentSoulList.get(i);
double distSq = pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition());
- if(distSq < closestDistSq) {
+ if (distSq < closestDistSq) {
closestDistSq = distSq;
closestIndex = i;
}
}
- if(closestIndex != -1) {
+ if (closestIndex != -1) {
Set<Integer> found = foundSouls.computeIfAbsent(location, k -> new HashSet<>());
found.add(closestIndex);
}
@@ -94,32 +94,32 @@ public class FairySouls {
}
public static void tick() {
- if(!enabled) return;
+ if (!enabled) return;
- if(Minecraft.getMinecraft().theWorld == null) {
+ if (Minecraft.getMinecraft().theWorld == null) {
currentSoulList = null;
return;
}
JsonObject fairySouls = Constants.FAIRYSOULS;
- if(fairySouls == null) return;
+ if (fairySouls == null) return;
String location = SBInfo.getInstance().getLocation();
- if(location == null) {
+ if (location == null) {
currentSoulList = null;
return;
}
- if(currentSoulList == null) {
- if(fairySouls.has(location) && fairySouls.get(location).isJsonArray()) {
+ if (currentSoulList == null) {
+ if (fairySouls.has(location) && fairySouls.get(location).isJsonArray()) {
JsonArray locations = fairySouls.get(location).getAsJsonArray();
currentSoulList = new ArrayList<>();
- for(int i=0; i<locations.size(); i++) {
+ for (int i = 0; i < locations.size(); i++) {
try {
String coord = locations.get(i).getAsString();
String[] split = coord.split(",");
- if(split.length == 3) {
+ if (split.length == 3) {
String xS = split[0];
String yS = split[1];
String zS = split[2];
@@ -128,20 +128,21 @@ public class FairySouls {
int y = Integer.parseInt(yS);
int z = Integer.parseInt(zS);
- currentSoulList.add(new BlockPos(x, y , z));
+ currentSoulList.add(new BlockPos(x, y, z));
}
- } catch(Exception ignored) {}
+ } catch (Exception ignored) {
+ }
}
}
}
- if(currentSoulList != null && !currentSoulList.isEmpty()) {
+ if (currentSoulList != null && !currentSoulList.isEmpty()) {
TreeMap<Double, BlockPos> distanceSqMap = new TreeMap<>();
Set<Integer> found = foundSouls.computeIfAbsent(location, k -> new HashSet<>());
- for(int i=0; i<currentSoulList.size(); i++) {
- if(found.contains(i)) continue;
+ for (int i = 0; i < currentSoulList.size(); i++) {
+ if (found.contains(i)) continue;
BlockPos pos = currentSoulList.get(i);
double distSq = pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition());
@@ -151,26 +152,25 @@ public class FairySouls {
int maxSouls = 15;
int souls = 0;
currentSoulListClose = new ArrayList<>();
- for(BlockPos pos : distanceSqMap.values()) {
+ for (BlockPos pos : distanceSqMap.values()) {
currentSoulListClose.add(pos);
- if(++souls >= maxSouls) break;
+ if (++souls >= maxSouls) break;
}
}
}
@SubscribeEvent
public void onRenderLast(RenderWorldLastEvent event) {
- if(!enabled) return;
+ if (!enabled) return;
String location = SBInfo.getInstance().getLocation();
- if(location == null) return;
- if(currentSoulList == null || currentSoulList.isEmpty()) return;
+ if (location == null) return;
+ if (currentSoulList == null || currentSoulList.isEmpty()) return;
Set<Integer> found = foundSouls.computeIfAbsent(location, k -> new HashSet<>());
int rgb = 0xa839ce;
- for(int i=0; i<currentSoulListClose.size(); i++) {
- BlockPos currentSoul = currentSoulListClose.get(i);
+ for (BlockPos currentSoul : currentSoulListClose) {
RenderUtils.renderBeaconBeamOrBoundingBox(currentSoul, rgb, 1.0f, event.partialTicks);
}
}
@@ -188,10 +188,10 @@ public class FairySouls {
}
}
- private static SimpleCommand.ProcessCommandRunnable fairysoulRunnable = new SimpleCommand.ProcessCommandRunnable() {
+ private static final SimpleCommand.ProcessCommandRunnable fairysoulRunnable = new SimpleCommand.ProcessCommandRunnable() {
@Override
public void processCommand(ICommandSender sender, String[] args) {
- if(args.length != 1) {
+ if (args.length != 1) {
printHelp();
return;
}
@@ -203,39 +203,39 @@ public class FairySouls {
return;
case "on":
case "enable":
- print(EnumChatFormatting.DARK_PURPLE+"Enabled fairy soul waypoints");
+ print(EnumChatFormatting.DARK_PURPLE + "Enabled fairy soul waypoints");
enabled = true;
return;
case "off":
case "disable":
- print(EnumChatFormatting.DARK_PURPLE+"Disabled fairy soul waypoints");
+ print(EnumChatFormatting.DARK_PURPLE + "Disabled fairy soul waypoints");
enabled = false;
return;
case "clear": {
String location = SBInfo.getInstance().getLocation();
- if(currentSoulList == null || location == null) {
- print(EnumChatFormatting.RED+"No fairy souls found in your current world");
+ if (currentSoulList == null || location == null) {
+ print(EnumChatFormatting.RED + "No fairy souls found in your current world");
} else {
Set<Integer> found = foundSouls.computeIfAbsent(location, k -> new HashSet<>());
- for(int i=0; i<currentSoulList.size(); i++) {
+ for (int i = 0; i < currentSoulList.size(); i++) {
found.add(i);
}
- print(EnumChatFormatting.DARK_PURPLE+"Marked all fairy souls as found");
+ print(EnumChatFormatting.DARK_PURPLE + "Marked all fairy souls as found");
}
}
return;
case "unclear":
String location = SBInfo.getInstance().getLocation();
- if(location == null) {
- print(EnumChatFormatting.RED+"No fairy souls found in your current world");
+ if (location == null) {
+ print(EnumChatFormatting.RED + "No fairy souls found in your current world");
} else {
- print(EnumChatFormatting.DARK_PURPLE+"Marked all fairy souls as not found");
+ print(EnumChatFormatting.DARK_PURPLE + "Marked all fairy souls as not found");
foundSouls.remove(location);
}
return;
}
- print(EnumChatFormatting.RED+"Unknown subcommand: " + subcommand);
+ print(EnumChatFormatting.RED + "Unknown subcommand: " + subcommand);
}
};
@@ -245,16 +245,16 @@ public class FairySouls {
private static void printHelp() {
print("");
- print(EnumChatFormatting.DARK_PURPLE.toString()+EnumChatFormatting.BOLD+" NEU Fairy Soul Waypoint Guide");
- print(EnumChatFormatting.LIGHT_PURPLE+"Shows waypoints for every fairy soul in your world");
- print(EnumChatFormatting.LIGHT_PURPLE+"Clicking a fairy soul automatically removes it from the list");
- if(!NotEnoughUpdates.INSTANCE.config.hidden.dev) {
+ print(EnumChatFormatting.DARK_PURPLE.toString() + EnumChatFormatting.BOLD + " NEU Fairy Soul Waypoint Guide");
+ print(EnumChatFormatting.LIGHT_PURPLE + "Shows waypoints for every fairy soul in your world");
+ print(EnumChatFormatting.LIGHT_PURPLE + "Clicking a fairy soul automatically removes it from the list");
+ if (!NotEnoughUpdates.INSTANCE.config.hidden.dev) {
print(EnumChatFormatting.DARK_RED + "" + EnumChatFormatting.OBFUSCATED + "Ab" + EnumChatFormatting.RESET + EnumChatFormatting.DARK_RED + "!" + EnumChatFormatting.RESET + EnumChatFormatting.RED + " This feature cannot and will not work in Dungeons. " + EnumChatFormatting.DARK_RED + "!" + EnumChatFormatting.OBFUSCATED + "Ab");
}
- print(EnumChatFormatting.GOLD.toString()+EnumChatFormatting.BOLD+" Commands:");
- print(EnumChatFormatting.YELLOW+"/neusouls help - Display this message");
- print(EnumChatFormatting.YELLOW+"/neusouls on/off - Enable/disable the waypoint markers");
- print(EnumChatFormatting.YELLOW+"/neusouls clear/unclear - Marks every waypoint in your current world as completed/uncompleted");
+ print(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + " Commands:");
+ print(EnumChatFormatting.YELLOW + "/neusouls help - Display this message");
+ print(EnumChatFormatting.YELLOW + "/neusouls on/off - Enable/disable the waypoint markers");
+ print(EnumChatFormatting.YELLOW + "/neusouls clear/unclear - Marks every waypoint in your current world as completed/uncompleted");
print("");
}