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;
|
||||
|
||||
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.MemorySection;
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
@ -88,6 +55,39 @@ 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.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,
|
||||
* with a static getter for easy access
|
||||
@ -1803,38 +1803,38 @@ public class PS {
|
||||
if (newFile.exists()) {
|
||||
return;
|
||||
}
|
||||
final InputStream stream = IMP.getClass().getResourceAsStream(file);
|
||||
final byte[] buffer = new byte[2048];
|
||||
if (stream == null) {
|
||||
final ZipInputStream zis = new ZipInputStream(new FileInputStream(FILE));
|
||||
ZipEntry ze = zis.getNextEntry();
|
||||
while (ze != null) {
|
||||
final String name = ze.getName();
|
||||
if (name.equals(file)) {
|
||||
new File(newFile.getParent()).mkdirs();
|
||||
final FileOutputStream fos = new FileOutputStream(newFile);
|
||||
int len;
|
||||
while ((len = zis.read(buffer)) > 0) {
|
||||
fos.write(buffer, 0, len);
|
||||
try (InputStream stream = IMP.getClass().getResourceAsStream(file)) {
|
||||
final byte[] buffer = new byte[2048];
|
||||
if (stream == null) {
|
||||
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(FILE))) {
|
||||
ZipEntry ze = zis.getNextEntry();
|
||||
while (ze != null) {
|
||||
final String name = ze.getName();
|
||||
if (name.equals(file)) {
|
||||
new File(newFile.getParent()).mkdirs();
|
||||
try (FileOutputStream fos = new FileOutputStream(newFile)) {
|
||||
int len;
|
||||
while ((len = zis.read(buffer)) > 0) {
|
||||
fos.write(buffer, 0, len);
|
||||
}
|
||||
}
|
||||
ze = null;
|
||||
} else {
|
||||
ze = zis.getNextEntry();
|
||||
}
|
||||
}
|
||||
fos.close();
|
||||
ze = null;
|
||||
} else {
|
||||
ze = zis.getNextEntry();
|
||||
zis.closeEntry();
|
||||
}
|
||||
return;
|
||||
}
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
log("&cCould not save " + file);
|
||||
|
@ -1,11 +1,5 @@
|
||||
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.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.database.MySQL;
|
||||
@ -19,6 +13,13 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
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(
|
||||
command = "database",
|
||||
aliases = { "convert" },
|
||||
@ -93,7 +94,7 @@ public class Database extends SubCommand {
|
||||
implementation = new SQLite(file.getPath());
|
||||
final SQLManager manager = new SQLManager(implementation, (args.length == 3) ? args[2] : "", true);
|
||||
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()) {
|
||||
String areaname = entry.getKey();
|
||||
PlotArea pa = PS.get().getPlotAreaByString(areaname);
|
||||
@ -107,15 +108,14 @@ public class Database extends SubCommand {
|
||||
PS.get().updatePlot(plot);
|
||||
plots.add(entry2.getValue());
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
HashMap<PlotId, Plot> plotmap = PS.get().plots_tmp.get(areaname);
|
||||
if (plotmap == null) {
|
||||
plotmap = new HashMap<>();
|
||||
PS.get().plots_tmp.put(areaname, plotmap);
|
||||
}
|
||||
plotmap.putAll(entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
DBFunc.createPlotsAndData(plots, new Runnable() {
|
||||
@Override
|
||||
@ -152,7 +152,7 @@ public class Database extends SubCommand {
|
||||
final SQLManager manager = new SQLManager(implementation, prefix, true);
|
||||
insertPlots(manager, plots, player);
|
||||
return true;
|
||||
} catch (final Exception e) {
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
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 ===");
|
||||
e.printStackTrace();
|
||||
@ -160,7 +160,7 @@ public class Database extends SubCommand {
|
||||
MainUtil.sendMessage(player, "$1Please make sure you are using the correct arguments!");
|
||||
return false;
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
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 ===");
|
||||
e.printStackTrace();
|
||||
|
@ -1,8 +1,5 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -13,6 +10,9 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "debugpaste",
|
||||
aliases = { "dp" },
|
||||
@ -32,7 +32,7 @@ public class DebugPaste extends SubCommand {
|
||||
String latestLOG;
|
||||
try {
|
||||
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");
|
||||
latestLOG = "too big :(";
|
||||
}
|
||||
|
@ -20,10 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
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.object.Location;
|
||||
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.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "remove",
|
||||
aliases = { "r" },
|
||||
@ -59,7 +59,7 @@ public class Remove 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;
|
||||
}
|
||||
|
@ -115,7 +115,8 @@ public class SQLManager implements AbstractDB {
|
||||
*
|
||||
* @param database
|
||||
* @param p prefix
|
||||
* @throws Exception
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public SQLManager(final Database database, final String p, final boolean debug) throws SQLException, ClassNotFoundException {
|
||||
// Private final
|
||||
@ -198,18 +199,18 @@ public class SQLManager implements AbstractDB {
|
||||
task = new UniqueStatement(plot.hashCode() + "") {
|
||||
|
||||
@Override
|
||||
public PreparedStatement get() throws SQLException {
|
||||
public PreparedStatement get() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(final PreparedStatement stmt) throws SQLException {}
|
||||
public void set(final PreparedStatement stmt) {}
|
||||
|
||||
@Override
|
||||
public void addBatch(final PreparedStatement stmt) throws SQLException {}
|
||||
public void addBatch(final PreparedStatement stmt) {}
|
||||
|
||||
@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() + "") {
|
||||
|
||||
@Override
|
||||
public PreparedStatement get() throws SQLException {
|
||||
public PreparedStatement get() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(final PreparedStatement stmt) throws SQLException {}
|
||||
public void set(final PreparedStatement stmt) {}
|
||||
|
||||
@Override
|
||||
public void addBatch(final PreparedStatement stmt) throws SQLException {}
|
||||
public void addBatch(final PreparedStatement stmt) {}
|
||||
|
||||
@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() + "") {
|
||||
|
||||
@Override
|
||||
public PreparedStatement get() throws SQLException {
|
||||
public PreparedStatement get() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(final PreparedStatement stmt) throws SQLException {}
|
||||
public void set(final PreparedStatement stmt) {}
|
||||
|
||||
@Override
|
||||
public void addBatch(final PreparedStatement stmt) throws SQLException {}
|
||||
public void addBatch(final PreparedStatement stmt) {}
|
||||
|
||||
@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
|
||||
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<Integer, Plot> plots = new HashMap<>();
|
||||
try {
|
||||
HashSet<String> areas = new HashSet<>();;
|
||||
HashSet<String> areas = new HashSet<>();
|
||||
if (PS.get().config.contains("worlds")) {
|
||||
ConfigurationSection worldSection = PS.get().config.getConfigurationSection("worlds");
|
||||
if (worldSection != null) {
|
||||
@ -2187,27 +2188,28 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final PreparedStatement stmt) throws SQLException {}
|
||||
public void execute(final PreparedStatement stmt) {}
|
||||
|
||||
@Override
|
||||
public void addBatch(final PreparedStatement statement) throws SQLException {
|
||||
final ArrayList<PlotComment> comments = new ArrayList<>();
|
||||
final ResultSet set = statement.executeQuery();
|
||||
while (set.next()) {
|
||||
final String sender = set.getString("sender");
|
||||
final String world = set.getString("world");
|
||||
final int hash = set.getInt("hashcode");
|
||||
PlotId id;
|
||||
if (hash != 0) {
|
||||
id = PlotId.unpair(hash);
|
||||
} else {
|
||||
id = null;
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
while (set.next()) {
|
||||
final String sender = set.getString("sender");
|
||||
final String world = set.getString("world");
|
||||
final int hash = set.getInt("hashcode");
|
||||
PlotId id;
|
||||
if (hash != 0) {
|
||||
id = PlotId.unpair(hash);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
@ -2773,7 +2775,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
|
||||
@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)) {
|
||||
DBFunc.setDenied(current, uuid);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1570,14 +1570,24 @@ public class Plot {
|
||||
public boolean removeDenied(final UUID uuid) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
boolean result = false;
|
||||
for (final UUID other : new HashSet<>(this.denied)) {
|
||||
result = result || removeDenied(other);
|
||||
for (final UUID other : getDenied()) {
|
||||
result = result || rmvDenied(other);
|
||||
}
|
||||
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>
|
||||
* Using the * uuid will remove all users
|
||||
@ -1586,14 +1596,25 @@ public class Plot {
|
||||
public boolean removeTrusted(final UUID uuid) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
boolean result = false;
|
||||
for (final UUID other : new HashSet<>(this.trusted)) {
|
||||
result = result || removeTrusted(other);
|
||||
for (final UUID other : getTrusted()) {
|
||||
result = result || rmvTrusted(other);
|
||||
}
|
||||
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>
|
||||
* Using the * uuid will remove all users
|
||||
@ -1606,13 +1627,24 @@ public class Plot {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
boolean result = false;
|
||||
for (final UUID other : new HashSet<>(this.members)) {
|
||||
result = result || removeMember(other);
|
||||
result = result || rmvMember(other);
|
||||
}
|
||||
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
|
||||
* @return
|
||||
|
@ -49,13 +49,13 @@ public class HastebinUtility {
|
||||
|
||||
public static String upload(final File file) throws IOException {
|
||||
final StringBuilder content = new StringBuilder();
|
||||
final BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
String line;
|
||||
int i = 0;
|
||||
while ((line = reader.readLine()) != null && i++ < 1000) {
|
||||
content.append(line).append("\n");
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
String line;
|
||||
int i = 0;
|
||||
while ((line = reader.readLine()) != null && i++ < 1000) {
|
||||
content.append(line).append("\n");
|
||||
}
|
||||
}
|
||||
reader.close();
|
||||
return upload(content.toString());
|
||||
}
|
||||
|
||||
|
@ -4,13 +4,17 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class DefaultTitle extends AbstractTitle {
|
||||
|
||||
@Override
|
||||
public void sendTitle(final PlotPlayer player, final String head, final String sub, final int in, final int delay, final int out) {
|
||||
try {
|
||||
final DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out);
|
||||
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.sendTitle(player, head, sub, in, delay, out);
|
||||
}
|
||||
|
@ -101,7 +101,8 @@ public class DefaultTitleManager {
|
||||
* Fade out time
|
||||
* @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.subtitle = subtitle;
|
||||
this.fadeInTime = fadeInTime;
|
||||
@ -255,21 +256,22 @@ public class DefaultTitleManager {
|
||||
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
final Object[] actions = packetActions.getEnumConstants();
|
||||
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),
|
||||
stayTime * (ticks ? 1 : 20), fadeOutTime * (ticks ? 1 : 20));
|
||||
Object packet = packetTitle.getConstructor(packetActions, chatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE)
|
||||
.newInstance(actions[2], null, fadeInTime * (ticks ? 1 : 20),
|
||||
stayTime * (ticks ? 1 : 20), fadeOutTime * (ticks ? 1 : 20));
|
||||
// Send if set
|
||||
if (fadeInTime != -1 && fadeOutTime != -1 && stayTime != -1) {
|
||||
sendPacket.invoke(connection, packet);
|
||||
}
|
||||
// Send title
|
||||
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);
|
||||
sendPacket.invoke(connection, packet);
|
||||
if (!subtitle.isEmpty()) {
|
||||
// Send subtitle if present
|
||||
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);
|
||||
sendPacket.invoke(connection, packet);
|
||||
}
|
||||
@ -278,7 +280,8 @@ public class DefaultTitleManager {
|
||||
|
||||
/**
|
||||
* Broadcast the title to all players
|
||||
* @throws Exception
|
||||
* @throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException,
|
||||
SecurityException
|
||||
*/
|
||||
public void broadcast()
|
||||
throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException,
|
||||
|
@ -34,7 +34,7 @@ public class HackTitleManager {
|
||||
private int stayTime = -1;
|
||||
private int fadeOutTime = -1;
|
||||
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
|
||||
|
@ -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;
|
||||
|
||||
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;
|
||||
@ -44,6 +40,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;
|
||||
|
||||
/**
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ public class PlotListener {
|
||||
if (plot.isDenied(pp.getUUID()) && !Permissions.hasPermission(pp, "plots.admin.entry.denied")) {
|
||||
return false;
|
||||
}
|
||||
final Plot last = (Plot) pp.getMeta("lastplot");
|
||||
final Plot last = pp.getMeta("lastplot");
|
||||
if ((last != null) && !last.getId().equals(plot.getId())) {
|
||||
plotExit(pp, last);
|
||||
}
|
||||
@ -82,12 +82,9 @@ public class PlotListener {
|
||||
});
|
||||
} else {
|
||||
greeting = "";
|
||||
}
|
||||
if (greeting != null) {
|
||||
|
||||
}
|
||||
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")) {
|
||||
for (final UUID uuid : plot.getOwners()) {
|
||||
final PlotPlayer owner = UUIDHandler.getPlayer(uuid);
|
||||
@ -128,9 +125,9 @@ public class PlotListener {
|
||||
final Flag musicFlag = flags.get("music");
|
||||
if (musicFlag != null) {
|
||||
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 lastLoc = (Location) pp.getMeta("music");
|
||||
final Location lastLoc = pp.getMeta("music");
|
||||
if (lastLoc != null) {
|
||||
pp.playMusic(lastLoc, 0);
|
||||
if (id == 0) {
|
||||
@ -145,7 +142,7 @@ public class PlotListener {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final Location lastLoc = (Location) pp.getMeta("music");
|
||||
final Location lastLoc = pp.getMeta("music");
|
||||
if (lastLoc != null) {
|
||||
pp.deleteMeta("music");
|
||||
pp.playMusic(lastLoc, 0);
|
||||
@ -162,7 +159,7 @@ public class PlotListener {
|
||||
TaskManager.runTaskLaterAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final Plot lastPlot = (Plot) pp.getMeta("lastplot");
|
||||
final Plot lastPlot = pp.getMeta("lastplot");
|
||||
if ((lastPlot != null) && plot.getId().equals(lastPlot.getId())) {
|
||||
final Map<String, String> replacements = new HashMap<>();
|
||||
replacements.put("%x%", lastPlot.getId().x + "");
|
||||
@ -223,7 +220,7 @@ public class PlotListener {
|
||||
}
|
||||
if (FlagManager.getPlotFlagRaw(plot, "fly") != null) {
|
||||
final PlotGamemode gamemode = pp.getGamemode();
|
||||
if ((gamemode == PlotGamemode.SURVIVAL) || (gamemode == PlotGamemode.ADVENTURE)) {
|
||||
if (gamemode == PlotGamemode.SURVIVAL || (gamemode == PlotGamemode.ADVENTURE)) {
|
||||
pp.setFlight(false);
|
||||
}
|
||||
}
|
||||
@ -233,7 +230,7 @@ public class PlotListener {
|
||||
if (FlagManager.getPlotFlagRaw(plot, "weather") != null) {
|
||||
pp.setWeather(PlotWeather.RESET);
|
||||
}
|
||||
final Location lastLoc = (Location) pp.getMeta("music");
|
||||
final Location lastLoc = pp.getMeta("music");
|
||||
if (lastLoc != null) {
|
||||
pp.deleteMeta("music");
|
||||
pp.playMusic(lastLoc, 0);
|
||||
|
@ -1,8 +1,5 @@
|
||||
package com.plotsquared.listener;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
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.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.*;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
private final HashSet<RegionWrapper> mask;
|
||||
private final String world;
|
||||
@ -95,7 +94,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
final Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
|
||||
field.setAccessible(true);
|
||||
field.set(parent, new NullExtent());
|
||||
field.set(parent, new com.sk89q.worldedit.extent.NullExtent());
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -117,7 +116,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
final Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
|
||||
field.setAccessible(true);
|
||||
field.set(parent, new NullExtent());
|
||||
field.set(parent, new com.sk89q.worldedit.extent.NullExtent());
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -14,9 +14,7 @@ import com.sk89q.worldedit.command.tool.Tool;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.ChangeSetExtent;
|
||||
import com.sk89q.worldedit.extent.MaskingExtent;
|
||||
import com.sk89q.worldedit.extent.*;
|
||||
import com.sk89q.worldedit.extent.reorder.MultiStageReorder;
|
||||
import com.sk89q.worldedit.extent.world.FastModeExtent;
|
||||
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
|
||||
@ -50,7 +48,7 @@ public class WESubscriber {
|
||||
MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASS);
|
||||
}
|
||||
if (PS.get().hasPlotArea(world)) {
|
||||
event.setExtent(new NullExtent());
|
||||
event.setExtent(new com.sk89q.worldedit.extent.NullExtent());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -99,22 +97,20 @@ public class WESubscriber {
|
||||
final ExtentWrapper wrapper = new ExtentWrapper(event.getExtent());
|
||||
event.setExtent(wrapper);
|
||||
field.set(extent, new ProcessedWEExtent(world, mask, max, new FastModeExtent(worldObj, true), wrapper));
|
||||
} else if (fast) {
|
||||
event.setExtent(new ExtentWrapper(extent));
|
||||
} else {
|
||||
if (fast) {
|
||||
event.setExtent(new ExtentWrapper(extent));
|
||||
ExtentWrapper wrapper;
|
||||
if (maskextent != null) {
|
||||
wrapper = new ExtentWrapper(maskextent);
|
||||
field.set(maskextent, history);
|
||||
event.setExtent(wrapper);
|
||||
} else {
|
||||
ExtentWrapper wrapper;
|
||||
if (maskextent != null) {
|
||||
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));
|
||||
wrapper = new ExtentWrapper(history);
|
||||
event.setExtent(wrapper);
|
||||
}
|
||||
field.set(history, reorder);
|
||||
field.set(reorder, new ProcessedWEExtent(world, mask, max, new FastModeExtent(worldObj, true), wrapper));
|
||||
}
|
||||
return;
|
||||
} catch (IllegalAccessException | SecurityException | NoSuchFieldException | IllegalArgumentException e) {
|
||||
|
@ -783,7 +783,7 @@ public class MainListener {
|
||||
if (plotworld == null) {
|
||||
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 Plot lastPlot = pp.getMeta("lastplot");
|
||||
if (id == null) {
|
||||
@ -839,7 +839,7 @@ public class MainListener {
|
||||
if (plotworld == null) {
|
||||
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 Plot lastPlot = pp.getMeta("lastplot");
|
||||
if (id == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user