Fix reflection in PlayerDataStorage + new wrapOptional method in reflection library
This commit is contained in:
@@ -16,13 +16,12 @@ public class PlayerDataStorage extends ReflectWrapper {
|
||||
public static final ReflectMethod<?> load = wrapEx(() -> REFLECT.method("load", String.class, String.class));
|
||||
|
||||
/**
|
||||
* @param playerName the name of the player: used for loading error message and of offline UUID generation.
|
||||
* @param playerId UUID of a player as it is used to name the player data file (UUID.toString())
|
||||
* @param playerName the name of the player: used for loading error message and for offline UUID generation.
|
||||
* @param playerId UUID of a player as it is used to name the player data file (UUID.toString()).
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Optional<CompoundTag> load(String playerName, String playerId) {
|
||||
return ((Optional<Object>) wrapReflectEx(() -> load.invoke(__getRuntimeInstance(), playerId)))
|
||||
.map(o -> wrap(o, CompoundTag.class));
|
||||
return wrapOptional((Optional<Object>) wrapReflectEx(() -> load.invoke(__getRuntimeInstance(), playerName, playerId)), CompoundTag.class);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user