Merge develop into master (#15)

* Fixes BEETROOT_SEEDS enum for itemstack in schem

https://github.com/BentoBoxWorld/CaveBlock/issues/12

* Adds error checking for MATERIALs in config.yml

MATERIALs must be blocks otherwise the world populator will throw errors
and crash the server. This commit checks that all imported materials are
blocks and if they are not logs the error.

Updated config.yml to use correct 1.13 material names for blocks.

https://github.com/BentoBoxWorld/CaveBlock/issues/11

* Removes extraneous settings

https://github.com/BentoBoxWorld/BentoBox/issues/531

* Implement ability to change user and admin command in config.

* Improve CaveBlock pom.xml

Remove unnecessary things.
Add dependency projects in properties
Add BuildNumber to version tag.

* Add BentoBox 1.3.0 admin commands

* Remove BeaconEnabler as it is not necessary.
Beacon can shine through bedrock.

Update pom as Challenges addon.
This commit is contained in:
BONNe 2019-03-05 11:24:34 +02:00 committed by GitHub
parent ad383ec1c0
commit 446087ab48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 127 additions and 342 deletions

3
.gitignore vendored
View File

@ -22,3 +22,6 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/target/
/.DS_Store
/.classpath
/.project

84
pom.xml
View File

@ -6,7 +6,7 @@
<groupId>world.bentobox</groupId>
<artifactId>caveblock</artifactId>
<version>0.1.0</version>
<version>${revision}</version>
<name>CaveBlock</name>
<description>CaveBlock is an add-on for BentoBox, an expandable Minecraft Bukkit plugin for island-type games like SkyBlock or AcidIsland.</description>
@ -44,9 +44,45 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<powermock.version>1.7.4</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.13.2-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.3.0</bentobox.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>1.3.0</build.version>
</properties>
<profiles>
<profile>
<id>develop</id>
<activation>
<property>
<name>env.BUILD_NUMBER</name>
</property>
</activation>
<properties>
<!-- Override only if necessary -->
<revision>${build.version}-SNAPSHOT #${env.BUILD_NUMBER}</revision>
<!-- GIT_BRANCH -->
</properties>
</profile>
<profile>
<id>master</id>
<activation>
<property>
<name>env.GIT_BRANCH</name>
<value>origin/master</value>
</property>
</activation>
<properties>
<!-- Override only if necessary -->
<revision>${build.version}</revision>
<!-- GIT_BRANCH -->
</properties>
</profile>
</profiles>
<repositories>
<repository>
<id>spigot-repo</id>
@ -62,31 +98,13 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version>
<version>${spigot.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>world.bentobox</groupId>
<artifactId>bentobox</artifactId>
<version>1.2.0</version>
<version>${bentobox.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
@ -199,28 +217,6 @@
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
<configuration>
<append>true</append>
</configuration>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -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());
}

View File

@ -412,16 +412,6 @@ public class Settings implements DataObject, WorldSettings
}
/**
* This method returns the resetConfirmation object.
* @return the resetConfirmation object.
*/
public boolean isResetConfirmation()
{
return resetConfirmation;
}
/**
* This method returns the leaversLoseReset object.
* @return the leaversLoseReset object.
@ -508,16 +498,6 @@ public class Settings implements DataObject, WorldSettings
}
/**
* This method returns the respawnOnIsland object.
* @return the respawnOnIsland object.
*/
public boolean isRespawnOnIsland()
{
return respawnOnIsland;
}
/**
* This method returns the allowSetHomeInNether object.
* @return the allowSetHomeInNether object.
@ -627,16 +607,6 @@ public class Settings implements DataObject, WorldSettings
}
/**
* This method returns the closePanelOnClickOutside object.
* @return the closePanelOnClickOutside object.
*/
public boolean isClosePanelOnClickOutside()
{
return closePanelOnClickOutside;
}
/**
* @return the permission prefix
*/
@ -828,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
// ---------------------------------------------------------------------
@ -1195,17 +1185,6 @@ public class Settings implements DataObject, WorldSettings
}
/**
* This method sets the resetConfirmation object value.
* @param resetConfirmation the resetConfirmation object new value.
*
*/
public void setResetConfirmation(boolean resetConfirmation)
{
this.resetConfirmation = resetConfirmation;
}
/**
* This method sets the leaversLoseReset object value.
* @param leaversLoseReset the leaversLoseReset object new value.
@ -1294,17 +1273,6 @@ public class Settings implements DataObject, WorldSettings
}
/**
* This method sets the respawnOnIsland object value.
* @param respawnOnIsland the respawnOnIsland object new value.
*
*/
public void setRespawnOnIsland(boolean respawnOnIsland)
{
this.respawnOnIsland = respawnOnIsland;
}
/**
* This method sets the allowSetHomeInNether object value.
* @param allowSetHomeInNether the allowSetHomeInNether object new value.
@ -1414,18 +1382,6 @@ public class Settings implements DataObject, WorldSettings
this.ivSettings = ivSettings;
}
/**
* This method sets the closePanelOnClickOutside object value.
* @param closePanelOnClickOutside the closePanelOnClickOutside object new value.
*
*/
public void setClosePanelOnClickOutside(boolean closePanelOnClickOutside)
{
this.closePanelOnClickOutside = closePanelOnClickOutside;
}
/**
* This method sets the resetEpoch object value.
* @param resetEpoch the resetEpoch object new value.
@ -1629,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")
@ -1895,9 +1886,6 @@ public class Settings implements DataObject, WorldSettings
@ConfigEntry(path = "island.reset.reset-limit")
private int resetLimit = -1;
@ConfigEntry(path = "island.require-confirmation.reset")
private boolean resetConfirmation = true;
@ConfigComment("Kicked or leaving players lose resets")
@ConfigComment("Players who leave a team will lose an island reset chance")
@ConfigComment("If a player has zero resets left and leaves a team, they cannot make a new")
@ -1946,10 +1934,6 @@ public class Settings implements DataObject, WorldSettings
@ConfigEntry(path = "island.reset.on-leave.ender-chest")
private boolean onLeaveResetEnderChest = false;
@ConfigComment("Have player's respawn on their island if they die")
@ConfigEntry(path = "island.respawn-on-island")
private boolean respawnOnIsland = true;
// Sethome
@ConfigEntry(path = "island.sethome.nether.allow")
private boolean allowSetHomeInNether = true;
@ -1993,12 +1977,6 @@ public class Settings implements DataObject, WorldSettings
@ConfigEntry(path = "protection.invincible-visitors")
private List<String> ivSettings = new ArrayList<>();
//---------------------------------------------------------------------------------------/
@ConfigComment("Whether GUIs should be closed when the player clicks outside.")
@ConfigEntry(path = "panel.close-on-click-outside")
private boolean closePanelOnClickOutside = true;
//---------------------------------------------------------------------------------------/
@ConfigComment("These settings should not be edited")
@ConfigEntry(path = "do-not-edit-these-settings.reset-epoch")

View File

@ -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
@ -62,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

View File

@ -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)

View File

@ -146,11 +146,13 @@ public class MaterialPopulator extends BlockPopulator
filter(splitString -> splitString.length == 4).
forEach(splitString -> {
Material material = Material.getMaterial(splitString[1]);
if (material != null)
// Material must be a block otherwise the chunk cannot be populated
if (material != null && material.isBlock())
{
materialMap.put(material,
new Pair<>(Double.parseDouble(splitString[2]), Integer.parseInt(splitString[3])));
} else {
addon.logError("Could not parse MATERIAL in config.yml: " + splitString[1] + " is not a valid block.");
}
});

View File

@ -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 <code>true</code> - bedrock roof is enabled, otherwise <code>false</code>
*/
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;
}

