Skip to content

Commit

Permalink
Merge pull request #335 from BentoBoxWorld/develop
Browse files Browse the repository at this point in the history
Release 1.14.2
  • Loading branch information
tastybento authored Sep 19, 2023
2 parents 1ca6a85 + 8ca6370 commit 6260a3c
Show file tree
Hide file tree
Showing 10 changed files with 601 additions and 133 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<name>AOneBlock</name>
<description>AOneBlock is an add-on for BentoBox, an expandable Minecraft Bukkit plugin for island-type games like SkyBlock or AcidIsland.</description>
<url>https://github.com/BentoBoxWorlgit checkout masterd/AOneBlock</url>
<url>https://github.com/BentoBoxWorld/AOneBlock</url>
<inceptionYear>2020</inceptionYear>

<developers>
Expand Down Expand Up @@ -67,7 +67,7 @@
<!-- Do not change unless you want different name for local builds. -->
<build.number>-LOCAL</build.number>
<!-- This allows to change between versions. -->
<build.version>1.14.1</build.version>
<build.version>1.14.2</build.version>
<!-- SonarCloud -->
<sonar.projectKey>BentoBoxWorld_AOneBlock</sonar.projectKey>
<sonar.organization>bentobox-world</sonar.organization>
Expand Down Expand Up @@ -215,7 +215,7 @@
<dependency>
<groupId>com.github.LoneDev6</groupId>
<artifactId>API-ItemsAdder</artifactId>
<version>3.2.5</version>
<version>3.5.0b</version>
<scope>provided</scope>
</dependency>

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/world/bentobox/aoneblock/AOneBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class AOneBlock extends GameModeAddon {

private static final String NETHER = "_nether";
private static final String THE_END = "_the_end";
public static boolean hasItemsAdder = false;
private boolean hasItemsAdder = false;

// Settings
private Settings settings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;

/**
* Command to run a sanity check
* @author tastybento
*
*/
public class AdminSanityCheck extends CompositeCommand {

private AOneBlock addon;
Expand Down
62 changes: 31 additions & 31 deletions src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -407,46 +407,46 @@ else if (player.getLocation().getBlock().equals(block.getRelative(BlockFace.UP))
private void spawnBlock(@NonNull OneBlockObject nextBlock, @NonNull Block block) {
if (nextBlock.isCustomBlock()) {
nextBlock.getCustomBlock().setBlock(block);
return;
} else if (nextBlock.isItemsAdderBlock()) {
//Get Custom Block from ItemsAdder and place it
CustomBlock cBlock = CustomBlock.getInstance(nextBlock.getItemsAdderBlock());
if (cBlock != null) {
block.getLocation().getBlock().setType(Material.AIR);
cBlock.place(block.getLocation());
}
} else {
@NonNull
Material type = nextBlock.getMaterial();
// Place new block with no physics
block.setType(type, false);
// Fill the chest
if (type.equals(Material.CHEST) && nextBlock.getChest() != null) {
fillChest(nextBlock, block);
return;
} else if (Tag.LEAVES.isTagged(type)) {
Leaves leaves = (Leaves) block.getState().getBlockData();
leaves.setPersistent(true);
block.setBlockData(leaves);
} else if (block.getState() instanceof BrushableBlock bb) {
LootTable lt = switch(bb.getBlock().getBiome()) {
default -> {
if (random.nextDouble() < 0.8) {
yield LootTables.TRAIL_RUINS_ARCHAEOLOGY_COMMON.getLootTable();
} else {
// 20% rare
yield LootTables.TRAIL_RUINS_ARCHAEOLOGY_RARE.getLootTable();
}
}
case DESERT -> LootTables.DESERT_PYRAMID_ARCHAEOLOGY.getLootTable();
case FROZEN_OCEAN -> LootTables.OCEAN_RUIN_COLD_ARCHAEOLOGY.getLootTable();
case OCEAN -> LootTables.OCEAN_RUIN_COLD_ARCHAEOLOGY.getLootTable();
case WARM_OCEAN -> LootTables.OCEAN_RUIN_WARM_ARCHAEOLOGY.getLootTable();
};
bb.setLootTable(lt);
bb.update();
}
}

@NonNull
Material type = nextBlock.getMaterial();
// Place new block with no physics
block.setType(type, false);
// Fill the chest
if (type.equals(Material.CHEST) && nextBlock.getChest() != null) {
fillChest(nextBlock, block);
return;
} else if (Tag.LEAVES.isTagged(type)) {
Leaves leaves = (Leaves) block.getState().getBlockData();
leaves.setPersistent(true);
block.setBlockData(leaves);
} else if (block.getState() instanceof BrushableBlock bb) {
LootTable lt = switch(bb.getBlock().getBiome()) {
default -> {
if (random.nextDouble() < 0.8) {
yield LootTables.TRAIL_RUINS_ARCHAEOLOGY_COMMON.getLootTable();
} else {
// 20% rare
yield LootTables.TRAIL_RUINS_ARCHAEOLOGY_RARE.getLootTable();
}
}
case DESERT -> LootTables.DESERT_PYRAMID_ARCHAEOLOGY.getLootTable();
case FROZEN_OCEAN -> LootTables.OCEAN_RUIN_COLD_ARCHAEOLOGY.getLootTable();
case OCEAN -> LootTables.OCEAN_RUIN_COLD_ARCHAEOLOGY.getLootTable();
case WARM_OCEAN -> LootTables.OCEAN_RUIN_WARM_ARCHAEOLOGY.getLootTable();
};
bb.setLootTable(lt);
bb.update();
}
}

private void spawnEntity(@NonNull OneBlockObject nextBlock, @NonNull Block block) {
Expand Down
63 changes: 30 additions & 33 deletions src/main/java/world/bentobox/aoneblock/listeners/CheckPhase.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,51 +50,48 @@ public CheckPhase(AOneBlock addon, BlockListener blockListener) {
* @param i - island
* @param phase - one block phase
* @param world - world
* @return true if the player can proceed to the next phase, false if not or if there is no next phase.
* @return true if the player cannot proceed to the next phase.
*/
protected boolean phaseRequirementsFail(@Nullable Player player, @NonNull Island i, OneBlockPhase phase, @NonNull World world) {
if (phase.getRequirements().isEmpty()) {
return false;
}
// Check requirements
boolean blocked = false;
for (Requirement r : phase.getRequirements()) {
switch (r.getType()) {
case LEVEL:
return addon.getAddonByName("Level").map(l -> {
if (((Level) l).getIslandLevel(world, i.getOwner()) < r.getLevel()) {
User.getInstance(player).sendMessage("aoneblock.phase.insufficient-level", TextVariables.NUMBER, String.valueOf(r.getLevel()));
return true;
}
return false;
}).orElse(false);
case BANK:
return addon.getAddonByName("Bank").map(l -> {
if (((Bank) l).getBankManager().getBalance(i).getValue() < r.getBank()) {
User.getInstance(player).sendMessage("aoneblock.phase.insufficient-bank-balance", TextVariables.NUMBER, String.valueOf(r.getBank()));
return true;
}
return false;
}).orElse(false);
case ECO:
return addon.getPlugin().getVault().map(l -> {
if (l.getBalance(User.getInstance(player), world) < r.getEco()) {
User.getInstance(player).sendMessage("aoneblock.phase.insufficient-funds", TextVariables.NUMBER, String.valueOf(r.getEco()));
return true;
}
return false;
}).orElse(false);
case PERMISSION:
if (player != null && !player.hasPermission(r.getPermission())) {
User.getInstance(player).sendMessage("aoneblock.phase.insufficient-permission", TextVariables.NAME, String.valueOf(r.getPermission()));
boolean b = switch (r.getType()) {
case LEVEL -> addon.getAddonByName("Level").map(l -> {
if (((Level) l).getIslandLevel(world, i.getOwner()) < r.getLevel()) {
User.getInstance(player).sendMessage("aoneblock.phase.insufficient-level", TextVariables.NUMBER, String.valueOf(r.getLevel()));
return true;
}
return false;
default:
break;

}).orElse(false);
case BANK -> addon.getAddonByName("Bank").map(l -> {
if (((Bank) l).getBankManager().getBalance(i).getValue() < r.getBank()) {
User.getInstance(player).sendMessage("aoneblock.phase.insufficient-bank-balance", TextVariables.NUMBER, String.valueOf(r.getBank()));
return true;
}
return false;
}).orElse(false);
case ECO -> addon.getPlugin().getVault().map(l -> {
if (l.getBalance(User.getInstance(player), world) < r.getEco()) {
User.getInstance(player).sendMessage("aoneblock.phase.insufficient-funds", TextVariables.NUMBER, String.valueOf(r.getEco()));
return true;
}
return false;
}).orElse(false);
case PERMISSION -> {
if (player != null && !player.hasPermission(r.getPermission())) {
User.getInstance(player).sendMessage("aoneblock.phase.insufficient-permission", TextVariables.NAME, String.valueOf(r.getPermission()));
yield true;
}
yield false;
}
};
if (b) blocked = true;
}
return false;
return blocked;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import java.util.jar.JarFile;
import java.util.stream.Collectors;

import dev.lone.itemsadder.api.CustomBlock;
import dev.lone.itemsadder.api.ItemsAdder;
import org.apache.commons.lang.math.NumberUtils;
import org.bukkit.Material;
import org.bukkit.block.Biome;
Expand All @@ -33,6 +31,8 @@
import com.google.common.base.Enums;
import com.google.common.io.Files;

import dev.lone.itemsadder.api.CustomBlock;
import dev.lone.itemsadder.api.ItemsAdder;
import world.bentobox.aoneblock.AOneBlock;
import world.bentobox.aoneblock.dataobjects.OneBlockIslands;
import world.bentobox.aoneblock.oneblocks.OneBlockObject.Rarity;
Expand Down Expand Up @@ -163,6 +163,13 @@ private void loadPhase(File phaseFile) throws IOException {
}
}

/**
* Load in the phase's init
* @param blockNumber string representation of this phase's block number
* @param obPhase OneBlockPhase
* @param phase configuration section being read
* @throws IOException if there's an error in the config file
*/
void initBlock(String blockNumber, OneBlockPhase obPhase, ConfigurationSection phase) throws IOException {
if (phase.contains(NAME, true)) {
if (obPhase.getPhaseName() != null) {
Expand Down Expand Up @@ -323,10 +330,18 @@ void addRequirements(OneBlockPhase obPhase, ConfigurationSection phase) {
if (!phase.isConfigurationSection(REQUIREMENTS)) {
return;
}
ConfigurationSection reqs = phase.getConfigurationSection(REQUIREMENTS);
for (ReqType key : Requirement.ReqType.values()) {
ConfigurationSection reqs = phase.getConfigurationSection(REQUIREMENTS);
if (reqs.contains(key.getKey())) {
reqList.add(new Requirement(key, reqs.get(key.getKey())));
Requirement r;
if (key.getClazz().equals(Double.class)) {
r = new Requirement(key, reqs.getDouble(key.getKey()));
} else if (key.getClazz().equals(Long.class)) {
r = new Requirement(key, reqs.getLong(key.getKey()));
} else {
r = new Requirement(key, reqs.getString(key.getKey()));
}
reqList.add(r);
}
}
obPhase.setRequirements(reqList);
Expand Down Expand Up @@ -415,8 +430,10 @@ void addBlocks(OneBlockPhase obPhase, ConfigurationSection phase) {
CustomBlock block = CustomBlock.getInstance(material);
if (block != null) {
addItemsAdderBlock(obPhase, material, Objects.toString(blocks.get(material)));
} else if (ItemsAdder.getAllItems().size() != 0){
addon.logError("Bad block material in " + obPhase.getPhaseName() + ": " + material);
} else if (ItemsAdder.getAllItems() != null){
if (ItemsAdder.getAllItems().size() != 0) {
addon.logError("Bad block material in " + obPhase.getPhaseName() + ": " + material);
}
}
} else {
addon.logError("Bad block material in " + obPhase.getPhaseName() + ": " + material);
Expand Down Expand Up @@ -783,6 +800,9 @@ public void getProbs(OneBlockPhase phase) {
}
}

/**
* Get all the probs for each phases and log to console
*/
public void getAllProbs() {
blockProbs.values().forEach(this::getProbs);
}
Expand Down
Loading

0 comments on commit 6260a3c

Please sign in to comment.