mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2025-08-03 11:05:41 +00:00
Added location reflection methods (ours -> bukkit), should not be used often -> Got to add wrappers.
This commit is contained in:
parent
5b3a2d58b4
commit
54d33bb21c
1 changed files with 21 additions and 0 deletions
|
@ -1,5 +1,8 @@
|
|||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
/**
|
||||
* Created 2015-02-11 for PlotSquared
|
||||
*
|
||||
|
@ -156,4 +159,22 @@ public class Location implements Cloneable, Comparable<Location> {
|
|||
public String toString() {
|
||||
return "\"plotsquaredlocation\":{" + "\"x\":" + x + ",\"y\":" + y + ",\"z\":" + z + ",\"yaw\":" + yaw + ",\"pitch\":" + pitch + ",\"world\":\"" + world + "\"}";
|
||||
}
|
||||
|
||||
private Object getBukkitWorld() {
|
||||
try {
|
||||
Class clazz = Class.forName("org.bukkit.Bukkit");
|
||||
return clazz.getMethod("getWorld", String.class).invoke(null, world);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object toBukkitLocation() {
|
||||
try {
|
||||
Constructor constructor = Class.forName("org.bukkit.Location").getConstructor(Class.forName("org.bukkit.World"), double.class, double.class, double.class, float.class, float.class);
|
||||
return constructor.newInstance(Class.forName("org.bukkit.World").cast(getBukkitWorld()), x, y, z, yaw, pitch);
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | ClassNotFoundException | NoSuchMethodException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue