From 4669f316581a0aeec32d3da8e451a1ec3fc8533c Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Fri, 26 Feb 2016 17:29:31 +1100 Subject: [PATCH] Fixes Fixes hybridplotworld rotation for stairs Fixes hybridplotworld skipping non-rotatable blocks on swapped sideroad schem Fixes schematic generation using wrong height Fixes debug spam printed when using download cmd Fixes pagination having page number instead of total list items Fixes plot area list page being off by 1 Remove compatibility for a spigot 1.8.0 bug where getting the world name during initialization crashes the server. Fixes type 1,2 plot worlds not being fetchable if there are more than 8 plot worlds loaded. --- .../com/plotsquared/bukkit/BukkitMain.java | 103 ++++-------------- .../bukkit/generator/BukkitPlotGenerator.java | 41 +++---- .../bukkit/listeners/WorldEvents.java | 13 +-- .../com/intellectualcrafters/plot/PS.java | 31 ++++-- .../plot/commands/Area.java | 2 +- .../plot/commands/SubCommand.java | 2 +- .../plot/generator/HybridGen.java | 24 ++-- .../plot/generator/HybridPlotManager.java | 11 +- .../plot/generator/HybridPlotWorld.java | 35 +++--- .../plot/util/SchematicHandler.java | 73 ++++--------- 10 files changed, 115 insertions(+), 220 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index e12b5ab7e..5a515e3ea 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -1,30 +1,5 @@ package com.plotsquared.bukkit; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.OfflinePlayer; -import org.bukkit.Server; -import org.bukkit.World; -import org.bukkit.command.PluginCommand; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.Listener; -import org.bukkit.generator.ChunkGenerator; -import org.bukkit.metadata.MetadataValue; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.java.JavaPlugin; - import com.intellectualcrafters.configuration.ConfigurationSection; import com.intellectualcrafters.plot.IPlotMain; import com.intellectualcrafters.plot.PS; @@ -37,67 +12,40 @@ import com.intellectualcrafters.plot.generator.GeneratorWrapper; import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.generator.IndependentPlotGenerator; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotArea; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.RunnableVal; -import com.intellectualcrafters.plot.object.SetupObject; -import com.intellectualcrafters.plot.util.AbstractTitle; -import com.intellectualcrafters.plot.util.ChatManager; -import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.ConsoleColors; -import com.intellectualcrafters.plot.util.EconHandler; -import com.intellectualcrafters.plot.util.EventUtil; -import com.intellectualcrafters.plot.util.InventoryUtil; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.PlotQueue; -import com.intellectualcrafters.plot.util.SchematicHandler; -import com.intellectualcrafters.plot.util.SetupUtils; -import com.intellectualcrafters.plot.util.StringMan; -import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.UUIDHandler; -import com.intellectualcrafters.plot.util.UUIDHandlerImplementation; -import com.intellectualcrafters.plot.util.WorldUtil; +import com.intellectualcrafters.plot.object.*; +import com.intellectualcrafters.plot.util.*; import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.plotsquared.bukkit.commands.DebugUUID; import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector; import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter; import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017; import com.plotsquared.bukkit.generator.BukkitPlotGenerator; -import com.plotsquared.bukkit.listeners.ChunkListener; -import com.plotsquared.bukkit.listeners.ForceFieldListener; -import com.plotsquared.bukkit.listeners.PlayerEvents; -import com.plotsquared.bukkit.listeners.PlayerEvents_1_8; -import com.plotsquared.bukkit.listeners.PlayerEvents_1_8_3; -import com.plotsquared.bukkit.listeners.PlotPlusListener; -import com.plotsquared.bukkit.listeners.WorldEvents; +import com.plotsquared.bukkit.listeners.*; import com.plotsquared.bukkit.listeners.worldedit.WEListener; import com.plotsquared.bukkit.titles.DefaultTitle; -import com.plotsquared.bukkit.util.BukkitChatManager; -import com.plotsquared.bukkit.util.BukkitChunkManager; -import com.plotsquared.bukkit.util.BukkitCommand; -import com.plotsquared.bukkit.util.BukkitEconHandler; -import com.plotsquared.bukkit.util.BukkitEventUtil; -import com.plotsquared.bukkit.util.BukkitHybridUtils; -import com.plotsquared.bukkit.util.BukkitInventoryUtil; -import com.plotsquared.bukkit.util.BukkitPlainChatManager; -import com.plotsquared.bukkit.util.BukkitSchematicHandler; -import com.plotsquared.bukkit.util.BukkitSetupUtils; -import com.plotsquared.bukkit.util.BukkitTaskManager; -import com.plotsquared.bukkit.util.BukkitUtil; -import com.plotsquared.bukkit.util.Metrics; -import com.plotsquared.bukkit.util.SendChunk; -import com.plotsquared.bukkit.util.SetGenCB; +import com.plotsquared.bukkit.util.*; import com.plotsquared.bukkit.util.block.FastQueue_1_7; import com.plotsquared.bukkit.util.block.FastQueue_1_8; import com.plotsquared.bukkit.util.block.FastQueue_1_8_3; import com.plotsquared.bukkit.util.block.SlowQueue; -import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper; -import com.plotsquared.bukkit.uuid.FileUUIDHandler; -import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper; -import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper; -import com.plotsquared.bukkit.uuid.SQLUUIDHandler; +import com.plotsquared.bukkit.uuid.*; import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import org.bukkit.*; +import org.bukkit.Location; +import org.bukkit.command.PluginCommand; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; +import org.bukkit.generator.ChunkGenerator; +import org.bukkit.metadata.MetadataValue; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.java.JavaPlugin; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.*; public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @@ -346,19 +294,10 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) { - WorldEvents.lastWorld = world; final HybridGen result = new HybridGen(); if (!PS.get().setupPlotWorld(world, id, result)) { return null; } - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - if ((WorldEvents.lastWorld != null) && WorldEvents.lastWorld.equals(world)) { - WorldEvents.lastWorld = null; - } - } - }, 20); return (ChunkGenerator) result.specify(); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java index e2093b9cd..e8b300ef3 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java @@ -20,33 +20,27 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.plotsquared.bukkit.generator; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import java.util.Set; - +import com.intellectualcrafters.plot.PS; +import com.intellectualcrafters.plot.generator.GeneratorWrapper; +import com.intellectualcrafters.plot.generator.HybridGen; +import com.intellectualcrafters.plot.generator.IndependentPlotGenerator; +import com.intellectualcrafters.plot.object.*; +import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.PlotChunk; +import com.intellectualcrafters.plot.util.SetQueue; +import com.plotsquared.bukkit.util.BukkitUtil; +import com.plotsquared.bukkit.util.block.GenChunk; import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; -import com.intellectualcrafters.plot.PS; -import com.intellectualcrafters.plot.generator.GeneratorWrapper; -import com.intellectualcrafters.plot.generator.HybridGen; -import com.intellectualcrafters.plot.generator.IndependentPlotGenerator; -import com.intellectualcrafters.plot.object.PlotArea; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotManager; -import com.intellectualcrafters.plot.object.PseudoRandom; -import com.intellectualcrafters.plot.object.SetupObject; -import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.PlotChunk; -import com.intellectualcrafters.plot.util.SetQueue; -import com.plotsquared.bukkit.listeners.WorldEvents; -import com.plotsquared.bukkit.util.BukkitUtil; -import com.plotsquared.bukkit.util.block.GenChunk; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.Set; public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper { @@ -96,7 +90,6 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap throw new IllegalArgumentException("ChunkGenerator: " + cg.getClass().getName() + " is already a BukkitPlotGenerator!"); } this.full = false; - WorldEvents.lastWorld = world; PS.get().debug("BukkitPlotGenerator does not fully support: " + cg); platformGenerator = cg; plotGenerator = new IndependentPlotGenerator() { @@ -205,7 +198,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap public List getDefaultPopulators(final World world) { try { if (!loaded) { - final String name = WorldEvents.getName(world); + final String name = world.getName(); PS.get().loadWorld(name, this); Set areas = PS.get().getPlotAreas(name); if (!areas.isEmpty()) { @@ -265,7 +258,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap public void generate(World world, int cx, int cz, GenChunk result) { // Load if improperly loaded if (!loaded) { - final String name = WorldEvents.getName(world); + final String name = world.getName(); PS.get().loadWorld(name, this); loaded = true; } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/WorldEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/WorldEvents.java index 15e4b7247..7fbec47f8 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/WorldEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/WorldEvents.java @@ -13,20 +13,10 @@ import com.plotsquared.bukkit.generator.BukkitPlotGenerator; public class WorldEvents implements Listener { - public static String lastWorld = null; - - public static String getName(final World world) { - if ((lastWorld != null) && !lastWorld.equals("CheckingPlotSquaredGenerator")) { - return lastWorld; - } else { - return world.getName(); - } - } - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onWorldInit(final WorldInitEvent event) { final World world = event.getWorld(); - final String name = getName(world); + final String name = world.getName(); final ChunkGenerator gen = world.getGenerator(); if (gen instanceof GeneratorWrapper) { PS.get().loadWorld(name, (GeneratorWrapper) gen); @@ -35,6 +25,5 @@ public class WorldEvents implements Listener { PS.get().loadWorld(name, new BukkitPlotGenerator(name, gen)); } } - lastWorld = null; } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/PS.java b/Core/src/main/java/com/intellectualcrafters/plot/PS.java index 577f32ccc..a89908024 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/PS.java @@ -616,19 +616,17 @@ public class PS { globalAreas.add(plotarea); plotareas = globalAreas.toArray(new PlotArea[globalAreas.size()]); plotareamap.put(plotarea.worldname, localAreas.toArray(new PlotArea[localAreas.size()])); - if (plotarea.TYPE == 2) { - QuadMap map = plotareagrid.get(plotarea.worldname); - if (map == null) { - map = new QuadMap(Integer.MAX_VALUE, 0, 0) { - @Override - public RegionWrapper getRegion(PlotArea value) { - return value.getRegion(); - } - }; - plotareagrid.put(plotarea.worldname, map); - } - map.add(plotarea); + QuadMap map = plotareagrid.get(plotarea.worldname); + if (map == null) { + map = new QuadMap(Integer.MAX_VALUE, 0, 0) { + @Override + public RegionWrapper getRegion(PlotArea value) { + return value.getRegion(); + } + }; + plotareagrid.put(plotarea.worldname, map); } + map.add(plotarea); } /** @@ -1354,7 +1352,9 @@ 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,11 +1383,13 @@ 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 @@ -1413,7 +1415,9 @@ 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"); @@ -1465,6 +1469,7 @@ public class PS { for (PlotArea area : toLoad) { addPlotArea(area); } + System.out.println("ADDED BY CLUSTER! " + world); return; } GeneratorWrapper areaGen = IMP.getGenerator(world, gen_string); @@ -1485,6 +1490,7 @@ public class PS { areaGen.getPlotGenerator().initialize(pa); areaGen.augment(pa); addPlotArea(pa); + System.out.println("ADDED BY AUG! " + world); return; } if (type == 1) { @@ -1560,6 +1566,7 @@ 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/Area.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java index 7210290bd..852b43ebe 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java @@ -335,7 +335,7 @@ public class Area extends SubCommand { break; case 2: if (MathMan.isInteger(args[1])) { - page = Integer.parseInt(args[1]); + page = Integer.parseInt(args[1]) - 1; break; } default: diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java index 4e00accf1..ef797fbf9 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java @@ -68,7 +68,7 @@ public abstract class SubCommand extends com.plotsquared.general.commands.Comman max = c.size(); } // Send the header - header = header.replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%amount%", totalPages + "").replaceAll("%word%", "all"); + header = header.replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%amount%", c.size() + "").replaceAll("%word%", "all"); MainUtil.sendMessage(player, header); // Send the page content final List subList = c.subList(page * size, max); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java b/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java index 95585b968..7fdbec550 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -1,16 +1,12 @@ package com.intellectualcrafters.plot.generator; +import com.intellectualcrafters.plot.object.*; +import com.intellectualcrafters.plot.util.MathMan; +import com.intellectualcrafters.plot.util.PlotChunk; + import java.util.HashMap; import java.util.Map.Entry; -import com.intellectualcrafters.plot.object.PlotArea; -import com.intellectualcrafters.plot.object.PlotBlock; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotManager; -import com.intellectualcrafters.plot.object.PseudoRandom; -import com.intellectualcrafters.plot.util.MathMan; -import com.intellectualcrafters.plot.util.PlotChunk; - public class HybridGen extends IndependentPlotGenerator { @Override @@ -80,7 +76,7 @@ public class HybridGen extends IndependentPlotGenerator { result.setBlock(x, y, z, hpw.ROAD_BLOCK); } if (hpw.ROAD_SCHEMATIC_ENABLED) { - HashMap map = sch.get(MathMan.pair(x, z)); + HashMap map = sch.get(MathMan.pair(rx[x], rz[z])); if (map != null) { for (Entry entry : map.entrySet()) { result.setBlock(x, entry.getKey(), z, entry.getValue()); @@ -96,7 +92,7 @@ public class HybridGen extends IndependentPlotGenerator { result.setBlock(x, y, z, hpw.ROAD_BLOCK); } if (hpw.ROAD_SCHEMATIC_ENABLED) { - HashMap map = sch.get(MathMan.pair(x, z)); + HashMap map = sch.get(MathMan.pair(rx[x], rz[z])); if (map != null) { for (Entry entry : map.entrySet()) { result.setBlock(x, entry.getKey(), z, entry.getValue()); @@ -111,7 +107,7 @@ public class HybridGen extends IndependentPlotGenerator { if (!hpw.ROAD_SCHEMATIC_ENABLED) { result.setBlock(x, hpw.WALL_HEIGHT + 1, z, hpw.WALL_BLOCK); } else { - HashMap map = sch.get(MathMan.pair(x, z)); + HashMap map = sch.get(MathMan.pair(rx[x], rz[z])); if (map != null) { for (Entry entry : map.entrySet()) { result.setBlock(x, entry.getKey(), z, entry.getValue()); @@ -128,7 +124,7 @@ public class HybridGen extends IndependentPlotGenerator { result.setBlock(x, y, z, hpw.ROAD_BLOCK); } if (hpw.ROAD_SCHEMATIC_ENABLED) { - HashMap map = sch.get(MathMan.pair(x, z)); + HashMap map = sch.get(MathMan.pair(rx[x], rz[z])); if (map != null) { for (Entry entry : map.entrySet()) { result.setBlock(x, entry.getKey(), z, entry.getValue()); @@ -143,7 +139,7 @@ public class HybridGen extends IndependentPlotGenerator { if (!hpw.ROAD_SCHEMATIC_ENABLED) { result.setBlock(x, hpw.WALL_HEIGHT + 1, z, hpw.WALL_BLOCK); } else { - HashMap map = sch.get(MathMan.pair(x, z)); + HashMap map = sch.get(MathMan.pair(rx[x], rz[z])); if (map != null) { for (Entry entry : map.entrySet()) { result.setBlock(x, entry.getKey(), z, entry.getValue()); @@ -157,7 +153,7 @@ public class HybridGen extends IndependentPlotGenerator { } result.setBlock(x, hpw.PLOT_HEIGHT, z, hpw.TOP_BLOCK[random.random(hpw.TOP_BLOCK.length)]); if (hpw.PLOT_SCHEMATIC) { - HashMap map = sch.get(MathMan.pair(x, z)); + HashMap map = sch.get(MathMan.pair(rx[x], rz[z])); if (map != null) { for (Entry entry : map.entrySet()) { result.setBlock(x, entry.getKey(), z, entry.getValue()); 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 92f6070ed..54654d825 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -85,7 +85,7 @@ public class HybridPlotManager extends ClassicPlotManager { 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); - createSchemAbs(hpw, pos1, pos2, hpw.ROAD_HEIGHT, true); + createSchemAbs(hpw, pos1, pos2, 0, true); return true; } @@ -104,7 +104,7 @@ public class HybridPlotManager extends ClassicPlotManager { final HashMap blocks = hpw.G_SCH.get(MathMan.pair(absX, absZ)); if (clear) { for (short y = (short) (height); y <= (height + hpw.SCHEMATIC_HEIGHT); y++) { - SetQueue.IMP.setBlock(hpw.worldname, x, y + y, z, 0); + SetQueue.IMP.setBlock(hpw.worldname, x, y, z, 0); } } if (blocks != null) { @@ -129,7 +129,7 @@ public class HybridPlotManager extends ClassicPlotManager { 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()); - createSchemAbs(hpw, pos1, pos2, hpw.ROAD_HEIGHT, true); + createSchemAbs(hpw, pos1, pos2, 0, true); return true; } @@ -146,7 +146,7 @@ public class HybridPlotManager extends ClassicPlotManager { final Location pos2 = getPlotBottomLocAbs(hpw, id2); pos1.setY(0); pos2.setY(256); - createSchemAbs(hpw, pos1, pos2, hpw.ROAD_HEIGHT, true); + createSchemAbs(hpw, pos1, pos2, 0, true); return true; } @@ -214,7 +214,6 @@ public class HybridPlotManager extends ClassicPlotManager { if (!plotworld.PLOT_SCHEMATIC) { return; } - createSchemAbs(plotworld, l1, l2, plotworld.PLOT_HEIGHT, false); + createSchemAbs(plotworld, l1, l2, 0, false); } - } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java b/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java index 171cacbfb..d07c5acf2 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java @@ -98,7 +98,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { data = wrap(data, 0); data = wrap(data, 4); data = wrap(data, 8); - data = wrap(data, 16); + data = wrap(data, 12); return data; case 26: @@ -225,7 +225,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { final short id = ids[index]; final byte data = datas[index]; if (id != 0) { - addOverlayBlock((short) (x + shift + oddshift + center_shift_x), y, (short) (z + shift + oddshift + center_shift_z), id, + addOverlayBlock((short) (x + shift + oddshift + center_shift_x), (short) (y + PLOT_HEIGHT), (short) (z + shift + oddshift + center_shift_z), id, data, false); } } @@ -241,10 +241,14 @@ public class HybridPlotWorld extends ClassicPlotWorld { final short x = (short) item.x; final short z = (short) item.z; int pair = MathMan.pair(x, z); - HashSet v = G_SCH_STATE.putIfAbsent(pair, new HashSet()); - if (v != null) { - v.add(item); + + + HashSet existing = G_SCH_STATE.get(pair); + if (existing == null) { + existing = new HashSet<>(); + G_SCH_STATE.put(pair, existing); } + existing.add(item); } } } @@ -278,8 +282,8 @@ public class HybridPlotWorld extends ClassicPlotWorld { final short id = ids1[index]; final byte data = datas1[index]; if (id != 0) { - addOverlayBlock((short) (x - shift), y, (short) (z + shift + oddshift), id, data, false); - addOverlayBlock((short) (z + shift + oddshift), y, (short) (x - shift), id, data, true); + addOverlayBlock((short) (x - shift), (short) (y + ROAD_HEIGHT), (short) (z + shift + oddshift), id, data, false); + addOverlayBlock((short) (z + shift + oddshift), (short) (y + ROAD_HEIGHT), (short) (x - shift), id, data, true); } } } @@ -291,7 +295,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { final short id = ids2[index]; final byte data = datas2[index]; if (id != 0) { - addOverlayBlock((short) (x - shift), y, (short) (z - shift), id, data, false); + addOverlayBlock((short) (x - shift), (short) (y + ROAD_HEIGHT), (short) (z - shift), id, data, false); } } } @@ -307,15 +311,16 @@ public class HybridPlotWorld extends ClassicPlotWorld { } if (rotate) { final byte newdata = rotate(id, data); - if (data == 0 && newdata == 0) { - return; + if (data != 0 || newdata != 0) { + data = newdata; } - data = newdata; } - int pair = MathMan.pair(x, y); - HashMap v = G_SCH.putIfAbsent(pair, new HashMap()); - if (v != null) { - v.put((int) y, new PlotBlock(id, data)); + int pair = MathMan.pair(x, z); + HashMap existing = G_SCH.get(pair); + if (existing == null) { + existing = new HashMap<>(); + G_SCH.put(pair, existing); } + existing.put((int) y, new PlotBlock(id, data)); } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index e85b3c6c5..eb19ba4b8 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -1,56 +1,23 @@ package com.intellectualcrafters.plot.util; import com.google.common.collect.Lists; -import com.intellectualcrafters.jnbt.ByteArrayTag; -import com.intellectualcrafters.jnbt.CompoundTag; -import com.intellectualcrafters.jnbt.IntTag; -import com.intellectualcrafters.jnbt.ListTag; -import com.intellectualcrafters.jnbt.NBTInputStream; -import com.intellectualcrafters.jnbt.NBTOutputStream; -import com.intellectualcrafters.jnbt.ShortTag; -import com.intellectualcrafters.jnbt.StringTag; -import com.intellectualcrafters.jnbt.Tag; +import com.intellectualcrafters.jnbt.*; import com.intellectualcrafters.json.JSONArray; import com.intellectualcrafters.json.JSONException; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.generator.ClassicPlotWorld; -import com.intellectualcrafters.plot.object.ChunkLoc; -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.RegionWrapper; -import com.intellectualcrafters.plot.object.RunnableVal; +import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.object.schematic.PlotItem; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.io.Reader; +import java.io.*; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; +import java.util.*; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; @@ -583,22 +550,22 @@ public abstract class SchematicHandler { writer.append("--" + boundary + "--").append(CRLF).flush(); nos.close(); } - try (Reader response = new InputStreamReader(con.getInputStream(), StandardCharsets.UTF_8)) { - final char[] buffer = new char[256]; - final StringBuilder result = new StringBuilder(); - while (true) { - final int r = response.read(buffer); - if (r < 0) { - break; - } - result.append(buffer, 0, r); - } - if (!result.toString().equals("The file plot.schematic has been uploaded.")) { - PS.debug(result); - } - } catch (IOException e) { - e.printStackTrace(); - } +// try (Reader response = new InputStreamReader(con.getInputStream(), StandardCharsets.UTF_8)) { +// final char[] buffer = new char[256]; +// final StringBuilder result = new StringBuilder(); +// while (true) { +// final int r = response.read(buffer); +// if (r < 0) { +// break; +// } +// result.append(buffer, 0, r); +// } +// if (!result.toString().equals("The file plot.schematic has been uploaded.")) { +// PS.debug(result); +// } +// } catch (IOException e) { +// e.printStackTrace(); +// } final int responseCode = ((HttpURLConnection) con).getResponseCode(); if (responseCode != 200) { return null;