forked from Upstream/mmocore
Fixed doc
This commit is contained in:
parent
ee813bde38
commit
25d4639636
@ -6,118 +6,112 @@ import java.util.Objects;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Booster {
|
public class Booster {
|
||||||
private final UUID uuid = UUID.randomUUID();
|
private final UUID uuid = UUID.randomUUID();
|
||||||
private final long date = System.currentTimeMillis();
|
private final long date = System.currentTimeMillis();
|
||||||
private final Profession profession;
|
private final Profession profession;
|
||||||
private final double extra;
|
private final double extra;
|
||||||
private final String author;
|
private final String author;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Length is not final because boosters can stacks. This allows to reduce
|
* Length is not final because boosters can stacks. This allows to reduce
|
||||||
* the amount of boosters displayed in the main player menu
|
* the amount of boosters displayed in the main player menu
|
||||||
*
|
* <p>
|
||||||
* See {@link BoosterManager#register(Booster)}
|
* See {@link BoosterManager#register(Booster)}
|
||||||
*/
|
*/
|
||||||
private long length;
|
private long length;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param extra
|
* @param extra 1 for +100% experience, 3 for 300% etc.
|
||||||
* 1 for +100% experience, 3 for 300% etc.
|
* @param length Booster length in seconds
|
||||||
* @param length
|
*/
|
||||||
* Booster length in milliseconds
|
public Booster(double extra, long length) {
|
||||||
*/
|
this(null, null, extra, length);
|
||||||
public Booster(double extra, long length) {
|
}
|
||||||
this(null, null, extra, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main class experience booster
|
* Main class experience booster
|
||||||
*
|
*
|
||||||
* @param author The booster creator
|
* @param author The booster creator
|
||||||
* @param extra 1 for +100% experience, 3 for 300% etc.
|
* @param extra 1 for +100% experience, 3 for 300% etc.
|
||||||
* @param length Booster length in milliseconds
|
* @param length Booster length in seconds
|
||||||
*/
|
*/
|
||||||
public Booster(String author, double extra, long length) {
|
public Booster(String author, double extra, long length) {
|
||||||
this(author, null, extra, length);
|
this(author, null, extra, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Profession experience booster
|
* Profession experience booster
|
||||||
*
|
*
|
||||||
* @param author
|
* @param author The booster creator
|
||||||
* The booster creator
|
* @param profession Either null for main level boosters or a specific profession
|
||||||
* @param profession
|
* @param extra 1 for +100% experience, 3 for 300% etc.
|
||||||
* Either null for main level boosters or a specific profession
|
* @param length Booster length in seconds
|
||||||
* @param extra
|
*/
|
||||||
* 1 for +100% experience, 3 for 300% etc.
|
public Booster(String author, Profession profession, double extra, long length) {
|
||||||
* @param length
|
this.author = author;
|
||||||
* Booster length in milliseconds
|
this.length = length * 1000;
|
||||||
*/
|
this.profession = profession;
|
||||||
public Booster(String author, Profession profession, double extra, long length) {
|
this.extra = extra;
|
||||||
this.author = author;
|
}
|
||||||
this.length = length * 1000;
|
|
||||||
this.profession = profession;
|
|
||||||
this.extra = extra;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getUniqueId() {
|
public UUID getUniqueId() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getExtra() {
|
public double getExtra() {
|
||||||
return extra;
|
return extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasAuthor() {
|
public boolean hasAuthor() {
|
||||||
return author != null;
|
return author != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAuthor() {
|
public String getAuthor() {
|
||||||
return author;
|
return author;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getCreationDate() {
|
public long getCreationDate() {
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasProfession() {
|
public boolean hasProfession() {
|
||||||
return profession != null;
|
return profession != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Profession getProfession() {
|
public Profession getProfession() {
|
||||||
return profession;
|
return profession;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTimedOut() {
|
public boolean isTimedOut() {
|
||||||
return date + length < System.currentTimeMillis();
|
return date + length < System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getLeft() {
|
public long getLeft() {
|
||||||
return Math.max(0, date + length - System.currentTimeMillis());
|
return Math.max(0, date + length - System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getLength() {
|
public long getLength() {
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLength(long length) {
|
public void addLength(long length) {
|
||||||
this.length += length;
|
this.length += length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canStackWith(Booster booster) {
|
public boolean canStackWith(Booster booster) {
|
||||||
return extra == booster.extra && Objects.equals(profession, booster.profession);
|
return extra == booster.extra && Objects.equals(profession, booster.profession);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
Booster booster = (Booster) o;
|
Booster booster = (Booster) o;
|
||||||
return Objects.equals(uuid, booster.uuid);
|
return Objects.equals(uuid, booster.uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(uuid);
|
return Objects.hash(uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user