From 9bd019399a956f2472e15e38924661523bd2c4c5 Mon Sep 17 00:00:00 2001 From: Sauilitired Date: Sat, 18 Jul 2015 10:47:35 +0200 Subject: [PATCH] Fixes #163 --- src/main/java/com/intellectualcrafters/plot/config/C.java | 1 + .../intellectualcrafters/plot/listeners/PlayerEvents.java | 6 ++++++ .../com/intellectualcrafters/plot/object/PlotWorld.java | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/intellectualcrafters/plot/config/C.java b/src/main/java/com/intellectualcrafters/plot/config/C.java index 775d2479f..c96d04c2b 100644 --- a/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -106,6 +106,7 @@ public enum C { WORLDEDIT_RESTRICTED("$1Your WorldEdit is now restricted.", "WorldEdit Masks"), GAMEMODE_WAS_BYPASSED("$1You bypassed the gamemode ($2{gamemode}) $1set for this plot", "Gamemode"), + HEIGHT_LIMIT("$1This plot world has a height limit of $2{limit}", "Height Limit"), /* * Records */ diff --git a/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index e5e6f260d..55bba42a6 100644 --- a/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -1853,6 +1853,12 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi Block block = event.getBlockPlaced(); sendBlockChange(block.getLocation(), block.getType(), block.getData()); } + int temporary; + if (!player.hasPermission("plots.admin.build.heightlimit") && loc.getY() >= (temporary = PS.get().getPlotWorld(world).MAX_BUILD_HEIGHT)) { + event.setCancelled(true); + MainUtil.sendMessage(pp, C.HEIGHT_LIMIT.s().replace("{limit}", "" + temporary)); + return; + } return; } else if (!Permissions.hasPermission(pp, "plots.admin.build.road")) { diff --git a/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java b/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java index c542fc78b..e2ca93094 100644 --- a/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java +++ b/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java @@ -60,6 +60,7 @@ public abstract class PlotWorld { public final static boolean SPAWN_BREEDING_DEFAULT = false; public final static boolean WORLD_BORDER_DEFAULT = false; public final static int MAX_PLOT_MEMBERS_DEFAULT = 128; + public final static int MAX_BUILD_HEIGHT_DEFAULT = 256; // are plot clusters enabled // require claim in cluster // TODO make this configurable @@ -94,6 +95,7 @@ public abstract class PlotWorld { public int TERRAIN = 0; public boolean HOME_ALLOW_NONMEMBER; public PlotLoc DEFAULT_HOME; + public int MAX_BUILD_HEIGHT; public PlotWorld(final String worldname) { this.worldname = worldname; @@ -149,6 +151,7 @@ public abstract class PlotWorld { this.SELL_PRICE = config.getDouble("economy.prices.sell"); this.PLOT_CHAT = config.getBoolean("chat.enabled"); this.WORLD_BORDER = config.getBoolean("world.border"); + this.MAX_BUILD_HEIGHT = config.getInt("world.max_height"); this.HOME_ALLOW_NONMEMBER = config.getBoolean("home.allow-nonmembers"); String homeDefault = config.getString("home.default"); @@ -229,7 +232,8 @@ public abstract class PlotWorld { options.put("limits.max-members", PlotWorld.MAX_PLOT_MEMBERS_DEFAULT); options.put("home.default", "side"); options.put("home.allow-nonmembers", false); - + options.put("world.max_height", PlotWorld.MAX_BUILD_HEIGHT_DEFAULT); + if (Settings.ENABLE_CLUSTERS && (this.TYPE != 0)) { options.put("generator.terrain", this.TERRAIN); options.put("generator.type", this.TYPE);