diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridGen.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridGen.java index 24fc39bfe..bccb61d32 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridGen.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridGen.java @@ -3,14 +3,10 @@ package com.github.intellectualsites.plotsquared.plot.generator; import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.util.MathMan; -import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler; -import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; -import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; -import com.sk89q.jnbt.CompoundTag; +import com.sk89q.worldedit.world.block.BaseBlock; import java.util.HashMap; -import java.util.Map.Entry; public class HybridGen extends IndependentPlotGenerator { @@ -21,12 +17,11 @@ public class HybridGen extends IndependentPlotGenerator { private void placeSchem(HybridPlotWorld world, ScopedLocalBlockQueue result, short relativeX, short relativeZ, int x, int z) { int minY = Math.min(world.PLOT_HEIGHT, world.ROAD_HEIGHT); - String[] blocks = world.G_SCH.get(MathMan.pair(relativeX, relativeZ)); + BaseBlock[] blocks = world.G_SCH.get(MathMan.pair(relativeX, relativeZ)); if (blocks != null) { for (int y = 0; y < blocks.length; y++) { if (blocks[y] != null) { - PlotBlock block = PlotBlock.get(blocks[y]); - result.setBlock(x, minY + y, z, block); + result.setBlock(x, minY + y, z, blocks[y]); } } } @@ -91,7 +86,7 @@ public class HybridGen extends IndependentPlotGenerator { } } // generation - HashMap sch = hpw.G_SCH; + HashMap sch = hpw.G_SCH; for (short x = 0; x < 16; x++) { if (gx[x]) { for (short z = 0; z < 16; z++) { @@ -160,7 +155,7 @@ public class HybridGen extends IndependentPlotGenerator { } } - @Override public boolean populateChunk(ScopedLocalBlockQueue result, PlotArea settings) { +/* @Override public boolean populateChunk(ScopedLocalBlockQueue result, PlotArea settings) { HybridPlotWorld hpw = (HybridPlotWorld) settings; if (hpw.G_SCH_STATE != null) { Location min = result.getMin(); @@ -220,7 +215,7 @@ public class HybridGen extends IndependentPlotGenerator { } } return false; - } + }*/ @Override public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) { return new HybridPlotWorld(world, id, this, min, max); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java index 50db1ed19..1f6429dbd 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java @@ -9,6 +9,7 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; +import com.sk89q.worldedit.world.block.BaseBlock; import java.io.File; import java.io.IOException; @@ -89,12 +90,11 @@ public class HybridPlotManager extends ClassicPlotManager { if (absZ < 0) { absZ += size; } - String[] blocks = hpw.G_SCH.get(MathMan.pair(absX, absZ)); + BaseBlock[] blocks = hpw.G_SCH.get(MathMan.pair(absX, absZ)); if (blocks != null) { for (int y = 0; y < blocks.length; y++) { if (blocks[y] != null) { - PlotBlock block = PlotBlock.get(blocks[y]); - queue.setBlock(x, minY + y, z, block); + queue.setBlock(x, minY + y, z, blocks[y]); } } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java index ba0a5637a..a4d3317e5 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java @@ -3,7 +3,10 @@ package com.github.intellectualsites.plotsquared.plot.generator; import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection; import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.config.C; -import com.github.intellectualsites.plotsquared.plot.object.*; +import com.github.intellectualsites.plotsquared.plot.object.Location; +import com.github.intellectualsites.plotsquared.plot.object.Plot; +import com.github.intellectualsites.plotsquared.plot.object.PlotArea; +import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic; import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MathMan; @@ -15,11 +18,14 @@ import com.sk89q.worldedit.internal.helper.MCDirections; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.AffineTransform; +import com.sk89q.worldedit.registry.state.DirectionalProperty; +import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.world.block.BaseBlock; import java.io.File; import java.util.HashMap; +import java.util.Map; public class HybridPlotWorld extends ClassicPlotWorld { @@ -28,8 +34,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { public boolean PLOT_SCHEMATIC = false; public short PATH_WIDTH_LOWER; public short PATH_WIDTH_UPPER; - public HashMap G_SCH; - public HashMap> G_SCH_STATE; + public HashMap G_SCH; private Location SIGN_LOCATION; public HybridPlotWorld(String worldName, String id, IndependentPlotGenerator generator, @@ -54,10 +59,37 @@ public class HybridPlotWorld extends ClassicPlotWorld { // FIXME depends on block ids // Possibly make abstract? public static BaseBlock rotate(BaseBlock id) { - CompoundTag tag = id.toBaseBlock().getNbtData(); + Map, Object> stateMap = id.getStates(); + + if (stateMap != null) { + for (Map.Entry, Object> entry : stateMap.entrySet()) { + if (entry.getKey() instanceof DirectionalProperty) { + Direction dir = (Direction) entry.getValue(); + Property property = entry.getKey(); + switch (dir) { + case NORTH: + id = id.with(property, Direction.EAST); + break; + case EAST: + id = id.with(property, Direction.SOUTH); + break; + case SOUTH: + id = id.with(property, Direction.WEST); + break; + case WEST: + id = id.with(property, Direction.NORTH); + break; + } + } + } + return id; + } + + CompoundTag tag = id.getNbtData(); if (tag != null) { // Handle blocks which store their rotation in NBT + PlotSquared.log(tag.getValue().toString()); if (tag.containsKey("Rot")) { int rot = tag.asInt("Rot"); @@ -172,7 +204,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { for (short y = 0; y < h3; y++) { BaseBlock id = blockArrayClipboard3.getFullBlock(BlockVector3.at(x, y, z)) .toBaseBlock(); - if (!id.getBlockType().getId().toLowerCase().contains("air")) { + if (!id.getBlockType().getMaterial().isAir()) { addOverlayBlock((short) (x + shift + oddshift + centerShiftX), (short) (y + startY), (short) (z + shift + oddshift + centerShiftZ), id, false, h3); @@ -237,7 +269,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { for (short y = 0; y < h1; y++) { BaseBlock id = blockArrayClipboard1.getFullBlock(BlockVector3.at(x, y, z)).toBaseBlock(); - if (!id.getBlockType().getId().toLowerCase().contains("air")) { + if (!id.getBlockType().getMaterial().isAir()) { addOverlayBlock((short) (x - shift), (short) (y + startY), (short) (z + shift + oddshift), id, false, h1); addOverlayBlock((short) (z + shift + oddshift), (short) (y + startY), @@ -250,7 +282,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { for (short z = 0; z < l2; z++) { for (short y = 0; y < h2; y++) { BaseBlock id = blockArrayClipboard2.getFullBlock(BlockVector3.at(x, y, z)); - if (!id.getBlockType().getId().toLowerCase().contains("air")) { + if (!id.getBlockType().getMaterial().isAir()) { addOverlayBlock((short) (x - shift), (short) (y + startY), (short) (z - shift), id, false, h2); } @@ -275,11 +307,11 @@ public class HybridPlotWorld extends ClassicPlotWorld { id = rotate(id); } int pair = MathMan.pair(x, z); - String[] existing = this.G_SCH.get(pair); + BaseBlock[] existing = this.G_SCH.get(pair); if (existing == null) { - existing = new String[height]; + existing = new BaseBlock[height]; this.G_SCH.put(pair, existing); } - existing[y] = id.getBlockType().getId(); + existing[y] = id; } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java index 3ac302d8d..30d7ea22f 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java @@ -10,6 +10,7 @@ import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis; import com.sk89q.jnbt.CompoundTag; +import com.sk89q.worldedit.world.block.BaseBlock; import java.io.File; import java.util.*; @@ -352,7 +353,7 @@ public abstract class HybridUtils { condition = !gx || !gz || !lx || !lz; } if (condition) { - String[] blocks = plotWorld.G_SCH.get(MathMan.pair(absX, absZ)); + BaseBlock[] blocks = plotWorld.G_SCH.get(MathMan.pair(absX, absZ)); int minY = Math.min(plotWorld.PLOT_HEIGHT, plotWorld.ROAD_HEIGHT); if (blocks != null) { for (int y = 0; y < blocks.length; y++) {