Skip to content

Commit

Permalink
update core to use 1.18, itemstack type adapter renamed, add item b64…
Browse files Browse the repository at this point in the history
… backwards comapt
  • Loading branch information
The-Epic committed May 7, 2023
1 parent 8a95a6c commit 195c178
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion epicspigotlib-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repositories {
}

dependencies {
compileOnly 'org.spigotmc:spigot:1.17-R0.1-SNAPSHOT'
compileOnly 'org.spigotmc:spigot:1.18-R0.1-SNAPSHOT'
annotationProcessor 'org.projectlombok:lombok:1.18.24' // Lombok
compileOnly 'org.projectlombok:lombok:1.18.24' // Lombok
compileOnly "net.kyori:adventure-platform-bukkit:4.2.0" // Adventure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import com.google.gson.*;
import com.google.gson.reflect.TypeToken;
import me.epic.spigotlib.serialisation.ItemSerializer;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.configuration.serialization.ConfigurationSerialization;

import java.lang.reflect.Type;
import java.util.LinkedHashMap;
import java.util.Map;

public class ItemStackAdapter implements JsonSerializer<ConfigurationSerializable>, JsonDeserializer<ConfigurationSerializable> {
public class ConfigurationSerializableAdapter implements JsonSerializer<ConfigurationSerializable>, JsonDeserializer<ConfigurationSerializable> {
// @Override
// public void write(JsonWriter out, ItemStack value) throws IOException {
// out.beginObject();
Expand All @@ -32,6 +33,13 @@ public class ItemStackAdapter implements JsonSerializer<ConfigurationSerializabl

@Override
public ConfigurationSerializable deserialize(JsonElement json,Type typeOfT,JsonDeserializationContext context) throws JsonParseException {
if (json.isJsonObject()) {
JsonObject jsonObject = json.getAsJsonObject();
if (jsonObject.has("item")) {
return ItemSerializer.itemStackFromBase64(jsonObject.get("item").getAsString());
}
}

final Map<String, Object> map = new LinkedHashMap<>();

for (Map.Entry<String, JsonElement> entry : json.getAsJsonObject().entrySet()) {
Expand Down

0 comments on commit 195c178

Please sign in to comment.