Skip to content

Commit

Permalink
Fixed serialization for collections made by utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
mikigal committed Apr 4, 2021
1 parent 696ff89 commit 7d3ff09
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ maven {
url = 'https://repo.mikigal.pl/releases'
}
compile group: 'pl.mikigal', name: 'ConfigAPI', version: '1.1.2'
compile group: 'pl.mikigal', name: 'ConfigAPI', version: '1.1.3'
```

#### Maven
Expand All @@ -33,7 +33,7 @@ compile group: 'pl.mikigal', name: 'ConfigAPI', version: '1.1.2'
<dependency>
<groupId>pl.mikigal</groupId>
<artifactId>ConfigAPI</artifactId>
<version>1.1.2</version>
<version>1.1.3</version>
<scope>compile</scope>
</dependency>
```
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'pl.mikigal'
version '1.1.2'
version '1.1.3'

publishing {
repositories {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/pl/mikigal/config/serializer/universal/UniversalCollectionSerializer.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ protected void saveObject(String path, Collection object, BukkitConfiguration co
throw new IllegalStateException("Can't set empty Collection to config");
}

if (object.getClass().isMemberClass()) {
// Workaround for utilities, e. g. Arrays.asList()
object = new ArrayList(object);
}

Class<?> generic = TypeUtils.getCollectionGeneric(object);
Serializer<?> serializer = Serializers.of(generic);
if (serializer == null && !TypeUtils.isSimpleType(generic)) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/pl/mikigal/config/serializer/universal/UniversalMapSerializer.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ protected void saveObject(String path, Map object, BukkitConfiguration configura
throw new IllegalStateException("Can't set empty Map to config");
}

if (object.getClass().isMemberClass()) {
// Workaround for utilities, e. g. Collections.singletonMap()
object = new HashMap(object);
}

Class<?> generic = TypeUtils.getMapGeneric(object)[1];
Serializer<?> serializer = Serializers.of(generic);
if (serializer == null && !TypeUtils.isSimpleType(generic)) {
Expand Down

0 comments on commit 7d3ff09

Please sign in to comment.