Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/com/intellectualcrafters/plot/commands/Condense.java
#	src/main/java/com/intellectualcrafters/plot/commands/Deny.java
#	src/main/java/com/intellectualcrafters/plot/commands/Save.java
#	src/main/java/com/intellectualcrafters/plot/commands/list.java
#	src/main/java/com/intellectualcrafters/plot/database/SQLManager.java
This commit is contained in:
Jesse Boyd 2016-02-13 04:32:43 +11:00
commit 03aec43f5d
38 changed files with 517 additions and 638 deletions

1
.gitignore vendored
View File

@ -127,3 +127,4 @@ local.properties
# STS (Spring Tool Suite)
.springBeans
/target/

View File

@ -1,5 +1,7 @@
package com.intellectualcrafters.configuration.serialization;
import com.intellectualcrafters.configuration.Configuration;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@ -9,8 +11,6 @@ import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.intellectualcrafters.configuration.Configuration;
/**
* Utility class for storing and retrieving classes for {@link Configuration}.
*/
@ -86,16 +86,12 @@ public class ConfigurationSerialization {
throw new NullPointerException("Args must not be null");
}
ConfigurationSerializable result = null;
Method method = null;
if (result == null) {
method = getMethod("deserialize", true);
if (method != null) {
result = deserializeViaMethod(method, args);
}
Method method = getMethod("deserialize", true);
if (method != null) {
result = deserializeViaMethod(method, args);
}
if (result == null) {
method = getMethod("valueOf", true);
@ -247,15 +243,13 @@ public class ConfigurationSerialization {
return getAlias(delegate.value());
}
}
if (delegate == null) {
final SerializableAs alias = clazz.getAnnotation(SerializableAs.class);
if ((alias != null) && (alias.value() != null)) {
return alias.value();
}
final SerializableAs alias = clazz.getAnnotation(SerializableAs.class);
if ((alias != null) && (alias.value() != null)) {
return alias.value();
}
return clazz.getName();
}
}

View File

