Documentation and formatting changes

This commit is contained in:
MattBDev 2019-04-29 15:19:49 -04:00
parent 9e324762b6
commit db6115eae5
6 changed files with 88 additions and 86 deletions

View File

@ -45,16 +45,12 @@ public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
@Override public PlotBlock getBlock(int x, int y, int z) { @Override public PlotBlock getBlock(int x, int y, int z) {
World worldObj = Bukkit.getWorld(getWorld()); World worldObj = Bukkit.getWorld(getWorld());
if (worldObj != null) {
Block block = worldObj.getBlockAt(x, y, z); Block block = worldObj.getBlockAt(x, y, z);
if (block == null) { return PlotBlock.get(block.getType().toString());
} else {
return PlotBlock.get(0, 0); return PlotBlock.get(0, 0);
} }
// int id = block.getTypeId();
// if (id == 0) {
// return PlotBlock.get(0, 0);
// }
// return PlotBlock.get(id, block.getData());
return PlotBlock.get(block.getType().toString());
} }
@Override public void refreshChunk(int x, int z) { @Override public void refreshChunk(int x, int z) {
@ -194,9 +190,7 @@ public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
if (biomes2 != null) { if (biomes2 != null) {
for (String biomeStr : biomes2) { for (String biomeStr : biomes2) {
if (biomeStr != null) { if (biomeStr != null) {
if (last == null || !StringMan.isEqual(last, biomeStr)) {
biome = Biome.valueOf(biomeStr.toUpperCase()); biome = Biome.valueOf(biomeStr.toUpperCase());
}
worldObj.setBiome(bx, bz, biome); worldObj.setBiome(bx, bz, biome);
} }
} }

View File

@ -105,10 +105,10 @@ public class Config {
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
file.createNewFile(); file.createNewFile();
} }
PrintWriter writer = new PrintWriter(file); try (PrintWriter writer = new PrintWriter(file)) {
Object instance = root.newInstance(); Object instance = root.newInstance();
save(writer, root, instance, 0); save(writer, root, instance, 0);
writer.close(); }
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -183,7 +183,6 @@ public class Config {
} }
} }
} }
continue;
} else { } else {
writer.write(spacing + toNodeName(field.getName() + ": ") + toYamlString( writer.write(spacing + toNodeName(field.getName() + ": ") + toYamlString(
field.get(instance), spacing) + lineSeparator); field.get(instance), spacing) + lineSeparator);
@ -281,10 +280,9 @@ public class Config {
Class<?> clazz = root == null ? MethodHandles.lookup().lookupClass() : root; Class<?> clazz = root == null ? MethodHandles.lookup().lookupClass() : root;
Object instance = clazz.newInstance(); Object instance = clazz.newInstance();
while (split.length > 0) { while (split.length > 0) {
switch (split.length) { if (split.length == 1) {
case 1:
return instance; return instance;
default: }
Class found = null; Class found = null;
Class<?>[] classes = clazz.getDeclaredClasses(); Class<?>[] classes = clazz.getDeclaredClasses();
for (Class current : classes) { for (Class current : classes) {
@ -330,7 +328,6 @@ public class Config {
} }
return null; return null;
} }
}
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -3,7 +3,14 @@ package com.github.intellectualsites.plotsquared.plot.generator;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.commands.Template; import com.github.intellectualsites.plotsquared.plot.commands.Template;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
import com.github.intellectualsites.plotsquared.plot.object.FileBytes;
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.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
@ -11,7 +18,6 @@ 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.LocalBlockQueue;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
@ -144,10 +150,11 @@ public class HybridPlotManager extends ClassicPlotManager {
} }
/** /**
* <p>Clearing the plot needs to only consider removing the blocks - This implementation has used the setCuboidAsync * <p>Clearing the plot needs to only consider removing the blocks - This implementation has
* function, as it is fast, and uses NMS code - It also makes use of the fact that deleting chunks is a lot faster * used the setCuboidAsync function, as it is fast, and uses NMS code - It also makes use of the
* than block updates This code is very messy, but you don't need to do something quite as complex unless you happen * fact that deleting chunks is a lot faster than block updates This code is very messy, but you
* to have 512x512 sized plots. </p> * don't need to do something quite as complex unless you happen to have 512x512 sized plots.
* </p>
*/ */
@Override public boolean clearPlot(final PlotArea plotArea, Plot plot, @Override public boolean clearPlot(final PlotArea plotArea, Plot plot,
final Runnable whenDone) { final Runnable whenDone) {
@ -177,9 +184,7 @@ public class HybridPlotManager extends ClassicPlotManager {
queue.regenChunk(value[0], value[1]); queue.regenChunk(value[0], value[1]);
return; return;
} }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* Otherwise we need to set each component, as we don't want to regenerate the road or other plots that share the same chunk.*/
// Otherwise we need to set each component, as we don't want to regenerate the road or other plots that share the same chunk //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Set the biome // Set the biome
MainUtil.setBiome(world, value[2], value[3], value[4], value[5], biome); MainUtil.setBiome(world, value[2], value[3], value[4], value[5], biome);
// These two locations are for each component (e.g. bedrock, main block, floor, air) // These two locations are for each component (e.g. bedrock, main block, floor, air)
@ -199,12 +204,10 @@ public class HybridPlotManager extends ClassicPlotManager {
// And finally set the schematic, the y value is unimportant for this function // And finally set the schematic, the y value is unimportant for this function
pastePlotSchematic(dpw, queue, bot, top); pastePlotSchematic(dpw, queue, bot, top);
} }
}, new Runnable() { }, () -> {
@Override public void run() {
queue.enqueue(); queue.enqueue();
// And notify whatever called this when plot clearing is done // And notify whatever called this when plot clearing is done
GlobalBlockQueue.IMP.addTask(whenDone); GlobalBlockQueue.IMP.addTask(whenDone);
}
}, 10); }, 10);
return true; return true;
} }

