Skip to content

Commit

Permalink
Merge pull request #330 from BentoBoxWorld/itemsadder_fix
Browse files Browse the repository at this point in the history
ItemsAdder fix
  • Loading branch information
tastybento authored Jul 23, 2023
2 parents 8ae3635 + 53783f5 commit 77b94ee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
19 changes: 11 additions & 8 deletions src/main/java/world/bentobox/aoneblock/AOneBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,13 @@ private boolean loadSettings() {

@Override
public void onEnable() {
loadData();

oneBlockManager = new OneBlocksManager(this);
if (loadData()) {
// Failed to load - don't register anything
return;
}
blockListener = new BlockListener(this);
registerListener(blockListener);
registerListener(new NoBlockHandler(this));
registerListener(new BlockProtect(this));
registerListener(new JoinLeaveListener(this));
Expand All @@ -106,20 +111,18 @@ public void onEnable() {
registerListener(holoListener);
}

//Load some of Manager
public void loadData() {
// Load phase data
public boolean loadData() {
try {
oneBlockManager = new OneBlocksManager(this);
oneBlockManager.loadPhases();
blockListener = new BlockListener(this);
} catch (IOException e) {
// Disable
logError("AOneBlock settings could not load (oneblock.yml error)! Addon disabled.");
logError(e.getMessage());
setState(State.DISABLED);
return;
return true;
}
registerListener(blockListener);
return false;
}

private void registerPlaceholders() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,7 @@ private void process(@NonNull Cancellable e, @NonNull Island i, @Nullable Player
String originalPhase = is.getPhaseName();
// Check for a goto
if (Objects.requireNonNull(phase).getGotoBlock() != null) {
int gotoBlock = phase.getGotoBlock();
phase = oneBlocksManager.getPhase(gotoBlock);
// Store lifetime
is.setLifetime(is.getLifetime() + gotoBlock);
// Set current block
is.setBlockNumber(gotoBlock);

handleGoto(is, phase);
}
// Check for new phase and run commands if required
boolean newPhase = check.checkPhase(player, i, is, Objects.requireNonNull(phase));
Expand Down Expand Up @@ -355,6 +349,15 @@ private void process(@NonNull Cancellable e, @NonNull Island i, @Nullable Player
is.incrementBlockNumber();
}

private void handleGoto(OneBlockIslands is, OneBlockPhase phase) {
int gotoBlock = phase.getGotoBlock();
phase = oneBlocksManager.getPhase(gotoBlock);
// Store lifetime
is.setLifetime(is.getLifetime() + gotoBlock);
// Set current block
is.setBlockNumber(gotoBlock);
}

private void setBiome(@NonNull Block block, @Nullable Biome biome) {
if (biome == null) {
return;
Expand Down

0 comments on commit 77b94ee

Please sign in to comment.