-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add advancement and game stats sharables
- Loading branch information
1 parent
9a1edd9
commit 651a179
Showing
3 changed files
with
127 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/onarandombox/multiverseinventories/share/StringArraySerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.onarandombox.multiverseinventories.share; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class StringArraySerializer implements SharableSerializer<String[]> { | ||
@Override | ||
public String[] deserialize(Object obj) { | ||
List<?> list = (List<?>) obj; | ||
List<String> resultList = new ArrayList<>(list.size()); | ||
for (Object o : list) { | ||
if (o instanceof String) { | ||
resultList.add((String) o); | ||
} | ||
} | ||
return resultList.toArray(new String[resultList.size()]); | ||
} | ||
|
||
@Override | ||
public Object serialize(String[] strings) { | ||
return Arrays.asList(strings); | ||
} | ||
} |