2021-11-04 16:57:55 +00:00
|
|
|
package com.alttd.vboosters.data;
|
|
|
|
|
|
2021-12-25 17:05:07 +00:00
|
|
|
import com.alttd.boosterapi.Booster;
|
|
|
|
|
import com.alttd.boosterapi.BoosterType;
|
2021-11-04 16:57:55 +00:00
|
|
|
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
2021-12-25 17:05:07 +00:00
|
|
|
public class VelocityBooster implements Booster {
|
2021-11-04 16:57:55 +00:00
|
|
|
|
|
|
|
|
private UUID uuid;
|
|
|
|
|
private String activator;
|
|
|
|
|
private Long startingTime;
|
|
|
|
|
private long duration;
|
|
|
|
|
private BoosterType boosterType;
|
2022-07-25 16:50:02 +00:00
|
|
|
private Double multiplier;
|
2021-11-04 16:57:55 +00:00
|
|
|
private Boolean active;
|
|
|
|
|
private Boolean finished;
|
|
|
|
|
|
2022-07-25 16:50:02 +00:00
|
|
|
public VelocityBooster(UUID uuid, BoosterType boosterType, String reason, long duration, double multiplier) {
|
2021-11-04 16:57:55 +00:00
|
|
|
this.uuid = uuid;
|
|
|
|
|
this.boosterType = boosterType;
|
|
|
|
|
this.activator = reason;
|
|
|
|
|
this.duration = duration;
|
|
|
|
|
this.multiplier = multiplier;
|
|
|
|
|
this.active = false;
|
|
|
|
|
this.finished = false;
|
|
|
|
|
saveBooster();
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-25 16:50:02 +00:00
|
|
|
public VelocityBooster(BoosterType type, String playerName, long duration, double multiplier) {
|
2021-11-04 16:57:55 +00:00
|
|
|
this(UUID.randomUUID(), type, playerName, duration, multiplier);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isActive() {
|
|
|
|
|
return active;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setActive(Boolean active) {
|
|
|
|
|
this.active = active;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BoosterType getType() {
|
|
|
|
|
return boosterType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setType(BoosterType boosterType) {
|
|
|
|
|
this.boosterType = boosterType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-07-25 16:50:02 +00:00
|
|
|
public double getMultiplier() {
|
2021-11-04 16:57:55 +00:00
|
|
|
return multiplier;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-07-25 16:50:02 +00:00
|
|
|
public void setMultiplier(double multiplier) {
|
2021-11-04 16:57:55 +00:00
|
|
|
this.multiplier = multiplier;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Long getStartingTime() {
|
|
|
|
|
return startingTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setStartingTime(long startingTime) {
|
|
|
|
|
this.startingTime = startingTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Long getDuration() {
|
|
|
|
|
return duration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setDuration(long duration) {
|
|
|
|
|
this.duration = duration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getActivator() {
|
|
|
|
|
return activator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setActivator(String activationReason) {
|
|
|
|
|
this.activator = activationReason;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public long getTimeRemaining() {
|
|
|
|
|
if(active) {
|
|
|
|
|
return startingTime + duration - System.currentTimeMillis();
|
|
|
|
|
}
|
|
|
|
|
return duration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public UUID getUUID() {
|
|
|
|
|
return uuid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void stopBooster() {
|
2021-12-25 17:05:07 +00:00
|
|
|
setDuration(getTimeRemaining());
|
|
|
|
|
setActive(false);
|
|
|
|
|
saveBooster();
|
2021-11-04 16:57:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void saveBooster() {
|
2021-12-25 17:05:07 +00:00
|
|
|
// logic to save to yaml or to db
|
|
|
|
|
}
|
2021-11-04 16:57:55 +00:00
|
|
|
|
2021-12-25 17:05:07 +00:00
|
|
|
public void finish() {
|
|
|
|
|
finished = true;
|
|
|
|
|
stopBooster();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean finished() {
|
|
|
|
|
return finished;
|
2021-11-04 16:57:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|