Skip to content

Commit

Permalink
Added lifetime counter and fixed goto bug
Browse files Browse the repository at this point in the history
Fixes #43
  • Loading branch information
tastybento committed May 3, 2020
1 parent 38bdf1a commit 1e85074
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/java/world/bentobox/aoneblock/AOneBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ private boolean loadSettings() {
public void onEnable(){
try {
oneBlockManager = new OneBlocksManager(this);
oneBlockManager.loadPhases();
listener = new BlockListener(this);
registerListener(listener);
registerListener(new NoBlockHandler(this));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class OneBlockIslands implements DataObject {
@Expose
private int blockNumber;
@Expose
private long lifetime;
@Expose
private String phaseName = "";

private List<OneBlockObject> queue;
Expand Down Expand Up @@ -119,5 +121,19 @@ public void clearQueue() {
queue.clear();
}

/**
* @return the loops
*/
public long getLifetime() {
return lifetime;
}

/**
* @param loops the loops to set
*/
public void setLifetime(long loops) {
this.lifetime = loops;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,13 @@ private void process(Cancellable e, Island i, @NonNull Player player) {
OneBlockPhase phase = oneBlocksManager.getPhase(is.getBlockNumber());
// Check for a goto
if (phase.getGotoBlock() != null) {
phase = oneBlocksManager.getPhase(phase.getGotoBlock());
is.setBlockNumber(phase.getGotoBlock());
int gotoBlock = phase.getGotoBlock();
phase = oneBlocksManager.getPhase(gotoBlock);
// Store lifetime
is.setLifetime(is.getLifetime() + is.getBlockNumber());
// Set current block
is.setBlockNumber(gotoBlock);

}
// Announce the phase
boolean newPhase = false;
Expand Down

0 comments on commit 1e85074

Please sign in to comment.