From d9d79a1ca9a939354a9c95d18f4c2e09c4790268 Mon Sep 17 00:00:00 2001 From: BONNe1704 Date: Fri, 15 Feb 2019 16:41:08 +0200 Subject: [PATCH 1/4] Implement ability to change user and admin command in config. --- .../world/bentobox/caveblock/Settings.java | 59 ++++++++++++++++++- .../caveblock/commands/AdminCommand.java | 4 +- .../caveblock/commands/IslandCommand.java | 4 +- src/main/resources/config.yml | 8 +++ 4 files changed, 71 insertions(+), 4 deletions(-) diff --git a/src/main/java/world/bentobox/caveblock/Settings.java b/src/main/java/world/bentobox/caveblock/Settings.java index 9e74479..9f0e7c3 100644 --- a/src/main/java/world/bentobox/caveblock/Settings.java +++ b/src/main/java/world/bentobox/caveblock/Settings.java @@ -798,7 +798,27 @@ public class Settings implements DataObject, WorldSettings } - // --------------------------------------------------------------------- + /** + * This method returns the islandCommand value. + * @return the value of islandCommand. + */ + public String getIslandCommand() + { + return islandCommand; + } + + + /** + * This method returns the adminCommand value. + * @return the value of adminCommand. + */ + public String getAdminCommand() + { + return adminCommand; + } + + + // --------------------------------------------------------------------- // Section: Setters // --------------------------------------------------------------------- @@ -1565,10 +1585,45 @@ public class Settings implements DataObject, WorldSettings this.debug = debug; } - // --------------------------------------------------------------------- + + /** + * This method sets the islandCommand value. + * @param islandCommand the islandCommand new value. + * + */ + public void setIslandCommand(String islandCommand) + { + this.islandCommand = islandCommand; + } + + + /** + * This method sets the adminCommand value. + * @param adminCommand the adminCommand new value. + * + */ + public void setAdminCommand(String adminCommand) + { + this.adminCommand = adminCommand; + } + + + // --------------------------------------------------------------------- // Section: Variables // --------------------------------------------------------------------- + + /* Commands */ + @ConfigComment("Cave Command. What command users will run to access their cave.") + @ConfigComment("To define alias, just separate commands with white space.") + @ConfigEntry(path = "cave.command.island") + private String islandCommand = "cave cb"; + + @ConfigComment("The Cave admin command.") + @ConfigComment("To define alias, just separate commands with white space.") + @ConfigEntry(path = "cave.command.admin") + private String adminCommand = "cbadmin cba"; + /* WORLD */ @ConfigComment("Friendly name for this world. Used in admin commands. Must be a single word") @ConfigEntry(path = "world.friendly-name") diff --git a/src/main/java/world/bentobox/caveblock/commands/AdminCommand.java b/src/main/java/world/bentobox/caveblock/commands/AdminCommand.java index 30a8df1..5dd5ef5 100644 --- a/src/main/java/world/bentobox/caveblock/commands/AdminCommand.java +++ b/src/main/java/world/bentobox/caveblock/commands/AdminCommand.java @@ -21,7 +21,9 @@ import world.bentobox.caveblock.CaveBlock; public class AdminCommand extends CompositeCommand { public AdminCommand(CaveBlock addon) { - super(addon, "cbadmin", "cba"); + super(addon, + addon.getSettings().getAdminCommand().split(" ")[0], + addon.getSettings().getAdminCommand().split(" ")); } @Override diff --git a/src/main/java/world/bentobox/caveblock/commands/IslandCommand.java b/src/main/java/world/bentobox/caveblock/commands/IslandCommand.java index 971dd77..df73586 100644 --- a/src/main/java/world/bentobox/caveblock/commands/IslandCommand.java +++ b/src/main/java/world/bentobox/caveblock/commands/IslandCommand.java @@ -15,7 +15,9 @@ import world.bentobox.caveblock.CaveBlock; public class IslandCommand extends CompositeCommand { public IslandCommand(CaveBlock addon) { - super(addon, "cave", "cb"); + super(addon, + addon.getSettings().getIslandCommand().split(" ")[0], + addon.getSettings().getIslandCommand().split(" ")); } /* (non-Javadoc) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 29691c8..a6fb763 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -2,6 +2,14 @@ # This config file is dynamic and saved when the server is shutdown. # If you edit it while the server is running use /cbadmin reload # otherwise your settings will be lost. +caveblock: + command: + # Cave Command. What command users will run to access their cave. + # To define alias, just separate commands with white space. + island: cave cb + # The Cave admin command. + # To define alias, just separate commands with white space. + admin: cbadmin cba world: # Friendly name for this world. Used in admin commands. Must be a single word friendly-name: CaveBlock From 207733527d6f85f6fec5267a97d719a2dc8b0eb1 Mon Sep 17 00:00:00 2001 From: BONNe1704 Date: Mon, 25 Feb 2019 16:31:06 +0200 Subject: [PATCH 2/4] Improve CaveBlock pom.xml Remove unnecessary things. Add dependency projects in properties Add BuildNumber to version tag. --- pom.xml | 69 +++++++++++++++++++++------------------------------------ 1 file changed, 25 insertions(+), 44 deletions(-) diff --git a/pom.xml b/pom.xml index c01cbfb..cc57814 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ world.bentobox caveblock - 0.1.0 + ${revision} CaveBlock CaveBlock is an add-on for BentoBox, an expandable Minecraft Bukkit plugin for island-type games like SkyBlock or AcidIsland. @@ -44,9 +44,30 @@ UTF-8 UTF-8 1.8 - 1.7.4 + + 1.13.2-R0.1-SNAPSHOT + 1.3.0 + + ${build.version} + + 1.3.0-SNAPSHOT + + + ci + + + env.BUILD_NUMBER + + + + + ${build.version} #${env.BUILD_NUMBER} + + + + spigot-repo @@ -62,31 +83,13 @@ org.spigotmc spigot-api - 1.13.2-R0.1-SNAPSHOT + ${spigot.version} provided - - org.mockito - mockito-all - 1.10.19 - test - - - org.powermock - powermock-module-junit4 - ${powermock.version} - test - - - org.powermock - powermock-api-mockito - ${powermock.version} - test - world.bentobox bentobox - 1.2.0 + ${bentobox.version} provided @@ -199,28 +202,6 @@ maven-deploy-plugin 2.8.2 - - org.jacoco - jacoco-maven-plugin - 0.8.1 - - true - - - - pre-unit-test - - prepare-agent - - - - post-unit-test - - report - - - - \ No newline at end of file From f301e56ea6c0a81b98e3a63a1e341f43c9e3e747 Mon Sep 17 00:00:00 2001 From: BONNe1704 Date: Mon, 25 Feb 2019 16:37:52 +0200 Subject: [PATCH 3/4] Add BentoBox 1.3.0 admin commands --- .../world/bentobox/caveblock/commands/AdminCommand.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/world/bentobox/caveblock/commands/AdminCommand.java b/src/main/java/world/bentobox/caveblock/commands/AdminCommand.java index 5dd5ef5..4b88eee 100644 --- a/src/main/java/world/bentobox/caveblock/commands/AdminCommand.java +++ b/src/main/java/world/bentobox/caveblock/commands/AdminCommand.java @@ -64,6 +64,12 @@ public class AdminCommand extends CompositeCommand { new AdminReloadCommand(this); // Spawn new AdminSetspawnCommand(this); + // Reset flags + new AdminResetFlagsCommand(this); + // Trash + new AdminTrashCommand(this); + new AdminEmptyTrashCommand(this); + new AdminSwitchtoCommand(this); } @Override From a720f7097c80f147ccf1ae124d3017fa599c33cb Mon Sep 17 00:00:00 2001 From: BONNe Date: Tue, 5 Mar 2019 11:22:09 +0200 Subject: [PATCH 4/4] Remove BeaconEnabler as it is not necessary. Beacon can shine through bedrock. Update pom as Challenges addon. --- pom.xml | 21 +- .../world/bentobox/caveblock/CaveBlock.java | 2 - .../caveblock/listeners/BeaconEnabler.java | 203 ------------------ 3 files changed, 18 insertions(+), 208 deletions(-) delete mode 100644 src/main/java/world/bentobox/caveblock/listeners/BeaconEnabler.java diff --git a/pom.xml b/pom.xml index cc57814..f583b0f 100644 --- a/pom.xml +++ b/pom.xml @@ -50,12 +50,12 @@ ${build.version} - 1.3.0-SNAPSHOT + 1.3.0 - ci + develop env.BUILD_NUMBER @@ -63,7 +63,22 @@ - ${build.version} #${env.BUILD_NUMBER} + ${build.version}-SNAPSHOT #${env.BUILD_NUMBER} + + + + + master + + + env.GIT_BRANCH + origin/master + + + + + ${build.version} + diff --git a/src/main/java/world/bentobox/caveblock/CaveBlock.java b/src/main/java/world/bentobox/caveblock/CaveBlock.java index c170de6..bc1acf7 100644 --- a/src/main/java/world/bentobox/caveblock/CaveBlock.java +++ b/src/main/java/world/bentobox/caveblock/CaveBlock.java @@ -13,7 +13,6 @@ import world.bentobox.bentobox.api.configuration.WorldSettings; import world.bentobox.caveblock.commands.AdminCommand; import world.bentobox.caveblock.commands.IslandCommand; import world.bentobox.caveblock.generators.ChunkGeneratorWorld; -import world.bentobox.caveblock.listeners.BeaconEnabler; import world.bentobox.caveblock.listeners.CustomHeightLimitations; @@ -165,7 +164,6 @@ public class CaveBlock extends GameModeAddon } this.getServer().getPluginManager().registerEvents(new CustomHeightLimitations(this), this.getPlugin()); - this.getServer().getPluginManager().registerEvents(new BeaconEnabler(this), this.getPlugin()); } diff --git a/src/main/java/world/bentobox/caveblock/listeners/BeaconEnabler.java b/src/main/java/world/bentobox/caveblock/listeners/BeaconEnabler.java deleted file mode 100644 index 61a8f4f..0000000 --- a/src/main/java/world/bentobox/caveblock/listeners/BeaconEnabler.java +++ /dev/null @@ -1,203 +0,0 @@ -package world.bentobox.caveblock.listeners; - - -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockDamageEvent; -import org.bukkit.event.block.BlockExplodeEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.entity.EntityExplodeEvent; - -import world.bentobox.bentobox.util.Util; -import world.bentobox.caveblock.CaveBlock; -import world.bentobox.caveblock.Settings; - - -/** - * This class allows to enable beacon in CaveBlock, if cave roof is made of bedrock. - * It will replace Bedrock with black glass. - */ -public class BeaconEnabler implements Listener -{ - /** - * Constructor BeaconEnabler creates a new BeaconEnabler instance. - * - * @param addon of type CaveBlock - */ - public BeaconEnabler(CaveBlock addon) - { - this.addon = addon; - this.settings = addon.getSettings(); - } - - - /** - * Method onBlockPlacement detects if beacon is placed and replace roof bedrock with black glass. - * - * @param event of type BlockPlaceEvent - */ - @EventHandler(priority = EventPriority.LOWEST) - public void onBlockPlacement(BlockPlaceEvent event) - { - World world = event.getPlayer().getWorld(); - - if (!Util.sameWorld(this.addon.getOverWorld(), world) || - !this.settings.isBeaconAllowed() || - !this.isRoofEnabled(world) || - !event.getBlock().getType().equals(Material.BEACON)) - { - // This should work only if it is cave block world or world has roof from bedrock. Otherwise, - // players can dig till top themself. - return; - } - - - Block roofBlock = world.getBlockAt(event.getBlock().getX(), this.settings.getWorldDepth() - 1, event.getBlock().getZ()); - - if (roofBlock.getType().equals(Material.BEDROCK)) - { - // Replace only bedrock. - roofBlock.setType(Material.BLACK_STAINED_GLASS); - } - } - - - /** - * Method onBlockBreak detects if beacon is destroyed and replace roof black glass with bedrock. - * - * @param event of type BlockBreakEvent - */ - @EventHandler(priority = EventPriority.LOWEST) - public void onBlockBreak(BlockBreakEvent event) - { - World world = event.getPlayer().getWorld(); - - if (!Util.sameWorld(this.addon.getOverWorld(), world) || - !this.isRoofEnabled(world) || - !this.settings.isBeaconAllowed() || - !event.getBlock().getType().equals(Material.BEACON)) - { - // This should work only if it is cave block world or world has roof from bedrock. - return; - } - - Block roofBlock = world.getBlockAt(event.getBlock().getX(), this.settings.getWorldDepth() - 1, event.getBlock().getZ()); - - if (roofBlock.getType().equals(Material.BLACK_STAINED_GLASS)) - { - // Replace only black glass. - roofBlock.setType(Material.BEDROCK); - } - } - - - /** - * Method onBlockDamage detects if user tries to destroy black glass on roof and disable it. - * - * @param event of type BlockDamageEvent - */ - @EventHandler(priority = EventPriority.LOWEST) - public void onBlockDamage(BlockDamageEvent event) - { - World world = event.getPlayer().getWorld(); - - if (!Util.sameWorld(this.addon.getOverWorld(), world) || - !this.isRoofEnabled(world) || - !this.settings.isBeaconAllowed() || - event.getBlock().getY() != this.settings.getWorldDepth() - 1) - { - // This should work only if it is cave block world or world has roof from bedrock. - return; - } - - // Cancel break event if it is black glass. - event.setCancelled(event.getBlock().getType().equals(Material.BLACK_STAINED_GLASS)); - } - - - /** - * Method onBlockExplode detects if explosion tries to destroy black glass on roof and disable it. - * - * @param event of type BlockExplodeEvent - */ - @EventHandler(priority = EventPriority.LOWEST) - public void onBlockExplode(BlockExplodeEvent event) - { - World world = event.getBlock().getWorld(); - - if (!Util.sameWorld(this.addon.getOverWorld(), world) || - !this.isRoofEnabled(world) || - !this.settings.isBeaconAllowed() || - event.getBlock().getY() < this.settings.getWorldDepth() - 9) - { - // This should work only if it is cave block world or world has roof from bedrock. - return; - } - - final int blockY = this.settings.getWorldDepth() - 1; - - // Remove all black stained glass from explosion block list if it is on the roof. - event.blockList().removeIf(block -> - block.getY() == blockY && block.getType().equals(Material.BLACK_STAINED_GLASS)); - } - - - /** - * Method onEntityExplode detects if explosion tries to destroy black glass on roof and disable it. - * - * @param event of type EntityExplodeEvent - */ - @EventHandler(priority = EventPriority.LOWEST) - public void onEntityExplode(EntityExplodeEvent event) - { - World world = event.getLocation().getWorld(); - - if (!Util.sameWorld(this.addon.getOverWorld(), world) || - !this.isRoofEnabled(world) || - !this.settings.isBeaconAllowed() || - event.getLocation().getY() < this.settings.getWorldDepth() - 9) - { - // This should work only if it is cave block world or world has roof from bedrock. - return; - } - - final int blockY = this.settings.getWorldDepth() - 1; - - // Remove all black stained glass from explosion block list if it is on the roof. - event.blockList().removeIf(block -> - block.getY() == blockY && block.getType().equals(Material.BLACK_STAINED_GLASS)); - } - - - /** - * This method checks if in given world bedrock roof is enabled. - * @param world World that must be checked. - * @return true - bedrock roof is enabled, otherwise false - */ - private boolean isRoofEnabled(World world) - { - return world.getEnvironment().equals(World.Environment.NORMAL) && this.settings.isNormalRoof() || - world.getEnvironment().equals(World.Environment.NETHER) && this.settings.isNetherRoof() || - world.getEnvironment().equals(World.Environment.THE_END) && this.settings.isEndRoof(); - } - - -// --------------------------------------------------------------------- -// Section: Variables -// --------------------------------------------------------------------- - - /** - * CaveBlock addon. - */ - private CaveBlock addon; - - /** - * Addon settings. - */ - private Settings settings; -}