Relight command

This commit is contained in:
Jesse Boyd 2016-03-30 04:34:48 +11:00
parent df630f9be1
commit 560ebf412b
5 changed files with 70 additions and 10 deletions

View File

@ -129,12 +129,12 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
}
}
if (owner == null) {
if (!name.isEmpty()) {
owner = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
if (name.isEmpty()) {
PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + "'");
missing++;
continue;
}
PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + "'");
missing++;
continue;
owner = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
}
}
} else {

View File

@ -70,6 +70,7 @@ public class MainCommand extends Command {
new PluginCmd();
new Purge();
new Reload();
new Relight();
new Merge();
new DebugPaste();
new Unlink();

View File

@ -0,0 +1,45 @@
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.RunnableVal2;
import com.intellectualcrafters.plot.object.RunnableVal3;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.PlotChunk;
import com.intellectualcrafters.plot.util.SetQueue;
import com.plotsquared.general.commands.Command;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.HashSet;
@CommandDeclaration(command = "relight", description = "Relight your plot", category = CommandCategory.DEBUG)
public class Relight extends Command {
public Relight() {
super(MainCommand.getInstance(), true);
}
@Override
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
final Plot plot = player.getCurrentPlot();
if (plot == null) {
C.NOT_IN_PLOT.send(player);
return;
}
HashSet<RegionWrapper> regions = plot.getRegions();
ChunkManager.chunkTask(plot, new RunnableVal<int[]>() {
@Override
public void run(int[] value) {
SetQueue.ChunkWrapper cw = SetQueue.IMP.new ChunkWrapper(plot.getArea().worldname, value[0], value[1]);
PlotChunk<?> pc = SetQueue.IMP.queue.getChunk(cw);
pc.fixLighting();
}
}, new Runnable() {
@Override
public void run() {
C.SET_BLOCK_ACTION_FINISHED.send(player);
}
}, 5);
}
}

View File

@ -1,11 +1,9 @@
package com.intellectualcrafters.plot.flag;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.util.StringComparison;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.WorldUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
@ -443,7 +441,6 @@ public abstract class FlagValue<T> {
@Override
public List<String> parse(final String t) {
System.out.println("PARSE: " + t);
PS.stacktrace();
return new ArrayList<>(Arrays.asList(t.split(",")));
}

View File

@ -8,7 +8,6 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
@ -107,6 +106,24 @@ public abstract class ChunkManager {
});
}
public static void chunkTask(final Plot plot, final RunnableVal<int[]> task, final Runnable whenDone, final int allocate) {
final ArrayList<RegionWrapper> regions = new ArrayList<>(plot.getRegions());
Runnable smallTask = new Runnable() {
@Override
public void run() {
if (regions.size() == 0) {
TaskManager.runTask(whenDone);
return;
}
RegionWrapper value = regions.remove(0);
Location pos1 = new Location(plot.getArea().worldname, value.minX, 0, value.minZ);
Location pos2 = new Location(plot.getArea().worldname, value.maxX, 0, value.maxZ);
chunkTask(pos1, pos2, task, this, allocate);
}
};
smallTask.run();
}
/**
* The int[] will be in the form: [chunkx, chunkz, pos1x, pos1z, pos2x, pos2z, isedge] and will represent the bottom and top parts of the chunk
* @param pos1
@ -123,7 +140,7 @@ public abstract class ChunkManager {
final int bcz = p1z >> 4;
final int tcx = p2x >> 4;
final int tcz = p2z >> 4;
final ArrayList<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
final ArrayList<ChunkLoc> chunks = new ArrayList<>();
for (int x = bcx; x <= tcx; x++) {
for (int z = bcz; z <= tcz; z++) {