Browse Source

refactoring: Shop.java

remotes/origin/develop
Max Gerbeth 2 years ago
parent
commit
87803bc281
  1. 2
      pom.xml
  2. 5
      src/main/java/org/bitbiome/classes/Shop.java

2
pom.xml

@ -28,7 +28,7 @@
<dependency> <dependency>
<groupId>org.json</groupId> <groupId>org.json</groupId>
<artifactId>json</artifactId> <artifactId>json</artifactId>
<version>20180130</version>
<version>20220320</version>
</dependency> </dependency>
</dependencies> </dependencies>

5
src/main/java/org/bitbiome/classes/Shop.java

@ -7,6 +7,7 @@ import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.File; import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
@ -155,7 +156,7 @@ public class Shop {
File file = new File("src/main/resources/items.json"); File file = new File("src/main/resources/items.json");
JSONArray itemJSON = null; JSONArray itemJSON = null;
try { try {
String content3 = new String(Files.readAllBytes(Paths.get(file.toURI())), "UTF-8");
String content3 = new String(Files.readAllBytes(Paths.get(file.toURI())), StandardCharsets.UTF_8);
itemJSON = new JSONArray(content3); itemJSON = new JSONArray(content3);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -192,7 +193,7 @@ public class Shop {
} else { } else {
damage = tempJSON.getString("damage"); damage = tempJSON.getString("damage");
} }
doesDmg = !damage.equals("0") ? false : true;
doesDmg = damage.equals("0");
arrayList.add(new Item(tempJSON.getString("name"), doesDmg, damage, tempJSON.getInt(key), arrayList.add(new Item(tempJSON.getString("name"), doesDmg, damage, tempJSON.getInt(key),
tempJSON.getInt("gold"))); tempJSON.getInt("gold")));
} }

Loading…
Cancel
Save