This commit is contained in:
MattBDev
2016-03-29 15:47:59 -04:00
parent d0622eb87d
commit 6007f040cd
65 changed files with 754 additions and 752 deletions

View File

@ -315,11 +315,11 @@ public class SpongeMain implements IPlotMain {
}
@Override
public void setGenerator(String worldname) {
World world = SpongeUtil.getWorld(worldname);
public void setGenerator(String worldName) {
World world = SpongeUtil.getWorld(worldName);
if (world == null) {
// create world
ConfigurationSection worldConfig = PS.get().config.getConfigurationSection("worlds." + worldname);
ConfigurationSection worldConfig = PS.get().config.getConfigurationSection("worlds." + worldName);
String manager = worldConfig.getString("generator.plugin", "PlotSquared");
String generator = worldConfig.getString("generator.init", manager);
@ -331,15 +331,15 @@ public class SpongeMain implements IPlotMain {
setup.type = type;
setup.terrain = terrain;
setup.step = new ConfigurationNode[0];
setup.world = worldname;
setup.world = worldName;
SetupUtils.manager.setupWorld(setup);
} else {
throw new IllegalArgumentException("World already loaded: " + worldname + "???");
throw new IllegalArgumentException("World already loaded: " + worldName + "???");
}
WorldGenerator wg = world.getWorldGenerator();
GenerationPopulator gen = wg.getBaseGenerationPopulator();
if (gen instanceof SpongePlotGenerator) {
PS.get().loadWorld(worldname, (SpongePlotGenerator) gen);
PS.get().loadWorld(worldName, (SpongePlotGenerator) gen);
} else {
throw new UnsupportedOperationException("NOT IMPLEMENTED YET!");
}

View File

@ -1,10 +1,9 @@
package com.plotsquared.sponge.events;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Cancellable;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Cancellable;
public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellable {
@ -13,43 +12,43 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl
private boolean cancelled;
/**
* PlayerTeleportToPlotEvent: Called when a player teleports to a plot
* PlayerTeleportToPlotEvent: Called when a player teleports to a plot.
*
* @param player That was teleported
* @param from Start location
* @param plot Plot to which the player was teleported
* @param from Start location
* @param plot Plot to which the player was teleported
*/
public PlayerTeleportToPlotEvent(final Player player, final Location from, final Plot plot) {
public PlayerTeleportToPlotEvent(Player player, Location from, Plot plot) {
super(player);
this.from = from;
this.plot = plot;
}
/**
* Get the from location
* Get the from location.
*
* @return Location
*/
public Location getFrom() {
return from;
return this.from;
}
/**
* Get the plot involved
* Get the plot involved.
*
* @return Plot
*/
public Plot getPlot() {
return plot;
return this.plot;
}
@Override
public boolean isCancelled() {
return cancelled;
return this.cancelled;
}
@Override
public void setCancelled(final boolean cancel) {
cancelled = cancel;
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
}

View File

@ -25,9 +25,9 @@ public class SpongeAugmentedGenerator implements GenerationPopulator {
public static SpongeAugmentedGenerator get(World world) {
WorldGenerator wg = world.getWorldGenerator();
List<GenerationPopulator> populators = wg.getGenerationPopulators();
for (GenerationPopulator poplator : populators) {
if (poplator instanceof SpongeAugmentedGenerator) {
return (SpongeAugmentedGenerator) poplator;
for (GenerationPopulator populator : populators) {
if (populator instanceof SpongeAugmentedGenerator) {
return (SpongeAugmentedGenerator) populator;
}
}
if (generator == null) {
@ -38,12 +38,12 @@ public class SpongeAugmentedGenerator implements GenerationPopulator {
}
@Override
public void populate(final World world, final MutableBlockVolume terrain, final ImmutableBiomeArea biome) {
public void populate(World world, MutableBlockVolume terrain, ImmutableBiomeArea biome) {
Vector3i min = terrain.getBlockMin();
final int bx = min.getX();
final int bz = min.getZ();
final int cx = bx >> 4;
final int cz = bz >> 4;
int bx = min.getX();
int bz = min.getZ();
int cx = bx >> 4;
int cz = bz >> 4;
AugmentedUtils.generate(world.getName(), cx, cz, new LazyResult<PlotChunk<?>>() {
@Override
public PlotChunk<?> create() {

View File

@ -28,9 +28,9 @@ public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWra
private final IndependentPlotGenerator plotGenerator;
private final List<GenerationPopulator> populators = new ArrayList<>();
private final boolean loaded = false;
private PlotManager manager;
private final WorldGeneratorModifier platformGenerator;
private final boolean full;
private PlotManager manager;
public SpongePlotGenerator(IndependentPlotGenerator generator) {
this.plotGenerator = generator;
@ -48,34 +48,34 @@ public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWra
@Override
public String getId() {
if (plotGenerator == null) {
if (platformGenerator != this) {
return platformGenerator.getId();
if (this.plotGenerator == null) {
if (this.platformGenerator != this) {
return this.platformGenerator.getId();
}
return "null";
}
return plotGenerator.getName();
return this.plotGenerator.getName();
}
@Override
public String getName() {
if (plotGenerator == null) {
if (platformGenerator != this) {
return platformGenerator.getName();
if (this.plotGenerator == null) {
if (this.platformGenerator != this) {
return this.platformGenerator.getName();
}
return "null";
}
return plotGenerator.getName();
return this.plotGenerator.getName();
}
@Override
public void modifyWorldGenerator(WorldCreationSettings settings, DataContainer data, WorldGenerator wg) {
final String worldname = settings.getWorldName();
wg.setBaseGenerationPopulator(new SpongeTerrainGen(this, plotGenerator));
String worldName = settings.getWorldName();
wg.setBaseGenerationPopulator(new SpongeTerrainGen(this, this.plotGenerator));
wg.setBiomeGenerator(new BiomeGenerator() {
@Override
public void generateBiomes(MutableBiomeArea buffer) {
PlotArea area = PS.get().getPlotArea(worldname, null);
PlotArea area = PS.get().getPlotArea(worldName, null);
if (area != null) {
BiomeType biome = SpongeUtil.getBiome(area.PLOT_BIOME);
Vector2i min = buffer.getBiomeMin();
@ -96,17 +96,17 @@ public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWra
}
wg.getGenerationPopulators().clear();
wg.getPopulators().clear();
PS.get().loadWorld(worldname, this);
PS.get().loadWorld(worldName, this);
}
@Override
public IndependentPlotGenerator getPlotGenerator() {
return plotGenerator;
return this.plotGenerator;
}
@Override
public WorldGeneratorModifier getPlatformGenerator() {
return platformGenerator;
return this.platformGenerator;
}
@Override
@ -116,7 +116,7 @@ public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWra
@Override
public boolean isFull() {
return full;
return this.full;
}
}

View File

@ -372,8 +372,8 @@ public class MainListener {
if (e instanceof ExplosionEvent.Detonate) {
ExplosionEvent.Detonate event = (Detonate) e;
World world = event.getTargetWorld();
String worldname = world.getName();
if (!PS.get().hasPlotArea(worldname)) {
String worldName = world.getName();
if (!PS.get().hasPlotArea(worldName)) {
return;
}
Optional<Explosive> source = event.getExplosion().getSourceExplosive();
@ -418,13 +418,13 @@ public class MainListener {
public void onChangeBlock(ChangeBlockEvent event) {
World world = event.getTargetWorld();
String worldname = world.getName();
if (!PS.get().hasPlotArea(worldname)) {
String worldName = world.getName();
if (!PS.get().hasPlotArea(worldName)) {
return;
}
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
Transaction<BlockSnapshot> first = transactions.get(0);
Location loc = SpongeUtil.getLocation(worldname, first.getOriginal().getPosition());
Location loc = SpongeUtil.getLocation(worldName, first.getOriginal().getPosition());
Plot plot = loc.getPlot();
if (plot == null) {
if (!loc.isPlotArea()) {
@ -436,7 +436,7 @@ public class MainListener {
event.filter(new Predicate<org.spongepowered.api.world.Location<World>>() {
@Override
public boolean test(org.spongepowered.api.world.Location<World> loc) {
return !SpongeUtil.getLocation(worldname, loc).isPlotRoad();
return !SpongeUtil.getLocation(worldName, loc).isPlotRoad();
}
});
}
@ -465,14 +465,14 @@ public class MainListener {
}
PlotPlayer pp = SpongeUtil.getPlayer(player);
World world = event.getTargetWorld();
String worldname = world.getName();
if (!PS.get().hasPlotArea(worldname)) {
String worldName = world.getName();
if (!PS.get().hasPlotArea(worldName)) {
return;
}
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
Transaction<BlockSnapshot> first = transactions.get(0);
BlockSnapshot pos = first.getOriginal();
Location loc = SpongeUtil.getLocation(worldname, pos.getPosition());
Location loc = SpongeUtil.getLocation(worldName, pos.getPosition());
Plot plot = loc.getPlot();
if (plot == null) {
if (!loc.isPlotArea()) {
@ -507,7 +507,7 @@ public class MainListener {
@Override
public boolean test(org.spongepowered.api.world.Location<World> l) {
Location loc = SpongeUtil.getLocation(worldname, l);
Location loc = SpongeUtil.getLocation(worldName, l);
Plot plot = loc.getPlot();
if (plot == null) {
if (loc.getPlotAbs() == null) {
@ -546,14 +546,14 @@ public class MainListener {
}
PlotPlayer pp = SpongeUtil.getPlayer(player);
World world = event.getTargetWorld();
String worldname = world.getName();
if (!PS.get().hasPlotArea(worldname)) {
String worldName = world.getName();
if (!PS.get().hasPlotArea(worldName)) {
return;
}
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
Transaction<BlockSnapshot> first = transactions.get(0);
BlockSnapshot pos = first.getOriginal();
Location loc = SpongeUtil.getLocation(worldname, pos.getPosition());
Location loc = SpongeUtil.getLocation(worldName, pos.getPosition());
Plot plot = loc.getPlot();
if (plot == null) {
if (loc.getPlotAbs() == null) {
@ -588,7 +588,7 @@ public class MainListener {
@Override
public boolean test(org.spongepowered.api.world.Location<World> l) {
Location loc = SpongeUtil.getLocation(worldname, l);
Location loc = SpongeUtil.getLocation(worldName, l);
Plot plot = loc.getPlot();
if (plot == null) {
if (loc.getPlotAbs() == null) {

View File

@ -126,8 +126,8 @@ public class SpongeChunkManager extends ChunkManager {
@Override
public void clearAllEntities(Location pos1, Location pos2) {
String worldname = pos1.getWorld();
World world = SpongeUtil.getWorld(worldname);
String worldName = pos1.getWorld();
World world = SpongeUtil.getWorld(worldName);
int bx = pos1.getX();
int bz = pos1.getZ();
int tx = pos2.getX();

View File

@ -1,28 +1,27 @@
package com.plotsquared.sponge.util;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.block.BlockTypes;
import org.spongepowered.api.world.World;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.object.PlotAnalysis;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.block.BlockTypes;
import org.spongepowered.api.world.World;
public class SpongeHybridUtils extends HybridUtils {
@Override
public int checkModified(final String worldname, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks) {
final World world = SpongeUtil.getWorld(worldname);
public int checkModified(String worldName, int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock[] blocks) {
World world = SpongeUtil.getWorld(worldName);
int count = 0;
for (int y = y1; y <= y2; y++) {
for (int x = x1; x <= x2; x++) {
for (int z = z1; z <= z2; z++) {
final BlockState state = world.getBlock(x, y, z);
final PlotBlock block = SpongeUtil.getPlotBlock(state);
BlockState state = world.getBlock(x, y, z);
PlotBlock block = SpongeUtil.getPlotBlock(state);
boolean same = false;
for (final PlotBlock p : blocks) {
for (PlotBlock p : blocks) {
if (block.id == p.id) {
same = true;
break;
@ -38,15 +37,15 @@ public class SpongeHybridUtils extends HybridUtils {
}
@Override
public int get_ey(final String worldname, final int sx, final int ex, final int sz, final int ez, final int sy) {
final World world = SpongeUtil.getWorld(worldname);
public int get_ey(String worldName, int sx, int ex, int sz, int ez, int sy) {
World world = SpongeUtil.getWorld(worldName);
int ey = sy;
for (int x = sx; x <= ex; x++) {
for (int z = sz; z <= ez; z++) {
for (int y = sy; y < 256; y++) {
if (y > ey) {
final BlockState state = world.getBlock(x, y, z);
if ((state != null) && (state.getType() != BlockTypes.AIR)) {
BlockState state = world.getBlock(x, y, z);
if (state.getType() != BlockTypes.AIR) {
ey = y;
}
}

View File

@ -1,18 +1,5 @@
package com.plotsquared.sponge.util;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.item.inventory.Carrier;
import org.spongepowered.api.item.inventory.type.CarriedInventory;
import org.spongepowered.api.world.World;
import com.intellectualcrafters.jnbt.ByteArrayTag;
import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.jnbt.IntTag;
@ -28,25 +15,37 @@ import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.TaskManager;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.item.inventory.Carrier;
import org.spongepowered.api.item.inventory.type.CarriedInventory;
import org.spongepowered.api.world.World;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
public class SpongeSchematicHandler extends SchematicHandler {
@Override
public void getCompoundTag(final String world, final Set<RegionWrapper> regions, final RunnableVal<CompoundTag> whenDone) {
public void getCompoundTag(String world, Set<RegionWrapper> regions, RunnableVal<CompoundTag> whenDone) {
// async
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
// Main positions
Location[] corners = MainUtil.getCorners(world, regions);
final Location bot = corners[0];
final Location top = corners[1];
final int width = (top.getX() - bot.getX()) + 1;
final int height = (top.getY() - bot.getY()) + 1;
final int length = (top.getZ() - bot.getZ()) + 1;
Location bot = corners[0];
Location top = corners[1];
int width = (top.getX() - bot.getX()) + 1;
int height = (top.getY() - bot.getY()) + 1;
int length = (top.getZ() - bot.getZ()) + 1;
// Main Schematic tag
final HashMap<String, Tag> schematic = new HashMap<>();
HashMap<String, Tag> schematic = new HashMap<>();
schematic.put("Width", new ShortTag("Width", (short) width));
schematic.put("Length", new ShortTag("Length", (short) length));
schematic.put("Height", new ShortTag("Height", (short) height));
@ -58,11 +57,11 @@ public class SpongeSchematicHandler extends SchematicHandler {
schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0));
schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0));
// Arrays of data types
final List<Tag> tileEntities = new ArrayList<Tag>();
final byte[] blocks = new byte[width * height * length];
final byte[] blockData = new byte[width * height * length];
List<Tag> tileEntities = new ArrayList<Tag>();
byte[] blocks = new byte[width * height * length];
byte[] blockData = new byte[width * height * length];
// Queue
final ArrayDeque<RegionWrapper> queue = new ArrayDeque<>(regions);
ArrayDeque<RegionWrapper> queue = new ArrayDeque<>(regions);
TaskManager.runTask(new Runnable() {
@Override
public void run() {
@ -82,40 +81,40 @@ public class SpongeSchematicHandler extends SchematicHandler {
});
return;
}
final Runnable regionTask = this;
Runnable regionTask = this;
RegionWrapper region = queue.poll();
Location pos1 = new Location(world, region.minX, region.minY, region.minZ);
Location pos2 = new Location(world, region.maxX, region.maxY, region.maxZ);
final int bx = bot.getX();
final int bz = bot.getZ();
final int p1x = pos1.getX();
final int p1z = pos1.getZ();
final int p2x = pos2.getX();
final int p2z = pos2.getZ();
final int bcx = p1x >> 4;
final int bcz = p1z >> 4;
final int tcx = p2x >> 4;
final int tcz = p2z >> 4;
final int sy = pos1.getY();
final int ey = pos2.getY();
int bx = bot.getX();
int bz = bot.getZ();
int p1x = pos1.getX();
int p1z = pos1.getZ();
int p2x = pos2.getX();
int p2z = pos2.getZ();
int bcx = p1x >> 4;
int bcz = p1z >> 4;
int tcx = p2x >> 4;
int tcz = p2z >> 4;
int sy = pos1.getY();
int ey = pos2.getY();
// Generate list of chunks
final ArrayList<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
ArrayList<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
for (int x = bcx; x <= tcx; x++) {
for (int z = bcz; z <= tcz; z++) {
chunks.add(new ChunkLoc(x, z));
}
}
final World worldObj = SpongeUtil.getWorld(world);
World worldObj = SpongeUtil.getWorld(world);
// Main thread
TaskManager.runTask(new Runnable() {
@Override
public void run() {
final long start = System.currentTimeMillis();
while ((!chunks.isEmpty()) && ((System.currentTimeMillis() - start) < 20)) {
long start = System.currentTimeMillis();
while (!chunks.isEmpty() && ((System.currentTimeMillis() - start) < 20)) {
// save schematics
final ChunkLoc chunk = chunks.remove(0);
final int X = chunk.x;
final int Z = chunk.z;
ChunkLoc chunk = chunks.remove(0);
int X = chunk.x;
int Z = chunk.z;
int xxb = X << 4;
int zzb = Z << 4;
if (!worldObj.getChunk(xxb, 1, zzb).isPresent() && !worldObj.loadChunk(xxb, 1, zzb, false).isPresent()) {
@ -137,18 +136,18 @@ public class SpongeSchematicHandler extends SchematicHandler {
zzt = p2z;
}
for (int y = sy; y <= Math.min(255, ey); y++) {
final int ry = y - sy;
final int i1 = (ry * width * length);
int ry = y - sy;
int i1 = ry * width * length;
for (int z = zzb; z <= zzt; z++) {
final int rz = z - p1z;
final int i2 = i1 + (rz * width);
int rz = z - p1z;
int i2 = i1 + (rz * width);
for (int x = xxb; x <= xxt; x++) {
final int rx = x - p1x;
final int index = i2 + rx;
final BlockState state = worldObj.getBlock(x, y, z);
int rx = x - p1x;
int index = i2 + rx;
BlockState state = worldObj.getBlock(x, y, z);
PlotBlock block = SpongeUtil.getPlotBlock(state);
final int id = block.id;
int id = block.id;
switch (id) {
case 0:
case 2:
@ -265,15 +264,15 @@ public class SpongeSchematicHandler extends SchematicHandler {
rawTag = null;
}
if (rawTag != null) {
final Map<String, Tag> values = new HashMap<String, Tag>();
for (final Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
Map<String, Tag> values = new HashMap<String, Tag>();
for (Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
values.put(entry.getKey(), entry.getValue());
}
values.put("id", new StringTag("id", "Chest"));
values.put("x", new IntTag("x", x));
values.put("y", new IntTag("y", y));
values.put("z", new IntTag("z", z));
final CompoundTag tileEntityTag = new CompoundTag(values);
CompoundTag tileEntityTag = new CompoundTag(values);
tileEntities.add(tileEntityTag);
}
}
@ -300,7 +299,7 @@ public class SpongeSchematicHandler extends SchematicHandler {
}
@Override
public void restoreTag(CompoundTag ct, short x, short y, short z, Schematic schem) {
public void restoreTag(CompoundTag ct, short x, short y, short z, Schematic schematic) {
// TODO Auto-generated method stub
// This method should place the compound tag at a location e.g. chest contents
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");

View File

@ -50,23 +50,23 @@ public class SpongeSetupUtils extends SetupUtils {
}
@Override
public String getGenerator(final PlotArea plotworld) {
public String getGenerator(PlotArea plotworld) {
if (SetupUtils.generators.isEmpty()) {
updateGenerators();
}
final World world = SpongeUtil.getWorld(plotworld.worldname);
World world = SpongeUtil.getWorld(plotworld.worldname);
if (world == null) {
return null;
}
final WorldGenerator generator = world.getWorldGenerator();
WorldGenerator generator = world.getWorldGenerator();
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
}
@Override
public String setupWorld(final SetupObject object) {
public String setupWorld(SetupObject object) {
SetupUtils.manager.updateGenerators();
ConfigurationNode[] steps = object.step == null ? new ConfigurationNode[0] : object.step;
final String world = object.world;
String world = object.world;
int type = object.type;
String worldPath = "worlds." + object.world;
if (!PS.get().config.contains(worldPath)) {
@ -76,14 +76,14 @@ public class SpongeSetupUtils extends SetupUtils {
switch (type) {
case 2: {
if (object.id != null) {
String areaname = object.id + "-" + object.min + "-" + object.max;
String areaPath = "areas." + areaname;
String areaName = object.id + "-" + object.min + "-" + object.max;
String areaPath = "areas." + areaName;
if (!worldSection.contains(areaPath)) {
worldSection.createSection(areaPath);
}
ConfigurationSection areaSection = worldSection.getConfigurationSection(areaPath);
HashMap<String, Object> options = new HashMap<>();
for (final ConfigurationNode step : steps) {
for (ConfigurationNode step : steps) {
options.put(step.getConstant(), step.getValue());
}
options.put("generator.type", object.type);
@ -112,7 +112,7 @@ public class SpongeSetupUtils extends SetupUtils {
break;
}
case 1: {
for (final ConfigurationNode step : steps) {
for (ConfigurationNode step : steps) {
worldSection.set(step.getConstant(), step.getValue());
}
PS.get().config.set("worlds." + world + "." + "generator.type", object.type);
@ -128,7 +128,7 @@ public class SpongeSetupUtils extends SetupUtils {
break;
}
case 0: {
for (final ConfigurationNode step : steps) {
for (ConfigurationNode step : steps) {
worldSection.set(step.getConstant(), step.getValue());
}
break;
@ -136,7 +136,7 @@ public class SpongeSetupUtils extends SetupUtils {
}
try {
PS.get().config.save(PS.get().configFile);
} catch (final IOException e) {
} catch (IOException e) {
e.printStackTrace();
}
if (object.setupGenerator != null) {

View File

@ -362,7 +362,7 @@ public class SpongeUtil extends WorldUtil {
}
@Override
public void saveWorld(String worldname) {
public void saveWorld(String worldName) {
throw new NotImplementedException("TODO WIP"); // TODO FIXME
}
@ -391,8 +391,8 @@ public class SpongeUtil extends WorldUtil {
}
@Override
public boolean isWorld(String world) {
return SpongeUtil.getWorld(world) != null;
public boolean isWorld(String worldName) {
return SpongeUtil.getWorld(worldName) != null;
}
@Override
@ -401,8 +401,8 @@ public class SpongeUtil extends WorldUtil {
}
@Override
public int getHighestBlock(String worldname, int x, int z) {
World world = SpongeUtil.getWorld(worldname);
public int getHighestBlock(String worldName, int x, int z) {
World world = SpongeUtil.getWorld(worldName);
if (world == null) {
return 64;
}
@ -416,8 +416,8 @@ public class SpongeUtil extends WorldUtil {
}
@Override
public void setSign(String worldname, int x, int y, int z, String[] lines) {
World world = SpongeUtil.getWorld(worldname);
public void setSign(String worldName, int x, int y, int z, String[] lines) {
World world = SpongeUtil.getWorld(worldName);
world.setBlock(x, y, z, BlockTypes.WALL_SIGN.getDefaultState());
Optional<TileEntity> block = world.getTileEntity(x, y, z);
if (!block.isPresent()) {
@ -436,8 +436,8 @@ public class SpongeUtil extends WorldUtil {
}
@Override
public void setBiomes(String worldname, RegionWrapper region, String biomename) {
World world = SpongeUtil.getWorld(worldname);
public void setBiomes(String worldName, RegionWrapper region, String biomename) {
World world = SpongeUtil.getWorld(worldName);
BiomeType biome = SpongeUtil.getBiome(biomename);
for (int x = region.minX; x <= region.maxX; x++) {
for (int z = region.minZ; z <= region.maxZ; z++) {

View File

@ -97,9 +97,9 @@ public class FastQueue extends SlowQueue {
ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
// Trim tiles
Set<Entry<BlockPos, TileEntity>> entryset = tiles.entrySet();
Iterator<Entry<BlockPos, TileEntity>> iter = entryset.iterator();
while (iter.hasNext()) {
Entry<BlockPos,TileEntity> tile = iter.next();
Iterator<Entry<BlockPos, TileEntity>> iterator = entryset.iterator();
while (iterator.hasNext()) {
Entry<BlockPos, TileEntity> tile = iterator.next();
BlockPos pos = tile.getKey();
int lx = pos.getX() & 15;
int ly = pos.getY();
@ -111,7 +111,7 @@ public class FastQueue extends SlowQueue {
continue;
}
if (array[k] != 0) {
iter.remove();
iterator.remove();
}
}
// Trim entities
@ -206,7 +206,7 @@ public class FastQueue extends SlowQueue {
spongeChunk.unloadChunk();
spongeChunk.loadChunk(false);
}
// TODO load adjaced chunks
// TODO load adjacent chunks
nmsChunk.generateSkylightMap();
if (bc.getTotalRelight() == 0 && !fixAll) {
return true;

View File

@ -6,7 +6,6 @@ import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.sponge.object.SpongePlayer;
@ -19,7 +18,11 @@ import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.world.Chunk;
import org.spongepowered.api.world.World;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
/**
@ -29,11 +32,11 @@ import java.util.Map.Entry;
*/
public class SendChunk {
public void sendChunk(final Collection<Chunk> input) {
final HashSet<Chunk> chunks = new HashSet<Chunk>(input);
final HashMap<String, ArrayList<Chunk>> map = new HashMap<>();
for (final Chunk chunk : chunks) {
final String world = chunk.getWorld().getName();
public void sendChunk(Collection<Chunk> input) {
HashSet<Chunk> chunks = new HashSet<Chunk>(input);
HashMap<String, ArrayList<Chunk>> map = new HashMap<>();
for (Chunk chunk : chunks) {
String world = chunk.getWorld().getName();
ArrayList<Chunk> list = map.get(world);
if (list == null) {
list = new ArrayList<>();
@ -44,7 +47,7 @@ public class SendChunk {
}
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
PlotPlayer pp = entry.getValue();
final Plot plot = pp.getCurrentPlot();
Plot plot = pp.getCurrentPlot();
Location loc = null;
String world;
if (plot != null) {
@ -53,16 +56,16 @@ public class SendChunk {
loc = pp.getLocation();
world = loc.getWorld();
}
final ArrayList<Chunk> list = map.get(world);
ArrayList<Chunk> list = map.get(world);
if (list == null) {
continue;
}
if (loc == null) {
loc = pp.getLocation();
}
final int cx = loc.getX() >> 4;
final int cz = loc.getZ() >> 4;
final Player player = ((SpongePlayer) pp).player;
int cx = loc.getX() >> 4;
int cz = loc.getZ() >> 4;
Player player = ((SpongePlayer) pp).player;
int view = player.getViewDistance();
EntityPlayer nmsPlayer = (EntityPlayer) player;
if (!(nmsPlayer instanceof EntityPlayerMP)) {
@ -70,10 +73,10 @@ public class SendChunk {
return;
}
EntityPlayerMP nmsPlayerMP = (EntityPlayerMP) nmsPlayer;
for (final Chunk chunk : list) {
for (Chunk chunk : list) {
Vector3i min = chunk.getBlockMin();
final int dx = Math.abs(cx - (min.getX() >> 4));
final int dz = Math.abs(cz - (min.getZ() >> 4));
int dx = Math.abs(cx - (min.getX() >> 4));
int dz = Math.abs(cz - (min.getZ() >> 4));
if ((dx > view) || (dz > view)) {
continue;
}
@ -84,7 +87,7 @@ public class SendChunk {
con.sendPacket(packet);
}
}
for (final Chunk chunk : chunks) {
for (Chunk chunk : chunks) {
TaskManager.runTask(new Runnable() {
@Override
public void run() {
@ -94,10 +97,10 @@ public class SendChunk {
}
}
public void sendChunk(final String worldname, final List<ChunkLoc> locs) {
World spongeWorld = SpongeUtil.getWorld(worldname);
final ArrayList<Chunk> chunks = new ArrayList<>();
for (final ChunkLoc loc : locs) {
public void sendChunk(String worldName, List<ChunkLoc> chunkLocations) {
World spongeWorld = SpongeUtil.getWorld(worldName);
ArrayList<Chunk> chunks = new ArrayList<>();
for (ChunkLoc loc : chunkLocations) {
chunks.add(spongeWorld.getChunk(loc.x, 0, loc.z).get());
}
sendChunk(chunks);