@ -1,33 +1,5 @@
package com.intellectualcrafters.plot;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.configuration.MemorySection;
import com.intellectualcrafters.configuration.file.YamlConfiguration;
@ -84,6 +56,34 @@ import com.intellectualcrafters.plot.util.area.QuadMap;
import com.plotsquared.listener.WESubscriber;
import com.sk89q.worldedit.WorldEdit;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
/**
* An implementation of the core,
* with a static getter for easy access
@ -407,7 +407,7 @@ public class PS {
* @param plot Plot Object to update
*/
public boolean updatePlot(final Plot plot) {
return plot.area.addPlot(plot);
return plot.getArea().addPlot(plot);
}
/**
@ -595,7 +595,7 @@ public class PS {
}
public PlotManager getPlotManager(Plot plot) {
return plot.area.manager;
return plot.getArea().manager;
}
public PlotManager getPlotManager(Location loc) {
@ -1159,10 +1159,10 @@ public class PS {
Collection<Plot> lastList = null;
PlotArea lastWorld = null;
for (final Plot plot : myplots) {
if (lastWorld == plot.area) {
if (lastWorld == plot.getArea()) {
lastList.add(plot);
} else {
lastWorld = plot.area;
lastWorld = plot.getArea();
lastList = map.get(lastWorld);
lastList.add(plot);
}
@ -1418,12 +1418,12 @@ public class PS {
if (callEvent) {
EventUtil.manager.callDelete(plot);
}
if (plot.area.removePlot(plot.id)) {
PlotId last = (PlotId) plot.area.getMeta("lastPlot");
if (plot.getArea().removePlot(plot.getId())) {
PlotId last = (PlotId) plot.getArea().getMeta("lastPlot");
final int last_max = Math.max(Math.abs(last.x), Math.abs(last.y));
final int this_max = Math.max(Math.abs(plot.id.x), Math.abs(plot.id.y));
final int this_max = Math.max(Math.abs(plot.getId().x), Math.abs(plot.getId().y));
if (this_max < last_max) {
plot.area.setMeta("lastPlot", plot.id);
plot.getArea().setMeta("lastPlot", plot.getId());
}
return true;
}

View File

@ -54,7 +54,7 @@ public class Alias extends SetCommand {
C.NOT_VALID_VALUE.send(plr);
return false;
}
for (final Plot p : PS.get().getPlots(plot.area)) {
for (final Plot p : PS.get().getPlots(plot.getArea())) {
if (p.getAlias().equalsIgnoreCase(alias)) {
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
return false;

View File

@ -190,7 +190,7 @@ public class Auto extends SubCommand {
Claim.claimPlot(plr, plot, true, true);
br = true;
}
plotarea.setMeta("lastPlot", getNextPlotId(plot.id, 1));
plotarea.setMeta("lastPlot", getNextPlotId(plot.getId(), 1));
}
} else {
while (!br) {

View File

@ -146,7 +146,7 @@ public class Condense extends SubCommand {
final Plot origin = allPlots.remove(0);
int i = 0;
while (free.size() > i) {
final Plot possible = origin.area.getPlotAbs(free.get(i));
final Plot possible = origin.getArea().getPlotAbs(free.get(i));
if (possible.owner != null) {
free.remove(i);
continue;

View File

@ -20,26 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
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;
import java.util.List;
import java.util.UUID;
import javax.script.Bindings;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import javax.script.SimpleScriptContext;
import com.google.common.io.Files;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
@ -74,6 +54,26 @@ import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.Command;
import com.plotsquared.general.commands.CommandDeclaration;
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;
import java.util.List;
import java.util.UUID;
import javax.script.Bindings;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import javax.script.SimpleScriptContext;
@CommandDeclaration(command = "debugexec", permission = "plots.admin", description = "Mutli-purpose debug command", aliases = { "exec" }, category = CommandCategory.DEBUG)
public class DebugExec extends SubCommand {
@ -289,7 +289,7 @@ public class DebugExec extends SubCommand {
MainUtil.sendMessage(player, "Expired plots (" + ExpireManager.expiredPlots.get(args[1]).size() + "):");
for (final Plot plot : ExpireManager.expiredPlots.get(args[1])) {
MainUtil.sendMessage(player,
" - " + plot.area + ";" + plot.getId().x + ";" + plot.getId().y + ";" + UUIDHandler.getName(plot.owner) + " : " + ExpireManager.dates.get(plot.owner));
" - " + plot.getArea() + ";" + plot.getId().x + ";" + plot.getId().y + ";" + UUIDHandler.getName(plot.owner) + " : " + ExpireManager.dates.get(plot.owner));
}
return true;
}

View File

@ -50,7 +50,7 @@ public class Deny extends SubCommand {
if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT);
}
if ((plot == null) || !plot.hasOwner()) {
if (!plot.hasOwner()) {
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
return false;
}

View File

@ -20,13 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.ConsolePlayer;
@ -45,6 +38,13 @@ import com.plotsquared.general.commands.Command;
import com.plotsquared.general.commands.CommandHandlingOutput;
import com.plotsquared.general.commands.CommandManager;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
/**
* PlotSquared command class
*
@ -278,7 +278,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
if (newPlot == null) {
break;
}
if (!ConsolePlayer.isConsole(player) && (!newPlot.area.equals(area) || newPlot.isDenied(player.getUUID())) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN)) {
if (!ConsolePlayer.isConsole(player) && (!newPlot.getArea().equals(area) || newPlot.isDenied(player.getUUID())) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN)) {
break;
}
// Save meta

View File

@ -62,7 +62,7 @@ public class Move extends SubCommand {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
return false;
}
if (!plot1.area.isCompatible(plot2.area)) {
if (!plot1.getArea().isCompatible(plot2.getArea())) {
C.PLOTWORLD_INCOMPATIBLE.send(plr);
return false;
}

View File

@ -20,9 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.HashSet;
import java.util.UUID;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.Plot;
@ -32,6 +29,9 @@ import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.HashSet;
import java.util.UUID;
@CommandDeclaration(
command = "setowner",
permission = "plots.set.owner",
@ -82,7 +82,7 @@ public class Owner extends SetCommand {
return false;
}
final int size = plots.size();
final int currentPlots = (Settings.GLOBAL_LIMIT ? other.getPlotCount() : other.getPlotCount(plot.area.worldname)) + size;
final int currentPlots = (Settings.GLOBAL_LIMIT ? other.getPlotCount() : other.getPlotCount(plot.getArea().worldname)) + size;
if (currentPlots > other.getAllowedPlots()) {
sendMessage(plr, C.CANT_TRANSFER_MORE_PLOTS);
return false;
@ -93,7 +93,7 @@ public class Owner extends SetCommand {
plot.setSign(name);
MainUtil.sendMessage(plr, C.SET_OWNER);
if (other != null) {
MainUtil.sendMessage(other, C.NOW_OWNER, plot.area + ";" + plot.getId());
MainUtil.sendMessage(other, C.NOW_OWNER, plot.getArea() + ";" + plot.getId());
}
return true;
}

View File

@ -20,12 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc;
@ -38,6 +32,12 @@ import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
@CommandDeclaration(
usage = "/plot purge world:<world> area:<area> id:<id> owner:<owner> shared:<shared> unknown:[true|false]",
command = "purge",
@ -117,13 +117,13 @@ public class Purge extends SubCommand {
final HashSet<Integer> toDelete = new HashSet<>();
Set<Plot> basePlots = PS.get().getBasePlots();
for (Plot plot : PS.get().getBasePlots()) {
if (world != null && !plot.area.worldname.equalsIgnoreCase(world)) {
if (world != null && !plot.getArea().worldname.equalsIgnoreCase(world)) {
continue;
}
if (area != null && !plot.area.equals(area)) {
if (area != null && !plot.getArea().equals(area)) {
continue;
}
if (id != null && !plot.id.equals(id)) {
if (id != null && !plot.getId().equals(id)) {
continue;
}
if (owner != null && !plot.isOwner(owner)) {
@ -150,7 +150,7 @@ public class Purge extends SubCommand {
}
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
Plot plot = entry2.getValue();
if (id != null && !plot.id.equals(id)) {
if (id != null && !plot.getId().equals(id)) {
continue;
}
if (owner != null && !plot.isOwner(owner)) {

View File

@ -61,7 +61,7 @@ public class Save extends SubCommand {
Location[] corners = plot.getCorners();
final int size = (corners[1].getX() - corners[0].getX()) + 1;
final PlotId id = plot.getId();
final String world = plot.area.toString().replaceAll(";", "-").replaceAll("[^A-Za-z0-9]", "");
final String world = plot.getArea().toString().replaceAll(";", "-").replaceAll("[^A-Za-z0-9]", "");
final String file = time + "_" + world + "_" + id.x + "_" + id.y + "_" + size + "_" + name;
final UUID uuid = plr.getUUID();

View File

@ -55,7 +55,7 @@ public class Swap extends SubCommand {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
return false;
}
if (!plot1.area.isCompatible(plot2.area)) {
if (!plot1.getArea().isCompatible(plot2.getArea())) {
C.PLOTWORLD_INCOMPATIBLE.send(plr);
return false;
}

View File

@ -100,7 +100,7 @@ public class list extends SubCommand {
}
public void noArgs(final PlotPlayer plr) {
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(getArgumentList(plr)));
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(plr));
}
@Override
@ -388,8 +388,9 @@ public class list extends SubCommand {
strFlags = C.NONE.s();
}
final PlotMessage flags = new PlotMessage().text(C.color(C.PLOT_INFO_FLAGS.s().replaceAll("%flags%", strFlags))).color("$1");
message.text("[").color("$3").text(i + "").command("/plot visit " + plot.area + ";" + plot.getId()).tooltip("/plot visit " + plot.area + ";" + plot.getId()).color("$1").text("]")
.color("$3").text(" " + plot.toString()).tooltip(trusted, members, flags).command("/plot info " + plot.area + ";" + plot.getId()).color(color).text(" - ").color("$2");
message.text("[").color("$3").text(i + "").command("/plot visit " + plot.getArea() + ";" + plot.getId()).tooltip("/plot visit " + plot.getArea() + ";" + plot.getId()).color("$1")
.text("]")
.color("$3").text(" " + plot.toString()).tooltip(trusted, members, flags).command("/plot info " + plot.getArea() + ";" + plot.getId()).color(color).text(" - ").color("$2");
String prefix = "";
for (final UUID uuid : plot.getOwners()) {
final String name = UUIDHandler.getName(uuid);

View File

@ -471,7 +471,7 @@ public class SQLManager implements AbstractDB {
statement.setString(1, uuid.toString());
statement.setInt(2, plot.getId().x);
statement.setInt(3, plot.getId().y);
statement.setString(4, plot.area.toString());
statement.setString(4, plot.getArea().toString());
}
@Override
@ -657,7 +657,7 @@ public class SQLManager implements AbstractDB {
} catch (final Exception e) {
stmt.setString((i * 5) + 3, everyone.toString());
}
stmt.setString((i * 5) + 4, plot.area.toString());
stmt.setString((i * 5) + 4, plot.getArea().toString());
stmt.setTimestamp((i * 5) + 5, new Timestamp(plot.getTimestamp()));
}
@ -671,7 +671,7 @@ public class SQLManager implements AbstractDB {
} catch (final Exception e1) {
stmt.setString((i * 6) + 4, everyone.toString());
}
stmt.setString((i * 6) + 5, plot.area.toString());
stmt.setString((i * 6) + 5, plot.getArea().toString());
stmt.setTimestamp((i * 6) + 6, new Timestamp(plot.getTimestamp()));
}
@ -680,7 +680,7 @@ public class SQLManager implements AbstractDB {
stmt.setInt(1, plot.getId().x);
stmt.setInt(2, plot.getId().y);
stmt.setString(3, plot.owner.toString());
stmt.setString(4, plot.area.toString());
stmt.setString(4, plot.getArea().toString());
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
}
@ -994,7 +994,7 @@ public class SQLManager implements AbstractDB {
stmt.setInt(1, plot.getId().x);
stmt.setInt(2, plot.getId().y);
stmt.setString(3, plot.owner.toString());
stmt.setString(4, plot.area.toString());
stmt.setString(4, plot.getArea().toString());
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
}
@ -1027,7 +1027,7 @@ public class SQLManager implements AbstractDB {
stmt.setInt(1, plot.getId().x);
stmt.setInt(2, plot.getId().y);
stmt.setString(3, plot.owner.toString());
stmt.setString(4, plot.area.toString());
stmt.setString(4, plot.getArea().toString());
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
}
@ -1363,7 +1363,7 @@ public class SQLManager implements AbstractDB {
addPlotTask(plot, new UniqueStatement("delete_plot_comments") {
@Override
public void set(final PreparedStatement stmt) throws SQLException {
stmt.setString(1, plot.area.toString());
stmt.setString(1, plot.getArea().toString());
stmt.setInt(2, plot.hashCode());
}
@ -1493,7 +1493,7 @@ public class SQLManager implements AbstractDB {
stmt = connection.prepareStatement("SELECT `id` FROM `" + prefix + "plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC");
stmt.setInt(1, plot.getId().x);
stmt.setInt(2, plot.getId().y);
stmt.setString(3, plot.area.toString());
stmt.setString(3, plot.getArea().toString());
final ResultSet r = stmt.executeQuery();
int id = Integer.MAX_VALUE;
while (r.next()) {
@ -1711,9 +1711,9 @@ public class SQLManager implements AbstractDB {
p = new Plot(plot_id, user, new HashSet<UUID>(), new HashSet<UUID>(), new HashSet<UUID>(), "", null, null, null, new boolean[] { false, false, false, false }, time, id);
HashMap<PlotId, Plot> map = newplots.get(areaid);
if (map != null) {
Plot last = map.put(p.id, p);
Plot last = map.put(p.getId(), p);
if (last != null) {
map.put(last.id, last);
map.put(last.getId(), last);
if (Settings.AUTO_PURGE) {
toDelete.add(id);
} else {
@ -1724,7 +1724,7 @@ public class SQLManager implements AbstractDB {
} else {
map = new HashMap<PlotId, Plot>();
newplots.put(areaid, map);
map.put(p.id, p);
map.put(p.getId(), p);
}
plots.put(id, p);
}
@ -1991,7 +1991,7 @@ public class SQLManager implements AbstractDB {
public void set(final PreparedStatement stmt) throws SQLException {
stmt.setInt(1, newPlot.getId().x);
stmt.setInt(2, newPlot.getId().y);
stmt.setString(3, newPlot.area.toString());
stmt.setString(3, newPlot.getArea().toString());
stmt.setInt(4, getId(original));
}
@ -2149,7 +2149,7 @@ public class SQLManager implements AbstractDB {
@Override
public void set(final PreparedStatement statement) throws SQLException {
if (plot != null) {
statement.setString(1, plot.area.toString());
statement.setString(1, plot.getArea().toString());
statement.setInt(2, plot.getId().hashCode());
statement.setString(3, comment.comment);
statement.setString(4, comment.inbox);
@ -2177,7 +2177,7 @@ public class SQLManager implements AbstractDB {
@Override
public void set(final PreparedStatement statement) throws SQLException {
if (plot != null) {
statement.setString(1, plot.area.toString());
statement.setString(1, plot.getArea().toString());
statement.setInt(2, plot.getId().hashCode());
statement.setString(3, inbox);
} else {
@ -2201,7 +2201,7 @@ public class SQLManager implements AbstractDB {
@Override
public void set(final PreparedStatement statement) throws SQLException {
if (plot != null) {
statement.setString(1, plot.area.toString());
statement.setString(1, plot.getArea().toString());
statement.setInt(2, plot.getId().hashCode());
statement.setString(3, inbox);
} else {
@ -2251,7 +2251,7 @@ public class SQLManager implements AbstractDB {
addPlotTask(plot, new UniqueStatement("setComment") {
@Override
public void set(final PreparedStatement statement) throws SQLException {
statement.setString(1, plot.area.toString());
statement.setString(1, plot.getArea().toString());
statement.setInt(2, plot.getId().hashCode());
statement.setString(3, comment.comment);
statement.setString(4, comment.inbox);
@ -2989,7 +2989,7 @@ public class SQLManager implements AbstractDB {
if (plot.temp == -1) {
continue;
}
final HashMap<PlotId, Plot> worldplots = database.get(plot.area.toString());
final HashMap<PlotId, Plot> worldplots = database.get(plot.getArea().toString());
if (worldplots == null) {
PS.debug("&8 - &7Creating plot (1): " + plot);
toCreate.add(plot);

View File

@ -20,13 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
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;
@ -39,6 +32,13 @@ 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
*
@ -173,7 +173,7 @@ public class FlagManager {
if (plot.owner == null) {
return null;
}
return getSettingFlag(plot.area, plot.getSettings(), flag);
return getSettingFlag(plot.getArea(), plot.getSettings(), flag);
}
public static boolean isPlotFlagTrue(final Plot plot, final String strFlag) {
@ -255,7 +255,7 @@ public class FlagManager {
if (!plot.hasOwner()) {
return null;
}
return getSettingFlags(plot.area, plot.getSettings());
return getSettingFlags(plot.getArea(), plot.getSettings());
}
public static HashMap<String, Flag> getPlotFlags(PlotArea area, final PlotSettings settings, final boolean ignorePluginflags) {

View File

@ -1,17 +1,5 @@
package com.intellectualcrafters.plot.generator;
import java.io.File;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
@ -33,6 +21,18 @@ import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.TaskManager;
import java.io.File;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
public abstract class HybridUtils {
public static HybridUtils manager;
@ -93,7 +93,7 @@ public abstract class HybridUtils {
}
RegionWrapper region = zones.poll();
final Runnable task = this;
analyzeRegion(origin.area.worldname, region, new RunnableVal<PlotAnalysis>() {
analyzeRegion(origin.getArea().worldname, region, new RunnableVal<PlotAnalysis>() {
@Override
public void run(PlotAnalysis value) {
analysis.add(value);
@ -151,20 +151,21 @@ public abstract class HybridUtils {
return;
}
RegionWrapper region = zones.poll();
Location pos1 = new Location(plot.area.worldname, region.minX, region.minY, region.minZ);
Location pos2 = new Location(plot.area.worldname, region.maxX, region.maxY, region.maxZ);
Location pos1 = new Location(plot.getArea().worldname, region.minX, region.minY, region.minZ);
Location pos2 = new Location(plot.getArea().worldname, region.maxX, region.maxY, region.maxZ);
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
@Override
public void run(int[] value) {
final ChunkLoc loc = new ChunkLoc(value[0], value[1]);
ChunkManager.manager.loadChunk(plot.area.worldname, loc, false);
ChunkManager.manager.loadChunk(plot.getArea().worldname, loc, false);
final int bx = value[2];
final int bz = value[3];
final int ex = value[4];
final int ez = value[5];
whenDone.value += checkModified(plot.area.worldname, bx, ex, 1, cpw.PLOT_HEIGHT - 1, bz, ez, cpw.MAIN_BLOCK);
whenDone.value += checkModified(plot.area.worldname, bx, ex, cpw.PLOT_HEIGHT, cpw.PLOT_HEIGHT, bz, ez, cpw.TOP_BLOCK);
whenDone.value += checkModified(plot.area.worldname, bx, ex, cpw.PLOT_HEIGHT + 1, 255, bz, ez, new PlotBlock[] { new PlotBlock((short) 0, (byte) 0) });
whenDone.value += checkModified(plot.getArea().worldname, bx, ex, 1, cpw.PLOT_HEIGHT - 1, bz, ez, cpw.MAIN_BLOCK);
whenDone.value += checkModified(plot.getArea().worldname, bx, ex, cpw.PLOT_HEIGHT, cpw.PLOT_HEIGHT, bz, ez, cpw.TOP_BLOCK);
whenDone.value += checkModified(
plot.getArea().worldname, bx, ex, cpw.PLOT_HEIGHT + 1, 255, bz, ez, new PlotBlock[] { new PlotBlock((short) 0, (byte) 0) });
}
}, this, 5);
@ -296,10 +297,10 @@ public abstract class HybridUtils {
}
public boolean setupRoadSchematic(final Plot plot) {
final String world = plot.area.worldname;
final String world = plot.getArea().worldname;
final Location bot = plot.getBottomAbs().subtract(1, 0, 1);
final Location top = plot.getTopAbs();
final HybridPlotWorld plotworld = (HybridPlotWorld) plot.area;
final HybridPlotWorld plotworld = (HybridPlotWorld) plot.getArea();
final int sx = (bot.getX() - plotworld.ROAD_WIDTH) + 1;
final int sz = bot.getZ() + 1;
final int sy = plotworld.ROAD_HEIGHT;
@ -313,7 +314,8 @@ public abstract class HybridUtils {
final Set<RegionWrapper> sideroad = new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ey, sz, ez)));
final Set<RegionWrapper> intersection = new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ty, bz, tz)));
final String dir = PS.get().IMP.getDirectory() + File.separator + "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot.area.toString() + File.separator;
final String dir = PS.get().IMP.getDirectory() + File.separator + "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot
.getArea().toString() + File.separator;
SchematicHandler.manager.getCompoundTag(world, sideroad, new RunnableVal<CompoundTag>() {
@Override
public void run(CompoundTag value) {

View File

@ -1,9 +1,5 @@
package com.intellectualcrafters.plot.generator;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
@ -13,6 +9,10 @@ import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
/**
* A plot manager with a square grid layout, with square shaped plots
*/
@ -30,8 +30,8 @@ public abstract class SquarePlotManager extends GridPlotManager {
Iterator<RegionWrapper> iter = regions.iterator();
RegionWrapper region = iter.next();
iter.remove();
Location pos1 = new Location(plot.area.worldname, region.minX, region.minY, region.minZ);
Location pos2 = new Location(plot.area.worldname, region.maxX, region.maxY, region.maxZ);
Location pos1 = new Location(plot.getArea().worldname, region.minX, region.minY, region.minZ);
Location pos2 = new Location(plot.getArea().worldname, region.maxX, region.maxY, region.maxZ);
ChunkManager.manager.regenerateRegion(pos1, pos2, false, this);
}
};

