From 409456e89531a1e35511ec6c47a96f6b743fec84 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sun, 31 Jul 2016 09:16:58 +1000 Subject: [PATCH] Minor sponge fix --- .../intellectualcrafters/plot/flag/Flags.java | 2 +- .../com/plotsquared/sponge/SpongeMain.java | 4 +- .../sponge/util/SpongeSetupUtils.java | 4 +- .../plotsquared/sponge/util/SpongeUtil.java | 3 +- .../sponge/util/block/SpongeLocalQueue.java | 46 +++++++++++-------- 5 files changed, 34 insertions(+), 25 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/Flags.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/Flags.java index 235b3f74a..bb9473c39 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/Flags.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/Flags.java @@ -114,7 +114,7 @@ public final class Flags { } }; public static final BooleanFlag SLEEP = new BooleanFlag("sleep"); - public static final TeleportDenyFlag DENY_TELEPORT = new TeleportDenyFlag("teleport-deny"); + public static final TeleportDenyFlag TELEPORT_DENY = new TeleportDenyFlag("teleport-deny"); private static final HashMap> flags; diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index f43685b3d..8e6641741 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -332,7 +332,7 @@ public class SpongeMain implements IPlotMain { if (gen instanceof SpongePlotGenerator) { PS.get().loadWorld(worldName, (SpongePlotGenerator) gen); } else { - throw new UnsupportedOperationException("NOT IMPLEMENTED YET!"); + throw new UnsupportedOperationException("NOT IMPLEMENTED YET! " + worldName + " | " + gen); } } @@ -345,6 +345,8 @@ public class SpongeMain implements IPlotMain { public PlotPlayer wrapPlayer(Object player) { if (player instanceof Player) { return SpongeUtil.getPlayer((Player) player); + } else if (UUIDHandler.implementation == null) { + return null; } else if (player instanceof String) { return UUIDHandler.getPlayer((String) player); } else if (player instanceof UUID) { diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeSetupUtils.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeSetupUtils.java index cea7fa5a3..061e913f0 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeSetupUtils.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeSetupUtils.java @@ -141,7 +141,7 @@ public class SpongeSetupUtils extends SetupUtils { // create world with generator GeneratorWrapper gw = SetupUtils.generators.get(object.setupGenerator); WorldGeneratorModifier wgm = (WorldGeneratorModifier) gw.getPlatformGenerator(); - + WorldArchetype settings = WorldArchetype.builder() .loadsOnStartup(true) .keepsSpawnLoaded(true) @@ -149,7 +149,7 @@ public class SpongeSetupUtils extends SetupUtils { .generator(GeneratorTypes.OVERWORLD) .usesMapFeatures(false) .enabled(true) - //.generatorModifiers(wgm) + .generatorModifiers(wgm) .build("PS",object.world); WorldProperties properties = null; try { diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java index b6784456c..e6cfd833b 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java @@ -15,6 +15,7 @@ import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.WorldUtil; +import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.object.SpongePlayer; import java.io.IOException; import java.lang.reflect.Field; @@ -52,7 +53,7 @@ import org.spongepowered.api.world.extent.Extent; public class SpongeUtil extends WorldUtil { - public static Cause CAUSE = Cause.of(NamedCause.source("PlotSquared")); + public static Cause CAUSE = Cause.of(NamedCause.source(Sponge.getPluginManager().fromInstance(SpongeMain.THIS).get())); private static BiomeType[] biomes; private static HashMap biomeMap; private static HashMap stateMap; diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java b/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java index 06d37177e..f8f974daa 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java @@ -17,6 +17,7 @@ import net.minecraft.entity.EntityTracker; import net.minecraft.entity.EntityTrackerEntry; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; import net.minecraft.network.play.server.SPacketChunkData; import net.minecraft.network.play.server.SPacketDestroyEntities; import net.minecraft.server.management.PlayerChunkMap; @@ -31,9 +32,6 @@ import org.spongepowered.api.block.BlockState; import org.spongepowered.api.block.BlockTypes; import org.spongepowered.api.world.World; import org.spongepowered.api.world.biome.BiomeType; -import org.spongepowered.api.world.extent.UnmodifiableBlockVolume; -import org.spongepowered.api.world.extent.worker.MutableBlockVolumeWorker; -import org.spongepowered.api.world.extent.worker.procedure.BlockVolumeMapper; public class SpongeLocalQueue extends BasicLocalBlockQueue { @@ -59,7 +57,6 @@ public class SpongeLocalQueue extends BasicLocalBlockQueue { @Override public PlotBlock getBlock(int x, int y, int z) { - World worldObj = getSpongeWorld(); BlockState block = worldObj.getBlock(x, y, z); if (block == null) { @@ -440,24 +437,28 @@ public class SpongeLocalQueue extends BasicLocalBlockQueue { public void setBlocks(LocalChunk lc) { World worldObj = getSpongeWorld(); org.spongepowered.api.world.Chunk spongeChunk = (org.spongepowered.api.world.Chunk) getChunk(worldObj, lc.getX(), lc.getZ()); + Chunk nmsChunk = (Chunk) spongeChunk; char[][] ids = ((CharLocalChunk) lc).blocks; - MutableBlockVolumeWorker blockWorker = spongeChunk.getBlockWorker(SpongeUtil.CAUSE); - blockWorker.map(new BlockVolumeMapper() { - @Override - public BlockState map(UnmodifiableBlockVolume volume, int xx, int y, int zz) { - int x = xx & 15; - int z = zz & 15; - int i = MainUtil.CACHE_I[y][x][z]; - char[] array = ids[i]; - if (array == null) { - return null; - } - int combinedId = array[MainUtil.CACHE_J[y][x][z]]; + for (int layer = 0; layer < 16; layer++) { + char[] array = ids[layer]; + if (array == null) { + continue; + } + ExtendedBlockStorage section = nmsChunk.getBlockStorageArray()[layer]; + short[] cacheX = MainUtil.x_loc[0]; + short[] cacheY = MainUtil.y_loc[0]; + short[] cacheZ = MainUtil.z_loc[0]; + for (int j = 0; j < array.length; j++) { + int combinedId = array[j]; switch (combinedId) { case 0: - return null; + continue; case 1: - return AIR; + int x = cacheX[j]; + int y = cacheY[j]; + int z = cacheZ[j]; + section.set(x, y, z, Blocks.AIR.getDefaultState()); + continue; default: int id = combinedId >> 4; Block block = Block.getBlockById(id); @@ -468,10 +469,15 @@ public class SpongeLocalQueue extends BasicLocalBlockQueue { } else { ibd = block.getDefaultState(); } - return (BlockState) ibd; + x = cacheX[j]; + y = cacheY[j]; + z = cacheZ[j]; + section.set(x, y, z, ibd); + continue; } } - }); + } + refreshChunk(nmsChunk.xPosition, nmsChunk.zPosition); } public void setBiomes(LocalChunk lc) {