diff --git a/src/main/java/world/bentobox/greenhouses/greenhouse/MinMaxXZ.java b/src/main/java/world/bentobox/greenhouses/greenhouse/MinMaxXZ.java new file mode 100644 index 0000000..04b0a94 --- /dev/null +++ b/src/main/java/world/bentobox/greenhouses/greenhouse/MinMaxXZ.java @@ -0,0 +1,49 @@ +package world.bentobox.greenhouses.greenhouse; + +/** + * Holds min, max x and z coords and provides the area + * @author tastybento + * + */ +public abstract class MinMaxXZ { + + protected int minX; + protected int maxX; + protected int minZ; + protected int maxZ; + + /** + * @return the minX + */ + public int getMinX() { + return minX; + } + + /** + * @return the maxX + */ + public int getMaxX() { + return maxX; + } + + /** + * @return the minZ + */ + public int getMinZ() { + return minZ; + } + + /** + * @return the maxZ + */ + public int getMaxZ() { + return maxZ; + } + + /** + * @return the area + */ + public int getArea() { + return (maxX - minX) * (maxZ - minZ); + } +} diff --git a/src/main/java/world/bentobox/greenhouses/greenhouse/Roof.java b/src/main/java/world/bentobox/greenhouses/greenhouse/Roof.java index e93a472..873ffda 100644 --- a/src/main/java/world/bentobox/greenhouses/greenhouse/Roof.java +++ b/src/main/java/world/bentobox/greenhouses/greenhouse/Roof.java @@ -15,12 +15,8 @@ import org.bukkit.util.Vector; * @author tastybento * */ -public class Roof { +public class Roof extends MinMaxXZ { private final Location location; - private int minX; - private int maxX; - private int minZ; - private int maxZ; private final int height; private boolean roofFound; @@ -158,40 +154,6 @@ public class Roof { } } - /** - * @return the minX - */ - public int getMinX() { - return minX; - } - - /** - * @return the maxX - */ - public int getMaxX() { - return maxX; - } - - /** - * @return the minZ - */ - public int getMinZ() { - return minZ; - } - - /** - * @return the maxZ - */ - public int getMaxZ() { - return maxZ; - } - - /** - * @return the area - */ - public int getArea() { - return (maxX - minX) * (maxZ - minZ); - } /** * @return the roofFound */ diff --git a/src/main/java/world/bentobox/greenhouses/greenhouse/Walls.java b/src/main/java/world/bentobox/greenhouses/greenhouse/Walls.java index b5956c7..825b347 100644 --- a/src/main/java/world/bentobox/greenhouses/greenhouse/Walls.java +++ b/src/main/java/world/bentobox/greenhouses/greenhouse/Walls.java @@ -9,14 +9,10 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.BlockFace; -public class Walls { - private int minX; - private int maxX; - private int minZ; - private int maxZ; +public class Walls extends MinMaxXZ { private int floor; - public static final List ORDINALS = Arrays.asList(BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST); + private static final List ORDINALS = Arrays.asList(BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST); /** * @return list of valid wall blocks @@ -151,36 +147,6 @@ public class Walls { } - /** - * @return the minXX - */ - public int getMinX() { - return minX; - } - /** - * @return the maxXX - */ - public int getMaxX() { - return maxX; - } - /** - * @return the minZZ - */ - public int getMinZ() { - return minZ; - } - /** - * @return the maxZZ - */ - public int getMaxZ() { - return maxZ; - } - - public int getArea() { - // Get interior area - return (maxX - minX) * (maxZ - minZ); - } - /** * @return the floor */ diff --git a/src/main/java/world/bentobox/greenhouses/listeners/GreenhouseEvents.java b/src/main/java/world/bentobox/greenhouses/listeners/GreenhouseEvents.java index 702eaab..410aedd 100644 --- a/src/main/java/world/bentobox/greenhouses/listeners/GreenhouseEvents.java +++ b/src/main/java/world/bentobox/greenhouses/listeners/GreenhouseEvents.java @@ -98,12 +98,12 @@ public class GreenhouseEvents implements Listener { // from is a greenhouse if (from.isPresent() && !to.isPresent()) { // Exiting - user.sendMessage("greenhouses.event.leaving", "BIOME", from.get().getBiomeRecipe().getFriendlyName()); + user.sendMessage("greenhouses.event.leaving", BIOME, from.get().getBiomeRecipe().getFriendlyName()); return; } if (!from.isPresent()) { // Entering - user.sendMessage("greenhouses.event.entering", "BIOME", to.get().getBiomeRecipe().getFriendlyName()); + user.sendMessage("greenhouses.event.entering", BIOME, to.get().getBiomeRecipe().getFriendlyName()); } } @@ -133,7 +133,7 @@ public class GreenhouseEvents implements Listener { || e.getBlock().getLocation().getBlockZ() == (int)g.getBoundingBox().getMinZ() || e.getBlock().getLocation().getBlockZ() == (int)g.getBoundingBox().getMaxZ() - 1 ) { - user.sendMessage("greenhouses.event.broke", "BIOME", Util.prettifyText(g.getOriginalBiome().name())); + user.sendMessage("greenhouses.event.broke", BIOME, Util.prettifyText(g.getOriginalBiome().name())); plugin.getManager().removeGreenhouse(g); } }); diff --git a/src/main/java/world/bentobox/greenhouses/ui/panel/Panel.java b/src/main/java/world/bentobox/greenhouses/ui/panel/Panel.java index a024f32..0eb7343 100644 --- a/src/main/java/world/bentobox/greenhouses/ui/panel/Panel.java +++ b/src/main/java/world/bentobox/greenhouses/ui/panel/Panel.java @@ -12,6 +12,7 @@ import world.bentobox.greenhouses.greenhouse.BiomeRecipe; public class Panel { + private static final String COVERAGE = "[coverage]"; private Greenhouses addon; public Panel(Greenhouses addon) { @@ -41,13 +42,13 @@ public class Panel { br.getRecipeBlocks().forEach(b -> d.add(user.getTranslation("greenhouses.recipe.blockscolor") + b)); } if (br.getWaterCoverage() > 0) { - d.add(user.getTranslation("greenhouses.recipe.watermustbe", "[coverage]", String.valueOf(br.getWaterCoverage()))); + d.add(user.getTranslation("greenhouses.recipe.watermustbe", COVERAGE, String.valueOf(br.getWaterCoverage()))); } if (br.getLavaCoverage() > 0) { - d.add(user.getTranslation("greenhouses.recipe.lavamustbe", "[coverage]", String.valueOf(br.getLavaCoverage()))); + d.add(user.getTranslation("greenhouses.recipe.lavamustbe", COVERAGE, String.valueOf(br.getLavaCoverage()))); } if (br.getIceCoverage() > 0) { - d.add(user.getTranslation("greenhouses.recipe.icemustbe", "[coverage]", String.valueOf(br.getIceCoverage()))); + d.add(user.getTranslation("greenhouses.recipe.icemustbe", COVERAGE, String.valueOf(br.getIceCoverage()))); } if (br.getRecipeBlocks().isEmpty()) { d.add(user.getTranslation("greenhouses.recipe.nootherblocks"));