View File

@ -20,22 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.object;
import java.io.File;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import com.google.common.collect.BiMap;
import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.plot.PS;
@ -57,6 +41,22 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.listener.PlotListener;
import java.io.File;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
/**
* The plot class
*/
@ -72,8 +72,7 @@ public class Plot {
* plot world
* Direct access is Deprecated: use getWorld()
*/
@Deprecated
public PlotArea area;
private PlotArea area;
/**
* plot owner
* (Merged plots can have multiple owners)
@ -304,7 +303,7 @@ public class Plot {
* @return the PlotCluster object, or null
*/
public PlotCluster getCluster() {
return area.getCluster(id);
return getArea().getCluster(id);
}
/**
@ -389,7 +388,7 @@ public class Plot {
}
public void setArea(PlotArea area) {
if (this.area != null) {
if (this.getArea() != null) {
this.area.removePlot(id);
}
this.area = area;

View File

@ -20,18 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.object;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
@ -50,6 +38,18 @@ import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.intellectualcrafters.plot.util.area.QuadMap;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author Jesse Boyd
*/
@ -517,7 +517,7 @@ public abstract class PlotArea {
if (plot == null) {
return null;
}
return clusters != null ? clusters.get(plot.id.x, plot.id.y) : null;
return clusters != null ? clusters.get(plot.getId().x, plot.getId().y) : null;
}
public PlotCluster getFirstIntersectingCluster(PlotId pos1, PlotId pos2) {
@ -607,11 +607,11 @@ public abstract class PlotArea {
for (PlotPlayer pp : plot.getPlayersInPlot()) {
pp.setMeta("lastplot", plot);
}
return plots.put(plot.id, plot) == null;
return plots.put(plot.getId(), plot) == null;
}
public boolean addPlotIfAbsent(Plot plot) {
if (plots.putIfAbsent(plot.id, plot) == null) {
if (plots.putIfAbsent(plot.getId(), plot) == null) {
for (PlotPlayer pp : plot.getPlayersInPlot()) {
pp.setMeta("lastplot", plot);
}
@ -621,12 +621,11 @@ public abstract class PlotArea {
}
public boolean addPlotAbs(Plot plot) {
return plots.put(plot.id, plot) == null;
return plots.put(plot.getId(), plot) == null;
}
/**
* Check if the plots in a selection are unowned
* @param world
* @param pos1
* @param pos2
* @return
@ -635,7 +634,7 @@ public abstract class PlotArea {
int area = (pos2.x - pos1.x + 1) * (pos2.y - pos1.y + 1);
if (area > getPlotCount()) {
for (Plot plot : getPlots()) {
if (plot.id.x >= pos1.x && plot.id.x <= pos2.x && plot.id.y >= pos1.y && plot.id.y <= pos2.y) {
if (plot.getId().x >= pos1.x && plot.getId().x <= pos2.x && plot.getId().y >= pos1.y && plot.getId().y <= pos2.y) {
return false;
}
}
@ -654,7 +653,6 @@ public abstract class PlotArea {
/**
* Get the plot border distance for a world<br>
* @param worldname
* @return The border distance or Integer.MAX_VALUE if no border is set
*/
public int getBorder() {
@ -672,7 +670,6 @@ public abstract class PlotArea {
/**
* Setup the plot border for a world (usually done when the world is created)
* @param world
*/
public void setupBorder() {
if (!WORLD_BORDER) {

View File

@ -1,14 +1,14 @@
package com.intellectualcrafters.plot.object;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.util.UUIDHandler;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.UUID;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.util.UUIDHandler;
public class PlotHandler {
public static HashSet<UUID> getOwners(final Plot plot) {
if (plot.owner == null) {
@ -238,7 +238,7 @@ public class PlotHandler {
return false;
}
for (Plot current : plot.getConnectedPlots()) {
plot.area.removePlot(plot.id);
plot.getArea().removePlot(plot.getId());
DBFunc.delete(current);
current.settings = null;
}

View File

@ -1,15 +1,5 @@
package com.intellectualcrafters.plot.util;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.flag.FlagManager;
@ -23,6 +13,16 @@ import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
public class BO3Handler {
/**
@ -51,7 +51,7 @@ public class BO3Handler {
* @return
*/
public static boolean saveBO3(final PlotPlayer plr, final Plot plot) {
final PlotArea plotworld = plot.area;
final PlotArea plotworld = plot.getArea();
if (!(plotworld instanceof ClassicPlotWorld) || (plotworld.TYPE != 0)) {
MainUtil.sendMessage(plr, "BO3 exporting only supports type 0 classic generation.");
return false;
@ -78,13 +78,13 @@ public class BO3Handler {
}
}
for (ChunkLoc loc : chunks) {
ChunkManager.manager.loadChunk(plot.area.worldname, loc, false);
ChunkManager.manager.loadChunk(plot.getArea().worldname, loc, false);
}
boolean content = false;
for (RegionWrapper region : regions) {
Location pos1 = new Location(plot.area.worldname, region.minX, region.minY, region.minZ);
Location pos2 = new Location(plot.area.worldname, region.maxX, region.maxY, region.maxZ);
Location pos1 = new Location(plot.getArea().worldname, region.minX, region.minY, region.minZ);
Location pos2 = new Location(plot.getArea().worldname, region.maxX, region.maxY, region.maxZ);
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
final int X = ((x + 7) - cx) >> 4;
final int xx = (x - cx) % 16;
@ -94,7 +94,7 @@ public class BO3Handler {
final ChunkLoc loc = new ChunkLoc(X, Z);
BO3 bo3 = map.get(loc);
for (int y = 1; y < height; y++) {
final PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.area.worldname, x, y, z));
final PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, y, z));
if ((block != null) && !contains(cpw.MAIN_BLOCK, block)) {
if (bo3 == null) {
bo3 = new BO3(alias, loc);
@ -104,7 +104,7 @@ public class BO3Handler {
bo3.addBlock(xx, y - height - 1, zz, block);
}
}
final PlotBlock floor = WorldUtil.IMP.getBlock(new Location(plot.area.worldname, x, height, z));
final PlotBlock floor = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, height, z));
if ((floor != null) && !contains(cpw.TOP_BLOCK, floor)) {
if (bo3 == null) {
bo3 = new BO3(alias, loc);
@ -114,7 +114,7 @@ public class BO3Handler {
bo3.addBlock(xx, -1, zz, floor);
}
for (int y = height + 1; y < 256; y++) {
final PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.area.worldname, x, y, z));
final PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, y, z));
if ((block != null) && (block.id != 0)) {
if (bo3 == null) {
bo3 = new BO3(alias, loc);
@ -172,7 +172,7 @@ public class BO3Handler {
}
public static boolean save(final Plot plot, final BO3 bo3) {
final File base = getBaseFile(plot.area.worldname);
final File base = getBaseFile(plot.getArea().worldname);
try {
final List<String> lines = Files.readAllLines(base.toPath(), StandardCharsets.UTF_8);
for (int i = 0; i < lines.size(); i++) {

View File

@ -1,10 +1,5 @@
package com.intellectualcrafters.plot.util;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.concurrent.atomic.AtomicInteger;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.Plot;
@ -16,6 +11,11 @@ import com.intellectualcrafters.plot.object.comment.InboxPublic;
import com.intellectualcrafters.plot.object.comment.InboxReport;
import com.intellectualcrafters.plot.object.comment.PlotComment;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
public class CommentManager {
public static HashMap<String, CommentInbox> inboxes = new HashMap<>();
@ -33,13 +33,13 @@ public class CommentManager {
final AtomicInteger count = new AtomicInteger(0);
final AtomicInteger size = new AtomicInteger(boxes.size());
for (final CommentInbox inbox : inboxes.values()) {
inbox.getComments(plot, new RunnableVal() {
inbox.getComments(plot, new RunnableVal<List<PlotComment>>() {
@Override
public void run(Object value) {
public void run(List<PlotComment> value) {
int total;
if (value != null) {
int num = 0;
for (final PlotComment comment : (ArrayList<PlotComment>) value) {
for (final PlotComment comment : value) {
if (comment.timestamp > getTimestamp(player, inbox.toString())) {
num++;
}

View File

@ -1,11 +1,5 @@
package com.intellectualcrafters.plot.util;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
@ -20,6 +14,12 @@ import com.intellectualcrafters.plot.object.PlotHandler;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
public class ExpireManager {
public static ConcurrentHashMap<String, List<Plot>> expiredPlots = new ConcurrentHashMap<>();
public static ConcurrentHashMap<String, Boolean> updatingPlots = new ConcurrentHashMap<>();
@ -123,7 +123,7 @@ public class ExpireManager {
final int complexity = changed == null ? 0 : changed.getComplexity();
final int modified = changed == null ? 0 : changed.changes;
PS.debug("$2[&5Expire&dManager$2] &cDeleted expired plot: " + plot + " : " + complexity + " - " + modified);
PS.debug("$4 - Area: " + plot.area);
PS.debug("$4 - Area: " + plot.getArea());
if (plot.hasOwner()) {
PS.debug("$4 - Owner: " + UUIDHandler.getName(plot.owner));
} else {

View File

@ -20,15 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.util;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.regex.Matcher;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
@ -47,6 +38,15 @@ import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.regex.Matcher;
/**
* plot functions
*
@ -216,10 +216,7 @@ public class MainUtil {
if (uuid == null) {
uuid = UUID.fromString(term);
}
if (uuid != null) {
uuids.add(uuid);
continue;
}
uuids.add(uuid);
} catch (final Exception e) {
id = PlotId.fromString(term);
if (id != null) {
@ -253,7 +250,7 @@ public class MainUtil {
count++;
}
}
if ((area != null) && plot.area.equals(area)) {
if ((area != null) && plot.getArea().equals(area)) {
count++;
}
if ((alias != null) && alias.equals(plot.getAlias())) {
@ -633,7 +630,7 @@ public class MainUtil {
final int num = plot.getConnectedPlots().size();
final String alias = plot.getAlias().length() > 0 ? plot.getAlias() : C.NONE.s();
final Location bot = plot.getCorners()[0];
final String biome = WorldUtil.IMP.getBiome(plot.area.worldname, bot.getX(), bot.getZ());
final String biome = WorldUtil.IMP.getBiome(plot.getArea().worldname, bot.getX(), bot.getZ());
final String trusted = getPlayerList(plot.getTrusted());
final String members = getPlayerList(plot.getMembers());
final String denied = getPlayerList(plot.getDenied());
@ -643,7 +640,9 @@ public class MainUtil {
final String flags = StringMan.replaceFromMap(
"$2"
+ (StringMan.join(FlagManager.getPlotFlags(plot.area, plot.getSettings(), true).values(), "").length() > 0 ? StringMan.join(FlagManager.getPlotFlags(plot.area, plot.getSettings(), true)
+ (StringMan.join(FlagManager.getPlotFlags(plot.getArea(), plot.getSettings(), true).values(), "").length() > 0 ? StringMan.join(FlagManager.getPlotFlags(
plot.getArea(), plot.getSettings(), true)
.values(), "$1, $2") : C.NONE.s()), C.replacements);
final boolean build = plot.isAdded(player.getUUID());

View File

@ -1,5 +1,28 @@
package com.intellectualcrafters.plot.util;
import com.google.common.collect.Lists;
import com.intellectualcrafters.jnbt.ByteArrayTag;
import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.jnbt.IntTag;
import com.intellectualcrafters.jnbt.ListTag;
import com.intellectualcrafters.jnbt.NBTInputStream;
import com.intellectualcrafters.jnbt.NBTOutputStream;
import com.intellectualcrafters.jnbt.ShortTag;
import com.intellectualcrafters.jnbt.StringTag;
import com.intellectualcrafters.jnbt.Tag;
import com.intellectualcrafters.json.JSONArray;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.generator.ClassicPlotWorld;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.schematic.PlotItem;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@ -29,29 +52,6 @@ import java.util.UUID;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import com.google.common.collect.Lists;
import com.intellectualcrafters.jnbt.ByteArrayTag;
import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.jnbt.IntTag;
import com.intellectualcrafters.jnbt.ListTag;
import com.intellectualcrafters.jnbt.NBTInputStream;
import com.intellectualcrafters.jnbt.NBTOutputStream;
import com.intellectualcrafters.jnbt.ShortTag;
import com.intellectualcrafters.jnbt.StringTag;
import com.intellectualcrafters.jnbt.Tag;
import com.intellectualcrafters.json.JSONArray;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.generator.ClassicPlotWorld;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.schematic.PlotItem;
public abstract class SchematicHandler {
public static SchematicHandler manager;
@ -83,10 +83,10 @@ public abstract class SchematicHandler {
}
final String name;
if (namingScheme == null) {
name = plot.getId().x + ";" + plot.getId().y + "," + plot.area + "," + o;
name = plot.getId().x + ";" + plot.getId().y + "," + plot.getArea() + "," + o;
} else {
name = namingScheme.replaceAll("%owner%", o).replaceAll("%id%", plot.getId().toString()).replaceAll("%idx%", plot.getId().x + "").replaceAll("%idy%", plot.getId().y + "")
.replaceAll("%world%", plot.area.toString());
.replaceAll("%world%", plot.getArea().toString());
}
final String directory;
if (outputDir == null) {
@ -170,14 +170,14 @@ public abstract class SchematicHandler {
if (HEIGHT >= 256) {
y_offset = 0;
} else {
PlotArea pw = plot.area;
PlotArea pw = plot.getArea();
if (pw instanceof ClassicPlotWorld) {
y_offset = ((ClassicPlotWorld) pw).PLOT_HEIGHT;
} else {
y_offset = MainUtil.getHeighestBlock(plot.area.worldname, region.minX + 1, region.minZ + 1);
y_offset = MainUtil.getHeighestBlock(plot.getArea().worldname, region.minX + 1, region.minZ + 1);
}
}
final Location pos1 = new Location(plot.area.worldname, region.minX + x_offset, y_offset, region.minZ + z_offset);
final Location pos1 = new Location(plot.getArea().worldname, region.minX + x_offset, y_offset, region.minZ + z_offset);
final Location pos2 = pos1.clone().add(WIDTH - 1, HEIGHT - 1, LENGTH - 1);
// TODO switch to ChunkManager.chunkTask(pos1, pos2, task, whenDone, allocate);
final int p1x = pos1.getX();
@ -306,11 +306,11 @@ public abstract class SchematicHandler {
case 190:
case 191:
case 192: {
SetQueue.IMP.setBlock(plot.area.worldname, xx, yy, zz, id);
SetQueue.IMP.setBlock(plot.getArea().worldname, xx, yy, zz, id);
break;
}
default: {
SetQueue.IMP.setBlock(plot.area.worldname, xx, yy, zz, new PlotBlock((short) id, datas[i]));
SetQueue.IMP.setBlock(plot.getArea().worldname, xx, yy, zz, new PlotBlock((short) id, datas[i]));
break;
}
}
@ -362,9 +362,9 @@ public abstract class SchematicHandler {
return false;
}
RegionWrapper region = plot.getLargestRegion();
Location l1 = new Location(plot.area.worldname, region.minX + x_offset, 1, region.minZ + z_offset);
Location l1 = new Location(plot.getArea().worldname, region.minX + x_offset, 1, region.minZ + z_offset);
// Location l1 = MainUtil.getPlotBottomLoc(plot.world, plot.getId());
final int sy = MainUtil.getHeighestBlock(plot.area.worldname, l1.getX() + 1, l1.getZ() + 1);
final int sy = MainUtil.getHeighestBlock(plot.getArea().worldname, l1.getX() + 1, l1.getZ() + 1);
final Dimension demensions = schematic.getSchematicDimension();
final int HEIGHT = demensions.getY();
if ((HEIGHT < 255)) {
@ -377,7 +377,7 @@ public abstract class SchematicHandler {
item.x += X;
item.y += Y;
item.z += Z;
WorldUtil.IMP.addItems(plot.area.worldname, item);
WorldUtil.IMP.addItems(plot.getArea().worldname, item);
}
return true;
}
@ -672,7 +672,7 @@ public abstract class SchematicHandler {
public abstract void getCompoundTag(final String world, Set<RegionWrapper> regions, final RunnableVal<CompoundTag> whenDone);
public void getCompoundTag(Plot plot, final RunnableVal<CompoundTag> whenDone) {
getCompoundTag(plot.area.worldname, plot.getRegions(), whenDone);
getCompoundTag(plot.getArea().worldname, plot.getRegions(), whenDone);
}
/**
@ -684,33 +684,10 @@ public abstract class SchematicHandler {
// Lossy but fast
private final short[] ids;
private final byte[] datas;
@Deprecated
private DataCollection[] collection;
private final Dimension schematicDimension;
private HashSet<PlotItem> items;
/**
* This is deprecated as having a wrapper for each block is slow.<br>
* - There's also a performance hit by having to cast the DataCollection short / byte
* -
* @param blockCollection
* @param schematicDimension
*/
@Deprecated
public Schematic(final DataCollection[] blockCollection, final Dimension schematicDimension) {
ids = new short[blockCollection.length];
datas = new byte[blockCollection.length];
for (int i = 0; i < blockCollection.length; i++) {
final DataCollection block = blockCollection[i];
ids[i] = (byte) block.block;
datas[i] = block.data;
}
collection = blockCollection;
this.schematicDimension = schematicDimension;
}
public Schematic(final short[] i, final byte[] b, final Dimension d) {
ids = i;
datas = b;
@ -759,22 +736,7 @@ public abstract class SchematicHandler {
public byte[] getDatas() {
return datas;
}
/**
* @deprecated as it is slow to wrap each block
* @return DataCollection of schematic blocks
*/
@Deprecated
public DataCollection[] getBlockCollection() {
if (collection == null) {
collection = new DataCollection[ids.length];
for (int i = 0; i < ids.length; i++) {
collection[i] = new DataCollection(ids[i], datas[i]);
}
}
return collection;
}
public Schematic copySection(RegionWrapper region) {
int x1 = region.minX;
@ -855,29 +817,5 @@ public abstract class SchematicHandler {
return z;
}
}
/**
* Schematic Data Collection
* @deprecated as it is slow to wrap each block
*/
@Deprecated
public class DataCollection {
private final short block;
private final byte data;
// public CompoundTag tag;
public DataCollection(final short block, final byte data) {
this.block = block;
this.data = data;
}
public short getBlock() {
return block;
}
public byte getData() {
return data;
}
}
}

View File

@ -20,18 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.commands;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.commands.CommandCategory;
import com.intellectualcrafters.plot.commands.RequiredType;
@ -55,6 +43,18 @@ import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.CommandDeclaration;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
@CommandDeclaration(
command = "uuidconvert",
permission = "plots.admin",
@ -139,7 +139,7 @@ public class DebugUUID extends SubCommand {
return s.endsWith(".dat");
}
});
if (dat != null) {
if (dat != null)
for (final String current : dat) {
final String s = current.replaceAll(".dat$", "");
try {
@ -149,7 +149,6 @@ public class DebugUUID extends SubCommand {
MainUtil.sendMessage(player, C.PREFIX.s() + "Invalid playerdata: " + current);
}
}
}
final File playersFolder = new File(worldname + File.separator + "players");
dat = playersFolder.list(new FilenameFilter() {
@Override

View File

@ -1,15 +1,5 @@
package com.plotsquared.bukkit.database.plotme;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.UUID;
import com.intellectualcrafters.configuration.file.FileConfiguration;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
@ -22,6 +12,16 @@ import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.StringWrapper;
import com.intellectualcrafters.plot.util.UUIDHandler;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.UUID;
public class PlotMeConnector_017 extends APlotMeConnector {
private String plugin;
private String prefix;
@ -135,7 +135,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
}
for (final Entry<Integer, Plot> entry : plots.entrySet()) {
final Plot plot = entry.getValue();
final HashMap<PlotId, boolean[]> mergeMap = merges.get(plot.area.worldname);
final HashMap<PlotId, boolean[]> mergeMap = merges.get(plot.getArea().worldname);
if (mergeMap != null) {
if (mergeMap.containsKey(plot.getId())) {
plot.setMerged(mergeMap.get(plot.getId()));
@ -184,10 +184,10 @@ public class PlotMeConnector_017 extends APlotMeConnector {
for (final Entry<Integer, Plot> entry : plots.entrySet()) {
final Plot plot = entry.getValue();
HashMap<PlotId, Plot> map = processed.get(plot.area.worldname);
HashMap<PlotId, Plot> map = processed.get(plot.getArea().worldname);
if (map == null) {
map = new HashMap<>();
processed.put(plot.area.worldname, map);
processed.put(plot.getArea().worldname, map);
}
map.put(plot.getId(), plot);
}

View File

@ -1,16 +1,33 @@
package com.plotsquared.bukkit.listeners;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotHandler;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotInventory;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.StringWrapper;
import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.ExpireManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.RegExUtil;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.BukkitMain;
import com.plotsquared.bukkit.object.BukkitLazyBlock;
import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.listener.PlayerBlockEventType;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -89,34 +106,16 @@ import org.bukkit.projectiles.BlockProjectileSource;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.util.Vector;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotHandler;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotInventory;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.StringWrapper;
import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.ExpireManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.RegExUtil;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.BukkitMain;
import com.plotsquared.bukkit.object.BukkitLazyBlock;
import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.listener.PlayerBlockEventType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
/**
* Player Events involving plots
@ -226,7 +225,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
}
event.setNewCurrent(0);
return;
}
}
}
@ -484,66 +482,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
return;
}
Plot now = area.getPlotAbs(loc);
final Plot lastPlot = (Plot) pp.getMeta("lastplot");
if (now == null) {
if ((lastPlot != null) && !plotExit(pp, lastPlot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
if (lastPlot.equals((BukkitUtil.getLocation(from).getPlot()))) {
player.teleport(from);
} else {
player.teleport(player.getWorld().getSpawnLocation());
}
event.setCancelled(true);
return;
}
} else if ((lastPlot != null) && now.equals(lastPlot)) {
return;
} else {
if (!plotEntry(pp, now)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!now.equals(lastPlot)) {
player.teleport(from);
} else {
player.teleport(player.getWorld().getSpawnLocation());
}
event.setCancelled(true);
return;
}
}
final Integer border = area.getBorder();;
if (border != null) {
if (x2 > border) {
to.setX(border - 4);
player.teleport(event.getTo());
MainUtil.sendMessage(pp, C.BORDER);
return;
} else if (x2 < -border) {
to.setX(-border + 4);
player.teleport(event.getTo());
MainUtil.sendMessage(pp, C.BORDER);
return;
}
}
return;
}
int z2;
if (MathMan.roundInt(from.getZ()) != (z2 = MathMan.roundInt(to.getZ()))) {
final Player player = event.getPlayer();
final PlotPlayer pp = BukkitUtil.getPlayer(player);
// Cancel teleport
TaskManager.TELEPORT_QUEUE.remove(pp.getName());
// Set last location
Location loc = BukkitUtil.getLocation(to);
pp.setMeta("location", loc);
PlotArea area = loc.getPlotArea();
if (area == null) {
return;
}
Plot now = area.getPlotAbs(loc);
final Plot lastPlot = (Plot) pp.getMeta("lastplot");
final Plot lastPlot = pp.getMeta("lastplot");
if (now == null) {
if ((lastPlot != null) && !plotExit(pp, lastPlot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
@ -570,16 +509,71 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
}
final Integer border = area.getBorder();
if (border != null) {
if (z2 > border) {
to.setZ(border - 4);
player.teleport(event.getTo());
MainUtil.sendMessage(pp, C.BORDER);
} else if (z2 < -border) {
to.setZ(-border + 4);
player.teleport(event.getTo());
MainUtil.sendMessage(pp, C.BORDER);
if (x2 > border) {
to.setX(border - 4);
player.teleport(event.getTo());
MainUtil.sendMessage(pp, C.BORDER);
return;
} else if (x2 < -border) {
to.setX(-border + 4);
player.teleport(event.getTo());
MainUtil.sendMessage(pp, C.BORDER);
return;
}
return;
}
int z2;
if (MathMan.roundInt(from.getZ()) != (z2 = MathMan.roundInt(to.getZ()))) {
final Player player = event.getPlayer();
final PlotPlayer pp = BukkitUtil.getPlayer(player);
// Cancel teleport
TaskManager.TELEPORT_QUEUE.remove(pp.getName());
// Set last location
Location loc = BukkitUtil.getLocation(to);
pp.setMeta("location", loc);
PlotArea area = loc.getPlotArea();
if (area == null) {
return;
}
Plot now = area.getPlotAbs(loc);
final Plot lastPlot = pp.getMeta("lastplot");
if (now == null) {
if ((lastPlot != null) && !plotExit(pp, lastPlot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
if (lastPlot.equals((BukkitUtil.getLocation(from).getPlot()))) {
player.teleport(from);
} else {
player.teleport(player.getWorld().getSpawnLocation());
}
event.setCancelled(true);
return;
}
} else if ((lastPlot != null) && now.equals(lastPlot)) {
return;
} else {
if (!plotEntry(pp, now)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!now.equals(lastPlot)) {
player.teleport(from);
} else {
player.teleport(player.getWorld().getSpawnLocation());
}
event.setCancelled(true);
return;
}
}
final Integer border = area.getBorder();
if (z2 > border) {
to.setZ(border - 4);
player.teleport(event.getTo());
MainUtil.sendMessage(pp, C.BORDER);
} else if (z2 < -border) {
to.setZ(-border + 4);
player.teleport(event.getTo());
MainUtil.sendMessage(pp, C.BORDER);
}
}
}
@ -713,7 +707,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
iter.remove();
}
}
return;
}
} else {
event.setCancelled(true);
@ -791,7 +784,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
public void onBD(final BlockDamageEvent event) {
final Player player = event.getPlayer();
Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
final String world;
if (player == null) {
if (loc.isPlotRoad()) {
event.setCancelled(true);
@ -871,7 +863,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
final Location loc = BukkitUtil.getLocation(b.getLocation());
if (loc.isUnownedPlotArea()) {
e.setCancelled(true);
return;
}
}
@ -973,7 +964,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
Plot newPlot = area.getOwnedPlot(loc);
if (!Objects.equals(plot, newPlot)) {
event.setCancelled(true);
return;
}
}
}
@ -1269,7 +1259,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
if (checkEntity(entity, plot)) {
event.setCancelled(true);
return;
}
}
@ -1557,7 +1546,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
return;
}
Plot now = area.getPlotAbs(loc);
final Plot lastPlot = (Plot) pp.getMeta("lastplot");
final Plot lastPlot = pp.getMeta("lastplot");
if (now == null) {
if ((lastPlot != null) && !plotExit(pp, lastPlot) && tmp_teleport) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
@ -1598,7 +1587,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
}
final Integer border = area.getBorder();
if (border != null && tmp_teleport) {
if (tmp_teleport) {
if (x2 > border) {
to.setX(border - 4);
tmp_teleport = false;
@ -1629,7 +1618,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
return;
}
Plot now = area.getPlotAbs(loc);
final Plot lastPlot = (Plot) pp.getMeta("lastplot");
final Plot lastPlot = pp.getMeta("lastplot");
if (now == null) {
if ((lastPlot != null) && !plotExit(pp, lastPlot) && tmp_teleport) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
@ -1670,24 +1659,21 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
}
final Integer border = area.getBorder();
if (border != null && tmp_teleport) {
if (tmp_teleport) {
if (z2 > border) {
to.setZ(border - 4);
tmp_teleport = false;
player.teleport(event.getTo());
tmp_teleport = true;
MainUtil.sendMessage(pp, C.BORDER);
return;
} else if (z2 < -border) {
to.setZ(-border + 4);
tmp_teleport = false;
player.teleport(event.getTo());
tmp_teleport = true;
MainUtil.sendMessage(pp, C.BORDER);
return;
}
}
return;
}
}
@ -1737,7 +1723,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
final Player player = (Player) clicker;
final PlotPlayer pp = BukkitUtil.getPlayer(player);
final PlotInventory inv = (PlotInventory) pp.getMeta("inventory");
final PlotInventory inv = pp.getMeta("inventory");
if ((inv != null) && (event.getRawSlot() == event.getSlot())) {
if (!inv.onClick(event.getSlot())) {
event.setCancelled(true);
@ -1857,7 +1843,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
if (checkEntity(e.getEntity(), plot)) {
e.setCancelled(true);
return;
}
}
@ -2154,10 +2139,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
return true;
}
// player is null
if ((damager instanceof Arrow) && (!(victim instanceof Creature))) {
return false;
}
return true;
return !((damager instanceof Arrow) && (!(victim instanceof Creature)));
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)

View File

@ -137,43 +137,20 @@ public class BukkitPlayer extends PlotPlayer {
@Override
public void setAttribute(String key) {
key = "plotsquared_user_attributes." + key;
if ((EconHandler.manager == null) || player.hasPermission("plotsquared_user_attributes.*")) {
setMeta(key, true);
return;
}
EconHandler.manager.setPermission(getName(), key, true);
setPersistentMeta("attrib_" + key, new byte[]{(byte) 1});
}
@Override
public boolean getAttribute(String key) {
key = "plotsquared_user_attributes." + key;
if ((EconHandler.manager == null) || player.hasPermission("plotsquared_user_attributes.*")) {
final Object v = getMeta(key);
return v == null ? false : (Boolean) v;
}
Permission perm = Bukkit.getServer().getPluginManager().getPermission(key);
if (perm == null) {
try {
perm = new Permission(key, PermissionDefault.FALSE);
Bukkit.getServer().getPluginManager().addPermission(perm);
Bukkit.getServer().getPluginManager().recalculatePermissionDefaults(perm);
}
catch (Exception e) {
e.printStackTrace();
}
}
return player.hasPermission(key);
if (!hasPersistentMeta(key)) {
return false;
}
return getPersistentMeta("attrib_" + key)[0] == 1;
}
@Override
public void removeAttribute(String key) {
key = "plotsquared_user_attributes." + key;
if ((EconHandler.manager == null) || player.hasPermission("plotsquared_user_attributes.*")) {
deleteMeta(key);
return;
}
EconHandler.manager.setPermission(getName(), key, false);
removePersistentMeta("attrib_" + key);
}
@Override

View File

@ -1,5 +1,6 @@
package com.plotsquared.bukkit.object.entity;
import com.intellectualcrafters.plot.PS;
import org.bukkit.Art;
import org.bukkit.DyeColor;
import org.bukkit.Location;
@ -31,8 +32,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
import com.intellectualcrafters.plot.PS;
public class EntityWrapper {
public short id;
public float yaw;
@ -71,9 +70,7 @@ public class EntityWrapper {
}
private void restoreLiving(final LivingEntity entity) {
if (lived.loot) {
entity.setCanPickupItems(lived.loot);
}
entity.setCanPickupItems(lived.loot);
if (lived.name != null) {
entity.setCustomName(lived.name);
entity.setCustomNameVisible(lived.visible);
@ -143,9 +140,7 @@ public class EntityWrapper {
if (!aged.adult) {
entity.setBaby();
}
if (aged.locked) {
entity.setAgeLock(aged.locked);
}
entity.setAgeLock(aged.locked);
if (aged.age > 0) {
entity.setAge(aged.age);
}

View File

@ -1,13 +1,24 @@
package com.plotsquared.bukkit.util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.generator.AugmentedUtils;
import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotLoc;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.PlotChunk;
import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.bukkit.object.entity.EntityWrapper;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.DyeColor;
@ -42,25 +53,13 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.generator.AugmentedUtils;
import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotLoc;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.PlotChunk;
import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.bukkit.object.entity.EntityWrapper;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
public class BukkitChunkManager extends ChunkManager {
@Override
@ -1026,7 +1025,7 @@ public class BukkitChunkManager extends ChunkManager {
@Override
public int[] countEntities(final Plot plot) {
final int[] count = new int[6];
PlotArea area = plot.area;
PlotArea area = plot.getArea();
final World world = BukkitUtil.getWorld(area.worldname);
final Location bot = plot.getBottomAbs();

View File

@ -1,13 +1,5 @@
package com.plotsquared.bukkit.util;
import java.util.ArrayList;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
@ -33,6 +25,13 @@ import com.plotsquared.bukkit.events.PlotMergeEvent;
import com.plotsquared.bukkit.events.PlotRateEvent;
import com.plotsquared.bukkit.events.PlotUnlinkEvent;
import com.plotsquared.bukkit.object.BukkitPlayer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import java.util.ArrayList;
import java.util.UUID;
public class BukkitEventUtil extends EventUtil {
@ -83,7 +82,7 @@ public class BukkitEventUtil extends EventUtil {
@Override
public boolean callMerge(final Plot plot, final ArrayList<PlotId> plots) {
return callEvent(new PlotMergeEvent(BukkitUtil.getWorld(plot.area.worldname), plot, plots));
return callEvent(new PlotMergeEvent(BukkitUtil.getWorld(plot.getArea().worldname), plot, plots));
}
@Override

View File

@ -2,18 +2,6 @@ package com.plotsquared.bukkit.util;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
@ -26,10 +14,22 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.object.BukkitPlayer;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
/**
* An utility that can be used to send chunks, rather than using bukkit code to do so (uses heavy NMS)
*
*
*/
public class SendChunk {
@ -83,7 +83,7 @@ public class SendChunk {
Location loc = null;
String world;
if (plot != null) {
world = plot.area.worldname;
world = plot.getArea().worldname;
} else {
loc = pp.getLocation();
world = loc.getWorld();

View File

@ -2,16 +2,6 @@ package com.plotsquared.bukkit.util.block;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.Biome;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.util.MainUtil;
@ -23,6 +13,15 @@ import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.SendChunk;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.Biome;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
public class FastQueue_1_7 extends SlowQueue {
@ -54,7 +53,7 @@ public class FastQueue_1_7 extends SlowQueue {
return;
}
int count = 0;
final ArrayList<Chunk> chunks = new ArrayList<Chunk>();
final ArrayList<Chunk> chunks = new ArrayList<>();
final Iterator<Entry<ChunkWrapper, Chunk>> i = toUpdate.entrySet().iterator();
while (i.hasNext() && (count < 128)) {
chunks.add(i.next().getValue());
@ -145,7 +144,7 @@ public class FastQueue_1_7 extends SlowQueue {
/**
* This should be overriden by any specialized queues
* @param pc
* @param wrap
*/
@Override
public PlotChunk<Chunk> getChunk(ChunkWrapper wrap) {
@ -154,7 +153,8 @@ public class FastQueue_1_7 extends SlowQueue {
/**
* This should be overriden by any specialized queues
* @param pc
* @param chunk
* @param fixAll
*/
@Override
public boolean fixLighting(PlotChunk<Chunk> chunk, boolean fixAll) {
@ -165,7 +165,8 @@ public class FastQueue_1_7 extends SlowQueue {
/**
* This should be overriden by any specialized queues
* @param pc
* @param world
* @param locs
*/
@Override
public void sendChunk(String world, Collection<ChunkLoc> locs) {

View File

@ -2,22 +2,6 @@ package com.plotsquared.bukkit.util.block;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Biome;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.util.ChunkManager;
@ -33,6 +17,21 @@ import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.SendChunk;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Biome;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
public class FastQueue_1_8_3 extends SlowQueue {
@ -209,10 +208,6 @@ public class FastQueue_1_8_3 extends SlowQueue {
boolean fill = true;
for (int k = 0; k < newArray.length; k++) {
final char n = newArray[k];
if (n == 0) {
fill = false;
continue;
}
switch (n) {
case 0:
fill = false;
@ -263,7 +258,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
/**
* This should be overriden by any specialized queues
* @param pc
* @param wrap
*/
@Override
public PlotChunk<Chunk> getChunk(ChunkWrapper wrap) {
@ -415,7 +410,8 @@ public class FastQueue_1_8_3 extends SlowQueue {
/**
* This should be overriden by any specialized queues
* @param pc
* @param world
* @param locs
*/
@Override
public void sendChunk(String world, Collection<ChunkLoc> locs) {

View File

@ -20,10 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.listener;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.flag.Flag;
@ -45,6 +41,10 @@ import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
@ -168,7 +168,7 @@ public class PlotListener {
final Map<String, String> replacements = new HashMap<>();
replacements.put("%x%", lastPlot.getId().x + "");
replacements.put("%z%", lastPlot.getId().y + "");
replacements.put("%world%", plot.area.toString());
replacements.put("%world%", plot.getArea().toString());
replacements.put("%greeting%", greeting);
replacements.put("%alias", plot.toString());
replacements.put("%s", MainUtil.getName(plot.owner));