View File

@ -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
@ -133,11 +141,11 @@ world:
# MATERIAL:DIAMOND_ORE:100:5 - means there is 100% chace of spawing diamonds
# where max amount in pack are 5 per each subchunk!
blocks:
- MATERIAL:QUARTZ_ORE:30:5
- MATERIAL:NETHER_QUARTZ_ORE:30:5
- MATERIAL:SOUL_SAND:40:10
- MATERIAL:MAGMA_BLOCK:10:3
- MATERIAL:GLOWSTONE:20:8
- MATERIAL:NETHER_BRICK:10:5
- MATERIAL:NETHER_BRICKS:10:5
- MATERIAL:LAVA:10:1
- ENTITY:MAGMA_CUBE:0.5:1
- ENTITY:GHAST:0.1:1
@ -166,7 +174,7 @@ world:
blocks:
- ENTITY:SHULKER:0.2:1
- MATERIAL:OBSIDIAN:1:1
- MATERIAL:CHORUS_FRUIT:1:3
- MATERIAL:CHORUS_PLANT:1:3
# Mob white list - these mobs will NOT be removed when logging in or doing /cave
remove-mobs-whitelist:
- WITHER
@ -311,10 +319,6 @@ island:
inventory: false
# Reset Ender Chest - if true, the player's Ender Chest will be cleared.
ender-chest: false
require-confirmation:
reset: true
# Have player's respawn on their island if they die
respawn-on-island: false
sethome:
nether:
allow: true
@ -364,9 +368,6 @@ protection:
- HOT_FLOOR
- CRAMMING
- VOID
panel:
# Whether GUIs should be closed when the player clicks outside.
close-on-click-outside: true
do-not-edit-these-settings:
# These settings should not be edited
reset-epoch: 0