Stage 2-3: Player states and Killer system
This commit is contained in:
parent
5a53620b3a
commit
d1f854fc79
14 changed files with 1095 additions and 0 deletions
86
src/main/java/dev/loki/totem/Totem.java
Normal file
86
src/main/java/dev/loki/totem/Totem.java
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue