Skip to content

Commit 2829e70

Browse files
Release 1.3.1 (#45)
2 parents 81db20b + 6a1b3c5 commit 2829e70

File tree

11 files changed

+57
-38
lines changed

11 files changed

+57
-38
lines changed

.github/workflows/javadocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
echo "Creating .nojekyll to have Github pages deploy html as is:"
2626
touch .nojekyll
2727
- name: Deploy
28-
uses: JamesIves/github-pages-deploy-action@v4.4.1
28+
uses: JamesIves/github-pages-deploy-action@v4
2929
with:
3030
branch: gh-pages # The branch the action should deploy to.
3131
folder: build/docs/javadoc # The folder the action should deploy.

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ plugins {
55
`maven-publish`
66
`java-library`
77
id("de.chojo.publishdata") version "1.2.4"
8-
id("com.diffplug.spotless") version "6.18.0"
8+
id("com.diffplug.spotless") version "6.19.0"
99
}
1010

1111
group = "de.chojo.universalis"
12-
version = "1.3.0"
12+
version = "1.3.1"
1313

1414
repositories {
1515
maven("https://eldonexus.de/repository/maven-public")

gradle/wrapper/gradle-wrapper.jar

1.27 KB
Binary file not shown.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
44
networkTimeout=10000
5+
validateDistributionUrl=true
56
zipStoreBase=GRADLE_USER_HOME
67
zipStorePath=wrapper/dists

gradlew

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,13 @@ location of your Java installation."
130130
fi
131131
else
132132
JAVACMD=java
133-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
133+
if ! command -v java >/dev/null 2>&1
134+
then
135+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
134136
135137
Please set the JAVA_HOME variable in your environment to match the
136138
location of your Java installation."
139+
fi
137140
fi
138141

139142
# Increase the maximum file descriptors if we can.

universalis-core/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dependencies {
2-
api("com.fasterxml.jackson.core", "jackson-databind", "2.15.0")
2+
api("com.fasterxml.jackson.core", "jackson-databind", "2.15.2")
33
// Logging
44
api("org.slf4j", "slf4j-api", "2.0.7")
55

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* SPDX-License-Identifier: AGPL-3.0-only
3+
*
4+
* Copyright (C) Rainbowdashlabs and Contributor
5+
*/
6+
7+
package de.chojo.universalis.entities;
8+
9+
public enum Language {
10+
ENGLISH, GERMAN, FRENCH, JAPANESE
11+
}

universalis-core/src/main/java/de/chojo/universalis/entities/Name.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,13 @@ public record Name(@JsonProperty("en") String english,
3030
public static Name empty() {
3131
return EMPTY;
3232
}
33+
34+
public String get(Language language) {
35+
return switch (language) {
36+
case ENGLISH -> english;
37+
case GERMAN -> german;
38+
case FRENCH -> french;
39+
case JAPANESE -> japanese;
40+
};
41+
}
3342
}

universalis-core/src/main/java/de/chojo/universalis/provider/NameSupplier.java

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

77
package de.chojo.universalis.provider;
88

9+
import de.chojo.universalis.entities.Language;
910
import de.chojo.universalis.entities.Name;
1011

1112
import java.util.Collections;
13+
import java.util.Locale;
1214
import java.util.Map;
1315
import java.util.Optional;
1416

@@ -22,11 +24,6 @@ public Name fromId(int id) {
2224
return new Name("", "", "", "");
2325
}
2426

25-
@Override
26-
public Optional<Integer> fromName(String name) {
27-
return Optional.empty();
28-
}
29-
3027
@Override
3128
public Map<Integer, Name> ids() {
3229
return Collections.emptyMap();
@@ -53,18 +50,33 @@ public Map<String, Integer> jp() {
5350
}
5451
};
5552

56-
/**
57-
* Returns the name based on an id
58-
*
59-
* @param id id
60-
* @return name
61-
*/
62-
Name fromId(int id);
53+
default Name fromId(int id) {
54+
return ids().get(id);
55+
}
6356

64-
Optional<Integer> fromName(String name);
57+
default Optional<Integer> fromName(String name) {
58+
for (Language lang : Language.values()) {
59+
Optional<Integer> id = fromName(lang, name);
60+
if (id.isPresent()) return id;
61+
}
62+
return Optional.empty();
63+
}
64+
65+
default Optional<Integer> fromName(Language language, String name) {
66+
return Optional.ofNullable(languageMap(language).get(name.toLowerCase(Locale.ROOT)));
67+
}
6568

6669
Map<Integer, Name> ids();
6770

71+
default Map<String, Integer> languageMap(Language language) {
72+
return switch (language) {
73+
case ENGLISH -> en();
74+
case GERMAN -> de();
75+
case FRENCH -> fr();
76+
case JAPANESE -> jp();
77+
};
78+
}
79+
6880
Map<String, Integer> en();
6981

7082
Map<String, Integer> de();

universalis-core/src/main/java/de/chojo/universalis/provider/items/Items.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717
import java.net.http.HttpResponse;
1818
import java.util.Collections;
1919
import java.util.HashMap;
20-
import java.util.List;
2120
import java.util.Locale;
2221
import java.util.Map;
23-
import java.util.Optional;
2422

2523
/**
2624
* A class which is able to act as a {@link NameSupplier} for items
@@ -68,21 +66,6 @@ public static Items create() throws IOException, InterruptedException {
6866
return new Items(idNames);
6967
}
7068

71-
@Override
72-
public Name fromId(int id) {
73-
return ids.get(id);
74-
}
75-
76-
@Override
77-
public Optional<Integer> fromName(String name) {
78-
for (var map : List.of(en, de, fr, jp)) {
79-
if (map.containsKey(name.toLowerCase(Locale.ROOT))) {
80-
return Optional.ofNullable(map.get(name.toLowerCase(Locale.ROOT)));
81-
}
82-
}
83-
return Optional.empty();
84-
}
85-
8669
@Override
8770
public Map<Integer, Name> ids() {
8871
return Collections.unmodifiableMap(ids);

0 commit comments

Comments
 (0)