Skip to content

Commit b534727

Browse files
authored
Merge pull request #1 from dec4234/dec4234-patch-1
Moving forward for first production release
2 parents 346bf38 + 81ecb60 commit b534727

File tree

7 files changed

+42
-4
lines changed

7 files changed

+42
-4
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class Clan {
3333
private BungieUser founder;
3434
private List<BungieUser> admins;
3535
private List<BungieUser> members = new ArrayList<>();
36+
private ClanManagement clanManagement;
3637

3738
public Clan(long clanId) {
3839
this.clanId = clanId;
@@ -114,4 +115,10 @@ public List<BungieUser> getMembers() {
114115

115116
return members;
116117
}
118+
119+
public ClanManagement getClanManagement() {
120+
if(clanManagement != null) return clanManagement;
121+
clanManagement = new ClanManagement(this);
122+
return clanManagement;
123+
}
117124
}

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,28 @@ public void kickPlayer(BungieUser bungieUser) {
3636
* Bans the user from the clan
3737
*/
3838
public void banUser(BungieUser bungieUser) {
39+
hu.urlRequestPOSTOauth("https://www.bungie.net/Platform/GroupV2/" + clan.getClanID() + "/Members/" + bungieUser.getMembershipType() + "/" + bungieUser.getBungieMembershipID() + "/Ban/", "");
40+
}
41+
42+
/**
43+
* Unbans this user from the clan, as long as they are banned, of course
44+
*/
45+
public void unbanUser(BungieUser bungieUser) {
46+
hu.urlRequestPOSTOauth("https://www.bungie.net/Platform/GroupV2/" + clan.getClanID() + "/Members/" + bungieUser.getMembershipType() + "/" + bungieUser.getBungieMembershipID() + "/Unban/", "");
47+
}
3948

49+
/**
50+
* Invites the specified user to join the clan
51+
*/
52+
public void inviteUser(BungieUser bungieUser) {
53+
hu.urlRequestPOSTOauth("https://www.bungie.net/Platform/GroupV2/" + clan.getClanID() + "/Members/IndividualInvite/" + bungieUser.getMembershipType() + "/" + bungieUser.getBungieMembershipID() + "/", "");
54+
}
55+
56+
/**
57+
* Cancels the invite for this user to join the clan
58+
*/
59+
public void cancelInvite(BungieUser bungieUser) {
60+
hu.urlRequestPOSTOauth("https://www.bungie.net/Platform/GroupV2/" + clan.getClanID() + "/Members/IndividualInviteCancel/" + bungieUser.getMembershipType() + "/" + bungieUser.getBungieMembershipID() + "/", "");
4061
}
4162

4263
/**
@@ -61,7 +82,7 @@ public void denyAllPendingMembers() {
6182
}
6283

6384
/**
64-
* Abdicates foundership to the next admin in the line of succession
85+
* Abdicates foundership to the admin specified (This user must already be an admin of the clan)
6586
* @param bungieUser The user who will be the new founder (leader) of the clan
6687
*/
6788
public void abdicateFoundership(BungieUser bungieUser) {

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class BungieUser {
2929
private boolean isPublic;
3030
private int membershipType;
3131
private List<Character> characters;
32+
private int playTime = -1;
3233

3334
private String iconPath;
3435
private Clan clan;
@@ -106,16 +107,25 @@ private void assignValues() {
106107
/**
107108
* Currently not working
108109
*/
109-
@Deprecated
110110
public List<Character> getCharacters() {
111111
if(clan != null) return characters;
112112
characters = new ArrayList<>();
113-
JsonObject jo = hu.urlRequestGET("https://www.bungie.net/Platform/Destiny2/" + getMembershipType() + "/Profile/" + bungieMembershipID + "/?components=200").getAsJsonObject("Response").getAsJsonObject("characters");
114-
113+
JsonArray ja = hu.urlRequestGET("https://www.bungie.net/Platform/Destiny2/" + getMembershipType() + "/Profile/" + bungieMembershipID + "/?components=100").getAsJsonObject("Response").getAsJsonObject("profile").getAsJsonObject("data").getAsJsonArray("characterIds");
114+
for(JsonElement je : ja) {
115+
characters.add(new Character(this, je.getAsString()));
116+
}
115117

116118
return characters;
117119
}
118120

121+
public int getTimePlayed() {
122+
if(playTime != -1) return playTime;
123+
for(Character c : getCharacters()) {
124+
playTime += Integer.parseInt(c.getMinutesPlayedTotal());
125+
}
126+
return playTime;
127+
}
128+
119129
/**
120130
* Gets the clan that this user is a member of
121131
*/
-15 Bytes
Binary file not shown.
501 Bytes
Binary file not shown.
602 Bytes
Binary file not shown.
-455 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)