feat: add computers as second objective type
- New: Computer, ComputerManager, ComputerRepair, ComputerHologram, ComputerDataManager - Config: total-count=2, required-count=2, repair-seconds=90 in game.yml - Win condition: all generators AND all computers required - No regression, no ComputerKick, no compass on skill-check fail - /dbdsetup set computer, /dbdadmin list computer - Hologram progress display, persistence to data/computers.yml - LECTERN block right-click cancelled
This commit is contained in:
parent
4482b3a0ea
commit
c31ea425db
21 changed files with 1049 additions and 39 deletions
146
src/main/java/dev/loki/objective/Computer.java
Normal file
146
src/main/java/dev/loki/objective/Computer.java
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
package dev.loki.objective;
|
||||
|
||||
import dev.loki.data.ComputerDataManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class Computer {
|
||||
private final int id;
|
||||
private final Location location;
|
||||
private final double zoneRadius;
|
||||
private double progress;
|
||||
private boolean isCompleted;
|
||||
private boolean isBlocked;
|
||||
private UUID currentRepairer;
|
||||
private int regressionTicks;
|
||||
private boolean wasKicked;
|
||||
|
||||
public Computer(int id, Location location) {
|
||||
this(id, location, ComputerDataManager.getZoneRadius());
|
||||
}
|
||||
|
||||
public Computer(int id, Location location, double zoneRadius) {
|
||||
this.id = id;
|
||||
this.location = location;
|
||||
this.zoneRadius = zoneRadius;
|
||||
this.progress = 0.0;
|
||||
this.isCompleted = false;
|
||||
this.isBlocked = false;
|
||||
this.currentRepairer = null;
|
||||
this.regressionTicks = 0;
|
||||
this.wasKicked = false;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public double getZoneRadius() {
|
||||
return zoneRadius;
|
||||
}
|
||||
|
||||
public boolean isPlayerInZone(Player player) {
|
||||
if (!player.getWorld().equals(location.getWorld())) return false;
|
||||
return player.getLocation().distance(location) <= zoneRadius;
|
||||
}
|
||||
|
||||
public boolean isLocationInZone(Location loc) {
|
||||
if (!loc.getWorld().equals(location.getWorld())) return false;
|
||||
return loc.distance(location) <= zoneRadius;
|
||||
}
|
||||
|
||||
public double getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
||||
public void setProgress(double progress) {
|
||||
this.progress = Math.max(0, Math.min(100, progress));
|
||||
if (this.progress >= 100) {
|
||||
this.progress = 100;
|
||||
this.isCompleted = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void addProgress(double amount) {
|
||||
setProgress(progress + amount);
|
||||
}
|
||||
|
||||
public void removeProgress(double amount) {
|
||||
setProgress(progress - amount);
|
||||
}
|
||||
|
||||
public boolean isCompleted() {
|
||||
return isCompleted;
|
||||
}
|
||||
|
||||
public boolean isBlocked() {
|
||||
return isBlocked;
|
||||
}
|
||||
|
||||
public void setBlocked(boolean blocked) {
|
||||
this.isBlocked = blocked;
|
||||
}
|
||||
|
||||
public UUID getCurrentRepairer() {
|
||||
return currentRepairer;
|
||||
}
|
||||
|
||||
public void setCurrentRepairer(UUID repairer) {
|
||||
this.currentRepairer = repairer;
|
||||
}
|
||||
|
||||
public boolean isBeingRepaired() {
|
||||
return currentRepairer != null;
|
||||
}
|
||||
|
||||
public int getRegressionTicks() {
|
||||
return regressionTicks;
|
||||
}
|
||||
|
||||
public void setRegressionTicks(int ticks) {
|
||||
this.regressionTicks = ticks;
|
||||
}
|
||||
|
||||
public void decrementRegression() {
|
||||
if (regressionTicks > 0) {
|
||||
regressionTicks--;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isUnderRegression() {
|
||||
return regressionTicks > 0 && !isCompleted && !isBeingRepaired();
|
||||
}
|
||||
|
||||
public void setUnderRegression(boolean kicked, int durationTicks) {
|
||||
this.wasKicked = kicked;
|
||||
this.regressionTicks = durationTicks;
|
||||
}
|
||||
|
||||
public boolean wasKicked() {
|
||||
return wasKicked;
|
||||
}
|
||||
|
||||
public void setKicked(boolean kicked) {
|
||||
this.wasKicked = kicked;
|
||||
}
|
||||
|
||||
public boolean canBeRepaired() {
|
||||
return !isCompleted && !isBlocked && !isUnderRegression();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Block getBlock() {
|
||||
return location.getBlock();
|
||||
}
|
||||
|
||||
public double getDistance(Location loc) {
|
||||
return location.distance(loc);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue