diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8.java index b18a895a9..313b6d97e 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8.java @@ -2,6 +2,7 @@ package com.plotsquared.bukkit.listeners; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.flag.Flags; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotArea; @@ -10,6 +11,9 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.listener.PlotListener; +import java.util.HashSet; +import java.util.List; +import java.util.UUID; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.ArmorStand; @@ -26,10 +30,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.meta.ItemMeta; -import java.util.HashSet; -import java.util.List; -import java.util.UUID; - public class PlayerEvents_1_8 extends PlotListener implements Listener { @SuppressWarnings("deprecation") @@ -141,6 +141,9 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener { } else { UUID uuid = pp.getUUID(); if (!plot.isAdded(uuid)) { + if (Flags.MISC_INTERACT.isTrue(plot)) { + return; + } if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) { MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.interact.other"); e.setCancelled(true); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index a82337de4..fb46885c6 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -197,7 +197,7 @@ public class MainCommand extends Command { } @Override - public void execute(PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) { + public void execute(final PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) { // Clear perm caching // player.deleteMeta("perm"); // Optional command scope // @@ -223,6 +223,37 @@ public class MainCommand extends Command { // Trim command args = Arrays.copyOfRange(args, 1, args.length); } + if (args.length >= 2 && args[0].charAt(0) == '-') { + switch (args[0].substring(1)) { + case "f": + confirm = new RunnableVal3() { + @Override + public void run(final Command cmd, final Runnable success, final Runnable failure) { + if (EconHandler.manager != null) { + PlotArea area = player.getApplicablePlotArea(); + if (area != null) { + Expression priceEval = area.PRICES.get(cmd.getFullId()); + Double price = priceEval != null ? priceEval.evaluate(0d) : 0d; + if (price != 0d && EconHandler.manager.getMoney(player) < price) { + if (failure != null) { + failure.run(); + } + return; + } + } + } + if (success != null) { + success.run(); + } + } + }; + args = Arrays.copyOfRange(args, 1, args.length); + break; + default: + C.INVALID_COMMAND_FLAG.send(player); + return; + } + } } try { super.execute(player, args, confirm, whenDone); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/config/C.java b/Core/src/main/java/com/intellectualcrafters/plot/config/C.java index 93432f633..460056740 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -452,6 +452,10 @@ public enum C { INVALID_PLAYER_WAIT("$2Player not found: $1%s$2, fetching it. Try again soon.", "Errors"), INVALID_PLAYER("$2Player not found: $1%s$2.", "Errors"), INVALID_PLAYER_OFFLINE("$2The player must be online: $1%s.", "Errors"), + /* + * Command flag + */ + INVALID_COMMAND_FLAG("$2Invalid command flag: %s0", "Errors"), /* * Unknown Error */ diff --git a/Core/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java b/Core/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java index 2f45c8e8e..bf868cb2c 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java @@ -83,7 +83,7 @@ public class ClassicPlotManager extends SquarePlotManager { int maxY = plotArea.getPlotManager().getWorldHeight(); for (RegionWrapper region : plot.getRegions()) { Location pos1 = new Location(plotArea.worldname, region.minX, 1, region.minZ); - Location pos2 = new Location(plotArea.worldname, region.maxX, Math.min(maxY, 255), region.maxZ); + Location pos2 = new Location(plotArea.worldname, region.maxX, maxY, region.maxZ); queue.setCuboid(pos1, pos2, blocks); } queue.enqueue(); @@ -100,7 +100,7 @@ public class ClassicPlotManager extends SquarePlotManager { int maxY = plotArea.getPlotManager().getWorldHeight(); for (RegionWrapper region : plot.getRegions()) { Location pos1 = new Location(plotArea.worldname, region.minX, dpw.PLOT_HEIGHT + 1, region.minZ); - Location pos2 = new Location(plotArea.worldname, region.maxX, Math.min(maxY, 255), region.maxZ); + Location pos2 = new Location(plotArea.worldname, region.maxX,maxY, region.maxZ); queue.setCuboid(pos1, pos2, blocks); } queue.enqueue(); @@ -153,7 +153,7 @@ public class ClassicPlotManager extends SquarePlotManager { if (!plot.getMerged(0)) { int z = bottom.getZ(); for (int x = bottom.getX(); x <= top.getX(); x++) { - for (int y = dpw.PLOT_HEIGHT; y <= Math.min(maxY, 255); y++) { + for (int y = dpw.PLOT_HEIGHT; y <= maxY; y++) { queue.setBlock(x, y, z, blocks[random.random(blocks.length)]); } } @@ -161,7 +161,7 @@ public class ClassicPlotManager extends SquarePlotManager { if (!plot.getMerged(3)) { int x = bottom.getX(); for (int z = bottom.getZ(); z <= top.getZ(); z++) { - for (int y = dpw.PLOT_HEIGHT; y <= Math.min(maxY, 255); y++) { + for (int y = dpw.PLOT_HEIGHT; y <= maxY; y++) { queue.setBlock(x, y, z, blocks[random.random(blocks.length)]); } } @@ -170,7 +170,7 @@ public class ClassicPlotManager extends SquarePlotManager { if (!plot.getMerged(2)) { int z = top.getZ(); for (int x = bottom.getX(); x <= top.getX(); x++) { - for (int y = dpw.PLOT_HEIGHT; y <= Math.min(maxY, 255); y++) { + for (int y = dpw.PLOT_HEIGHT; y <= maxY; y++) { queue.setBlock(x, y, z, blocks[random.random(blocks.length)]); } } @@ -178,15 +178,15 @@ public class ClassicPlotManager extends SquarePlotManager { if (!plot.getMerged(1)) { int x = top.getX(); for (int z = bottom.getZ(); z <= top.getZ(); z++) { - for (int y = dpw.PLOT_HEIGHT; y <= Math.min(maxY, 255); y++) { + for (int y = dpw.PLOT_HEIGHT; y <= maxY; y++) { queue.setBlock(x, y, z, blocks[random.random(blocks.length)]); } } } if (plot.isBasePlot()) { for (RegionWrapper region : plot.getRegions()) { - Location pos1 = new Location(plotArea.worldname, region.minX, Math.min(maxY, 255), region.minZ); - Location pos2 = new Location(plotArea.worldname, region.maxX, Math.min(maxY, 255), region.maxZ); + Location pos1 = new Location(plotArea.worldname, region.minX, maxY, region.minZ); + Location pos2 = new Location(plotArea.worldname, region.maxX, maxY, region.maxZ); queue.setCuboid(pos1, pos2, blocks); } } @@ -295,7 +295,7 @@ public class ClassicPlotManager extends SquarePlotManager { int maxY = plotArea.getPlotManager().getWorldHeight(); queue.setCuboid( new Location(plotArea.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), - new Location(plotArea.worldname, ex, Math.min(maxY, 255), ez - 1), PlotBlock.get((short) 0, (byte) 0)); + new Location(plotArea.worldname, ex, maxY, ez - 1), PlotBlock.get((short) 0, (byte) 0)); queue.setCuboid(new Location(plotArea.worldname, sx, 0, sz + 1), new Location(plotArea.worldname, ex, 0, ez - 1), PlotBlock.get((short) 7, (byte) 0)); @@ -325,10 +325,9 @@ public class ClassicPlotManager extends SquarePlotManager { int sx = pos1.getX() - 2; int ex = pos2.getX() + 2; LocalBlockQueue queue = plotArea.getQueue(false); - int maxY = plotArea.getPlotManager().getWorldHeight(); queue.setCuboid( new Location(plotArea.worldname, sx + 1, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), - new Location(plotArea.worldname, ex - 1, Math.min(maxY, 255), ez), PlotBlock.get((short) 0, (byte) 0)); + new Location(plotArea.worldname, ex - 1, plotArea.getPlotManager().getWorldHeight(), ez), PlotBlock.get((short) 0, (byte) 0)); queue.setCuboid(new Location(plotArea.worldname, sx + 1, 0, sz), new Location(plotArea.worldname, ex - 1, 0, ez), PlotBlock.get((short) 7, (byte) 0)); queue.setCuboid(new Location(plotArea.worldname, sx + 1, 1, sz), @@ -357,7 +356,7 @@ public class ClassicPlotManager extends SquarePlotManager { int ez = sz + dpw.ROAD_WIDTH - 1; LocalBlockQueue queue = plotArea.getQueue(false); queue.setCuboid(new Location(plotArea.worldname, sx + 1, dpw.ROAD_HEIGHT + 1, sz + 1), - new Location(plotArea.worldname, ex - 1, 255, ez - 1), PlotBlock.get( + new Location(plotArea.worldname, ex - 1, dpw.getPlotManager().getWorldHeight(), ez - 1), PlotBlock.get( (short) 0, (byte) 0)); queue.setCuboid(new Location(plotArea.worldname, sx + 1, 0, sz + 1), new Location(plotArea.worldname, ex - 1, 0, ez - 1), PlotBlock.get((short) 7, (byte) 0)); @@ -377,9 +376,8 @@ public class ClassicPlotManager extends SquarePlotManager { int sz = pos1.getZ() - 1; int ez = pos2.getZ() + 1; LocalBlockQueue queue = plotArea.getQueue(false); - int maxY = plotArea.getPlotManager().getWorldHeight(); queue.setCuboid(new Location(plotArea.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), - new Location(plotArea.worldname, ex, Math.min(maxY, 255), ez), PlotBlock.get((short) 0, (byte) 0)); + new Location(plotArea.worldname, ex, plotArea.getPlotManager().getWorldHeight(), ez), PlotBlock.get((short) 0, (byte) 0)); queue.setCuboid(new Location(plotArea.worldname, sx, 1, sz + 1), new Location(plotArea.worldname, ex, dpw.PLOT_HEIGHT - 1, ez - 1), dpw.MAIN_BLOCK); queue.setCuboid(new Location(plotArea.worldname, sx, dpw.PLOT_HEIGHT, sz + 1), @@ -398,9 +396,8 @@ public class ClassicPlotManager extends SquarePlotManager { int sx = pos1.getX() - 1; int ex = pos2.getX() + 1; LocalBlockQueue queue = plotArea.getQueue(false); - int maxY = plotArea.getPlotManager().getWorldHeight(); queue.setCuboid(new Location(plotArea.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), - new Location(plotArea.worldname, ex, Math.min(maxY, 255), ez), PlotBlock.get((short) 0, (byte) 0)); + new Location(plotArea.worldname, ex, plotArea.getPlotManager().getWorldHeight(), ez), PlotBlock.get((short) 0, (byte) 0)); queue.setCuboid(new Location(plotArea.worldname, sx + 1, 1, sz), new Location(plotArea.worldname, ex - 1, dpw.PLOT_HEIGHT - 1, ez), dpw.MAIN_BLOCK); queue.setCuboid(new Location(plotArea.worldname, sx + 1, dpw.PLOT_HEIGHT, sz), @@ -419,7 +416,7 @@ public class ClassicPlotManager extends SquarePlotManager { int ez = sz + dpw.ROAD_WIDTH - 1; LocalBlockQueue queue = plotArea.getQueue(false); queue.setCuboid(new Location(plotArea.worldname, sx, dpw.ROAD_HEIGHT + 1, sz), - new Location(plotArea.worldname, ex, 255, ez), PlotBlock.get((short) 0, (byte) 0)); + new Location(plotArea.worldname, ex, plotArea.getPlotManager().getWorldHeight(), ez), PlotBlock.get((short) 0, (byte) 0)); queue.setCuboid(new Location(plotArea.worldname, sx, 1, sz), new Location(plotArea.worldname, ex, dpw.ROAD_HEIGHT - 1, ez), dpw.MAIN_BLOCK); queue.setCuboid(new Location(plotArea.worldname, sx, dpw.ROAD_HEIGHT, sz), diff --git a/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java b/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java index 456129214..d354a7a77 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java @@ -322,15 +322,16 @@ public abstract class HybridUtils { Location bot = plot.getBottomAbs().subtract(1, 0, 1); Location top = plot.getTopAbs(); final HybridPlotWorld plotworld = (HybridPlotWorld) plot.getArea(); + PlotManager plotManager = plotworld.getPlotManager(); int sx = bot.getX() - plotworld.ROAD_WIDTH + 1; int sz = bot.getZ() + 1; int sy = plotworld.ROAD_HEIGHT; int ex = bot.getX(); int ez = top.getZ(); - int ey = get_ey(queue, sx, ex, sz, ez, sy); + int ey = get_ey(plotManager, queue, sx, ex, sz, ez, sy); int bz = sz - plotworld.ROAD_WIDTH; int tz = sz - 1; - int ty = get_ey(queue, sx, ex, bz, tz, sy); + int ty = get_ey(plotManager, queue, sx, ex, bz, tz, sy); Set sideRoad = new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ey, sz, ez))); final Set intersection = new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ty, bz, tz))); @@ -354,11 +355,11 @@ public abstract class HybridUtils { return true; } - public int get_ey(LocalBlockQueue queue, int sx, int ex, int sz, int ez, int sy) { + public int get_ey(final PlotManager pm, LocalBlockQueue queue, int sx, int ex, int sz, int ez, int sy) { int ey = sy; for (int x = sx; x <= ex; x++) { for (int z = sz; z <= ez; z++) { - for (int y = sy; y < 256; y++) { + for (int y = sy; y <= pm.getWorldHeight(); y++) { if (y > ey) { PlotBlock block = queue.getBlock(x, y, z); if (block.id != 0) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/HastebinUtility.java b/Core/src/main/java/com/intellectualcrafters/plot/util/HastebinUtility.java index 8acddb621..71e605598 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/HastebinUtility.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/HastebinUtility.java @@ -1,13 +1,10 @@ package com.intellectualcrafters.plot.util; -import java.io.BufferedReader; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStreamReader; +import java.io.*; import java.net.HttpURLConnection; import java.net.URL; +import java.util.ArrayList; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -49,13 +46,17 @@ public class HastebinUtility { public static String upload(final File file) throws IOException { final StringBuilder content = new StringBuilder(); + List lines = new ArrayList<>(); try (BufferedReader reader = new BufferedReader(new FileReader(file))) { String line; int i = 0; - while ((line = reader.readLine()) != null && i++ < 1000) { - content.append(line).append("\n"); + while ((line = reader.readLine()) != null) { + lines.add(line); } } + for (int i = Math.max(0, lines.size() - 1000); i < lines.size(); i++) { + content.append(lines.get(i)).append("\n"); + } return upload(content.toString()); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java b/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java index 08ba065b9..22349a858 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java @@ -52,7 +52,7 @@ public class ExpireManager { public void handleJoin(PlotPlayer pp) { storeDate(pp.getUUID(), System.currentTimeMillis()); - if (!plotsToDelete.isEmpty()) { + if (plotsToDelete != null && !plotsToDelete.isEmpty()) { for (Plot plot : pp.getPlots()) { plotsToDelete.remove(plot); } @@ -77,7 +77,7 @@ public class ExpireManager { } public void updateExpired(Plot plot) { - if (!plotsToDelete.isEmpty() && plotsToDelete.contains(plot)) { + if (plotsToDelete != null && !plotsToDelete.isEmpty() && plotsToDelete.contains(plot)) { if (isExpired(new ArrayDeque<>(tasks), plot).isEmpty()) { plotsToDelete.remove(plot); } diff --git a/Nukkit/src/main/java/com/plotsquared/nukkit/util/NukkitSetupUtils.java b/Nukkit/src/main/java/com/plotsquared/nukkit/util/NukkitSetupUtils.java index 548d3c935..53530b260 100644 --- a/Nukkit/src/main/java/com/plotsquared/nukkit/util/NukkitSetupUtils.java +++ b/Nukkit/src/main/java/com/plotsquared/nukkit/util/NukkitSetupUtils.java @@ -3,7 +3,6 @@ package com.plotsquared.nukkit.util; import cn.nukkit.level.Level; import cn.nukkit.level.generator.Generator; import com.intellectualcrafters.configuration.ConfigurationSection; -import com.intellectualcrafters.configuration.file.YamlConfiguration; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.generator.GeneratorWrapper; @@ -12,7 +11,7 @@ import com.intellectualcrafters.plot.object.SetupObject; import com.intellectualcrafters.plot.util.SetupUtils; import com.plotsquared.nukkit.NukkitMain; import com.plotsquared.nukkit.generator.NukkitPlotGenerator; -import java.io.File; +import com.plotsquared.nukkit.util.block.NukkitHybridGen; import java.io.IOException; import java.lang.reflect.Field; import java.util.HashMap; @@ -25,6 +24,7 @@ public class NukkitSetupUtils extends SetupUtils { public NukkitSetupUtils(NukkitMain plugin) { this.plugin = plugin; + Generator.addGenerator(NukkitHybridGen.class, "PlotSquared", 1); } @Override @@ -119,14 +119,16 @@ public class NukkitSetupUtils extends SetupUtils { HashMap map = new HashMap<>(); map.put("world", object.world); map.put("plot-generator", PS.get().IMP.getDefaultGenerator()); - if (!plugin.getServer().generateLevel(object.world, object.world.hashCode(), NukkitPlotGenerator.class, map)) { + if (!plugin.getServer().generateLevel(object.world, object.world.hashCode(), NukkitHybridGen.class, map)) { plugin.getServer().loadLevel(object.world); } try { - File nukkitFile = new File("nukkit.yml"); - YamlConfiguration nukkitYml = YamlConfiguration.loadConfiguration(nukkitFile); - nukkitYml.set("worlds." + object.world + ".generator", object.setupGenerator); - nukkitYml.save(nukkitFile); +// File nukkitFile = new File("nukkit.yml"); +// YamlConfiguration nukkitYml = YamlConfiguration.loadConfiguration(nukkitFile); +// if (!nukkitYml.contains("worlds." + object.world + ".generator")) { +// nukkitYml.set("worlds." + object.world + ".generator", object.setupGenerator); +// nukkitYml.save(nukkitFile); +// } } catch (Throwable e) { e.printStackTrace(); } @@ -138,17 +140,6 @@ public class NukkitSetupUtils extends SetupUtils { return object.world; } - public void setGenerator(String world, String generator) { - File file = new File("nukkit.yml").getAbsoluteFile(); - YamlConfiguration yml = YamlConfiguration.loadConfiguration(file); - yml.set("worlds." + world + ".generator", generator); - try { - yml.save(file); - } catch (IOException e) { - e.printStackTrace(); - } - } - @Override public String getGenerator(PlotArea plotArea) { if (SetupUtils.generators.isEmpty()) { diff --git a/Nukkit/src/main/java/com/plotsquared/nukkit/util/block/NukkitHybridGen.java b/Nukkit/src/main/java/com/plotsquared/nukkit/util/block/NukkitHybridGen.java index aec5bf646..68a79014d 100644 --- a/Nukkit/src/main/java/com/plotsquared/nukkit/util/block/NukkitHybridGen.java +++ b/Nukkit/src/main/java/com/plotsquared/nukkit/util/block/NukkitHybridGen.java @@ -2,7 +2,6 @@ package com.plotsquared.nukkit.util.block; import cn.nukkit.level.Level; import com.intellectualcrafters.plot.PS; -import com.intellectualcrafters.plot.generator.HybridGen; import com.plotsquared.nukkit.NukkitMain; import com.plotsquared.nukkit.generator.NukkitPlotGenerator; import java.util.Map;