View File

@ -30,13 +30,11 @@ public class SinglePlotManager extends PlotManager {
SetupUtils.manager.unload(plot.getWorldName(), false); SetupUtils.manager.unload(plot.getWorldName(), false);
final File worldFolder = final File worldFolder =
new File(PlotSquared.get().IMP.getWorldContainer(), plot.getWorldName()); new File(PlotSquared.get().IMP.getWorldContainer(), plot.getWorldName());
TaskManager.IMP.taskAsync(new Runnable() { TaskManager.IMP.taskAsync(() -> {
@Override public void run() {
MainUtil.deleteDirectory(worldFolder); MainUtil.deleteDirectory(worldFolder);
if (whenDone != null) { if (whenDone != null) {
whenDone.run(); whenDone.run();
} }
}
}); });
return true; return true;
} }

View File

@ -116,7 +116,9 @@ public abstract class BasicLocalBlockQueue<T> extends LocalBlockQueue {
} }
@Override public boolean setBlock(int x, int y, int z, PlotBlock id) { @Override public boolean setBlock(int x, int y, int z, PlotBlock id) {
if ((y > 255) || (y < 0)) { if (y > 255) {
return false;
} else if (y < 0) {
return false; return false;
} }
int cx = x >> 4; int cx = x >> 4;

View File

@ -37,6 +37,14 @@ public abstract class LocalBlockQueue {
public abstract void setModified(long modified); public abstract void setModified(long modified);
/**
* Sets the block at the coordinates provided to the given id.
*
* @param x the x coordinate from from 0 to 15 inclusive
* @param y the y coordinate from from 0 (inclusive) - maxHeight(exclusive)
* @param z the z coordinate from 0 to 15 inclusive
* @param id the id to set the block to
*/
public abstract boolean setBlock(final int x, final int y, final int z, final PlotBlock id); public abstract boolean setBlock(final int x, final int y, final int z, final PlotBlock id);
public abstract boolean setBlock(final int x, final int y, final int z, final BaseBlock id); public abstract boolean setBlock(final int x, final int y, final int z, final BaseBlock id);