feat: 添加工具方法
This commit is contained in:
@@ -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);
|
||||
|
@@ -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());
|
||||
|
Reference in New Issue
Block a user