Stage 12: Data storage system
This commit is contained in:
parent
82ed455cd2
commit
4fd7955d56
62 changed files with 5613 additions and 0 deletions
117
src/main/java/dev/loki/objective/Generator.java
Normal file
117
src/main/java/dev/loki/objective/Generator.java
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
package dev.loki.objective;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Generator {
|
||||
private final int id;
|
||||
private final Location location;
|
||||
private double progress;
|
||||
private boolean isCompleted;
|
||||
private boolean isBlocked;
|
||||
private UUID currentRepairer;
|
||||
private int regressionTicks;
|
||||
private boolean wasKicked;
|
||||
|
||||
public Generator(int id, Location location) {
|
||||
this.id = id;
|
||||
this.location = location;
|
||||
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 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 boolean wasKicked() {
|
||||
return wasKicked;
|
||||
}
|
||||
|
||||
public void setKicked(boolean kicked) {
|
||||
this.wasKicked = kicked;
|
||||
}
|
||||
|
||||
public boolean canBeRepaired() {
|
||||
return !isCompleted && !isBlocked;
|
||||
}
|
||||
|
||||
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