Skip to content

Commit

Permalink
Database loading fixes try 1
Browse files Browse the repository at this point in the history
  • Loading branch information
efekos committed Feb 25, 2024
1 parent fcf9e63 commit 4d57d1f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,5 @@ command classes yourself.\

## 1.7.1

![](https://raw.githubusercontent.com/efekos/efekos/main/icons/symbol-plus.svg) Added icons to changelogs.
![](https://raw.githubusercontent.com/efekos/efekos/main/icons/symbol-plus.svg) Added icons to changelogs.\
![](https://raw.githubusercontent.com/efekos/efekos/main/icons/symbol-change.svg) Changed
10 changes: 5 additions & 5 deletions src/main/java/me/efekos/simpler/config/ListDataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@
import java.io.*;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;

/**
* A basic database class made using {@link Gson}. You can store a {@link List<T>} in this data. Use {@link #save()}
* and {@link #load(Class)} to load your data.
* and {@link #load()} to load your data.
* @param <T>
* Type of the data you want to store as a list. Be aware that using incompatible types
* in this type might cause errors. Just to let you know, there is a list of the classes
Expand Down Expand Up @@ -163,11 +164,10 @@ public void load(){
Reader reader = new FileReader(file);


T[] n = gson.fromJson(reader, new TypeToken<List<T>>(){}.getType());
TypeToken<List<T>> token = new TypeToken<>(){};
T[] n = gson.fromJson(reader, token.getType());

for (T t : n) {
datas.add(t);
}
Collections.addAll(datas, n);

reader.close();
} catch (Exception e){
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/me/efekos/simpler/config/MapDataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ public void load(){
TypeToken<Map<K, V>> token = new TypeToken<>() {
};

Map<K,V> n = (Map<K, V>) gson.fromJson(reader,token.getRawType());

data = n;
data = gson.fromJson(reader,token.getType());

reader.close();
} catch (Exception e){
Expand Down

0 comments on commit 4d57d1f

Please sign in to comment.