mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Feature / Fix
Add trim regen argument @manuelgu /plot trim <world> true Add grant check other + console usage Finish abstracting world generation to prepare for sponge port Fix economy hook Add ban as alias for deny Remove some redundant code
This commit is contained in:
parent
411a74eefa
commit
60629db042
@ -213,7 +213,7 @@ public interface IPlotMain {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
GeneratorWrapper<?> wrapPlotGenerator(String world, IndependentPlotGenerator generator);
|
||||
GeneratorWrapper<?> wrapPlotGenerator(IndependentPlotGenerator generator);
|
||||
|
||||
/**
|
||||
* Register the chunk processor which will clean out chunks that have too many blockstates or entities
|
||||
|
@ -1294,7 +1294,6 @@ public class PS {
|
||||
|
||||
public Collection<Plot> getPlots(final String world) {
|
||||
final HashSet<Plot> set = new HashSet<>();
|
||||
foreachPlotArea(null);
|
||||
foreachPlotArea(world, new RunnableVal<PlotArea>() {
|
||||
@Override
|
||||
public void run(PlotArea value) {
|
||||
@ -2436,6 +2435,21 @@ public class PS {
|
||||
}
|
||||
}
|
||||
|
||||
public void foreachPlotRaw(final RunnableVal<Plot> runnable) {
|
||||
for (PlotArea area : plotareas) {
|
||||
for (Plot plot : area.getPlots()) {
|
||||
runnable.run(plot);
|
||||
}
|
||||
}
|
||||
if (plots_tmp != null) {
|
||||
for (Entry<String, HashMap<PlotId, Plot>> entry : plots_tmp.entrySet()) {
|
||||
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||
runnable.run(entry2.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void foreachBasePlot(RunnableVal<Plot> run) {
|
||||
for (PlotArea area : plotareas) {
|
||||
area.foreachBasePlot(run);
|
||||
|
@ -131,8 +131,8 @@ public class Area extends SubCommand {
|
||||
if (area.TERRAIN != 3) {
|
||||
ChunkManager.largeRegionTask(world, region, new RunnableVal<ChunkLoc>() {
|
||||
@Override
|
||||
public void run(ChunkLoc value) {
|
||||
AugmentedUtils.generate(world, value.x, value.z);
|
||||
public void run(final ChunkLoc value) {
|
||||
AugmentedUtils.generate(world, value.x, value.z, null);
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
@ -415,7 +415,7 @@ public class Area extends SubCommand {
|
||||
ChunkManager.largeRegionTask(area.worldname, area.getRegion(), new RunnableVal<ChunkLoc>() {
|
||||
@Override
|
||||
public void run(ChunkLoc value) {
|
||||
AugmentedUtils.generate(area.worldname, value.x, value.z);
|
||||
AugmentedUtils.generate(area.worldname, value.x, value.z, null);
|
||||
}
|
||||
}, null);
|
||||
return true;
|
||||
|
@ -21,12 +21,9 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@ -47,7 +44,6 @@ import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
@ -158,7 +154,7 @@ public class DebugExec extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String... args) {
|
||||
final List<String> allowed_params = Arrays.asList("calibrate-analysis", "remove-flag", "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "trim-check");
|
||||
final List<String> allowed_params = Arrays.asList("calibrate-analysis", "remove-flag", "stop-expire", "start-expire", "show-expired", "update-expired", "seen");
|
||||
if (args.length > 0) {
|
||||
final String arg = args[0].toLowerCase();
|
||||
String script;
|
||||
@ -313,46 +309,6 @@ public class DebugExec extends SubCommand {
|
||||
MainUtil.sendMessage(player, "GMT: " + date.toGMTString());
|
||||
MainUtil.sendMessage(player, "Local: " + date.toLocaleString());
|
||||
return true;
|
||||
case "trim-check":
|
||||
if (args.length != 2) {
|
||||
MainUtil.sendMessage(player, "Use /plot debugexec trim-check <world>");
|
||||
MainUtil.sendMessage(player, "&7 - Generates a list of regions to trim");
|
||||
return MainUtil.sendMessage(player, "&7 - Run after plot expiry has run");
|
||||
}
|
||||
final String world = args[1];
|
||||
if (!WorldUtil.IMP.isWorld(world) || !PS.get().hasPlotArea(args[1])) {
|
||||
return MainUtil.sendMessage(player, "Invalid world: " + args[1]);
|
||||
}
|
||||
final ArrayList<ChunkLoc> empty = new ArrayList<>();
|
||||
final boolean result = Trim.getTrimRegions(empty, world, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Trim.sendMessage("Processing is complete! Here's how many chunks would be deleted:");
|
||||
Trim.sendMessage(" - MCA #: " + empty.size());
|
||||
Trim.sendMessage(" - CHUNKS: " + empty.size() * 1024 + " (max)");
|
||||
Trim.sendMessage("Exporting log for manual approval...");
|
||||
final File file = new File(PS.get().IMP.getDirectory() + File.separator + "trim.txt");
|
||||
try {
|
||||
PrintWriter writer = new PrintWriter(file);
|
||||
for (final ChunkLoc loc : empty) {
|
||||
writer.println(world + "/region/r." + loc.x + "." + loc.z + ".mca");
|
||||
}
|
||||
writer.close();
|
||||
Trim.sendMessage("File saved to 'plugins/PlotSquared/trim.txt'");
|
||||
} catch (final FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
Trim.sendMessage("File failed to save! :(");
|
||||
}
|
||||
Trim.sendMessage("How to get the chunk coords from a region file:");
|
||||
Trim.sendMessage(" - Locate the x,z values for the region file (the two numbers which are separated by a dot)");
|
||||
Trim.sendMessage(" - Multiply each number by 32; this gives you the starting position");
|
||||
Trim.sendMessage(" - Add 31 to each number to get the end position");
|
||||
}
|
||||
});
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player, "Trim task already started!");
|
||||
}
|
||||
return result;
|
||||
case "h":
|
||||
case "he":
|
||||
case "?":
|
||||
|
@ -35,7 +35,7 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "deny", aliases = { "d" }, description = "Deny a user from a plot", usage = "/plot deny <player>", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE)
|
||||
@CommandDeclaration(command = "deny", aliases = { "d", "ban" }, description = "Deny a user from a plot", usage = "/plot deny <player>", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE)
|
||||
public class Deny extends SubCommand {
|
||||
|
||||
public Deny() {
|
||||
|
@ -1,78 +1,60 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.ByteArrayUtilities;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "grant",
|
||||
category = CommandCategory.CLAIMING,
|
||||
usage = "/plot grant <check|add> [...]",
|
||||
usage = "/plot grant <check|add> [player]",
|
||||
permission = "plots.grant",
|
||||
requiredType = RequiredType.NONE
|
||||
)
|
||||
public class Grant extends SubCommand {
|
||||
|
||||
void grantPlayer(PlotPlayer plr, String enteredName) {
|
||||
PlotPlayer player;
|
||||
if (enteredName.length() > 16) {
|
||||
player = PlotPlayer.wrap(UUID.fromString(enteredName));
|
||||
} else {
|
||||
player = UUIDHandler.getPlayer(enteredName);
|
||||
}
|
||||
if (player == null) {
|
||||
sendMessage(plr, C.GRANTED_PLOT_FAILED, "Player not found");
|
||||
} else {
|
||||
int n = 1;
|
||||
if (player.hasPersistentMeta("grantedPlots")) {
|
||||
n += ByteArrayUtilities.bytesToInteger(player.getPersistentMeta("grantedPlots"));
|
||||
}
|
||||
player.setPersistentMeta("grantedPlots", ByteArrayUtilities.integerToBytes(n));
|
||||
sendMessage(plr, C.GRANTED_PLOT, enteredName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] arguments) {
|
||||
if (plr == null || plr instanceof ConsolePlayer) {
|
||||
if (arguments.length != 1) {
|
||||
MainUtil.sendMessage(null, "Usage: /plot grant <Player>");
|
||||
} else {
|
||||
grantPlayer(null, arguments[0]);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (arguments.length < 1) {
|
||||
arguments = new String[] { "check" };
|
||||
}
|
||||
switch (arguments[0]) {
|
||||
case "check": {
|
||||
int grantedPlots = 0;
|
||||
if (plr.hasPersistentMeta("grantedPlots")) {
|
||||
grantedPlots = ByteArrayUtilities.bytesToInteger(plr.getPersistentMeta("grantedPlots"));
|
||||
}
|
||||
return sendMessage(plr, C.GRANTED_PLOTS, "" + grantedPlots);
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final String arg0 = args[0].toLowerCase();
|
||||
switch (arg0) {
|
||||
case "add":
|
||||
case "check":
|
||||
if (Permissions.hasPermission(plr, "plots.grant." + arg0)) {
|
||||
C.NO_PERMISSION.send(plr, "plots.grant." + arg0);
|
||||
return false;
|
||||
}
|
||||
case "add": {
|
||||
if (!plr.hasPermission("plots.grant.add")) {
|
||||
return sendMessage(plr, C.NO_PERMISSION, "plots.grant.add");
|
||||
if (args.length > 2) {
|
||||
break;
|
||||
}
|
||||
final UUID uuid = args.length == 2 ? UUIDHandler.getUUIDFromString(args[1]) : plr.getUUID();
|
||||
if (uuid == null) {
|
||||
C.INVALID_PLAYER.send(plr, args[1]);
|
||||
return false;
|
||||
}
|
||||
MainUtil.getPersistentMeta(uuid, "grantedPlots", new RunnableVal<byte[]>() {
|
||||
@Override
|
||||
public void run(byte[] array) {
|
||||
if (arg0.equals("check")) { // check
|
||||
int granted = array == null ? 0 : ByteArrayUtilities.bytesToInteger(array);
|
||||
C.GRANTED_PLOTS.send(plr, granted);
|
||||
} else { // add
|
||||
int amount = 1 + (array == null ? 0 : ByteArrayUtilities.bytesToInteger(array));
|
||||
boolean replace = array != null;
|
||||
DBFunc.dbManager.addPersistentMeta(uuid, "grantedPlots", ByteArrayUtilities.integerToBytes(amount), replace);
|
||||
}
|
||||
}
|
||||
if (arguments.length < 2) {
|
||||
plr.sendMessage("&cUsage: /plot grant add <player>");
|
||||
} else {
|
||||
grantPlayer(plr, arguments[1]);
|
||||
}
|
||||
} break;
|
||||
default: return onCommand(plr, new String[] { "check" });
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,20 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
@ -42,19 +28,34 @@ import java.nio.file.Paths;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
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.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal2;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "trim",
|
||||
permission = "plots.admin",
|
||||
description = "Delete unmodified portions of your plotworld",
|
||||
usage = "/plot trim",
|
||||
usage = "/plot trim <world> [regenerate]",
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
public class Trim extends SubCommand {
|
||||
|
||||
public static boolean TASK = false;
|
||||
public static ArrayList<Plot> expired = null;
|
||||
private static int TASK_ID = 0;
|
||||
|
||||
public static boolean getBulkRegions(final ArrayList<ChunkLoc> empty, final String world, final Runnable whenDone) {
|
||||
if (Trim.TASK) {
|
||||
@ -110,114 +111,127 @@ public class Trim extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean getTrimRegions(final ArrayList<ChunkLoc> empty, final String world, final Runnable whenDone) {
|
||||
if (Trim.TASK) {
|
||||
/**
|
||||
* Runs the result task with the parameters (viable, nonViable).<br>
|
||||
* @param world
|
||||
* @param result (viable = .mcr to trim, nonViable = .mcr keep)
|
||||
* @return
|
||||
*/
|
||||
public static boolean getTrimRegions(final String world, final RunnableVal2<Set<ChunkLoc>, Set<ChunkLoc>> result) {
|
||||
if (result == null) {
|
||||
return false;
|
||||
}
|
||||
System.currentTimeMillis();
|
||||
sendMessage("Collecting region data...");
|
||||
MainUtil.sendMessage(null, "Collecting region data...");
|
||||
final ArrayList<Plot> plots = new ArrayList<>();
|
||||
plots.addAll(PS.get().getPlots(world));
|
||||
final HashSet<ChunkLoc> chunks = new HashSet<>(ChunkManager.manager.getChunkChunks(world));
|
||||
sendMessage(" - MCA #: " + chunks.size());
|
||||
sendMessage(" - CHUNKS: " + (chunks.size() * 1024) + " (max)");
|
||||
sendMessage(" - TIME ESTIMATE: " + (chunks.size() / 1200) + " minutes");
|
||||
Trim.TASK_ID = TaskManager.runTaskRepeat(new Runnable() {
|
||||
result.value1 = new HashSet<>(ChunkManager.manager.getChunkChunks(world));
|
||||
result.value2 = new HashSet<ChunkLoc>();
|
||||
MainUtil.sendMessage(null, " - MCA #: " + result.value1.size());
|
||||
MainUtil.sendMessage(null, " - CHUNKS: " + (result.value1.size() * 1024) + " (max)");
|
||||
MainUtil.sendMessage(null, " - TIME ESTIMATE: 12 Parsecs");
|
||||
TaskManager.objectTask(plots, new RunnableVal<Plot>() {
|
||||
@Override
|
||||
public void run() {
|
||||
final long start = System.currentTimeMillis();
|
||||
while ((System.currentTimeMillis() - start) < 50) {
|
||||
if (plots.isEmpty()) {
|
||||
empty.addAll(chunks);
|
||||
Trim.TASK = false;
|
||||
TaskManager.runTaskAsync(whenDone);
|
||||
PS.get().TASK.cancelTask(Trim.TASK_ID);
|
||||
return;
|
||||
}
|
||||
final Plot plot = plots.remove(0);
|
||||
|
||||
final Location pos1 = plot.getBottom();
|
||||
final Location pos2 = plot.getTop();
|
||||
|
||||
final int ccx1 = (pos1.getX() >> 9);
|
||||
final int ccz1 = (pos1.getZ() >> 9);
|
||||
final int ccx2 = (pos2.getX() >> 9);
|
||||
final int ccz2 = (pos2.getZ() >> 9);
|
||||
|
||||
for (int x = ccx1; x <= ccx2; x++) {
|
||||
for (int z = ccz1; z <= ccz2; z++) {
|
||||
chunks.remove(new ChunkLoc(x, z));
|
||||
public void run(Plot plot) {
|
||||
final Location pos1 = plot.getBottom();
|
||||
final Location pos2 = plot.getTop();
|
||||
final int ccx1 = (pos1.getX() >> 9);
|
||||
final int ccz1 = (pos1.getZ() >> 9);
|
||||
final int ccx2 = (pos2.getX() >> 9);
|
||||
final int ccz2 = (pos2.getZ() >> 9);
|
||||
for (int x = ccx1; x <= ccx2; x++) {
|
||||
for (int z = ccz1; z <= ccz2; z++) {
|
||||
ChunkLoc loc = new ChunkLoc(x, z);
|
||||
if (result.value1.remove(loc)) {
|
||||
result.value2.add(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 20);
|
||||
Trim.TASK = true;
|
||||
}, result);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void deleteChunks(final String world, final ArrayList<ChunkLoc> chunks, final Runnable whenDone) {
|
||||
ChunkManager.manager.deleteRegionFiles(world, chunks, whenDone);
|
||||
}
|
||||
|
||||
public static void sendMessage(final String message) {
|
||||
ConsolePlayer.getConsole().sendMessage("&3PlotSquared -> World trim&8: &7" + message);
|
||||
}
|
||||
|
||||
public PlotId getId(final String id) {
|
||||
try {
|
||||
final String[] split = id.split(";");
|
||||
return new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||
} catch (final Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static volatile boolean TASK = false;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
final String arg = args[0].toLowerCase();
|
||||
final PlotId id = getId(arg);
|
||||
if (id != null) {
|
||||
MainUtil.sendMessage(plr, "/plot trim x;z &l<world>");
|
||||
return false;
|
||||
}
|
||||
if (arg.equals("all")) {
|
||||
MainUtil.sendMessage(plr, "/plot trim all &l<world>");
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.TRIM_SYNTAX);
|
||||
if (args.length == 0) {
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
MainUtil.sendMessage(plr, C.TRIM_SYNTAX);
|
||||
return false;
|
||||
}
|
||||
final String arg = args[0].toLowerCase();
|
||||
if (!arg.equals("all")) {
|
||||
MainUtil.sendMessage(plr, C.TRIM_SYNTAX);
|
||||
return false;
|
||||
}
|
||||
final String world = args[1];
|
||||
final String world = args[0];
|
||||
if (!WorldUtil.IMP.isWorld(world) || (!PS.get().hasPlotArea(world))) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_WORLD);
|
||||
return false;
|
||||
}
|
||||
if (Trim.TASK) {
|
||||
sendMessage(C.TRIM_IN_PROGRESS.s());
|
||||
C.TRIM_IN_PROGRESS.send(plr);
|
||||
return false;
|
||||
}
|
||||
sendMessage(C.TASK_START.s());
|
||||
final ArrayList<ChunkLoc> empty = new ArrayList<>();
|
||||
getTrimRegions(empty, world, new Runnable() {
|
||||
Trim.TASK = true;
|
||||
final boolean regen = args.length == 2 ? Boolean.parseBoolean(args[1]) : false;
|
||||
getTrimRegions(world, new RunnableVal2<Set<ChunkLoc>, Set<ChunkLoc>>() {
|
||||
@Override
|
||||
public void run() {
|
||||
deleteChunks(world, empty, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ConsolePlayer.getConsole().sendMessage("$1Trim task complete!");
|
||||
}
|
||||
});
|
||||
public void run(final Set<ChunkLoc> viable, final Set<ChunkLoc> nonViable) {
|
||||
Runnable regenTask;
|
||||
if (regen) {
|
||||
regenTask = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (nonViable.size() == 0) {
|
||||
Trim.TASK = false;
|
||||
plr.sendMessage("Trim done!");
|
||||
return;
|
||||
}
|
||||
Iterator<ChunkLoc> iter = nonViable.iterator();
|
||||
ChunkLoc mcr = iter.next();
|
||||
iter.remove();
|
||||
int cbx = mcr.x << 5;
|
||||
int cbz = mcr.z << 5;
|
||||
// get all 1024 chunks
|
||||
HashSet<ChunkLoc> chunks = new HashSet<>();
|
||||
for (int x = cbx; x < cbx + 32; x++) {
|
||||
for (int z = cbz; z < cbz + 32; z++) {
|
||||
ChunkLoc loc = new ChunkLoc(x, z);
|
||||
chunks.add(loc);
|
||||
}
|
||||
}
|
||||
int bx = cbx << 4;
|
||||
int bz = cbz << 4;
|
||||
RegionWrapper region = new RegionWrapper(bx, bx + 511, bz, bz + 511);
|
||||
for (Plot plot : PS.get().getPlots(world)) {
|
||||
Location bot = plot.getBottomAbs();
|
||||
Location top = plot.getExtendedTopAbs();
|
||||
RegionWrapper plotReg = new RegionWrapper(bot.getX(), top.getX(), bot.getZ(), top.getZ());
|
||||
if (!region.intersects(plotReg)) {
|
||||
continue;
|
||||
}
|
||||
for (int x = plotReg.minX >> 4; x <= plotReg.maxX >> 4; x++) {
|
||||
for (int z = plotReg.minZ >> 4; z <= plotReg.maxZ >> 4; z++) {
|
||||
ChunkLoc loc = new ChunkLoc(x, z);
|
||||
chunks.remove(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
TaskManager.objectTask(chunks, new RunnableVal<ChunkLoc>() {
|
||||
@Override
|
||||
public void run(ChunkLoc value) {
|
||||
ChunkManager.manager.regenerateChunk(world, value);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
regenTask = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Trim.TASK = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
ChunkManager.manager.deleteRegionFiles(world, viable, regenTask);
|
||||
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
@ -31,7 +31,7 @@ import java.util.Set;
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.CommandCaller;
|
||||
|
||||
@ -393,7 +393,6 @@ public enum C {
|
||||
/*
|
||||
* trim
|
||||
*/
|
||||
TRIM_SYNTAX("Use /plot trim <all|x;y> <world>", "Trim"),
|
||||
TRIM_IN_PROGRESS("A world trim task is already in progress!", "Trim"),
|
||||
NOT_VALID_HYBRID_PLOT_WORLD("The hybrid plot manager is required to perform this action", "Trim"),
|
||||
/*
|
||||
@ -611,8 +610,11 @@ public enum C {
|
||||
* Direction
|
||||
*/
|
||||
DIRECTION("$1Current direction: %dir%", "Help"),
|
||||
GRANTED_PLOTS("$1You've got $2%s $1grants left", "Grants"),
|
||||
GRANTED_PLOT("$1You granted 1 plot to $2%s", "Grants"),
|
||||
/*
|
||||
* Grant
|
||||
*/
|
||||
GRANTED_PLOTS("$1Result: $2%s $1grants left", "Grants"),
|
||||
GRANTED_PLOT("$1You granted %s0 plot to $2%s1", "Grants"),
|
||||
GRANTED_PLOT_FAILED("$1Grant failed: $2%s", "Grants"),
|
||||
/*
|
||||
* Custom
|
||||
@ -693,7 +695,7 @@ public enum C {
|
||||
}
|
||||
|
||||
public static String format(final C c, final Object... args) {
|
||||
return format(c.s, args);
|
||||
return (c.usePrefix() ? C.PREFIX.s() : "") + format(c.s, args);
|
||||
}
|
||||
|
||||
public static String color(final String string) {
|
||||
@ -801,10 +803,15 @@ public enum C {
|
||||
}
|
||||
|
||||
public void send(final CommandCaller plr, final String... args) {
|
||||
send(plr, (Object[]) args);
|
||||
}
|
||||
|
||||
public void send(final CommandCaller plr, final Object... args) {
|
||||
String msg = format(this, args);
|
||||
if (plr == null) {
|
||||
MainUtil.sendConsoleMessage(this, args);
|
||||
ConsolePlayer.getConsole().sendMessage(msg);
|
||||
} else {
|
||||
plr.sendMessage(this, args);
|
||||
plr.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||
|
||||
@ -103,7 +102,7 @@ public interface AbstractDB {
|
||||
|
||||
void removePersistentMeta(UUID uuid, String key);
|
||||
|
||||
void getPersistentMeta(PlotPlayer player, RunnableVal<Map<String, byte[]>> result);
|
||||
void getPersistentMeta(UUID uuid, RunnableVal<Map<String, byte[]>> result);
|
||||
|
||||
/**
|
||||
* Create plot settings
|
||||
|
@ -54,7 +54,6 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotSettings;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||
@ -2421,16 +2420,17 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPersistentMeta(final UUID uuid, final String key, final byte[] meta, final boolean delete) {
|
||||
public void addPersistentMeta(final UUID uuid, final String key, final byte[] meta, final boolean replace) {
|
||||
addPlayerTask(uuid, new UniqueStatement("addPersistentMeta") {
|
||||
@Override
|
||||
public void set(final PreparedStatement stmt) throws SQLException {
|
||||
if (delete) {
|
||||
stmt.setString(1, uuid.toString());
|
||||
stmt.setString(2, key);
|
||||
Blob blob = connection.createBlob();
|
||||
blob.setBytes(1, meta);
|
||||
if (replace) {
|
||||
stmt.setBlob(1, blob);
|
||||
stmt.setString(2, uuid.toString());
|
||||
stmt.setString(3, key);
|
||||
} else {
|
||||
Blob blob = connection.createBlob();
|
||||
blob.setBytes(1, meta);
|
||||
stmt.setString(1, uuid.toString());
|
||||
stmt.setString(2, key);
|
||||
stmt.setBlob(3, blob);
|
||||
@ -2439,8 +2439,8 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public PreparedStatement get() throws SQLException {
|
||||
if (delete) {
|
||||
return connection.prepareStatement("DELETE FROM `" + prefix + "player_meta` WHERE `uuid` = ? AND `key` = ?");
|
||||
if (replace) {
|
||||
return connection.prepareStatement("UPDATE `" + prefix + "player_meta` SET `value` = ? WHERE `uuid` = ? AND `key` = ?");
|
||||
} else {
|
||||
return connection.prepareStatement("INSERT INTO `" + prefix + "player_meta`(`uuid`, `key`, `value`) VALUES(?, ? ,?)");
|
||||
}
|
||||
@ -2465,11 +2465,11 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getPersistentMeta(final PlotPlayer player, final RunnableVal<Map<String, byte[]>> result) {
|
||||
addPlayerTask(player.getUUID(), new UniqueStatement("getPersistentMeta") {
|
||||
public void getPersistentMeta(final UUID uuid, final RunnableVal<Map<String, byte[]>> result) {
|
||||
addPlayerTask(uuid, new UniqueStatement("getPersistentMeta") {
|
||||
@Override
|
||||
public void set(final PreparedStatement stmt) throws SQLException {
|
||||
stmt.setString(1, player.getUUID().toString());
|
||||
stmt.setString(1, uuid.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,6 +20,13 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.flag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
@ -32,13 +39,6 @@ import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Flag Manager Utility
|
||||
*
|
||||
@ -100,13 +100,13 @@ public class FlagManager {
|
||||
PS.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
||||
@Override
|
||||
public void run(PlotArea value) {
|
||||
final Flag flag = ((HashMap<String, Flag>) value.DEFAULT_FLAGS.clone()).get(af.getKey());
|
||||
final Flag flag = value.DEFAULT_FLAGS.get(af.getKey());
|
||||
if (flag != null) {
|
||||
flag.setKey(af);
|
||||
}
|
||||
}
|
||||
});
|
||||
PS.get().foreachPlot(new RunnableVal<Plot>() {
|
||||
PS.get().foreachPlotRaw(new RunnableVal<Plot>() {
|
||||
@Override
|
||||
public void run(Plot value) {
|
||||
final Flag flag = value.getFlags().get(af.getKey());
|
||||
@ -115,11 +115,12 @@ public class FlagManager {
|
||||
}
|
||||
}
|
||||
});
|
||||
if (getFlag(af.getKey()) == null && flags.add(af)) {
|
||||
if (reserved) {
|
||||
reserveFlag(af.getKey());
|
||||
}
|
||||
return true;
|
||||
if (flags.remove(af)) {
|
||||
PS.debug("(Replaced existing flag)");
|
||||
}
|
||||
flags.add(af);
|
||||
if (reserved) {
|
||||
reserveFlag(af.getKey());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.LazyResult;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
@ -10,8 +13,6 @@ import com.intellectualcrafters.plot.util.PlotChunk;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class AugmentedUtils {
|
||||
|
||||
private static boolean enabled = true;
|
||||
@ -22,10 +23,18 @@ public class AugmentedUtils {
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
public static void generate(String world, int cx, int cz) {
|
||||
public static void generate(final String world, final int cx, final int cz, LazyResult<PlotChunk<?>> lazyChunk) {
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
if (lazyChunk == null) {
|
||||
lazyChunk = new LazyResult<PlotChunk<?>>() {
|
||||
@Override
|
||||
public PlotChunk<?> create() {
|
||||
return SetQueue.IMP.queue.getChunk(SetQueue.IMP.new ChunkWrapper(world, cx, cz));
|
||||
}
|
||||
};
|
||||
}
|
||||
final int bx = cx << 4;
|
||||
final int bz = cz << 4;
|
||||
RegionWrapper region = new RegionWrapper(bx, bx + 15, bz, bz + 15);
|
||||
@ -35,7 +44,6 @@ public class AugmentedUtils {
|
||||
}
|
||||
final PseudoRandom r = new PseudoRandom();
|
||||
r.state = (cx << 16) | (cz & 0xFFFF);;
|
||||
PlotChunk<?> cache_chunk = null;
|
||||
ChunkWrapper wrap = SetQueue.IMP.new ChunkWrapper(world, cx, cz);
|
||||
for (final PlotArea area : areas) {
|
||||
if (area.TYPE == 0) {
|
||||
@ -48,10 +56,7 @@ public class AugmentedUtils {
|
||||
if (generator == null) {
|
||||
continue;
|
||||
}
|
||||
if (cache_chunk == null) {
|
||||
cache_chunk = SetQueue.IMP.queue.getChunk(wrap);
|
||||
}
|
||||
final PlotChunk<?> result = cache_chunk;
|
||||
final PlotChunk<?> result = lazyChunk.getOrCreate();
|
||||
final PlotChunk<?> primaryMask;
|
||||
// coords
|
||||
int bxx = Math.max(0, area.getRegion().minX - bx);
|
||||
@ -154,9 +159,9 @@ public class AugmentedUtils {
|
||||
}
|
||||
generator.generateChunk(secondaryMask, area, r);
|
||||
}
|
||||
if (cache_chunk != null) {
|
||||
cache_chunk.addToQueue();
|
||||
cache_chunk.flush(false);
|
||||
if (lazyChunk.get() != null) {
|
||||
lazyChunk.get().addToQueue();
|
||||
lazyChunk.get().flush(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,8 +61,8 @@ public abstract class IndependentPlotGenerator {
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public <T> GeneratorWrapper<T> specify(String world) {
|
||||
return (GeneratorWrapper<T>) PS.get().IMP.wrapPlotGenerator(world, this);
|
||||
public <T> GeneratorWrapper<T> specify() {
|
||||
return (GeneratorWrapper<T>) PS.get().IMP.wrapPlotGenerator(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,9 +5,7 @@ import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.RequiredType;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.PlotGamemode;
|
||||
import com.intellectualcrafters.plot.util.PlotWeather;
|
||||
|
||||
@ -75,11 +73,6 @@ public class ConsolePlayer extends PlotPlayer {
|
||||
PS.log(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(final C c, final String... args) {
|
||||
MainUtil.sendMessage(this, c, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(final Location loc) {
|
||||
final Plot plot = loc.getPlot();
|
||||
|
@ -0,0 +1,18 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
public abstract class LazyResult<T> {
|
||||
private T result;
|
||||
|
||||
public T get() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public T getOrCreate() {
|
||||
if (this.result == null) {
|
||||
return (this.result = create());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public abstract T create();
|
||||
}
|
@ -422,7 +422,7 @@ public abstract class PlotPlayer implements CommandCaller {
|
||||
}
|
||||
|
||||
public void populatePersistentMetaMap() {
|
||||
DBFunc.dbManager.getPersistentMeta(this, new RunnableVal<Map<String, byte[]>>() {
|
||||
DBFunc.dbManager.getPersistentMeta(getUUID(), new RunnableVal<Map<String, byte[]>>() {
|
||||
@Override
|
||||
public void run(Map<String, byte[]> value) {
|
||||
PlotPlayer.this.metaMap = value;
|
||||
|
@ -1,5 +1,11 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
@ -9,12 +15,6 @@ 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.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class ChunkManager {
|
||||
|
||||
public static ChunkManager manager = null;
|
||||
@ -206,11 +206,11 @@ public abstract class ChunkManager {
|
||||
|
||||
public abstract void regenerateChunk(final String world, final ChunkLoc loc);
|
||||
|
||||
public void deleteRegionFiles(String world, List<ChunkLoc> chunks) {
|
||||
public void deleteRegionFiles(String world, Collection<ChunkLoc> chunks) {
|
||||
deleteRegionFiles(world, chunks, null);
|
||||
}
|
||||
|
||||
public void deleteRegionFiles(final String world, final List<ChunkLoc> chunks, final Runnable whenDone) {
|
||||
public void deleteRegionFiles(final String world, final Collection<ChunkLoc> chunks, final Runnable whenDone) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -222,9 +222,7 @@ public abstract class ChunkManager {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
if (whenDone != null) {
|
||||
whenDone.run();
|
||||
}
|
||||
TaskManager.runTask(whenDone);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -11,9 +11,11 @@ public abstract class EconHandler {
|
||||
if (ConsolePlayer.isConsole(player)) {
|
||||
return Double.MAX_VALUE;
|
||||
}
|
||||
return Double.NaN;
|
||||
return getBalance(player);
|
||||
}
|
||||
|
||||
public abstract double getBalance(PlotPlayer player);
|
||||
|
||||
public abstract void withdrawMoney(final PlotPlayer player, final double amount);
|
||||
|
||||
public abstract void depositMoney(final PlotPlayer player, final double amount);
|
||||
|
@ -25,6 +25,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
@ -525,14 +526,11 @@ public class MainUtil {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String msg = c.s();
|
||||
if (args.length != 0) {
|
||||
msg = C.format(c, args);
|
||||
}
|
||||
if (plr != null) {
|
||||
plr.sendMessage(c.usePrefix() ? C.PREFIX.s() + msg : msg);
|
||||
String m = C.format(c, args);
|
||||
if (plr == null) {
|
||||
ConsolePlayer.getConsole().sendMessage(m);
|
||||
} else {
|
||||
ConsolePlayer.getConsole().sendMessage((c.usePrefix() ? C.PREFIX.s() : "") + msg);
|
||||
plr.sendMessage(m);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -712,4 +710,18 @@ public class MainUtil {
|
||||
}
|
||||
return list.toString();
|
||||
}
|
||||
|
||||
public static void getPersistentMeta(final UUID uuid, final String key, final RunnableVal<byte[]> result) {
|
||||
PlotPlayer pp = UUIDHandler.getPlayer(uuid);
|
||||
if (pp != null) {
|
||||
result.run(pp.getPersistentMeta(key));
|
||||
} else {
|
||||
DBFunc.dbManager.getPersistentMeta(uuid, new RunnableVal<Map<String, byte[]>>() {
|
||||
@Override
|
||||
public void run(Map<String, byte[]> value) {
|
||||
result.run(value.get(key));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
@ -9,10 +13,6 @@ import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UUIDHandler {
|
||||
|
||||
public static UUIDHandlerImplementation implementation;
|
||||
@ -107,6 +107,13 @@ public class UUIDHandler {
|
||||
return implementation.getPlayer(name);
|
||||
}
|
||||
|
||||
public static UUID getUUIDFromString(String nameOrUUIDString) {
|
||||
if (nameOrUUIDString.length() > 16) {
|
||||
return UUID.fromString(nameOrUUIDString);
|
||||
}
|
||||
return UUIDHandler.getUUID(nameOrUUIDString, null);
|
||||
}
|
||||
|
||||
public static UUID getUUID(final String name, final RunnableVal<UUID> ifFetch) {
|
||||
return implementation.getUUID(name, ifFetch);
|
||||
}
|
||||
|
@ -375,9 +375,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@Override
|
||||
public void registerInventoryEvents() {
|
||||
|
||||
// Part of PlayerEvents - can be moved if necessary
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -486,7 +484,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
}
|
||||
return new BukkitPlotGenerator(world, gen);
|
||||
} else {
|
||||
return new BukkitPlotGenerator(world, new HybridGen());
|
||||
return new BukkitPlotGenerator(new HybridGen());
|
||||
}
|
||||
}
|
||||
|
||||
@ -654,11 +652,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
} else if (obj instanceof String) {
|
||||
return UUIDHandler.getPlayer((String) obj);
|
||||
} else if (obj instanceof UUID) {
|
||||
PlotPlayer player = UUIDHandler.getPlayer((UUID) obj);
|
||||
if (player == null) {
|
||||
return BukkitUtil.getPlayer(Bukkit.getOfflinePlayer((UUID) obj));
|
||||
}
|
||||
return player;
|
||||
return UUIDHandler.getPlayer((UUID) obj);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -697,7 +691,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@Override
|
||||
public GeneratorWrapper<?> wrapPlotGenerator(String world, IndependentPlotGenerator generator) {
|
||||
return new BukkitPlotGenerator(world, generator);
|
||||
return new BukkitPlotGenerator(generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -371,7 +371,7 @@ public class LikePlotMeConverter {
|
||||
// Load using Bukkit API
|
||||
// - User must set generator manually
|
||||
Bukkit.getServer().unloadWorld(world, true);
|
||||
final World myworld = WorldCreator.name(actualWorldName).generator(new BukkitPlotGenerator(actualWorldName, new HybridGen())).createWorld();
|
||||
final World myworld = WorldCreator.name(actualWorldName).generator(new BukkitPlotGenerator(new HybridGen())).createWorld();
|
||||
myworld.save();
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class BukkitAugmentedGenerator extends BlockPopulator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populate(World world, Random r, Chunk chunk) {
|
||||
AugmentedUtils.generate(world.getName(), chunk.getX(), chunk.getZ());
|
||||
public void populate(final World world, Random r, final Chunk chunk) {
|
||||
AugmentedUtils.generate(world.getName(), chunk.getX(), chunk.getZ(), null);
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,17 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.plotsquared.bukkit.generator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
@ -36,16 +47,6 @@ import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.plotsquared.bukkit.listeners.WorldEvents;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.bukkit.util.block.GenChunk;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper<ChunkGenerator> {
|
||||
|
||||
@ -54,12 +55,10 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
private final IndependentPlotGenerator plotGenerator;
|
||||
private final List<BlockPopulator> populators = new ArrayList<>();
|
||||
private boolean loaded = false;
|
||||
private PlotManager manager;
|
||||
private ChunkGenerator platformGenerator;
|
||||
private boolean full;
|
||||
|
||||
public BukkitPlotGenerator(final String world, IndependentPlotGenerator generator) {
|
||||
WorldEvents.lastWorld = world;
|
||||
public BukkitPlotGenerator(IndependentPlotGenerator generator) {
|
||||
this.plotGenerator = generator;
|
||||
this.platformGenerator = this;
|
||||
populators.add(new BlockPopulator() {
|
||||
@ -87,7 +86,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
}
|
||||
}
|
||||
});
|
||||
chunkSetter = new GenChunk(null, SetQueue.IMP.new ChunkWrapper(world, 0, 0));
|
||||
chunkSetter = new GenChunk(null, null);
|
||||
this.full = true;
|
||||
MainUtil.initCache();
|
||||
}
|
||||
|
@ -1,14 +1,7 @@
|
||||
package com.plotsquared.bukkit.object;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.PlotGamemode;
|
||||
import com.intellectualcrafters.plot.util.PlotWeather;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
@ -18,7 +11,14 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.util.UUID;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.PlotGamemode;
|
||||
import com.intellectualcrafters.plot.util.PlotWeather;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
|
||||
public class BukkitPlayer extends PlotPlayer {
|
||||
|
||||
@ -101,11 +101,6 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
player.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(final C c, final String... args) {
|
||||
MainUtil.sendMessage(this, c, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(final Location loc) {
|
||||
if (Math.abs(loc.getX()) >= 30000000 || Math.abs(loc.getZ()) >= 30000000) {
|
||||
@ -145,7 +140,6 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
|
||||
@Override
|
||||
public boolean getAttribute(String key) {
|
||||
|
||||
if (!hasPersistentMeta(key)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1,14 +1,16 @@
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.plotsquared.bukkit.object.BukkitOfflinePlayer;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
public class BukkitEconHandler extends EconHandler {
|
||||
|
||||
@ -88,4 +90,9 @@ public class BukkitEconHandler extends EconHandler {
|
||||
public boolean hasPermission(final String world, final String player, final String perm) {
|
||||
return perms.playerHas(world, Bukkit.getOfflinePlayer(player), perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(PlotPlayer player) {
|
||||
return econ.getBalance(player.getName());
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,10 @@
|
||||
package com.plotsquared.general.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.RequiredType;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
|
||||
public interface CommandCaller {
|
||||
void sendMessage(final String message);
|
||||
|
||||
void sendMessage(final C c, final String... args);
|
||||
|
||||
boolean hasPermission(final String perm);
|
||||
|
||||
RequiredType getSuperCaller();
|
||||
|
Loading…
Reference in New Issue
Block a user