mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26: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
|
* 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) {
|
public Collection<Plot> getPlots(final String world) {
|
||||||
final HashSet<Plot> set = new HashSet<>();
|
final HashSet<Plot> set = new HashSet<>();
|
||||||
foreachPlotArea(null);
|
|
||||||
foreachPlotArea(world, new RunnableVal<PlotArea>() {
|
foreachPlotArea(world, new RunnableVal<PlotArea>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(PlotArea value) {
|
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) {
|
public void foreachBasePlot(RunnableVal<Plot> run) {
|
||||||
for (PlotArea area : plotareas) {
|
for (PlotArea area : plotareas) {
|
||||||
area.foreachBasePlot(run);
|
area.foreachBasePlot(run);
|
||||||
|
@ -131,8 +131,8 @@ public class Area extends SubCommand {
|
|||||||
if (area.TERRAIN != 3) {
|
if (area.TERRAIN != 3) {
|
||||||
ChunkManager.largeRegionTask(world, region, new RunnableVal<ChunkLoc>() {
|
ChunkManager.largeRegionTask(world, region, new RunnableVal<ChunkLoc>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(ChunkLoc value) {
|
public void run(final ChunkLoc value) {
|
||||||
AugmentedUtils.generate(world, value.x, value.z);
|
AugmentedUtils.generate(world, value.x, value.z, null);
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
@ -415,7 +415,7 @@ public class Area extends SubCommand {
|
|||||||
ChunkManager.largeRegionTask(area.worldname, area.getRegion(), new RunnableVal<ChunkLoc>() {
|
ChunkManager.largeRegionTask(area.worldname, area.getRegion(), new RunnableVal<ChunkLoc>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(ChunkLoc value) {
|
public void run(ChunkLoc value) {
|
||||||
AugmentedUtils.generate(area.worldname, value.x, value.z);
|
AugmentedUtils.generate(area.worldname, value.x, value.z, null);
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
return true;
|
return true;
|
||||||
|
@ -21,12 +21,9 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -47,7 +44,6 @@ import com.intellectualcrafters.plot.config.Settings;
|
|||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
|
||||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||||
@ -158,7 +154,7 @@ public class DebugExec extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final PlotPlayer player, final String... args) {
|
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) {
|
if (args.length > 0) {
|
||||||
final String arg = args[0].toLowerCase();
|
final String arg = args[0].toLowerCase();
|
||||||
String script;
|
String script;
|
||||||
@ -313,46 +309,6 @@ public class DebugExec extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, "GMT: " + date.toGMTString());
|
MainUtil.sendMessage(player, "GMT: " + date.toGMTString());
|
||||||
MainUtil.sendMessage(player, "Local: " + date.toLocaleString());
|
MainUtil.sendMessage(player, "Local: " + date.toLocaleString());
|
||||||
return true;
|
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 "h":
|
||||||
case "he":
|
case "he":
|
||||||
case "?":
|
case "?":
|
||||||
|
@ -35,7 +35,7 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
|||||||
import com.plotsquared.general.commands.Argument;
|
import com.plotsquared.general.commands.Argument;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
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 class Deny extends SubCommand {
|
||||||
|
|
||||||
public Deny() {
|
public Deny() {
|
||||||
|
@ -1,78 +1,60 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
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.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.util.ByteArrayUtilities;
|
import com.intellectualcrafters.plot.util.ByteArrayUtilities;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
command = "grant",
|
command = "grant",
|
||||||
category = CommandCategory.CLAIMING,
|
category = CommandCategory.CLAIMING,
|
||||||
usage = "/plot grant <check|add> [...]",
|
usage = "/plot grant <check|add> [player]",
|
||||||
permission = "plots.grant",
|
permission = "plots.grant",
|
||||||
requiredType = RequiredType.NONE
|
requiredType = RequiredType.NONE
|
||||||
)
|
)
|
||||||
public class Grant extends SubCommand {
|
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
|
@Override
|
||||||
public boolean onCommand(PlotPlayer plr, String[] arguments) {
|
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||||
if (plr == null || plr instanceof ConsolePlayer) {
|
final String arg0 = args[0].toLowerCase();
|
||||||
if (arguments.length != 1) {
|
switch (arg0) {
|
||||||
MainUtil.sendMessage(null, "Usage: /plot grant <Player>");
|
case "add":
|
||||||
} else {
|
case "check":
|
||||||
grantPlayer(null, arguments[0]);
|
if (Permissions.hasPermission(plr, "plots.grant." + arg0)) {
|
||||||
|
C.NO_PERMISSION.send(plr, "plots.grant." + arg0);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||||
if (arguments.length < 1) {
|
return false;
|
||||||
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);
|
|
||||||
}
|
|
||||||
case "add": {
|
|
||||||
if (!plr.hasPermission("plots.grant.add")) {
|
|
||||||
return sendMessage(plr, C.NO_PERMISSION, "plots.grant.add");
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,20 +20,6 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.intellectualcrafters.plot.commands;
|
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.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@ -42,19 +28,34 @@ import java.nio.file.Paths;
|
|||||||
import java.nio.file.attribute.BasicFileAttributes;
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
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(
|
@CommandDeclaration(
|
||||||
command = "trim",
|
command = "trim",
|
||||||
permission = "plots.admin",
|
permission = "plots.admin",
|
||||||
description = "Delete unmodified portions of your plotworld",
|
description = "Delete unmodified portions of your plotworld",
|
||||||
usage = "/plot trim",
|
usage = "/plot trim <world> [regenerate]",
|
||||||
requiredType = RequiredType.CONSOLE,
|
requiredType = RequiredType.CONSOLE,
|
||||||
category = CommandCategory.ADMINISTRATION)
|
category = CommandCategory.ADMINISTRATION)
|
||||||
public class Trim extends SubCommand {
|
public class Trim extends SubCommand {
|
||||||
|
|
||||||
public static boolean TASK = false;
|
|
||||||
public static ArrayList<Plot> expired = null;
|
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) {
|
public static boolean getBulkRegions(final ArrayList<ChunkLoc> empty, final String world, final Runnable whenDone) {
|
||||||
if (Trim.TASK) {
|
if (Trim.TASK) {
|
||||||
@ -110,114 +111,127 @@ public class Trim extends SubCommand {
|
|||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
System.currentTimeMillis();
|
MainUtil.sendMessage(null, "Collecting region data...");
|
||||||
sendMessage("Collecting region data...");
|
|
||||||
final ArrayList<Plot> plots = new ArrayList<>();
|
final ArrayList<Plot> plots = new ArrayList<>();
|
||||||
plots.addAll(PS.get().getPlots(world));
|
plots.addAll(PS.get().getPlots(world));
|
||||||
final HashSet<ChunkLoc> chunks = new HashSet<>(ChunkManager.manager.getChunkChunks(world));
|
result.value1 = new HashSet<>(ChunkManager.manager.getChunkChunks(world));
|
||||||
sendMessage(" - MCA #: " + chunks.size());
|
result.value2 = new HashSet<ChunkLoc>();
|
||||||
sendMessage(" - CHUNKS: " + (chunks.size() * 1024) + " (max)");
|
MainUtil.sendMessage(null, " - MCA #: " + result.value1.size());
|
||||||
sendMessage(" - TIME ESTIMATE: " + (chunks.size() / 1200) + " minutes");
|
MainUtil.sendMessage(null, " - CHUNKS: " + (result.value1.size() * 1024) + " (max)");
|
||||||
Trim.TASK_ID = TaskManager.runTaskRepeat(new Runnable() {
|
MainUtil.sendMessage(null, " - TIME ESTIMATE: 12 Parsecs");
|
||||||
|
TaskManager.objectTask(plots, new RunnableVal<Plot>() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run(Plot plot) {
|
||||||
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 pos1 = plot.getBottom();
|
||||||
final Location pos2 = plot.getTop();
|
final Location pos2 = plot.getTop();
|
||||||
|
|
||||||
final int ccx1 = (pos1.getX() >> 9);
|
final int ccx1 = (pos1.getX() >> 9);
|
||||||
final int ccz1 = (pos1.getZ() >> 9);
|
final int ccz1 = (pos1.getZ() >> 9);
|
||||||
final int ccx2 = (pos2.getX() >> 9);
|
final int ccx2 = (pos2.getX() >> 9);
|
||||||
final int ccz2 = (pos2.getZ() >> 9);
|
final int ccz2 = (pos2.getZ() >> 9);
|
||||||
|
|
||||||
for (int x = ccx1; x <= ccx2; x++) {
|
for (int x = ccx1; x <= ccx2; x++) {
|
||||||
for (int z = ccz1; z <= ccz2; z++) {
|
for (int z = ccz1; z <= ccz2; z++) {
|
||||||
chunks.remove(new ChunkLoc(x, z));
|
ChunkLoc loc = new ChunkLoc(x, z);
|
||||||
|
if (result.value1.remove(loc)) {
|
||||||
|
result.value2.add(loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 20);
|
}, result);
|
||||||
Trim.TASK = true;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteChunks(final String world, final ArrayList<ChunkLoc> chunks, final Runnable whenDone) {
|
private static volatile boolean TASK = false;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 0) {
|
||||||
final String arg = args[0].toLowerCase();
|
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||||
final PlotId id = getId(arg);
|
|
||||||
if (id != null) {
|
|
||||||
MainUtil.sendMessage(plr, "/plot trim x;z &l<world>");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (arg.equals("all")) {
|
final String world = args[0];
|
||||||
MainUtil.sendMessage(plr, "/plot trim all &l<world>");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
MainUtil.sendMessage(plr, C.TRIM_SYNTAX);
|
|
||||||
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];
|
|
||||||
if (!WorldUtil.IMP.isWorld(world) || (!PS.get().hasPlotArea(world))) {
|
if (!WorldUtil.IMP.isWorld(world) || (!PS.get().hasPlotArea(world))) {
|
||||||
MainUtil.sendMessage(plr, C.NOT_VALID_WORLD);
|
MainUtil.sendMessage(plr, C.NOT_VALID_WORLD);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Trim.TASK) {
|
if (Trim.TASK) {
|
||||||
sendMessage(C.TRIM_IN_PROGRESS.s());
|
C.TRIM_IN_PROGRESS.send(plr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
sendMessage(C.TASK_START.s());
|
Trim.TASK = true;
|
||||||
final ArrayList<ChunkLoc> empty = new ArrayList<>();
|
final boolean regen = args.length == 2 ? Boolean.parseBoolean(args[1]) : false;
|
||||||
getTrimRegions(empty, world, new Runnable() {
|
getTrimRegions(world, new RunnableVal2<Set<ChunkLoc>, Set<ChunkLoc>>() {
|
||||||
|
@Override
|
||||||
|
public void run(final Set<ChunkLoc> viable, final Set<ChunkLoc> nonViable) {
|
||||||
|
Runnable regenTask;
|
||||||
|
if (regen) {
|
||||||
|
regenTask = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
deleteChunks(world, empty, new Runnable() {
|
if (nonViable.size() == 0) {
|
||||||
@Override
|
Trim.TASK = false;
|
||||||
public void run() {
|
plr.sendMessage("Trim done!");
|
||||||
ConsolePlayer.getConsole().sendMessage("$1Trim task complete!");
|
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;
|
return true;
|
||||||
|
@ -31,7 +31,7 @@ import java.util.Set;
|
|||||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||||
import com.intellectualcrafters.plot.PS;
|
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.intellectualcrafters.plot.util.StringMan;
|
||||||
import com.plotsquared.general.commands.CommandCaller;
|
import com.plotsquared.general.commands.CommandCaller;
|
||||||
|
|
||||||
@ -393,7 +393,6 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* trim
|
* trim
|
||||||
*/
|
*/
|
||||||
TRIM_SYNTAX("Use /plot trim <all|x;y> <world>", "Trim"),
|
|
||||||
TRIM_IN_PROGRESS("A world trim task is already in progress!", "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"),
|
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
|
||||||
*/
|
*/
|
||||||
DIRECTION("$1Current direction: %dir%", "Help"),
|
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"),
|
GRANTED_PLOT_FAILED("$1Grant failed: $2%s", "Grants"),
|
||||||
/*
|
/*
|
||||||
* Custom
|
* Custom
|
||||||
@ -693,7 +695,7 @@ public enum C {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String format(final C c, final Object... args) {
|
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) {
|
public static String color(final String string) {
|
||||||
@ -801,10 +803,15 @@ public enum C {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void send(final CommandCaller plr, final String... args) {
|
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) {
|
if (plr == null) {
|
||||||
MainUtil.sendConsoleMessage(this, args);
|
ConsolePlayer.getConsole().sendMessage(msg);
|
||||||
} else {
|
} 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.PlotArea;
|
||||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||||
|
|
||||||
@ -103,7 +102,7 @@ public interface AbstractDB {
|
|||||||
|
|
||||||
void removePersistentMeta(UUID uuid, String key);
|
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
|
* Create plot settings
|
||||||
|
@ -54,7 +54,6 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
import com.intellectualcrafters.plot.object.PlotArea;
|
import com.intellectualcrafters.plot.object.PlotArea;
|
||||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotSettings;
|
import com.intellectualcrafters.plot.object.PlotSettings;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||||
@ -2421,16 +2420,17 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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") {
|
addPlayerTask(uuid, new UniqueStatement("addPersistentMeta") {
|
||||||
@Override
|
@Override
|
||||||
public void set(final PreparedStatement stmt) throws SQLException {
|
public void set(final PreparedStatement stmt) throws SQLException {
|
||||||
if (delete) {
|
|
||||||
stmt.setString(1, uuid.toString());
|
|
||||||
stmt.setString(2, key);
|
|
||||||
} else {
|
|
||||||
Blob blob = connection.createBlob();
|
Blob blob = connection.createBlob();
|
||||||
blob.setBytes(1, meta);
|
blob.setBytes(1, meta);
|
||||||
|
if (replace) {
|
||||||
|
stmt.setBlob(1, blob);
|
||||||
|
stmt.setString(2, uuid.toString());
|
||||||
|
stmt.setString(3, key);
|
||||||
|
} else {
|
||||||
stmt.setString(1, uuid.toString());
|
stmt.setString(1, uuid.toString());
|
||||||
stmt.setString(2, key);
|
stmt.setString(2, key);
|
||||||
stmt.setBlob(3, blob);
|
stmt.setBlob(3, blob);
|
||||||
@ -2439,8 +2439,8 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreparedStatement get() throws SQLException {
|
public PreparedStatement get() throws SQLException {
|
||||||
if (delete) {
|
if (replace) {
|
||||||
return connection.prepareStatement("DELETE FROM `" + prefix + "player_meta` WHERE `uuid` = ? AND `key` = ?");
|
return connection.prepareStatement("UPDATE `" + prefix + "player_meta` SET `value` = ? WHERE `uuid` = ? AND `key` = ?");
|
||||||
} else {
|
} else {
|
||||||
return connection.prepareStatement("INSERT INTO `" + prefix + "player_meta`(`uuid`, `key`, `value`) VALUES(?, ? ,?)");
|
return connection.prepareStatement("INSERT INTO `" + prefix + "player_meta`(`uuid`, `key`, `value`) VALUES(?, ? ,?)");
|
||||||
}
|
}
|
||||||
@ -2465,11 +2465,11 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getPersistentMeta(final PlotPlayer player, final RunnableVal<Map<String, byte[]>> result) {
|
public void getPersistentMeta(final UUID uuid, final RunnableVal<Map<String, byte[]>> result) {
|
||||||
addPlayerTask(player.getUUID(), new UniqueStatement("getPersistentMeta") {
|
addPlayerTask(uuid, new UniqueStatement("getPersistentMeta") {
|
||||||
@Override
|
@Override
|
||||||
public void set(final PreparedStatement stmt) throws SQLException {
|
public void set(final PreparedStatement stmt) throws SQLException {
|
||||||
stmt.setString(1, player.getUUID().toString());
|
stmt.setString(1, uuid.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,6 +20,13 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.intellectualcrafters.plot.flag;
|
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.PS;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
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.EventUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
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
|
* Flag Manager Utility
|
||||||
*
|
*
|
||||||
@ -100,13 +100,13 @@ public class FlagManager {
|
|||||||
PS.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
PS.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(PlotArea value) {
|
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) {
|
if (flag != null) {
|
||||||
flag.setKey(af);
|
flag.setKey(af);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
PS.get().foreachPlot(new RunnableVal<Plot>() {
|
PS.get().foreachPlotRaw(new RunnableVal<Plot>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Plot value) {
|
public void run(Plot value) {
|
||||||
final Flag flag = value.getFlags().get(af.getKey());
|
final Flag flag = value.getFlags().get(af.getKey());
|
||||||
@ -115,12 +115,13 @@ public class FlagManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (getFlag(af.getKey()) == null && flags.add(af)) {
|
if (flags.remove(af)) {
|
||||||
|
PS.debug("(Replaced existing flag)");
|
||||||
|
}
|
||||||
|
flags.add(af);
|
||||||
if (reserved) {
|
if (reserved) {
|
||||||
reserveFlag(af.getKey());
|
reserveFlag(af.getKey());
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package com.intellectualcrafters.plot.generator;
|
package com.intellectualcrafters.plot.generator;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
|
import com.intellectualcrafters.plot.object.LazyResult;
|
||||||
import com.intellectualcrafters.plot.object.PlotArea;
|
import com.intellectualcrafters.plot.object.PlotArea;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
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;
|
||||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class AugmentedUtils {
|
public class AugmentedUtils {
|
||||||
|
|
||||||
private static boolean enabled = true;
|
private static boolean enabled = true;
|
||||||
@ -22,10 +23,18 @@ public class AugmentedUtils {
|
|||||||
enabled = true;
|
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) {
|
if (!enabled) {
|
||||||
return;
|
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 bx = cx << 4;
|
||||||
final int bz = cz << 4;
|
final int bz = cz << 4;
|
||||||
RegionWrapper region = new RegionWrapper(bx, bx + 15, bz, bz + 15);
|
RegionWrapper region = new RegionWrapper(bx, bx + 15, bz, bz + 15);
|
||||||
@ -35,7 +44,6 @@ public class AugmentedUtils {
|
|||||||
}
|
}
|
||||||
final PseudoRandom r = new PseudoRandom();
|
final PseudoRandom r = new PseudoRandom();
|
||||||
r.state = (cx << 16) | (cz & 0xFFFF);;
|
r.state = (cx << 16) | (cz & 0xFFFF);;
|
||||||
PlotChunk<?> cache_chunk = null;
|
|
||||||
ChunkWrapper wrap = SetQueue.IMP.new ChunkWrapper(world, cx, cz);
|
ChunkWrapper wrap = SetQueue.IMP.new ChunkWrapper(world, cx, cz);
|
||||||
for (final PlotArea area : areas) {
|
for (final PlotArea area : areas) {
|
||||||
if (area.TYPE == 0) {
|
if (area.TYPE == 0) {
|
||||||
@ -48,10 +56,7 @@ public class AugmentedUtils {
|
|||||||
if (generator == null) {
|
if (generator == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cache_chunk == null) {
|
final PlotChunk<?> result = lazyChunk.getOrCreate();
|
||||||
cache_chunk = SetQueue.IMP.queue.getChunk(wrap);
|
|
||||||
}
|
|
||||||
final PlotChunk<?> result = cache_chunk;
|
|
||||||
final PlotChunk<?> primaryMask;
|
final PlotChunk<?> primaryMask;
|
||||||
// coords
|
// coords
|
||||||
int bxx = Math.max(0, area.getRegion().minX - bx);
|
int bxx = Math.max(0, area.getRegion().minX - bx);
|
||||||
@ -154,9 +159,9 @@ public class AugmentedUtils {
|
|||||||
}
|
}
|
||||||
generator.generateChunk(secondaryMask, area, r);
|
generator.generateChunk(secondaryMask, area, r);
|
||||||
}
|
}
|
||||||
if (cache_chunk != null) {
|
if (lazyChunk.get() != null) {
|
||||||
cache_chunk.addToQueue();
|
lazyChunk.get().addToQueue();
|
||||||
cache_chunk.flush(false);
|
lazyChunk.get().flush(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,8 @@ public abstract class IndependentPlotGenerator {
|
|||||||
* @param <T>
|
* @param <T>
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public <T> GeneratorWrapper<T> specify(String world) {
|
public <T> GeneratorWrapper<T> specify() {
|
||||||
return (GeneratorWrapper<T>) PS.get().IMP.wrapPlotGenerator(world, this);
|
return (GeneratorWrapper<T>) PS.get().IMP.wrapPlotGenerator(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,9 +5,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.commands.RequiredType;
|
import com.intellectualcrafters.plot.commands.RequiredType;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
|
||||||
import com.intellectualcrafters.plot.util.PlotGamemode;
|
import com.intellectualcrafters.plot.util.PlotGamemode;
|
||||||
import com.intellectualcrafters.plot.util.PlotWeather;
|
import com.intellectualcrafters.plot.util.PlotWeather;
|
||||||
|
|
||||||
@ -75,11 +73,6 @@ public class ConsolePlayer extends PlotPlayer {
|
|||||||
PS.log(message);
|
PS.log(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendMessage(final C c, final String... args) {
|
|
||||||
MainUtil.sendMessage(this, c, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void teleport(final Location loc) {
|
public void teleport(final Location loc) {
|
||||||
final Plot plot = loc.getPlot();
|
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() {
|
public void populatePersistentMetaMap() {
|
||||||
DBFunc.dbManager.getPersistentMeta(this, new RunnableVal<Map<String, byte[]>>() {
|
DBFunc.dbManager.getPersistentMeta(getUUID(), new RunnableVal<Map<String, byte[]>>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Map<String, byte[]> value) {
|
public void run(Map<String, byte[]> value) {
|
||||||
PlotPlayer.this.metaMap = value;
|
PlotPlayer.this.metaMap = value;
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
package com.intellectualcrafters.plot.util;
|
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.PS;
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
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.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
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 abstract class ChunkManager {
|
||||||
|
|
||||||
public static ChunkManager manager = null;
|
public static ChunkManager manager = null;
|
||||||
@ -206,11 +206,11 @@ public abstract class ChunkManager {
|
|||||||
|
|
||||||
public abstract void regenerateChunk(final String world, final ChunkLoc loc);
|
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);
|
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() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -222,9 +222,7 @@ public abstract class ChunkManager {
|
|||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (whenDone != null) {
|
TaskManager.runTask(whenDone);
|
||||||
whenDone.run();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,11 @@ public abstract class EconHandler {
|
|||||||
if (ConsolePlayer.isConsole(player)) {
|
if (ConsolePlayer.isConsole(player)) {
|
||||||
return Double.MAX_VALUE;
|
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 withdrawMoney(final PlotPlayer player, final double amount);
|
||||||
|
|
||||||
public abstract void depositMoney(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.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@ -525,14 +526,11 @@ public class MainUtil {
|
|||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String msg = c.s();
|
String m = C.format(c, args);
|
||||||
if (args.length != 0) {
|
if (plr == null) {
|
||||||
msg = C.format(c, args);
|
ConsolePlayer.getConsole().sendMessage(m);
|
||||||
}
|
|
||||||
if (plr != null) {
|
|
||||||
plr.sendMessage(c.usePrefix() ? C.PREFIX.s() + msg : msg);
|
|
||||||
} else {
|
} else {
|
||||||
ConsolePlayer.getConsole().sendMessage((c.usePrefix() ? C.PREFIX.s() : "") + msg);
|
plr.sendMessage(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -712,4 +710,18 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
return list.toString();
|
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;
|
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.google.common.collect.BiMap;
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
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.object.StringWrapper;
|
||||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class UUIDHandler {
|
public class UUIDHandler {
|
||||||
|
|
||||||
public static UUIDHandlerImplementation implementation;
|
public static UUIDHandlerImplementation implementation;
|
||||||
@ -107,6 +107,13 @@ public class UUIDHandler {
|
|||||||
return implementation.getPlayer(name);
|
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) {
|
public static UUID getUUID(final String name, final RunnableVal<UUID> ifFetch) {
|
||||||
return implementation.getUUID(name, ifFetch);
|
return implementation.getUUID(name, ifFetch);
|
||||||
}
|
}
|
||||||
|
@ -375,9 +375,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerInventoryEvents() {
|
public void registerInventoryEvents() {
|
||||||
|
|
||||||
// Part of PlayerEvents - can be moved if necessary
|
// Part of PlayerEvents - can be moved if necessary
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -486,7 +484,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
}
|
}
|
||||||
return new BukkitPlotGenerator(world, gen);
|
return new BukkitPlotGenerator(world, gen);
|
||||||
} else {
|
} 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) {
|
} else if (obj instanceof String) {
|
||||||
return UUIDHandler.getPlayer((String) obj);
|
return UUIDHandler.getPlayer((String) obj);
|
||||||
} else if (obj instanceof UUID) {
|
} else if (obj instanceof UUID) {
|
||||||
PlotPlayer player = UUIDHandler.getPlayer((UUID) obj);
|
return UUIDHandler.getPlayer((UUID) obj);
|
||||||
if (player == null) {
|
|
||||||
return BukkitUtil.getPlayer(Bukkit.getOfflinePlayer((UUID) obj));
|
|
||||||
}
|
|
||||||
return player;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -697,7 +691,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GeneratorWrapper<?> wrapPlotGenerator(String world, IndependentPlotGenerator generator) {
|
public GeneratorWrapper<?> wrapPlotGenerator(String world, IndependentPlotGenerator generator) {
|
||||||
return new BukkitPlotGenerator(world, generator);
|
return new BukkitPlotGenerator(generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -371,7 +371,7 @@ public class LikePlotMeConverter {
|
|||||||
// Load using Bukkit API
|
// Load using Bukkit API
|
||||||
// - User must set generator manually
|
// - User must set generator manually
|
||||||
Bukkit.getServer().unloadWorld(world, true);
|
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();
|
myworld.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class BukkitAugmentedGenerator extends BlockPopulator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void populate(World world, Random r, Chunk chunk) {
|
public void populate(final World world, Random r, final Chunk chunk) {
|
||||||
AugmentedUtils.generate(world.getName(), chunk.getX(), chunk.getZ());
|
AugmentedUtils.generate(world.getName(), chunk.getX(), chunk.getZ(), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,17 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.plotsquared.bukkit.generator;
|
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.PS;
|
||||||
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
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.listeners.WorldEvents;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.plotsquared.bukkit.util.block.GenChunk;
|
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> {
|
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 IndependentPlotGenerator plotGenerator;
|
||||||
private final List<BlockPopulator> populators = new ArrayList<>();
|
private final List<BlockPopulator> populators = new ArrayList<>();
|
||||||
private boolean loaded = false;
|
private boolean loaded = false;
|
||||||
private PlotManager manager;
|
|
||||||
private ChunkGenerator platformGenerator;
|
private ChunkGenerator platformGenerator;
|
||||||
private boolean full;
|
private boolean full;
|
||||||
|
|
||||||
public BukkitPlotGenerator(final String world, IndependentPlotGenerator generator) {
|
public BukkitPlotGenerator(IndependentPlotGenerator generator) {
|
||||||
WorldEvents.lastWorld = world;
|
|
||||||
this.plotGenerator = generator;
|
this.plotGenerator = generator;
|
||||||
this.platformGenerator = this;
|
this.platformGenerator = this;
|
||||||
populators.add(new BlockPopulator() {
|
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;
|
this.full = true;
|
||||||
MainUtil.initCache();
|
MainUtil.initCache();
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,7 @@
|
|||||||
package com.plotsquared.bukkit.object;
|
package com.plotsquared.bukkit.object;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import java.util.UUID;
|
||||||
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 org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -18,7 +11,14 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
|||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
import org.bukkit.plugin.PluginManager;
|
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 {
|
public class BukkitPlayer extends PlotPlayer {
|
||||||
|
|
||||||
@ -101,11 +101,6 @@ public class BukkitPlayer extends PlotPlayer {
|
|||||||
player.sendMessage(message);
|
player.sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendMessage(final C c, final String... args) {
|
|
||||||
MainUtil.sendMessage(this, c, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void teleport(final Location loc) {
|
public void teleport(final Location loc) {
|
||||||
if (Math.abs(loc.getX()) >= 30000000 || Math.abs(loc.getZ()) >= 30000000) {
|
if (Math.abs(loc.getX()) >= 30000000 || Math.abs(loc.getZ()) >= 30000000) {
|
||||||
@ -145,7 +140,6 @@ public class BukkitPlayer extends PlotPlayer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getAttribute(String key) {
|
public boolean getAttribute(String key) {
|
||||||
|
|
||||||
if (!hasPersistentMeta(key)) {
|
if (!hasPersistentMeta(key)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
package com.plotsquared.bukkit.util;
|
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.OfflinePlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.EconHandler;
|
import com.intellectualcrafters.plot.util.EconHandler;
|
||||||
import com.plotsquared.bukkit.object.BukkitOfflinePlayer;
|
import com.plotsquared.bukkit.object.BukkitOfflinePlayer;
|
||||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
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 {
|
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) {
|
public boolean hasPermission(final String world, final String player, final String perm) {
|
||||||
return perms.playerHas(world, Bukkit.getOfflinePlayer(player), 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;
|
package com.plotsquared.general.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.commands.RequiredType;
|
import com.intellectualcrafters.plot.commands.RequiredType;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
|
||||||
|
|
||||||
public interface CommandCaller {
|
public interface CommandCaller {
|
||||||
void sendMessage(final String message);
|
void sendMessage(final String message);
|
||||||
|
|
||||||
void sendMessage(final C c, final String... args);
|
|
||||||
|
|
||||||
boolean hasPermission(final String perm);
|
boolean hasPermission(final String perm);
|
||||||
|
|
||||||
RequiredType getSuperCaller();
|
RequiredType getSuperCaller();
|
||||||
|
Loading…
Reference in New Issue
Block a user