aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/tracker
diff options
context:
space:
mode:
authorTymanWasTaken <tyman@tyman.tech>2021-07-06 17:20:49 -0400
committerTymanWasTaken <tyman@tyman.tech>2021-07-06 17:20:49 -0400
commitc04ca523f9fb9f7adefa74587db61f76deeae9f0 (patch)
treef148e7bcd9105813d3fe781badcb2cf3892712fd /src/main/java/com/thatgravyboat/skyblockhud/tracker
parenta8e475fa0a7977f64f072548459d592274169d66 (diff)
downloadSkyblockHud-Death-Defied-c04ca523f9fb9f7adefa74587db61f76deeae9f0.tar.gz
SkyblockHud-Death-Defied-c04ca523f9fb9f7adefa74587db61f76deeae9f0.tar.bz2
SkyblockHud-Death-Defied-c04ca523f9fb9f7adefa74587db61f76deeae9f0.zip
Increase line width
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/tracker')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/tracker/KillTrackerHandler.java10
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java116
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java75
3 files changed, 46 insertions, 155 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/KillTrackerHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/KillTrackerHandler.java
index 552837b..8f0608d 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/KillTrackerHandler.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/KillTrackerHandler.java
@@ -34,9 +34,7 @@ public class KillTrackerHandler {
NBTTagCompound tag = new NBTTagCompound();
event.entity.writeToNBT(tag);
System.out.println("Tag : " + tag);
- System.out.println(
- "Damage : " + getDamageSourceString(event.source)
- );
+ System.out.println("Damage : " + getDamageSourceString(event.source));
System.out.println(
"----------------------------------------------------------------------------------------------------------------"
);
@@ -74,11 +72,7 @@ public class KillTrackerHandler {
@SubscribeEvent
public void onWorldChange(EntityJoinWorldEvent event) {
if (event.entity != null) {
- if (
- event.entity
- .getUniqueID()
- .equals(Minecraft.getMinecraft().thePlayer.getUniqueID())
- ) {
+ if (event.entity.getUniqueID().equals(Minecraft.getMinecraft().thePlayer.getUniqueID())) {
attackedEntities.clear();
}
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java
index 7035fee..ba22101 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java
@@ -23,24 +23,15 @@ public class TrackerFileLoader {
public static ItemStack getDisplayItem(JsonObject jsonObject) {
int meta = jsonObject.get("meta").getAsInt();
String displayItemId = jsonObject.get("item").getAsString();
- Item item = Item.itemRegistry.getObject(
- new ResourceLocation(displayItemId)
- );
+ Item item = Item.itemRegistry.getObject(new ResourceLocation(displayItemId));
ItemStack stack = new ItemStack(item, 0, meta);
- if (
- jsonObject.has("skullData") &&
- displayItemId.equals("minecraft:skull") &&
- meta == 3
- ) {
- stack.setTagInfo(
- "SkullOwner",
- getSkullTag(jsonObject.getAsJsonObject("skullData"))
- );
+ if (jsonObject.has("skullData") && displayItemId.equals("minecraft:skull") && meta == 3) {
+ stack.setTagInfo("SkullOwner", getSkullTag(jsonObject.getAsJsonObject("skullData")));
}
- if (
- jsonObject.has("enchanted") &&
- jsonObject.get("enchanted").getAsBoolean()
- ) stack.setTagInfo("ench", new NBTTagList());
+ if (jsonObject.has("enchanted") && jsonObject.get("enchanted").getAsBoolean()) stack.setTagInfo(
+ "ench",
+ new NBTTagList()
+ );
return stack;
}
@@ -65,10 +56,7 @@ public class TrackerFileLoader {
for (JsonElement element : object.get("trackers").getAsJsonArray()) {
JsonObject tracker = element.getAsJsonObject();
StringBuilder builder = new StringBuilder();
- tracker
- .get("location")
- .getAsJsonArray()
- .forEach(loc -> builder.append(loc.getAsString()));
+ tracker.get("location").getAsJsonArray().forEach(loc -> builder.append(loc.getAsString()));
String location = builder.toString();
Map<String, ItemStack> stacks = new HashMap<>();
@@ -76,42 +64,27 @@ public class TrackerFileLoader {
JsonObject dropObject = drop.getAsJsonObject();
//Display Item Creation
- ItemStack stack = getDisplayItem(
- dropObject.getAsJsonObject("displayItem")
- );
+ ItemStack stack = getDisplayItem(dropObject.getAsJsonObject("displayItem"));
String itemId = dropObject.get("id").getAsString();
stacks.put(itemId, stack);
}
- String event = tracker.has("event")
- ? tracker.get("event").getAsString()
- : null;
+ String event = tracker.has("event") ? tracker.get("event").getAsString() : null;
Map<String, Map<String, ItemStack>> events = new HashMap<>();
events.put(event, stacks);
if (TrackerHandler.trackers.containsKey(location)) {
- TrackerHandler.trackers
- .get(location)
- .dropTrackers.put(event, stacks);
+ TrackerHandler.trackers.get(location).dropTrackers.put(event, stacks);
} else {
- TrackerHandler.trackers.putIfAbsent(
- location,
- new TrackerHandler.TrackerData(events)
- );
+ TrackerHandler.trackers.putIfAbsent(location, new TrackerHandler.TrackerData(events));
}
tracker
.get("location")
.getAsJsonArray()
- .forEach(
- loc ->
- TrackerHandler.trackerIds.put(
- Locations.get(loc.getAsString()),
- location
- )
- );
+ .forEach(loc -> TrackerHandler.trackerIds.put(Locations.get(loc.getAsString()), location));
}
}
@@ -124,16 +97,13 @@ public class TrackerFileLoader {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("location", locations);
- if (event == null) jsonObject.add(
+ if (event == null) jsonObject.add("event", new JsonNull()); else jsonObject.addProperty(
"event",
- new JsonNull()
- ); else jsonObject.addProperty("event", event);
+ event
+ );
JsonObject dropsData = new JsonObject();
- drops.forEach(
- (s, stack) ->
- dropsData.addProperty(s, stack.stackSize)
- );
+ drops.forEach((s, stack) -> dropsData.addProperty(s, stack.stackSize));
jsonObject.add("drops", dropsData);
trackerStats.add(jsonObject);
}
@@ -146,20 +116,10 @@ public class TrackerFileLoader {
public static void loadTrackersFile() {
try {
- ResourceLocation trackers = new ResourceLocation(
- "skyblockhud:data/trackers.json"
- );
- InputStream is = Minecraft
- .getMinecraft()
- .getResourceManager()
- .getResource(trackers)
- .getInputStream();
+ ResourceLocation trackers = new ResourceLocation("skyblockhud:data/trackers.json");
+ InputStream is = Minecraft.getMinecraft().getResourceManager().getResource(trackers).getInputStream();
- try (
- BufferedReader reader = new BufferedReader(
- new InputStreamReader(is, StandardCharsets.UTF_8)
- )
- ) {
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
loadTrackers(gson.fromJson(reader, JsonObject.class));
}
} catch (Exception ignored) {}
@@ -175,10 +135,7 @@ public class TrackerFileLoader {
try (
BufferedReader reader = new BufferedReader(
- new InputStreamReader(
- new FileInputStream(configFile),
- StandardCharsets.UTF_8
- )
+ new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8)
)
) {
JsonObject json = gson.fromJson(reader, JsonObject.class);
@@ -189,37 +146,25 @@ public class TrackerFileLoader {
element -> {
if (element.isJsonObject()) {
JsonObject object = element.getAsJsonObject();
- String location = object
- .get("location")
- .getAsString();
- Map<String, Map<String, ItemStack>> trackers = TrackerHandler.trackers.get(
- location
- )
+ String location = object.get("location").getAsString();
+ Map<String, Map<String, ItemStack>> trackers = TrackerHandler.trackers.get(location)
.dropTrackers;
JsonElement event = object.get("event");
- String eventString = event == null ||
- event.isJsonNull()
+ String eventString = event == null || event.isJsonNull()
? null
: event.getAsString();
- Map<String, ItemStack> drops = trackers.get(
- eventString
- );
+ Map<String, ItemStack> drops = trackers.get(eventString);
if (drops != null) {
for (Map.Entry<String, JsonElement> drop : object
.getAsJsonObject("drops")
.entrySet()) {
- if (
- drops.containsKey(drop.getKey())
- ) {
- drops.get(drop.getKey())
- .stackSize =
- drop.getValue().getAsInt();
+ if (drops.containsKey(drop.getKey())) {
+ drops.get(drop.getKey()).stackSize = drop.getValue().getAsInt();
}
}
- drops =
- TrackerHandler.sortTrackers(drops);
+ drops = TrackerHandler.sortTrackers(drops);
trackers.put(eventString, drops);
}
}
@@ -239,10 +184,7 @@ public class TrackerFileLoader {
try (
BufferedWriter writer = new BufferedWriter(
- new OutputStreamWriter(
- new FileOutputStream(configFile),
- StandardCharsets.UTF_8
- )
+ new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8)
)
) {
JsonObject json = new JsonObject();
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java
index 8c8a521..2d5607f 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java
@@ -37,30 +37,16 @@ public class TrackerHandler {
}
private boolean eventGoing() {
- return SeasonDateHandler
- .getCurrentEventTime()
- .trim()
- .toLowerCase()
- .contains("ends in");
+ return SeasonDateHandler.getCurrentEventTime().trim().toLowerCase().contains("ends in");
}
}
public static Map<String, TrackerData> trackers = new HashMap<>();
public static Map<Locations, String> trackerIds = new HashMap<>();
- public static Map<String, ItemStack> sortTrackers(
- Map<String, ItemStack> map
- ) {
- List<Map.Entry<String, ItemStack>> list = new ArrayList<>(
- map.entrySet()
- );
- list.sort(
- (entry1, entry2) ->
- Integer.compare(
- entry2.getValue().stackSize,
- entry1.getValue().stackSize
- )
- );
+ public static Map<String, ItemStack> sortTrackers(Map<String, ItemStack> map) {
+ List<Map.Entry<String, ItemStack>> list = new ArrayList<>(map.entrySet());
+ list.sort((entry1, entry2) -> Integer.compare(entry2.getValue().stackSize, entry1.getValue().stackSize));
Map<String, ItemStack> result = new LinkedHashMap<>();
for (Map.Entry<String, ItemStack> entry : list) {
@@ -70,26 +56,12 @@ public class TrackerHandler {
return result;
}
- public static void onItemAdded(
- String id,
- int amount,
- String enchant,
- int level
- ) {
- if (
- SkyblockHud.hasSkyblockScoreboard() &&
- trackerIds.containsKey(LocationHandler.getCurrentLocation())
- ) {
- String trackerId = trackerIds.get(
- LocationHandler.getCurrentLocation()
- );
+ public static void onItemAdded(String id, int amount, String enchant, int level) {
+ if (SkyblockHud.hasSkyblockScoreboard() && trackerIds.containsKey(LocationHandler.getCurrentLocation())) {
+ String trackerId = trackerIds.get(LocationHandler.getCurrentLocation());
TrackerData tracked = trackers.get(trackerId);
- String dropTrackerId = tracked.getDropId(
- SeasonDateHandler.getCurrentEvent()
- );
- Map<String, ItemStack> tracker = tracked.dropTrackers.get(
- dropTrackerId
- );
+ String dropTrackerId = tracked.getDropId(SeasonDateHandler.getCurrentEvent());
+ Map<String, ItemStack> tracker = tracked.dropTrackers.get(dropTrackerId);
String dropId = id;
if (enchant != null) {
dropId = enchant.toUpperCase() + ";" + level;
@@ -123,9 +95,7 @@ public class TrackerHandler {
!SkyblockHud.config.trackers.hideTracker
)
) {
- String trackerId = trackerIds.get(
- LocationHandler.getCurrentLocation()
- );
+ String trackerId = trackerIds.get(LocationHandler.getCurrentLocation());
Minecraft mc = Minecraft.getMinecraft();
TrackerData tracked = trackers.get(trackerId);
@@ -134,29 +104,16 @@ public class TrackerHandler {
);
if (tracker != null) {
Position pos = SkyblockHud.config.trackers.trackerPosition;
- int startPos = pos.getAbsX(
- event.resolution,
- (tracker.size() >= 6 ? 120 : tracker.size() * 20)
- );
- int y = pos.getAbsY(
- event.resolution,
- (int) (10 + Math.ceil(tracker.size() / 5d) * 20)
- );
+ int startPos = pos.getAbsX(event.resolution, (tracker.size() >= 6 ? 120 : tracker.size() * 20));
+ int y = pos.getAbsY(event.resolution, (int) (10 + Math.ceil(tracker.size() / 5d) * 20));
Gui.drawRect(startPos, y, startPos + 120, y + 10, -1072689136);
- mc.fontRendererObj.drawString(
- "Tracker",
- startPos + 4,
- y + 1,
- 0xffffff,
- false
- );
+ mc.fontRendererObj.drawString("Tracker", startPos + 4, y + 1, 0xffffff, false);
y += 10;
Gui.drawRect(
startPos,
y,
- startPos +
- (tracker.size() >= 6 ? 120 : tracker.size() * 20),
+ startPos + (tracker.size() >= 6 ? 120 : tracker.size() * 20),
(int) (y + (Math.ceil(tracker.size() / 5d) * 20)),
1610612736
);
@@ -170,9 +127,7 @@ public class TrackerHandler {
GlStateManager.disableBlend();
mc.fontRendererObj.drawStringWithShadow(
s,
- (float) (
- x + 19 - 2 - mc.fontRendererObj.getStringWidth(s)
- ),
+ (float) (x + 19 - 2 - mc.fontRendererObj.getStringWidth(s)),
(float) (y + 9),
stack.stackSize < 1 ? 16733525 : 16777215
);