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