perf: 重写部分代码
This commit is contained in:
@@ -3,7 +3,6 @@ package cn.hamster3.mc.plugin.core.bukkit.util;
|
|||||||
import cn.hamster3.mc.plugin.core.bukkit.listener.CallbackListener;
|
import cn.hamster3.mc.plugin.core.bukkit.listener.CallbackListener;
|
||||||
import cn.hamster3.mc.plugin.core.common.data.DisplayMessage;
|
import cn.hamster3.mc.plugin.core.common.data.DisplayMessage;
|
||||||
import com.comphenix.protocol.utility.StreamSerializer;
|
import com.comphenix.protocol.utility.StreamSerializer;
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -281,13 +280,12 @@ public final class CoreBukkitUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static PotionEffect deserializePotionEffect(@NotNull JsonElement element) {
|
public static PotionEffect deserializePotionEffect(@NotNull JsonObject object) {
|
||||||
JsonObject effectObject = element.getAsJsonObject();
|
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
return new PotionEffect(
|
return new PotionEffect(
|
||||||
PotionEffectType.getByName(effectObject.get("type").getAsString()),
|
PotionEffectType.getByName(object.get("type").getAsString()),
|
||||||
effectObject.get("duration").getAsInt(),
|
object.get("duration").getAsInt(),
|
||||||
effectObject.get("amplifier").getAsInt()
|
object.get("amplifier").getAsInt()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@ public final class PotionEffectAdapter implements JsonSerializer<PotionEffect>,
|
|||||||
if (json.isJsonNull()) {
|
if (json.isJsonNull()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return CoreBukkitUtils.deserializePotionEffect(json);
|
return CoreBukkitUtils.deserializePotionEffect(json.getAsJsonObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user