feat: 添加工具方法

This commit is contained in:
2022-11-04 01:06:05 +08:00
parent a3c22a08bd
commit 1be826ff3c
4 changed files with 35 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ package cn.hamster3.mc.plugin.ball.bukkit.data;
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
import cn.hamster3.mc.plugin.ball.common.data.BallBlockPos;
import cn.hamster3.mc.plugin.core.common.constant.CoreConstantObjects;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
@@ -42,6 +43,10 @@ public class BukkitBlockPos extends BallBlockPos {
);
}
public static BukkitBlockPos fromJson(String json) {
return CoreConstantObjects.GSON.fromJson(json, BukkitBlockPos.class);
}
@NotNull
public Location toBukkitLocation() {
return new Location(Bukkit.getWorld(getWorldName()), getX(), getY(), getZ(), 0, 0);

View File

@@ -2,6 +2,7 @@ package cn.hamster3.mc.plugin.ball.bukkit.data;
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
import cn.hamster3.mc.plugin.ball.common.data.BallLocation;
import cn.hamster3.mc.plugin.core.common.constant.CoreConstantObjects;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
@@ -50,6 +51,10 @@ public class BukkitLocation extends BallLocation {
);
}
public static BukkitLocation fromJson(String json) {
return CoreConstantObjects.GSON.fromJson(json, BukkitLocation.class);
}
@NotNull
public Location toBukkitLocation() {
return new Location(Bukkit.getWorld(getWorldName()), getX(), getY(), getZ(), getYaw(), getPitch());