From aac866630e974c7b07bb355aac9a16282a553284 Mon Sep 17 00:00:00 2001 From: BONNe Date: Sat, 28 May 2022 18:54:41 +0300 Subject: [PATCH 01/43] Fix random block issues (#261) * Possible solution for incorrect random value calculation. To get next block it calculated random value 2 times. This increases a chance for a rare block to spawn. Also, this change separates block and chest randomness, just to avoid influencing block spawning chances. * The arraylist is not suited for constantly removing first element and adding one at the end. The Queue is exactly that does it. And linked list just works in this case better. --- .../dataobjects/OneBlockIslands.java | 12 +++++----- .../aoneblock/oneblocks/OneBlockPhase.java | 23 +++++++++++++------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/main/java/world/bentobox/aoneblock/dataobjects/OneBlockIslands.java b/src/main/java/world/bentobox/aoneblock/dataobjects/OneBlockIslands.java index c57fea70..2f751745 100644 --- a/src/main/java/world/bentobox/aoneblock/dataobjects/OneBlockIslands.java +++ b/src/main/java/world/bentobox/aoneblock/dataobjects/OneBlockIslands.java @@ -1,7 +1,8 @@ package world.bentobox.aoneblock.dataobjects; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; +import java.util.Queue; import org.bukkit.entity.EntityType; import org.eclipse.jdt.annotation.NonNull; @@ -41,7 +42,7 @@ public class OneBlockIslands implements DataObject { @Expose private String hologram = ""; - private List queue = new ArrayList<>(); + private Queue queue = new LinkedList<>(); /** * @return the phaseName @@ -121,8 +122,8 @@ public void setUniqueId(String uniqueId) { /** * @return the queue */ - public List getQueue() { - if (queue == null) queue = new ArrayList<>(); + public Queue getQueue() { + if (queue == null) queue = new LinkedList<>(); return queue; } @@ -141,8 +142,7 @@ public void add(OneBlockObject nextBlock) { public OneBlockObject pollAndAdd(OneBlockObject toAdd) { getQueue(); - OneBlockObject b = queue.get(0); - queue.remove(0); + OneBlockObject b = queue.poll(); queue.add(toAdd); return b; } diff --git a/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockPhase.java b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockPhase.java index 30552dc2..3048fd09 100644 --- a/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockPhase.java +++ b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockPhase.java @@ -46,7 +46,8 @@ public class OneBlockPhase { private OneBlockObject firstBlock; private ItemStack iconBlock; private final Map> chests = new EnumMap<>(Rarity.class); - private final Random random = new Random(); + private final Random blockRandom; + private final Random chestRandom; private final String blockNumber; private Integer gotoBlock; private int blockTotal = 0; @@ -70,6 +71,11 @@ public OneBlockPhase(String blockNumber) { requirements = new ArrayList<>(); fixedBlocks = new HashMap<>(); holograms = new HashMap<>(); + + // Separate chest and block random. + // May be expose random to users? + blockRandom = new Random(); + chestRandom = new Random(); } /** @@ -195,28 +201,31 @@ private OneBlockObject getResult(OneBlockObject block) { private OneBlockObject getRandomChest() { // Get the right type of chest - Rarity r = CHEST_CHANCES.getOrDefault(((TreeMap) CHEST_CHANCES).ceilingKey(random.nextDouble()), + Rarity r = CHEST_CHANCES.getOrDefault(((TreeMap) CHEST_CHANCES).ceilingKey(this.chestRandom.nextDouble()), Rarity.COMMON); // If the chest lists have no common fallback, then return empty chest - if (!chests.containsKey(r) && !chests.containsKey(Rarity.COMMON)) { + if (!this.chests.containsKey(r) && !this.chests.containsKey(Rarity.COMMON)) { return new OneBlockObject(Material.CHEST, 0); } // Get the rare chest or worse case the common one - List list = chests.containsKey(r) ? chests.get(r) : chests.get(Rarity.COMMON); + List list = this.chests.containsKey(r) ? this.chests.get(r) : this.chests.get(Rarity.COMMON); // Pick one from the list or return an empty chest. Note list.get() can return // nothing - return list.isEmpty() ? new OneBlockObject(Material.CHEST, 0) : list.get(random.nextInt(list.size())); + return list.isEmpty() ? new OneBlockObject(Material.CHEST, 0) : list.get(this.chestRandom.nextInt(list.size())); } private OneBlockObject getRandomBlock(TreeMap probMap2, int total2) { // Use +1 on the bound because the random choice is exclusive - OneBlockObject temp = probMap2.get(random.nextInt(total2 + 1)); + int randomValue = this.blockRandom.nextInt(total2 + 1); + + OneBlockObject temp = probMap2.get(randomValue); if (temp == null) { - temp = probMap2.ceilingEntry(random.nextInt(total2 + 1)).getValue(); + temp = probMap2.ceilingEntry(randomValue).getValue(); } if (temp == null) { temp = probMap2.firstEntry().getValue(); } + return new OneBlockObject(temp); } From d36825db92063bd1c4226f2eebe82c8658232206 Mon Sep 17 00:00:00 2001 From: BONNe Date: Sun, 26 Jun 2022 13:19:26 +0300 Subject: [PATCH 02/43] Do not replace water with water. This will replace with water-only blocks that are not water, similar to the water-logged blocks. People complained that flowing water was not accepted as a valid block for water animals. Fixes #265 --- .../java/world/bentobox/aoneblock/listeners/BlockListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java b/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java index 0a93a1d0..de53f022 100644 --- a/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java +++ b/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java @@ -768,7 +768,7 @@ private void checkBlock(Block block, waterBlocks.add(block); } } - else + else if (block.getType() != Material.WATER) { // Well, unfortunately block must go. waterBlocks.add(block); From ff37c6a3d53afabb9049aece116ca4a73fd5529a Mon Sep 17 00:00:00 2001 From: Oh hi Mark! <61845375+MrMarL@users.noreply.github.com> Date: Sat, 20 Aug 2022 13:21:38 +0300 Subject: [PATCH 03/43] 62.5% and 75% had identical filling of the scale. I fixed it now everything should be right. (#277) --- .../bentobox/aoneblock/PlaceholdersManager.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/world/bentobox/aoneblock/PlaceholdersManager.java b/src/main/java/world/bentobox/aoneblock/PlaceholdersManager.java index d463980a..5ea6dfa1 100644 --- a/src/main/java/world/bentobox/aoneblock/PlaceholdersManager.java +++ b/src/main/java/world/bentobox/aoneblock/PlaceholdersManager.java @@ -12,14 +12,14 @@ public class PlaceholdersManager { private static final TreeMap SCALE; static { SCALE = new TreeMap<>(); - SCALE.put(0D, "&c╍╍╍╍╍╍╍╍"); - SCALE.put(12.5, "&a╍&c╍╍╍╍╍╍╍"); - SCALE.put(25.0, "&a╍╍&c╍╍╍╍╍╍"); - SCALE.put(37.5, "&a╍╍╍&c╍╍╍╍╍"); - SCALE.put(50D, "&a╍╍╍╍&c╍╍╍╍"); + SCALE.put(0D, "&c╍╍╍╍╍╍╍╍"); + SCALE.put(12.5, "&a╍&c╍╍╍╍╍╍╍"); + SCALE.put(25.0, "&a╍╍&c╍╍╍╍╍╍"); + SCALE.put(37.5, "&a╍╍╍&c╍╍╍╍╍"); + SCALE.put(50D, "&a╍╍╍╍&c╍╍╍╍"); SCALE.put(62.5, "&a╍╍╍╍╍&c╍╍╍"); - SCALE.put(75.0, "&a╍╍╍╍╍&c╍╍╍"); - SCALE.put(87.5, "&a╍╍╍╍╍╍╍&c╍"); + SCALE.put(75.0, "&a╍╍╍╍╍╍&c╍╍"); + SCALE.put(87.5, "&a╍╍╍╍╍╍╍&c╍"); SCALE.put(100D, "&a╍╍╍╍╍╍╍╍"); } From 93ee416dea481779a44561c8d75113ee0fe7cd83 Mon Sep 17 00:00:00 2001 From: Marmur2020 <109208530+Marmur2020@users.noreply.github.com> Date: Thu, 8 Sep 2022 21:31:47 +0300 Subject: [PATCH 04/43] ADDED WARDEN SOUND(EVENT mob-warning) (#281) I added a line that produces the sound of the WARDEN spawn and also the color combination of it --- .../java/world/bentobox/aoneblock/listeners/BlockListener.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java b/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java index de53f022..6984245a 100644 --- a/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java +++ b/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java @@ -155,6 +155,7 @@ public class BlockListener implements Listener { m.put(EntityType.VINDICATOR, new MobAspects(Sound.ENTITY_VINDICATOR_AMBIENT, Color.fromRGB(137, 156, 166))); m.put(EntityType.WITCH, new MobAspects(Sound.ENTITY_WITCH_AMBIENT, Color.fromRGB(56, 39, 67))); m.put(EntityType.WITHER, new MobAspects(Sound.ENTITY_WITHER_AMBIENT, Color.fromRGB(80, 80, 80))); + m.put(EntityType.WARDEN, new MobAspects(Sound.ENTITY_WARDEN_AMBIENT, Color.fromRGB(6, 72, 86))); //ADDED WARDEN SOUND m.put(EntityType.WITHER_SKELETON, new MobAspects(Sound.ENTITY_WITHER_SKELETON_AMBIENT, Color.fromRGB(100, 100, 100))); m.put(EntityType.ZOGLIN, new MobAspects(Sound.ENTITY_ZOGLIN_AMBIENT, Color.fromRGB(255, 192, 203))); m.put(EntityType.ZOMBIE, new MobAspects(Sound.ENTITY_ZOMBIE_AMBIENT, Color.fromRGB(74, 99, 53))); From 1d2509b05f7d00fe96d79e720f1b6738633654d4 Mon Sep 17 00:00:00 2001 From: BONNe Date: Thu, 8 Sep 2022 21:37:43 +0300 Subject: [PATCH 05/43] Update to Spigot 1.19 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 4095840b..f088a7b3 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ 2.0.9 - 1.18-R0.1-SNAPSHOT + 1.19-R0.1-SNAPSHOT 1.20.0 2.6.2 1.3.0 @@ -389,4 +389,4 @@ - \ No newline at end of file + From 651941ddcea9a4d55f591aee184f5080ed0f3dfe Mon Sep 17 00:00:00 2001 From: Huynh Tien Date: Thu, 29 Sep 2022 22:29:53 +0700 Subject: [PATCH 06/43] Custom Block support (#283) * setCustomBlock * Config & OneBlockCustomBlockCreator * revert reformat * just custom-blocks * use Blocks with new approach * simply return instead of default value --- .../aoneblock/listeners/BlockListener.java | 5 ++ .../oneblocks/OneBlockCustomBlock.java | 17 +++++ .../oneblocks/OneBlockCustomBlockCreator.java | 50 +++++++++++++ .../aoneblock/oneblocks/OneBlockObject.java | 30 +++++++- .../aoneblock/oneblocks/OneBlockPhase.java | 12 +++ .../aoneblock/oneblocks/OneBlocksManager.java | 73 +++++++++++++++---- .../customblock/BlockDataCustomBlock.java | 40 ++++++++++ 7 files changed, 210 insertions(+), 17 deletions(-) create mode 100644 src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockCustomBlock.java create mode 100644 src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockCustomBlockCreator.java create mode 100644 src/main/java/world/bentobox/aoneblock/oneblocks/customblock/BlockDataCustomBlock.java diff --git a/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java b/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java index 6984245a..13480bab 100644 --- a/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java +++ b/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java @@ -600,6 +600,11 @@ 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; + } + @NonNull Material type = nextBlock.getMaterial(); // Place new block with no physics diff --git a/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockCustomBlock.java b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockCustomBlock.java new file mode 100644 index 00000000..40560508 --- /dev/null +++ b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockCustomBlock.java @@ -0,0 +1,17 @@ +package world.bentobox.aoneblock.oneblocks; + +import org.bukkit.block.Block; + +/** + * Represents a custom block + * + * @author HSGamer + */ +public interface OneBlockCustomBlock { + /** + * Set the block + * + * @param block the block + */ + void setBlock(Block block); +} diff --git a/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockCustomBlockCreator.java b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockCustomBlockCreator.java new file mode 100644 index 00000000..b14fae97 --- /dev/null +++ b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockCustomBlockCreator.java @@ -0,0 +1,50 @@ +package world.bentobox.aoneblock.oneblocks; + +import world.bentobox.aoneblock.oneblocks.customblock.BlockDataCustomBlock; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Function; + +/** + * A creator for {@link OneBlockCustomBlock} + * + * @author HSGamer + */ +public final class OneBlockCustomBlockCreator { + private static final Map, Optional>> creatorMap = new LinkedHashMap<>(); + + static { + register("block-data", BlockDataCustomBlock::fromMap); + } + + private OneBlockCustomBlockCreator() { + // EMPTY + } + + /** + * Register a creator + * + * @param type the type + * @param creator the creator + */ + public static void register(String type, Function, Optional> creator) { + creatorMap.put(type, creator); + } + + /** + * Create a custom block from the map + * + * @param map the map + * @return the custom block + */ + public static Optional create(Map map) { + String type = Objects.toString(map.get("type"), null); + if (type == null) { + return Optional.empty(); + } + return Optional.ofNullable(creatorMap.get(type)).flatMap(builder -> builder.apply(map)); + } +} diff --git a/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockObject.java b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockObject.java index 50c21c3d..0710d337 100644 --- a/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockObject.java +++ b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockObject.java @@ -41,6 +41,7 @@ public enum Rarity { private Material material; private Map chest; private Rarity rarity; + private OneBlockCustomBlock customBlock; private int prob; /** @@ -63,7 +64,17 @@ public OneBlockObject(EntityType entityType, int prob) { public OneBlockObject(Material material, int prob) { this.material = material; this.prob = prob; + } + /** + * A custom block + * + * @param customBlock - custom block + * @param prob - relative probability + */ + public OneBlockObject(OneBlockCustomBlock customBlock, int prob) { + this.customBlock = customBlock; + this.prob = prob; } @@ -76,7 +87,6 @@ public OneBlockObject(Map chest, Rarity rarity) { this.material = Material.CHEST; this.chest = chest; this.setRarity(rarity); - } /** @@ -90,6 +100,7 @@ public OneBlockObject(OneBlockObject ob) { this.material = ob.getMaterial(); this.rarity = ob.getRarity(); this.prob = ob.getProb(); + this.customBlock = ob.getCustomBlock(); } /** @@ -116,6 +127,14 @@ public Map getChest() { } + /** + * @return the customBlock + */ + public OneBlockCustomBlock getCustomBlock() { + return customBlock; + } + + /** * @return the isMaterial */ @@ -131,6 +150,14 @@ public boolean isEntity() { return entityType != null; } + + /** + * @return the isCustomBlock + */ + public boolean isCustomBlock() { + return customBlock != null; + } + /** * @return the rarity */ @@ -167,6 +194,7 @@ public String toString() { return "OneBlockObject [" + (entityType != null ? "entityType=" + entityType + ", " : "") + (material != null ? "material=" + material + ", " : "") + (chest != null ? "chest=" + chest + ", " : "") + (rarity != null ? "rarity=" + rarity + ", " : "") + + (customBlock != null ? "customBlock=" + customBlock + ", " : "") + "prob=" + prob + "]"; } diff --git a/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockPhase.java b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockPhase.java index 3048fd09..e3792c8a 100644 --- a/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockPhase.java +++ b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockPhase.java @@ -151,6 +151,18 @@ public void addBlock(Material material, int prob) { probMap.put(total, new OneBlockObject(material, prob)); } + /** + * Adds a custom block and associated probability + * + * @param customBlock - custom block + * @param prob - probability + */ + public void addCustomBlock(OneBlockCustomBlock customBlock, int prob) { + total += prob; + blockTotal += prob; + probMap.put(total, new OneBlockObject(customBlock, prob)); + } + /** * Adds an entity type and associated probability * diff --git a/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlocksManager.java b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlocksManager.java index 8aa33828..f25c8ef1 100644 --- a/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlocksManager.java +++ b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlocksManager.java @@ -209,13 +209,23 @@ private void addFixedBlocks(OneBlockPhase obPhase, ConfigurationSection fb) { continue; } int k = Integer.parseInt(key); - String mat = fb.getString(key); - if (mat != null) { - Material m = Material.matchMaterial(mat); - if (m != null && m.isBlock()) { - result.put(k, new OneBlockObject(m, 0)); + if (fb.isConfigurationSection(key)) { + Map map = fb.getConfigurationSection(key).getValues(false); + Optional customBlock = OneBlockCustomBlockCreator.create(map); + if (customBlock.isPresent()) { + result.put(k, new OneBlockObject(customBlock.get(), 0)); } else { - addon.logError("Fixed block key " + key + " material is invalid or not a block. Ignoring."); + addon.logError("Fixed block key " + key + " material is not a valid custom block. Ignoring."); + } + } else { + String mat = fb.getString(key); + if (mat != null) { + Material m = Material.matchMaterial(mat); + if (m != null && m.isBlock()) { + result.put(k, new OneBlockObject(m, 0)); + } else { + addon.logError("Fixed block key " + key + " material is invalid or not a block. Ignoring."); + } } } } @@ -375,19 +385,50 @@ void addBlocks(OneBlockPhase obPhase, ConfigurationSection phase) { if (!phase.isConfigurationSection(BLOCKS)) { return; } - ConfigurationSection blocks = phase.getConfigurationSection(BLOCKS); - for (String material : blocks.getKeys(false)) { - Material m = Material.matchMaterial(material); - int probability = blocks.getInt(material); + if (phase.isConfigurationSection(BLOCKS)) { + ConfigurationSection blocks = phase.getConfigurationSection(BLOCKS); + for (String material : blocks.getKeys(false)) { + addMaterial(obPhase, material, Objects.toString(blocks.get(material))); + } + } else if (phase.isList(BLOCKS)) { + List> blocks = phase.getMapList(BLOCKS); + for (Map map : blocks) { + if (map.size() == 1) { + Map.Entry entry = map.entrySet().iterator().next(); + if (addMaterial(obPhase, Objects.toString(entry.getKey()), Objects.toString(entry.getValue()))) { + continue; + } + } - if (m == null || !m.isBlock()) { - addon.logError("Bad block material in " + obPhase.getPhaseName() + ": " + material); - } else if (probability < 1) { - addon.logWarning("Bad item weight for " + obPhase.getPhaseName() + ": " + material + ". Must be positive number above 1."); - } else { - obPhase.addBlock(m, probability); + int probability = Integer.parseInt(Objects.toString(map.get("probability"), "0")); + Optional customBlock = OneBlockCustomBlockCreator.create(map); + if (customBlock.isPresent()) { + obPhase.addCustomBlock(customBlock.get(), probability); + } else { + addon.logError("Bad custom block in " + obPhase.getPhaseName() + ": " + map); + } } + } + } + private boolean addMaterial(OneBlockPhase obPhase, String material, String probability) { + Material m = Material.matchMaterial(material); + int prob; + try { + prob = Integer.parseInt(probability); + } catch (Exception e) { + return false; + } + + if (m == null || !m.isBlock()) { + addon.logError("Bad block material in " + obPhase.getPhaseName() + ": " + material); + return false; + } else if (prob < 1) { + addon.logWarning("Bad item weight for " + obPhase.getPhaseName() + ": " + material + ". Must be positive number above 1."); + return false; + } else { + obPhase.addBlock(m, prob); + return true; } } diff --git a/src/main/java/world/bentobox/aoneblock/oneblocks/customblock/BlockDataCustomBlock.java b/src/main/java/world/bentobox/aoneblock/oneblocks/customblock/BlockDataCustomBlock.java new file mode 100644 index 00000000..939e8a42 --- /dev/null +++ b/src/main/java/world/bentobox/aoneblock/oneblocks/customblock/BlockDataCustomBlock.java @@ -0,0 +1,40 @@ +package world.bentobox.aoneblock.oneblocks.customblock; + +import org.bukkit.Bukkit; +import org.bukkit.block.Block; +import world.bentobox.aoneblock.oneblocks.OneBlockCustomBlock; +import world.bentobox.bentobox.BentoBox; + +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * A custom block that is defined by a block data value. + * + * @author HSGamer + */ +public class BlockDataCustomBlock implements OneBlockCustomBlock { + private final String blockData; + + public BlockDataCustomBlock(String blockData) { + this.blockData = blockData; + } + + public static Optional fromMap(Map map) { + if (map.containsKey("data")) { + return Optional.of(new BlockDataCustomBlock(Objects.toString(map.get("data")))); + } else { + return Optional.empty(); + } + } + + @Override + public void setBlock(Block block) { + try { + block.setBlockData(Bukkit.createBlockData(blockData)); + } catch (IllegalArgumentException e) { + BentoBox.getInstance().logError("Could not set block data " + blockData + " for block " + block.getType()); + } + } +} From 8ff4504fa78953b2244c06f6c7857f6b0a9392c3 Mon Sep 17 00:00:00 2001 From: BONNe Date: Tue, 4 Oct 2022 13:07:35 +0300 Subject: [PATCH 07/43] Migrate to BentoBox API 1.21 This migration allows to define any custom flag names for default settings. If the flag does not exist, it will just ignore it and not remove. --- pom.xml | 2 +- .../world/bentobox/aoneblock/Settings.java | 84 ++++++++++++++----- src/main/resources/addon.yml | 5 +- 3 files changed, 69 insertions(+), 22 deletions(-) diff --git a/pom.xml b/pom.xml index f088a7b3..b9b71e64 100644 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,7 @@ 2.0.9 1.19-R0.1-SNAPSHOT - 1.20.0 + 1.21.0 2.6.2 1.3.0 diff --git a/src/main/java/world/bentobox/aoneblock/Settings.java b/src/main/java/world/bentobox/aoneblock/Settings.java index 178bd715..1f5eeb60 100644 --- a/src/main/java/world/bentobox/aoneblock/Settings.java +++ b/src/main/java/world/bentobox/aoneblock/Settings.java @@ -1,11 +1,6 @@ package world.bentobox.aoneblock; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import org.bukkit.Difficulty; import org.bukkit.GameMode; @@ -13,6 +8,7 @@ import org.bukkit.entity.EntityType; import com.google.common.base.Enums; +import com.google.gson.annotations.JsonAdapter; import world.bentobox.aoneblock.listeners.BlockListener; import world.bentobox.bentobox.api.configuration.ConfigComment; @@ -21,8 +17,7 @@ import world.bentobox.bentobox.api.configuration.WorldSettings; import world.bentobox.bentobox.api.flags.Flag; import world.bentobox.bentobox.database.objects.adapters.Adapter; -import world.bentobox.bentobox.database.objects.adapters.FlagSerializer; -import world.bentobox.bentobox.database.objects.adapters.FlagSerializer2; +import world.bentobox.bentobox.database.objects.adapters.FlagBooleanSerializer; /** @@ -256,13 +251,12 @@ public class Settings implements WorldSettings { @ConfigComment(" SUB-OWNER = 900") @ConfigComment(" OWNER = 1000") @ConfigEntry(path = "world.default-island-flags") - @Adapter(FlagSerializer.class) - private Map defaultIslandFlags = new HashMap<>(); + private Map defaultIslandFlagNames = new HashMap<>(); @ConfigComment("These are the default settings for new islands") @ConfigEntry(path = "world.default-island-settings") - @Adapter(FlagSerializer2.class) - private Map defaultIslandSettings = new HashMap<>(); + @Adapter(FlagBooleanSerializer.class) + private Map defaultIslandSettingNames = new HashMap<>(); @ConfigComment("These settings/flags are hidden from users") @ConfigComment("Ops can toggle hiding in-game using SHIFT-LEFT-CLICK on flags in settings") @@ -728,20 +722,47 @@ public Map getWorldFlags() { return worldFlags; } + + /** + * @return the defaultIslandFlags + * @since 1.21.0 + */ + @Override + public Map getDefaultIslandFlagNames() + { + return defaultIslandFlagNames; + } + + + /** + * @return the defaultIslandSettings + * @since 1.21.0 + */ + @Override + public Map getDefaultIslandSettingNames() + { + return defaultIslandSettingNames; + } + + /** * @return the defaultIslandFlags + * @deprecated since 1.21 Replaced with #getDefaultIslandFlagNames */ @Override + @Deprecated public Map getDefaultIslandFlags() { - return defaultIslandFlags; + return Collections.emptyMap(); } /** * @return the defaultIslandSettings + * @deprecated since 1.21 Replaced with #getDefaultIslandSettingNames */ @Override + @Deprecated public Map getDefaultIslandSettings() { - return defaultIslandSettings; + return Collections.emptyMap(); } /** @@ -1128,19 +1149,42 @@ public void setWorldFlags(Map worldFlags) { this.worldFlags = worldFlags; } + + /** + * Sets default island flag names. + * + * @param defaultIslandFlagNames the default island flag names + */ + public void setDefaultIslandFlagNames(Map defaultIslandFlagNames) + { + this.defaultIslandFlagNames = defaultIslandFlagNames; + } + + /** - * @param defaultIslandFlags the defaultIslandFlags to set + * Sets default island setting names. + * + * @param defaultIslandSettingNames the default island setting names */ - public void setDefaultIslandFlags(Map defaultIslandFlags) { - this.defaultIslandFlags = defaultIslandFlags; + public void setDefaultIslandSettingNames(Map defaultIslandSettingNames) + { + this.defaultIslandSettingNames = defaultIslandSettingNames; } + + /** + * @param defaultIslandFlags the defaultIslandFlags to set + * @deprecated since 1.21 + */ + public void setDefaultIslandFlags(Map defaultIslandFlags) {} + + /** * @param defaultIslandSettings the defaultIslandSettings to set + * @deprecated since 1.21 */ - public void setDefaultIslandSettings(Map defaultIslandSettings) { - this.defaultIslandSettings = defaultIslandSettings; - } + public void setDefaultIslandSettings(Map defaultIslandSettings) {} + /** * @param hiddenFlags the hidden flags to set diff --git a/src/main/resources/addon.yml b/src/main/resources/addon.yml index 778bdf72..ea2a8c9e 100755 --- a/src/main/resources/addon.yml +++ b/src/main/resources/addon.yml @@ -125,7 +125,10 @@ permissions: default: op aoneblock.mod.bypassban: description: Bypasses island ban - default: op + default: op + aoneblock.mod.resetname: + description: Allows to reset island name + default: op aoneblock.mod.team: description: Enables modification of teams via kick and add commands default: false From 16566d7ff0791e290b8cf45ca987471a6300197a Mon Sep 17 00:00:00 2001 From: BONNe Date: Tue, 4 Oct 2022 13:07:46 +0300 Subject: [PATCH 08/43] Remove unused methods. --- .../commands/IslandPhasesCommand.java | 0 .../commands/IslandSetCountCommand.java | 77 ------------------- .../aoneblock/commands/PlayerCommand.java | 0 3 files changed, 77 deletions(-) delete mode 100644 src/main/java/world/bentobox/aoneblock/commands/IslandPhasesCommand.java delete mode 100644 src/main/java/world/bentobox/aoneblock/commands/IslandSetCountCommand.java delete mode 100644 src/main/java/world/bentobox/aoneblock/commands/PlayerCommand.java diff --git a/src/main/java/world/bentobox/aoneblock/commands/IslandPhasesCommand.java b/src/main/java/world/bentobox/aoneblock/commands/IslandPhasesCommand.java deleted file mode 100644 index e69de29b..00000000 diff --git a/src/main/java/world/bentobox/aoneblock/commands/IslandSetCountCommand.java b/src/main/java/world/bentobox/aoneblock/commands/IslandSetCountCommand.java deleted file mode 100644 index 449619bb..00000000 --- a/src/main/java/world/bentobox/aoneblock/commands/IslandSetCountCommand.java +++ /dev/null @@ -1,77 +0,0 @@ -package world.bentobox.aoneblock.commands; - -import java.util.List; - -import org.eclipse.jdt.annotation.NonNull; - -import world.bentobox.aoneblock.AOneBlock; -import world.bentobox.aoneblock.dataobjects.OneBlockIslands; -import world.bentobox.bentobox.api.commands.CompositeCommand; -import world.bentobox.bentobox.api.localization.TextVariables; -import world.bentobox.bentobox.api.user.User; -import world.bentobox.bentobox.database.objects.Island; -import world.bentobox.bentobox.util.Util; - -/** - * Enables a player to set their count to anything less than they - * have done so far. - * @author tastybento - * - */ -public class IslandSetCountCommand extends CompositeCommand { - - private AOneBlock addon; - - public IslandSetCountCommand(CompositeCommand islandCommand) { - super(islandCommand, "setcount"); - } - - @Override - public void setup() { - setOnlyPlayer(true); - setParametersHelp("aoneblock.commands.island.setcount.parameters"); - setDescription("aoneblock.commands.island.setcount.description"); - // Permission - setPermission("island.setcount"); - addon = getAddon(); - } - - @Override - public boolean execute(User user, String label, List args) { - if (args.size() != 1) { - showHelp(this, user); - return false; - } - // Get their island - Island island = getIslands().getIsland(getWorld(), user); - if (island == null) { - user.sendMessage("general.errors.no-island"); - return false; - } - // Check ownership - if (!getIslands().hasIsland(getWorld(), user)) { - user.sendMessage("general.errors.not-owner"); - return false; - } - // Get value - // Get new range - if (!Util.isInteger(args.get(0), true) || Integer.parseInt(args.get(0)) < 0) { - user.sendMessage("general.errors.must-be-positive-number", TextVariables.NUMBER, args.get(0)); - return false; - } - int count = Integer.parseInt(args.get(0)); - // Check the value is lower than played so far - @NonNull - OneBlockIslands i = addon.getBlockListener().getIsland(island); - long maxCount = i.getLifetime(); - if (count > maxCount) { - user.sendMessage("aoneblock.commands.island.setcount.too-high", TextVariables.NUMBER, String.valueOf(maxCount)); - return false; - } - i.setBlockNumber(count); - i.clearQueue(); - user.sendMessage("aoneblock.commands.island.setcount.set", TextVariables.NUMBER, String.valueOf(i.getBlockNumber())); - return true; - } - -} diff --git a/src/main/java/world/bentobox/aoneblock/commands/PlayerCommand.java b/src/main/java/world/bentobox/aoneblock/commands/PlayerCommand.java deleted file mode 100644 index e69de29b..00000000 From 0199d9cdafaf2f9ebdbc163ad87f5a3817bb44f6 Mon Sep 17 00:00:00 2001 From: BONNe Date: Tue, 4 Oct 2022 13:18:16 +0300 Subject: [PATCH 09/43] Fixes #276 and #278 --- .../java/world/bentobox/aoneblock/listeners/BlockListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java b/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java index 13480bab..f702e553 100644 --- a/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java +++ b/src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java @@ -340,7 +340,7 @@ private void process(@NonNull Cancellable e, @NonNull Island i, @Nullable Player int gotoBlock = phase.getGotoBlock(); phase = oneBlocksManager.getPhase(gotoBlock); // Store lifetime - is.setLifetime(is.getLifetime() + is.getBlockNumber()); + is.setLifetime(is.getLifetime() + gotoBlock); // Set current block is.setBlockNumber(gotoBlock); From 5dad78963258e5f25566f7e9da28f617b384bfc9 Mon Sep 17 00:00:00 2001 From: BONNe Date: Tue, 4 Oct 2022 13:49:01 +0300 Subject: [PATCH 10/43] Initialize 1.12.0 version --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b9b71e64..32fc18b0 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ UTF-8 UTF-8 - 16 + 17 2.0.9 @@ -67,7 +67,7 @@ -LOCAL - 1.11.0 + 1.12.0 BentoBoxWorld_AOneBlock bentobox-world From 6dd4ec0941dae80ba4863e2b4c8bb764e7c6e528 Mon Sep 17 00:00:00 2001 From: BONNe Date: Tue, 4 Oct 2022 13:54:14 +0300 Subject: [PATCH 11/43] Update build.yml --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b9cf60cc..4b8156be 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,10 +14,10 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Set up JDK 16 + - name: Set up JDK 17 uses: actions/setup-java@v1 with: - java-version: 16 + java-version: 17 - name: Cache SonarCloud packages uses: actions/cache@v1 with: @@ -34,4 +34,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \ No newline at end of file + run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar From 8985a830611456739c32a0d34b84c8aa4243205b Mon Sep 17 00:00:00 2001 From: "gitlocalize-app[bot]" <55277160+gitlocalize-app[bot]@users.noreply.github.com> Date: Mon, 31 Oct 2022 08:27:01 +0200 Subject: [PATCH 12/43] Translate ru.yml via GitLocalize (#290) Co-authored-by: Marmur2020 --- src/main/resources/locales/ru.yml | 61 ++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/src/main/resources/locales/ru.yml b/src/main/resources/locales/ru.yml index 60bd7090..b6ce370f 100644 --- a/src/main/resources/locales/ru.yml +++ b/src/main/resources/locales/ru.yml @@ -3,9 +3,10 @@ aoneblock: commands: admin: setcount: - parameters: "<имя> <кол-во>" + parameters: " [lifetime]" description: установить количество блоков игрока set: "&a [name] кол-во блоков установлено на [number]" + set-lifetime: "&a Счетчик жизни [name] установлен на [number]" setchest: parameters: " " description: положить проверенный сундук в фазу с указанной редкостью @@ -31,7 +32,57 @@ aoneblock: name-syntax: "&a [name]" description-syntax: "&b [number] блоков" island: - setcount: {} - phase: {} - placeholders: {} - island: {} + setcount: + parameters: "" + description: установить счетчик блоков на ранее завершенное значение + set: "&a Счетчик установлен на [number]." + too-high: "&c Максимум, что вы можете установить, это [number]!" + respawn-block: + description: возрождает магический блок в ситуациях, когда они исчезают + block-exist: "&a Блок существует, не требует возрождения. Я отметил это для + вас." + block-respawned: "& Блок возродился, пожалуйста, не аннулируйте его снова." + phase: + insufficient-level: "&c Уровень вашего острова слишком низок для продолжения! + Должно быть [number]." + insufficient-funds: "&c У вас слишком мало средств для продолжения! Они должны + быть [number]." + insufficient-bank-balance: "&c Баланс банка острова слишком низок для продолжения! + Должно быть [number]." + insufficient-permission: "&c Вы не можете продолжать, пока не получите разрешение + [name]!" + placeholders: + infinite: Бесконечный + gui: + titles: + phases: "&0&l Фазы OneBlock" + buttons: + previous: + name: "&f&l Предыдущая страница" + description: "&7 Перейти на [number] страницы" + next: + name: "&f&l Следующая страница" + description: "&7 Перейти на [number] страницы" + phase: + name: "&f&l [phase]" + description: |- + [starting-block] + [biome] + [bank] + [economy] + [level] + [permission] + starting-block: "&7 Запускается после разбиения блоков &e [number]." + biome: "&7 Биом: &e [biome]" + bank: "&7 Требуется &e $[number] &7 на банковском счете." + economy: "&7 Требуется &e $[number] &7 в учетной записи игрока." + level: "&7 Требуется &e [number] &7 уровня острова." + permission: "&7 Требуется разрешение `&e[permission]&7`." + tips: + click-to-previous: "&e Нажмите &7, чтобы просмотреть предыдущую страницу." + click-to-next: "&e Нажмите &7 для просмотра следующей страницы." + click-to-change: "&e Нажмите &7, чтобы изменить." + island: + starting-hologram: |- + &aДобро пожаловать в AOneBlock + &eРазбейте этот блок, чтобы начать From ecbce2320a9149ef46ef40e5acb270b9d322dc2a Mon Sep 17 00:00:00 2001 From: "gitlocalize-app[bot]" <55277160+gitlocalize-app[bot]@users.noreply.github.com> Date: Mon, 31 Oct 2022 08:27:07 +0200 Subject: [PATCH 13/43] Translate pl.yml via GitLocalize (#289) Co-authored-by: wiktorm12 --- src/main/resources/locales/pl.yml | 53 +++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/src/main/resources/locales/pl.yml b/src/main/resources/locales/pl.yml index 8c520c2d..bbd44532 100644 --- a/src/main/resources/locales/pl.yml +++ b/src/main/resources/locales/pl.yml @@ -16,11 +16,11 @@ aoneblock: look-at-chest: "&cSpójrz na wypełnioną skrzynię, aby ją ustawić" only-single-chest: "&cMożna ustawić tylko pojedyncze skrzynie" success: "&aSkrzynia pomyślnie dodana do fazy" - failure: "&cSkrzynia nie mogła zostać dodana do fazy! Zobacz konsolę dla błędów" + failure: "&cSkrzynia nie mogła zostać dodana do fazy! Zobacz błąd w konsoli" sanity: - parameters: "" + parameters: "" description: wyświetlać kontrolę poprawności prawdopodobieństwa fazy w konsoli - see-console: "&a Zobacz konsolę dla raportu" + see-console: "&a Zobacz raport w konsoli" count: description: pokaż liczbę bloków i fazę info: "&a Jesteś na bloku &b [number] w fazie &a [name]" @@ -35,18 +35,51 @@ aoneblock: description: ustaw liczbę bloków na poprzednio uzupełnioną wartość set: "&a Liczba ustawiona na [number]." too-high: "&c Maksymalna wartość, jaką możesz ustawić, to [number]!" + respawn-block: + description: odnawia magiczny blok, w przypadku zniknięcia + block-exist: "&a Blok nie potrzebował odnowienia. Został chwilowo zaznaczony" + block-respawned: "&a Odnowiono blok, proszę nie usuwaj go ponownie" phase: insufficient-level: Poziom Twojej wyspy jest za niski, aby kontynuować! Musi to - być [liczba]. - insufficient-funds: Twoje fundusze są zbyt niskie, aby kontynuować! Muszą być - [liczba]. + być [number]. + insufficient-funds: Twoje fundusze są zbyt niskie, aby kontynuować! Musisz posiadać + [number]. insufficient-bank-balance: Saldo na rachunku bankowym wyspy jest zbyt niskie, - aby kontynuować! Musi to być [liczba]. + aby kontynuować! Musi to być [number]. insufficient-permission: Nie możesz kontynuować, dopóki nie uzyskasz pozwolenia - [imię i nazwisko]! + [name]! placeholders: infinite: Nieskończony + gui: + titles: + phases: "&0&l Fazy OneBlock" + buttons: + previous: + name: "&f&lNastępna strona" + description: "&7 Przeskocz do [number] strony" + next: + name: "&f&l Następna strona" + description: "&7 Przeskocz do [number] strony" + phase: + name: "&f&l [phase]" + description: |- + [starting-block] + [biome] + [bank] + [economy] + [level] + [permission] + starting-block: "&7 Rozpoczyna sie po&e [number] &7zniszczonych blokach." + biome: "&7 Biom: &e [biome]" + bank: "&7 Potrzebujesz&e $[number] &7 na twoim koncie." + economy: "&7 Potrzebujesz&e $[number] &7 na twoim koncie." + level: "&7 Potrzebujesz &e [number] &7 poziom wyspy." + permission: "&7 Wymaga uprawnienia `&e[permission]&7`." + tips: + click-to-previous: "&e Kliknij &7, aby wyświetlić poprzednią stronę." + click-to-next: "&e Kliknij &7, aby wyświetlić następną stronę." + click-to-change: "&e Kliknij &7, aby zmienić." island: starting-hologram: |- - &aWitamy w AOneBlock - &ePrzerwij ten blok, aby rozpocząć + &aWitamy w OneBlock + &eZniszcz ten blok, aby rozpocząć From 350dcaa496613a17ed6873cab857b2f92b251636 Mon Sep 17 00:00:00 2001 From: "gitlocalize-app[bot]" <55277160+gitlocalize-app[bot]@users.noreply.github.com> Date: Mon, 31 Oct 2022 08:27:14 +0200 Subject: [PATCH 14/43] Update FR (#288) * Translate fr.yml via GitLocalize * Translate fr.yml via GitLocalize Co-authored-by: Shroom of Doom Co-authored-by: mt-gitlocalize --- src/main/resources/locales/fr.yml | 36 ++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/main/resources/locales/fr.yml b/src/main/resources/locales/fr.yml index be8c1d8c..792580db 100644 --- a/src/main/resources/locales/fr.yml +++ b/src/main/resources/locales/fr.yml @@ -37,6 +37,11 @@ aoneblock: description: définir le nombre de blocs à la valeur précédemment terminée set: "&a Nombre défini sur [number]." too-high: "&c Le maximum que vous pouvez définir est [number] !" + respawn-block: + description: Force la réapparition du bloc magique dans le cas ou il disparait + block-exist: "&a Le bloc magique existe déja, inutile de le faire réapparaitre. + Je l'ai marqué pour toi." + block-respawned: "&a Bloc magique réapparu, s'il te plait, ne recommence pas." phase: insufficient-level: Ton niveau d'île est trop bas ! Il doit être de [number] au minimum. @@ -48,7 +53,36 @@ aoneblock: : [name] !' placeholders: infinite: Infini + gui: + titles: + phases: "&0&l Phases OneBlock" + buttons: + previous: + name: "&f&l Page Précédente" + description: "&7 Aller à la page [number]" + next: + name: "&f&l Page Suivante" + description: "&7 Aller à la page [number]" + phase: + name: "&f&l [phase]" + description: |- + [Bloc de départ] + [biome] + [banque] + [économie] + [niveau] + [autorisation] + starting-block: "&7 Commence après avoir détruit &e [number] blocs." + biome: "&7 Biome : &e [biome]" + bank: "&7 Requiert &e $[number] &7 dans ta banque." + economy: "&7 Requiert &e $[number] &7 dans ton solde." + level: "&7 Requiert &e [number] &7 niveaux d'île." + permission: "&7 Requiert la permission : `&e[permission]&7` ." + tips: + click-to-previous: "&e Click &7 pour voir la page précédente." + click-to-next: "&e Click &7 pour voir la page suivante." + click-to-change: "&e Click &7 pour changer." island: starting-hologram: |- &aBienvenue sur AOneBlock - &eBrise ce bloc pour commencer + &eMine ce bloc pour commencer From ee2b0d4cb72e80ddebf9b57259da7a4be87d51cc Mon Sep 17 00:00:00 2001 From: BONNe Date: Thu, 1 Dec 2022 22:47:13 +0200 Subject: [PATCH 15/43] Update to 1.18 name --- src/main/resources/phases/7500_the nether.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/phases/7500_the nether.yml b/src/main/resources/phases/7500_the nether.yml index ecf83b1c..f75dcfe0 100644 --- a/src/main/resources/phases/7500_the nether.yml +++ b/src/main/resources/phases/7500_the nether.yml @@ -33,7 +33,7 @@ SKELETON: 50 MAGMA_CUBE: 100 GHAST: 20 - PIG_ZOMBIE: 300 + ZOMBIFIED_PIGLIN: 300 ENDERMAN: 20 BLAZE: 200 WITHER_SKELETON: 20 From 19ba0fa6f56319c8a1c22aefbb1db0213cd11ab5 Mon Sep 17 00:00:00 2001 From: tastybento Date: Mon, 16 Jan 2023 09:26:18 -0800 Subject: [PATCH 16/43] Version 1.12.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 32fc18b0..3c3424e8 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ -LOCAL - 1.12.0 + 1.12.1 BentoBoxWorld_AOneBlock bentobox-world From aad6c6e7bddaa13fcc203df9ae232eb4acb67976 Mon Sep 17 00:00:00 2001 From: tastybento Date: Mon, 16 Jan 2023 09:26:33 -0800 Subject: [PATCH 17/43] Fix JavaDoc by using {@code --- .../world/bentobox/aoneblock/requests/IslandStatsHandler.java | 2 +- .../world/bentobox/aoneblock/requests/LocationStatsHandler.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/world/bentobox/aoneblock/requests/IslandStatsHandler.java b/src/main/java/world/bentobox/aoneblock/requests/IslandStatsHandler.java index 8917d6ae..384504fd 100644 --- a/src/main/java/world/bentobox/aoneblock/requests/IslandStatsHandler.java +++ b/src/main/java/world/bentobox/aoneblock/requests/IslandStatsHandler.java @@ -12,7 +12,7 @@ /** * Provides stats on the player's island.
* Submit "player" -> UUID to {@link #handle(Map)}.
- * Return map is a Map of the following: + * Return map is a {@code Map} of the following: *
  • "count" - block count of island
  • *
  • "doneScale" - character scale of phase completion
  • *
  • "nextPhaseBlocks" - number of blocks to next phase
  • diff --git a/src/main/java/world/bentobox/aoneblock/requests/LocationStatsHandler.java b/src/main/java/world/bentobox/aoneblock/requests/LocationStatsHandler.java index 623ffc2a..f1708428 100644 --- a/src/main/java/world/bentobox/aoneblock/requests/LocationStatsHandler.java +++ b/src/main/java/world/bentobox/aoneblock/requests/LocationStatsHandler.java @@ -12,7 +12,7 @@ /** * Provides stats based on the user's location.
    * Submit "player" -> UUID to {@link #handle(Map)}.
    - * Return map is a Map of the following: + * Return map is a {@code Map} of the following: *
    • "count" - block count of island
    • *
    • "doneScale" - character scale of phase completion
    • *
    • "nextPhaseBlocks" - number of blocks to next phase
    • From 466d7743707c4a8f1e258551f433ad46e4706605 Mon Sep 17 00:00:00 2001 From: tastybento Date: Mon, 16 Jan 2023 09:26:45 -0800 Subject: [PATCH 18/43] Add Settings test class --- .../world/bentobox/aoneblock/Settings.java | 24 +- .../bentobox/aoneblock/SettingsTest.java | 1708 +++++++++++++++++ 2 files changed, 1715 insertions(+), 17 deletions(-) create mode 100644 src/test/java/world/bentobox/aoneblock/SettingsTest.java diff --git a/src/main/java/world/bentobox/aoneblock/Settings.java b/src/main/java/world/bentobox/aoneblock/Settings.java index 1f5eeb60..83065583 100644 --- a/src/main/java/world/bentobox/aoneblock/Settings.java +++ b/src/main/java/world/bentobox/aoneblock/Settings.java @@ -1,6 +1,12 @@ package world.bentobox.aoneblock; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import org.bukkit.Difficulty; import org.bukkit.GameMode; @@ -8,7 +14,6 @@ import org.bukkit.entity.EntityType; import com.google.common.base.Enums; -import com.google.gson.annotations.JsonAdapter; import world.bentobox.aoneblock.listeners.BlockListener; import world.bentobox.bentobox.api.configuration.ConfigComment; @@ -1171,21 +1176,6 @@ public void setDefaultIslandSettingNames(Map defaultIslandSetti this.defaultIslandSettingNames = defaultIslandSettingNames; } - - /** - * @param defaultIslandFlags the defaultIslandFlags to set - * @deprecated since 1.21 - */ - public void setDefaultIslandFlags(Map defaultIslandFlags) {} - - - /** - * @param defaultIslandSettings the defaultIslandSettings to set - * @deprecated since 1.21 - */ - public void setDefaultIslandSettings(Map defaultIslandSettings) {} - - /** * @param hiddenFlags the hidden flags to set */ diff --git a/src/test/java/world/bentobox/aoneblock/SettingsTest.java b/src/test/java/world/bentobox/aoneblock/SettingsTest.java new file mode 100644 index 00000000..7ddca0ea --- /dev/null +++ b/src/test/java/world/bentobox/aoneblock/SettingsTest.java @@ -0,0 +1,1708 @@ +package world.bentobox.aoneblock; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.bukkit.Difficulty; +import org.bukkit.GameMode; +import org.bukkit.block.Biome; +import org.bukkit.entity.EntityType; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.modules.junit4.PowerMockRunner; + +import world.bentobox.aoneblock.listeners.BlockListener; + +/** + * @author tastybento + * + */ +@RunWith(PowerMockRunner.class) +public class SettingsTest { + + private Settings s; + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + s = new Settings(); + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getFriendlyName()}. + */ + @Test + public void testGetFriendlyName() { + assertEquals("OneBlock", s.getFriendlyName()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getWorldName()}. + */ + @Test + public void testGetWorldName() { + assertEquals("oneblock_world", s.getWorldName()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getDifficulty()}. + */ + @Test + public void testGetDifficulty() { + assertEquals(Difficulty.NORMAL, s.getDifficulty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getIslandDistance()}. + */ + @Test + public void testGetIslandDistance() { + assertEquals(400, s.getIslandDistance()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getIslandProtectionRange()}. + */ + @Test + public void testGetIslandProtectionRange() { + assertEquals(50, s.getIslandProtectionRange()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getIslandStartX()}. + */ + @Test + public void testGetIslandStartX() { + assertEquals(0, s.getIslandStartX()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getIslandStartZ()}. + */ + @Test + public void testGetIslandStartZ() { + assertEquals(0, s.getIslandStartZ()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getIslandXOffset()}. + */ + @Test + public void testGetIslandXOffset() { + assertEquals(0, s.getIslandXOffset()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getIslandZOffset()}. + */ + @Test + public void testGetIslandZOffset() { + assertEquals(0, s.getIslandZOffset()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getIslandHeight()}. + */ + @Test + public void testGetIslandHeight() { + assertEquals(120, s.getIslandHeight()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isUseOwnGenerator()}. + */ + @Test + public void testIsUseOwnGenerator() { + assertFalse(s.isUseOwnGenerator()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getSeaHeight()}. + */ + @Test + public void testGetSeaHeight() { + assertEquals(0, s.getSeaHeight()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getMaxIslands()}. + */ + @Test + public void testGetMaxIslands() { + assertEquals(-1, s.getMaxIslands()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getDefaultGameMode()}. + */ + @Test + public void testGetDefaultGameMode() { + assertEquals(GameMode.SURVIVAL, s.getDefaultGameMode()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isNetherGenerate()}. + */ + @Test + public void testIsNetherGenerate() { + assertTrue(s.isNetherGenerate()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isNetherIslands()}. + */ + @Test + public void testIsNetherIslands() { + assertFalse(s.isNetherIslands()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isNetherRoof()}. + */ + @Test + public void testIsNetherRoof() { + assertFalse(s.isNetherRoof()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getNetherSpawnRadius()}. + */ + @Test + public void testGetNetherSpawnRadius() { + assertEquals(32, s.getNetherSpawnRadius()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isEndGenerate()}. + */ + @Test + public void testIsEndGenerate() { + assertFalse(s.isEndGenerate()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isEndIslands()}. + */ + @Test + public void testIsEndIslands() { + assertFalse(s.isEndIslands()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isDragonSpawn()}. + */ + @Test + public void testIsDragonSpawn() { + assertFalse(s.isDragonSpawn()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getRemoveMobsWhitelist()}. + */ + @Test + public void testGetRemoveMobsWhitelist() { + assertTrue(s.getRemoveMobsWhitelist().isEmpty()); + + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getWorldFlags()}. + */ + @Test + public void testGetWorldFlags() { + assertTrue(s.getWorldFlags().isEmpty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getDefaultIslandFlagNames()}. + */ + @Test + public void testGetDefaultIslandFlagNames() { + assertTrue(s.getDefaultIslandFlagNames().isEmpty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getDefaultIslandSettingNames()}. + */ + @Test + public void testGetDefaultIslandSettingNames() { + assertTrue(s.getDefaultIslandSettingNames().isEmpty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getDefaultIslandFlags()}. + */ + @SuppressWarnings("deprecation") + @Test + public void testGetDefaultIslandFlags() { + assertTrue(s.getDefaultIslandFlags().isEmpty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getDefaultIslandSettings()}. + */ + @SuppressWarnings("deprecation") + @Test + public void testGetDefaultIslandSettings() { + assertTrue(s.getDefaultIslandSettings().isEmpty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getHiddenFlags()}. + */ + @Test + public void testGetHiddenFlags() { + assertTrue(s.getHiddenFlags().isEmpty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getVisitorBannedCommands()}. + */ + @Test + public void testGetVisitorBannedCommands() { + assertTrue(s.getVisitorBannedCommands().isEmpty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getFallingBannedCommands()}. + */ + @Test + public void testGetFallingBannedCommands() { + assertTrue(s.getFallingBannedCommands().isEmpty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getMaxTeamSize()}. + */ + @Test + public void testGetMaxTeamSize() { + assertEquals(4, s.getMaxTeamSize()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getMaxHomes()}. + */ + @Test + public void testGetMaxHomes() { + assertEquals(5, s.getMaxHomes()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getResetLimit()}. + */ + @Test + public void testGetResetLimit() { + assertEquals(-1, s.getResetLimit()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isLeaversLoseReset()}. + */ + @Test + public void testIsLeaversLoseReset() { + assertFalse(s.isLeaversLoseReset()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isKickedKeepInventory()}. + */ + @Test + public void testIsKickedKeepInventory() { + assertFalse(s.isKickedKeepInventory()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isCreateIslandOnFirstLoginEnabled()}. + */ + @Test + public void testIsCreateIslandOnFirstLoginEnabled() { + assertFalse(s.isCreateIslandOnFirstLoginEnabled()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getCreateIslandOnFirstLoginDelay()}. + */ + @Test + public void testGetCreateIslandOnFirstLoginDelay() { + assertEquals(5, s.getCreateIslandOnFirstLoginDelay()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isCreateIslandOnFirstLoginAbortOnLogout()}. + */ + @Test + public void testIsCreateIslandOnFirstLoginAbortOnLogout() { + assertTrue(s.isCreateIslandOnFirstLoginAbortOnLogout()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isOnJoinResetMoney()}. + */ + @Test + public void testIsOnJoinResetMoney() { + assertFalse(s.isOnJoinResetMoney()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isOnJoinResetInventory()}. + */ + @Test + public void testIsOnJoinResetInventory() { + assertTrue(s.isOnJoinResetInventory()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isOnJoinResetEnderChest()}. + */ + @Test + public void testIsOnJoinResetEnderChest() { + assertFalse(s.isOnJoinResetEnderChest()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isOnLeaveResetMoney()}. + */ + @Test + public void testIsOnLeaveResetMoney() { + assertFalse(s.isOnLeaveResetMoney()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isOnLeaveResetInventory()}. + */ + @Test + public void testIsOnLeaveResetInventory() { + assertFalse(s.isOnLeaveResetInventory()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isOnLeaveResetEnderChest()}. + */ + @Test + public void testIsOnLeaveResetEnderChest() { + assertFalse(s.isOnLeaveResetEnderChest()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isDeathsCounted()}. + */ + @Test + public void testIsDeathsCounted() { + assertTrue(s.isDeathsCounted()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isAllowSetHomeInNether()}. + */ + @Test + public void testIsAllowSetHomeInNether() { + assertTrue(s.isAllowSetHomeInNether()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isAllowSetHomeInTheEnd()}. + */ + @Test + public void testIsAllowSetHomeInTheEnd() { + assertTrue(s.isAllowSetHomeInTheEnd()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isRequireConfirmationToSetHomeInNether()}. + */ + @Test + public void testIsRequireConfirmationToSetHomeInNether() { + assertTrue(s.isRequireConfirmationToSetHomeInNether()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isRequireConfirmationToSetHomeInTheEnd()}. + */ + @Test + public void testIsRequireConfirmationToSetHomeInTheEnd() { + assertTrue(s.isRequireConfirmationToSetHomeInTheEnd()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getDeathsMax()}. + */ + @Test + public void testGetDeathsMax() { + assertEquals(10, s.getDeathsMax()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isTeamJoinDeathReset()}. + */ + @Test + public void testIsTeamJoinDeathReset() { + assertTrue(s.isTeamJoinDeathReset()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getGeoLimitSettings()}. + */ + @Test + public void testGetGeoLimitSettings() { + assertTrue(s.getGeoLimitSettings().isEmpty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getIvSettings()}. + */ + @Test + public void testGetIvSettings() { + assertTrue(s.getIvSettings().isEmpty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getResetEpoch()}. + */ + @Test + public void testGetResetEpoch() { + assertEquals(0L, s.getResetEpoch()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setFriendlyName(java.lang.String)}. + */ + @Test + public void testSetFriendlyName() { + s.setFriendlyName("test"); + assertEquals("test", s.getFriendlyName()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setWorldName(java.lang.String)}. + */ + @Test + public void testSetWorldName() { + s.setWorldName("test"); + assertEquals("test", s.getWorldName()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setDifficulty(org.bukkit.Difficulty)}. + */ + @Test + public void testSetDifficulty() { + s.setDifficulty(Difficulty.HARD); + assertEquals(Difficulty.HARD, s.getDifficulty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setIslandDistance(int)}. + */ + @Test + public void testSetIslandDistance() { + s.setIslandDistance(12345); + assertEquals(12345, s.getIslandDistance()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setIslandProtectionRange(int)}. + */ + @Test + public void testSetIslandProtectionRange() { + s.setIslandProtectionRange(12345); + assertEquals(12345, s.getIslandProtectionRange()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setIslandStartX(int)}. + */ + @Test + public void testSetIslandStartX() { + s.setIslandStartX(12345); + assertEquals(12345, s.getIslandStartX()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setIslandStartZ(int)}. + */ + @Test + public void testSetIslandStartZ() { + s.setIslandStartZ(12345); + assertEquals(12345, s.getIslandStartZ()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setIslandXOffset(int)}. + */ + @Test + public void testSetIslandXOffset() { + s.setIslandXOffset(12345); + assertEquals(12345, s.getIslandXOffset()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setIslandZOffset(int)}. + */ + @Test + public void testSetIslandZOffset() { + s.setIslandZOffset(12345); + assertEquals(12345, s.getIslandZOffset()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setIslandHeight(int)}. + */ + @Test + public void testSetIslandHeight() { + s.setIslandHeight(12345); + assertEquals(12345, s.getIslandHeight()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setUseOwnGenerator(boolean)}. + */ + @Test + public void testSetUseOwnGenerator() { + s.setUseOwnGenerator(true); + assertTrue(s.isUseOwnGenerator()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setSeaHeight(int)}. + */ + @Test + public void testSetSeaHeight() { + s.setSeaHeight(12345); + assertEquals(12345, s.getSeaHeight()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setMaxIslands(int)}. + */ + @Test + public void testSetMaxIslands() { + s.setMaxIslands(12345); + assertEquals(12345, s.getMaxIslands()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setDefaultGameMode(org.bukkit.GameMode)}. + */ + @Test + public void testSetDefaultGameMode() { + s.setDefaultGameMode(GameMode.SPECTATOR); + assertEquals(GameMode.SPECTATOR, s.getDefaultGameMode()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setNetherGenerate(boolean)}. + */ + @Test + public void testSetNetherGenerate() { + s.setNetherGenerate(false); + assertFalse(s.isNetherGenerate()); + s.setNetherGenerate(true); + assertTrue(s.isNetherGenerate()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setNetherIslands(boolean)}. + */ + @Test + public void testSetNetherIslands() { + s.setNetherIslands(false); + assertFalse(s.isNetherIslands()); + s.setNetherIslands(true); + assertTrue(s.isNetherIslands()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setNetherRoof(boolean)}. + */ + @Test + public void testSetNetherRoof() { + s.setNetherRoof(false); + assertFalse(s.isNetherRoof()); + s.setNetherRoof(true); + assertTrue(s.isNetherRoof()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setNetherSpawnRadius(int)}. + */ + @Test + public void testSetNetherSpawnRadius() { + s.setNetherSpawnRadius(12345); + assertEquals(12345, s.getNetherSpawnRadius()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setEndGenerate(boolean)}. + */ + @Test + public void testSetEndGenerate() { + s.setEndGenerate(false); + assertFalse(s.isEndGenerate()); + s.setEndGenerate(true); + assertTrue(s.isEndGenerate()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setEndIslands(boolean)}. + */ + @Test + public void testSetEndIslands() { + s.setEndIslands(false); + assertFalse(s.isEndIslands()); + s.setEndIslands(true); + assertTrue(s.isEndIslands()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setRemoveMobsWhitelist(java.util.Set)}. + */ + @Test + public void testSetRemoveMobsWhitelist() { + s.setRemoveMobsWhitelist(Collections.singleton(EntityType.AXOLOTL)); + assertTrue(s.getRemoveMobsWhitelist().contains(EntityType.AXOLOTL)); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setWorldFlags(java.util.Map)}. + */ + @Test + public void testSetWorldFlags() { + s.setWorldFlags(Map.of("trueFlag", true, "falseFlag", false)); + assertTrue(s.getWorldFlags().get("trueFlag")); + assertFalse(s.getWorldFlags().get("falseFlag")); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setDefaultIslandFlagNames(java.util.Map)}. + */ + @Test + public void testSetDefaultIslandFlagNames() { + s.setDefaultIslandFlagNames(Map.of("TEST", 500)); + assertTrue(s.getDefaultIslandFlagNames().get("TEST") == 500); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setDefaultIslandSettingNames(java.util.Map)}. + */ + @Test + public void testSetDefaultIslandSettingNames() { + s.setDefaultIslandSettingNames(Map.of("SETTING", 456)); + assertTrue(s.getDefaultIslandSettingNames().get("SETTING") == 456); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setHiddenFlags(java.util.List)}. + */ + @Test + public void testSetHiddenFlags() { + s.setHiddenFlags(List.of("FLAG1", "FLAG2")); + assertTrue(s.getHiddenFlags().contains("FLAG2")); + assertFalse(s.getHiddenFlags().contains("FLAG3")); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setVisitorBannedCommands(java.util.List)}. + */ + @Test + public void testSetVisitorBannedCommands() { + s.setVisitorBannedCommands(List.of("banned")); + assertTrue(s.getVisitorBannedCommands().contains("banned")); + assertFalse(s.getVisitorBannedCommands().contains("not-banned")); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setFallingBannedCommands(java.util.List)}. + */ + @Test + public void testSetFallingBannedCommands() { + s.setFallingBannedCommands(List.of("banned")); + assertTrue(s.getFallingBannedCommands().contains("banned")); + assertFalse(s.getFallingBannedCommands().contains("not-banned")); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setMaxTeamSize(int)}. + */ + @Test + public void testSetMaxTeamSize() { + s.setMaxTeamSize(12345); + assertEquals(12345, s.getMaxTeamSize()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setMaxHomes(int)}. + */ + @Test + public void testSetMaxHomes() { + s.setMaxHomes(12345); + assertEquals(12345, s.getMaxHomes()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setResetLimit(int)}. + */ + @Test + public void testSetResetLimit() { + s.setResetLimit(12345); + assertEquals(12345, s.getResetLimit()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setLeaversLoseReset(boolean)}. + */ + @Test + public void testSetLeaversLoseReset() { + s.setLeaversLoseReset(false); + assertFalse(s.isLeaversLoseReset()); + s.setLeaversLoseReset(true); + assertTrue(s.isLeaversLoseReset()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setKickedKeepInventory(boolean)}. + */ + @Test + public void testSetKickedKeepInventory() { + s.setKickedKeepInventory(false); + assertFalse(s.isKickedKeepInventory()); + s.setKickedKeepInventory(true); + assertTrue(s.isKickedKeepInventory()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setOnJoinResetMoney(boolean)}. + */ + @Test + public void testSetOnJoinResetMoney() { + s.setOnJoinResetMoney(false); + assertFalse(s.isOnJoinResetMoney()); + s.setOnJoinResetMoney(true); + assertTrue(s.isOnJoinResetMoney()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setOnJoinResetInventory(boolean)}. + */ + @Test + public void testSetOnJoinResetInventory() { + s.setOnJoinResetInventory(false); + assertFalse(s.isOnJoinResetInventory()); + s.setOnJoinResetInventory(true); + assertTrue(s.isOnJoinResetInventory()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setOnJoinResetEnderChest(boolean)}. + */ + @Test + public void testSetOnJoinResetEnderChest() { + s.setOnJoinResetEnderChest(false); + assertFalse(s.isOnJoinResetEnderChest()); + s.setOnJoinResetEnderChest(true); + assertTrue(s.isOnJoinResetEnderChest()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setOnLeaveResetMoney(boolean)}. + */ + @Test + public void testSetOnLeaveResetMoney() { + s.setOnLeaveResetMoney(false); + assertFalse(s.isOnLeaveResetMoney()); + s.setOnLeaveResetMoney(true); + assertTrue(s.isOnLeaveResetMoney()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setOnLeaveResetInventory(boolean)}. + */ + @Test + public void testSetOnLeaveResetInventory() { + s.setOnLeaveResetInventory(false); + assertFalse(s.isOnLeaveResetInventory()); + s.setOnLeaveResetInventory(true); + assertTrue(s.isOnLeaveResetInventory()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setOnLeaveResetEnderChest(boolean)}. + */ + @Test + public void testSetOnLeaveResetEnderChest() { + s.setOnLeaveResetEnderChest(false); + assertFalse(s.isOnLeaveResetEnderChest()); + s.setOnLeaveResetEnderChest(true); + assertTrue(s.isOnLeaveResetEnderChest()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setCreateIslandOnFirstLoginEnabled(boolean)}. + */ + @Test + public void testSetCreateIslandOnFirstLoginEnabled() { + s.setCreateIslandOnFirstLoginEnabled(false); + assertFalse(s.isCreateIslandOnFirstLoginEnabled()); + s.setCreateIslandOnFirstLoginEnabled(true); + assertTrue(s.isCreateIslandOnFirstLoginEnabled()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setCreateIslandOnFirstLoginDelay(int)}. + */ + @Test + public void testSetCreateIslandOnFirstLoginDelay() { + s.setCreateIslandOnFirstLoginDelay(12345); + assertEquals(12345, s.getCreateIslandOnFirstLoginDelay()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setCreateIslandOnFirstLoginAbortOnLogout(boolean)}. + */ + @Test + public void testSetCreateIslandOnFirstLoginAbortOnLogout() { + s.setCreateIslandOnFirstLoginAbortOnLogout(false); + assertFalse(s.isCreateIslandOnFirstLoginAbortOnLogout()); + s.setCreateIslandOnFirstLoginAbortOnLogout(true); + assertTrue(s.isCreateIslandOnFirstLoginAbortOnLogout()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setDeathsCounted(boolean)}. + */ + @Test + public void testSetDeathsCounted() { + s.setDeathsCounted(false); + assertFalse(s.isDeathsCounted()); + s.setDeathsCounted(true); + assertTrue(s.isDeathsCounted()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setDeathsMax(int)}. + */ + @Test + public void testSetDeathsMax() { + s.setDeathsMax(12345); + assertEquals(12345, s.getDeathsMax()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setTeamJoinDeathReset(boolean)}. + */ + @Test + public void testSetTeamJoinDeathReset() { + s.setTeamJoinDeathReset(false); + assertFalse(s.isTeamJoinDeathReset()); + s.setTeamJoinDeathReset(true); + assertTrue(s.isTeamJoinDeathReset()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setGeoLimitSettings(java.util.List)}. + */ + @Test + public void testSetGeoLimitSettings() { + s.setGeoLimitSettings(List.of("test")); + assertTrue(s.getGeoLimitSettings().contains("test")); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setIvSettings(java.util.List)}. + */ + @Test + public void testSetIvSettings() { + s.setIvSettings(List.of("test")); + assertTrue(s.getIvSettings().contains("test")); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setAllowSetHomeInNether(boolean)}. + */ + @Test + public void testSetAllowSetHomeInNether() { + s.setAllowSetHomeInNether(false); + assertFalse(s.isAllowSetHomeInNether()); + s.setAllowSetHomeInNether(true); + assertTrue(s.isAllowSetHomeInNether()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setAllowSetHomeInTheEnd(boolean)}. + */ + @Test + public void testSetAllowSetHomeInTheEnd() { + s.setAllowSetHomeInTheEnd(false); + assertFalse(s.isAllowSetHomeInTheEnd()); + s.setAllowSetHomeInTheEnd(true); + assertTrue(s.isAllowSetHomeInTheEnd()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setRequireConfirmationToSetHomeInNether(boolean)}. + */ + @Test + public void testSetRequireConfirmationToSetHomeInNether() { + s.setRequireConfirmationToSetHomeInNether(false); + assertFalse(s.isRequireConfirmationToSetHomeInNether()); + s.setRequireConfirmationToSetHomeInNether(true); + assertTrue(s.isRequireConfirmationToSetHomeInNether()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setRequireConfirmationToSetHomeInTheEnd(boolean)}. + */ + @Test + public void testSetRequireConfirmationToSetHomeInTheEnd() { + s.setRequireConfirmationToSetHomeInTheEnd(false); + assertFalse(s.isRequireConfirmationToSetHomeInTheEnd()); + s.setRequireConfirmationToSetHomeInTheEnd(true); + assertTrue(s.isRequireConfirmationToSetHomeInTheEnd()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setResetEpoch(long)}. + */ + @Test + public void testSetResetEpoch() { + s.setResetEpoch(12345); + assertEquals(12345, s.getResetEpoch()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getPermissionPrefix()}. + */ + @Test + public void testGetPermissionPrefix() { + assertEquals("aoneblock", s.getPermissionPrefix()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isWaterUnsafe()}. + */ + @Test + public void testIsWaterUnsafe() { + assertFalse(s.isWaterUnsafe()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getDefaultBiome()}. + */ + @Test + public void testGetDefaultBiome() { + assertEquals(Biome.PLAINS, s.getDefaultBiome()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setDefaultBiome(org.bukkit.block.Biome)}. + */ + @Test + public void testSetDefaultBiome() { + assertEquals(Biome.PLAINS, s.getDefaultBiome()); + s.setDefaultBiome(Biome.BAMBOO_JUNGLE); + assertEquals(Biome.BAMBOO_JUNGLE, s.getDefaultBiome()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getBanLimit()}. + */ + @Test + public void testGetBanLimit() { + assertEquals(-1, s.getBanLimit()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setBanLimit(int)}. + */ + @Test + public void testSetBanLimit() { + assertEquals(-1, s.getBanLimit()); + s.setBanLimit(12345); + assertEquals(12345, s.getBanLimit()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getPlayerCommandAliases()}. + */ + @Test + public void testGetPlayerCommandAliases() { + assertEquals("ob oneblock",s.getPlayerCommandAliases()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setPlayerCommandAliases(java.lang.String)}. + */ + @Test + public void testSetPlayerCommandAliases() { + assertEquals("ob oneblock",s.getPlayerCommandAliases()); + s.setPlayerCommandAliases("aliases"); + assertEquals("aliases",s.getPlayerCommandAliases()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getAdminCommandAliases()}. + */ + @Test + public void testGetAdminCommandAliases() { + assertEquals("oba obadmin",s.getAdminCommandAliases()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setAdminCommandAliases(java.lang.String)}. + */ + @Test + public void testSetAdminCommandAliases() { + assertEquals("oba obadmin",s.getAdminCommandAliases()); + s.setAdminCommandAliases("aliases"); + assertEquals("aliases",s.getAdminCommandAliases()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isDeathsResetOnNewIsland()}. + */ + @Test + public void testIsDeathsResetOnNewIsland() { + assertTrue(s.isDeathsResetOnNewIsland()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setDeathsResetOnNewIsland(boolean)}. + */ + @Test + public void testSetDeathsResetOnNewIsland() { + s.setDeathsResetOnNewIsland(false); + assertFalse(s.isDeathsResetOnNewIsland()); + s.setDeathsResetOnNewIsland(true); + assertTrue(s.isDeathsResetOnNewIsland()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getOnJoinCommands()}. + */ + @Test + public void testGetOnJoinCommands() { + assertTrue(s.getOnJoinCommands().isEmpty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setOnJoinCommands(java.util.List)}. + */ + @Test + public void testSetOnJoinCommands() { + s.setOnJoinCommands(List.of("command", "do this")); + assertEquals("do this", s.getOnJoinCommands().get(1)); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getOnLeaveCommands()}. + */ + @Test + public void testGetOnLeaveCommands() { + assertTrue(s.getOnLeaveCommands().isEmpty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setOnLeaveCommands(java.util.List)}. + */ + @Test + public void testSetOnLeaveCommands() { + s.setOnLeaveCommands(List.of("command", "do this")); + assertEquals("do this", s.getOnLeaveCommands().get(1)); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getOnRespawnCommands()}. + */ + @Test + public void testGetOnRespawnCommands() { + assertTrue(s.getOnRespawnCommands().isEmpty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setOnRespawnCommands(java.util.List)}. + */ + @Test + public void testSetOnRespawnCommands() { + s.setOnRespawnCommands(List.of("command", "do this")); + assertEquals("do this", s.getOnRespawnCommands().get(1)); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isOnJoinResetHealth()}. + */ + @Test + public void testIsOnJoinResetHealth() { + assertTrue(s.isOnJoinResetHealth()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setOnJoinResetHealth(boolean)}. + */ + @Test + public void testSetOnJoinResetHealth() { + s.setOnJoinResetHealth(false); + assertFalse(s.isOnJoinResetHealth()); + s.setOnJoinResetHealth(true); + assertTrue(s.isOnJoinResetHealth()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isOnJoinResetHunger()}. + */ + @Test + public void testIsOnJoinResetHunger() { + assertTrue(s.isOnJoinResetHunger()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setOnJoinResetHunger(boolean)}. + */ + @Test + public void testSetOnJoinResetHunger() { + s.setOnJoinResetHunger(false); + assertFalse(s.isOnJoinResetHunger()); + s.setOnJoinResetHunger(true); + assertTrue(s.isOnJoinResetHunger()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isOnJoinResetXP()}. + */ + @Test + public void testIsOnJoinResetXP() { + assertTrue(s.isOnJoinResetXP()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setOnJoinResetXP(boolean)}. + */ + @Test + public void testSetOnJoinResetXP() { + s.setOnJoinResetXP(false); + assertFalse(s.isOnJoinResetXP()); + s.setOnJoinResetXP(true); + assertTrue(s.isOnJoinResetXP()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isOnLeaveResetHealth()}. + */ + @Test + public void testIsOnLeaveResetHealth() { + assertFalse(s.isOnLeaveResetHealth()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setOnLeaveResetHealth(boolean)}. + */ + @Test + public void testSetOnLeaveResetHealth() { + s.setOnLeaveResetHealth(false); + assertFalse(s.isOnLeaveResetHealth()); + s.setOnLeaveResetHealth(true); + assertTrue(s.isOnLeaveResetHealth()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isOnLeaveResetHunger()}. + */ + @Test + public void testIsOnLeaveResetHunger() { + assertFalse(s.isOnLeaveResetHunger()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setOnLeaveResetHunger(boolean)}. + */ + @Test + public void testSetOnLeaveResetHunger() { + s.setOnLeaveResetHunger(false); + assertFalse(s.isOnLeaveResetHunger()); + s.setOnLeaveResetHunger(true); + assertTrue(s.isOnLeaveResetHunger()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isOnLeaveResetXP()}. + */ + @Test + public void testIsOnLeaveResetXP() { + assertFalse(s.isOnLeaveResetXP()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setOnLeaveResetXP(boolean)}. + */ + @Test + public void testSetOnLeaveResetXP() { + assertFalse(s.isOnLeaveResetXP()); + s.setOnLeaveResetXP(true); + assertTrue(s.isOnLeaveResetXP()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isPasteMissingIslands()}. + */ + @Test + public void testIsPasteMissingIslands() { + assertFalse(s.isPasteMissingIslands()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setPasteMissingIslands(boolean)}. + */ + @Test + public void testSetPasteMissingIslands() { + assertFalse(s.isPasteMissingIslands()); + s.setPasteMissingIslands(true); + assertTrue(s.isPasteMissingIslands()); + + + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isTeleportPlayerToIslandUponIslandCreation()}. + */ + @Test + public void testIsTeleportPlayerToIslandUponIslandCreation() { + assertTrue(s.isTeleportPlayerToIslandUponIslandCreation()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setTeleportPlayerToIslandUponIslandCreation(boolean)}. + */ + @Test + public void testSetTeleportPlayerToIslandUponIslandCreation() { + assertTrue(s.isTeleportPlayerToIslandUponIslandCreation()); + s.setTeleportPlayerToIslandUponIslandCreation(false); + assertFalse(s.isTeleportPlayerToIslandUponIslandCreation()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getSpawnLimitMonsters()}. + */ + @Test + public void testGetSpawnLimitMonsters() { + assertEquals(-1, s.getSpawnLimitMonsters()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setSpawnLimitMonsters(int)}. + */ + @Test + public void testSetSpawnLimitMonsters() { + assertEquals(-1, s.getSpawnLimitMonsters()); + s.setSpawnLimitMonsters(12345); + assertEquals(12345, s.getSpawnLimitMonsters()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getSpawnLimitAnimals()}. + */ + @Test + public void testGetSpawnLimitAnimals() { + assertEquals(-1, s.getSpawnLimitAnimals()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setSpawnLimitAnimals(int)}. + */ + @Test + public void testSetSpawnLimitAnimals() { + assertEquals(-1, s.getSpawnLimitAnimals()); + s.setSpawnLimitAnimals(12345); + assertEquals(12345, s.getSpawnLimitAnimals()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getSpawnLimitWaterAnimals()}. + */ + @Test + public void testGetSpawnLimitWaterAnimals() { + assertEquals(-1, s.getSpawnLimitWaterAnimals()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setSpawnLimitWaterAnimals(int)}. + */ + @Test + public void testSetSpawnLimitWaterAnimals() { + assertEquals(-1, s.getSpawnLimitWaterAnimals()); + s.setSpawnLimitWaterAnimals(12345); + assertEquals(12345, s.getSpawnLimitWaterAnimals()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getSpawnLimitAmbient()}. + */ + @Test + public void testGetSpawnLimitAmbient() { + assertEquals(-1, s.getSpawnLimitAmbient()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setSpawnLimitAmbient(int)}. + */ + @Test + public void testSetSpawnLimitAmbient() { + assertEquals(-1, s.getSpawnLimitAmbient()); + s.setSpawnLimitAmbient(12345); + assertEquals(12345, s.getSpawnLimitAmbient()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getTicksPerAnimalSpawns()}. + */ + @Test + public void testGetTicksPerAnimalSpawns() { + assertEquals(-1, s.getTicksPerAnimalSpawns()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setTicksPerAnimalSpawns(int)}. + */ + @Test + public void testSetTicksPerAnimalSpawns() { + assertEquals(-1, s.getTicksPerAnimalSpawns()); + s.setTicksPerAnimalSpawns(12345); + assertEquals(12345, s.getTicksPerAnimalSpawns()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getTicksPerMonsterSpawns()}. + */ + @Test + public void testGetTicksPerMonsterSpawns() { + assertEquals(-1, s.getTicksPerMonsterSpawns()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setTicksPerMonsterSpawns(int)}. + */ + @Test + public void testSetTicksPerMonsterSpawns() { + assertEquals(-1, s.getTicksPerMonsterSpawns()); + s.setTicksPerMonsterSpawns(12345); + assertEquals(12345, s.getTicksPerMonsterSpawns()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getMaxCoopSize()}. + */ + @Test + public void testGetMaxCoopSize() { + assertEquals(4, s.getMaxCoopSize()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setMaxCoopSize(int)}. + */ + @Test + public void testSetMaxCoopSize() { + s.setMaxCoopSize(12345); + assertEquals(12345, s.getMaxCoopSize()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getMaxTrustSize()}. + */ + @Test + public void testGetMaxTrustSize() { + assertEquals(4, s.getMaxTrustSize()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setMaxTrustSize(int)}. + */ + @Test + public void testSetMaxTrustSize() { + s.setMaxTrustSize(12345); + assertEquals(12345, s.getMaxTrustSize()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getMobWarning()}. + */ + @Test + public void testGetMobWarning() { + assertEquals(5, s.getMobWarning()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setMobWarning(int)}. + */ + @Test + public void testSetMobWarning() { + s.setMobWarning(12345); + // Should be no more than 5 + assertEquals(BlockListener.MAX_LOOK_AHEAD, s.getMobWarning()); + s.setMobWarning(-12345); + // Should be 0 + assertEquals(0, s.getMobWarning()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isWaterMobProtection()}. + */ + @Test + public void testIsWaterMobProtection() { + assertTrue(s.isWaterMobProtection()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setWaterMobProtection(boolean)}. + */ + @Test + public void testSetWaterMobProtection() { + s.setWaterMobProtection(false); + assertFalse(s.isWaterMobProtection()); + s.setWaterMobProtection(true); + assertTrue(s.isWaterMobProtection()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getDefaultNewPlayerAction()}. + */ + @Test + public void testGetDefaultNewPlayerAction() { + assertEquals("create", s.getDefaultNewPlayerAction()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setDefaultNewPlayerAction(java.lang.String)}. + */ + @Test + public void testSetDefaultNewPlayerAction() { + s.setDefaultNewPlayerAction("test"); + assertEquals("test", s.getDefaultNewPlayerAction()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getDefaultPlayerAction()}. + */ + @Test + public void testGetDefaultPlayerAction() { + assertEquals("go", s.getDefaultPlayerAction()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setDefaultPlayerAction(java.lang.String)}. + */ + @Test + public void testSetDefaultPlayerAction() { + s.setDefaultPlayerAction("test"); + assertEquals("test", s.getDefaultPlayerAction()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getMobLimitSettings()}. + */ + @Test + public void testGetMobLimitSettings() { + assertTrue(s.getMobLimitSettings().isEmpty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setMobLimitSettings(java.util.List)}. + */ + @Test + public void testSetMobLimitSettings() { + s.setMobLimitSettings(List.of("test")); + assertEquals("test", s.getMobLimitSettings().get(0)); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isDropOnTop()}. + */ + @Test + public void testIsDropOnTop() { + assertTrue(s.isDropOnTop()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setDropOnTop(boolean)}. + */ + @Test + public void testSetDropOnTop() { + s.setDropOnTop(false); + assertFalse(s.isDropOnTop()); + s.setDropOnTop(true); + assertTrue(s.isDropOnTop()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getDefaultNetherBiome()}. + */ + @Test + public void testGetDefaultNetherBiome() { + assertEquals(Biome.NETHER_WASTES, s.getDefaultNetherBiome()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setDefaultNetherBiome(org.bukkit.block.Biome)}. + */ + @Test + public void testSetDefaultNetherBiome() { + assertEquals(Biome.NETHER_WASTES, s.getDefaultNetherBiome()); + s.setDefaultNetherBiome(Biome.BADLANDS); + assertEquals(Biome.BADLANDS, s.getDefaultNetherBiome()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getDefaultEndBiome()}. + */ + @Test + public void testGetDefaultEndBiome() { + assertEquals(Biome.THE_END, s.getDefaultEndBiome()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setDefaultEndBiome(org.bukkit.block.Biome)}. + */ + @Test + public void testSetDefaultEndBiome() { + assertEquals(Biome.THE_END, s.getDefaultEndBiome()); + s.setDefaultEndBiome(Biome.BADLANDS); + assertEquals(Biome.BADLANDS, s.getDefaultEndBiome()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isMakeNetherPortals()}. + */ + @Test + public void testIsMakeNetherPortals() { + assertFalse(s.isMakeNetherPortals()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isMakeEndPortals()}. + */ + @Test + public void testIsMakeEndPortals() { + assertFalse(s.isMakeEndPortals()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setMakeNetherPortals(boolean)}. + */ + @Test + public void testSetMakeNetherPortals() { + s.setMakeNetherPortals(false); + assertFalse(s.isMakeNetherPortals()); + s.setMakeNetherPortals(true); + assertTrue(s.isMakeNetherPortals()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setMakeEndPortals(boolean)}. + */ + @Test + public void testSetMakeEndPortals() { + s.setMakeEndPortals(false); + assertFalse(s.isMakeEndPortals()); + s.setMakeEndPortals(true); + assertTrue(s.isMakeEndPortals()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getPercentCompleteSymbol()}. + */ + @Test + public void testGetPercentCompleteSymbol() { + assertEquals("■", s.getPercentCompleteSymbol()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setPercentCompleteSymbol(java.lang.String)}. + */ + @Test + public void testSetPercentCompleteSymbol() { + assertEquals("■", s.getPercentCompleteSymbol()); + s.setPercentCompleteSymbol("#"); + assertEquals("#", s.getPercentCompleteSymbol()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getCountCommand()}. + */ + @Test + public void testGetCountCommand() { + assertEquals("count", s.getCountCommand()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setCountCommand(java.lang.String)}. + */ + @Test + public void testSetCountCommand() { + s.setCountCommand("count123"); + assertEquals("count123", s.getCountCommand()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getPhasesCommand()}. + */ + @Test + public void testGetPhasesCommand() { + assertEquals("phases", s.getPhasesCommand()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setPhasesCommand(java.lang.String)}. + */ + @Test + public void testSetPhasesCommand() { + s.setPhasesCommand("count123"); + assertEquals("count123", s.getPhasesCommand()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getSetCountCommand()}. + */ + @Test + public void testGetSetCountCommand() { + assertEquals("setCount", s.getSetCountCommand()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setSetCountCommand(java.lang.String)}. + */ + @Test + public void testSetSetCountCommand() { + s.setSetCountCommand("count123"); + assertEquals("count123", s.getSetCountCommand()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getRespawnBlockCommand()}. + */ + @Test + public void testGetRespawnBlockCommand() { + assertEquals("respawnBlock check", s.getRespawnBlockCommand()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setRespawnBlockCommand(java.lang.String)}. + */ + @Test + public void testSetRespawnBlockCommand() { + s.setRespawnBlockCommand("respawn"); + assertEquals("respawn", s.getRespawnBlockCommand()); + } + +} From c0fe375f0472e93bd02e530efe0ecd87f8186836 Mon Sep 17 00:00:00 2001 From: tastybento Date: Mon, 16 Jan 2023 09:28:27 -0800 Subject: [PATCH 19/43] Update to Apache Commons Addresses CVE-2022-42889 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3c3424e8..4a18b212 100644 --- a/pom.xml +++ b/pom.xml @@ -168,7 +168,7 @@ org.apache.commons commons-text - 1.9 + 1.10.0 compile From 96479f3a175e1e534437b32db77d6a1c845fb160 Mon Sep 17 00:00:00 2001 From: tastybento Date: Mon, 16 Jan 2023 09:29:15 -0800 Subject: [PATCH 20/43] Remove unused imports --- .../commands/island/IslandPhasesCommand.java | 9 --------- .../commands/island/IslandRespawnBlockCommand.java | 4 ++-- .../aoneblock/dataobjects/OneBlockIslands.java | 1 + .../oneblocks/OneBlockCustomBlockCreator.java | 4 ++-- .../aoneblock/oneblocks/OneBlocksManager.java | 12 +++++++++++- .../bentobox/aoneblock/oneblocks/Requirement.java | 2 ++ .../oneblocks/customblock/BlockDataCustomBlock.java | 9 +++++---- .../world/bentobox/aoneblock/panels/PhasesPanel.java | 11 ++++++++--- 8 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/main/java/world/bentobox/aoneblock/commands/island/IslandPhasesCommand.java b/src/main/java/world/bentobox/aoneblock/commands/island/IslandPhasesCommand.java index 88372603..e89e1a52 100644 --- a/src/main/java/world/bentobox/aoneblock/commands/island/IslandPhasesCommand.java +++ b/src/main/java/world/bentobox/aoneblock/commands/island/IslandPhasesCommand.java @@ -1,19 +1,10 @@ package world.bentobox.aoneblock.commands.island; -import java.util.Comparator; import java.util.List; -import java.util.Map; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; import world.bentobox.aoneblock.AOneBlock; import world.bentobox.aoneblock.panels.PhasesPanel; import world.bentobox.bentobox.api.commands.CompositeCommand; -import world.bentobox.bentobox.api.localization.TextVariables; -import world.bentobox.bentobox.api.panels.PanelItem; -import world.bentobox.bentobox.api.panels.builders.PanelBuilder; -import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder; import world.bentobox.bentobox.api.user.User; public class IslandPhasesCommand extends CompositeCommand { diff --git a/src/main/java/world/bentobox/aoneblock/commands/island/IslandRespawnBlockCommand.java b/src/main/java/world/bentobox/aoneblock/commands/island/IslandRespawnBlockCommand.java index 4fb2fdef..57b778d5 100644 --- a/src/main/java/world/bentobox/aoneblock/commands/island/IslandRespawnBlockCommand.java +++ b/src/main/java/world/bentobox/aoneblock/commands/island/IslandRespawnBlockCommand.java @@ -1,14 +1,14 @@ package world.bentobox.aoneblock.commands.island; +import java.util.List; + import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.Particle; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.util.Vector; -import java.util.List; -import world.bentobox.aoneblock.AOneBlock; import world.bentobox.bentobox.api.commands.CompositeCommand; import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.database.objects.Island; diff --git a/src/main/java/world/bentobox/aoneblock/dataobjects/OneBlockIslands.java b/src/main/java/world/bentobox/aoneblock/dataobjects/OneBlockIslands.java index 2f751745..f528d9da 100644 --- a/src/main/java/world/bentobox/aoneblock/dataobjects/OneBlockIslands.java +++ b/src/main/java/world/bentobox/aoneblock/dataobjects/OneBlockIslands.java @@ -3,6 +3,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; + import org.bukkit.entity.EntityType; import org.eclipse.jdt.annotation.NonNull; diff --git a/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockCustomBlockCreator.java b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockCustomBlockCreator.java index b14fae97..2d739021 100644 --- a/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockCustomBlockCreator.java +++ b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockCustomBlockCreator.java @@ -1,13 +1,13 @@ package world.bentobox.aoneblock.oneblocks; -import world.bentobox.aoneblock.oneblocks.customblock.BlockDataCustomBlock; - import java.util.LinkedHashMap; import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.Function; +import world.bentobox.aoneblock.oneblocks.customblock.BlockDataCustomBlock; + /** * A creator for {@link OneBlockCustomBlock} * diff --git a/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlocksManager.java b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlocksManager.java index f25c8ef1..b54e0fef 100644 --- a/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlocksManager.java +++ b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlocksManager.java @@ -3,8 +3,18 @@ import java.io.File; import java.io.FilenameFilter; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; import java.util.Map.Entry; +import java.util.NavigableMap; +import java.util.Objects; +import java.util.Optional; +import java.util.TreeMap; import java.util.jar.JarFile; import java.util.stream.Collectors; diff --git a/src/main/java/world/bentobox/aoneblock/oneblocks/Requirement.java b/src/main/java/world/bentobox/aoneblock/oneblocks/Requirement.java index ffb324de..a333eff0 100644 --- a/src/main/java/world/bentobox/aoneblock/oneblocks/Requirement.java +++ b/src/main/java/world/bentobox/aoneblock/oneblocks/Requirement.java @@ -1,5 +1,7 @@ package world.bentobox.aoneblock.oneblocks; +import world.bentobox.aoneblock.oneblocks.Requirement.ReqType; + /** * Requirement for finishing a phase * @author tastybento diff --git a/src/main/java/world/bentobox/aoneblock/oneblocks/customblock/BlockDataCustomBlock.java b/src/main/java/world/bentobox/aoneblock/oneblocks/customblock/BlockDataCustomBlock.java index 939e8a42..2b73215a 100644 --- a/src/main/java/world/bentobox/aoneblock/oneblocks/customblock/BlockDataCustomBlock.java +++ b/src/main/java/world/bentobox/aoneblock/oneblocks/customblock/BlockDataCustomBlock.java @@ -1,14 +1,15 @@ package world.bentobox.aoneblock.oneblocks.customblock; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + import org.bukkit.Bukkit; import org.bukkit.block.Block; + import world.bentobox.aoneblock.oneblocks.OneBlockCustomBlock; import world.bentobox.bentobox.BentoBox; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - /** * A custom block that is defined by a block data value. * diff --git a/src/main/java/world/bentobox/aoneblock/panels/PhasesPanel.java b/src/main/java/world/bentobox/aoneblock/panels/PhasesPanel.java index 9de27673..d3b8b8f4 100644 --- a/src/main/java/world/bentobox/aoneblock/panels/PhasesPanel.java +++ b/src/main/java/world/bentobox/aoneblock/panels/PhasesPanel.java @@ -6,15 +6,20 @@ package world.bentobox.aoneblock.panels; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import org.bukkit.Material; import org.bukkit.World; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; -import java.io.File; -import java.util.*; -import java.util.stream.Collectors; import world.bentobox.aoneblock.AOneBlock; import world.bentobox.aoneblock.dataobjects.OneBlockIslands; From e03fccdf906f2757f02ba97b9a586f2551504517 Mon Sep 17 00:00:00 2001 From: tastybento Date: Mon, 16 Jan 2023 09:32:28 -0800 Subject: [PATCH 21/43] Update API to use SpawnCaterogy settings --- .../java/world/bentobox/aoneblock/AOneBlock.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/world/bentobox/aoneblock/AOneBlock.java b/src/main/java/world/bentobox/aoneblock/AOneBlock.java index 8ffd3b9c..002d1dc8 100644 --- a/src/main/java/world/bentobox/aoneblock/AOneBlock.java +++ b/src/main/java/world/bentobox/aoneblock/AOneBlock.java @@ -8,6 +8,7 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.World.Environment; +import org.bukkit.entity.SpawnCategory; import org.bukkit.WorldCreator; import org.bukkit.WorldType; import org.bukkit.generator.ChunkGenerator; @@ -203,22 +204,22 @@ private World getWorld(String worldName2, Environment env, ChunkGeneratorWorld c private void setSpawnRates(World w) { if (getSettings().getSpawnLimitMonsters() > 0) { - w.setMonsterSpawnLimit(getSettings().getSpawnLimitMonsters()); + w.setSpawnLimit(SpawnCategory.MONSTER, getSettings().getSpawnLimitMonsters()); } if (getSettings().getSpawnLimitAmbient() > 0) { - w.setAmbientSpawnLimit(getSettings().getSpawnLimitAmbient()); + w.setSpawnLimit(SpawnCategory.AMBIENT, getSettings().getSpawnLimitAmbient()); } if (getSettings().getSpawnLimitAnimals() > 0) { - w.setAnimalSpawnLimit(getSettings().getSpawnLimitAnimals()); + w.setSpawnLimit(SpawnCategory.ANIMAL, getSettings().getSpawnLimitAnimals()); } if (getSettings().getSpawnLimitWaterAnimals() > 0) { - w.setWaterAnimalSpawnLimit(getSettings().getSpawnLimitWaterAnimals()); + w.setSpawnLimit(SpawnCategory.WATER_ANIMAL, getSettings().getSpawnLimitWaterAnimals()); } if (getSettings().getTicksPerAnimalSpawns() > 0) { - w.setTicksPerAnimalSpawns(getSettings().getTicksPerAnimalSpawns()); + w.setTicksPerSpawns(SpawnCategory.ANIMAL, getSettings().getTicksPerAnimalSpawns()); } if (getSettings().getTicksPerMonsterSpawns() > 0) { - w.setTicksPerMonsterSpawns(getSettings().getTicksPerMonsterSpawns()); + w.setTicksPerSpawns(SpawnCategory.MONSTER, getSettings().getTicksPerMonsterSpawns()); } } From 8f95247fdfcc787f3308d640c85f7f09d8458eef Mon Sep 17 00:00:00 2001 From: tastybento Date: Mon, 16 Jan 2023 09:33:57 -0800 Subject: [PATCH 22/43] Remove unused import --- .../java/world/bentobox/aoneblock/oneblocks/Requirement.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/world/bentobox/aoneblock/oneblocks/Requirement.java b/src/main/java/world/bentobox/aoneblock/oneblocks/Requirement.java index a333eff0..ffb324de 100644 --- a/src/main/java/world/bentobox/aoneblock/oneblocks/Requirement.java +++ b/src/main/java/world/bentobox/aoneblock/oneblocks/Requirement.java @@ -1,7 +1,5 @@ package world.bentobox.aoneblock.oneblocks; -import world.bentobox.aoneblock.oneblocks.Requirement.ReqType; - /** * Requirement for finishing a phase * @author tastybento From ffcab7927ab00348842b2007fe4511f10a110e22 Mon Sep 17 00:00:00 2001 From: tastybento Date: Thu, 26 Jan 2023 17:49:35 +0000 Subject: [PATCH 23/43] Added OneBlockIslands test class Created over Greenland, and now entering Canadian airspace. 11582m altitude. --- .../dataobjects/OneBlockIslands.java | 12 ++ .../dataobjects/OneBlockIslandsTest.java | 202 ++++++++++++++++++ 2 files changed, 214 insertions(+) create mode 100644 src/test/java/world/bentobox/aoneblock/dataobjects/OneBlockIslandsTest.java diff --git a/src/main/java/world/bentobox/aoneblock/dataobjects/OneBlockIslands.java b/src/main/java/world/bentobox/aoneblock/dataobjects/OneBlockIslands.java index f528d9da..364b99ce 100644 --- a/src/main/java/world/bentobox/aoneblock/dataobjects/OneBlockIslands.java +++ b/src/main/java/world/bentobox/aoneblock/dataobjects/OneBlockIslands.java @@ -137,10 +137,22 @@ public List getNearestMob(int i) { return getQueue().stream().limit(i).filter(OneBlockObject::isEntity).map(OneBlockObject::getEntityType).toList(); } + /** + * Adds a OneBlockObject to the queue + * @param nextBlock + */ public void add(OneBlockObject nextBlock) { getQueue().add(nextBlock); } + /** + * Retrieves and removes the head of the queue, or returns null if this queue is empty. + * Inserts the specified element into the queue if it is possible to do so immediately without + * violating capacity restrictions, and throwing an + * {@code IllegalStateException} if no space is currently available. + * @param toAdd OneBlockObject + * @return OneBlockObject head of the queue, or returns null if this queue is empty. + */ public OneBlockObject pollAndAdd(OneBlockObject toAdd) { getQueue(); OneBlockObject b = queue.poll(); diff --git a/src/test/java/world/bentobox/aoneblock/dataobjects/OneBlockIslandsTest.java b/src/test/java/world/bentobox/aoneblock/dataobjects/OneBlockIslandsTest.java new file mode 100644 index 00000000..0bed35f9 --- /dev/null +++ b/src/test/java/world/bentobox/aoneblock/dataobjects/OneBlockIslandsTest.java @@ -0,0 +1,202 @@ +package world.bentobox.aoneblock.dataobjects; + +import static org.junit.Assert.*; + +import java.util.List; +import java.util.Queue; +import java.util.UUID; + +import org.bukkit.entity.EntityType; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.modules.junit4.PowerMockRunner; + +import world.bentobox.aoneblock.oneblocks.OneBlockObject; + +/** + * @author tastybento + * + */ +@RunWith(PowerMockRunner.class) +public class OneBlockIslandsTest { + + private OneBlockIslands obi; + private String id; + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + id = UUID.randomUUID().toString(); + obi = new OneBlockIslands(id); + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + } + + /** + * Test method for {@link world.bentobox.aoneblock.dataobjects.OneBlockIslands#getPhaseName()}. + */ + @Test + public void testGetPhaseName() { + assertEquals("", obi.getPhaseName()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.dataobjects.OneBlockIslands#setPhaseName(java.lang.String)}. + */ + @Test + public void testSetPhaseName() { + obi.setPhaseName("test"); + assertEquals("test", obi.getPhaseName()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.dataobjects.OneBlockIslands#OneBlockIslands(java.lang.String)}. + */ + @Test + public void testOneBlockIslands() { + assertFalse(obi == null); + } + + /** + * Test method for {@link world.bentobox.aoneblock.dataobjects.OneBlockIslands#getBlockNumber()}. + */ + @Test + public void testGetBlockNumber() { + assertEquals(0, obi.getBlockNumber()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.dataobjects.OneBlockIslands#setBlockNumber(int)}. + */ + @Test + public void testSetBlockNumber() { + obi.setBlockNumber(1234); + assertEquals(1234, obi.getBlockNumber()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.dataobjects.OneBlockIslands#incrementBlockNumber()}. + */ + @Test + public void testIncrementBlockNumber() { + obi.incrementBlockNumber(); + assertEquals(1, obi.getBlockNumber()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.dataobjects.OneBlockIslands#getHologram()}. + */ + @Test + public void testGetHologram() { + assertEquals("", obi.getHologram()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.dataobjects.OneBlockIslands#setHologram(java.lang.String)}. + */ + @Test + public void testSetHologram() { + obi.setHologram("test"); + assertEquals("test",obi.getHologram()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.dataobjects.OneBlockIslands#getUniqueId()}. + */ + @Test + public void testGetUniqueId() { + assertEquals(id, obi.getUniqueId()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.dataobjects.OneBlockIslands#setUniqueId(java.lang.String)}. + */ + @Test + public void testSetUniqueId() { + String t = UUID.randomUUID().toString(); + obi.setUniqueId(t); + assertEquals(t, obi.getUniqueId()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.dataobjects.OneBlockIslands#getQueue()}. + */ + @Test + public void testGetQueue() { + Queue q = obi.getQueue(); + assertTrue(q.isEmpty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.dataobjects.OneBlockIslands#getNearestMob(int)}. + */ + @Test + public void testGetNearestMob() { + List l = obi.getNearestMob(10); + assertTrue(l.isEmpty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.dataobjects.OneBlockIslands#add(world.bentobox.aoneblock.oneblocks.OneBlockObject)}. + */ + @Test + public void testAdd() { + OneBlockObject obo = new OneBlockObject(EntityType.ALLAY, 50); + obi.add(obo); + Queue q = obi.getQueue(); + OneBlockObject ob = q.poll(); + assertEquals(obo, ob); + } + + /** + * Test method for {@link world.bentobox.aoneblock.dataobjects.OneBlockIslands#pollAndAdd(world.bentobox.aoneblock.oneblocks.OneBlockObject)}. + */ + @Test + public void testPollAndAdd() { + OneBlockObject obo = new OneBlockObject(EntityType.ALLAY, 50); + OneBlockObject ob = obi.pollAndAdd(obo); + assertNull(ob); + ob = obi.getQueue().poll(); + assertEquals(obo, ob); + + } + + /** + * Test method for {@link world.bentobox.aoneblock.dataobjects.OneBlockIslands#clearQueue()}. + */ + @Test + public void testClearQueue() { + OneBlockObject obo = new OneBlockObject(EntityType.ALLAY, 50); + obi.add(obo); + assertEquals(1, obi.getQueue().size()); + obi.clearQueue(); + assertEquals(0, obi.getQueue().size()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.dataobjects.OneBlockIslands#getLifetime()}. + */ + @Test + public void testGetLifetime() { + assertEquals(0L, obi.getLifetime()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.dataobjects.OneBlockIslands#setLifetime(long)}. + */ + @Test + public void testSetLifetime() { + obi.setLifetime(123456789L); + assertEquals(123456789L, obi.getLifetime()); + } + +} From edc5c74f8bfca33ee58d17c05c67fb3bc46a9fb9 Mon Sep 17 00:00:00 2001 From: tastybento Date: Thu, 26 Jan 2023 19:18:50 +0000 Subject: [PATCH 24/43] Added BlockProtect test class Altitude 12912m; north-west edge of Hudson Bay, Canada 924 km/h --- .../aoneblock/listeners/BlockProtect.java | 4 +- .../aoneblock/listeners/BlockProtectTest.java | 350 ++++++++++++++++++ 2 files changed, 352 insertions(+), 2 deletions(-) create mode 100644 src/test/java/world/bentobox/aoneblock/listeners/BlockProtectTest.java diff --git a/src/main/java/world/bentobox/aoneblock/listeners/BlockProtect.java b/src/main/java/world/bentobox/aoneblock/listeners/BlockProtect.java index d4a44861..08486d44 100644 --- a/src/main/java/world/bentobox/aoneblock/listeners/BlockProtect.java +++ b/src/main/java/world/bentobox/aoneblock/listeners/BlockProtect.java @@ -67,7 +67,7 @@ public void onBlockChange(final EntityChangeBlockEvent e) { */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onExplosion(final EntityExplodeEvent e) { - if (!addon.inWorld(e.getEntity().getWorld())) { + if (!addon.inWorld(e.getLocation().getWorld())) { return; } e.blockList().removeIf(b -> addon.getIslands().getIslandAt(b.getLocation()).filter(i -> b.getLocation().equals(i.getCenter())).isPresent()); @@ -86,7 +86,7 @@ public void onPistonExtend(BlockPistonExtendEvent e) { * @param e - BlockPistonRetractEvent */ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onPistonExtend(BlockPistonRetractEvent e) { + public void onPistonRetract(BlockPistonRetractEvent e) { checkPiston(e, e.getBlock(), e.getBlocks()); } private void checkPiston(Cancellable e, Block block, List blocks) { diff --git a/src/test/java/world/bentobox/aoneblock/listeners/BlockProtectTest.java b/src/test/java/world/bentobox/aoneblock/listeners/BlockProtectTest.java new file mode 100644 index 00000000..41cc70ef --- /dev/null +++ b/src/test/java/world/bentobox/aoneblock/listeners/BlockProtectTest.java @@ -0,0 +1,350 @@ +package world.bentobox.aoneblock.listeners; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyDouble; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Particle; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.BlockData; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockDamageEvent; +import org.bukkit.event.block.BlockPistonExtendEvent; +import org.bukkit.event.block.BlockPistonRetractEvent; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.inventory.ItemStack; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.powermock.modules.junit4.PowerMockRunner; + +import world.bentobox.aoneblock.AOneBlock; +import world.bentobox.bentobox.database.objects.Island; +import world.bentobox.bentobox.managers.IslandsManager; + +/** + * @author bengibbs + * + */ +@RunWith(PowerMockRunner.class) +public class BlockProtectTest { + + private BlockProtect bp; + @Mock + AOneBlock addon; + @Mock + private Player p; + @Mock + private Block block; + @Mock + private World world; + @Mock + private Location location; + @Mock + private IslandsManager im; + @Mock + private Island island; + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + // In World + when(addon.inWorld(eq(world))).thenReturn(true); + + // Location + when(location.getWorld()).thenReturn(world); + + // Block + when(block.getWorld()).thenReturn(world); + when(block.getLocation()).thenReturn(location); + + // Island Manager + when(addon.getIslands()).thenReturn(im); + when(island.getCenter()).thenReturn(location); + when(im.getIslandAt(any())).thenReturn(Optional.of(island)); + + // Class under test + bp = new BlockProtect(addon); + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.BlockProtect#BlockProtect(world.bentobox.aoneblock.AOneBlock)}. + */ + @Test + public void testBlockProtect() { + assertFalse(bp == null); + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.BlockProtect#onBlockDamage(org.bukkit.event.block.BlockDamageEvent)}. + */ + @Test + public void testOnBlockDamage() { + ItemStack item = new ItemStack(Material.DIAMOND_PICKAXE); + BlockDamageEvent blockDamageEvent = new BlockDamageEvent(p, block, item, false); + bp.onBlockDamage(blockDamageEvent); + verify(addon).inWorld(world); + verify(im).getIslandAt(location); + verify(world).spawnParticle(eq(Particle.REDSTONE), eq(null), eq(5), + eq(0.1D), eq(0D), eq(0.1D), eq(1D), any(Particle.DustOptions.class)); + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.BlockProtect#onBlockDamage(org.bukkit.event.block.BlockDamageEvent)}. + */ + @Test + public void testOnBlockDamageWrongWorld() { + when(block.getWorld()).thenReturn(mock(World.class)); + ItemStack item = new ItemStack(Material.DIAMOND_PICKAXE); + BlockDamageEvent blockDamageEvent = new BlockDamageEvent(p, block, item, false); + bp.onBlockDamage(blockDamageEvent); + verify(im, never()).getIslandAt(location); + verify(world, never()).spawnParticle(any(Particle.class), any(Location.class),anyInt(), + anyDouble(), anyDouble(), anyDouble(), anyDouble(), any()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.BlockProtect#onBlockDamage(org.bukkit.event.block.BlockDamageEvent)}. + */ + @Test + public void testOnBlockDamageNotCenterMagicBlock() { + when(block.getLocation()).thenReturn(mock(Location.class)); + ItemStack item = new ItemStack(Material.DIAMOND_PICKAXE); + BlockDamageEvent blockDamageEvent = new BlockDamageEvent(p, block, item, false); + bp.onBlockDamage(blockDamageEvent); + verify(addon).inWorld(world); + verify(im).getIslandAt(any(Location.class)); + verify(world, never()).spawnParticle(any(Particle.class), any(Location.class),anyInt(), + anyDouble(), anyDouble(), anyDouble(), anyDouble(), any()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.BlockProtect#onBlockChange(org.bukkit.event.entity.EntityChangeBlockEvent)}. + */ + @Test + public void testOnBlockChange() { + BlockData blockData = mock(BlockData.class); + EntityChangeBlockEvent event = new EntityChangeBlockEvent(p, block, blockData); + bp.onBlockChange(event); + assertTrue(event.isCancelled()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.BlockProtect#onBlockChange(org.bukkit.event.entity.EntityChangeBlockEvent)}. + */ + @Test + public void testOnBlockChangeWrongWorld() { + when(block.getWorld()).thenReturn(mock(World.class)); + BlockData blockData = mock(BlockData.class); + EntityChangeBlockEvent event = new EntityChangeBlockEvent(p, block, blockData); + bp.onBlockChange(event); + assertFalse(event.isCancelled()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.BlockProtect#onBlockChange(org.bukkit.event.entity.EntityChangeBlockEvent)}. + */ + @Test + public void testOnBlockChangeNotMagicBlock() { + when(block.getLocation()).thenReturn(mock(Location.class)); + BlockData blockData = mock(BlockData.class); + EntityChangeBlockEvent event = new EntityChangeBlockEvent(p, block, blockData); + bp.onBlockChange(event); + assertFalse(event.isCancelled()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.BlockProtect#onExplosion(org.bukkit.event.entity.EntityExplodeEvent)}. + */ + @Test + public void testOnExplosion() { + List blocks = new ArrayList<>(); + EntityExplodeEvent event = new EntityExplodeEvent(p, location, blocks, 0); + bp.onExplosion(event); + assertTrue(blocks.isEmpty()); + // Add the magic block + blocks.add(block); + // Magic block does not get blown up so it is removed + bp.onExplosion(event); + assertTrue(blocks.isEmpty()); + // Normal blocks remain + Block b = mock(Block.class); + when(b.getLocation()).thenReturn(mock(Location.class)); + blocks.add(b); + bp.onExplosion(event); + assertFalse(blocks.isEmpty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.BlockProtect#onExplosion(org.bukkit.event.entity.EntityExplodeEvent)}. + */ + @Test + public void testOnExplosionWrongWorld() { + when(location.getWorld()).thenReturn(mock(World.class)); + List blocks = new ArrayList<>(); + EntityExplodeEvent event = new EntityExplodeEvent(p, location, blocks, 0); + blocks.add(block); + // Block as correct location, but wrong world + bp.onExplosion(event); + assertFalse(blocks.isEmpty()); + // Normal blocks remain + blocks.add(mock(Block.class)); + event = new EntityExplodeEvent(p, location, blocks, 0); + bp.onExplosion(event); + assertFalse(blocks.isEmpty()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.BlockProtect#onPistonExtend(org.bukkit.event.block.BlockPistonExtendEvent)}. + */ + @Test + public void testOnPistonExtendBlockPistonExtendEvent() { + List blocks = new ArrayList<>(); + BlockPistonExtendEvent event = new BlockPistonExtendEvent(block, blocks, BlockFace.EAST); + bp.onPistonExtend(event); + assertFalse(event.isCancelled()); + blocks.add(block); + bp.onPistonExtend(event); + assertTrue(event.isCancelled()); + + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.BlockProtect#onPistonExtend(org.bukkit.event.block.BlockPistonExtendEvent)}. + */ + @Test + public void testOnPistonExtendBlockPistonExtendEventWrongWorld() { + when(block.getWorld()).thenReturn(mock(World.class)); + List blocks = new ArrayList<>(); + BlockPistonExtendEvent event = new BlockPistonExtendEvent(block, blocks, BlockFace.EAST); + bp.onPistonExtend(event); + assertFalse(event.isCancelled()); + blocks.add(block); + bp.onPistonExtend(event); + assertFalse(event.isCancelled()); + + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.BlockProtect#onPistonRetract(BlockPistonRetractEvent)}. + */ + @Test + public void testOnPistonBlockPistonRetractEvent() { + List blocks = new ArrayList<>(); + BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, blocks, BlockFace.EAST); + bp.onPistonRetract(event); + assertFalse(event.isCancelled()); + blocks.add(block); + bp.onPistonRetract(event); + assertTrue(event.isCancelled()); + + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.BlockProtect#onPistonRetract(BlockPistonRetractEvent)}. + */ + @Test + public void testOnPistonBlockPistonRetractEventWrongWorld() { + when(block.getWorld()).thenReturn(mock(World.class)); + List blocks = new ArrayList<>(); + BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, blocks, BlockFace.EAST); + bp.onPistonRetract(event); + assertFalse(event.isCancelled()); + blocks.add(block); + bp.onPistonRetract(event); + assertFalse(event.isCancelled()); + + } + + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.BlockProtect#onFallingBlockSpawn(org.bukkit.event.entity.EntitySpawnEvent)}. + */ + @Test + public void testOnFallingBlockSpawn() { + Entity fallingBlock = mock(Entity.class); + when(fallingBlock.getLocation()).thenReturn(location); + when(fallingBlock.getType()).thenReturn(EntityType.FALLING_BLOCK); + when(fallingBlock.getWorld()).thenReturn(world); + EntitySpawnEvent event = new EntitySpawnEvent(fallingBlock); + bp.onFallingBlockSpawn(event); + assertTrue(event.isCancelled()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.BlockProtect#onFallingBlockSpawn(org.bukkit.event.entity.EntitySpawnEvent)}. + */ + @Test + public void testOnFallingBlockSpawnWrongWorld() { + Entity fallingBlock = mock(Entity.class); + when(fallingBlock.getLocation()).thenReturn(location); + when(fallingBlock.getType()).thenReturn(EntityType.FALLING_BLOCK); + when(fallingBlock.getWorld()).thenReturn(mock(World.class)); + EntitySpawnEvent event = new EntitySpawnEvent(fallingBlock); + bp.onFallingBlockSpawn(event); + assertFalse(event.isCancelled()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.BlockProtect#onFallingBlockSpawn(org.bukkit.event.entity.EntitySpawnEvent)}. + */ + @Test + public void testOnFallingBlockSpawnNotFallingBlock() { + Entity fallingBlock = mock(Entity.class); + when(fallingBlock.getLocation()).thenReturn(location); + when(fallingBlock.getType()).thenReturn(EntityType.AREA_EFFECT_CLOUD); + when(fallingBlock.getWorld()).thenReturn(world); + EntitySpawnEvent event = new EntitySpawnEvent(fallingBlock); + bp.onFallingBlockSpawn(event); + assertFalse(event.isCancelled()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.BlockProtect#onFallingBlockSpawn(org.bukkit.event.entity.EntitySpawnEvent)}. + */ + @Test + public void testOnFallingBlockSpawnWrongLocation() { + Entity fallingBlock = mock(Entity.class); + Location l = mock(Location.class); + when(l.getWorld()).thenReturn(world); + when(l.getBlockX()).thenReturn(1234); // not center + when(fallingBlock.getLocation()).thenReturn(l); + when(fallingBlock.getType()).thenReturn(EntityType.FALLING_BLOCK); + when(fallingBlock.getWorld()).thenReturn(world); + EntitySpawnEvent event = new EntitySpawnEvent(fallingBlock); + bp.onFallingBlockSpawn(event); + assertFalse(event.isCancelled()); + } + +} From 4887c54182961813a93dc246143d5390e379e057 Mon Sep 17 00:00:00 2001 From: tastybento Date: Thu, 26 Jan 2023 19:19:17 +0000 Subject: [PATCH 25/43] Remove unused imports --- .../world/bentobox/aoneblock/listeners/BlockProtectTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/world/bentobox/aoneblock/listeners/BlockProtectTest.java b/src/test/java/world/bentobox/aoneblock/listeners/BlockProtectTest.java index 41cc70ef..25904fd6 100644 --- a/src/test/java/world/bentobox/aoneblock/listeners/BlockProtectTest.java +++ b/src/test/java/world/bentobox/aoneblock/listeners/BlockProtectTest.java @@ -2,7 +2,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyDouble; import static org.mockito.ArgumentMatchers.anyInt; From 0f8deb9b401df48b936749294fcb4894d311ae49 Mon Sep 17 00:00:00 2001 From: tastybento Date: Thu, 26 Jan 2023 19:42:55 +0000 Subject: [PATCH 26/43] Added JoinLeaveListener test class 12191 m, 935 km/h; near Arviat, Canada. --- .../listeners/JoinLeaveListener.java | 3 +- .../listeners/JoinLeaveListenerTest.java | 133 ++++++++++++++++++ 2 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 src/test/java/world/bentobox/aoneblock/listeners/JoinLeaveListenerTest.java diff --git a/src/main/java/world/bentobox/aoneblock/listeners/JoinLeaveListener.java b/src/main/java/world/bentobox/aoneblock/listeners/JoinLeaveListener.java index 275658da..e0b2978b 100644 --- a/src/main/java/world/bentobox/aoneblock/listeners/JoinLeaveListener.java +++ b/src/main/java/world/bentobox/aoneblock/listeners/JoinLeaveListener.java @@ -14,6 +14,7 @@ public class JoinLeaveListener implements Listener { final AOneBlock addon; /** + * Save island on player quitting * @param addon - AOneBlock */ public JoinLeaveListener(AOneBlock addon) { @@ -21,7 +22,7 @@ public JoinLeaveListener(AOneBlock addon) { } /** - * Show particles when block is hit + * Save island on player quitting * @param e - event */ @EventHandler(priority = EventPriority.NORMAL) diff --git a/src/test/java/world/bentobox/aoneblock/listeners/JoinLeaveListenerTest.java b/src/test/java/world/bentobox/aoneblock/listeners/JoinLeaveListenerTest.java new file mode 100644 index 00000000..888b1306 --- /dev/null +++ b/src/test/java/world/bentobox/aoneblock/listeners/JoinLeaveListenerTest.java @@ -0,0 +1,133 @@ +package world.bentobox.aoneblock.listeners; + +import static org.junit.Assert.assertFalse; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.UUID; +import java.util.concurrent.CompletableFuture; + +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.util.Vector; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.powermock.modules.junit4.PowerMockRunner; + +import world.bentobox.aoneblock.AOneBlock; +import world.bentobox.bentobox.database.objects.Island; +import world.bentobox.bentobox.managers.IslandsManager; + +/** + * @author bengibbs + * @PrepareForTest( {Util.class} ) + */ +@RunWith(PowerMockRunner.class) +public class JoinLeaveListenerTest { + + @Mock + private AOneBlock aob; + @Mock + private Player p; + + private JoinLeaveListener jll; + @Mock + private BlockListener bl; + @Mock + private Location location; + @Mock + private IslandsManager im; + @Mock + private Island island; + @Mock + private World world; + + private static final UUID ID = UUID.randomUUID(); + private static final Vector VECTOR = new Vector(123,120,456); + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + + when(aob.getOverWorld()).thenReturn(world); + // Player + when(p.getUniqueId()).thenReturn(ID); + + // Island + when(island.getCenter()).thenReturn(location); + when(location.toVector()).thenReturn(VECTOR); + + // Island Manager + when(aob.getIslands()).thenReturn(im); + when(island.getCenter()).thenReturn(location); + when(im.getIsland(world, ID)).thenReturn(island); + + // Save is successful + when(bl.saveIsland(any())).thenReturn(CompletableFuture.completedFuture(Boolean.TRUE)); + when(aob.getBlockListener()).thenReturn(bl); + jll = new JoinLeaveListener(aob); + + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.JoinLeaveListener#JoinLeaveListener(world.bentobox.aoneblock.AOneBlock)}. + */ + @Test + public void testJoinLeaveListener() { + assertFalse(jll == null); + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.JoinLeaveListener#onPlayerQuit(org.bukkit.event.player.PlayerQuitEvent)}. + */ + @Test + public void testOnPlayerQuit() { + PlayerQuitEvent event = new PlayerQuitEvent(p, "nothing"); + jll.onPlayerQuit(event); + verify(aob,never()).logError(anyString()); + verify(bl).saveIsland(island); + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.JoinLeaveListener#onPlayerQuit(org.bukkit.event.player.PlayerQuitEvent)}. + */ + @Test + public void testOnPlayerQuitNoIsland() { + when(im.getIsland(world, ID)).thenReturn(null); + PlayerQuitEvent event = new PlayerQuitEvent(p, "nothing"); + jll.onPlayerQuit(event); + verify(aob,never()).logError(anyString()); + verify(bl, never()).saveIsland(island); + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.JoinLeaveListener#onPlayerQuit(org.bukkit.event.player.PlayerQuitEvent)}. + */ + @Test + public void testOnPlayerQuitSaveError() { + when(bl.saveIsland(any())).thenReturn(CompletableFuture.completedFuture(Boolean.FALSE)); + PlayerQuitEvent event = new PlayerQuitEvent(p, "nothing"); + jll.onPlayerQuit(event); + verify(aob).logError(anyString()); + verify(bl).saveIsland(island); + verify(aob).logError(eq("Could not save AOneBlock island at 123,120,456 to database null")); + } + +} From b22c88f0de45e757c587c9e15be2c1d9c8a9413e Mon Sep 17 00:00:00 2001 From: tastybento Date: Thu, 26 Jan 2023 19:45:59 +0000 Subject: [PATCH 27/43] Clean up --- .../aoneblock/listeners/BlockProtectTest.java | 2 +- .../listeners/JoinLeaveListenerTest.java | 3 +- .../listeners/NoBlockHandlerTest.java | 48 +++++++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 src/test/java/world/bentobox/aoneblock/listeners/NoBlockHandlerTest.java diff --git a/src/test/java/world/bentobox/aoneblock/listeners/BlockProtectTest.java b/src/test/java/world/bentobox/aoneblock/listeners/BlockProtectTest.java index 25904fd6..4ca4def6 100644 --- a/src/test/java/world/bentobox/aoneblock/listeners/BlockProtectTest.java +++ b/src/test/java/world/bentobox/aoneblock/listeners/BlockProtectTest.java @@ -44,7 +44,7 @@ import world.bentobox.bentobox.managers.IslandsManager; /** - * @author bengibbs + * @author tastybento * */ @RunWith(PowerMockRunner.class) diff --git a/src/test/java/world/bentobox/aoneblock/listeners/JoinLeaveListenerTest.java b/src/test/java/world/bentobox/aoneblock/listeners/JoinLeaveListenerTest.java index 888b1306..b7b23cf4 100644 --- a/src/test/java/world/bentobox/aoneblock/listeners/JoinLeaveListenerTest.java +++ b/src/test/java/world/bentobox/aoneblock/listeners/JoinLeaveListenerTest.java @@ -28,8 +28,7 @@ import world.bentobox.bentobox.managers.IslandsManager; /** - * @author bengibbs - * @PrepareForTest( {Util.class} ) + * @author tastybento */ @RunWith(PowerMockRunner.class) public class JoinLeaveListenerTest { diff --git a/src/test/java/world/bentobox/aoneblock/listeners/NoBlockHandlerTest.java b/src/test/java/world/bentobox/aoneblock/listeners/NoBlockHandlerTest.java new file mode 100644 index 00000000..c026cc3c --- /dev/null +++ b/src/test/java/world/bentobox/aoneblock/listeners/NoBlockHandlerTest.java @@ -0,0 +1,48 @@ +/** + * + */ +package world.bentobox.aoneblock.listeners; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * @author tastybento + * + */ +public class NoBlockHandlerTest { + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.NoBlockHandler#NoBlockHandler(world.bentobox.aoneblock.AOneBlock)}. + */ + @Test + public void testNoBlockHandler() { + fail("Not yet implemented"); + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.NoBlockHandler#onRespawn(org.bukkit.event.player.PlayerRespawnEvent)}. + */ + @Test + public void testOnRespawn() { + fail("Not yet implemented"); + } + +} From 47be579e662843938cdf8626ca4b92f82cffbba0 Mon Sep 17 00:00:00 2001 From: tastybento Date: Thu, 26 Jan 2023 20:01:12 +0000 Subject: [PATCH 28/43] Added NoBlockHandler test class. --- .../listeners/NoBlockHandlerTest.java | 118 ++++++++++++++++-- 1 file changed, 111 insertions(+), 7 deletions(-) diff --git a/src/test/java/world/bentobox/aoneblock/listeners/NoBlockHandlerTest.java b/src/test/java/world/bentobox/aoneblock/listeners/NoBlockHandlerTest.java index c026cc3c..0993cdbe 100644 --- a/src/test/java/world/bentobox/aoneblock/listeners/NoBlockHandlerTest.java +++ b/src/test/java/world/bentobox/aoneblock/listeners/NoBlockHandlerTest.java @@ -1,25 +1,87 @@ -/** - * - */ package world.bentobox.aoneblock.listeners; -import static org.junit.Assert.*; +import static org.junit.Assert.assertFalse; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.UUID; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerRespawnEvent; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.powermock.modules.junit4.PowerMockRunner; + +import world.bentobox.aoneblock.AOneBlock; +import world.bentobox.bentobox.database.objects.Island; +import world.bentobox.bentobox.managers.IslandsManager; /** * @author tastybento * */ +@RunWith(PowerMockRunner.class) public class NoBlockHandlerTest { + + private static final UUID ID = UUID.randomUUID(); + + @Mock + private AOneBlock aob; + @Mock + private Player p; + + private NoBlockHandler nbh; + + @Mock + private Block block; + @Mock + private BlockListener bl; + @Mock + private Location location; + @Mock + private IslandsManager im; + @Mock + private Island island; + @Mock + private World world; + /** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { + // Player + when(p.getUniqueId()).thenReturn(ID); + + // In world + when(aob.inWorld(world)).thenReturn(true); + + // Location + when(location.getWorld()).thenReturn(world); + + // Block + when(location.getBlock()).thenReturn(block); + when(block.isEmpty()).thenReturn(false); + + // Island + when(island.getCenter()).thenReturn(location); + + // Island Manager + when(aob.getIslands()).thenReturn(im); + when(island.getCenter()).thenReturn(location); + when(im.getIsland(world, ID)).thenReturn(island); + + nbh = new NoBlockHandler(aob); } /** @@ -34,15 +96,57 @@ public void tearDown() throws Exception { */ @Test public void testNoBlockHandler() { - fail("Not yet implemented"); + assertFalse(nbh == null); } /** * Test method for {@link world.bentobox.aoneblock.listeners.NoBlockHandler#onRespawn(org.bukkit.event.player.PlayerRespawnEvent)}. */ @Test - public void testOnRespawn() { - fail("Not yet implemented"); + public void testOnRespawnSolidBlock() { + PlayerRespawnEvent event = new PlayerRespawnEvent(p, location, false, false); + nbh.onRespawn(event); + verify(block, never()).setType(any(Material.class)); + + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.NoBlockHandler#onRespawn(org.bukkit.event.player.PlayerRespawnEvent)}. + */ + @Test + public void testOnRespawnAirBlock() { + when(block.isEmpty()).thenReturn(true); + PlayerRespawnEvent event = new PlayerRespawnEvent(p, location, false, false); + nbh.onRespawn(event); + verify(block).setType(any(Material.class)); + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.NoBlockHandler#onRespawn(org.bukkit.event.player.PlayerRespawnEvent)}. + */ + @Test + public void testOnRespawnAirBlockWrongWorld() { + when(aob.inWorld(world)).thenReturn(false); + when(block.isEmpty()).thenReturn(true); + PlayerRespawnEvent event = new PlayerRespawnEvent(p, location, false, false); + nbh.onRespawn(event); + verify(block, never()).setType(any(Material.class)); + + } + + /** + * Test method for {@link world.bentobox.aoneblock.listeners.NoBlockHandler#onRespawn(org.bukkit.event.player.PlayerRespawnEvent)}. + */ + @Test + public void testOnRespawnAirBlockNoIsland() { + when(im.getIsland(world, ID)).thenReturn(null); + when(block.isEmpty()).thenReturn(true); + PlayerRespawnEvent event = new PlayerRespawnEvent(p, location, false, false); + nbh.onRespawn(event); + verify(block, never()).setType(any(Material.class)); + + } + } From 0411012d13e8b1740486e526edfc68ee91574e97 Mon Sep 17 00:00:00 2001 From: tastybento Date: Fri, 27 Jan 2023 10:42:11 -0800 Subject: [PATCH 29/43] Added AOneBlock test class. --- .../world/bentobox/aoneblock/AOneBlock.java | 30 +- .../bentobox/aoneblock/AOneBlockTest.java | 343 ++++++++++++++++++ 2 files changed, 359 insertions(+), 14 deletions(-) create mode 100644 src/test/java/world/bentobox/aoneblock/AOneBlockTest.java diff --git a/src/main/java/world/bentobox/aoneblock/AOneBlock.java b/src/main/java/world/bentobox/aoneblock/AOneBlock.java index 002d1dc8..eb9d7116 100644 --- a/src/main/java/world/bentobox/aoneblock/AOneBlock.java +++ b/src/main/java/world/bentobox/aoneblock/AOneBlock.java @@ -97,12 +97,26 @@ public void onEnable() { setState(State.DISABLED); return; } - registerListener(blockListener); registerListener(new NoBlockHandler(this)); registerListener(new BlockProtect(this)); registerListener(new JoinLeaveListener(this)); // Register placeholders + registerPlaceholders(); + + // Register request handlers + registerRequestHandler(new IslandStatsHandler(this)); + registerRequestHandler(new LocationStatsHandler(this)); + + // Decide if HolographicDisplays is Usable + useHolographicDisplays = Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays"); + if (this.useHolographicDisplays) { + holoListener = new HoloListener(this); + registerListener(holoListener); + } + } + + private void registerPlaceholders() { phManager = new PlaceholdersManager(this); getPlugin().getPlaceholdersManager().registerPlaceholder(this, "visited_island_phase", phManager::getPhaseByLocation); getPlugin().getPlaceholdersManager().registerPlaceholder(this, "visited_island_count", phManager::getCountByLocation); @@ -116,21 +130,9 @@ public void onEnable() { getPlugin().getPlaceholdersManager().registerPlaceholder(this, "visited_island_percent_done", phManager::getPercentDoneByLocation); getPlugin().getPlaceholdersManager().registerPlaceholder(this, "my_island_done_scale", phManager::getDoneScale); getPlugin().getPlaceholdersManager().registerPlaceholder(this, "visited_island_done_scale", phManager::getDoneScaleByLocation); - // Since 1.10 getPlugin().getPlaceholdersManager().registerPlaceholder(this, "visited_island_lifetime_count", phManager::getLifetimeByLocation); - getPlugin().getPlaceholdersManager().registerPlaceholder(this, "my_island_lifetime_count", phManager::getLifetime); - - // Register request handlers - registerRequestHandler(new IslandStatsHandler(this)); - registerRequestHandler(new LocationStatsHandler(this)); - - // Decide if HolographicDisplays is Usable - useHolographicDisplays = Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays"); - if (this.useHolographicDisplays) { - holoListener = new HoloListener(this); - registerListener(holoListener); - } + getPlugin().getPlaceholdersManager().registerPlaceholder(this, "my_island_lifetime_count", phManager::getLifetime); } @Override diff --git a/src/test/java/world/bentobox/aoneblock/AOneBlockTest.java b/src/test/java/world/bentobox/aoneblock/AOneBlockTest.java new file mode 100644 index 00000000..73664358 --- /dev/null +++ b/src/test/java/world/bentobox/aoneblock/AOneBlockTest.java @@ -0,0 +1,343 @@ +package world.bentobox.aoneblock; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collections; +import java.util.Comparator; +import java.util.UUID; +import java.util.jar.JarEntry; +import java.util.jar.JarOutputStream; +import java.util.logging.Logger; + +import org.bukkit.Bukkit; +import org.bukkit.Server; +import org.bukkit.entity.Player; +import org.bukkit.plugin.PluginManager; +import org.eclipse.jdt.annotation.NonNull; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.stubbing.Answer; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.reflect.Whitebox; + +import world.bentobox.aoneblock.dataobjects.OneBlockIslands; +import world.bentobox.bentobox.BentoBox; +import world.bentobox.bentobox.Settings; +import world.bentobox.bentobox.api.addons.Addon.State; +import world.bentobox.bentobox.api.addons.AddonDescription; +import world.bentobox.bentobox.api.configuration.Config; +import world.bentobox.bentobox.api.user.User; +import world.bentobox.bentobox.database.DatabaseSetup.DatabaseType; +import world.bentobox.bentobox.database.objects.Island; +import world.bentobox.bentobox.managers.AddonsManager; +import world.bentobox.bentobox.managers.CommandsManager; +import world.bentobox.bentobox.managers.FlagsManager; +import world.bentobox.bentobox.managers.IslandWorldManager; +import world.bentobox.bentobox.managers.IslandsManager; +import world.bentobox.bentobox.managers.PlaceholdersManager; + +/** + * @author tastybento + * + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({Bukkit.class, BentoBox.class, User.class, Config.class }) +public class AOneBlockTest { + + @Mock + private User user; + @Mock + private IslandsManager im; + @Mock + private Island island; + + private AOneBlock addon; + @Mock + private BentoBox plugin; + @Mock + private FlagsManager fm; + @Mock + private Settings settings; + @Mock + private PlaceholdersManager phm; + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + // Set up plugin + Whitebox.setInternalState(BentoBox.class, "instance", plugin); + when(plugin.getLogger()).thenReturn(Logger.getAnonymousLogger()); + + // The database type has to be created one line before the thenReturn() to work! + DatabaseType value = DatabaseType.JSON; + when(plugin.getSettings()).thenReturn(settings); + when(settings.getDatabaseType()).thenReturn(value); + when(plugin.getPlaceholdersManager()).thenReturn(phm); + // Placeholders + when(phm.replacePlaceholders(any(), anyString())).thenAnswer(a -> (String)a.getArgument(1, String.class)); + + + // Command manager + CommandsManager cm = mock(CommandsManager.class); + when(plugin.getCommandsManager()).thenReturn(cm); + + // Player + Player p = mock(Player.class); + // Sometimes use Mockito.withSettings().verboseLogging() + when(user.isOp()).thenReturn(false); + UUID uuid = UUID.randomUUID(); + when(user.getUniqueId()).thenReturn(uuid); + when(user.getPlayer()).thenReturn(p); + when(user.getName()).thenReturn("tastybento"); + User.setPlugin(plugin); + + // Island World Manager + IslandWorldManager iwm = mock(IslandWorldManager.class); + when(plugin.getIWM()).thenReturn(iwm); + + + // Player has island to begin with + island = mock(Island.class); + when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(island); + when(plugin.getIslands()).thenReturn(im); + + // Locales + // Return the reference (USE THIS IN THE FUTURE) + when(user.getTranslation(Mockito.anyString())).thenAnswer((Answer) invocation -> invocation.getArgument(0, String.class)); + + // Server + PowerMockito.mockStatic(Bukkit.class); + Server server = mock(Server.class); + when(Bukkit.getServer()).thenReturn(server); + when(Bukkit.getLogger()).thenReturn(Logger.getAnonymousLogger()); + when(Bukkit.getPluginManager()).thenReturn(mock(PluginManager.class)); + + // Create an Addon + addon = new AOneBlock(); + File jFile = new File("addon.jar"); + try (JarOutputStream tempJarOutputStream = new JarOutputStream(new FileOutputStream(jFile))) { + + // Copy over config file from src folder + Path fromPath = Paths.get("src/main/resources/config.yml"); + Path path = Paths.get("config.yml"); + Files.copy(fromPath, path); + + //Add the new files to the jar. + add(path, tempJarOutputStream); + + // Copy over panels file from src folder + fromPath = Paths.get("src/main/resources/panels/phases_panel.yml"); + path = Paths.get("panels"); + Files.createDirectory(path); + path = Paths.get("panels/phases_panel.yml"); + Files.copy(fromPath, path); + + //Add the new files to the jar. + add(path, tempJarOutputStream); + } + + File dataFolder = new File("addons/AOneBlock"); + addon.setDataFolder(dataFolder); + addon.setFile(jFile); + AddonDescription desc = new AddonDescription.Builder("bentobox", "aoneblock", "1.3").description("test").authors("tasty").build(); + addon.setDescription(desc); + // Addons manager + AddonsManager am = mock(AddonsManager.class); + when(plugin.getAddonsManager()).thenReturn(am); + + // Flags manager + when(plugin.getFlagsManager()).thenReturn(fm); + when(fm.getFlags()).thenReturn(Collections.emptyList()); + + + } + + private void add(Path path, JarOutputStream tempJarOutputStream) throws FileNotFoundException, IOException { + try (FileInputStream fis = new FileInputStream(path.toFile())) { + byte[] buffer = new byte[1024]; + int bytesRead = 0; + JarEntry entry = new JarEntry(path.toString()); + tempJarOutputStream.putNextEntry(entry); + while((bytesRead = fis.read(buffer)) != -1) { + tempJarOutputStream.write(buffer, 0, bytesRead); + } + } + + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + //new File("addon.jar").delete(); + new File("config.yml").delete(); + deleteAll(new File("addons")); + deleteAll(new File("panels")); + } + + private void deleteAll(File file) throws IOException { + if (file.exists()) { + Files.walk(file.toPath()) + .sorted(Comparator.reverseOrder()) + .map(Path::toFile) + .forEach(File::delete); + } + + } + + + /** + * Test method for {@link world.bentobox.aoneblock.AOneBlock#onEnable()}. + */ + @Test + public void testOnEnable() { + testOnLoad(); + addon.setState(State.ENABLED); + addon.onEnable(); + verify(plugin, never()).logError(anyString()); + assertFalse(addon.getState().equals(State.DISABLED)); + assertTrue(addon.getBlockListener() != null); + assertTrue(addon.getOneBlockManager() != null); + + + + } + + /** + * Test method for {@link world.bentobox.aoneblock.AOneBlock#onLoad()}. + */ + @Test + public void testOnLoad() { + addon.onLoad(); + // Check that config.yml file has been saved + File check = new File("addons/AOneBlock","config.yml"); + assertTrue(check.exists()); + assertTrue(addon.getPlayerCommand().isPresent()); + assertTrue(addon.getAdminCommand().isPresent()); + + } + + /** + * Test method for {@link world.bentobox.aoneblock.AOneBlock#onReload()}. + */ + @Test + public void testOnReload() { + addon.onEnable(); + addon.onReload(); + // Check that config.yml file has been saved + File check = new File("addons/AOneBlock","config.yml"); + assertTrue(check.exists()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.AOneBlock#createWorlds()}. + */ + @Test + public void testCreateWorlds() { + addon.onLoad(); + addon.createWorlds(); + verify(plugin).log("[aoneblock] Creating AOneBlock world ..."); + verify(plugin).log("[aoneblock] Creating AOneBlock's Nether..."); + verify(plugin).log("[aoneblock] Creating AOneBlock's End World..."); + + } + + /** + * Test method for {@link world.bentobox.aoneblock.AOneBlock#getSettings()}. + */ + @Test + public void testGetSettings() { + addon.onLoad(); + assertNotNull(addon.getSettings()); + + } + + /** + * Test method for {@link world.bentobox.aoneblock.AOneBlock#getWorldSettings()}. + */ + @Test + public void testGetWorldSettings() { + addon.onLoad(); + assertEquals(addon.getSettings(), addon.getWorldSettings()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.AOneBlock#getOneBlocksIsland(world.bentobox.bentobox.database.objects.Island)}. + */ + @Test + public void testGetOneBlocksIsland() { + addon.onEnable(); + @NonNull + OneBlockIslands i = addon.getOneBlocksIsland(island); + assertEquals(island.getUniqueId(), i.getUniqueId()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.AOneBlock#getOneBlockManager()}. + */ + @Test + public void testGetOneBlockManager() { + assertNull(addon.getOneBlockManager()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.AOneBlock#getBlockListener()}. + */ + @Test + public void testGetBlockListener() { + assertNull(addon.getBlockListener()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.AOneBlock#getPlaceholdersManager()}. + */ + @Test + public void testGetPlaceholdersManager() { + assertNull(addon.getPlaceholdersManager()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.AOneBlock#getHoloListener()}. + */ + @Test + public void testGetHoloListener() { + assertNull(addon.getHoloListener()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.AOneBlock#useHolographicDisplays()}. + */ + @Test + public void testUseHolographicDisplays() { + assertFalse(addon.useHolographicDisplays()); + } + +} From 27c4e110e28fe3a8e2aa3d589aeca1483c59dd98 Mon Sep 17 00:00:00 2001 From: tastybento Date: Fri, 27 Jan 2023 12:54:57 -0800 Subject: [PATCH 30/43] Use better test asserts --- src/test/java/world/bentobox/aoneblock/AOneBlockTest.java | 8 ++++---- .../aoneblock/dataobjects/OneBlockIslandsTest.java | 2 +- .../bentobox/aoneblock/listeners/BlockProtectTest.java | 5 +++-- .../aoneblock/listeners/JoinLeaveListenerTest.java | 5 +++-- .../bentobox/aoneblock/listeners/NoBlockHandlerTest.java | 3 ++- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/test/java/world/bentobox/aoneblock/AOneBlockTest.java b/src/test/java/world/bentobox/aoneblock/AOneBlockTest.java index 73664358..64c5cf47 100644 --- a/src/test/java/world/bentobox/aoneblock/AOneBlockTest.java +++ b/src/test/java/world/bentobox/aoneblock/AOneBlockTest.java @@ -2,10 +2,10 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; @@ -223,9 +223,9 @@ public void testOnEnable() { addon.setState(State.ENABLED); addon.onEnable(); verify(plugin, never()).logError(anyString()); - assertFalse(addon.getState().equals(State.DISABLED)); - assertTrue(addon.getBlockListener() != null); - assertTrue(addon.getOneBlockManager() != null); + assertNotEquals(State.DISABLED, addon.getState()); + assertNotNull(addon.getBlockListener()); + assertNotNull(addon.getOneBlockManager()); diff --git a/src/test/java/world/bentobox/aoneblock/dataobjects/OneBlockIslandsTest.java b/src/test/java/world/bentobox/aoneblock/dataobjects/OneBlockIslandsTest.java index 0bed35f9..772d8ef9 100644 --- a/src/test/java/world/bentobox/aoneblock/dataobjects/OneBlockIslandsTest.java +++ b/src/test/java/world/bentobox/aoneblock/dataobjects/OneBlockIslandsTest.java @@ -63,7 +63,7 @@ public void testSetPhaseName() { */ @Test public void testOneBlockIslands() { - assertFalse(obi == null); + assertNotNull(obi); } /** diff --git a/src/test/java/world/bentobox/aoneblock/listeners/BlockProtectTest.java b/src/test/java/world/bentobox/aoneblock/listeners/BlockProtectTest.java index 4ca4def6..4b4c2e1b 100644 --- a/src/test/java/world/bentobox/aoneblock/listeners/BlockProtectTest.java +++ b/src/test/java/world/bentobox/aoneblock/listeners/BlockProtectTest.java @@ -1,6 +1,7 @@ package world.bentobox.aoneblock.listeners; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyDouble; @@ -72,7 +73,7 @@ public class BlockProtectTest { @Before public void setUp() throws Exception { // In World - when(addon.inWorld(eq(world))).thenReturn(true); + when(addon.inWorld(world)).thenReturn(true); // Location when(location.getWorld()).thenReturn(world); @@ -102,7 +103,7 @@ public void tearDown() throws Exception { */ @Test public void testBlockProtect() { - assertFalse(bp == null); + assertNotNull(bp); } /** diff --git a/src/test/java/world/bentobox/aoneblock/listeners/JoinLeaveListenerTest.java b/src/test/java/world/bentobox/aoneblock/listeners/JoinLeaveListenerTest.java index b7b23cf4..7a974071 100644 --- a/src/test/java/world/bentobox/aoneblock/listeners/JoinLeaveListenerTest.java +++ b/src/test/java/world/bentobox/aoneblock/listeners/JoinLeaveListenerTest.java @@ -1,6 +1,7 @@ package world.bentobox.aoneblock.listeners; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -90,7 +91,7 @@ public void tearDown() throws Exception { */ @Test public void testJoinLeaveListener() { - assertFalse(jll == null); + assertNotNull(jll); } /** @@ -126,7 +127,7 @@ public void testOnPlayerQuitSaveError() { jll.onPlayerQuit(event); verify(aob).logError(anyString()); verify(bl).saveIsland(island); - verify(aob).logError(eq("Could not save AOneBlock island at 123,120,456 to database null")); + verify(aob).logError("Could not save AOneBlock island at 123,120,456 to database null"); } } diff --git a/src/test/java/world/bentobox/aoneblock/listeners/NoBlockHandlerTest.java b/src/test/java/world/bentobox/aoneblock/listeners/NoBlockHandlerTest.java index 0993cdbe..2330dc99 100644 --- a/src/test/java/world/bentobox/aoneblock/listeners/NoBlockHandlerTest.java +++ b/src/test/java/world/bentobox/aoneblock/listeners/NoBlockHandlerTest.java @@ -1,6 +1,7 @@ package world.bentobox.aoneblock.listeners; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; @@ -96,7 +97,7 @@ public void tearDown() throws Exception { */ @Test public void testNoBlockHandler() { - assertFalse(nbh == null); + assertNotNull(nbh); } /** From 0f0ae6771b013cb3b258f357deee29079419d315 Mon Sep 17 00:00:00 2001 From: tastybento Date: Fri, 27 Jan 2023 12:56:16 -0800 Subject: [PATCH 31/43] getCenter() cannot be null --- src/main/java/world/bentobox/aoneblock/AOneBlock.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/aoneblock/AOneBlock.java b/src/main/java/world/bentobox/aoneblock/AOneBlock.java index eb9d7116..1d5431bd 100644 --- a/src/main/java/world/bentobox/aoneblock/AOneBlock.java +++ b/src/main/java/world/bentobox/aoneblock/AOneBlock.java @@ -267,7 +267,7 @@ public void allLoaded() { OneBlockIslands oneBlockIsland = getOneBlocksIsland(island); String hololine = oneBlockIsland.getHologram(); Location center = island.getCenter(); - if (hololine != null && center != null) { + if (hololine != null) { final Hologram hologram = HologramsAPI.createHologram(BentoBox.getInstance(), center.add(0.5, 2.6, 0.5)); for (String line : hololine.split("\\n")) { hologram.appendTextLine(ChatColor.translateAlternateColorCodes('&', line)); From bb8ed45718cb55aa4657c371a0e35f8835167c27 Mon Sep 17 00:00:00 2001 From: tastybento Date: Fri, 27 Jan 2023 12:58:54 -0800 Subject: [PATCH 32/43] Add explicit @since annotation --- src/main/java/world/bentobox/aoneblock/Settings.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/world/bentobox/aoneblock/Settings.java b/src/main/java/world/bentobox/aoneblock/Settings.java index 83065583..3ebc20ad 100644 --- a/src/main/java/world/bentobox/aoneblock/Settings.java +++ b/src/main/java/world/bentobox/aoneblock/Settings.java @@ -752,7 +752,8 @@ public Map getDefaultIslandSettingNames() /** * @return the defaultIslandFlags - * @deprecated since 1.21 Replaced with #getDefaultIslandFlagNames + * @deprecated Replaced with #getDefaultIslandFlagNames + * @since 1.21 */ @Override @Deprecated @@ -762,7 +763,8 @@ public Map getDefaultIslandFlags() { /** * @return the defaultIslandSettings - * @deprecated since 1.21 Replaced with #getDefaultIslandSettingNames + * @deprecated Replaced with #getDefaultIslandSettingNames + * @since 1.21 */ @Override @Deprecated From 5b19fb17d2b2cf395bbd8cb3c0b570d43de0f6f3 Mon Sep 17 00:00:00 2001 From: tastybento Date: Fri, 27 Jan 2023 15:47:12 -0800 Subject: [PATCH 33/43] Removed extraneous config settings. Removed the options for island nether and end islands because they don't exist in this game mode. Also removed sea level and nether roof options that were left over from BSkyBlock. --- .../world/bentobox/aoneblock/Settings.java | 100 +--------------- .../generators/ChunkGeneratorWorld.java | 112 +----------------- src/main/resources/config.yml | 74 ++++++------ .../bentobox/aoneblock/SettingsTest.java | 86 -------------- 4 files changed, 46 insertions(+), 326 deletions(-) diff --git a/src/main/java/world/bentobox/aoneblock/Settings.java b/src/main/java/world/bentobox/aoneblock/Settings.java index 3ebc20ad..f775960e 100644 --- a/src/main/java/world/bentobox/aoneblock/Settings.java +++ b/src/main/java/world/bentobox/aoneblock/Settings.java @@ -13,8 +13,6 @@ import org.bukkit.block.Biome; import org.bukkit.entity.EntityType; -import com.google.common.base.Enums; - import world.bentobox.aoneblock.listeners.BlockListener; import world.bentobox.bentobox.api.configuration.ConfigComment; import world.bentobox.bentobox.api.configuration.ConfigEntry; @@ -156,13 +154,6 @@ public class Settings implements WorldSettings { @ConfigEntry(path = "world.use-own-generator") private boolean useOwnGenerator; - @ConfigComment("Sea height (don't changes this mid-game unless you delete the world)") - @ConfigComment("Minimum is 0") - @ConfigComment("If sea height is less than about 10, then players will drop right through it") - @ConfigComment("if it exists.") - @ConfigEntry(path = "world.sea-height", needsReset = true) - private int seaHeight = 0; - @ConfigComment("Maximum number of islands in the world. Set to -1 or 0 for unlimited.") @ConfigComment("If the number of islands is greater than this number, it will stop players from creating islands.") @ConfigEntry(path = "world.max-islands") @@ -176,12 +167,6 @@ public class Settings implements WorldSettings { @ConfigComment("The default biome for the overworld") @ConfigEntry(path = "world.default-biome") private Biome defaultBiome = Biome.PLAINS; - @ConfigComment("The default biome for the nether world (this may affect what mobs can spawn)") - @ConfigEntry(path = "world.default-nether-biome") - private Biome defaultNetherBiome = Enums.getIfPresent(Biome.class, "NETHER").or(Enums.getIfPresent(Biome.class, "NETHER_WASTES").or(Biome.BADLANDS)); - @ConfigComment("The default biome for the end world (this may affect what mobs can spawn)") - @ConfigEntry(path = "world.default-end-biome") - private Biome defaultEndBiome = Biome.THE_END; @ConfigComment("The maximum number of players a player can ban at any one time in this game mode.") @ConfigComment("The permission acidisland.ban.maxlimit.X where X is a number can also be used per player") @@ -198,16 +183,6 @@ public class Settings implements WorldSettings { @ConfigEntry(path = "world.nether.generate") private boolean netherGenerate = true; - @ConfigComment("Islands in Nether. Change to false for standard vanilla nether.") - @ConfigEntry(path = "world.nether.islands", needsReset = true) - private boolean netherIslands = false; - - @ConfigComment("Make the nether roof, if false, there is nothing up there") - @ConfigComment("Change to false if lag is a problem from the generation") - @ConfigComment("Only applies to islands Nether") - @ConfigEntry(path = "world.nether.roof") - private boolean netherRoof = false; - @ConfigComment("Nether spawn protection radius - this is the distance around the nether spawn") @ConfigComment("that will be protected from player interaction (breaking blocks, pouring lava etc.)") @ConfigComment("Minimum is 0 (not recommended), maximum is 100. Default is 25.") @@ -223,15 +198,11 @@ public class Settings implements WorldSettings { private boolean makeNetherPortals = false; // End - @ConfigComment("End Nether - if this is false, the end world will not be made and access to") + @ConfigComment("End world - if this is false, the end world will not be made and access to") @ConfigComment("the end will not occur. Other plugins may still enable portal usage.") @ConfigEntry(path = "world.end.generate") private boolean endGenerate = false; - @ConfigComment("Islands in The End. Change to false for standard vanilla end.") - @ConfigEntry(path = "world.end.islands", needsReset = true) - private boolean endIslands = false; - @ConfigComment("This option indicates if obsidian platform in the end should be generated") @ConfigComment("when player enters the end world.") @ConfigComment("This option requires `allow-end=true` in bukkit.yml.") @@ -637,7 +608,7 @@ public boolean isUseOwnGenerator() { */ @Override public int getSeaHeight() { - return seaHeight; + return 0; } /** @@ -669,14 +640,7 @@ public boolean isNetherGenerate() { */ @Override public boolean isNetherIslands() { - return netherIslands; - } - - /** - * @return the netherRoof - */ - public boolean isNetherRoof() { - return netherRoof; + return false; } /** @@ -700,7 +664,7 @@ public boolean isEndGenerate() { */ @Override public boolean isEndIslands() { - return endIslands; + return false; } /** @@ -1079,13 +1043,6 @@ public void setUseOwnGenerator(boolean useOwnGenerator) { this.useOwnGenerator = useOwnGenerator; } - /** - * @param seaHeight the seaHeight to set - */ - public void setSeaHeight(int seaHeight) { - this.seaHeight = seaHeight; - } - /** * @param maxIslands the maxIslands to set */ @@ -1107,20 +1064,6 @@ public void setNetherGenerate(boolean netherGenerate) { this.netherGenerate = netherGenerate; } - /** - * @param netherIslands the netherIslands to set - */ - public void setNetherIslands(boolean netherIslands) { - this.netherIslands = netherIslands; - } - - /** - * @param netherRoof the netherRoof to set - */ - public void setNetherRoof(boolean netherRoof) { - this.netherRoof = netherRoof; - } - /** * @param netherSpawnRadius the netherSpawnRadius to set */ @@ -1135,13 +1078,6 @@ public void setEndGenerate(boolean endGenerate) { this.endGenerate = endGenerate; } - /** - * @param endIslands the endIslands to set - */ - public void setEndIslands(boolean endIslands) { - this.endIslands = endIslands; - } - /** * @param removeMobsWhitelist the removeMobsWhitelist to set */ @@ -1826,34 +1762,6 @@ public void setDropOnTop(boolean dropOnTop) { this.dropOnTop = dropOnTop; } - /** - * @return the defaultNetherBiome - */ - public Biome getDefaultNetherBiome() { - return defaultNetherBiome; - } - - /** - * @param defaultNetherBiome the defaultNetherBiome to set - */ - public void setDefaultNetherBiome(Biome defaultNetherBiome) { - this.defaultNetherBiome = defaultNetherBiome; - } - - /** - * @return the defaultEndBiome - */ - public Biome getDefaultEndBiome() { - return defaultEndBiome; - } - - /** - * @param defaultEndBiome the defaultEndBiome to set - */ - public void setDefaultEndBiome(Biome defaultEndBiome) { - this.defaultEndBiome = defaultEndBiome; - } - /** * @return the makeNetherPortals */ diff --git a/src/main/java/world/bentobox/aoneblock/generators/ChunkGeneratorWorld.java b/src/main/java/world/bentobox/aoneblock/generators/ChunkGeneratorWorld.java index 31e80f5c..ba9846f5 100644 --- a/src/main/java/world/bentobox/aoneblock/generators/ChunkGeneratorWorld.java +++ b/src/main/java/world/bentobox/aoneblock/generators/ChunkGeneratorWorld.java @@ -1,19 +1,12 @@ package world.bentobox.aoneblock.generators; import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Random; -import org.bukkit.Material; import org.bukkit.World; -import org.bukkit.World.Environment; -import org.bukkit.block.Biome; import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; -import org.bukkit.util.Vector; -import org.bukkit.util.noise.PerlinOctaveGenerator; import world.bentobox.aoneblock.AOneBlock; @@ -23,49 +16,24 @@ */ public class ChunkGeneratorWorld extends ChunkGenerator { - private final AOneBlock addon; - private final Random rand = new Random(); - private final Map roofChunk = new HashMap<>(); - /** * @param addon - addon */ public ChunkGeneratorWorld(AOneBlock addon) { super(); - this.addon = addon; - makeNetherRoof(); } + @SuppressWarnings("deprecation") public ChunkData generateChunks(World world) { - ChunkData result = createChunkData(world); - if (world.getEnvironment().equals(Environment.NORMAL) && addon.getSettings().getSeaHeight() > 0) { - result.setRegion(0, 0, 0, 16, addon.getSettings().getSeaHeight() + 1, 16, Material.WATER); - } - if (world.getEnvironment().equals(Environment.NETHER) && addon.getSettings().isNetherRoof()) { - roofChunk.forEach((k,v) -> result.setBlock(k.getBlockX(), world.getMaxHeight() + k.getBlockY(), k.getBlockZ(), v)); - } - return result; + return createChunkData(world); } @Override + @Deprecated public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biomeGrid) { - setBiome(world, biomeGrid); return generateChunks(world); } - private void setBiome(World world, BiomeGrid biomeGrid) { - Biome biome = world.getEnvironment() == Environment.NORMAL ? addon.getSettings().getDefaultBiome() : - world.getEnvironment() == Environment.NETHER ? addon.getSettings().getDefaultNetherBiome() : addon.getSettings().getDefaultEndBiome(); - for (int x = 0; x < 16; x+=4) { - for (int z = 0; z < 16; z+=4) { - for (int y = 0; y < world.getMaxHeight(); y+=4) { - biomeGrid.setBiome(x, y, z, biome); - } - } - } - - } - // This needs to be set to return true to override minecraft's default // behavior @Override @@ -78,78 +46,4 @@ public List getDefaultPopulators(final World world) { return Collections.emptyList(); } - /* - * Nether Section - */ - private void makeNetherRoof() { - rand.setSeed(System.currentTimeMillis()); - PerlinOctaveGenerator gen = new PerlinOctaveGenerator((long) (rand.nextLong() * rand.nextGaussian()), 8); - - // Make the roof - common across the world - for (int x = 0; x < 16; x++) { - for (int z = 0; z < 16; z++) { - // Do the ceiling - setBlock(x, -1, z, Material.BEDROCK); - // Next three layers are a mix of bedrock and netherrack - for (int y = 2; y < 5; y++) { - double r = gen.noise(x, - y, z, 0.5, 0.5); - if (r > 0D) { - setBlock(x, - y, z, Material.BEDROCK); - } - } - // Next three layers are a mix of netherrack and air - for (int y = 5; y < 8; y++) { - double r = gen.noise(x, - y, z, 0.5, 0.5); - if (r > 0D) { - setBlock(x, -y, z, Material.NETHERRACK); - } else { - setBlock(x, -y, z, Material.AIR); - } - } - // Layer 8 may be glowstone - double r = gen.noise(x, - 8, z, rand.nextFloat(), rand.nextFloat()); - if (r > 0.5D) { - // Have blobs of glowstone - switch (rand.nextInt(4)) { - case 1: - // Single block - setBlock(x, -8, z, Material.GLOWSTONE); - if (x < 14 && z < 14) { - setBlock(x + 1, -8, z + 1, Material.GLOWSTONE); - setBlock(x + 2, -8, z + 2, Material.GLOWSTONE); - setBlock(x + 1, -8, z + 2, Material.GLOWSTONE); - setBlock(x + 1, -8, z + 2, Material.GLOWSTONE); - } - break; - case 2: - // Stalatite - for (int i = 0; i < rand.nextInt(10); i++) { - setBlock(x, - 8 - i, z, Material.GLOWSTONE); - } - break; - case 3: - setBlock(x, -8, z, Material.GLOWSTONE); - if (x > 3 && z > 3) { - for (int xx = 0; xx < 3; xx++) { - for (int zz = 0; zz < 3; zz++) { - setBlock(x - xx, - 8 - rand.nextInt(2), z - xx, Material.GLOWSTONE); - } - } - } - break; - default: - setBlock(x, -8, z, Material.GLOWSTONE); - } - setBlock(x, -8, z, Material.GLOWSTONE); - } else { - setBlock(x, -8, z, Material.AIR); - } - } - - } - } - - private void setBlock(int x, int y, int z, Material m) { - roofChunk.put(new Vector(x, y, z), m); - } } \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 06b27fd2..ef614e55 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -20,25 +20,26 @@ aoneblock: # Added since 1.2.0. default-action: go # The command label that shows current phase progress. - # By default, it is 'count'. + # By default it is 'count'. # Added since 1.10.0. count-command: count # The command label that opens phases GUI. - # By default, it is 'phases'. + # By default it is 'phases'. # Added since 1.10.0. phases-command: phases # The command label that allows to change island phase. - # By default, it is 'setCount'. + # By default it is 'setCount'. # Added since 1.10.0. set-count-command: setCount # The command label that allows to check if magic block is present and respawns it if not. - # By default, it is 'respawnBlock check'. + # By default it is 'respawnBlock check'. # Added since 1.10.0. respawn-block-command: respawnBlock check - # Placeholder customization - # SSymbol for the percentage completed scale bar placeholders: - scale-symbol: "■" + # Placeholder customization + # Symbol for the percentage completed scale bar + # Added since 1.9.0. + scale-symbol: ■ world: # Friendly name for this world. Used in admin commands. Must be a single word friendly-name: OneBlock @@ -75,7 +76,6 @@ world: # Default protection range radius in blocks. Cannot be larger than distance. # Admins can change protection sizes for players individually using /obadmin range set # or set this permission: aoneblock.island.range. - # /!\ BentoBox currently does not support changing this value mid-game. If you do need to change it, do a full reset of your databases and worlds. protection-range: 50 # Start islands at these coordinates. This is where new islands will start in the # world. These must be a factor of your island distance, but the plugin will auto @@ -96,12 +96,6 @@ world: # If used, you must specify the world name and generator in the bukkit.yml file. # See https://bukkit.gamepedia.com/Bukkit.yml#.2AOPTIONAL.2A_worlds use-own-generator: false - # Sea height (don't changes this mid-game unless you delete the world) - # Minimum is 0 - # If sea height is less than about 10, then players will drop right through it - # if it exists. - # /!\ BentoBox currently does not support changing this value mid-game. If you do need to change it, do a full reset of your databases and worlds. - sea-height: 0 # Maximum number of islands in the world. Set to -1 or 0 for unlimited. # If the number of islands is greater than this number, it will stop players from creating islands. max-islands: 0 @@ -111,7 +105,7 @@ world: # The default biome for the overworld default-biome: PLAINS # The maximum number of players a player can ban at any one time in this game mode. - # The permission aoneblock.ban.maxlimit.X where X is a number can also be used per player + # The permission acidisland.ban.maxlimit.X where X is a number can also be used per player # -1 = unlimited ban-limit: -1 nether: @@ -121,13 +115,6 @@ world: # Note that with a standard nether all players arrive at the same portal and entering a # portal will return them back to their islands. generate: true - # Islands in Nether. Change to false for standard vanilla nether. - # /!\ BentoBox currently does not support changing this value mid-game. If you do need to change it, do a full reset of your databases and worlds. - islands: true - # Make the nether roof, if false, there is nothing up there - # Change to false if lag is a problem from the generation - # Only applies to islands Nether - roof: true # Nether spawn protection radius - this is the distance around the nether spawn # that will be protected from player interaction (breaking blocks, pouring lava etc.) # Minimum is 0 (not recommended), maximum is 100. Default is 25. @@ -140,12 +127,9 @@ world: # Added since 1.16. create-and-link-portals: false end: - # End Nether - if this is false, the end world will not be made and access to + # End world - if this is false, the end world will not be made and access to # the end will not occur. Other plugins may still enable portal usage. generate: true - # Islands in The End. Change to false for standard vanilla end. - # /!\ BentoBox currently does not support changing this value mid-game. If you do need to change it, do a full reset of your databases and worlds. - islands: true # This option indicates if obsidian platform in the end should be generated # when player enters the end world. # This option requires `allow-end=true` in bukkit.yml. @@ -153,9 +137,9 @@ world: create-obsidian-platform: false # Mob white list - these mobs will NOT be removed when logging in or doing /island remove-mobs-whitelist: - - ENDERMAN - - WITHER - ZOMBIE_VILLAGER + - WITHER + - ENDERMAN # World flags. These are boolean settings for various flags for this world flags: CREEPER_DAMAGE: true @@ -198,16 +182,19 @@ world: LOCK: 0 ENDER_PEARL: 500 DOOR: 500 + BREAK_HOPPERS: 500 FURNACE: 500 ANVIL: 500 MINECART: 500 FISH_SCOOPING: 500 + TRAPPED_CHEST: 500 END_PORTAL: 500 BREEDING: 500 HURT_VILLAGERS: 500 FROST_WALKER: 500 TURTLE_EGGS: 500 COLLECT_LAVA: 500 + BREAK_SPAWNERS: 500 LEVER: 500 ELYTRA: 0 CAKE: 500 @@ -215,37 +202,47 @@ world: HURT_MONSTERS: 0 NAME_TAG: 500 ARMOR_STAND: 500 + CHANGE_SETTINGS: 1000 TRADING: 0 EGGS: 500 ITEM_DROP: 0 + CHEST: 500 NOTE_BLOCK: 0 FLINT_AND_STEEL: 500 NETHER_PORTAL: 500 + SCULK_SENSOR: 500 LECTERN: 500 + SHULKER_BOX: 500 ITEM_PICKUP: 0 CROP_TRAMPLE: 500 DROPPER: 500 BREWING: 500 TNT_PRIMING: 500 COLLECT_WATER: 500 + AXOLOTL_SCOOPING: 500 BUTTON: 500 + COMPOSTER: 500 FIRE_EXTINGUISH: 500 COMMAND_RANKS: 500 BEACON: 500 + ALLAY: 500 TRAPDOOR: 500 PRESSURE_PLATE: 0 EXPERIENCE_BOTTLE_THROWING: 500 DYE: 500 + HIVE: 500 ITEM_FRAME: 500 PLACE_BLOCKS: 500 CRAFTING: 0 SHEARING: 500 ENCHANTING: 0 + FLOWER_POT: 500 BOAT: 500 SPAWN_EGGS: 500 BED: 500 MILKING: 0 DISPENSER: 500 + SCULK_SHRIEKER: 500 GATE: 0 EXPERIENCE_PICKUP: 500 HOPPER: 500 @@ -256,16 +253,23 @@ world: CONTAINER: 500 JUKEBOX: 500 POTION_THROWING: 500 + BARREL: 500 + COLLECT_POWDERED_SNOW: 500 # These are the default settings for new islands default-island-settings: PVP_END: false PVP_NETHER: false LEAF_DECAY: true - TNT_DAMAGE: true - FIRE_IGNITE: true + ANIMAL_NATURAL_SPAWN: true + MONSTER_NATURAL_SPAWN: true FIRE_SPREAD: true FIRE_BURNING: true PVP_OVERWORLD: false + TNT_DAMAGE: true + MONSTER_SPAWNERS_SPAWN: true + FIRE_IGNITE: true + BLOCK_EXPLODE_DAMAGE: true + ANIMAL_SPAWNERS_SPAWN: true # These settings/flags are hidden from users # Ops can toggle hiding in-game using SHIFT-LEFT-CLICK on flags in settings # Added since 1.4.1. @@ -305,7 +309,7 @@ island: # Added since 1.13.0. max-trusted-size: 4 # Default maximum number of homes a player can have. Min = 1 - # Accessed via /ob sethome or /ob go + # Accessed via /is sethome or /is go max-homes: 1 reset: # How many resets a player is allowed (manage with /obadmin reset add/remove/reset/set command) @@ -435,17 +439,17 @@ island: # Note that player-executed commands might not work, as these commands can be run with said player being offline. # Added since 1.8.0. on-leave: [] - # Returns a list of commands that should be executed when the player respawns after death if Flags.ISLAND_RESPAWN is true. + # List of commands that should be executed when the player respawns after death if Flags.ISLAND_RESPAWN is true. # These commands are run by the console, unless otherwise stated using the [SUDO] prefix, # in which case they are executed by the player. - # + # # Available placeholders for the commands are the following: # * [name]: name of the player - # + # # Here are some examples of valid commands to execute: # * '[SUDO] bbox version' # * 'obadmin deaths set [player] 0' - # + # # Note that player-executed commands might not work, as these commands can be run with said player being offline. # Added since 1.14.0. on-respawn: [] diff --git a/src/test/java/world/bentobox/aoneblock/SettingsTest.java b/src/test/java/world/bentobox/aoneblock/SettingsTest.java index 7ddca0ea..96604316 100644 --- a/src/test/java/world/bentobox/aoneblock/SettingsTest.java +++ b/src/test/java/world/bentobox/aoneblock/SettingsTest.java @@ -172,14 +172,6 @@ public void testIsNetherIslands() { assertFalse(s.isNetherIslands()); } - /** - * Test method for {@link world.bentobox.aoneblock.Settings#isNetherRoof()}. - */ - @Test - public void testIsNetherRoof() { - assertFalse(s.isNetherRoof()); - } - /** * Test method for {@link world.bentobox.aoneblock.Settings#getNetherSpawnRadius()}. */ @@ -578,15 +570,6 @@ public void testSetUseOwnGenerator() { assertTrue(s.isUseOwnGenerator()); } - /** - * Test method for {@link world.bentobox.aoneblock.Settings#setSeaHeight(int)}. - */ - @Test - public void testSetSeaHeight() { - s.setSeaHeight(12345); - assertEquals(12345, s.getSeaHeight()); - } - /** * Test method for {@link world.bentobox.aoneblock.Settings#setMaxIslands(int)}. */ @@ -616,28 +599,6 @@ public void testSetNetherGenerate() { assertTrue(s.isNetherGenerate()); } - /** - * Test method for {@link world.bentobox.aoneblock.Settings#setNetherIslands(boolean)}. - */ - @Test - public void testSetNetherIslands() { - s.setNetherIslands(false); - assertFalse(s.isNetherIslands()); - s.setNetherIslands(true); - assertTrue(s.isNetherIslands()); - } - - /** - * Test method for {@link world.bentobox.aoneblock.Settings#setNetherRoof(boolean)}. - */ - @Test - public void testSetNetherRoof() { - s.setNetherRoof(false); - assertFalse(s.isNetherRoof()); - s.setNetherRoof(true); - assertTrue(s.isNetherRoof()); - } - /** * Test method for {@link world.bentobox.aoneblock.Settings#setNetherSpawnRadius(int)}. */ @@ -658,17 +619,6 @@ public void testSetEndGenerate() { assertTrue(s.isEndGenerate()); } - /** - * Test method for {@link world.bentobox.aoneblock.Settings#setEndIslands(boolean)}. - */ - @Test - public void testSetEndIslands() { - s.setEndIslands(false); - assertFalse(s.isEndIslands()); - s.setEndIslands(true); - assertTrue(s.isEndIslands()); - } - /** * Test method for {@link world.bentobox.aoneblock.Settings#setRemoveMobsWhitelist(java.util.Set)}. */ @@ -1545,42 +1495,6 @@ public void testSetDropOnTop() { assertTrue(s.isDropOnTop()); } - /** - * Test method for {@link world.bentobox.aoneblock.Settings#getDefaultNetherBiome()}. - */ - @Test - public void testGetDefaultNetherBiome() { - assertEquals(Biome.NETHER_WASTES, s.getDefaultNetherBiome()); - } - - /** - * Test method for {@link world.bentobox.aoneblock.Settings#setDefaultNetherBiome(org.bukkit.block.Biome)}. - */ - @Test - public void testSetDefaultNetherBiome() { - assertEquals(Biome.NETHER_WASTES, s.getDefaultNetherBiome()); - s.setDefaultNetherBiome(Biome.BADLANDS); - assertEquals(Biome.BADLANDS, s.getDefaultNetherBiome()); - } - - /** - * Test method for {@link world.bentobox.aoneblock.Settings#getDefaultEndBiome()}. - */ - @Test - public void testGetDefaultEndBiome() { - assertEquals(Biome.THE_END, s.getDefaultEndBiome()); - } - - /** - * Test method for {@link world.bentobox.aoneblock.Settings#setDefaultEndBiome(org.bukkit.block.Biome)}. - */ - @Test - public void testSetDefaultEndBiome() { - assertEquals(Biome.THE_END, s.getDefaultEndBiome()); - s.setDefaultEndBiome(Biome.BADLANDS); - assertEquals(Biome.BADLANDS, s.getDefaultEndBiome()); - } - /** * Test method for {@link world.bentobox.aoneblock.Settings#isMakeNetherPortals()}. */ From 9a45e0364eab0d7ae2fb36d2612c1b96434c5819 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 28 Jan 2023 12:33:05 -0800 Subject: [PATCH 34/43] Updated phases and added Deep Dark phase --- .../world/bentobox/aoneblock/AOneBlock.java | 15 +- .../aoneblock/oneblocks/OneBlockPhase.java | 16 + .../aoneblock/oneblocks/OneBlocksManager.java | 2 +- src/main/resources/phases/0_plains_chests.yml | 2 +- src/main/resources/phases/10500_deep_dark.yml | 42 + .../phases/10500_deep_dark_chests.yml | 876 ++++++++++++++++++ .../{10500_the end.yml => 11500_the end.yml} | 2 +- ...nd_chests.yml => 11500_the end_chests.yml} | 2 +- .../{11000_goto_0.yml => 12000_goto_0.yml} | 0 src/main/resources/phases/2000_winter.yml | 1 + src/main/resources/phases/3000_ocean.yml | 2 + src/main/resources/phases/4000_jungle.yml | 1 + src/main/resources/phases/5000_swamp.yml | 2 + src/main/resources/phases/8500_plenty.yml | 2 + 14 files changed, 954 insertions(+), 11 deletions(-) create mode 100644 src/main/resources/phases/10500_deep_dark.yml create mode 100644 src/main/resources/phases/10500_deep_dark_chests.yml rename src/main/resources/phases/{10500_the end.yml => 11500_the end.yml} (96%) rename src/main/resources/phases/{10500_the end_chests.yml => 11500_the end_chests.yml} (99%) rename src/main/resources/phases/{11000_goto_0.yml => 12000_goto_0.yml} (100%) diff --git a/src/main/java/world/bentobox/aoneblock/AOneBlock.java b/src/main/java/world/bentobox/aoneblock/AOneBlock.java index 1d5431bd..a205e532 100644 --- a/src/main/java/world/bentobox/aoneblock/AOneBlock.java +++ b/src/main/java/world/bentobox/aoneblock/AOneBlock.java @@ -61,12 +61,13 @@ public void onLoad() { // Save the default config from config.yml saveDefaultConfig(); // Load settings from config.yml. This will check if there are any issues with it too. - loadSettings(); - // Chunk generator - chunkGenerator = settings.isUseOwnGenerator() ? null : new ChunkGeneratorWorld(this); - // Register commands - playerCommand = new PlayerCommand(this); - adminCommand = new AdminCommand(this); + if (loadSettings()) { + // Chunk generator + chunkGenerator = settings.isUseOwnGenerator() ? null : new ChunkGeneratorWorld(this); + // Register commands + playerCommand = new PlayerCommand(this); + adminCommand = new AdminCommand(this); + } } private boolean loadSettings() { @@ -103,7 +104,7 @@ public void onEnable() { registerListener(new JoinLeaveListener(this)); // Register placeholders registerPlaceholders(); - + // Register request handlers registerRequestHandler(new IslandStatsHandler(this)); registerRequestHandler(new LocationStatsHandler(this)); diff --git a/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockPhase.java b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockPhase.java index e3792c8a..db7e85bc 100644 --- a/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockPhase.java +++ b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlockPhase.java @@ -425,4 +425,20 @@ public void setFixedBlocks(Map fixedBlocks) { public void setHologramLines(Map hologramLines) { this.holograms = hologramLines; } + + @Override + public String toString() { + return "OneBlockPhase [" + (phaseName != null ? "phaseName=" + phaseName + ", " : "") + + (phaseBiome != null ? "phaseBiome=" + phaseBiome + ", " : "") + + (environment != null ? "environment=" + environment + ", " : "") + + (firstBlock != null ? "firstBlock=" + firstBlock + ", " : "") + + (iconBlock != null ? "iconBlock=" + iconBlock + ", " : "") + + (gotoBlock != null ? "gotoBlock=" + gotoBlock + ", " : "") + "blockTotal=" + blockTotal + + ", entityTotal=" + entityTotal + ", " + + (startCommands != null ? "startCommands=" + startCommands + ", " : "") + + (endCommands != null ? "endCommands=" + endCommands + ", " : "") + + (requirements != null ? "requirements=" + requirements + ", " : "") + + (fixedBlocks != null ? "fixedBlocks=" + fixedBlocks + ", " : "") + + (holograms != null ? "holograms=" + holograms : "") + "]"; + } } \ No newline at end of file diff --git a/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlocksManager.java b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlocksManager.java index b54e0fef..7010f482 100644 --- a/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlocksManager.java +++ b/src/main/java/world/bentobox/aoneblock/oneblocks/OneBlocksManager.java @@ -584,7 +584,7 @@ private String getPhaseFileName(OneBlockPhase p) { if (p.isGotoPhase()) { return p.getBlockNumber() + "_goto_" + p.getGotoBlock(); } - return p.getBlockNumber() + "_" + (p.getPhaseName() == null ? "" : p.getPhaseName().toLowerCase()); + return p.getBlockNumber() + "_" + (p.getPhaseName() == null ? "" : p.getPhaseName().toLowerCase().replace(' ', '_')); } private void saveChests(ConfigurationSection phSec, OneBlockPhase phase) { diff --git a/src/main/resources/phases/0_plains_chests.yml b/src/main/resources/phases/0_plains_chests.yml index 13f95a45..36b73223 100644 --- a/src/main/resources/phases/0_plains_chests.yml +++ b/src/main/resources/phases/0_plains_chests.yml @@ -144,5 +144,5 @@ 13: ==: org.bukkit.inventory.ItemStack v: 2230 - type: MUSIC_DISC_11 + type: ICE rarity: RARE diff --git a/src/main/resources/phases/10500_deep_dark.yml b/src/main/resources/phases/10500_deep_dark.yml new file mode 100644 index 00000000..9bb8e6f5 --- /dev/null +++ b/src/main/resources/phases/10500_deep_dark.yml @@ -0,0 +1,42 @@ +'10500': + name: Deep Dark + firstBlock: DEEPSLATE + biome: DEEP_DARK + fixedBlocks: {} + blocks: + PACKED_ICE: 10 + BLUE_ICE: 10 + CHISELED_DEEPSLATE: 50 + SCULK_SENSOR: 10 + GRAY_WOOL: 5 + DEEPSLATE_COAL_ORE: 100 + DIRT: 100 + CRACKED_DEEPSLATE_TILES: 10 + SOUL_SAND: 10 + DEEPSLATE_GOLD_ORE: 50 + BLUE_WOOL: 10 + DEEPSLATE_REDSTONE_ORE: 10 + ICE: 10 + DARK_OAK_LOG: 10 + REINFORCED_DEEPSLATE: 5 + POLISHED_DEEPSLATE: 10 + DEEPSLATE: 2000 + POLISHED_BASALT: 10 + BLACKSTONE: 100 + DEEPSLATE_IRON_ORE: 100 + DEEPSLATE_COPPER_ORE: 100 + CRACKED_DEEPSLATE_BRICKS: 10 + COBBLED_DEEPSLATE: 50 + STONE: 100 + DEEPSLATE_EMERALD_ORE: 30 + DEEPSLATE_DIAMOND_ORE: 5 + COBBLESTONE: 250 + DEEPSLATE_LAPIS_ORE: 20 + CYAN_WOOL: 10 + TARGET: 5 + CHEST: 110 + mobs: + WARDEN: 1 + holograms: {} + start-commands: [] + end-commands: [] diff --git a/src/main/resources/phases/10500_deep_dark_chests.yml b/src/main/resources/phases/10500_deep_dark_chests.yml new file mode 100644 index 00000000..84dddb77 --- /dev/null +++ b/src/main/resources/phases/10500_deep_dark_chests.yml @@ -0,0 +1,876 @@ +'10500': + chests: + '1': + contents: + 16: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: BOOK + amount: 6 + 10: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: BONE + amount: 5 + 12: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: COAL + amount: 5 + 14: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: SOUL_TORCH + amount: 5 + rarity: COMMON + '2': + contents: + 10: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: POLISHED_BASALT + 12: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: COBBLED_DEEPSLATE + amount: 2 + 13: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: COBBLED_DEEPSLATE + amount: 2 + 14: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: COBBLED_DEEPSLATE + amount: 2 + 15: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: COBBLED_DEEPSLATE + amount: 2 + rarity: COMMON + '3': + contents: + 12: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: NAME_TAG + 15: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: POLISHED_BASALT + rarity: COMMON + '4': + contents: + 0: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 18: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 8: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 26: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 13: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + rarity: COMMON + '5': + contents: + 0: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 18: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 8: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 26: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 11: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: DISC_FRAGMENT_5 + 13: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 15: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: DISC_FRAGMENT_5 + rarity: COMMON + '6': + contents: + 12: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: EXPERIENCE_BOTTLE + amount: 5 + rarity: UNCOMMON + '7': + contents: + 19: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: BOW + 7: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: EMERALD + 12: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: CHAINMAIL_CHESTPLATE + 14: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: CHEST_MINECART + rarity: UNCOMMON + '8': + contents: + 11: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: EMERALD + amount: 2 + 12: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: EMERALD + amount: 2 + 13: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: EMERALD + amount: 2 + 14: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: EMERALD + amount: 2 + rarity: UNCOMMON + '9': + contents: + 3: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: EMERALD + 21: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: EMERALD + 13: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: LANTERN + rarity: UNCOMMON + '10': + contents: + 4: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: DISC_FRAGMENT_5 + 8: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: DISC_FRAGMENT_5 + 10: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: POTION + meta: + ==: ItemMeta + meta-type: POTION + potion-type: minecraft:long_regeneration + 15: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: DISC_FRAGMENT_5 + rarity: UNCOMMON + '11': + contents: + 0: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 18: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 4: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: EXPERIENCE_BOTTLE + 22: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: EXPERIENCE_BOTTLE + 8: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 26: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 11: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: EXPERIENCE_BOTTLE + 13: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 15: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: EXPERIENCE_BOTTLE + rarity: UNCOMMON + '12': + contents: + 11: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: ENCHANTED_BOOK + meta: + ==: ItemMeta + meta-type: ENCHANTED + stored-enchants: + PROTECTION_PROJECTILE: 2 + 13: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: EXPERIENCE_BOTTLE + amount: 4 + rarity: RARE + '13': + contents: + 10: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: IRON_TRAPDOOR + 12: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: ENCHANTED_BOOK + meta: + ==: ItemMeta + meta-type: ENCHANTED + stored-enchants: + DAMAGE_ALL: 1 + 14: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: EXPERIENCE_BOTTLE + amount: 4 + rarity: RARE + '14': + contents: + 12: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: ENCHANTED_BOOK + meta: + ==: ItemMeta + meta-type: ENCHANTED + stored-enchants: + DAMAGE_UNDEAD: 2 + 14: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: EXPERIENCE_BOTTLE + amount: 5 + rarity: RARE + '15': + contents: + 1: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_BERRIES + amount: 8 + 2: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_BERRIES + amount: 8 + 3: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_BERRIES + amount: 8 + 19: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_BERRIES + amount: 8 + 20: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_BERRIES + amount: 8 + 21: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_BERRIES + amount: 8 + 10: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_BERRIES + amount: 8 + 11: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: ENCHANTED_BOOK + meta: + ==: ItemMeta + meta-type: ENCHANTED + stored-enchants: + DAMAGE_UNDEAD: 2 + 12: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_BERRIES + amount: 8 + rarity: RARE + '16': + contents: + 11: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: COMPASS + 13: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: RAW_COPPER + amount: 2 + 15: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: MUSIC_DISC_OTHERSIDE + rarity: RARE + '17': + contents: + 0: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 1: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 2: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: ECHO_SHARD + 3: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: ECHO_SHARD + 4: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: ECHO_SHARD + 5: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 6: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 7: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 8: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 9: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 10: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 11: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: ECHO_SHARD + 12: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: COMPASS + 13: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: ECHO_SHARD + 14: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 15: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 16: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 17: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 18: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 20: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: ECHO_SHARD + 21: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: ECHO_SHARD + 22: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: ECHO_SHARD + 23: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 24: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 25: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 26: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + rarity: RARE + '18': + contents: + 0: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: CANDLE + 16: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: SCULK + 18: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: CANDLE + 8: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: CANDLE + 10: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: SCULK + 26: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: CANDLE + 11: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: SCULK + 12: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: SCULK + 13: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: SCULK + 14: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: SCULK + 15: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: SCULK + rarity: RARE + '19': + contents: + 0: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: AMETHYST_SHARD + 2: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 3: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 4: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 5: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 6: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 8: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: AMETHYST_SHARD + 11: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 12: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: SCULK_SENSOR + 13: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: SOUL_TORCH + 14: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: SCULK_SENSOR + 15: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 18: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: AMETHYST_SHARD + 20: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 21: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 22: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 23: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 24: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 26: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: AMETHYST_SHARD + rarity: RARE + '20': + contents: + 0: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 18: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 8: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 26: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 11: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: SADDLE + 13: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 15: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: DIAMOND_HORSE_ARMOR + rarity: RARE + '21': + contents: + 3: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: IRON_INGOT + 4: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: IRON_INGOT + 5: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: IRON_INGOT + 21: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: IRON_INGOT + 22: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: IRON_INGOT + 23: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: IRON_INGOT + 12: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: IRON_INGOT + 13: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: MUSIC_DISC_CAT + 14: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: IRON_INGOT + rarity: EPIC + '22': + contents: + 0: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: SCULK_SENSOR + 2: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 3: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 4: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 5: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 6: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 8: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: CANDLE + 11: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 12: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: SCULK_CATALYST + 13: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: DIAMOND_HOE + meta: + ==: ItemMeta + meta-type: UNSPECIFIC + display-name: '{"text":"Hoe of Smiting"}' + enchants: + DAMAGE_UNDEAD: 2 + VANISHING_CURSE: 1 + repair-cost: 3 + 14: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: SCULK_CATALYST + 15: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 18: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: CANDLE + 20: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 21: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 22: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 23: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 24: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 26: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: SCULK_SENSOR + rarity: EPIC + '23': + contents: + 2: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 3: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 4: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 5: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 6: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 11: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 13: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: ENCHANTED_GOLDEN_APPLE + 15: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 20: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 21: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 22: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 23: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 24: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + rarity: EPIC + '24': + contents: + 2: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 3: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 4: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 5: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 6: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 11: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 13: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: DIAMOND_LEGGINGS + meta: + ==: ItemMeta + meta-type: UNSPECIFIC + display-name: '{"text":"Sneaky Leggings"}' + enchants: + PROTECTION_ENVIRONMENTAL: 3 + SWIFT_SNEAK: 3 + VANISHING_CURSE: 1 + repair-cost: 7 + 15: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 20: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 21: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 22: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 23: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + 24: + ==: org.bukkit.inventory.ItemStack + v: 3218 + type: GLOW_LICHEN + rarity: EPIC diff --git a/src/main/resources/phases/10500_the end.yml b/src/main/resources/phases/11500_the end.yml similarity index 96% rename from src/main/resources/phases/10500_the end.yml rename to src/main/resources/phases/11500_the end.yml index 331fbb30..dd22ecee 100644 --- a/src/main/resources/phases/10500_the end.yml +++ b/src/main/resources/phases/11500_the end.yml @@ -1,4 +1,4 @@ -'10500': +'11500': name: The End firstBlock: END_STONE biome: THE_END diff --git a/src/main/resources/phases/10500_the end_chests.yml b/src/main/resources/phases/11500_the end_chests.yml similarity index 99% rename from src/main/resources/phases/10500_the end_chests.yml rename to src/main/resources/phases/11500_the end_chests.yml index c5e4b334..e076d6cc 100644 --- a/src/main/resources/phases/10500_the end_chests.yml +++ b/src/main/resources/phases/11500_the end_chests.yml @@ -1,4 +1,4 @@ -'10500': +'11500': chests: '1': contents: diff --git a/src/main/resources/phases/11000_goto_0.yml b/src/main/resources/phases/12000_goto_0.yml similarity index 100% rename from src/main/resources/phases/11000_goto_0.yml rename to src/main/resources/phases/12000_goto_0.yml diff --git a/src/main/resources/phases/2000_winter.yml b/src/main/resources/phases/2000_winter.yml index 8878c57f..0b00cb7b 100644 --- a/src/main/resources/phases/2000_winter.yml +++ b/src/main/resources/phases/2000_winter.yml @@ -30,3 +30,4 @@ CREEPER: 30 RABBIT: 50 CHICKEN: 10 + GOAT: 10 diff --git a/src/main/resources/phases/3000_ocean.yml b/src/main/resources/phases/3000_ocean.yml index 4ce6e320..d02187b0 100644 --- a/src/main/resources/phases/3000_ocean.yml +++ b/src/main/resources/phases/3000_ocean.yml @@ -35,3 +35,5 @@ TURTLE: 10 SQUID: 100 DROWNED: 600 + FROG: 10 + diff --git a/src/main/resources/phases/4000_jungle.yml b/src/main/resources/phases/4000_jungle.yml index 7ec30d47..11544754 100644 --- a/src/main/resources/phases/4000_jungle.yml +++ b/src/main/resources/phases/4000_jungle.yml @@ -32,3 +32,4 @@ ENDERMAN: 10 PANDA: 5 CHICKEN: 20 + FROG: 5 diff --git a/src/main/resources/phases/5000_swamp.yml b/src/main/resources/phases/5000_swamp.yml index 1fe96484..de6f3bca 100644 --- a/src/main/resources/phases/5000_swamp.yml +++ b/src/main/resources/phases/5000_swamp.yml @@ -28,3 +28,5 @@ VILLAGER: 10 EVOKER: 2 CHICKEN: 20 + TADPOLE: 20 + FROG: 40 diff --git a/src/main/resources/phases/8500_plenty.yml b/src/main/resources/phases/8500_plenty.yml index 6d8a96b5..0836aedc 100644 --- a/src/main/resources/phases/8500_plenty.yml +++ b/src/main/resources/phases/8500_plenty.yml @@ -56,3 +56,5 @@ VILLAGER: 1 RABBIT: 1 CHICKEN: 1 + ALLAY: 1 + From 6a28da9ceef0a50576e0608eb35f76c8e3b8c0eb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 31 Jan 2023 11:50:45 -0800 Subject: [PATCH 35/43] Bump commons-text from 1.9 to 1.10.0 (#297) Bumps commons-text from 1.9 to 1.10.0. --- updated-dependencies: - dependency-name: org.apache.commons:commons-text dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> From 11afb7150e49bc468686c3ac14c2b1d243ebfffa Mon Sep 17 00:00:00 2001 From: tastybento Date: Fri, 3 Feb 2023 13:32:55 -0800 Subject: [PATCH 36/43] Added 10s time limit to holograms This automatically deletes holograms placed above the magic block after a certain period of time. The default is 10 seconds. This should clear up excessive holograms that remain on the server. --- README.md | 5 +++++ .../java/world/bentobox/aoneblock/Settings.java | 13 +++++++++++++ .../bentobox/aoneblock/listeners/HoloListener.java | 7 ++++++- src/main/resources/config.yml | 8 +++++--- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 235841ca..e6b5c7af 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,11 @@ OneBlock is an add-on that uses the BentoBox API. Here are some other ones that You can add all the usual addons to OneBlock, like Challeges, Likes, Level, Warps, etc. but it is not required. +### Other Plugins + +* To use the Holographic phase names, you will need to install the [Holographic Displays plugin](https://dev.bukkit.org/projects/holographic-displays) + + Bugs and Feature requests ========================= File bug and feature requests here: https://github.com/BentoBoxWorld/OneBlock/issues diff --git a/src/main/java/world/bentobox/aoneblock/Settings.java b/src/main/java/world/bentobox/aoneblock/Settings.java index f775960e..44c3274b 100644 --- a/src/main/java/world/bentobox/aoneblock/Settings.java +++ b/src/main/java/world/bentobox/aoneblock/Settings.java @@ -94,6 +94,11 @@ public class Settings implements WorldSettings { @ConfigComment("Other plugins may override this setting") @ConfigEntry(path = "world.difficulty") private Difficulty difficulty = Difficulty.NORMAL; + + @ConfigComment("Duration in seconds that phase holograms will exist after being displayed, if used.") + @ConfigComment("If set to 0, then holograms will persist until cleared some other way.") + @ConfigEntry(path = "world.hologram-duration") + private int hologramDuration = 10; @ConfigComment("Spawn limits. These override the limits set in bukkit.yml") @ConfigComment("If set to a negative number, the server defaults will be used") @@ -1895,4 +1900,12 @@ public void setRespawnBlockCommand(String respawnBlockCommand) { this.respawnBlockCommand = respawnBlockCommand; } + + public int getHologramDuration() { + return hologramDuration; + } + + public void setHologramDuration(int hologramDuration) { + this.hologramDuration = hologramDuration; + } } diff --git a/src/main/java/world/bentobox/aoneblock/listeners/HoloListener.java b/src/main/java/world/bentobox/aoneblock/listeners/HoloListener.java index 82421b89..3a109828 100644 --- a/src/main/java/world/bentobox/aoneblock/listeners/HoloListener.java +++ b/src/main/java/world/bentobox/aoneblock/listeners/HoloListener.java @@ -1,5 +1,6 @@ package world.bentobox.aoneblock.listeners; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.event.EventHandler; @@ -78,10 +79,14 @@ protected void process(@NonNull Island i, @NonNull OneBlockIslands is, @NonNull is.setHologram(hololine == null ? "" : hololine); Location center = i.getCenter(); if (hololine != null && center != null) { - final Hologram hologram = HologramsAPI.createHologram(BentoBox.getInstance(), center.add(0.5, 2.6, 0.5)); + final Hologram hologram = HologramsAPI.createHologram(BentoBox.getInstance(), center.add(0.5, 2.6, 0.5)); for (String line : hololine.split("\\n")) { hologram.appendTextLine(ChatColor.translateAlternateColorCodes('&', line)); } + // Set up auto delete + if (addon.getSettings().getHologramDuration() > 0) { + Bukkit.getScheduler().runTaskLater(BentoBox.getInstance(), () -> hologram.delete(), addon.getSettings().getHologramDuration() * 20L); + } } } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ef614e55..01b0ec17 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -49,6 +49,9 @@ world: # World difficulty setting - PEACEFUL, EASY, NORMAL, HARD # Other plugins may override this setting difficulty: NORMAL + # Duration in seconds that phase holograms will exist after being displayed, if used. + # If set to 0, then holograms will persist until cleared some other way. + hologram-duration: 10 spawn-limits: # Spawn limits. These override the limits set in bukkit.yml # If set to a negative number, the server defaults will be used @@ -137,9 +140,9 @@ world: create-obsidian-platform: false # Mob white list - these mobs will NOT be removed when logging in or doing /island remove-mobs-whitelist: - - ZOMBIE_VILLAGER - - WITHER - ENDERMAN + - WITHER + - ZOMBIE_VILLAGER # World flags. These are boolean settings for various flags for this world flags: CREEPER_DAMAGE: true @@ -511,4 +514,3 @@ protection: do-not-edit-these-settings: # These settings should not be edited reset-epoch: 0 - From e77c5aa8ea8807b6a5e89d05942545fcc0174227 Mon Sep 17 00:00:00 2001 From: tastybento Date: Thu, 9 Feb 2023 15:11:55 -0800 Subject: [PATCH 37/43] Add ${argLine} to get jacoco coverage --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 4a18b212..d9a97d4a 100644 --- a/pom.xml +++ b/pom.xml @@ -284,6 +284,7 @@ 3.0.0-M5 + ${argLine} --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED From e1c8a18d8b841bfdd4b5aad5e43559c345fda074 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 11 Feb 2023 18:04:41 -0800 Subject: [PATCH 38/43] Remove unused import. --- src/main/java/world/bentobox/aoneblock/Settings.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/world/bentobox/aoneblock/Settings.java b/src/main/java/world/bentobox/aoneblock/Settings.java index 7cce09df..62142712 100644 --- a/src/main/java/world/bentobox/aoneblock/Settings.java +++ b/src/main/java/world/bentobox/aoneblock/Settings.java @@ -13,9 +13,6 @@ import org.bukkit.block.Biome; import org.bukkit.entity.EntityType; -import com.google.common.base.Enums; -import com.google.gson.annotations.JsonAdapter; - import world.bentobox.aoneblock.listeners.BlockListener; import world.bentobox.bentobox.api.configuration.ConfigComment; import world.bentobox.bentobox.api.configuration.ConfigEntry; @@ -97,7 +94,7 @@ public class Settings implements WorldSettings { @ConfigComment("Other plugins may override this setting") @ConfigEntry(path = "world.difficulty") private Difficulty difficulty = Difficulty.NORMAL; - + @ConfigComment("Duration in seconds that phase holograms will exist after being displayed, if used.") @ConfigComment("If set to 0, then holograms will persist until cleared some other way.") @ConfigEntry(path = "world.hologram-duration") From 3181971f23eeccc51767c1452bf8b90896293e23 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sun, 12 Feb 2023 10:55:06 -0800 Subject: [PATCH 39/43] Version 1.12.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d9a97d4a..feeb9e8d 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ -LOCAL - 1.12.1 + 1.12.2 BentoBoxWorld_AOneBlock bentobox-world From 08880a1f76fd96e8dcbe42d253b886c8b14ba524 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 18 Feb 2023 08:11:15 -0800 Subject: [PATCH 40/43] Revert "Removed extraneous config settings." This reverts commit 5b19fb17d2b2cf395bbd8cb3c0b570d43de0f6f3. --- .../world/bentobox/aoneblock/Settings.java | 100 +++++++++++++++- .../generators/ChunkGeneratorWorld.java | 112 +++++++++++++++++- src/main/resources/config.yml | 70 ++++++----- .../bentobox/aoneblock/SettingsTest.java | 86 ++++++++++++++ 4 files changed, 324 insertions(+), 44 deletions(-) diff --git a/src/main/java/world/bentobox/aoneblock/Settings.java b/src/main/java/world/bentobox/aoneblock/Settings.java index 62142712..c20af219 100644 --- a/src/main/java/world/bentobox/aoneblock/Settings.java +++ b/src/main/java/world/bentobox/aoneblock/Settings.java @@ -13,6 +13,8 @@ import org.bukkit.block.Biome; import org.bukkit.entity.EntityType; +import com.google.common.base.Enums; + import world.bentobox.aoneblock.listeners.BlockListener; import world.bentobox.bentobox.api.configuration.ConfigComment; import world.bentobox.bentobox.api.configuration.ConfigEntry; @@ -159,6 +161,13 @@ public class Settings implements WorldSettings { @ConfigEntry(path = "world.use-own-generator") private boolean useOwnGenerator; + @ConfigComment("Sea height (don't changes this mid-game unless you delete the world)") + @ConfigComment("Minimum is 0") + @ConfigComment("If sea height is less than about 10, then players will drop right through it") + @ConfigComment("if it exists.") + @ConfigEntry(path = "world.sea-height", needsReset = true) + private int seaHeight = 0; + @ConfigComment("Maximum number of islands in the world. Set to -1 or 0 for unlimited.") @ConfigComment("If the number of islands is greater than this number, it will stop players from creating islands.") @ConfigEntry(path = "world.max-islands") @@ -172,6 +181,12 @@ public class Settings implements WorldSettings { @ConfigComment("The default biome for the overworld") @ConfigEntry(path = "world.default-biome") private Biome defaultBiome = Biome.PLAINS; + @ConfigComment("The default biome for the nether world (this may affect what mobs can spawn)") + @ConfigEntry(path = "world.default-nether-biome") + private Biome defaultNetherBiome = Enums.getIfPresent(Biome.class, "NETHER").or(Enums.getIfPresent(Biome.class, "NETHER_WASTES").or(Biome.BADLANDS)); + @ConfigComment("The default biome for the end world (this may affect what mobs can spawn)") + @ConfigEntry(path = "world.default-end-biome") + private Biome defaultEndBiome = Biome.THE_END; @ConfigComment("The maximum number of players a player can ban at any one time in this game mode.") @ConfigComment("The permission acidisland.ban.maxlimit.X where X is a number can also be used per player") @@ -188,6 +203,16 @@ public class Settings implements WorldSettings { @ConfigEntry(path = "world.nether.generate") private boolean netherGenerate = true; + @ConfigComment("Islands in Nether. Change to false for standard vanilla nether.") + @ConfigEntry(path = "world.nether.islands", needsReset = true) + private boolean netherIslands = false; + + @ConfigComment("Make the nether roof, if false, there is nothing up there") + @ConfigComment("Change to false if lag is a problem from the generation") + @ConfigComment("Only applies to islands Nether") + @ConfigEntry(path = "world.nether.roof") + private boolean netherRoof = false; + @ConfigComment("Nether spawn protection radius - this is the distance around the nether spawn") @ConfigComment("that will be protected from player interaction (breaking blocks, pouring lava etc.)") @ConfigComment("Minimum is 0 (not recommended), maximum is 100. Default is 25.") @@ -203,11 +228,15 @@ public class Settings implements WorldSettings { private boolean makeNetherPortals = false; // End - @ConfigComment("End world - if this is false, the end world will not be made and access to") + @ConfigComment("End Nether - if this is false, the end world will not be made and access to") @ConfigComment("the end will not occur. Other plugins may still enable portal usage.") @ConfigEntry(path = "world.end.generate") private boolean endGenerate = false; + @ConfigComment("Islands in The End. Change to false for standard vanilla end.") + @ConfigEntry(path = "world.end.islands", needsReset = true) + private boolean endIslands = false; + @ConfigComment("This option indicates if obsidian platform in the end should be generated") @ConfigComment("when player enters the end world.") @ConfigComment("This option requires `allow-end=true` in bukkit.yml.") @@ -613,7 +642,7 @@ public boolean isUseOwnGenerator() { */ @Override public int getSeaHeight() { - return 0; + return seaHeight; } /** @@ -645,7 +674,14 @@ public boolean isNetherGenerate() { */ @Override public boolean isNetherIslands() { - return false; + return netherIslands; + } + + /** + * @return the netherRoof + */ + public boolean isNetherRoof() { + return netherRoof; } /** @@ -669,7 +705,7 @@ public boolean isEndGenerate() { */ @Override public boolean isEndIslands() { - return false; + return endIslands; } /** @@ -1049,6 +1085,13 @@ public void setUseOwnGenerator(boolean useOwnGenerator) { this.useOwnGenerator = useOwnGenerator; } + /** + * @param seaHeight the seaHeight to set + */ + public void setSeaHeight(int seaHeight) { + this.seaHeight = seaHeight; + } + /** * @param maxIslands the maxIslands to set */ @@ -1070,6 +1113,20 @@ public void setNetherGenerate(boolean netherGenerate) { this.netherGenerate = netherGenerate; } + /** + * @param netherIslands the netherIslands to set + */ + public void setNetherIslands(boolean netherIslands) { + this.netherIslands = netherIslands; + } + + /** + * @param netherRoof the netherRoof to set + */ + public void setNetherRoof(boolean netherRoof) { + this.netherRoof = netherRoof; + } + /** * @param netherSpawnRadius the netherSpawnRadius to set */ @@ -1084,6 +1141,13 @@ public void setEndGenerate(boolean endGenerate) { this.endGenerate = endGenerate; } + /** + * @param endIslands the endIslands to set + */ + public void setEndIslands(boolean endIslands) { + this.endIslands = endIslands; + } + /** * @param removeMobsWhitelist the removeMobsWhitelist to set */ @@ -1769,6 +1833,34 @@ public void setDropOnTop(boolean dropOnTop) { this.dropOnTop = dropOnTop; } + /** + * @return the defaultNetherBiome + */ + public Biome getDefaultNetherBiome() { + return defaultNetherBiome; + } + + /** + * @param defaultNetherBiome the defaultNetherBiome to set + */ + public void setDefaultNetherBiome(Biome defaultNetherBiome) { + this.defaultNetherBiome = defaultNetherBiome; + } + + /** + * @return the defaultEndBiome + */ + public Biome getDefaultEndBiome() { + return defaultEndBiome; + } + + /** + * @param defaultEndBiome the defaultEndBiome to set + */ + public void setDefaultEndBiome(Biome defaultEndBiome) { + this.defaultEndBiome = defaultEndBiome; + } + /** * @return the makeNetherPortals */ diff --git a/src/main/java/world/bentobox/aoneblock/generators/ChunkGeneratorWorld.java b/src/main/java/world/bentobox/aoneblock/generators/ChunkGeneratorWorld.java index ba9846f5..31e80f5c 100644 --- a/src/main/java/world/bentobox/aoneblock/generators/ChunkGeneratorWorld.java +++ b/src/main/java/world/bentobox/aoneblock/generators/ChunkGeneratorWorld.java @@ -1,12 +1,19 @@ package world.bentobox.aoneblock.generators; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Random; +import org.bukkit.Material; import org.bukkit.World; +import org.bukkit.World.Environment; +import org.bukkit.block.Biome; import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; +import org.bukkit.util.Vector; +import org.bukkit.util.noise.PerlinOctaveGenerator; import world.bentobox.aoneblock.AOneBlock; @@ -16,24 +23,49 @@ */ public class ChunkGeneratorWorld extends ChunkGenerator { + private final AOneBlock addon; + private final Random rand = new Random(); + private final Map roofChunk = new HashMap<>(); + /** * @param addon - addon */ public ChunkGeneratorWorld(AOneBlock addon) { super(); + this.addon = addon; + makeNetherRoof(); } - @SuppressWarnings("deprecation") public ChunkData generateChunks(World world) { - return createChunkData(world); + ChunkData result = createChunkData(world); + if (world.getEnvironment().equals(Environment.NORMAL) && addon.getSettings().getSeaHeight() > 0) { + result.setRegion(0, 0, 0, 16, addon.getSettings().getSeaHeight() + 1, 16, Material.WATER); + } + if (world.getEnvironment().equals(Environment.NETHER) && addon.getSettings().isNetherRoof()) { + roofChunk.forEach((k,v) -> result.setBlock(k.getBlockX(), world.getMaxHeight() + k.getBlockY(), k.getBlockZ(), v)); + } + return result; } @Override - @Deprecated public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biomeGrid) { + setBiome(world, biomeGrid); return generateChunks(world); } + private void setBiome(World world, BiomeGrid biomeGrid) { + Biome biome = world.getEnvironment() == Environment.NORMAL ? addon.getSettings().getDefaultBiome() : + world.getEnvironment() == Environment.NETHER ? addon.getSettings().getDefaultNetherBiome() : addon.getSettings().getDefaultEndBiome(); + for (int x = 0; x < 16; x+=4) { + for (int z = 0; z < 16; z+=4) { + for (int y = 0; y < world.getMaxHeight(); y+=4) { + biomeGrid.setBiome(x, y, z, biome); + } + } + } + + } + // This needs to be set to return true to override minecraft's default // behavior @Override @@ -46,4 +78,78 @@ public List getDefaultPopulators(final World world) { return Collections.emptyList(); } + /* + * Nether Section + */ + private void makeNetherRoof() { + rand.setSeed(System.currentTimeMillis()); + PerlinOctaveGenerator gen = new PerlinOctaveGenerator((long) (rand.nextLong() * rand.nextGaussian()), 8); + + // Make the roof - common across the world + for (int x = 0; x < 16; x++) { + for (int z = 0; z < 16; z++) { + // Do the ceiling + setBlock(x, -1, z, Material.BEDROCK); + // Next three layers are a mix of bedrock and netherrack + for (int y = 2; y < 5; y++) { + double r = gen.noise(x, - y, z, 0.5, 0.5); + if (r > 0D) { + setBlock(x, - y, z, Material.BEDROCK); + } + } + // Next three layers are a mix of netherrack and air + for (int y = 5; y < 8; y++) { + double r = gen.noise(x, - y, z, 0.5, 0.5); + if (r > 0D) { + setBlock(x, -y, z, Material.NETHERRACK); + } else { + setBlock(x, -y, z, Material.AIR); + } + } + // Layer 8 may be glowstone + double r = gen.noise(x, - 8, z, rand.nextFloat(), rand.nextFloat()); + if (r > 0.5D) { + // Have blobs of glowstone + switch (rand.nextInt(4)) { + case 1: + // Single block + setBlock(x, -8, z, Material.GLOWSTONE); + if (x < 14 && z < 14) { + setBlock(x + 1, -8, z + 1, Material.GLOWSTONE); + setBlock(x + 2, -8, z + 2, Material.GLOWSTONE); + setBlock(x + 1, -8, z + 2, Material.GLOWSTONE); + setBlock(x + 1, -8, z + 2, Material.GLOWSTONE); + } + break; + case 2: + // Stalatite + for (int i = 0; i < rand.nextInt(10); i++) { + setBlock(x, - 8 - i, z, Material.GLOWSTONE); + } + break; + case 3: + setBlock(x, -8, z, Material.GLOWSTONE); + if (x > 3 && z > 3) { + for (int xx = 0; xx < 3; xx++) { + for (int zz = 0; zz < 3; zz++) { + setBlock(x - xx, - 8 - rand.nextInt(2), z - xx, Material.GLOWSTONE); + } + } + } + break; + default: + setBlock(x, -8, z, Material.GLOWSTONE); + } + setBlock(x, -8, z, Material.GLOWSTONE); + } else { + setBlock(x, -8, z, Material.AIR); + } + } + + } + } + + private void setBlock(int x, int y, int z, Material m) { + roofChunk.put(new Vector(x, y, z), m); + } } \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 01b0ec17..087cbba8 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -20,26 +20,25 @@ aoneblock: # Added since 1.2.0. default-action: go # The command label that shows current phase progress. - # By default it is 'count'. + # By default, it is 'count'. # Added since 1.10.0. count-command: count # The command label that opens phases GUI. - # By default it is 'phases'. + # By default, it is 'phases'. # Added since 1.10.0. phases-command: phases # The command label that allows to change island phase. - # By default it is 'setCount'. + # By default, it is 'setCount'. # Added since 1.10.0. set-count-command: setCount # The command label that allows to check if magic block is present and respawns it if not. - # By default it is 'respawnBlock check'. + # By default, it is 'respawnBlock check'. # Added since 1.10.0. respawn-block-command: respawnBlock check + # Placeholder customization + # SSymbol for the percentage completed scale bar placeholders: - # Placeholder customization - # Symbol for the percentage completed scale bar - # Added since 1.9.0. - scale-symbol: ■ + scale-symbol: "■" world: # Friendly name for this world. Used in admin commands. Must be a single word friendly-name: OneBlock @@ -79,6 +78,7 @@ world: # Default protection range radius in blocks. Cannot be larger than distance. # Admins can change protection sizes for players individually using /obadmin range set # or set this permission: aoneblock.island.range. + # /!\ BentoBox currently does not support changing this value mid-game. If you do need to change it, do a full reset of your databases and worlds. protection-range: 50 # Start islands at these coordinates. This is where new islands will start in the # world. These must be a factor of your island distance, but the plugin will auto @@ -99,6 +99,12 @@ world: # If used, you must specify the world name and generator in the bukkit.yml file. # See https://bukkit.gamepedia.com/Bukkit.yml#.2AOPTIONAL.2A_worlds use-own-generator: false + # Sea height (don't changes this mid-game unless you delete the world) + # Minimum is 0 + # If sea height is less than about 10, then players will drop right through it + # if it exists. + # /!\ BentoBox currently does not support changing this value mid-game. If you do need to change it, do a full reset of your databases and worlds. + sea-height: 0 # Maximum number of islands in the world. Set to -1 or 0 for unlimited. # If the number of islands is greater than this number, it will stop players from creating islands. max-islands: 0 @@ -108,7 +114,7 @@ world: # The default biome for the overworld default-biome: PLAINS # The maximum number of players a player can ban at any one time in this game mode. - # The permission acidisland.ban.maxlimit.X where X is a number can also be used per player + # The permission aoneblock.ban.maxlimit.X where X is a number can also be used per player # -1 = unlimited ban-limit: -1 nether: @@ -118,6 +124,13 @@ world: # Note that with a standard nether all players arrive at the same portal and entering a # portal will return them back to their islands. generate: true + # Islands in Nether. Change to false for standard vanilla nether. + # /!\ BentoBox currently does not support changing this value mid-game. If you do need to change it, do a full reset of your databases and worlds. + islands: true + # Make the nether roof, if false, there is nothing up there + # Change to false if lag is a problem from the generation + # Only applies to islands Nether + roof: true # Nether spawn protection radius - this is the distance around the nether spawn # that will be protected from player interaction (breaking blocks, pouring lava etc.) # Minimum is 0 (not recommended), maximum is 100. Default is 25. @@ -130,9 +143,12 @@ world: # Added since 1.16. create-and-link-portals: false end: - # End world - if this is false, the end world will not be made and access to + # End Nether - if this is false, the end world will not be made and access to # the end will not occur. Other plugins may still enable portal usage. generate: true + # Islands in The End. Change to false for standard vanilla end. + # /!\ BentoBox currently does not support changing this value mid-game. If you do need to change it, do a full reset of your databases and worlds. + islands: true # This option indicates if obsidian platform in the end should be generated # when player enters the end world. # This option requires `allow-end=true` in bukkit.yml. @@ -185,19 +201,16 @@ world: LOCK: 0 ENDER_PEARL: 500 DOOR: 500 - BREAK_HOPPERS: 500 FURNACE: 500 ANVIL: 500 MINECART: 500 FISH_SCOOPING: 500 - TRAPPED_CHEST: 500 END_PORTAL: 500 BREEDING: 500 HURT_VILLAGERS: 500 FROST_WALKER: 500 TURTLE_EGGS: 500 COLLECT_LAVA: 500 - BREAK_SPAWNERS: 500 LEVER: 500 ELYTRA: 0 CAKE: 500 @@ -205,47 +218,37 @@ world: HURT_MONSTERS: 0 NAME_TAG: 500 ARMOR_STAND: 500 - CHANGE_SETTINGS: 1000 TRADING: 0 EGGS: 500 ITEM_DROP: 0 - CHEST: 500 NOTE_BLOCK: 0 FLINT_AND_STEEL: 500 NETHER_PORTAL: 500 - SCULK_SENSOR: 500 LECTERN: 500 - SHULKER_BOX: 500 ITEM_PICKUP: 0 CROP_TRAMPLE: 500 DROPPER: 500 BREWING: 500 TNT_PRIMING: 500 COLLECT_WATER: 500 - AXOLOTL_SCOOPING: 500 BUTTON: 500 - COMPOSTER: 500 FIRE_EXTINGUISH: 500 COMMAND_RANKS: 500 BEACON: 500 - ALLAY: 500 TRAPDOOR: 500 PRESSURE_PLATE: 0 EXPERIENCE_BOTTLE_THROWING: 500 DYE: 500 - HIVE: 500 ITEM_FRAME: 500 PLACE_BLOCKS: 500 CRAFTING: 0 SHEARING: 500 ENCHANTING: 0 - FLOWER_POT: 500 BOAT: 500 SPAWN_EGGS: 500 BED: 500 MILKING: 0 DISPENSER: 500 - SCULK_SHRIEKER: 500 GATE: 0 EXPERIENCE_PICKUP: 500 HOPPER: 500 @@ -256,23 +259,16 @@ world: CONTAINER: 500 JUKEBOX: 500 POTION_THROWING: 500 - BARREL: 500 - COLLECT_POWDERED_SNOW: 500 # These are the default settings for new islands default-island-settings: PVP_END: false PVP_NETHER: false LEAF_DECAY: true - ANIMAL_NATURAL_SPAWN: true - MONSTER_NATURAL_SPAWN: true + TNT_DAMAGE: true + FIRE_IGNITE: true FIRE_SPREAD: true FIRE_BURNING: true PVP_OVERWORLD: false - TNT_DAMAGE: true - MONSTER_SPAWNERS_SPAWN: true - FIRE_IGNITE: true - BLOCK_EXPLODE_DAMAGE: true - ANIMAL_SPAWNERS_SPAWN: true # These settings/flags are hidden from users # Ops can toggle hiding in-game using SHIFT-LEFT-CLICK on flags in settings # Added since 1.4.1. @@ -312,7 +308,7 @@ island: # Added since 1.13.0. max-trusted-size: 4 # Default maximum number of homes a player can have. Min = 1 - # Accessed via /is sethome or /is go + # Accessed via /ob sethome or /ob go max-homes: 1 reset: # How many resets a player is allowed (manage with /obadmin reset add/remove/reset/set command) @@ -442,17 +438,17 @@ island: # Note that player-executed commands might not work, as these commands can be run with said player being offline. # Added since 1.8.0. on-leave: [] - # List of commands that should be executed when the player respawns after death if Flags.ISLAND_RESPAWN is true. + # Returns a list of commands that should be executed when the player respawns after death if Flags.ISLAND_RESPAWN is true. # These commands are run by the console, unless otherwise stated using the [SUDO] prefix, # in which case they are executed by the player. - # + # # Available placeholders for the commands are the following: # * [name]: name of the player - # + # # Here are some examples of valid commands to execute: # * '[SUDO] bbox version' # * 'obadmin deaths set [player] 0' - # + # # Note that player-executed commands might not work, as these commands can be run with said player being offline. # Added since 1.14.0. on-respawn: [] diff --git a/src/test/java/world/bentobox/aoneblock/SettingsTest.java b/src/test/java/world/bentobox/aoneblock/SettingsTest.java index 96604316..7ddca0ea 100644 --- a/src/test/java/world/bentobox/aoneblock/SettingsTest.java +++ b/src/test/java/world/bentobox/aoneblock/SettingsTest.java @@ -172,6 +172,14 @@ public void testIsNetherIslands() { assertFalse(s.isNetherIslands()); } + /** + * Test method for {@link world.bentobox.aoneblock.Settings#isNetherRoof()}. + */ + @Test + public void testIsNetherRoof() { + assertFalse(s.isNetherRoof()); + } + /** * Test method for {@link world.bentobox.aoneblock.Settings#getNetherSpawnRadius()}. */ @@ -570,6 +578,15 @@ public void testSetUseOwnGenerator() { assertTrue(s.isUseOwnGenerator()); } + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setSeaHeight(int)}. + */ + @Test + public void testSetSeaHeight() { + s.setSeaHeight(12345); + assertEquals(12345, s.getSeaHeight()); + } + /** * Test method for {@link world.bentobox.aoneblock.Settings#setMaxIslands(int)}. */ @@ -599,6 +616,28 @@ public void testSetNetherGenerate() { assertTrue(s.isNetherGenerate()); } + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setNetherIslands(boolean)}. + */ + @Test + public void testSetNetherIslands() { + s.setNetherIslands(false); + assertFalse(s.isNetherIslands()); + s.setNetherIslands(true); + assertTrue(s.isNetherIslands()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setNetherRoof(boolean)}. + */ + @Test + public void testSetNetherRoof() { + s.setNetherRoof(false); + assertFalse(s.isNetherRoof()); + s.setNetherRoof(true); + assertTrue(s.isNetherRoof()); + } + /** * Test method for {@link world.bentobox.aoneblock.Settings#setNetherSpawnRadius(int)}. */ @@ -619,6 +658,17 @@ public void testSetEndGenerate() { assertTrue(s.isEndGenerate()); } + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setEndIslands(boolean)}. + */ + @Test + public void testSetEndIslands() { + s.setEndIslands(false); + assertFalse(s.isEndIslands()); + s.setEndIslands(true); + assertTrue(s.isEndIslands()); + } + /** * Test method for {@link world.bentobox.aoneblock.Settings#setRemoveMobsWhitelist(java.util.Set)}. */ @@ -1495,6 +1545,42 @@ public void testSetDropOnTop() { assertTrue(s.isDropOnTop()); } + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getDefaultNetherBiome()}. + */ + @Test + public void testGetDefaultNetherBiome() { + assertEquals(Biome.NETHER_WASTES, s.getDefaultNetherBiome()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setDefaultNetherBiome(org.bukkit.block.Biome)}. + */ + @Test + public void testSetDefaultNetherBiome() { + assertEquals(Biome.NETHER_WASTES, s.getDefaultNetherBiome()); + s.setDefaultNetherBiome(Biome.BADLANDS); + assertEquals(Biome.BADLANDS, s.getDefaultNetherBiome()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#getDefaultEndBiome()}. + */ + @Test + public void testGetDefaultEndBiome() { + assertEquals(Biome.THE_END, s.getDefaultEndBiome()); + } + + /** + * Test method for {@link world.bentobox.aoneblock.Settings#setDefaultEndBiome(org.bukkit.block.Biome)}. + */ + @Test + public void testSetDefaultEndBiome() { + assertEquals(Biome.THE_END, s.getDefaultEndBiome()); + s.setDefaultEndBiome(Biome.BADLANDS); + assertEquals(Biome.BADLANDS, s.getDefaultEndBiome()); + } + /** * Test method for {@link world.bentobox.aoneblock.Settings#isMakeNetherPortals()}. */ From 38b7cda2e2e494d9f18c3f85e7fe0b9cacd703f1 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 18 Feb 2023 08:14:57 -0800 Subject: [PATCH 41/43] Clarify config.yml comments on end and nether --- src/main/java/world/bentobox/aoneblock/Settings.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/world/bentobox/aoneblock/Settings.java b/src/main/java/world/bentobox/aoneblock/Settings.java index c20af219..71e83abe 100644 --- a/src/main/java/world/bentobox/aoneblock/Settings.java +++ b/src/main/java/world/bentobox/aoneblock/Settings.java @@ -204,6 +204,7 @@ public class Settings implements WorldSettings { private boolean netherGenerate = true; @ConfigComment("Islands in Nether. Change to false for standard vanilla nether.") + @ConfigComment("Note that there is currently no magic block in the Nether") @ConfigEntry(path = "world.nether.islands", needsReset = true) private boolean netherIslands = false; @@ -234,6 +235,7 @@ public class Settings implements WorldSettings { private boolean endGenerate = false; @ConfigComment("Islands in The End. Change to false for standard vanilla end.") + @ConfigComment("Note that there is currently no magic block in the End") @ConfigEntry(path = "world.end.islands", needsReset = true) private boolean endIslands = false; From 359c2888a72abd2b3ae62a51275344f7243fe441 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 18 Feb 2023 08:51:38 -0800 Subject: [PATCH 42/43] Updated config.yml --- src/main/resources/config.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 928fa4dc..2495775d 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -129,6 +129,7 @@ world: # portal will return them back to their islands. generate: true # Islands in Nether. Change to false for standard vanilla nether. + # Note that there is currently no magic block in the Nether # /!\ BentoBox currently does not support changing this value mid-game. If you do need to change it, do a full reset of your databases and worlds. islands: false # Make the nether roof, if false, there is nothing up there @@ -151,6 +152,7 @@ world: # the end will not occur. Other plugins may still enable portal usage. generate: true # Islands in The End. Change to false for standard vanilla end. + # Note that there is currently no magic block in the End # /!\ BentoBox currently does not support changing this value mid-game. If you do need to change it, do a full reset of your databases and worlds. islands: false # This option indicates if obsidian platform in the end should be generated @@ -160,8 +162,8 @@ world: create-obsidian-platform: false # Mob white list - these mobs will NOT be removed when logging in or doing /island remove-mobs-whitelist: - - WITHER - ENDERMAN + - WITHER - ZOMBIE_VILLAGER # World flags. These are boolean settings for various flags for this world flags: From 7952eb2c80a11159d752bf7bf7a3458b67937033 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 18 Feb 2023 08:56:12 -0800 Subject: [PATCH 43/43] Remove unused imports --- .../bentobox/aoneblock/listeners/JoinLeaveListenerTest.java | 2 -- .../world/bentobox/aoneblock/listeners/NoBlockHandlerTest.java | 1 - 2 files changed, 3 deletions(-) diff --git a/src/test/java/world/bentobox/aoneblock/listeners/JoinLeaveListenerTest.java b/src/test/java/world/bentobox/aoneblock/listeners/JoinLeaveListenerTest.java index 7a974071..e88d1269 100644 --- a/src/test/java/world/bentobox/aoneblock/listeners/JoinLeaveListenerTest.java +++ b/src/test/java/world/bentobox/aoneblock/listeners/JoinLeaveListenerTest.java @@ -1,10 +1,8 @@ package world.bentobox.aoneblock.listeners; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; diff --git a/src/test/java/world/bentobox/aoneblock/listeners/NoBlockHandlerTest.java b/src/test/java/world/bentobox/aoneblock/listeners/NoBlockHandlerTest.java index 2330dc99..10c4363c 100644 --- a/src/test/java/world/bentobox/aoneblock/listeners/NoBlockHandlerTest.java +++ b/src/test/java/world/bentobox/aoneblock/listeners/NoBlockHandlerTest.java @@ -1,6 +1,5 @@ package world.bentobox.aoneblock.listeners; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.never;