1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
package com.earth2me.essentials.bukkit;
import com.earth2me.essentials.api.server.World;
import com.earth2me.essentials.api.server.Location;
import lombok.Delegate;
import lombok.Getter;
public class BukkitLocation extends Location
{
public static class BukkitLocationFactory implements LocationFactory
{
private final org.bukkit.Server server;
public BukkitLocationFactory(org.bukkit.Server server)
{
this.server = server;
}
@Override
public Location create(String worldName, double x, double y, double z, double yaw, double pitch)
{
org.bukkit.World world = server.getWorld(worldName);
return new BukkitLocation(new org.bukkit.Location(world, x, y, z, (float)yaw, (float)pitch));
}
@Override
public Location create(World world, double x, double y, double z, double yaw, double pitch)
{
return new BukkitLocation(new org.bukkit.Location(((BukkitWorld)world).getBukkitWorld(), x, y, z, (float)yaw, (float)pitch));
}
}
private interface Excludes
{
org.bukkit.World getWorld();
}
@Delegate(excludes =
{
Excludes.class
})
@Getter
private final org.bukkit.Location bukkitLocation;
public BukkitLocation(org.bukkit.Location bukkitLocation)
{
this.bukkitLocation = bukkitLocation;
}
@Override
public World getWorld()
{
return new BukkitWorld(bukkitLocation.getWorld());
}
@Override
public double distanceSquared(final Location location)
{
return bukkitLocation.distanceSquared(((BukkitLocation)location).getBukkitLocation());
}
}
|