Skip to content

Commit 1742fc7

Browse files
authored
Merge pull request #7 from dec4234/dec4234-patch-1
Introduction of new features and various improvements
2 parents 0db53f1 + 628a0f8 commit 1742fc7

File tree

12 files changed

+103
-2
lines changed

12 files changed

+103
-2
lines changed

JavaDestinyAPI/src/main/java/material/DestinyAPI.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public List<BungieUser> getUsersWithName(String name) {
5858
InputStreamReader reader = new InputStreamReader(connection.getInputStream());
5959
JsonElement parse = new JsonParser().parse(reader);
6060
JsonObject obj = parse.getAsJsonObject();
61-
System.out.println(hu.urlRequestGETstring("https://www.bungie.net/platform/Destiny2/SearchDestinyPlayer/-1/" + name.replace(" ", "%20")));
6261
if (obj.get("Response").isJsonArray()) {
6362
for (JsonElement objj : obj.getAsJsonArray("Response")) {
6463
JsonObject us = objj.getAsJsonObject();

JavaDestinyAPI/src/main/java/material/clan/Clan.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ public List<BungieUser> getAdmins() {
106106
return temp;
107107
}
108108

109+
public double getAverageInactivityAmongMembers() {
110+
ArrayList<Double> averages = new ArrayList<Double>();
111+
int a = 0;
112+
for(BungieUser bu : this.getMembers()) {
113+
averages.add(bu.getDaysSinceLastPlayed());
114+
}
115+
for(Double d : averages) {
116+
a += d;
117+
}
118+
return a / getMembers().size();
119+
}
120+
109121
public List<BungieUser> getMembers() {
110122
if (!members.isEmpty()) { return members; }
111123

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,97 @@
11
package material.inventory;
22

33
import com.google.gson.JsonObject;
4+
import material.manifest.ManifestEntityTypes;
5+
import utils.HttpUtils;
46

57
public class DestinyItem {
68

9+
HttpUtils hu = new HttpUtils();
10+
711
private String hashID;
12+
private String name;
13+
private String icon;
14+
private String description;
15+
private boolean hasIcon;
16+
private String collectibleHash;
17+
private String screenshot;
18+
private ItemTier itemType;
19+
20+
private ItemTier tier;
821

922
private JsonObject jo;
1023

1124
public DestinyItem(String hashID) {
1225
this.hashID = hashID;
26+
jo = hu.manifestGET(ManifestEntityTypes.INVENTORYITEM, hashID).getAsJsonObject("Response");
27+
assignValues();
28+
}
29+
30+
private void assignValues() {
31+
JsonObject dp = jo.getAsJsonObject("displayProperties");
32+
name = dp.get("name").getAsString();
33+
description = dp.get("description").getAsString();
34+
icon = dp.get("icon").getAsString();
35+
hasIcon = dp.get("hasIcon").getAsBoolean();
36+
collectibleHash = jo.get("collectibleHash").getAsString();
37+
screenshot = jo.get("screenshot").getAsString();
38+
itemType = asessItemTier();
39+
}
40+
41+
public String getHashID() {
42+
return hashID;
43+
}
44+
45+
/**
46+
* Gets the name of the item
47+
*/
48+
public String getName() {
49+
return name;
50+
}
51+
52+
/**
53+
* Plug this after https://www.bungie.net/ in a browser
54+
*/
55+
public String getIcon() {
56+
return icon;
57+
}
58+
59+
/**
60+
* Gets the lore descriptions associated with this item
61+
*/
62+
public String getDescription() {
63+
return description;
64+
}
65+
66+
public boolean hasIcon() {
67+
return hasIcon;
68+
}
69+
70+
public String getCollectibleHash() {
71+
return collectibleHash;
72+
}
73+
74+
public ItemTier asessItemTier() {
75+
switch(jo.getAsJsonObject("inventory").get("tierTypeName").getAsString()) {
76+
case "Common":
77+
return ItemTier.COMMON;
78+
case "Uncommon":
79+
return ItemTier.UNCOMMON;
80+
case "Rare":
81+
return ItemTier.RARE;
82+
case "Legendary":
83+
return ItemTier.LEGENDARY;
84+
case "Exotic":
85+
return ItemTier.EXOTIC;
86+
}
87+
return null;
88+
}
89+
90+
enum ItemTier {
91+
COMMON,
92+
UNCOMMON,
93+
RARE,
94+
LEGENDARY,
95+
EXOTIC;
1396
}
1497
}

JavaDestinyAPI/src/main/java/material/user/BungieUser.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ private void assignValues() {
9494
/**
9595
* Gets an integer representing the number of days since the user last played
9696
*/
97-
public int getDaysSinceLastPlayed() { return (int) ChronoUnit.DAYS.between(getLastPlayed().toInstant(), new Date().toInstant()); }
97+
public double getDaysSinceLastPlayed() {
98+
return (double) ChronoUnit.DAYS.between(getLastPlayed().toInstant(), new Date().toInstant());
99+
}
98100

99101
public boolean isOverriden() { return isOverriden; }
100102
public boolean isCrossSavePrimary() { return isCrossSavePrimary; }

JavaDestinyAPI/src/main/java/utils/HttpUtils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ public JsonObject manifestGET(ManifestEntityTypes entityType, String hashIdentif
130130
return urlRequestGET("https://www.bungie.net/Platform/Destiny2/Manifest/" + entityType.getBungieEntityValue() + "/" + hashIdentifier + "/");
131131
}
132132

133+
public String generateLineGraph() {
134+
String body = "{\"chart\": {\"type\": \"line\", \"data\": {\"labels\": [\"Hello\", \"World\"], \"datasets\": [{\"label\": \"Foo\", \"data\": [1, 2]}]}}}";
135+
return urlRequestPOST("https://quickchart.io/chart/create", body);
136+
}
137+
133138
/**
134139
* Gets an access token using the refresh token in storage and replaces the old refresh token with the new one
135140
* @return Returns the new access token
-324 Bytes
Binary file not shown.
-166 Bytes
Binary file not shown.
604 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)