Skip to content

Commit

Permalink
Changed method names in enums
Browse files Browse the repository at this point in the history
  • Loading branch information
SocketConnection committed Mar 20, 2023
1 parent 29355fc commit e1f8997
Show file tree
Hide file tree
Showing 15 changed files with 147 additions and 149 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ Latest Release: [GitHub Releases](https://github.com/SocketC0nnection/JVA/releas
<dependency>
<groupId>io.github.socketc0nnection</groupId>
<artifactId>jva</artifactId>
<version>1.1</version>
<version>1.2</version>
</dependency>
```

**Gradle**
```gradle
implementation("io.github.socketc0nnection:jva:1.1")
implementation("io.github.socketc0nnection:jva:1.2")
```

## Documentation
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.socketc0nnection</groupId>
<artifactId>jva</artifactId>
<version>1.1</version>
<version>1.2</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down
26 changes: 13 additions & 13 deletions src/main/java/net/socketconnection/jva/ValorantAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ public List<LeaderboardPlayer> getLeaderboard(Region region, String riotId) thro
JsonArray leaderboardData;

if(riotId == null) {
leaderboardData = sendRestRequest("/v1/leaderboard/" + region.getRegionQuery()).getAsJsonArray();
leaderboardData = sendRestRequest("/v1/leaderboard/" + region.getQuery()).getAsJsonArray();
} else {
if(!riotId.contains("#") || riotId.split("#").length < 2) {
throw new InvalidRiotIdentificationException("Unknown format (right format: NAME#TAG)");
}

String[] data = riotId.split("#");

leaderboardData = sendRestRequest("/v1/leaderboard/" + region.getRegionQuery() + "?name=" + data[0] + "&tag=" + data[1]).getAsJsonArray();
leaderboardData = sendRestRequest("/v1/leaderboard/" + region.getQuery() + "?name=" + data[0] + "&tag=" + data[1]).getAsJsonArray();
}

List<LeaderboardPlayer> leaderboard = new LinkedList<>();
Expand All @@ -75,7 +75,7 @@ public List<LeaderboardPlayer> getLeaderboard(Region region) throws IOException
}

public ServerStatus getServerStatus(Region region) throws IOException {
JsonObject statusData = sendRestRequest("/v1/status/" + region.getRegionQuery()).getAsJsonObject().getAsJsonObject("data");
JsonObject statusData = sendRestRequest("/v1/status/" + region.getQuery()).getAsJsonObject().getAsJsonObject("data");

JsonArray maintenancesData = statusData.getAsJsonArray("maintenances");
JsonArray incidentsData = statusData.getAsJsonArray("incidents");
Expand All @@ -94,7 +94,7 @@ public ServerStatus getServerStatus(Region region) throws IOException {
for(JsonElement translationElement : updateObject.getAsJsonArray("translations")) {
JsonObject translationObject = translationElement.getAsJsonObject();

translations.put(Language.getFromLanguageLocale(translationObject.get("locale").getAsString()), translationObject.get("content").getAsString());
translations.put(Language.getFromLocale(translationObject.get("locale").getAsString()), translationObject.get("content").getAsString());
}

List<String> publishLocations = new LinkedList<>();
Expand Down Expand Up @@ -130,7 +130,7 @@ public ServerStatus getServerStatus(Region region) throws IOException {
for(JsonElement titleElement : maintenanceObject.getAsJsonArray("titles")) {
JsonObject titleObject = titleElement.getAsJsonObject();

titles.put(Language.getFromLanguageLocale(titleObject.get("locale").getAsString()), titleObject.get("content").getAsString());
titles.put(Language.getFromLocale(titleObject.get("locale").getAsString()), titleObject.get("content").getAsString());
}

String createdAt = null;
Expand Down Expand Up @@ -174,7 +174,7 @@ public ServerStatus getServerStatus(Region region) throws IOException {
for(JsonElement translationElement : updateObject.getAsJsonArray("translations")) {
JsonObject translationObject = translationElement.getAsJsonObject();

translations.put(Language.getFromLanguageLocale(translationObject.get("locale").getAsString()), translationObject.get("content").getAsString());
translations.put(Language.getFromLocale(translationObject.get("locale").getAsString()), translationObject.get("content").getAsString());
}

List<String> publishLocations = new LinkedList<>();
Expand Down Expand Up @@ -210,7 +210,7 @@ public ServerStatus getServerStatus(Region region) throws IOException {
for(JsonElement titleElement : incidentObject.getAsJsonArray("titles")) {
JsonObject titleObject = titleElement.getAsJsonObject();

titles.put(Language.getFromLanguageLocale(titleObject.get("locale").getAsString()), titleObject.get("content").getAsString());
titles.put(Language.getFromLocale(titleObject.get("locale").getAsString()), titleObject.get("content").getAsString());
}

String createdAt = null;
Expand Down Expand Up @@ -247,14 +247,14 @@ public ServerStatus getServerStatus(Region region) throws IOException {
}

public Version getVersion(Region region) throws IOException {
JsonObject versionData = sendRestRequest("/v1/version/" + region.getRegionQuery()).getAsJsonObject().getAsJsonObject("data");
JsonObject versionData = sendRestRequest("/v1/version/" + region.getQuery()).getAsJsonObject().getAsJsonObject("data");

return new Version(versionData.get("version").getAsString(), versionData.get("clientVersion").getAsString(),
versionData.get("branch").getAsString(), Region.getFromRegionQuery(versionData.get("region").getAsString()));
versionData.get("branch").getAsString(), Region.getFromQuery(versionData.get("region").getAsString()));
}

public List<WebsiteArticle> getWebsiteArticles(Language language) throws IOException {
JsonArray articleData = sendRestRequest("/v1/website/" + language.getLanguageLocaleUrl()).getAsJsonObject().getAsJsonArray("data");
JsonArray articleData = sendRestRequest("/v1/website/" + language.getLocaleUrl()).getAsJsonObject().getAsJsonArray("data");

List<WebsiteArticle> websiteArticles = new LinkedList<>();

Expand All @@ -267,7 +267,7 @@ public List<WebsiteArticle> getWebsiteArticles(Language language) throws IOExcep
externalLink = articleObject.get("external_link").getAsString();
}

websiteArticles.add(new WebsiteArticle(articleObject.get("banner_url").getAsString(), WebsiteArticle.Category.getFromCategoryQuery(articleObject.get("category").getAsString()),
websiteArticles.add(new WebsiteArticle(articleObject.get("banner_url").getAsString(), WebsiteArticle.Category.getFromQuery(articleObject.get("category").getAsString()),
articleObject.get("date").getAsString(), externalLink, articleObject.get("title").getAsString(), articleObject.get("url").getAsString()));
}

Expand All @@ -289,7 +289,7 @@ public List<Bundle> getStoreBundles() throws IOException {
JsonObject itemObject = itemElement.getAsJsonObject();

items.add(new BundleItem(itemObject.get("uuid").getAsString(), itemObject.get("name").getAsString(),
itemObject.get("image").getAsString(), Item.Type.getFromTypeQuery(itemObject.get("type").getAsString()),
itemObject.get("image").getAsString(), Item.Type.getFromQuery(itemObject.get("type").getAsString()),
itemObject.get("amount").getAsInt(), itemObject.get("discount_percent").getAsInt(), itemObject.get("base_price").getAsInt(),
itemObject.get("discounted_price").getAsInt(), itemObject.get("promo_item").getAsBoolean()));
}
Expand Down Expand Up @@ -325,7 +325,7 @@ public List<OfferItem> getStoreOffers() throws IOException {
}

items.add(new OfferItem(skinId, offerObject.get("name").getAsString(),
offerObject.get("icon").getAsString(), Item.Type.getFromTypeQuery(offerObject.get("type").getAsString()),
offerObject.get("icon").getAsString(), Item.Type.getFromQuery(offerObject.get("type").getAsString()),
offerObject.get("offer_id").getAsString(), offerObject.get("cost").getAsInt(), contentTier));
}

Expand Down
40 changes: 20 additions & 20 deletions src/main/java/net/socketconnection/jva/enums/Agent.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ public enum Agent {
HARBOR("Harbor", Category.CONTROLLER),
GEKKO("Gekko", Category.INITIATOR);

private final String agentName;
private final Category agentCategory;
private final String name;
private final Category category;

Agent(String agentName, Category agentCategory) {
this.agentName = agentName;
this.agentCategory = agentCategory;
Agent(String name, Category category) {
this.name = name;
this.category = category;
}

public static Agent getFromAgentCategory(Category agentCategory) {
public static Agent getFromCategory(Category category) {
for(Agent agent : values()) {
if(!agent.agentCategory.equals(agentCategory)) {
if(!agent.category.equals(category)) {
continue;
}

Expand All @@ -44,9 +44,9 @@ public static Agent getFromAgentCategory(Category agentCategory) {
return null;
}

public static Agent getFromAgentName(String agentName) {
public static Agent getFromName(String name) {
for(Agent agent : values()) {
if(!agent.agentName.equalsIgnoreCase(agentName)) {
if(!agent.name.equalsIgnoreCase(name)) {
continue;
}

Expand All @@ -56,12 +56,12 @@ public static Agent getFromAgentName(String agentName) {
return null;
}

public Category getAgentCategory() {
return agentCategory;
public Category getCategory() {
return category;
}

public String getAgentName() {
return agentName;
public String getName() {
return name;
}

public enum Category {
Expand All @@ -71,15 +71,15 @@ public enum Category {
INITIATOR("Initiator"),
SENTINEL("Sentinel");

private final String categoryName;
private final String name;

Category(String categoryName) {
this.categoryName = categoryName;
Category(String name) {
this.name = name;
}

public static Category getFromCategoryName(String categoryName) {
public static Category getFromName(String name) {
for(Category category : values()) {
if(!category.categoryName.equalsIgnoreCase(categoryName)) {
if(!category.name.equalsIgnoreCase(name)) {
continue;
}

Expand All @@ -89,8 +89,8 @@ public static Category getFromCategoryName(String categoryName) {
return null;
}

public String getCategoryName() {
return categoryName;
public String getName() {
return name;
}
}
}
26 changes: 13 additions & 13 deletions src/main/java/net/socketconnection/jva/enums/GameMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ public enum GameMode {
REPLICATION("replication", "Replication"),
ESCALATION("escalation", "Escalation");

private final String gameModeQuery;
private final String gameModeName;
private final String query;
private final String name;

GameMode(String gameModeQuery, String gameModeName) {
this.gameModeQuery = gameModeQuery;
this.gameModeName = gameModeName;
GameMode(String query, String name) {
this.query = query;
this.name = name;
}

public static GameMode getFromGameModeQuery(String gameModeQuery) {
public static GameMode getFromQuery(String query) {
for(GameMode gameMode : values()) {
if(!gameMode.gameModeQuery.equalsIgnoreCase(gameModeQuery)) {
if(!gameMode.query.equalsIgnoreCase(query)) {
continue;
}

Expand All @@ -30,9 +30,9 @@ public static GameMode getFromGameModeQuery(String gameModeQuery) {
return null;
}

public static GameMode getFromGameModeName(String gameModeName) {
public static GameMode getFromName(String name) {
for(GameMode gameMode : values()) {
if(!gameMode.gameModeName.equalsIgnoreCase(gameModeName)) {
if(!gameMode.name.equalsIgnoreCase(name)) {
continue;
}

Expand All @@ -42,11 +42,11 @@ public static GameMode getFromGameModeName(String gameModeName) {
return null;
}

public String getGameModeName() {
return gameModeName;
public String getName() {
return name;
}

public String getGameModeQuery() {
return gameModeQuery;
public String getQuery() {
return query;
}
}
40 changes: 20 additions & 20 deletions src/main/java/net/socketconnection/jva/enums/Language.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ public enum Language {
JAPANESE("ja_JP", "ja-jp", "Japanese"),
KOREAN("ko_KR", "ko-kr", "Korean");

private final String languageLocale;
private final String languageLocaleUrl;
private final String languageName;

Language(String languageLocale, String languageLocaleUrl, String languageName) {
this.languageLocale = languageLocale;
this.languageLocaleUrl = languageLocaleUrl;
this.languageName = languageName;
private final String locale;
private final String localeUrl;
private final String name;

Language(String locale, String localeUrl, String name) {
this.locale = locale;
this.localeUrl = localeUrl;
this.name = name;
}

public static Language getFromLanguageName(String languageName) {
public static Language getFromName(String name) {
for(Language language : values()) {
if(!language.languageName.equalsIgnoreCase(languageName)) {
if(!language.name.equalsIgnoreCase(name)) {
continue;
}

Expand All @@ -42,9 +42,9 @@ public static Language getFromLanguageName(String languageName) {
return null;
}

public static Language getFromLanguageLocaleUrl(String languageLocaleUrl) {
public static Language getFromLocaleUrl(String localeUrl) {
for(Language language : values()) {
if(!language.languageLocaleUrl.equalsIgnoreCase(languageLocaleUrl)) {
if(!language.localeUrl.equalsIgnoreCase(localeUrl)) {
continue;
}

Expand All @@ -54,9 +54,9 @@ public static Language getFromLanguageLocaleUrl(String languageLocaleUrl) {
return null;
}

public static Language getFromLanguageLocale(String languageLocale) {
public static Language getFromLocale(String locale) {
for(Language language : values()) {
if(!language.languageLocale.equalsIgnoreCase(languageLocale)) {
if(!language.locale.equalsIgnoreCase(locale)) {
continue;
}

Expand All @@ -66,15 +66,15 @@ public static Language getFromLanguageLocale(String languageLocale) {
return null;
}

public String getLanguageName() {
return languageName;
public String getName() {
return name;
}

public String getLanguageLocaleUrl() {
return languageLocaleUrl;
public String getLocaleUrl() {
return localeUrl;
}

public String getLanguageLocale() {
return languageLocale;
public String getLocale() {
return locale;
}
}
15 changes: 7 additions & 8 deletions src/main/java/net/socketconnection/jva/enums/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ public enum Map {
FRACTURE("Fracture"),
PEARL("Pearl");

private final String mapName;
private final String name;

Map(String mapName) {
this.mapName = mapName;
Map(String name) {
this.name = name;
}

public static Map getFromMapName(String mapName) {
public static Map getFromName(String name) {
for(Map map : values()) {
if(!map.mapName.equalsIgnoreCase(mapName)) {
if(!map.name.equalsIgnoreCase(name)) {
continue;
}

Expand All @@ -30,8 +30,7 @@ public static Map getFromMapName(String mapName) {
return null;
}

public String getMapName() {
return mapName;
public String getName() {
return name;
}

}
Loading

0 comments on commit e1f8997

Please sign in to comment.