From f68042bc115dab2f795277f7a126bd9a12933b9b Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 27 Feb 2016 16:05:21 +1100 Subject: [PATCH] Fixes Fixes unlink failing if a parameter is provided Fix plot unlinking not resetting the road biome Fixes #888 --- Bukkit/build.gradle | 4 +- Core/build.gradle | 3 +- .../com/intellectualcrafters/plot/PS.java | 9 ---- .../plot/commands/Unlink.java | 2 +- .../plot/generator/HybridPlotManager.java | 31 +++++++------- .../plot/object/Plot.java | 11 +++-- .../plot/util/MainUtil.java | 42 +++++++++---------- .../plotsquared/listener/PlotListener.java | 1 - Sponge/build.gradle | 4 +- build.gradle | 2 - 10 files changed, 50 insertions(+), 59 deletions(-) diff --git a/Bukkit/build.gradle b/Bukkit/build.gradle index 156341ac3..5772b37b6 100644 --- a/Bukkit/build.gradle +++ b/Bukkit/build.gradle @@ -18,14 +18,14 @@ processResources { } apply plugin: 'com.github.johnrengelman.shadow' - +// We only want the shadow jar produced +jar.enabled = false shadowJar { dependencies { include(dependency(':Core')) } archiveName = "${parent.name}-${project.name}-${parent.version}.jar" } - shadowJar.doLast { task -> ant.checksum file: task.archivePath diff --git a/Core/build.gradle b/Core/build.gradle index ba09a052d..1c2d200f5 100644 --- a/Core/build.gradle +++ b/Core/build.gradle @@ -1,3 +1,4 @@ dependencies { compile 'org.yaml:snakeyaml:1.16' -} \ No newline at end of file +} +jar.archiveName="PlotSquared-API-${parent.version}.jar" \ No newline at end of file diff --git a/Core/src/main/java/com/intellectualcrafters/plot/PS.java b/Core/src/main/java/com/intellectualcrafters/plot/PS.java index a89908024..9fca037ac 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/PS.java @@ -1352,9 +1352,7 @@ public class PS { * @param baseGenerator The generator for that world, or null if no generator */ public void loadWorld(final String world, final GeneratorWrapper baseGenerator) { - System.out.println("LOADING WORLD!? " + world); if (world.equals("CheckingPlotSquaredGenerator")) { - System.out.println("IS CHECK" + world); return; } final Set worlds = (config.contains("worlds") ? config.getConfigurationSection("worlds").getKeys(false) : new HashSet()); @@ -1383,13 +1381,11 @@ public class PS { pg = primaryGenerator.getPlotGenerator(); } else { - System.out.println("NO GENERATOR?! " + world); return; } } } else { - System.out.println("NO WORLD SECTION?! " + world); return; } // Conventional plot generator @@ -1415,9 +1411,7 @@ public class PS { pg.initialize(plotArea); plotArea.setupBorder(); } else { - System.out.println("NOT TYPE 0 " + world); if (!worlds.contains(world)) { - System.out.println("WORLD DOESN'T EXIST " + world); return; } ConfigurationSection areasSection = worldSection.getConfigurationSection("areas"); @@ -1469,7 +1463,6 @@ public class PS { for (PlotArea area : toLoad) { addPlotArea(area); } - System.out.println("ADDED BY CLUSTER! " + world); return; } GeneratorWrapper areaGen = IMP.getGenerator(world, gen_string); @@ -1490,7 +1483,6 @@ public class PS { areaGen.getPlotGenerator().initialize(pa); areaGen.augment(pa); addPlotArea(pa); - System.out.println("ADDED BY AUG! " + world); return; } if (type == 1) { @@ -1566,7 +1558,6 @@ public class PS { areaGen.getPlotGenerator().initialize(pa); areaGen.augment(pa); addPlotArea(pa); - System.out.println("ADDED BY PART! " + world); } } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java index 88957bb5e..aee84a6bb 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -54,7 +54,7 @@ public class Unlink extends SubCommand { } final boolean createRoad; if (args.length != 0) { - if (args.length != 1 || StringMan.isEqualIgnoreCaseToAny(args[1], "true", "false")) { + if (args.length != 1 || StringMan.isEqualIgnoreCaseToAny(args[0], "true", "false")) { C.COMMAND_SYNTAX.send(plr, getUsage()); return false; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java b/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java index 54654d825..69272e951 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -30,11 +30,7 @@ import com.intellectualcrafters.plot.object.PlotArea; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.RunnableVal; -import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.MathMan; -import com.intellectualcrafters.plot.util.SetQueue; -import com.intellectualcrafters.plot.util.WorldUtil; +import com.intellectualcrafters.plot.util.*; import java.io.File; import java.io.IOException; @@ -76,20 +72,21 @@ public class HybridPlotManager extends ClassicPlotManager { public boolean createRoadEast(final PlotArea plotworld, final Plot plot) { super.createRoadEast(plotworld, plot); final HybridPlotWorld hpw = (HybridPlotWorld) plotworld; - if (!hpw.ROAD_SCHEMATIC_ENABLED) { - return true; - } final PlotId id = plot.getId(); final PlotId id2 = new PlotId(id.x + 1, id.y); final Location bot = getPlotBottomLocAbs(hpw, id2); final Location top = getPlotTopLocAbs(hpw, id); final Location pos1 = new Location(plotworld.worldname, top.getX() + 1, 0, bot.getZ() - 1); final Location pos2 = new Location(plotworld.worldname, bot.getX(), 255, top.getZ() + 1); + MainUtil.resetBiome(plotworld, pos1, pos2); + if (!hpw.ROAD_SCHEMATIC_ENABLED) { + return true; + } createSchemAbs(hpw, pos1, pos2, 0, true); return true; } - - public void createSchemAbs(final HybridPlotWorld hpw, final Location pos1, final Location pos2, final int height, final boolean clear) { + + private void createSchemAbs(final HybridPlotWorld hpw, final Location pos1, final Location pos2, final int height, final boolean clear) { final int size = hpw.SIZE; for (int x = pos1.getX(); x <= pos2.getX(); x++) { short absX = (short) ((x - hpw.ROAD_OFFSET_X) % (size)); @@ -120,15 +117,16 @@ public class HybridPlotManager extends ClassicPlotManager { public boolean createRoadSouth(final PlotArea plotworld, final Plot plot) { super.createRoadSouth(plotworld, plot); final HybridPlotWorld hpw = (HybridPlotWorld) plotworld; - if (!hpw.ROAD_SCHEMATIC_ENABLED) { - return true; - } final PlotId id = plot.getId(); final PlotId id2 = new PlotId(id.x, id.y + 1); final Location bot = getPlotBottomLocAbs(hpw, id2); final Location top = getPlotTopLocAbs(hpw, id); final Location pos1 = new Location(plotworld.worldname, bot.getX() - 1, 0, top.getZ() + 1); final Location pos2 = new Location(plotworld.worldname, top.getX() + 1, 255, bot.getZ()); + MainUtil.resetBiome(plotworld, pos1, pos2); + if (!hpw.ROAD_SCHEMATIC_ENABLED) { + return true; + } createSchemAbs(hpw, pos1, pos2, 0, true); return true; } @@ -137,9 +135,6 @@ public class HybridPlotManager extends ClassicPlotManager { public boolean createRoadSouthEast(final PlotArea plotworld, final Plot plot) { super.createRoadSouthEast(plotworld, plot); final HybridPlotWorld hpw = (HybridPlotWorld) plotworld; - if (!hpw.ROAD_SCHEMATIC_ENABLED) { - return true; - } final PlotId id = plot.getId(); final PlotId id2 = new PlotId(id.x + 1, id.y + 1); final Location pos1 = getPlotTopLocAbs(hpw, id).add(1, 0, 1); @@ -147,6 +142,10 @@ public class HybridPlotManager extends ClassicPlotManager { pos1.setY(0); pos2.setY(256); createSchemAbs(hpw, pos1, pos2, 0, true); + if (!hpw.ROAD_SCHEMATIC_ENABLED) { + return true; + } + createSchemAbs(hpw, pos1, pos2, 0, true); return true; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java index 0e2a25e66..8ecaaf7a1 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -1056,9 +1056,12 @@ public class Plot { } public Location getCenter() { - final Location top = this.getTop(); - final Location bot = this.getBottom(); - return new Location(this.area.worldname, (top.getX() + bot.getX()) / 2, (top.getY() + bot.getY()) / 2, (top.getZ() + bot.getZ()) / 2); + Location[] corners = getCorners(); + final Location top = corners[0]; + final Location bot = corners[1]; + Location loc = new Location(this.area.worldname, (top.getX() + bot.getX()) / 2, (top.getY() + bot.getY()) / 2, (top.getZ() + bot.getZ()) / 2); + loc.setY(WorldUtil.IMP.getHighestBlock(top.getWorld(), loc.getX(), loc.getY())); + return loc; } /** @@ -1510,7 +1513,7 @@ public class Plot { */ @Deprecated public Location getTop() { - return this.getCorners()[0]; + return this.getCorners()[1]; } /** diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index f93d15d96..b3713d531 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -20,33 +20,17 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.util; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.UUID; -import java.util.regex.Matcher; - import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; -import com.intellectualcrafters.plot.object.ChunkLoc; -import com.intellectualcrafters.plot.object.ConsolePlayer; -import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotArea; -import com.intellectualcrafters.plot.object.PlotBlock; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.PseudoRandom; -import com.intellectualcrafters.plot.object.RegionWrapper; -import com.intellectualcrafters.plot.object.RunnableVal; +import com.intellectualcrafters.plot.object.*; + +import java.util.*; +import java.util.Map.Entry; +import java.util.regex.Matcher; /** * plot functions @@ -119,6 +103,22 @@ public class MainUtil { } } } + + /** + * Resets the biome if it was modified + * @param area + * @param pos1 + * @param pos2 + * @return true if any changes were made + */ + public static boolean resetBiome(PlotArea area, Location pos1, Location pos2) { + String biome = WorldUtil.IMP.getBiomeList()[area.PLOT_BIOME]; + if (!StringMan.isEqual(WorldUtil.IMP.getBiome(area.worldname, (pos1.getX() + pos2.getX()) / 2, (pos1.getZ() + pos2.getZ()) / 2), biome)) { + MainUtil.setBiome(area.worldname, pos1.getX(), pos1.getZ(), pos2.getX(), pos2.getZ(), biome); + return true; + } + return false; + } /** * Hashcode of a boolean array.
diff --git a/Core/src/main/java/com/plotsquared/listener/PlotListener.java b/Core/src/main/java/com/plotsquared/listener/PlotListener.java index b28fcc400..43363b366 100644 --- a/Core/src/main/java/com/plotsquared/listener/PlotListener.java +++ b/Core/src/main/java/com/plotsquared/listener/PlotListener.java @@ -51,7 +51,6 @@ import java.util.UUID; public class PlotListener { public static boolean plotEntry(final PlotPlayer pp, final Plot plot) { - System.out.println("POLOT ENTRY"); if (plot.isDenied(pp.getUUID()) && !Permissions.hasPermission(pp, "plots.admin.entry.denied")) { return false; } diff --git a/Sponge/build.gradle b/Sponge/build.gradle index 74c25ab6e..ce9de41d5 100644 --- a/Sponge/build.gradle +++ b/Sponge/build.gradle @@ -46,14 +46,14 @@ processResources { 'mcVersion': project.minecraft.version } } - +// We only want the shadow jar produced +jar.enabled = false shadowJar { dependencies { include(dependency(':Core')) } archiveName = "${parent.name}-${project.name}-${parent.version}.jar" } - shadowJar.doLast { task -> ant.checksum file: task.archivePath diff --git a/build.gradle b/build.gradle index a72cddf94..736f61b57 100644 --- a/build.gradle +++ b/build.gradle @@ -19,8 +19,6 @@ subprojects { apply plugin: 'eclipse' apply plugin: 'idea' - jar.enabled = false; - dependencies { compile(group: 'com.sk89q', name: 'worldedit', version:'6.0.0-SNAPSHOT') { exclude(module: 'bukkit-classloader-check')