Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bukkit-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>dev.spoocy.utils</groupId>
<artifactId>root</artifactId>
<version>1.0.12</version>
<version>1.0.13</version>
</parent>

<artifactId>bukkit-utils</artifactId>
Expand Down Expand Up @@ -66,12 +66,14 @@
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21.11-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>3.16.29</version>
<scope>provided</scope>
</dependency>

</dependencies>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap;
import dev.spoocy.utils.config.serializer.Serializer;
import org.jetbrains.annotations.NotNull;

import java.lang.reflect.Type;
Expand All @@ -16,58 +15,12 @@
* @author Spoocy99 | GitHub: Spoocy99
*/

public class GameProfileSerializer implements Serializer<GameProfile>, JsonSerializer<GameProfile>, JsonDeserializer<GameProfile> {
public class GameProfileSerializer implements JsonSerializer<GameProfile>, JsonDeserializer<GameProfile> {

public static final GameProfileSerializer INSTANCE = new GameProfileSerializer();

private GameProfileSerializer() { }

@Override
public @NotNull Map<String, Object> serialize(@NotNull GameProfile object) {
Map<String, Object> result = new HashMap<>();

if (object.getId() != null) {
result.put("id", object.getId());
}

if (object.getName() != null) {
result.put("name", object.getName());
}

if (!object.getProperties().isEmpty()) {
Map<String, Object> properties = new HashMap<>();
for (Map.Entry<String, Property> entry : object.getProperties().entries()) {
properties.put(entry.getKey(), entry.getValue().getValue());
}
result.put("properties", properties);
}

return result;
}

@Override
public @NotNull GameProfile deserialize(@NotNull Map<String, Object> map) {
UUID id = (UUID) map.get("id");
String name = (String) map.get("name");
GameProfile profile = new GameProfile(id, name);

if (map.containsKey("properties")) {
Map<String, Object> properties = null;

try {
properties = (Map<String, Object>) map.get("properties");
} catch (IllegalArgumentException ignored) { }

if(properties == null) {
for (Map.Entry<String, Object> entry : properties.entrySet()) {
profile.getProperties().put(entry.getKey(), new Property(entry.getKey(), (String) entry.getValue()));
}
}
}

return profile;
}

@Override
public JsonElement serialize(GameProfile gameProfile, Type type, JsonSerializationContext jsonSerializationContext) {
JsonObject result = new JsonObject();
Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion bukkit-utils/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

module dev.spoocy.utils.bukkit {
requires org.jetbrains.annotations;
requires static org.jetbrains.annotations;
requires dev.spoocy.utils.common;
requires dev.spoocy.utils.config;
requires org.bukkit;
Expand Down
2 changes: 1 addition & 1 deletion common-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>dev.spoocy.utils</groupId>
<artifactId>root</artifactId>
<version>1.0.12</version>
<version>1.0.13</version>
</parent>

<artifactId>common-utils</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.util.function.UnaryOperator;

/**
* A custom implementation of ArrayList that normalizes the index to be 1-based instead of 0-based.
*
* @author Spoocy99 | GitHub: Spoocy99
*/

Expand Down
Loading
Loading