mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
Optimizations and a purge fix
This commit is contained in:
parent
8243e0118a
commit
4ebd778c62
@ -15,7 +15,7 @@ import java.util.HashMap;
|
|||||||
|
|
||||||
abstract class APlotMeConnector {
|
abstract class APlotMeConnector {
|
||||||
|
|
||||||
public abstract Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder);
|
public abstract Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder);
|
||||||
|
|
||||||
public abstract HashMap<String, HashMap<PlotId, Plot>> getPlotMePlots(Connection connection) throws SQLException;
|
public abstract HashMap<String, HashMap<PlotId, Plot>> getPlotMePlots(Connection connection) throws SQLException;
|
||||||
|
|
||||||
|
@ -30,16 +30,15 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
|||||||
private String prefix;
|
private String prefix;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder) {
|
public Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder) {
|
||||||
this.plugin = plugin.toLowerCase();
|
this.plugin = this.plugin.toLowerCase();
|
||||||
this.prefix = plotConfig.getString("mySQLprefix", plugin.toLowerCase());
|
this.prefix = plotConfig.getString("mySQLprefix", this.plugin.toLowerCase());
|
||||||
try {
|
try {
|
||||||
if (plotConfig.getBoolean("usemySQL")) {
|
if (plotConfig.getBoolean("usemySQL")) {
|
||||||
String user = plotConfig.getString("mySQLuname");
|
String user = plotConfig.getString("mySQLuname");
|
||||||
String password = plotConfig.getString("mySQLpass");
|
String password = plotConfig.getString("mySQLpass");
|
||||||
String con = plotConfig.getString("mySQLconn");
|
String con = plotConfig.getString("mySQLconn");
|
||||||
return DriverManager.getConnection(con, user, password);
|
return DriverManager.getConnection(con, user, password);
|
||||||
// return new MySQL(plotsquared, hostname, port, database, username, password)
|
|
||||||
} else {
|
} else {
|
||||||
return new SQLite(dataFolder + File.separator + "plots.db").openConnection();
|
return new SQLite(dataFolder + File.separator + "plots.db").openConnection();
|
||||||
}
|
}
|
||||||
@ -110,17 +109,13 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
|||||||
owner = DBFunc.everyone;
|
owner = DBFunc.everyone;
|
||||||
} else {
|
} else {
|
||||||
if (checkUUID || checkUUID2) {
|
if (checkUUID || checkUUID2) {
|
||||||
try {
|
byte[] bytes = resultSet.getBytes(column);
|
||||||
byte[] bytes = resultSet.getBytes(column);
|
if (bytes != null) {
|
||||||
if (bytes != null) {
|
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
long high = bb.getLong();
|
||||||
long high = bb.getLong();
|
long low = bb.getLong();
|
||||||
long low = bb.getLong();
|
owner = new UUID(high, low);
|
||||||
owner = new UUID(high, low);
|
UUIDHandler.add(new StringWrapper(name), owner);
|
||||||
UUIDHandler.add(new StringWrapper(name), owner);
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
@ -173,17 +168,13 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
|||||||
if ("*".equals(name)) {
|
if ("*".equals(name)) {
|
||||||
denied = DBFunc.everyone;
|
denied = DBFunc.everyone;
|
||||||
} else if (DBFunc.hasColumn(resultSet, "playerid")) {
|
} else if (DBFunc.hasColumn(resultSet, "playerid")) {
|
||||||
try {
|
byte[] bytes = resultSet.getBytes("playerid");
|
||||||
byte[] bytes = resultSet.getBytes("playerid");
|
if (bytes != null) {
|
||||||
if (bytes != null) {
|
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
long mostSigBits = bb.getLong();
|
||||||
long mostSigBits = bb.getLong();
|
long leastSigBits = bb.getLong();
|
||||||
long leastSigBits = bb.getLong();
|
denied = new UUID(mostSigBits, leastSigBits);
|
||||||
denied = new UUID(mostSigBits, leastSigBits);
|
UUIDHandler.add(new StringWrapper(name), denied);
|
||||||
UUIDHandler.add(new StringWrapper(name), denied);
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (denied == null) {
|
if (denied == null) {
|
||||||
@ -212,17 +203,13 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
|||||||
if ("*".equals(name)) {
|
if ("*".equals(name)) {
|
||||||
helper = DBFunc.everyone;
|
helper = DBFunc.everyone;
|
||||||
} else if (DBFunc.hasColumn(resultSet, "playerid")) {
|
} else if (DBFunc.hasColumn(resultSet, "playerid")) {
|
||||||
try {
|
byte[] bytes = resultSet.getBytes("playerid");
|
||||||
byte[] bytes = resultSet.getBytes("playerid");
|
if (bytes != null) {
|
||||||
if (bytes != null) {
|
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
long mostSigBits = bb.getLong();
|
||||||
long mostSigBits = bb.getLong();
|
long leastSigBits = bb.getLong();
|
||||||
long leastSigBits = bb.getLong();
|
helper = new UUID(mostSigBits, leastSigBits);
|
||||||
helper = new UUID(mostSigBits, leastSigBits);
|
UUIDHandler.add(new StringWrapper(name), helper);
|
||||||
UUIDHandler.add(new StringWrapper(name), helper);
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (helper == null) {
|
if (helper == null) {
|
||||||
|
@ -63,10 +63,10 @@ public class LikePlotMeConverter {
|
|||||||
return plotConfig.getConfigurationSection("worlds").getKeys(false);
|
return plotConfig.getConfigurationSection("worlds").getKeys(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mergeWorldYml(String plugin, FileConfiguration plotConfig) {
|
public void mergeWorldYml(FileConfiguration plotConfig) {
|
||||||
try {
|
try {
|
||||||
File genConfig =
|
File genConfig =
|
||||||
new File("plugins" + File.separator + plugin + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
new File("plugins" + File.separator + "PlotMe" + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
||||||
if (genConfig.exists()) {
|
if (genConfig.exists()) {
|
||||||
YamlConfiguration yml = YamlConfiguration.loadConfiguration(genConfig);
|
YamlConfiguration yml = YamlConfiguration.loadConfiguration(genConfig);
|
||||||
for (String key : yml.getKeys(true)) {
|
for (String key : yml.getKeys(true)) {
|
||||||
@ -83,7 +83,7 @@ public class LikePlotMeConverter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateWorldYml(String plugin, String location) {
|
public void updateWorldYml(String location) {
|
||||||
try {
|
try {
|
||||||
Path path = Paths.get(location);
|
Path path = Paths.get(location);
|
||||||
File file = new File(location);
|
File file = new File(location);
|
||||||
@ -92,7 +92,7 @@ public class LikePlotMeConverter {
|
|||||||
}
|
}
|
||||||
String content = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
|
String content = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
|
||||||
content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared");
|
content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared");
|
||||||
content = content.replaceAll(plugin, "PlotSquared");
|
content = content.replaceAll("PlotMe", "PlotSquared");
|
||||||
Files.write(path, content.getBytes(StandardCharsets.UTF_8));
|
Files.write(path, content.getBytes(StandardCharsets.UTF_8));
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
//ignored
|
//ignored
|
||||||
@ -117,7 +117,7 @@ public class LikePlotMeConverter {
|
|||||||
|
|
||||||
PS.debug("&3Using connector: " + connector.getClass().getCanonicalName());
|
PS.debug("&3Using connector: " + connector.getClass().getCanonicalName());
|
||||||
|
|
||||||
Connection connection = connector.getPlotMeConnection("PlotMe", plotConfig, dataFolder);
|
Connection connection = connector.getPlotMeConnection(plotConfig, dataFolder);
|
||||||
|
|
||||||
if (!connector.isValidConnection(connection)) {
|
if (!connector.isValidConnection(connection)) {
|
||||||
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
|
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
|
||||||
@ -126,7 +126,7 @@ public class LikePlotMeConverter {
|
|||||||
|
|
||||||
sendMessage("PlotMe conversion has started. To disable this, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
|
sendMessage("PlotMe conversion has started. To disable this, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
|
||||||
|
|
||||||
mergeWorldYml("PlotMe", plotConfig);
|
mergeWorldYml(plotConfig);
|
||||||
|
|
||||||
sendMessage("Connecting to PlotMe DB");
|
sendMessage("Connecting to PlotMe DB");
|
||||||
|
|
||||||
@ -140,8 +140,8 @@ public class LikePlotMeConverter {
|
|||||||
|
|
||||||
if (Settings.CONVERT_PLOTME) {
|
if (Settings.CONVERT_PLOTME) {
|
||||||
sendMessage("Updating bukkit.yml");
|
sendMessage("Updating bukkit.yml");
|
||||||
updateWorldYml("PlotMe", "bukkit.yml");
|
updateWorldYml("bukkit.yml");
|
||||||
updateWorldYml("PlotMe", "plugins/Multiverse-Core/worlds.yml");
|
updateWorldYml("plugins/Multiverse-Core/worlds.yml");
|
||||||
for (String world : plotConfig.getConfigurationSection("worlds").getKeys(false)) {
|
for (String world : plotConfig.getConfigurationSection("worlds").getKeys(false)) {
|
||||||
sendMessage("Copying config for: " + world);
|
sendMessage("Copying config for: " + world);
|
||||||
try {
|
try {
|
||||||
|
@ -26,8 +26,8 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
|||||||
private String plugin;
|
private String plugin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder) {
|
public Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder) {
|
||||||
this.plugin = plugin.toLowerCase();
|
this.plugin = this.plugin.toLowerCase();
|
||||||
try {
|
try {
|
||||||
if (plotConfig.getBoolean("usemySQL")) {
|
if (plotConfig.getBoolean("usemySQL")) {
|
||||||
String user = plotConfig.getString("mySQLuname");
|
String user = plotConfig.getString("mySQLuname");
|
||||||
@ -109,14 +109,10 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
|||||||
owner = DBFunc.everyone;
|
owner = DBFunc.everyone;
|
||||||
} else {
|
} else {
|
||||||
if (checkUUID) {
|
if (checkUUID) {
|
||||||
try {
|
byte[] bytes = resultSet.getBytes("ownerid");
|
||||||
byte[] bytes = resultSet.getBytes("ownerid");
|
if (bytes != null) {
|
||||||
if (bytes != null) {
|
owner = UUID.nameUUIDFromBytes(bytes);
|
||||||
owner = UUID.nameUUIDFromBytes(bytes);
|
UUIDHandler.add(new StringWrapper(name), owner);
|
||||||
UUIDHandler.add(new StringWrapper(name), owner);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
|
@ -34,14 +34,14 @@ import org.bukkit.util.Vector;
|
|||||||
|
|
||||||
public class EntityWrapper {
|
public class EntityWrapper {
|
||||||
|
|
||||||
|
public final EntityType type;
|
||||||
|
public final float yaw;
|
||||||
|
public final float pitch;
|
||||||
|
public final short depth;
|
||||||
private final int hash;
|
private final int hash;
|
||||||
public EntityType type;
|
|
||||||
public float yaw;
|
|
||||||
public float pitch;
|
|
||||||
public double x;
|
public double x;
|
||||||
public double y;
|
public double y;
|
||||||
public double z;
|
public double z;
|
||||||
public short depth;
|
|
||||||
public EntityBaseStats base = null;
|
public EntityBaseStats base = null;
|
||||||
// Extended
|
// Extended
|
||||||
public ItemStack stack;
|
public ItemStack stack;
|
||||||
|
@ -8,11 +8,6 @@ import com.intellectualcrafters.jnbt.Tag;
|
|||||||
import com.intellectualcrafters.plot.object.schematic.ItemType;
|
import com.intellectualcrafters.plot.object.schematic.ItemType;
|
||||||
import com.intellectualcrafters.plot.util.MathMan;
|
import com.intellectualcrafters.plot.util.MathMan;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
@ -21,6 +16,12 @@ import org.bukkit.inventory.Inventory;
|
|||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
public class StateWrapper {
|
public class StateWrapper {
|
||||||
|
|
||||||
public BlockState state = null;
|
public BlockState state = null;
|
||||||
@ -38,8 +39,8 @@ public class StateWrapper {
|
|||||||
if (this.tag == null) {
|
if (this.tag == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (tag.getString("id").toLowerCase()) {
|
switch (this.tag.getString("id").toLowerCase()) {
|
||||||
case "chest": {
|
case "chest":
|
||||||
List<Tag> itemsTag = this.tag.getListTag("Items").getValue();
|
List<Tag> itemsTag = this.tag.getListTag("Items").getValue();
|
||||||
int length = itemsTag.size();
|
int length = itemsTag.size();
|
||||||
short[] ids = new short[length];
|
short[] ids = new short[length];
|
||||||
@ -75,9 +76,7 @@ public class StateWrapper {
|
|||||||
}
|
}
|
||||||
state.update(true);
|
state.update(true);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -43,9 +43,8 @@ public class DefaultTitleManager {
|
|||||||
* Create a new 1.8 title.
|
* Create a new 1.8 title.
|
||||||
*
|
*
|
||||||
* @param title Title
|
* @param title Title
|
||||||
* @throws ClassNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public DefaultTitleManager(String title) throws ClassNotFoundException {
|
public DefaultTitleManager(String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
loadClasses();
|
loadClasses();
|
||||||
}
|
}
|
||||||
@ -55,9 +54,8 @@ public class DefaultTitleManager {
|
|||||||
*
|
*
|
||||||
* @param title Title text
|
* @param title Title text
|
||||||
* @param subtitle Subtitle text
|
* @param subtitle Subtitle text
|
||||||
* @throws ClassNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public DefaultTitleManager(String title, String subtitle) throws ClassNotFoundException {
|
public DefaultTitleManager(String title, String subtitle) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.subtitle = subtitle;
|
this.subtitle = subtitle;
|
||||||
loadClasses();
|
loadClasses();
|
||||||
@ -67,9 +65,8 @@ public class DefaultTitleManager {
|
|||||||
* Copy 1.8 title.
|
* Copy 1.8 title.
|
||||||
*
|
*
|
||||||
* @param title Title
|
* @param title Title
|
||||||
* @throws ClassNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public DefaultTitleManager(DefaultTitleManager title) throws ClassNotFoundException {
|
public DefaultTitleManager(DefaultTitleManager title) {
|
||||||
// Copy title
|
// Copy title
|
||||||
this.title = title.title;
|
this.title = title.title;
|
||||||
this.subtitle = title.subtitle;
|
this.subtitle = title.subtitle;
|
||||||
@ -90,10 +87,8 @@ public class DefaultTitleManager {
|
|||||||
* @param fadeInTime Fade in time
|
* @param fadeInTime Fade in time
|
||||||
* @param stayTime Stay on screen time
|
* @param stayTime Stay on screen time
|
||||||
* @param fadeOutTime Fade out time
|
* @param fadeOutTime Fade out time
|
||||||
* @throws ClassNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public DefaultTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime)
|
public DefaultTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
|
||||||
throws ClassNotFoundException {
|
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.subtitle = subtitle;
|
this.subtitle = subtitle;
|
||||||
this.fadeInTime = fadeInTime;
|
this.fadeInTime = fadeInTime;
|
||||||
|
@ -42,11 +42,9 @@ public class DefaultTitleManager_183 {
|
|||||||
/**
|
/**
|
||||||
* Create a new 1.8 title
|
* Create a new 1.8 title
|
||||||
*
|
*
|
||||||
* @param title
|
* @param title Title
|
||||||
* Title
|
|
||||||
* @throws ClassNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public DefaultTitleManager_183(String title) throws ClassNotFoundException {
|
public DefaultTitleManager_183(String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
loadClasses();
|
loadClasses();
|
||||||
}
|
}
|
||||||
@ -56,9 +54,8 @@ public class DefaultTitleManager_183 {
|
|||||||
*
|
*
|
||||||
* @param title Title text
|
* @param title Title text
|
||||||
* @param subtitle Subtitle text
|
* @param subtitle Subtitle text
|
||||||
* @throws ClassNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public DefaultTitleManager_183(String title, String subtitle) throws ClassNotFoundException {
|
public DefaultTitleManager_183(String title, String subtitle) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.subtitle = subtitle;
|
this.subtitle = subtitle;
|
||||||
loadClasses();
|
loadClasses();
|
||||||
@ -68,9 +65,8 @@ public class DefaultTitleManager_183 {
|
|||||||
* Copy 1.8 title.
|
* Copy 1.8 title.
|
||||||
*
|
*
|
||||||
* @param title Title
|
* @param title Title
|
||||||
* @throws ClassNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public DefaultTitleManager_183(DefaultTitleManager_183 title) throws ClassNotFoundException {
|
public DefaultTitleManager_183(DefaultTitleManager_183 title) {
|
||||||
// Copy title
|
// Copy title
|
||||||
this.title = title.title;
|
this.title = title.title;
|
||||||
this.subtitle = title.subtitle;
|
this.subtitle = title.subtitle;
|
||||||
@ -91,9 +87,8 @@ public class DefaultTitleManager_183 {
|
|||||||
* @param fadeInTime Fade in time
|
* @param fadeInTime Fade in time
|
||||||
* @param stayTime Stay on screen time
|
* @param stayTime Stay on screen time
|
||||||
* @param fadeOutTime Fade out time
|
* @param fadeOutTime Fade out time
|
||||||
* @throws ClassNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public DefaultTitleManager_183(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) throws ClassNotFoundException {
|
public DefaultTitleManager_183(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.subtitle = subtitle;
|
this.subtitle = subtitle;
|
||||||
this.fadeInTime = fadeInTime;
|
this.fadeInTime = fadeInTime;
|
||||||
|
@ -42,9 +42,8 @@ public class HackTitleManager {
|
|||||||
* Create a new 1.8 title.
|
* Create a new 1.8 title.
|
||||||
*
|
*
|
||||||
* @param title Title
|
* @param title Title
|
||||||
* @throws ClassNotFoundException NMS Error.
|
|
||||||
*/
|
*/
|
||||||
public HackTitleManager(String title) throws ClassNotFoundException {
|
public HackTitleManager(String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
loadClasses();
|
loadClasses();
|
||||||
}
|
}
|
||||||
@ -54,9 +53,8 @@ public class HackTitleManager {
|
|||||||
*
|
*
|
||||||
* @param title Title text
|
* @param title Title text
|
||||||
* @param subtitle Subtitle text
|
* @param subtitle Subtitle text
|
||||||
* @throws ClassNotFoundException NMS Error
|
|
||||||
*/
|
*/
|
||||||
public HackTitleManager(String title, String subtitle) throws ClassNotFoundException {
|
public HackTitleManager(String title, String subtitle) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.subtitle = subtitle;
|
this.subtitle = subtitle;
|
||||||
loadClasses();
|
loadClasses();
|
||||||
@ -66,9 +64,8 @@ public class HackTitleManager {
|
|||||||
* Copy 1.8 title.
|
* Copy 1.8 title.
|
||||||
*
|
*
|
||||||
* @param title Title
|
* @param title Title
|
||||||
* @throws ClassNotFoundException NMS Error
|
|
||||||
*/
|
*/
|
||||||
public HackTitleManager(HackTitleManager title) throws ClassNotFoundException {
|
public HackTitleManager(HackTitleManager title) {
|
||||||
// Copy title
|
// Copy title
|
||||||
this.title = title.title;
|
this.title = title.title;
|
||||||
this.subtitle = title.subtitle;
|
this.subtitle = title.subtitle;
|
||||||
@ -89,9 +86,8 @@ public class HackTitleManager {
|
|||||||
* @param fadeInTime Fade in time
|
* @param fadeInTime Fade in time
|
||||||
* @param stayTime Stay on screen time
|
* @param stayTime Stay on screen time
|
||||||
* @param fadeOutTime Fade out time
|
* @param fadeOutTime Fade out time
|
||||||
* @throws ClassNotFoundException NMS error
|
|
||||||
*/
|
*/
|
||||||
public HackTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) throws ClassNotFoundException {
|
public HackTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.subtitle = subtitle;
|
this.subtitle = subtitle;
|
||||||
this.fadeInTime = fadeInTime;
|
this.fadeInTime = fadeInTime;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -53,6 +53,6 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
|||||||
for (Object o : objects) {
|
for (Object o : objects) {
|
||||||
result.add(o.toString());
|
result.add(o.toString());
|
||||||
}
|
}
|
||||||
return result.size() == 0 ? null : result;
|
return result.isEmpty() ? null : result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ public class SendChunk {
|
|||||||
RefClass classChunk = getRefClass("{nms}.Chunk");
|
RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||||
this.methodInitLighting = classChunk.getMethod("initLighting");
|
this.methodInitLighting = classChunk.getMethod("initLighting");
|
||||||
RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
|
RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
|
||||||
|
//TODO in 1.7.10 this is PacketPlayOutMapChunk(Chunk chunk, boolean flag, int i, int version)
|
||||||
this.mapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class);
|
this.mapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class);
|
||||||
RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer");
|
RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer");
|
||||||
this.connection = classEntityPlayer.getField("playerConnection");
|
this.connection = classEntityPlayer.getField("playerConnection");
|
||||||
|
@ -537,16 +537,16 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getStringList(String path) {
|
public List<String> getStringList(String path) {
|
||||||
final List<?> list = getList(path);
|
List<?> list = getList(path);
|
||||||
|
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
return new ArrayList<>(0);
|
return new ArrayList<>(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
|
|
||||||
for (final Object object : list) {
|
for (Object object : list) {
|
||||||
if ((object instanceof String) || (isPrimitiveWrapper(object))) {
|
if ((object instanceof String) || isPrimitiveWrapper(object)) {
|
||||||
result.add(String.valueOf(object));
|
result.add(String.valueOf(object));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,8 +67,14 @@ public class Inbox extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||||
|
|
||||||
final Plot plot = player.getCurrentPlot();
|
final Plot plot = player.getCurrentPlot();
|
||||||
|
if (plot == null) {
|
||||||
|
sendMessage(player, C.NOT_IN_PLOT);
|
||||||
|
return false;
|
||||||
|
} else if (!plot.hasOwner()) {
|
||||||
|
sendMessage(player, C.PLOT_UNOWNED);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox [inbox] [delete <index>|clear|page]");
|
sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox [inbox] [delete <index>|clear|page]");
|
||||||
for (final CommentInbox inbox : CommentManager.inboxes.values()) {
|
for (final CommentInbox inbox : CommentManager.inboxes.values()) {
|
||||||
@ -183,11 +189,7 @@ public class Inbox extends SubCommand {
|
|||||||
displayComments(player, value, page);
|
displayComments(player, value, page);
|
||||||
}
|
}
|
||||||
})) {
|
})) {
|
||||||
if (plot == null) {
|
sendMessage(player, C.PLOT_UNOWNED);
|
||||||
sendMessage(player, C.NOT_IN_PLOT);
|
|
||||||
} else {
|
|
||||||
sendMessage(player, C.PLOT_UNOWNED);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -11,6 +11,7 @@ import com.intellectualcrafters.plot.util.CmdConfirm;
|
|||||||
import com.intellectualcrafters.plot.util.StringMan;
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
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 com.plotsquared.listener.PlotListener;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -150,9 +151,10 @@ public class Purge extends SubCommand {
|
|||||||
if (plot.temp != Integer.MAX_VALUE) {
|
if (plot.temp != Integer.MAX_VALUE) {
|
||||||
ids.add(plot.temp);
|
ids.add(plot.temp);
|
||||||
plot.getArea().removePlot(plot.getId());
|
plot.getArea().removePlot(plot.getId());
|
||||||
for (PlotPlayer plotPlayer : plot.getPlayersInPlot()) {
|
for (PlotPlayer pp : plot.getPlayersInPlot()) {
|
||||||
plotPlayer.deleteMeta("lastplot");
|
PlotListener.plotEntry(pp, plot);
|
||||||
}
|
}
|
||||||
|
plot.removeSign();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DBFunc.purgeIds(ids);
|
DBFunc.purgeIds(ids);
|
||||||
|
@ -290,7 +290,7 @@ public class DBFunc {
|
|||||||
* @param comment
|
* @param comment
|
||||||
*/
|
*/
|
||||||
public static void removeComment(Plot plot, PlotComment comment) {
|
public static void removeComment(Plot plot, PlotComment comment) {
|
||||||
if (plot != null && plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DBFunc.dbManager.removeComment(plot, comment);
|
DBFunc.dbManager.removeComment(plot, comment);
|
||||||
|
@ -3147,7 +3147,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
public abstract class UniqueStatement {
|
public abstract class UniqueStatement {
|
||||||
|
|
||||||
public String method;
|
public final String method;
|
||||||
|
|
||||||
public UniqueStatement(String method) {
|
public UniqueStatement(String method) {
|
||||||
this.method = method;
|
this.method = method;
|
||||||
|
@ -214,7 +214,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
HashMap<BlockLoc, CompoundTag> items = schematic3.getTiles();
|
HashMap<BlockLoc, CompoundTag> items = schematic3.getTiles();
|
||||||
if (items.size() > 0) {
|
if (!items.isEmpty()) {
|
||||||
this.G_SCH_STATE = new HashMap<>();
|
this.G_SCH_STATE = new HashMap<>();
|
||||||
for (Map.Entry<BlockLoc, CompoundTag> entry : items.entrySet()) {
|
for (Map.Entry<BlockLoc, CompoundTag> entry : items.entrySet()) {
|
||||||
BlockLoc loc = entry.getKey();
|
BlockLoc loc = entry.getKey();
|
||||||
|
@ -20,6 +20,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
|||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||||
import com.plotsquared.listener.PlotListener;
|
import com.plotsquared.listener.PlotListener;
|
||||||
|
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
import java.awt.geom.PathIterator;
|
import java.awt.geom.PathIterator;
|
||||||
@ -765,8 +766,8 @@ public class Plot {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (queue.isEmpty()) {
|
if (queue.isEmpty()) {
|
||||||
final AtomicInteger finished = new AtomicInteger(0);
|
AtomicInteger finished = new AtomicInteger(0);
|
||||||
final Runnable run = new Runnable() {
|
Runnable run = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (RegionWrapper region : regions) {
|
for (RegionWrapper region : regions) {
|
||||||
@ -794,11 +795,11 @@ public class Plot {
|
|||||||
manager.clearPlot(Plot.this.area, current, this);
|
manager.clearPlot(Plot.this.area, current, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (!isMerged() && area.getRegion().equals(getLargestRegion())) {
|
if (!isMerged() && this.area.getRegion().equals(getLargestRegion())) {
|
||||||
ChunkManager.largeRegionTask(area.worldname, area.getRegion(), new RunnableVal<ChunkLoc>() {
|
ChunkManager.largeRegionTask(this.area.worldname, this.area.getRegion(), new RunnableVal<ChunkLoc>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(ChunkLoc value) {
|
public void run(ChunkLoc value) {
|
||||||
ChunkManager.manager.regenerateChunk(area.worldname, value);
|
ChunkManager.manager.regenerateChunk(Plot.this.area.worldname, value);
|
||||||
}
|
}
|
||||||
}, whenDone);
|
}, whenDone);
|
||||||
} else {
|
} else {
|
||||||
@ -1773,7 +1774,7 @@ public class Plot {
|
|||||||
* Upload this plot as a world file<br>
|
* Upload this plot as a world file<br>
|
||||||
* - The mca files are each 512x512, so depending on the plot size it may also download adjacent plots<br>
|
* - The mca files are each 512x512, so depending on the plot size it may also download adjacent plots<br>
|
||||||
* - Works best when (plot width + road width) % 512 == 0<br>
|
* - Works best when (plot width + road width) % 512 == 0<br>
|
||||||
* @see com.intellectualcrafters.plot.util.WorldUtil
|
* @see WorldUtil
|
||||||
* @param whenDone
|
* @param whenDone
|
||||||
*/
|
*/
|
||||||
public void uploadWorld(RunnableVal<URL> whenDone) {
|
public void uploadWorld(RunnableVal<URL> whenDone) {
|
||||||
@ -1784,7 +1785,7 @@ public class Plot {
|
|||||||
* Upload this plot as a BO3<br>
|
* Upload this plot as a BO3<br>
|
||||||
* - May not work on non default generator<br>
|
* - May not work on non default generator<br>
|
||||||
* - BO3 includes flags/ignores plot main/floor block<br>
|
* - BO3 includes flags/ignores plot main/floor block<br>
|
||||||
* @see com.intellectualcrafters.plot.util.BO3Handler
|
* @see BO3Handler
|
||||||
* @param whenDone
|
* @param whenDone
|
||||||
*/
|
*/
|
||||||
public void uploadBO3(RunnableVal<URL> whenDone) {
|
public void uploadBO3(RunnableVal<URL> whenDone) {
|
||||||
@ -1991,8 +1992,6 @@ public class Plot {
|
|||||||
int index = caption.indexOf("%plr%");
|
int index = caption.indexOf("%plr%");
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
continue;
|
continue;
|
||||||
} else if (index < -1) {
|
|
||||||
PS.debug("This should NEVER happen. Seriously, it's impossible.");
|
|
||||||
}
|
}
|
||||||
String line = lines[i - 1];
|
String line = lines[i - 1];
|
||||||
if (line.length() <= index) {
|
if (line.length() <= index) {
|
||||||
@ -2487,7 +2486,7 @@ public class Plot {
|
|||||||
RegionWrapper max = null;
|
RegionWrapper max = null;
|
||||||
double area = Double.NEGATIVE_INFINITY;
|
double area = Double.NEGATIVE_INFINITY;
|
||||||
for (RegionWrapper region : regions) {
|
for (RegionWrapper region : regions) {
|
||||||
double current = ((region.maxX - (double) region.minX + 1)) * (region.maxZ - (double) region.minZ + 1);
|
double current = (region.maxX - (double) region.minX + 1) * (region.maxZ - (double) region.minZ + 1);
|
||||||
if (current > area) {
|
if (current > area) {
|
||||||
max = region;
|
max = region;
|
||||||
area = current;
|
area = current;
|
||||||
|
@ -19,7 +19,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
public class PlotAnalysis {
|
public class PlotAnalysis {
|
||||||
|
|
||||||
public static PlotAnalysis MODIFIERS = new PlotAnalysis();
|
public static final PlotAnalysis MODIFIERS = new PlotAnalysis();
|
||||||
public static boolean running = false;
|
public static boolean running = false;
|
||||||
public int changes;
|
public int changes;
|
||||||
public int faces;
|
public int faces;
|
||||||
|
@ -3,28 +3,28 @@ package com.intellectualcrafters.plot.object;
|
|||||||
public class PlotLoc {
|
public class PlotLoc {
|
||||||
public int x;
|
public int x;
|
||||||
public int z;
|
public int z;
|
||||||
|
|
||||||
public PlotLoc(final int x, final int z) {
|
public PlotLoc(int x, int z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = (prime * result) + x;
|
result = (prime * result) + this.x;
|
||||||
result = (prime * result) + z;
|
result = (prime * result) + this.z;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return x + "," + z;
|
return this.x + "," + this.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ public class PlotLoc {
|
|||||||
if (getClass() != obj.getClass()) {
|
if (getClass() != obj.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final PlotLoc other = (PlotLoc) obj;
|
PlotLoc other = (PlotLoc) obj;
|
||||||
return ((x == other.x) && (z == other.z));
|
return (this.x == other.x) && (this.z == other.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,50 +10,50 @@ public class PlotMessage {
|
|||||||
public PlotMessage() {
|
public PlotMessage() {
|
||||||
reset(ChatManager.manager);
|
reset(ChatManager.manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T $(final ChatManager<T> manager) {
|
public PlotMessage(String text) {
|
||||||
return (T) builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlotMessage(final String text) {
|
|
||||||
this();
|
this();
|
||||||
text(text);
|
text(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T reset(ChatManager<T> manager) {
|
public <T> T $(ChatManager<T> manager) {
|
||||||
return (T) (builder = manager.builder());
|
return (T) this.builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotMessage text(final String text) {
|
public <T> T reset(ChatManager<T> manager) {
|
||||||
|
return (T) (this.builder = manager.builder());
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlotMessage text(String text) {
|
||||||
ChatManager.manager.text(this, text);
|
ChatManager.manager.text(this, text);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotMessage tooltip(final PlotMessage... tooltip) {
|
public PlotMessage tooltip(PlotMessage... tooltip) {
|
||||||
ChatManager.manager.tooltip(this, tooltip);
|
ChatManager.manager.tooltip(this, tooltip);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotMessage tooltip(final String tooltip) {
|
public PlotMessage tooltip(String tooltip) {
|
||||||
return tooltip(new PlotMessage(tooltip));
|
return tooltip(new PlotMessage(tooltip));
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotMessage command(final String command) {
|
public PlotMessage command(String command) {
|
||||||
ChatManager.manager.command(this, command);
|
ChatManager.manager.command(this, command);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotMessage suggest(final String command) {
|
public PlotMessage suggest(String command) {
|
||||||
ChatManager.manager.suggest(this, command);
|
ChatManager.manager.suggest(this, command);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotMessage color(final String color) {
|
public PlotMessage color(String color) {
|
||||||
ChatManager.manager.color(this, C.color(color));
|
ChatManager.manager.color(this, C.color(color));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(final PlotPlayer player) {
|
public void send(PlotPlayer player) {
|
||||||
ChatManager.manager.send(this, player);
|
ChatManager.manager.send(this, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.intellectualcrafters.plot.object.comment;
|
package com.intellectualcrafters.plot.object.comment;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
@ -18,7 +19,7 @@ public abstract class CommentInbox {
|
|||||||
public abstract boolean canModify(Plot plot, PlotPlayer player);
|
public abstract boolean canModify(Plot plot, PlotPlayer player);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The plot may be null if the user is not standing in a plot. Return false if this is not a plot-less inbox.
|
*
|
||||||
* <br>
|
* <br>
|
||||||
* The `whenDone` parameter should be executed when it's done fetching the comments.
|
* The `whenDone` parameter should be executed when it's done fetching the comments.
|
||||||
* The value should be set to List of comments
|
* The value should be set to List of comments
|
||||||
@ -31,7 +32,11 @@ public abstract class CommentInbox {
|
|||||||
|
|
||||||
public abstract boolean addComment(Plot plot, PlotComment comment);
|
public abstract boolean addComment(Plot plot, PlotComment comment);
|
||||||
|
|
||||||
public abstract boolean removeComment(Plot plot, PlotComment comment);
|
public void removeComment(Plot plot, PlotComment comment) {
|
||||||
|
DBFunc.removeComment(plot, comment);
|
||||||
|
}
|
||||||
|
|
||||||
public abstract boolean clearInbox(Plot plot);
|
public void clearInbox(Plot plot) {
|
||||||
|
DBFunc.clearInbox(plot, toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,45 +12,38 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class InboxOwner extends CommentInbox {
|
public class InboxOwner extends CommentInbox {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canRead(Plot plot, PlotPlayer player) {
|
public boolean canRead(Plot plot, PlotPlayer player) {
|
||||||
if (plot == null) {
|
if (Permissions.hasPermission(player, "plots.inbox.read." + toString())) {
|
||||||
return Permissions.hasPermission(player, "plots.inbox.read." + toString());
|
if (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.read." + toString() + ".other")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
return false;
|
||||||
.hasPermission(player, "plots.inbox.read."
|
|
||||||
+ toString()
|
|
||||||
+ ".other"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canWrite(Plot plot, PlotPlayer player) {
|
public boolean canWrite(Plot plot, PlotPlayer player) {
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return Permissions.hasPermission(player, "plots.inbox.write." + toString());
|
return Permissions.hasPermission(player, "plots.inbox.write." + toString());
|
||||||
}
|
}
|
||||||
return Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
return Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
||||||
.hasPermission(player, "plots.inbox.write."
|
.hasPermission(player, "plots.inbox.write." + toString() + ".other"));
|
||||||
+ toString()
|
|
||||||
+ ".other"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canModify(Plot plot, PlotPlayer player) {
|
public boolean canModify(Plot plot, PlotPlayer player) {
|
||||||
if (plot == null) {
|
if (Permissions.hasPermission(player, "plots.inbox.modify." + toString())) {
|
||||||
return Permissions.hasPermission(player, "plots.inbox.modify." + toString());
|
if (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.modify." + toString() + ".other")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
return false;
|
||||||
.hasPermission(player, "plots.inbox.modify."
|
|
||||||
+ toString()
|
|
||||||
+ ".other"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getComments(final Plot plot, final RunnableVal<List<PlotComment>> whenDone) {
|
public boolean getComments(final Plot plot, final RunnableVal<List<PlotComment>> whenDone) {
|
||||||
if ((plot == null) || (plot.owner == null)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(toString());
|
Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(toString());
|
||||||
if (comments.isPresent()) {
|
if (comments.isPresent()) {
|
||||||
whenDone.value = comments.get();
|
whenDone.value = comments.get();
|
||||||
@ -73,7 +66,7 @@ public class InboxOwner extends CommentInbox {
|
|||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addComment(Plot plot, PlotComment comment) {
|
public boolean addComment(Plot plot, PlotComment comment) {
|
||||||
if (plot.owner == null) {
|
if (plot.owner == null) {
|
||||||
@ -83,27 +76,10 @@ public class InboxOwner extends CommentInbox {
|
|||||||
DBFunc.setComment(plot, comment);
|
DBFunc.setComment(plot, comment);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "owner";
|
return "owner";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean removeComment(Plot plot, PlotComment comment) {
|
|
||||||
if ((plot == null) || (plot.owner == null)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
DBFunc.removeComment(plot, comment);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean clearInbox(Plot plot) {
|
|
||||||
if (plot == null || plot.owner == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
DBFunc.clearInbox(plot, this.toString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,12 @@ public class InboxPublic extends CommentInbox {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canRead(Plot plot, PlotPlayer player) {
|
public boolean canRead(Plot plot, PlotPlayer player) {
|
||||||
if (plot == null) {
|
if (Permissions.hasPermission(player, "plots.inbox.read." + toString())) {
|
||||||
return Permissions.hasPermission(player, "plots.inbox.read." + toString());
|
if (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.read." + toString() + ".other")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
return false;
|
||||||
.hasPermission(player, "plots.inbox.read."
|
|
||||||
+ toString()
|
|
||||||
+ ".other"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -35,18 +34,16 @@ public class InboxPublic extends CommentInbox {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canModify(Plot plot, PlotPlayer player) {
|
public boolean canModify(Plot plot, PlotPlayer player) {
|
||||||
if (plot == null) {
|
if (Permissions.hasPermission(player, "plots.inbox.modify." + toString())) {
|
||||||
return Permissions.hasPermission(player, "plots.inbox.modify." + toString());
|
if (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.modify." + toString() + ".other")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
return false;
|
||||||
.hasPermission(player, "plots.inbox.modify." + toString() + ".other"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getComments(final Plot plot, final RunnableVal<List<PlotComment>> whenDone) {
|
public boolean getComments(final Plot plot, final RunnableVal<List<PlotComment>> whenDone) {
|
||||||
if (plot.owner == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(toString());
|
Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(toString());
|
||||||
if (comments.isPresent()) {
|
if (comments.isPresent()) {
|
||||||
whenDone.value = comments.get();
|
whenDone.value = comments.get();
|
||||||
@ -70,9 +67,6 @@ public class InboxPublic extends CommentInbox {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addComment(Plot plot, PlotComment comment) {
|
public boolean addComment(Plot plot, PlotComment comment) {
|
||||||
if (plot.owner == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
plot.getSettings().addComment(comment);
|
plot.getSettings().addComment(comment);
|
||||||
DBFunc.setComment(plot, comment);
|
DBFunc.setComment(plot, comment);
|
||||||
return true;
|
return true;
|
||||||
@ -82,22 +76,6 @@ public class InboxPublic extends CommentInbox {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "public";
|
return "public";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean removeComment(Plot plot, PlotComment comment) {
|
|
||||||
if ((plot == null) || (plot.owner == null)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
DBFunc.removeComment(plot, comment);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean clearInbox(Plot plot) {
|
|
||||||
if (plot == null || plot.owner == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
DBFunc.clearInbox(plot, this.toString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,13 @@ public class InboxReport extends CommentInbox {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canRead(Plot plot, PlotPlayer player) {
|
public boolean canRead(Plot plot, PlotPlayer player) {
|
||||||
if (plot == null) {
|
if (Permissions.hasPermission(player, "plots.inbox.read." + toString())) {
|
||||||
return Permissions.hasPermission(player, "plots.inbox.read." + toString());
|
if (plot.isOwner(player.getUUID()) || Permissions
|
||||||
|
.hasPermission(player, "plots.inbox.read." + toString() + ".other")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
return false;
|
||||||
.hasPermission(player, "plots.inbox.read." + toString() + ".other"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -31,11 +33,12 @@ public class InboxReport extends CommentInbox {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canModify(Plot plot, PlotPlayer player) {
|
public boolean canModify(Plot plot, PlotPlayer player) {
|
||||||
if (plot == null) {
|
if (Permissions.hasPermission(player, "plots.inbox.modify." + toString())) {
|
||||||
return Permissions.hasPermission(player, "plots.inbox.modify." + toString());
|
if (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.modify." + toString() + ".other")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
return false;
|
||||||
.hasPermission(player, "plots.inbox.modify." + toString() + ".other"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -64,21 +67,4 @@ public class InboxReport extends CommentInbox {
|
|||||||
return "report";
|
return "report";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean removeComment(Plot plot, PlotComment comment) {
|
|
||||||
if (plot.owner == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
DBFunc.removeComment(plot, comment);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean clearInbox(Plot plot) {
|
|
||||||
if (plot == null || plot.owner == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
DBFunc.clearInbox(plot, this.toString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package com.intellectualcrafters.plot.object.schematic;
|
package com.intellectualcrafters.plot.object.schematic;
|
||||||
|
|
||||||
public class PlotItem {
|
public class PlotItem {
|
||||||
public int x;
|
|
||||||
public int y;
|
public final int x;
|
||||||
public int z;
|
public final int y;
|
||||||
public short[] id;
|
public final int z;
|
||||||
public byte[] data;
|
public final short[] id;
|
||||||
public byte[] amount;
|
public final byte[] data;
|
||||||
|
public final byte[] amount;
|
||||||
|
|
||||||
public PlotItem(short x, short y, short z, short[] id, byte[] data, byte[] amount) {
|
public PlotItem(short x, short y, short z, short[] id, byte[] data, byte[] amount) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
|
@ -111,7 +111,7 @@ public abstract class ChunkManager {
|
|||||||
Runnable smallTask = new Runnable() {
|
Runnable smallTask = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (regions.size() == 0) {
|
if (regions.isEmpty()) {
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
public class CommentManager {
|
public class CommentManager {
|
||||||
|
|
||||||
public static HashMap<String, CommentInbox> inboxes = new HashMap<>();
|
public static final HashMap<String, CommentInbox> inboxes = new HashMap<>();
|
||||||
|
|
||||||
public static void sendTitle(final PlotPlayer player, final Plot plot) {
|
public static void sendTitle(final PlotPlayer player, final Plot plot) {
|
||||||
if (!Settings.COMMENT_NOTIFICATIONS || !plot.isOwner(player.getUUID())) {
|
if (!Settings.COMMENT_NOTIFICATIONS || !plot.isOwner(player.getUUID())) {
|
||||||
|
@ -24,8 +24,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
public abstract class UUIDHandlerImplementation {
|
public abstract class UUIDHandlerImplementation {
|
||||||
|
|
||||||
public final ConcurrentHashMap<String, PlotPlayer> players;
|
public final ConcurrentHashMap<String, PlotPlayer> players;
|
||||||
|
public final HashSet<UUID> unknown = new HashSet<>();
|
||||||
public UUIDWrapper uuidWrapper = null;
|
public UUIDWrapper uuidWrapper = null;
|
||||||
public HashSet<UUID> unknown = new HashSet<>();
|
|
||||||
private boolean cached = false;
|
private boolean cached = false;
|
||||||
private BiMap<StringWrapper, UUID> uuidMap = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
private BiMap<StringWrapper, UUID> uuidMap = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
||||||
|
|
||||||
|
@ -459,13 +459,13 @@ public abstract class Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getUsage() {
|
public String getUsage() {
|
||||||
if (this.usage != null && this.usage.length() != 0) {
|
if (this.usage != null && !this.usage.isEmpty()) {
|
||||||
if (this.usage.startsWith("/")) {
|
if (this.usage.startsWith("/")) {
|
||||||
return this.usage;
|
return this.usage;
|
||||||
}
|
}
|
||||||
return getCommandString() + " " + this.usage;
|
return getCommandString() + " " + this.usage;
|
||||||
}
|
}
|
||||||
if (this.allCommands.size() == 0) {
|
if (this.allCommands.isEmpty()) {
|
||||||
return getCommandString();
|
return getCommandString();
|
||||||
}
|
}
|
||||||
StringBuilder args = new StringBuilder("[");
|
StringBuilder args = new StringBuilder("[");
|
||||||
@ -511,7 +511,7 @@ public abstract class Command {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.aliases.size() > 0 ? this.aliases.get(0) : this.id;
|
return !this.aliases.isEmpty() ? this.aliases.get(0) : this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,6 +19,7 @@ import org.spongepowered.api.entity.living.player.gamemode.GameModes;
|
|||||||
import org.spongepowered.api.service.ban.BanService;
|
import org.spongepowered.api.service.ban.BanService;
|
||||||
import org.spongepowered.api.text.chat.ChatTypes;
|
import org.spongepowered.api.text.chat.ChatTypes;
|
||||||
import org.spongepowered.api.text.serializer.TextSerializers;
|
import org.spongepowered.api.text.serializer.TextSerializers;
|
||||||
|
import org.spongepowered.api.world.World;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -94,7 +95,7 @@ public class SpongePlayer extends PlotPlayer {
|
|||||||
if (!world.equals(location.getWorld())) {
|
if (!world.equals(location.getWorld())) {
|
||||||
this.player.transferToWorld(location.getWorld(), new Vector3d(location.getX(), location.getY(), location.getZ()));
|
this.player.transferToWorld(location.getWorld(), new Vector3d(location.getX(), location.getY(), location.getZ()));
|
||||||
} else {
|
} else {
|
||||||
org.spongepowered.api.world.Location current = this.player.getLocation();
|
org.spongepowered.api.world.Location<World> current = this.player.getLocation();
|
||||||
current = current.setPosition(new Vector3d(location.getX(), location.getY(), location.getZ()));
|
current = current.setPosition(new Vector3d(location.getX(), location.getY(), location.getZ()));
|
||||||
this.player.setLocation(current);
|
this.player.setLocation(current);
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,6 @@ import com.intellectualcrafters.plot.object.ConsolePlayer;
|
|||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.plotsquared.sponge.SpongeMain;
|
import com.plotsquared.sponge.SpongeMain;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
|
||||||
import org.spongepowered.api.command.CommandCallable;
|
import org.spongepowered.api.command.CommandCallable;
|
||||||
import org.spongepowered.api.command.CommandException;
|
import org.spongepowered.api.command.CommandException;
|
||||||
import org.spongepowered.api.command.CommandResult;
|
import org.spongepowered.api.command.CommandResult;
|
||||||
@ -18,18 +12,25 @@ import org.spongepowered.api.command.CommandSource;
|
|||||||
import org.spongepowered.api.entity.living.player.Player;
|
import org.spongepowered.api.entity.living.player.Player;
|
||||||
import org.spongepowered.api.text.Text;
|
import org.spongepowered.api.text.Text;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class SpongeCommand implements CommandCallable {
|
public class SpongeCommand implements CommandCallable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult process(final CommandSource cmd, final String string) throws CommandException {
|
public CommandResult process(CommandSource cmd, String string) throws CommandException {
|
||||||
TaskManager.runTask(() -> {
|
TaskManager.runTask(() -> {
|
||||||
final String id = cmd.getIdentifier();
|
String id = cmd.getIdentifier();
|
||||||
PlotPlayer pp;
|
PlotPlayer pp;
|
||||||
try {
|
try {
|
||||||
final UUID uuid = UUID.fromString(id);
|
UUID uuid = UUID.fromString(id);
|
||||||
final Player player = SpongeMain.THIS.getServer().getPlayer(uuid).get();
|
Player player = SpongeMain.THIS.getServer().getPlayer(uuid).get();
|
||||||
pp = SpongeUtil.getPlayer(player);
|
pp = SpongeUtil.getPlayer(player);
|
||||||
} catch (final Exception e) {
|
} catch (Exception e) {
|
||||||
pp = ConsolePlayer.getConsole();
|
pp = ConsolePlayer.getConsole();
|
||||||
}
|
}
|
||||||
MainCommand.onCommand(pp, string.isEmpty() ? new String[]{} : string.split(" "));
|
MainCommand.onCommand(pp, string.isEmpty() ? new String[]{} : string.split(" "));
|
||||||
@ -38,11 +39,11 @@ public class SpongeCommand implements CommandCallable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getSuggestions(final CommandSource source, final String s) throws CommandException {
|
public List<String> getSuggestions(CommandSource source, String s) throws CommandException {
|
||||||
if (!(source instanceof Player)) {
|
if (!(source instanceof Player)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final PlotPlayer player = SpongeUtil.getPlayer((Player) source);
|
PlotPlayer player = SpongeUtil.getPlayer((Player) source);
|
||||||
String[] args = s.split(" ");
|
String[] args = s.split(" ");
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
return Collections.singletonList(MainCommand.getInstance().toString());
|
return Collections.singletonList(MainCommand.getInstance().toString());
|
||||||
@ -55,26 +56,26 @@ public class SpongeCommand implements CommandCallable {
|
|||||||
for (Object o : objects) {
|
for (Object o : objects) {
|
||||||
result.add(o.toString());
|
result.add(o.toString());
|
||||||
}
|
}
|
||||||
return result.size() == 0 ? null : result;
|
return result.isEmpty() ? null : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean testPermission(final CommandSource cmd) {
|
public boolean testPermission(CommandSource cmd) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<? extends Text> getShortDescription(final CommandSource cmd) {
|
public Optional<? extends Text> getShortDescription(CommandSource cmd) {
|
||||||
return Optional.of(Text.of("Shows plot help"));
|
return Optional.of(Text.of("Shows plot help"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<? extends Text> getHelp(final CommandSource cmd) {
|
public Optional<? extends Text> getHelp(CommandSource cmd) {
|
||||||
return Optional.of(Text.of("/plot"));
|
return Optional.of(Text.of("/plot"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Text getUsage(final CommandSource cmd) {
|
public Text getUsage(CommandSource cmd) {
|
||||||
return Text.of("/plot <command>");
|
return Text.of("/plot <command>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user