mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
parent
ca5e7f4564
commit
b255c5db47
@ -1,38 +1,5 @@
|
|||||||
package com.intellectualcrafters.plot;
|
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.MalformedURLException;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLConnection;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayDeque;
|
|
||||||
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.Iterator;
|
|
||||||
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.ConfigurationSection;
|
||||||
import com.intellectualcrafters.configuration.MemorySection;
|
import com.intellectualcrafters.configuration.MemorySection;
|
||||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||||
@ -88,6 +55,39 @@ import com.intellectualcrafters.plot.util.area.QuadMap;
|
|||||||
import com.plotsquared.listener.WESubscriber;
|
import com.plotsquared.listener.WESubscriber;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
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.MalformedURLException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayDeque;
|
||||||
|
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.Iterator;
|
||||||
|
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,
|
* An implementation of the core,
|
||||||
* with a static getter for easy access
|
* with a static getter for easy access
|
||||||
@ -1803,38 +1803,38 @@ public class PS {
|
|||||||
if (newFile.exists()) {
|
if (newFile.exists()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final InputStream stream = IMP.getClass().getResourceAsStream(file);
|
try (InputStream stream = IMP.getClass().getResourceAsStream(file)) {
|
||||||
final byte[] buffer = new byte[2048];
|
final byte[] buffer = new byte[2048];
|
||||||
if (stream == null) {
|
if (stream == null) {
|
||||||
final ZipInputStream zis = new ZipInputStream(new FileInputStream(FILE));
|
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(FILE))) {
|
||||||
ZipEntry ze = zis.getNextEntry();
|
ZipEntry ze = zis.getNextEntry();
|
||||||
while (ze != null) {
|
while (ze != null) {
|
||||||
final String name = ze.getName();
|
final String name = ze.getName();
|
||||||
if (name.equals(file)) {
|
if (name.equals(file)) {
|
||||||
new File(newFile.getParent()).mkdirs();
|
new File(newFile.getParent()).mkdirs();
|
||||||
final FileOutputStream fos = new FileOutputStream(newFile);
|
try (FileOutputStream fos = new FileOutputStream(newFile)) {
|
||||||
int len;
|
int len;
|
||||||
while ((len = zis.read(buffer)) > 0) {
|
while ((len = zis.read(buffer)) > 0) {
|
||||||
fos.write(buffer, 0, len);
|
fos.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ze = null;
|
||||||
|
} else {
|
||||||
|
ze = zis.getNextEntry();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fos.close();
|
zis.closeEntry();
|
||||||
ze = null;
|
}
|
||||||
} else {
|
return;
|
||||||
ze = zis.getNextEntry();
|
}
|
||||||
|
newFile.createNewFile();
|
||||||
|
try (FileOutputStream fos = new FileOutputStream(newFile)) {
|
||||||
|
int len;
|
||||||
|
while ((len = stream.read(buffer)) > 0) {
|
||||||
|
fos.write(buffer, 0, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zis.closeEntry();
|
|
||||||
zis.close();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
newFile.createNewFile();
|
|
||||||
final FileOutputStream fos = new FileOutputStream(newFile);
|
|
||||||
int len;
|
|
||||||
while ((len = stream.read(buffer)) > 0) {
|
|
||||||
fos.write(buffer, 0, len);
|
|
||||||
}
|
|
||||||
fos.close();
|
|
||||||
stream.close();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log("&cCould not save " + file);
|
log("&cCould not save " + file);
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.database.MySQL;
|
import com.intellectualcrafters.plot.database.MySQL;
|
||||||
@ -19,6 +13,13 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
|||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
command = "database",
|
command = "database",
|
||||||
aliases = { "convert" },
|
aliases = { "convert" },
|
||||||
@ -93,7 +94,7 @@ public class Database extends SubCommand {
|
|||||||
implementation = new SQLite(file.getPath());
|
implementation = new SQLite(file.getPath());
|
||||||
final SQLManager manager = new SQLManager(implementation, (args.length == 3) ? args[2] : "", true);
|
final SQLManager manager = new SQLManager(implementation, (args.length == 3) ? args[2] : "", true);
|
||||||
final HashMap<String, HashMap<PlotId, Plot>> map = manager.getPlots();
|
final HashMap<String, HashMap<PlotId, Plot>> map = manager.getPlots();
|
||||||
plots = new ArrayList<Plot>();
|
plots = new ArrayList<>();
|
||||||
for (final Entry<String, HashMap<PlotId, Plot>> entry : map.entrySet()) {
|
for (final Entry<String, HashMap<PlotId, Plot>> entry : map.entrySet()) {
|
||||||
String areaname = entry.getKey();
|
String areaname = entry.getKey();
|
||||||
PlotArea pa = PS.get().getPlotAreaByString(areaname);
|
PlotArea pa = PS.get().getPlotAreaByString(areaname);
|
||||||
@ -107,15 +108,14 @@ public class Database extends SubCommand {
|
|||||||
PS.get().updatePlot(plot);
|
PS.get().updatePlot(plot);
|
||||||
plots.add(entry2.getValue());
|
plots.add(entry2.getValue());
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
HashMap<PlotId, Plot> plotmap = PS.get().plots_tmp.get(areaname);
|
HashMap<PlotId, Plot> plotmap = PS.get().plots_tmp.get(areaname);
|
||||||
if (plotmap == null) {
|
if (plotmap == null) {
|
||||||
plotmap = new HashMap<>();
|
plotmap = new HashMap<>();
|
||||||
PS.get().plots_tmp.put(areaname, plotmap);
|
PS.get().plots_tmp.put(areaname, plotmap);
|
||||||
}
|
}
|
||||||
plotmap.putAll(entry.getValue());
|
plotmap.putAll(entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DBFunc.createPlotsAndData(plots, new Runnable() {
|
DBFunc.createPlotsAndData(plots, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -152,7 +152,7 @@ public class Database extends SubCommand {
|
|||||||
final SQLManager manager = new SQLManager(implementation, prefix, true);
|
final SQLManager manager = new SQLManager(implementation, prefix, true);
|
||||||
insertPlots(manager, plots, player);
|
insertPlots(manager, plots, player);
|
||||||
return true;
|
return true;
|
||||||
} catch (final Exception e) {
|
} catch (ClassNotFoundException | SQLException e) {
|
||||||
MainUtil.sendMessage(player, "$1Failed to save plots, read stacktrace for info");
|
MainUtil.sendMessage(player, "$1Failed to save plots, read stacktrace for info");
|
||||||
MainUtil.sendMessage(player, "&d==== Here is an ugly stacktrace, if you are interested in those things ===");
|
MainUtil.sendMessage(player, "&d==== Here is an ugly stacktrace, if you are interested in those things ===");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -160,7 +160,7 @@ public class Database extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, "$1Please make sure you are using the correct arguments!");
|
MainUtil.sendMessage(player, "$1Please make sure you are using the correct arguments!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (ClassNotFoundException | SQLException e) {
|
||||||
MainUtil.sendMessage(player, "$1Failed to open connection, read stacktrace for info");
|
MainUtil.sendMessage(player, "$1Failed to open connection, read stacktrace for info");
|
||||||
MainUtil.sendMessage(player, "&d==== Here is an ugly stacktrace, if you are interested in those things ===");
|
MainUtil.sendMessage(player, "&d==== Here is an ugly stacktrace, if you are interested in those things ===");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
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.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
@ -13,6 +10,9 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
|||||||
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.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
command = "debugpaste",
|
command = "debugpaste",
|
||||||
aliases = { "dp" },
|
aliases = { "dp" },
|
||||||
@ -32,7 +32,7 @@ public class DebugPaste extends SubCommand {
|
|||||||
String latestLOG;
|
String latestLOG;
|
||||||
try {
|
try {
|
||||||
latestLOG = HastebinUtility.upload(new File(PS.get().IMP.getDirectory(), "../../logs/latest.log"));
|
latestLOG = HastebinUtility.upload(new File(PS.get().IMP.getDirectory(), "../../logs/latest.log"));
|
||||||
} catch (final Exception e) {
|
} catch (IOException e) {
|
||||||
MainUtil.sendMessage(plr, "&clatest.log is too big to be pasted, will ignore");
|
MainUtil.sendMessage(plr, "&clatest.log is too big to be pasted, will ignore");
|
||||||
latestLOG = "too big :(";
|
latestLOG = "too big :(";
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,6 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
@ -34,6 +30,10 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
|||||||
import com.plotsquared.general.commands.Argument;
|
import com.plotsquared.general.commands.Argument;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
command = "remove",
|
command = "remove",
|
||||||
aliases = { "r" },
|
aliases = { "r" },
|
||||||
@ -59,7 +59,7 @@ public class Remove extends SubCommand {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
if ((plot == null) || !plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,8 @@ public class SQLManager implements AbstractDB {
|
|||||||
*
|
*
|
||||||
* @param database
|
* @param database
|
||||||
* @param p prefix
|
* @param p prefix
|
||||||
* @throws Exception
|
* @throws SQLException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
public SQLManager(final Database database, final String p, final boolean debug) throws SQLException, ClassNotFoundException {
|
public SQLManager(final Database database, final String p, final boolean debug) throws SQLException, ClassNotFoundException {
|
||||||
// Private final
|
// Private final
|
||||||
@ -198,18 +199,18 @@ public class SQLManager implements AbstractDB {
|
|||||||
task = new UniqueStatement(plot.hashCode() + "") {
|
task = new UniqueStatement(plot.hashCode() + "") {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreparedStatement get() throws SQLException {
|
public PreparedStatement get() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(final PreparedStatement stmt) throws SQLException {}
|
public void set(final PreparedStatement stmt) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBatch(final PreparedStatement stmt) throws SQLException {}
|
public void addBatch(final PreparedStatement stmt) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final PreparedStatement stmt) throws SQLException {}
|
public void execute(final PreparedStatement stmt) {}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -229,18 +230,18 @@ public class SQLManager implements AbstractDB {
|
|||||||
task = new UniqueStatement(uuid.hashCode() + "") {
|
task = new UniqueStatement(uuid.hashCode() + "") {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreparedStatement get() throws SQLException {
|
public PreparedStatement get() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(final PreparedStatement stmt) throws SQLException {}
|
public void set(final PreparedStatement stmt) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBatch(final PreparedStatement stmt) throws SQLException {}
|
public void addBatch(final PreparedStatement stmt) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final PreparedStatement stmt) throws SQLException {}
|
public void execute(final PreparedStatement stmt) {}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -257,18 +258,18 @@ public class SQLManager implements AbstractDB {
|
|||||||
task = new UniqueStatement(cluster.hashCode() + "") {
|
task = new UniqueStatement(cluster.hashCode() + "") {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreparedStatement get() throws SQLException {
|
public PreparedStatement get() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(final PreparedStatement stmt) throws SQLException {}
|
public void set(final PreparedStatement stmt) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBatch(final PreparedStatement stmt) throws SQLException {}
|
public void addBatch(final PreparedStatement stmt) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final PreparedStatement stmt) throws SQLException {}
|
public void execute(final PreparedStatement stmt) {}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -1010,7 +1011,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final PreparedStatement stmt) throws SQLException {
|
public void execute(final PreparedStatement stmt) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1614,7 +1615,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
final HashMap<String, HashMap<PlotId, Plot>> newplots = new HashMap<>();
|
final HashMap<String, HashMap<PlotId, Plot>> newplots = new HashMap<>();
|
||||||
final HashMap<Integer, Plot> plots = new HashMap<>();
|
final HashMap<Integer, Plot> plots = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
HashSet<String> areas = new HashSet<>();;
|
HashSet<String> areas = new HashSet<>();
|
||||||
if (PS.get().config.contains("worlds")) {
|
if (PS.get().config.contains("worlds")) {
|
||||||
ConfigurationSection worldSection = PS.get().config.getConfigurationSection("worlds");
|
ConfigurationSection worldSection = PS.get().config.getConfigurationSection("worlds");
|
||||||
if (worldSection != null) {
|
if (worldSection != null) {
|
||||||
@ -2187,27 +2188,28 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final PreparedStatement stmt) throws SQLException {}
|
public void execute(final PreparedStatement stmt) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBatch(final PreparedStatement statement) throws SQLException {
|
public void addBatch(final PreparedStatement statement) throws SQLException {
|
||||||
final ArrayList<PlotComment> comments = new ArrayList<>();
|
final ArrayList<PlotComment> comments = new ArrayList<>();
|
||||||
final ResultSet set = statement.executeQuery();
|
try (ResultSet set = statement.executeQuery()) {
|
||||||
while (set.next()) {
|
while (set.next()) {
|
||||||
final String sender = set.getString("sender");
|
final String sender = set.getString("sender");
|
||||||
final String world = set.getString("world");
|
final String world = set.getString("world");
|
||||||
final int hash = set.getInt("hashcode");
|
final int hash = set.getInt("hashcode");
|
||||||
PlotId id;
|
PlotId id;
|
||||||
if (hash != 0) {
|
if (hash != 0) {
|
||||||
id = PlotId.unpair(hash);
|
id = PlotId.unpair(hash);
|
||||||
} else {
|
} else {
|
||||||
id = null;
|
id = null;
|
||||||
|
}
|
||||||
|
final String msg = set.getString("comment");
|
||||||
|
final long timestamp = set.getInt("timestamp") * 1000;
|
||||||
|
PlotComment comment = new PlotComment(world, id, msg, sender, inbox, timestamp);
|
||||||
|
comments.add(comment);
|
||||||
|
whenDone.value = comments;
|
||||||
}
|
}
|
||||||
final String msg = set.getString("comment");
|
|
||||||
final long timestamp = set.getInt("timestamp") * 1000;
|
|
||||||
PlotComment comment = new PlotComment(world, id, msg, sender, inbox, timestamp);
|
|
||||||
comments.add(comment);
|
|
||||||
whenDone.value = comments;
|
|
||||||
}
|
}
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
}
|
}
|
||||||
@ -2773,7 +2775,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final PreparedStatement stmt) throws SQLException {
|
public void execute(final PreparedStatement stmt) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -697,7 +697,7 @@ public class Plot {
|
|||||||
if (current.getDenied().add(uuid)) {
|
if (current.getDenied().add(uuid)) {
|
||||||
DBFunc.setDenied(current, uuid);
|
DBFunc.setDenied(current, uuid);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1570,14 +1570,24 @@ public class Plot {
|
|||||||
public boolean removeDenied(final UUID uuid) {
|
public boolean removeDenied(final UUID uuid) {
|
||||||
if (uuid == DBFunc.everyone) {
|
if (uuid == DBFunc.everyone) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
for (final UUID other : new HashSet<>(this.denied)) {
|
for (final UUID other : getDenied()) {
|
||||||
result = result || removeDenied(other);
|
result = result || rmvDenied(other);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return removeDenied(uuid);
|
return rmvDenied(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean rmvDenied(UUID uuid) {
|
||||||
|
for (Plot current : this.getConnectedPlots()) {
|
||||||
|
if (current.getDenied().remove(uuid)) {
|
||||||
|
DBFunc.removeDenied(current, uuid);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a helper (use DBFunc as well)<br>
|
* Remove a helper (use DBFunc as well)<br>
|
||||||
* Using the * uuid will remove all users
|
* Using the * uuid will remove all users
|
||||||
@ -1586,14 +1596,25 @@ public class Plot {
|
|||||||
public boolean removeTrusted(final UUID uuid) {
|
public boolean removeTrusted(final UUID uuid) {
|
||||||
if (uuid == DBFunc.everyone) {
|
if (uuid == DBFunc.everyone) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
for (final UUID other : new HashSet<>(this.trusted)) {
|
for (final UUID other : getTrusted()) {
|
||||||
result = result || removeTrusted(other);
|
result = result || rmvTrusted(other);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return removeTrusted(uuid);
|
return rmvTrusted(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean rmvTrusted(UUID uuid) {
|
||||||
|
for (Plot plot : this.getConnectedPlots()) {
|
||||||
|
if (plot.getTrusted().remove(uuid)) {
|
||||||
|
DBFunc.removeTrusted(plot, uuid);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a trusted user (use DBFunc as well)<br>
|
* Remove a trusted user (use DBFunc as well)<br>
|
||||||
* Using the * uuid will remove all users
|
* Using the * uuid will remove all users
|
||||||
@ -1606,13 +1627,24 @@ public class Plot {
|
|||||||
if (uuid == DBFunc.everyone) {
|
if (uuid == DBFunc.everyone) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
for (final UUID other : new HashSet<>(this.members)) {
|
for (final UUID other : new HashSet<>(this.members)) {
|
||||||
result = result || removeMember(other);
|
result = result || rmvMember(other);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return removeMember(uuid);
|
return rmvMember(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean rmvMember(UUID uuid) {
|
||||||
|
for (Plot current : this.getConnectedPlots()) {
|
||||||
|
if (current.getMembers().remove(uuid)) {
|
||||||
|
DBFunc.removeMember(current, uuid);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Export the plot as a schematic to the configured output directory
|
* Export the plot as a schematic to the configured output directory
|
||||||
* @return
|
* @return
|
||||||
|
@ -49,13 +49,13 @@ public class HastebinUtility {
|
|||||||
|
|
||||||
public static String upload(final File file) throws IOException {
|
public static String upload(final File file) throws IOException {
|
||||||
final StringBuilder content = new StringBuilder();
|
final StringBuilder content = new StringBuilder();
|
||||||
final BufferedReader reader = new BufferedReader(new FileReader(file));
|
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||||
String line;
|
String line;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while ((line = reader.readLine()) != null && i++ < 1000) {
|
while ((line = reader.readLine()) != null && i++ < 1000) {
|
||||||
content.append(line).append("\n");
|
content.append(line).append("\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
reader.close();
|
|
||||||
return upload(content.toString());
|
return upload(content.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,13 +4,17 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
|||||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
public class DefaultTitle extends AbstractTitle {
|
public class DefaultTitle extends AbstractTitle {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendTitle(final PlotPlayer player, final String head, final String sub, final int in, final int delay, final int out) {
|
public void sendTitle(final PlotPlayer player, final String head, final String sub, final int in, final int delay, final int out) {
|
||||||
try {
|
try {
|
||||||
final DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out);
|
final DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out);
|
||||||
title.send(((BukkitPlayer) player).player);
|
title.send(((BukkitPlayer) player).player);
|
||||||
} catch (Exception e) {
|
} catch (ClassNotFoundException | InvocationTargetException | SecurityException | NoSuchMethodException | InstantiationException |
|
||||||
|
IllegalArgumentException | IllegalAccessException e) {
|
||||||
AbstractTitle.TITLE_CLASS = new DefaultTitle_183();
|
AbstractTitle.TITLE_CLASS = new DefaultTitle_183();
|
||||||
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
|
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,8 @@ public class DefaultTitleManager {
|
|||||||
* Fade out time
|
* Fade out time
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
public DefaultTitleManager(final String title, final String subtitle, final int fadeInTime, final int stayTime, final int fadeOutTime) throws ClassNotFoundException {
|
public DefaultTitleManager(final String title, final String subtitle, final int fadeInTime, final int stayTime, final int fadeOutTime)
|
||||||
|
throws ClassNotFoundException {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.subtitle = subtitle;
|
this.subtitle = subtitle;
|
||||||
this.fadeInTime = fadeInTime;
|
this.fadeInTime = fadeInTime;
|
||||||
@ -255,21 +256,22 @@ public class DefaultTitleManager {
|
|||||||
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||||
final Object[] actions = packetActions.getEnumConstants();
|
final Object[] actions = packetActions.getEnumConstants();
|
||||||
final Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
final Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
||||||
Object packet = packetTitle.getConstructor(packetActions, chatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE).newInstance(actions[2], null, fadeInTime * (ticks ? 1 : 20),
|
Object packet = packetTitle.getConstructor(packetActions, chatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE)
|
||||||
stayTime * (ticks ? 1 : 20), fadeOutTime * (ticks ? 1 : 20));
|
.newInstance(actions[2], null, fadeInTime * (ticks ? 1 : 20),
|
||||||
|
stayTime * (ticks ? 1 : 20), fadeOutTime * (ticks ? 1 : 20));
|
||||||
// Send if set
|
// Send if set
|
||||||
if (fadeInTime != -1 && fadeOutTime != -1 && stayTime != -1) {
|
if (fadeInTime != -1 && fadeOutTime != -1 && stayTime != -1) {
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
}
|
}
|
||||||
// Send title
|
// Send title
|
||||||
Object serialized = getMethod(nmsChatSerializer, "a", String.class).invoke(null,
|
Object serialized = getMethod(nmsChatSerializer, "a", String.class).invoke(null,
|
||||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', title) + "\",color:" + titleColor.name().toLowerCase() + "}");
|
"{text:\"" + ChatColor.translateAlternateColorCodes('&', title) + "\",color:" + titleColor.name().toLowerCase() + "}");
|
||||||
packet = packetTitle.getConstructor(packetActions, chatBaseComponent).newInstance(actions[0], serialized);
|
packet = packetTitle.getConstructor(packetActions, chatBaseComponent).newInstance(actions[0], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
if (!subtitle.isEmpty()) {
|
if (!subtitle.isEmpty()) {
|
||||||
// Send subtitle if present
|
// Send subtitle if present
|
||||||
serialized = getMethod(nmsChatSerializer, "a", String.class).invoke(null,
|
serialized = getMethod(nmsChatSerializer, "a", String.class).invoke(null,
|
||||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\",color:" + subtitleColor.name().toLowerCase() + "}");
|
"{text:\"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\",color:" + subtitleColor.name().toLowerCase() + "}");
|
||||||
packet = packetTitle.getConstructor(packetActions, chatBaseComponent).newInstance(actions[1], serialized);
|
packet = packetTitle.getConstructor(packetActions, chatBaseComponent).newInstance(actions[1], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
}
|
}
|
||||||
@ -278,7 +280,8 @@ public class DefaultTitleManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcast the title to all players
|
* Broadcast the title to all players
|
||||||
* @throws Exception
|
* @throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException,
|
||||||
|
SecurityException
|
||||||
*/
|
*/
|
||||||
public void broadcast()
|
public void broadcast()
|
||||||
throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException,
|
throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException,
|
||||||
|
@ -34,7 +34,7 @@ public class HackTitleManager {
|
|||||||
private int stayTime = -1;
|
private int stayTime = -1;
|
||||||
private int fadeOutTime = -1;
|
private int fadeOutTime = -1;
|
||||||
private boolean ticks = false;
|
private boolean ticks = false;
|
||||||
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<Class<?>, Class<?>>();
|
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new 1.8 title
|
* Create a new 1.8 title
|
||||||
|
@ -1,75 +0,0 @@
|
|||||||
package com.plotsquared.listener;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.Vector2D;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
|
||||||
import com.sk89q.worldedit.regions.Region;
|
|
||||||
import com.sk89q.worldedit.util.Location;
|
|
||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
|
||||||
|
|
||||||
public class NullExtent implements Extent {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BaseBiome getBiome(final Vector2D arg0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BaseBlock getBlock(final Vector arg0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BaseBlock getLazyBlock(final Vector arg0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Operation commit() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setBiome(final Vector2D arg0, final BaseBiome arg1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setBlock(final Vector arg0, final BaseBlock arg1) throws WorldEditException {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Entity createEntity(final Location arg0, final BaseEntity arg1) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<? extends Entity> getEntities() {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<? extends Entity> getEntities(final Region arg0) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Vector getMaximumPoint() {
|
|
||||||
return new Vector(0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Vector getMinimumPoint() {
|
|
||||||
return new Vector(0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -20,10 +20,6 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.plotsquared.listener;
|
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.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
@ -44,6 +40,10 @@ import com.intellectualcrafters.plot.util.StringMan;
|
|||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ public class PlotListener {
|
|||||||
if (plot.isDenied(pp.getUUID()) && !Permissions.hasPermission(pp, "plots.admin.entry.denied")) {
|
if (plot.isDenied(pp.getUUID()) && !Permissions.hasPermission(pp, "plots.admin.entry.denied")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final Plot last = (Plot) pp.getMeta("lastplot");
|
final Plot last = pp.getMeta("lastplot");
|
||||||
if ((last != null) && !last.getId().equals(plot.getId())) {
|
if ((last != null) && !last.getId().equals(plot.getId())) {
|
||||||
plotExit(pp, last);
|
plotExit(pp, last);
|
||||||
}
|
}
|
||||||
@ -82,12 +82,9 @@ public class PlotListener {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
greeting = "";
|
greeting = "";
|
||||||
}
|
|
||||||
if (greeting != null) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
final Flag enter = flags.get("notify-enter");
|
final Flag enter = flags.get("notify-enter");
|
||||||
if ((enter != null) && ((Boolean) enter.getValue())) {
|
if (enter != null && (Boolean) enter.getValue()) {
|
||||||
if (!Permissions.hasPermission(pp, "plots.flag.notify-enter.bypass")) {
|
if (!Permissions.hasPermission(pp, "plots.flag.notify-enter.bypass")) {
|
||||||
for (final UUID uuid : plot.getOwners()) {
|
for (final UUID uuid : plot.getOwners()) {
|
||||||
final PlotPlayer owner = UUIDHandler.getPlayer(uuid);
|
final PlotPlayer owner = UUIDHandler.getPlayer(uuid);
|
||||||
@ -128,9 +125,9 @@ public class PlotListener {
|
|||||||
final Flag musicFlag = flags.get("music");
|
final Flag musicFlag = flags.get("music");
|
||||||
if (musicFlag != null) {
|
if (musicFlag != null) {
|
||||||
final Integer id = (Integer) musicFlag.getValue();
|
final Integer id = (Integer) musicFlag.getValue();
|
||||||
if (((id >= 2256) && (id <= 2267)) || (id == 0)) {
|
if ((id >= 2256 && id <= 2267) || (id == 0)) {
|
||||||
final Location loc = pp.getLocation();
|
final Location loc = pp.getLocation();
|
||||||
final Location lastLoc = (Location) pp.getMeta("music");
|
final Location lastLoc = pp.getMeta("music");
|
||||||
if (lastLoc != null) {
|
if (lastLoc != null) {
|
||||||
pp.playMusic(lastLoc, 0);
|
pp.playMusic(lastLoc, 0);
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
@ -145,7 +142,7 @@ public class PlotListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final Location lastLoc = (Location) pp.getMeta("music");
|
final Location lastLoc = pp.getMeta("music");
|
||||||
if (lastLoc != null) {
|
if (lastLoc != null) {
|
||||||
pp.deleteMeta("music");
|
pp.deleteMeta("music");
|
||||||
pp.playMusic(lastLoc, 0);
|
pp.playMusic(lastLoc, 0);
|
||||||
@ -162,7 +159,7 @@ public class PlotListener {
|
|||||||
TaskManager.runTaskLaterAsync(new Runnable() {
|
TaskManager.runTaskLaterAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final Plot lastPlot = (Plot) pp.getMeta("lastplot");
|
final Plot lastPlot = pp.getMeta("lastplot");
|
||||||
if ((lastPlot != null) && plot.getId().equals(lastPlot.getId())) {
|
if ((lastPlot != null) && plot.getId().equals(lastPlot.getId())) {
|
||||||
final Map<String, String> replacements = new HashMap<>();
|
final Map<String, String> replacements = new HashMap<>();
|
||||||
replacements.put("%x%", lastPlot.getId().x + "");
|
replacements.put("%x%", lastPlot.getId().x + "");
|
||||||
@ -223,7 +220,7 @@ public class PlotListener {
|
|||||||
}
|
}
|
||||||
if (FlagManager.getPlotFlagRaw(plot, "fly") != null) {
|
if (FlagManager.getPlotFlagRaw(plot, "fly") != null) {
|
||||||
final PlotGamemode gamemode = pp.getGamemode();
|
final PlotGamemode gamemode = pp.getGamemode();
|
||||||
if ((gamemode == PlotGamemode.SURVIVAL) || (gamemode == PlotGamemode.ADVENTURE)) {
|
if (gamemode == PlotGamemode.SURVIVAL || (gamemode == PlotGamemode.ADVENTURE)) {
|
||||||
pp.setFlight(false);
|
pp.setFlight(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,7 +230,7 @@ public class PlotListener {
|
|||||||
if (FlagManager.getPlotFlagRaw(plot, "weather") != null) {
|
if (FlagManager.getPlotFlagRaw(plot, "weather") != null) {
|
||||||
pp.setWeather(PlotWeather.RESET);
|
pp.setWeather(PlotWeather.RESET);
|
||||||
}
|
}
|
||||||
final Location lastLoc = (Location) pp.getMeta("music");
|
final Location lastLoc = pp.getMeta("music");
|
||||||
if (lastLoc != null) {
|
if (lastLoc != null) {
|
||||||
pp.deleteMeta("music");
|
pp.deleteMeta("music");
|
||||||
pp.playMusic(lastLoc, 0);
|
pp.playMusic(lastLoc, 0);
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package com.plotsquared.listener;
|
package com.plotsquared.listener;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
@ -14,11 +11,13 @@ import com.sk89q.worldedit.WorldEditException;
|
|||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.*;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
public class ProcessedWEExtent extends AbstractDelegateExtent {
|
public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||||
private final HashSet<RegionWrapper> mask;
|
private final HashSet<RegionWrapper> mask;
|
||||||
private final String world;
|
private final String world;
|
||||||
@ -95,7 +94,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
try {
|
try {
|
||||||
final Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
|
final Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
field.set(parent, new NullExtent());
|
field.set(parent, new com.sk89q.worldedit.extent.NullExtent());
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -117,7 +116,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
try {
|
try {
|
||||||
final Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
|
final Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
field.set(parent, new NullExtent());
|
field.set(parent, new com.sk89q.worldedit.extent.NullExtent());
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,7 @@ import com.sk89q.worldedit.command.tool.Tool;
|
|||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.*;
|
||||||
import com.sk89q.worldedit.extent.ChangeSetExtent;
|
|
||||||
import com.sk89q.worldedit.extent.MaskingExtent;
|
|
||||||
import com.sk89q.worldedit.extent.reorder.MultiStageReorder;
|
import com.sk89q.worldedit.extent.reorder.MultiStageReorder;
|
||||||
import com.sk89q.worldedit.extent.world.FastModeExtent;
|
import com.sk89q.worldedit.extent.world.FastModeExtent;
|
||||||
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
|
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
|
||||||
@ -50,7 +48,7 @@ public class WESubscriber {
|
|||||||
MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASS);
|
MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASS);
|
||||||
}
|
}
|
||||||
if (PS.get().hasPlotArea(world)) {
|
if (PS.get().hasPlotArea(world)) {
|
||||||
event.setExtent(new NullExtent());
|
event.setExtent(new com.sk89q.worldedit.extent.NullExtent());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -99,22 +97,20 @@ public class WESubscriber {
|
|||||||
final ExtentWrapper wrapper = new ExtentWrapper(event.getExtent());
|
final ExtentWrapper wrapper = new ExtentWrapper(event.getExtent());
|
||||||
event.setExtent(wrapper);
|
event.setExtent(wrapper);
|
||||||
field.set(extent, new ProcessedWEExtent(world, mask, max, new FastModeExtent(worldObj, true), wrapper));
|
field.set(extent, new ProcessedWEExtent(world, mask, max, new FastModeExtent(worldObj, true), wrapper));
|
||||||
|
} else if (fast) {
|
||||||
|
event.setExtent(new ExtentWrapper(extent));
|
||||||
} else {
|
} else {
|
||||||
if (fast) {
|
ExtentWrapper wrapper;
|
||||||
event.setExtent(new ExtentWrapper(extent));
|
if (maskextent != null) {
|
||||||
|
wrapper = new ExtentWrapper(maskextent);
|
||||||
|
field.set(maskextent, history);
|
||||||
|
event.setExtent(wrapper);
|
||||||
} else {
|
} else {
|
||||||
ExtentWrapper wrapper;
|
wrapper = new ExtentWrapper(history);
|
||||||
if (maskextent != null) {
|
event.setExtent(wrapper);
|
||||||
wrapper = new ExtentWrapper(maskextent);
|
|
||||||
field.set(maskextent, history);
|
|
||||||
event.setExtent(wrapper);
|
|
||||||
} else {
|
|
||||||
wrapper = new ExtentWrapper(history);
|
|
||||||
event.setExtent(wrapper);
|
|
||||||
}
|
|
||||||
field.set(history, reorder);
|
|
||||||
field.set(reorder, new ProcessedWEExtent(world, mask, max, new FastModeExtent(worldObj, true), wrapper));
|
|
||||||
}
|
}
|
||||||
|
field.set(history, reorder);
|
||||||
|
field.set(reorder, new ProcessedWEExtent(world, mask, max, new FastModeExtent(worldObj, true), wrapper));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} catch (IllegalAccessException | SecurityException | NoSuchFieldException | IllegalArgumentException e) {
|
} catch (IllegalAccessException | SecurityException | NoSuchFieldException | IllegalArgumentException e) {
|
||||||
|
@ -783,7 +783,7 @@ public class MainListener {
|
|||||||
if (plotworld == null) {
|
if (plotworld == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlotManager plotManager = PS.get().getPlotManager(PS.get().getPlot(plotworld, plotworld.getMin()));
|
final PlotManager plotManager = PS.get().getPlot(plotworld, plotworld.getMin()).getManager();
|
||||||
final PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ()));
|
final PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ()));
|
||||||
final Plot lastPlot = pp.getMeta("lastplot");
|
final Plot lastPlot = pp.getMeta("lastplot");
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
@ -839,7 +839,7 @@ public class MainListener {
|
|||||||
if (plotworld == null) {
|
if (plotworld == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlotManager plotManager = PS.get().getPlotManager(PS.get().getPlot(plotworld, plotworld.getMin()));
|
final PlotManager plotManager = PS.get().getPlot(plotworld, plotworld.getMin()).getManager();
|
||||||
final PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2);
|
final PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2);
|
||||||
final Plot lastPlot = pp.getMeta("lastplot");
|
final Plot lastPlot = pp.getMeta("lastplot");
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user