mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2025-02-15 11:31:27 +01:00
Expand Position API
This commit is contained in:
parent
7db51a6dae
commit
cd6dd1b4d2
@ -8,6 +8,7 @@ package me.filoghost.holographicdisplays.api;
|
||||
import me.filoghost.holographicdisplays.api.internal.HolographicDisplaysAPIProvider;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -15,16 +16,24 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface Position {
|
||||
|
||||
static @NotNull Position create(@NotNull World world, double x, double y, double z) {
|
||||
static @NotNull Position of(@NotNull World world, double x, double y, double z) {
|
||||
return HolographicDisplaysAPIProvider.getImplementation().createPosition(world, x, y, z);
|
||||
}
|
||||
|
||||
static @NotNull Position create(@NotNull String worldName, double x, double y, double z) {
|
||||
static @NotNull Position of(@NotNull String worldName, double x, double y, double z) {
|
||||
return HolographicDisplaysAPIProvider.getImplementation().createPosition(worldName, x, y, z);
|
||||
}
|
||||
|
||||
static @NotNull Position fromLocation(@NotNull Location location) {
|
||||
return HolographicDisplaysAPIProvider.getImplementation().createPosition(location);
|
||||
static @NotNull Position of(@NotNull Location location) {
|
||||
return HolographicDisplaysAPIProvider.getImplementation().getPosition(location);
|
||||
}
|
||||
|
||||
static @NotNull Position of(@NotNull Entity entity) {
|
||||
return HolographicDisplaysAPIProvider.getImplementation().getPosition(entity);
|
||||
}
|
||||
|
||||
static @NotNull Position of(@NotNull Block block) {
|
||||
return HolographicDisplaysAPIProvider.getImplementation().getPosition(block);
|
||||
}
|
||||
|
||||
@NotNull String getWorldName();
|
||||
|
@ -9,6 +9,8 @@ import me.filoghost.holographicdisplays.api.HolographicDisplaysAPI;
|
||||
import me.filoghost.holographicdisplays.api.Position;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.ApiStatus.Internal;
|
||||
|
||||
@ -37,6 +39,10 @@ public abstract class HolographicDisplaysAPIProvider {
|
||||
|
||||
public abstract Position createPosition(String worldName, double x, double y, double z);
|
||||
|
||||
public abstract Position createPosition(Location location);
|
||||
public abstract Position getPosition(Location location);
|
||||
|
||||
public abstract Position getPosition(Entity entity);
|
||||
|
||||
public abstract Position getPosition(Block block);
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ import me.filoghost.holographicdisplays.plugin.hologram.base.ImmutablePosition;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.registry.PlaceholderRegistry;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.Map;
|
||||
@ -43,7 +45,7 @@ public class DefaultHolographicDisplaysAPIProvider extends HolographicDisplaysAP
|
||||
@Override
|
||||
public Position createPosition(World world, double x, double y, double z) {
|
||||
Preconditions.notNull(world, "world");
|
||||
return new ImmutablePosition(world.getName(), x, y, z);
|
||||
return createPosition(world.getName(), x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -52,8 +54,19 @@ public class DefaultHolographicDisplaysAPIProvider extends HolographicDisplaysAP
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position createPosition(Location location) {
|
||||
public Position getPosition(Location location) {
|
||||
return new ImmutablePosition(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position getPosition(Entity entity) {
|
||||
Preconditions.notNull(entity, "entity");
|
||||
return getPosition(entity.getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position getPosition(Block block) {
|
||||
return createPosition(block.getWorld(), block.getX(), block.getY(), block.getZ());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user