86 lines
1.9 KiB
Java
86 lines
1.9 KiB
Java
package dev.loki.totem;
|
|
|
|
import org.bukkit.Location;
|
|
import org.bukkit.entity.ArmorStand;
|
|
import org.bukkit.entity.EntityType;
|
|
|
|
import java.util.UUID;
|
|
|
|
public abstract class Totem {
|
|
protected final UUID id;
|
|
protected final Location location;
|
|
protected ArmorStand display;
|
|
protected TotemState state;
|
|
protected UUID linkedPerkId;
|
|
|
|
public Totem(Location location) {
|
|
this.id = UUID.randomUUID();
|
|
this.location = location;
|
|
this.state = TotemState.DULL;
|
|
this.linkedPerkId = null;
|
|
}
|
|
|
|
public void spawn() {
|
|
if (display != null && !display.isDead()) {
|
|
return;
|
|
}
|
|
display = (ArmorStand) location.getWorld().spawnEntity(location, EntityType.ARMOR_STAND);
|
|
display.setVisible(false);
|
|
display.setGravity(false);
|
|
display.setSmall(true);
|
|
display.setMarker(true);
|
|
display.setCustomNameVisible(true);
|
|
updateVisuals();
|
|
}
|
|
|
|
public void remove() {
|
|
if (display != null && !display.isDead()) {
|
|
display.remove();
|
|
}
|
|
}
|
|
|
|
public abstract void updateVisuals();
|
|
|
|
public abstract void onInteract(UUID playerId);
|
|
|
|
public UUID getId() {
|
|
return id;
|
|
}
|
|
|
|
public Location getLocation() {
|
|
return location;
|
|
}
|
|
|
|
public TotemState getState() {
|
|
return state;
|
|
}
|
|
|
|
public void setState(TotemState state) {
|
|
this.state = state;
|
|
updateVisuals();
|
|
}
|
|
|
|
public UUID getLinkedPerkId() {
|
|
return linkedPerkId;
|
|
}
|
|
|
|
public void setLinkedPerkId(UUID linkedPerkId) {
|
|
this.linkedPerkId = linkedPerkId;
|
|
}
|
|
|
|
public boolean isHexTotem() {
|
|
return state == TotemState.HEX;
|
|
}
|
|
|
|
public boolean isBlessedTotem() {
|
|
return state == TotemState.BLESSED;
|
|
}
|
|
|
|
public boolean isCleansed() {
|
|
return state == TotemState.CLEANSED;
|
|
}
|
|
|
|
public double distanceTo(Location other) {
|
|
return location.distance(other);
|
|
}
|
|
}
|