mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Relight command
This commit is contained in:
parent
df630f9be1
commit
560ebf412b
@ -129,13 +129,13 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
if (!name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
owner = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
|
|
||||||
}
|
|
||||||
PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + "'");
|
PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + "'");
|
||||||
missing++;
|
missing++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
owner = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
UUIDHandler.add(new StringWrapper(name), owner);
|
UUIDHandler.add(new StringWrapper(name), owner);
|
||||||
|
@ -70,6 +70,7 @@ public class MainCommand extends Command {
|
|||||||
new PluginCmd();
|
new PluginCmd();
|
||||||
new Purge();
|
new Purge();
|
||||||
new Reload();
|
new Reload();
|
||||||
|
new Relight();
|
||||||
new Merge();
|
new Merge();
|
||||||
new DebugPaste();
|
new DebugPaste();
|
||||||
new Unlink();
|
new Unlink();
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,9 @@
|
|||||||
package com.intellectualcrafters.plot.flag;
|
package com.intellectualcrafters.plot.flag;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.util.StringComparison;
|
import com.intellectualcrafters.plot.util.StringComparison;
|
||||||
import com.intellectualcrafters.plot.util.StringMan;
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -443,7 +441,6 @@ public abstract class FlagValue<T> {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> parse(final String t) {
|
public List<String> parse(final String t) {
|
||||||
System.out.println("PARSE: " + t);
|
System.out.println("PARSE: " + t);
|
||||||
PS.stacktrace();
|
|
||||||
return new ArrayList<>(Arrays.asList(t.split(",")));
|
return new ArrayList<>(Arrays.asList(t.split(",")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
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
|
* 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
|
* @param pos1
|
||||||
@ -123,7 +140,7 @@ public abstract class ChunkManager {
|
|||||||
final int bcz = p1z >> 4;
|
final int bcz = p1z >> 4;
|
||||||
final int tcx = p2x >> 4;
|
final int tcx = p2x >> 4;
|
||||||
final int tcz = p2z >> 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 x = bcx; x <= tcx; x++) {
|
||||||
for (int z = bcz; z <= tcz; z++) {
|
for (int z = bcz; z <= tcz; z++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user