Skip to content

Commit 6260a3c

Browse files
authored
Merge pull request #335 from BentoBoxWorld/develop
Release 1.14.2
2 parents 1ca6a85 + 8ca6370 commit 6260a3c

File tree

10 files changed

+601
-133
lines changed

10 files changed

+601
-133
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

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

1616
<developers>
@@ -67,7 +67,7 @@
6767
<!-- Do not change unless you want different name for local builds. -->
6868
<build.number>-LOCAL</build.number>
6969
<!-- This allows to change between versions. -->
70-
<build.version>1.14.1</build.version>
70+
<build.version>1.14.2</build.version>
7171
<!-- SonarCloud -->
7272
<sonar.projectKey>BentoBoxWorld_AOneBlock</sonar.projectKey>
7373
<sonar.organization>bentobox-world</sonar.organization>
@@ -215,7 +215,7 @@
215215
<dependency>
216216
<groupId>com.github.LoneDev6</groupId>
217217
<artifactId>API-ItemsAdder</artifactId>
218-
<version>3.2.5</version>
218+
<version>3.5.0b</version>
219219
<scope>provided</scope>
220220
</dependency>
221221

src/main/java/world/bentobox/aoneblock/AOneBlock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class AOneBlock extends GameModeAddon {
4141

4242
private static final String NETHER = "_nether";
4343
private static final String THE_END = "_the_end";
44-
public static boolean hasItemsAdder = false;
44+
private boolean hasItemsAdder = false;
4545

4646
// Settings
4747
private Settings settings;

src/main/java/world/bentobox/aoneblock/commands/admin/AdminSanityCheck.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
import world.bentobox.bentobox.api.commands.CompositeCommand;
99
import world.bentobox.bentobox.api.user.User;
1010

11+
/**
12+
* Command to run a sanity check
13+
* @author tastybento
14+
*
15+
*/
1116
public class AdminSanityCheck extends CompositeCommand {
1217

1318
private AOneBlock addon;

src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -407,46 +407,46 @@ else if (player.getLocation().getBlock().equals(block.getRelative(BlockFace.UP))
407407
private void spawnBlock(@NonNull OneBlockObject nextBlock, @NonNull Block block) {
408408
if (nextBlock.isCustomBlock()) {
409409
nextBlock.getCustomBlock().setBlock(block);
410-
return;
411410
} else if (nextBlock.isItemsAdderBlock()) {
412411
//Get Custom Block from ItemsAdder and place it
413412
CustomBlock cBlock = CustomBlock.getInstance(nextBlock.getItemsAdderBlock());
414413
if (cBlock != null) {
414+
block.getLocation().getBlock().setType(Material.AIR);
415415
cBlock.place(block.getLocation());
416+
}
417+
} else {
418+
@NonNull
419+
Material type = nextBlock.getMaterial();
420+
// Place new block with no physics
421+
block.setType(type, false);
422+
// Fill the chest
423+
if (type.equals(Material.CHEST) && nextBlock.getChest() != null) {
424+
fillChest(nextBlock, block);
416425
return;
426+
} else if (Tag.LEAVES.isTagged(type)) {
427+
Leaves leaves = (Leaves) block.getState().getBlockData();
428+
leaves.setPersistent(true);
429+
block.setBlockData(leaves);
430+
} else if (block.getState() instanceof BrushableBlock bb) {
431+
LootTable lt = switch(bb.getBlock().getBiome()) {
432+
default -> {
433+
if (random.nextDouble() < 0.8) {
434+
yield LootTables.TRAIL_RUINS_ARCHAEOLOGY_COMMON.getLootTable();
435+
} else {
436+
// 20% rare
437+
yield LootTables.TRAIL_RUINS_ARCHAEOLOGY_RARE.getLootTable();
438+
}
439+
}
440+
case DESERT -> LootTables.DESERT_PYRAMID_ARCHAEOLOGY.getLootTable();
441+
case FROZEN_OCEAN -> LootTables.OCEAN_RUIN_COLD_ARCHAEOLOGY.getLootTable();
442+
case OCEAN -> LootTables.OCEAN_RUIN_COLD_ARCHAEOLOGY.getLootTable();
443+
case WARM_OCEAN -> LootTables.OCEAN_RUIN_WARM_ARCHAEOLOGY.getLootTable();
444+
};
445+
bb.setLootTable(lt);
446+
bb.update();
417447
}
418448
}
419449

420-
@NonNull
421-
Material type = nextBlock.getMaterial();
422-
// Place new block with no physics
423-
block.setType(type, false);
424-
// Fill the chest
425-
if (type.equals(Material.CHEST) && nextBlock.getChest() != null) {
426-
fillChest(nextBlock, block);
427-
return;
428-
} else if (Tag.LEAVES.isTagged(type)) {
429-
Leaves leaves = (Leaves) block.getState().getBlockData();
430-
leaves.setPersistent(true);
431-
block.setBlockData(leaves);
432-
} else if (block.getState() instanceof BrushableBlock bb) {
433-
LootTable lt = switch(bb.getBlock().getBiome()) {
434-
default -> {
435-
if (random.nextDouble() < 0.8) {
436-
yield LootTables.TRAIL_RUINS_ARCHAEOLOGY_COMMON.getLootTable();
437-
} else {
438-
// 20% rare
439-
yield LootTables.TRAIL_RUINS_ARCHAEOLOGY_RARE.getLootTable();
440-
}
441-
}
442-
case DESERT -> LootTables.DESERT_PYRAMID_ARCHAEOLOGY.getLootTable();
443-
case FROZEN_OCEAN -> LootTables.OCEAN_RUIN_COLD_ARCHAEOLOGY.getLootTable();
444-
case OCEAN -> LootTables.OCEAN_RUIN_COLD_ARCHAEOLOGY.getLootTable();
445-
case WARM_OCEAN -> LootTables.OCEAN_RUIN_WARM_ARCHAEOLOGY.getLootTable();
446-
};
447-
bb.setLootTable(lt);
448-
bb.update();
449-
}
450450
}
451451

452452
private void spawnEntity(@NonNull OneBlockObject nextBlock, @NonNull Block block) {

src/main/java/world/bentobox/aoneblock/listeners/CheckPhase.java

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -50,51 +50,48 @@ public CheckPhase(AOneBlock addon, BlockListener blockListener) {
5050
* @param i - island
5151
* @param phase - one block phase
5252
* @param world - world
53-
* @return true if the player can proceed to the next phase, false if not or if there is no next phase.
53+
* @return true if the player cannot proceed to the next phase.
5454
*/
5555
protected boolean phaseRequirementsFail(@Nullable Player player, @NonNull Island i, OneBlockPhase phase, @NonNull World world) {
5656
if (phase.getRequirements().isEmpty()) {
5757
return false;
5858
}
5959
// Check requirements
60+
boolean blocked = false;
6061
for (Requirement r : phase.getRequirements()) {
61-
switch (r.getType()) {
62-
case LEVEL:
63-
return addon.getAddonByName("Level").map(l -> {
64-
if (((Level) l).getIslandLevel(world, i.getOwner()) < r.getLevel()) {
65-
User.getInstance(player).sendMessage("aoneblock.phase.insufficient-level", TextVariables.NUMBER, String.valueOf(r.getLevel()));
66-
return true;
67-
}
68-
return false;
69-
}).orElse(false);
70-
case BANK:
71-
return addon.getAddonByName("Bank").map(l -> {
72-
if (((Bank) l).getBankManager().getBalance(i).getValue() < r.getBank()) {
73-
User.getInstance(player).sendMessage("aoneblock.phase.insufficient-bank-balance", TextVariables.NUMBER, String.valueOf(r.getBank()));
74-
return true;
75-
}
76-
return false;
77-
}).orElse(false);
78-
case ECO:
79-
return addon.getPlugin().getVault().map(l -> {
80-
if (l.getBalance(User.getInstance(player), world) < r.getEco()) {
81-
User.getInstance(player).sendMessage("aoneblock.phase.insufficient-funds", TextVariables.NUMBER, String.valueOf(r.getEco()));
82-
return true;
83-
}
84-
return false;
85-
}).orElse(false);
86-
case PERMISSION:
87-
if (player != null && !player.hasPermission(r.getPermission())) {
88-
User.getInstance(player).sendMessage("aoneblock.phase.insufficient-permission", TextVariables.NAME, String.valueOf(r.getPermission()));
62+
boolean b = switch (r.getType()) {
63+
case LEVEL -> addon.getAddonByName("Level").map(l -> {
64+
if (((Level) l).getIslandLevel(world, i.getOwner()) < r.getLevel()) {
65+
User.getInstance(player).sendMessage("aoneblock.phase.insufficient-level", TextVariables.NUMBER, String.valueOf(r.getLevel()));
8966
return true;
9067
}
9168
return false;
92-
default:
93-
break;
94-
69+
}).orElse(false);
70+
case BANK -> addon.getAddonByName("Bank").map(l -> {
71+
if (((Bank) l).getBankManager().getBalance(i).getValue() < r.getBank()) {
72+
User.getInstance(player).sendMessage("aoneblock.phase.insufficient-bank-balance", TextVariables.NUMBER, String.valueOf(r.getBank()));
73+
return true;
74+
}
75+
return false;
76+
}).orElse(false);
77+
case ECO -> addon.getPlugin().getVault().map(l -> {
78+
if (l.getBalance(User.getInstance(player), world) < r.getEco()) {
79+
User.getInstance(player).sendMessage("aoneblock.phase.insufficient-funds", TextVariables.NUMBER, String.valueOf(r.getEco()));
80+
return true;
81+
}
82+
return false;
83+
}).orElse(false);
84+
case PERMISSION -> {
85+
if (player != null && !player.hasPermission(r.getPermission())) {
86+
User.getInstance(player).sendMessage("aoneblock.phase.insufficient-permission", TextVariables.NAME, String.valueOf(r.getPermission()));
87+
yield true;
88+
}
89+
yield false;
9590
}
91+
};
92+
if (b) blocked = true;
9693
}
97-
return false;
94+
return blocked;
9895
}
9996

10097
/**

src/main/java/world/bentobox/aoneblock/oneblocks/OneBlocksManager.java

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
import java.util.jar.JarFile;
1919
import java.util.stream.Collectors;
2020

21-
import dev.lone.itemsadder.api.CustomBlock;
22-
import dev.lone.itemsadder.api.ItemsAdder;
2321
import org.apache.commons.lang.math.NumberUtils;
2422
import org.bukkit.Material;
2523
import org.bukkit.block.Biome;
@@ -33,6 +31,8 @@
3331
import com.google.common.base.Enums;
3432
import com.google.common.io.Files;
3533

34+
import dev.lone.itemsadder.api.CustomBlock;
35+
import dev.lone.itemsadder.api.ItemsAdder;
3636
import world.bentobox.aoneblock.AOneBlock;
3737
import world.bentobox.aoneblock.dataobjects.OneBlockIslands;
3838
import world.bentobox.aoneblock.oneblocks.OneBlockObject.Rarity;
@@ -163,6 +163,13 @@ private void loadPhase(File phaseFile) throws IOException {
163163
}
164164
}
165165

166+
/**
167+
* Load in the phase's init
168+
* @param blockNumber string representation of this phase's block number
169+
* @param obPhase OneBlockPhase
170+
* @param phase configuration section being read
171+
* @throws IOException if there's an error in the config file
172+
*/
166173
void initBlock(String blockNumber, OneBlockPhase obPhase, ConfigurationSection phase) throws IOException {
167174
if (phase.contains(NAME, true)) {
168175
if (obPhase.getPhaseName() != null) {
@@ -323,10 +330,18 @@ void addRequirements(OneBlockPhase obPhase, ConfigurationSection phase) {
323330
if (!phase.isConfigurationSection(REQUIREMENTS)) {
324331
return;
325332
}
333+
ConfigurationSection reqs = phase.getConfigurationSection(REQUIREMENTS);
326334
for (ReqType key : Requirement.ReqType.values()) {
327-
ConfigurationSection reqs = phase.getConfigurationSection(REQUIREMENTS);
328335
if (reqs.contains(key.getKey())) {
329-
reqList.add(new Requirement(key, reqs.get(key.getKey())));
336+
Requirement r;
337+
if (key.getClazz().equals(Double.class)) {
338+
r = new Requirement(key, reqs.getDouble(key.getKey()));
339+
} else if (key.getClazz().equals(Long.class)) {
340+
r = new Requirement(key, reqs.getLong(key.getKey()));
341+
} else {
342+
r = new Requirement(key, reqs.getString(key.getKey()));
343+
}
344+
reqList.add(r);
330345
}
331346
}
332347
obPhase.setRequirements(reqList);
@@ -415,8 +430,10 @@ void addBlocks(OneBlockPhase obPhase, ConfigurationSection phase) {
415430
CustomBlock block = CustomBlock.getInstance(material);
416431
if (block != null) {
417432
addItemsAdderBlock(obPhase, material, Objects.toString(blocks.get(material)));
418-
} else if (ItemsAdder.getAllItems().size() != 0){
419-
addon.logError("Bad block material in " + obPhase.getPhaseName() + ": " + material);
433+
} else if (ItemsAdder.getAllItems() != null){
434+
if (ItemsAdder.getAllItems().size() != 0) {
435+
addon.logError("Bad block material in " + obPhase.getPhaseName() + ": " + material);
436+
}
420437
}
421438
} else {
422439
addon.logError("Bad block material in " + obPhase.getPhaseName() + ": " + material);
@@ -783,6 +800,9 @@ public void getProbs(OneBlockPhase phase) {
783800
}
784801
}
785802

803+
/**
804+
* Get all the probs for each phases and log to console
805+
*/
786806
public void getAllProbs() {
787807
blockProbs.values().forEach(this::getProbs);
788808
}

0 commit comments

Comments
 (0)