mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Documentation and formatting changes
This commit is contained in:
parent
9e324762b6
commit
db6115eae5
6 changed files with 88 additions and 86 deletions
|
@ -45,16 +45,12 @@ public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
|
|||
|
||||
@Override public PlotBlock getBlock(int x, int y, int z) {
|
||||
World worldObj = Bukkit.getWorld(getWorld());
|
||||
Block block = worldObj.getBlockAt(x, y, z);
|
||||
if (block == null) {
|
||||
if (worldObj != null) {
|
||||
Block block = worldObj.getBlockAt(x, y, z);
|
||||
return PlotBlock.get(block.getType().toString());
|
||||
} else {
|
||||
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) {
|
||||
|
@ -194,9 +190,7 @@ public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
|
|||
if (biomes2 != null) {
|
||||
for (String biomeStr : biomes2) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,10 +105,10 @@ public class Config {
|
|||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
}
|
||||
PrintWriter writer = new PrintWriter(file);
|
||||
Object instance = root.newInstance();
|
||||
save(writer, root, instance, 0);
|
||||
writer.close();
|
||||
try (PrintWriter writer = new PrintWriter(file)) {
|
||||
Object instance = root.newInstance();
|
||||
save(writer, root, instance, 0);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -183,7 +183,6 @@ public class Config {
|
|||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
writer.write(spacing + toNodeName(field.getName() + ": ") + toYamlString(
|
||||
field.get(instance), spacing) + lineSeparator);
|
||||
|
@ -281,55 +280,53 @@ public class Config {
|
|||
Class<?> clazz = root == null ? MethodHandles.lookup().lookupClass() : root;
|
||||
Object instance = clazz.newInstance();
|
||||
while (split.length > 0) {
|
||||
switch (split.length) {
|
||||
case 1:
|
||||
return instance;
|
||||
default:
|
||||
Class found = null;
|
||||
Class<?>[] classes = clazz.getDeclaredClasses();
|
||||
for (Class current : classes) {
|
||||
if (current.getSimpleName().equalsIgnoreCase(toFieldName(split[0]))) {
|
||||
found = current;
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Field instanceField = clazz.getDeclaredField(toFieldName(split[0]));
|
||||
setAccessible(instanceField);
|
||||
if (instanceField.getType() != ConfigBlock.class) {
|
||||
Object value = instanceField.get(instance);
|
||||
if (value == null) {
|
||||
value = found.newInstance();
|
||||
instanceField.set(instance, value);
|
||||
}
|
||||
clazz = found;
|
||||
instance = value;
|
||||
split = Arrays.copyOfRange(split, 1, split.length);
|
||||
continue;
|
||||
}
|
||||
ConfigBlock value = (ConfigBlock) instanceField.get(instance);
|
||||
if (value == null) {
|
||||
value = new ConfigBlock();
|
||||
instanceField.set(instance, value);
|
||||
}
|
||||
instance = value.get(split[1]);
|
||||
if (instance == null) {
|
||||
instance = found.newInstance();
|
||||
value.put(split[1], instance);
|
||||
}
|
||||
clazz = found;
|
||||
split = Arrays.copyOfRange(split, 2, split.length);
|
||||
continue;
|
||||
} catch (NoSuchFieldException ignore) {
|
||||
}
|
||||
if (found != null) {
|
||||
split = Arrays.copyOfRange(split, 1, split.length);
|
||||
clazz = found;
|
||||
instance = clazz.newInstance();
|
||||
continue;
|
||||
}
|
||||
return null;
|
||||
if (split.length == 1) {
|
||||
return instance;
|
||||
}
|
||||
Class found = null;
|
||||
Class<?>[] classes = clazz.getDeclaredClasses();
|
||||
for (Class current : classes) {
|
||||
if (current.getSimpleName().equalsIgnoreCase(toFieldName(split[0]))) {
|
||||
found = current;
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Field instanceField = clazz.getDeclaredField(toFieldName(split[0]));
|
||||
setAccessible(instanceField);
|
||||
if (instanceField.getType() != ConfigBlock.class) {
|
||||
Object value = instanceField.get(instance);
|
||||
if (value == null) {
|
||||
value = found.newInstance();
|
||||
instanceField.set(instance, value);
|
||||
}
|
||||
clazz = found;
|
||||
instance = value;
|
||||
split = Arrays.copyOfRange(split, 1, split.length);
|
||||
continue;
|
||||
}
|
||||
ConfigBlock value = (ConfigBlock) instanceField.get(instance);
|
||||
if (value == null) {
|
||||
value = new ConfigBlock();
|
||||
instanceField.set(instance, value);
|
||||
}
|
||||
instance = value.get(split[1]);
|
||||
if (instance == null) {
|
||||
instance = found.newInstance();
|
||||
value.put(split[1], instance);
|
||||
}
|
||||
clazz = found;
|
||||
split = Arrays.copyOfRange(split, 2, split.length);
|
||||
continue;
|
||||
} catch (NoSuchFieldException ignore) {
|
||||
}
|
||||
if (found != null) {
|
||||
split = Arrays.copyOfRange(split, 1, split.length);
|
||||
clazz = found;
|
||||
instance = clazz.newInstance();
|
||||
continue;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -3,7 +3,14 @@ package com.github.intellectualsites.plotsquared.plot.generator;
|
|||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.Template;
|
||||
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.MainUtil;
|
||||
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.google.common.collect.Sets;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
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
|
||||
* function, as it is fast, and uses NMS code - It also makes use of the fact that deleting chunks is a lot faster
|
||||
* than block updates This code is very messy, but you don't need to do something quite as complex unless you happen
|
||||
* to have 512x512 sized plots. </p>
|
||||
* <p>Clearing the plot needs to only consider removing the blocks - This implementation has
|
||||
* used the setCuboidAsync function, as it is fast, and uses NMS code - It also makes use of the
|
||||
* fact that deleting chunks is a lot faster than block updates This code is very messy, but you
|
||||
* 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,
|
||||
final Runnable whenDone) {
|
||||
|
@ -177,9 +184,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||
queue.regenChunk(value[0], value[1]);
|
||||
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
|
||||
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)
|
||||
|
@ -199,12 +204,10 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||
// And finally set the schematic, the y value is unimportant for this function
|
||||
pastePlotSchematic(dpw, queue, bot, top);
|
||||
}
|
||||
}, new Runnable() {
|
||||
@Override public void run() {
|
||||
queue.enqueue();
|
||||
// And notify whatever called this when plot clearing is done
|
||||
GlobalBlockQueue.IMP.addTask(whenDone);
|
||||
}
|
||||
}, () -> {
|
||||
queue.enqueue();
|
||||
// And notify whatever called this when plot clearing is done
|
||||
GlobalBlockQueue.IMP.addTask(whenDone);
|
||||
}, 10);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -30,12 +30,10 @@ public class SinglePlotManager extends PlotManager {
|
|||
SetupUtils.manager.unload(plot.getWorldName(), false);
|
||||
final File worldFolder =
|
||||
new File(PlotSquared.get().IMP.getWorldContainer(), plot.getWorldName());
|
||||
TaskManager.IMP.taskAsync(new Runnable() {
|
||||
@Override public void run() {
|
||||
MainUtil.deleteDirectory(worldFolder);
|
||||
if (whenDone != null) {
|
||||
whenDone.run();
|
||||
}
|
||||
TaskManager.IMP.taskAsync(() -> {
|
||||
MainUtil.deleteDirectory(worldFolder);
|
||||
if (whenDone != null) {
|
||||
whenDone.run();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
|
|
@ -116,7 +116,9 @@ public abstract class BasicLocalBlockQueue<T> extends LocalBlockQueue {
|
|||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
int cx = x >> 4;
|
||||
|
|
|
@ -37,6 +37,14 @@ public abstract class LocalBlockQueue {
|
|||
|
||||
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 BaseBlock id);
|
||||
|
|
Loading…
Reference in a new issue