mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8_3.java # Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java
This commit is contained in:
commit
8b10b7109c
@ -13,6 +13,7 @@ import com.intellectualcrafters.plot.object.PlotManager;
|
|||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||||
import com.intellectualcrafters.plot.util.SetQueue;
|
import com.intellectualcrafters.plot.util.SetQueue;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
@ -32,28 +33,20 @@ import java.util.UUID;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* PlotSquared API.
|
* PlotSquared API.
|
||||||
* <br>
|
*
|
||||||
* <br>
|
* <p>Useful classes:</p>
|
||||||
* Useful classes:<br>
|
* <ul>
|
||||||
* @see BukkitUtil
|
* <li>{@link BukkitUtil}</li>
|
||||||
* @see PlotPlayer
|
* <li>{@link PlotPlayer}</li>
|
||||||
* @see Plot
|
* <li>{@link Plot}</li>
|
||||||
* @see com.intellectualcrafters.plot.object.Location
|
* <li>{@link com.intellectualcrafters.plot.object.Location}</li>
|
||||||
* @see PlotArea
|
* <li>{@link PlotArea}</li>
|
||||||
* @see PS
|
* <li>{@link PS}</li>
|
||||||
|
* </ul>
|
||||||
* @version 3.3.3
|
* @version 3.3.3
|
||||||
>>>>>>> origin/master
|
|
||||||
*/
|
*/
|
||||||
public class PlotAPI {
|
public class PlotAPI {
|
||||||
|
|
||||||
/**
|
|
||||||
* Permission that allows for admin access, this permission node will allow
|
|
||||||
* the player to use any part of the plugin, without limitations.
|
|
||||||
* @deprecated Use C.PERMISSION_ADMIN instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static final String ADMIN_PERMISSION = C.PERMISSION_ADMIN.s();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deprecated, does nothing.
|
* Deprecated, does nothing.
|
||||||
* @param plugin not needed
|
* @param plugin not needed
|
||||||
@ -63,24 +56,6 @@ public class PlotAPI {
|
|||||||
public PlotAPI(JavaPlugin plugin) {
|
public PlotAPI(JavaPlugin plugin) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Default Constructor that does nothing.
|
|
||||||
*
|
|
||||||
* @deprecated Use this class if you just want to do a few simple things
|
|
||||||
* <ul>
|
|
||||||
* <li>It will remain stable for future versions
|
|
||||||
* of the plugin</li>
|
|
||||||
* <li>The PlotPlayer and Plot class should be considered
|
|
||||||
* relatively safe</li>
|
|
||||||
* <li>For more advanced/intensive tasks you should consider
|
|
||||||
* using other classes</li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public PlotAPI() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all plots.
|
* Get all plots.
|
||||||
*
|
*
|
||||||
@ -156,7 +131,7 @@ public class PlotAPI {
|
|||||||
*
|
*
|
||||||
* @return ChunkManager
|
* @return ChunkManager
|
||||||
*
|
*
|
||||||
* @see com.intellectualcrafters.plot.util.ChunkManager
|
* @see ChunkManager
|
||||||
*/
|
*/
|
||||||
public ChunkManager getChunkManager() {
|
public ChunkManager getChunkManager() {
|
||||||
return ChunkManager.manager;
|
return ChunkManager.manager;
|
||||||
@ -176,7 +151,7 @@ public class PlotAPI {
|
|||||||
*
|
*
|
||||||
* @return UUIDWrapper
|
* @return UUIDWrapper
|
||||||
*
|
*
|
||||||
* @see com.intellectualcrafters.plot.uuid.UUIDWrapper
|
* @see UUIDWrapper
|
||||||
*/
|
*/
|
||||||
public UUIDWrapper getUUIDWrapper() {
|
public UUIDWrapper getUUIDWrapper() {
|
||||||
return UUIDHandler.getUUIDWrapper();
|
return UUIDHandler.getUUIDWrapper();
|
||||||
@ -211,7 +186,7 @@ public class PlotAPI {
|
|||||||
*
|
*
|
||||||
* @return Array of strings
|
* @return Array of strings
|
||||||
*
|
*
|
||||||
* @see com.intellectualcrafters.plot.util.Permissions
|
* @see Permissions
|
||||||
* @deprecated Use {@link C} to list all the permissions
|
* @deprecated Use {@link C} to list all the permissions
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -231,7 +206,7 @@ public class PlotAPI {
|
|||||||
*
|
*
|
||||||
* @return SchematicHandler
|
* @return SchematicHandler
|
||||||
*
|
*
|
||||||
* @see com.intellectualcrafters.plot.util.SchematicHandler
|
* @see SchematicHandler
|
||||||
*/
|
*/
|
||||||
public SchematicHandler getSchematicHandler() {
|
public SchematicHandler getSchematicHandler() {
|
||||||
return SchematicHandler.manager;
|
return SchematicHandler.manager;
|
||||||
@ -256,7 +231,7 @@ public class PlotAPI {
|
|||||||
*
|
*
|
||||||
* @return PlotManager
|
* @return PlotManager
|
||||||
*
|
*
|
||||||
* @see com.intellectualcrafters.plot.object.PlotManager
|
* @see PlotManager
|
||||||
* @see PS#getPlotManager(Plot)
|
* @see PS#getPlotManager(Plot)
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -288,7 +263,7 @@ public class PlotAPI {
|
|||||||
* @return PlotManager
|
* @return PlotManager
|
||||||
*
|
*
|
||||||
* @see PS#getPlotManager(Plot)
|
* @see PS#getPlotManager(Plot)
|
||||||
* @see com.intellectualcrafters.plot.object.PlotManager
|
* @see PlotManager
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public PlotManager getPlotManager(String world) {
|
public PlotManager getPlotManager(String world) {
|
||||||
@ -314,7 +289,7 @@ public class PlotAPI {
|
|||||||
* @return The {@link PlotArea} for the world or null if not in plotworld
|
* @return The {@link PlotArea} for the world or null if not in plotworld
|
||||||
*
|
*
|
||||||
* @see #getPlotAreas(World)
|
* @see #getPlotAreas(World)
|
||||||
* @see com.intellectualcrafters.plot.object.PlotArea
|
* @see PlotArea
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public PlotArea getWorldSettings(World world) {
|
public PlotArea getWorldSettings(World world) {
|
||||||
@ -332,7 +307,7 @@ public class PlotAPI {
|
|||||||
* @return The {@link PlotArea} for the world or null if not in plotworld
|
* @return The {@link PlotArea} for the world or null if not in plotworld
|
||||||
*
|
*
|
||||||
* @see PS#getPlotArea(String, String)
|
* @see PS#getPlotArea(String, String)
|
||||||
* @see com.intellectualcrafters.plot.object.PlotArea
|
* @see PlotArea
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public PlotArea getWorldSettings(String world) {
|
public PlotArea getWorldSettings(String world) {
|
||||||
@ -392,7 +367,7 @@ public class PlotAPI {
|
|||||||
* @param caption The caption
|
* @param caption The caption
|
||||||
*
|
*
|
||||||
* @see #sendConsoleMessage(String)
|
* @see #sendConsoleMessage(String)
|
||||||
* @see com.intellectualcrafters.plot.config.C
|
* @see C
|
||||||
*/
|
*/
|
||||||
public void sendConsoleMessage(C caption) {
|
public void sendConsoleMessage(C caption) {
|
||||||
sendConsoleMessage(caption.s());
|
sendConsoleMessage(caption.s());
|
||||||
@ -403,8 +378,8 @@ public class PlotAPI {
|
|||||||
*
|
*
|
||||||
* @param flag Flag that should be registered
|
* @param flag Flag that should be registered
|
||||||
*
|
*
|
||||||
* @see com.intellectualcrafters.plot.flag.FlagManager#addFlag(com.intellectualcrafters.plot.flag.AbstractFlag)
|
* @see FlagManager#addFlag(AbstractFlag)
|
||||||
* @see com.intellectualcrafters.plot.flag.AbstractFlag
|
* @see AbstractFlag
|
||||||
*/
|
*/
|
||||||
public void addFlag(AbstractFlag flag) {
|
public void addFlag(AbstractFlag flag) {
|
||||||
FlagManager.addFlag(flag);
|
FlagManager.addFlag(flag);
|
||||||
@ -415,8 +390,8 @@ public class PlotAPI {
|
|||||||
*
|
*
|
||||||
* @return array of Flag[]
|
* @return array of Flag[]
|
||||||
*
|
*
|
||||||
* @see com.intellectualcrafters.plot.flag.FlagManager#getFlags()
|
* @see FlagManager#getFlags()
|
||||||
* @see com.intellectualcrafters.plot.flag.AbstractFlag
|
* @see AbstractFlag
|
||||||
*/
|
*/
|
||||||
public AbstractFlag[] getFlags() {
|
public AbstractFlag[] getFlags() {
|
||||||
return FlagManager.getFlags().toArray(new AbstractFlag[FlagManager.getFlags().size()]);
|
return FlagManager.getFlags().toArray(new AbstractFlag[FlagManager.getFlags().size()]);
|
||||||
@ -468,7 +443,7 @@ public class PlotAPI {
|
|||||||
*
|
*
|
||||||
* @return plot if found, otherwise it creates a temporary plot
|
* @return plot if found, otherwise it creates a temporary plot
|
||||||
*
|
*
|
||||||
* @see #getPlot(org.bukkit.Location)
|
* @see #getPlot(Location)
|
||||||
* @see Plot
|
* @see Plot
|
||||||
*/
|
*/
|
||||||
public Plot getPlot(Player player) {
|
public Plot getPlot(Player player) {
|
||||||
@ -638,7 +613,7 @@ public class PlotAPI {
|
|||||||
* Register a subcommand.
|
* Register a subcommand.
|
||||||
* @deprecated Command registration is done on object creation
|
* @deprecated Command registration is done on object creation
|
||||||
* @param c SubCommand, that we want to register
|
* @param c SubCommand, that we want to register
|
||||||
* @see com.intellectualcrafters.plot.commands.SubCommand
|
* @see SubCommand
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void registerCommand(SubCommand c) {
|
public void registerCommand(SubCommand c) {
|
||||||
|
@ -73,14 +73,9 @@ import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
|
|||||||
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
|
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
|
||||||
import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
|
import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -93,9 +88,15 @@ import org.bukkit.metadata.MetadataValue;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||||
|
|
||||||
public static BukkitMain THIS;
|
|
||||||
public static WorldEditPlugin worldEdit;
|
public static WorldEditPlugin worldEdit;
|
||||||
|
|
||||||
private int[] version;
|
private int[] version;
|
||||||
@ -123,7 +124,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
BukkitMain.THIS = this;
|
|
||||||
new PS(this, "Bukkit");
|
new PS(this, "Bukkit");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,40 +131,35 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
PS.get().disable();
|
PS.get().disable();
|
||||||
Bukkit.getScheduler().cancelTasks(this);
|
Bukkit.getScheduler().cancelTasks(this);
|
||||||
BukkitMain.THIS = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void log(String message) {
|
public void log(String message) {
|
||||||
if (BukkitMain.THIS != null) {
|
try {
|
||||||
try {
|
message = C.color(message);
|
||||||
message = C.color(message);
|
if (!Settings.CONSOLE_COLOR) {
|
||||||
if (!Settings.CONSOLE_COLOR) {
|
message = ChatColor.stripColor(message);
|
||||||
message = ChatColor.stripColor(message);
|
|
||||||
}
|
|
||||||
this.getServer().getConsoleSender().sendMessage(message);
|
|
||||||
return;
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
//ignored
|
|
||||||
}
|
}
|
||||||
|
this.getServer().getConsoleSender().sendMessage(message);
|
||||||
|
return;
|
||||||
|
} catch (Throwable ignored) {
|
||||||
|
//ignored
|
||||||
}
|
}
|
||||||
System.out.println(ConsoleColors.fromString(message));
|
System.out.println(ConsoleColors.fromString(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
if (BukkitMain.THIS != null) {
|
onDisable();
|
||||||
onDisable();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getPluginVersion() {
|
public int[] getPluginVersion() {
|
||||||
String version = getDescription().getVersion();
|
String ver = getDescription().getVersion();
|
||||||
if (version.contains("-SNAPSHOT")) {
|
if (ver.contains("-SNAPSHOT")) {
|
||||||
version = version.split("-SNAPSHOT")[0];
|
ver = ver.split("-SNAPSHOT")[0];
|
||||||
}
|
}
|
||||||
String[] split = version.split("\\.");
|
String[] split = ver.split("\\.");
|
||||||
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])};
|
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +184,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskManager getTaskManager() {
|
public TaskManager getTaskManager() {
|
||||||
return new BukkitTaskManager();
|
return new BukkitTaskManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -402,7 +397,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlotQueue initPlotQueue() {
|
public PlotQueue<Chunk> initPlotQueue() {
|
||||||
try {
|
try {
|
||||||
new SendChunk();
|
new SendChunk();
|
||||||
MainUtil.canSendChunk = true;
|
MainUtil.canSendChunk = true;
|
||||||
@ -449,18 +444,15 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
TaskManager.runTaskLaterAsync(new Runnable() {
|
TaskManager.runTaskLaterAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (new LikePlotMeConverter("PlotMe").run(new ClassicPlotMeConnector())) {
|
if (new LikePlotMeConverter().run(new ClassicPlotMeConnector())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (new LikePlotMeConverter("PlotMe").run(new PlotMeConnector_017())) {
|
if (new LikePlotMeConverter().run(new PlotMeConnector_017())) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (new LikePlotMeConverter("AthionPlots").run(new ClassicPlotMeConnector())) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 20);
|
}, 20);
|
||||||
return Bukkit.getPluginManager().getPlugin("PlotMe") != null || Bukkit.getPluginManager().getPlugin("AthionPlots") != null;
|
return Bukkit.getPluginManager().getPlugin("PlotMe") != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -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,32 +109,21 @@ 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);
|
||||||
try {
|
long high = bb.getLong();
|
||||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
long low = bb.getLong();
|
||||||
long high = bb.getLong();
|
owner = new UUID(high, low);
|
||||||
long low = bb.getLong();
|
UUIDHandler.add(new StringWrapper(name), owner);
|
||||||
owner = new UUID(high, low);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
owner = UUID.nameUUIDFromBytes(bytes);
|
|
||||||
}
|
|
||||||
UUIDHandler.add(new StringWrapper(name), owner);
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (owner == null) {
|
if (name.isEmpty()) {
|
||||||
if (name.isEmpty()) {
|
PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + "'");
|
||||||
PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + "'");
|
missing++;
|
||||||
missing++;
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
owner = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
|
|
||||||
}
|
}
|
||||||
|
owner = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
UUIDHandler.add(new StringWrapper(name), owner);
|
UUIDHandler.add(new StringWrapper(name), owner);
|
||||||
@ -180,22 +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);
|
||||||
try {
|
long mostSigBits = bb.getLong();
|
||||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
long leastSigBits = bb.getLong();
|
||||||
long high = bb.getLong();
|
denied = new UUID(mostSigBits, leastSigBits);
|
||||||
long low = bb.getLong();
|
UUIDHandler.add(new StringWrapper(name), denied);
|
||||||
denied = new UUID(high, low);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
denied = UUID.nameUUIDFromBytes(bytes);
|
|
||||||
}
|
|
||||||
UUIDHandler.add(new StringWrapper(name), denied);
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (denied == null) {
|
if (denied == null) {
|
||||||
@ -224,22 +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);
|
||||||
try {
|
long mostSigBits = bb.getLong();
|
||||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
long leastSigBits = bb.getLong();
|
||||||
long high = bb.getLong();
|
helper = new UUID(mostSigBits, leastSigBits);
|
||||||
long low = bb.getLong();
|
UUIDHandler.add(new StringWrapper(name), helper);
|
||||||
helper = new UUID(high, low);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
helper = UUID.nameUUIDFromBytes(bytes);
|
|
||||||
}
|
|
||||||
UUIDHandler.add(new StringWrapper(name), helper);
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (helper == null) {
|
if (helper == null) {
|
||||||
|
@ -24,6 +24,7 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -33,17 +34,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
|
|
||||||
public class LikePlotMeConverter {
|
public class LikePlotMeConverter {
|
||||||
|
|
||||||
private final String plugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*
|
|
||||||
* @param plugin Plugin Used to run the converter
|
|
||||||
*/
|
|
||||||
public LikePlotMeConverter(String plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getWorld(String world) {
|
public static String getWorld(String world) {
|
||||||
for (World newWorld : Bukkit.getWorlds()) {
|
for (World newWorld : Bukkit.getWorlds()) {
|
||||||
if (newWorld.getName().equalsIgnoreCase(world)) {
|
if (newWorld.getName().equalsIgnoreCase(world)) {
|
||||||
@ -58,11 +48,7 @@ public class LikePlotMeConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getPlotMePath() {
|
public String getPlotMePath() {
|
||||||
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + this.plugin + File.separator;
|
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe" + File.separator;
|
||||||
}
|
|
||||||
|
|
||||||
public String getAthionPlotsPath() {
|
|
||||||
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + this.plugin + File.separator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileConfiguration getPlotMeConfig(String dataFolder) {
|
public FileConfiguration getPlotMeConfig(String dataFolder) {
|
||||||
@ -77,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)) {
|
||||||
@ -97,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);
|
||||||
@ -106,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
|
||||||
@ -131,31 +117,31 @@ public class LikePlotMeConverter {
|
|||||||
|
|
||||||
PS.debug("&3Using connector: " + connector.getClass().getCanonicalName());
|
PS.debug("&3Using connector: " + connector.getClass().getCanonicalName());
|
||||||
|
|
||||||
Connection connection = connector.getPlotMeConnection(this.plugin, 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");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessage(this.plugin + " 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(this.plugin, plotConfig);
|
mergeWorldYml(plotConfig);
|
||||||
|
|
||||||
sendMessage("Connecting to " + this.plugin + " DB");
|
sendMessage("Connecting to PlotMe DB");
|
||||||
|
|
||||||
ArrayList<Plot> createdPlots = new ArrayList<>();
|
ArrayList<Plot> createdPlots = new ArrayList<>();
|
||||||
|
|
||||||
sendMessage("Collecting plot data");
|
sendMessage("Collecting plot data");
|
||||||
|
|
||||||
String dbPrefix = this.plugin.toLowerCase();
|
String dbPrefix = "PlotMe".toLowerCase();
|
||||||
sendMessage(" - " + dbPrefix + "Plots");
|
sendMessage(" - " + dbPrefix + "Plots");
|
||||||
final Set<String> worlds = getPlotMeWorlds(plotConfig);
|
final Set<String> worlds = getPlotMeWorlds(plotConfig);
|
||||||
|
|
||||||
if (Settings.CONVERT_PLOTME) {
|
if (Settings.CONVERT_PLOTME) {
|
||||||
sendMessage("Updating bukkit.yml");
|
sendMessage("Updating bukkit.yml");
|
||||||
updateWorldYml(this.plugin, "bukkit.yml");
|
updateWorldYml("bukkit.yml");
|
||||||
updateWorldYml(this.plugin, "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 {
|
||||||
@ -188,24 +174,17 @@ public class LikePlotMeConverter {
|
|||||||
for (String world : plots.keySet()) {
|
for (String world : plots.keySet()) {
|
||||||
String actualWorldName = getWorld(world);
|
String actualWorldName = getWorld(world);
|
||||||
String plotMeWorldName = world.toLowerCase();
|
String plotMeWorldName = world.toLowerCase();
|
||||||
Integer pathwidth = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
|
Integer pathWidth = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
|
||||||
/*
|
PS.get().config.set("worlds." + world + ".road.width", pathWidth);
|
||||||
* TODO: dead code
|
|
||||||
*
|
|
||||||
if (pathwidth == null) {
|
|
||||||
pathwidth = 7;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
PS.get().config.set("worlds." + world + ".road.width", pathwidth);
|
|
||||||
|
|
||||||
Integer pathheight = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
int pathHeight = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||||
if (pathheight == 0) {
|
if (pathHeight == 0) {
|
||||||
pathheight = 64;
|
pathHeight = 64;
|
||||||
}
|
}
|
||||||
PS.get().config.set("worlds." + world + ".road.height", pathheight);
|
PS.get().config.set("worlds." + world + ".road.height", pathHeight);
|
||||||
PS.get().config.set("worlds." + world + ".wall.height", pathheight);
|
PS.get().config.set("worlds." + world + ".wall.height", pathHeight);
|
||||||
PS.get().config.set("worlds." + world + ".plot.height", pathheight);
|
PS.get().config.set("worlds." + world + ".plot.height", pathHeight);
|
||||||
Integer plotSize = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
int plotSize = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PlotSize", 32); //
|
||||||
if (plotSize == 0) {
|
if (plotSize == 0) {
|
||||||
plotSize = 32;
|
plotSize = 32;
|
||||||
}
|
}
|
||||||
@ -218,7 +197,7 @@ public class LikePlotMeConverter {
|
|||||||
PS.get().config.set("worlds." + world + ".plot.filling", Collections.singletonList(filling));
|
PS.get().config.set("worlds." + world + ".plot.filling", Collections.singletonList(filling));
|
||||||
String road = plotmeDgYml.getString("worlds." + plotMeWorldName + ".RoadMainBlock", "5");
|
String road = plotmeDgYml.getString("worlds." + plotMeWorldName + ".RoadMainBlock", "5");
|
||||||
PS.get().config.set("worlds." + world + ".road.block", road);
|
PS.get().config.set("worlds." + world + ".road.block", road);
|
||||||
Integer height = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
int height = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||||
if (height == 0) {
|
if (height == 0) {
|
||||||
height = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".GroundHeight"); //
|
height = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".GroundHeight"); //
|
||||||
if (height == 0) {
|
if (height == 0) {
|
||||||
@ -364,7 +343,7 @@ public class LikePlotMeConverter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (InterruptedException | SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PS.debug("&/end/");
|
PS.debug("&/end/");
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlotMeConnector_017 extends APlotMeConnector {
|
public class PlotMeConnector_017 extends APlotMeConnector {
|
||||||
@ -27,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");
|
||||||
@ -110,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) {
|
||||||
@ -131,8 +126,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
|||||||
Plot plot = new Plot(PlotArea.createGeneric(world), id, owner);
|
Plot plot = new Plot(PlotArea.createGeneric(world), id, owner);
|
||||||
plots.put(key, plot);
|
plots.put(key, plot);
|
||||||
}
|
}
|
||||||
for (Entry<Integer, Plot> entry : plots.entrySet()) {
|
for (Plot plot : plots.values()) {
|
||||||
Plot plot = entry.getValue();
|
|
||||||
HashMap<PlotId, boolean[]> mergeMap = merges.get(plot.getArea().worldname);
|
HashMap<PlotId, boolean[]> mergeMap = merges.get(plot.getArea().worldname);
|
||||||
if (mergeMap != null) {
|
if (mergeMap != null) {
|
||||||
if (mergeMap.containsKey(plot.getId())) {
|
if (mergeMap.containsKey(plot.getId())) {
|
||||||
@ -180,8 +174,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
|||||||
}
|
}
|
||||||
HashMap<String, HashMap<PlotId, Plot>> processed = new HashMap<>();
|
HashMap<String, HashMap<PlotId, Plot>> processed = new HashMap<>();
|
||||||
|
|
||||||
for (Entry<Integer, Plot> entry : plots.entrySet()) {
|
for (Plot plot : plots.values()) {
|
||||||
Plot plot = entry.getValue();
|
|
||||||
HashMap<PlotId, Plot> map = processed.get(plot.getArea().worldname);
|
HashMap<PlotId, Plot> map = processed.get(plot.getArea().worldname);
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
map = new HashMap<>();
|
map = new HashMap<>();
|
||||||
|
@ -16,17 +16,18 @@ import com.intellectualcrafters.plot.util.PlotChunk;
|
|||||||
import com.intellectualcrafters.plot.util.SetQueue;
|
import com.intellectualcrafters.plot.util.SetQueue;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.plotsquared.bukkit.util.block.GenChunk;
|
import com.plotsquared.bukkit.util.block.GenChunk;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.Set;
|
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper<ChunkGenerator> {
|
public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper<ChunkGenerator> {
|
||||||
|
|
||||||
private final PlotChunk<Chunk> chunkSetter;
|
private final PlotChunk<Chunk> chunkSetter;
|
||||||
@ -35,10 +36,9 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
|||||||
private final List<BlockPopulator> populators = new ArrayList<>();
|
private final List<BlockPopulator> populators = new ArrayList<>();
|
||||||
private final ChunkGenerator platformGenerator;
|
private final ChunkGenerator platformGenerator;
|
||||||
private final boolean full;
|
private final boolean full;
|
||||||
|
private final HashMap<ChunkLoc, byte[][]> dataMap = new HashMap<>();
|
||||||
private boolean loaded = false;
|
private boolean loaded = false;
|
||||||
|
|
||||||
HashMap<ChunkLoc, byte[][]> dataMap = new HashMap<>();
|
|
||||||
|
|
||||||
public BukkitPlotGenerator(IndependentPlotGenerator generator) {
|
public BukkitPlotGenerator(IndependentPlotGenerator generator) {
|
||||||
this.plotGenerator = generator;
|
this.plotGenerator = generator;
|
||||||
this.platformGenerator = this;
|
this.platformGenerator = this;
|
||||||
@ -47,8 +47,8 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
|||||||
public void populate(World world, Random r, Chunk c) {
|
public void populate(World world, Random r, Chunk c) {
|
||||||
ChunkLoc loc = new ChunkLoc(c.getX(), c.getZ());
|
ChunkLoc loc = new ChunkLoc(c.getX(), c.getZ());
|
||||||
byte[][] resultData;
|
byte[][] resultData;
|
||||||
if (!dataMap.containsKey(loc)) {
|
if (!BukkitPlotGenerator.this.dataMap.containsKey(loc)) {
|
||||||
GenChunk result = (GenChunk) chunkSetter;
|
GenChunk result = (GenChunk) BukkitPlotGenerator.this.chunkSetter;
|
||||||
// Set the chunk location
|
// Set the chunk location
|
||||||
result.setChunkWrapper(SetQueue.IMP.new ChunkWrapper(world.getName(), loc.x, loc.z));
|
result.setChunkWrapper(SetQueue.IMP.new ChunkWrapper(world.getName(), loc.x, loc.z));
|
||||||
// Set the result data
|
// Set the result data
|
||||||
@ -60,7 +60,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
|||||||
generate(world, loc.x, loc.z, result);
|
generate(world, loc.x, loc.z, result);
|
||||||
resultData = result.result_data;
|
resultData = result.result_data;
|
||||||
} else {
|
} else {
|
||||||
resultData = dataMap.remove(loc);
|
resultData = BukkitPlotGenerator.this.dataMap.remove(loc);
|
||||||
}
|
}
|
||||||
if (resultData != null) {
|
if (resultData != null) {
|
||||||
for (int i = 0; i < resultData.length; i++) {
|
for (int i = 0; i < resultData.length; i++) {
|
||||||
@ -76,11 +76,11 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
random.state = c.getX() << 16 | c.getZ() & 0xFFFF;
|
BukkitPlotGenerator.this.random.state = c.getX() << 16 | c.getZ() & 0xFFFF;
|
||||||
PlotArea area = PS.get().getPlotArea(world.getName(), null);
|
PlotArea area = PS.get().getPlotArea(world.getName(), null);
|
||||||
SetQueue.ChunkWrapper wrap = SetQueue.IMP.new ChunkWrapper(area.worldname, c.getX(), c.getZ());
|
SetQueue.ChunkWrapper wrap = SetQueue.IMP.new ChunkWrapper(area.worldname, c.getX(), c.getZ());
|
||||||
PlotChunk<?> chunk = SetQueue.IMP.queue.getChunk(wrap);
|
PlotChunk<?> chunk = SetQueue.IMP.queue.getChunk(wrap);
|
||||||
if (plotGenerator.populateChunk(chunk, area, random)) {
|
if (BukkitPlotGenerator.this.plotGenerator.populateChunk(chunk, area, BukkitPlotGenerator.this.random)) {
|
||||||
chunk.addToQueue();
|
chunk.addToQueue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,12 +232,9 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (world == null) {
|
|
||||||
return populators;
|
|
||||||
}
|
|
||||||
ArrayList<BlockPopulator> toAdd = new ArrayList<BlockPopulator>();
|
ArrayList<BlockPopulator> toAdd = new ArrayList<BlockPopulator>();
|
||||||
List<BlockPopulator> existing = world.getPopulators();
|
List<BlockPopulator> existing = world.getPopulators();
|
||||||
for (BlockPopulator populator : populators) {
|
for (BlockPopulator populator : this.populators) {
|
||||||
if (!existing.contains(populator)) {
|
if (!existing.contains(populator)) {
|
||||||
toAdd.add(populator);
|
toAdd.add(populator);
|
||||||
}
|
}
|
||||||
@ -305,7 +302,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
|||||||
return this.platformGenerator.generateExtBlockSections(world, r, cx, cz, grid);
|
return this.platformGenerator.generateExtBlockSections(world, r, cx, cz, grid);
|
||||||
} else {
|
} else {
|
||||||
generate(world, cx, cz, result);
|
generate(world, cx, cz, result);
|
||||||
dataMap.put(new ChunkLoc(cx, cz), result.result_data);
|
this.dataMap.put(new ChunkLoc(cx, cz), result.result_data);
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
@ -330,7 +327,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (this.platformGenerator == this) {
|
if (this.platformGenerator == this) {
|
||||||
return "" + this.plotGenerator;
|
return this.plotGenerator.getName();
|
||||||
}
|
}
|
||||||
if (this.platformGenerator == null) {
|
if (this.platformGenerator == null) {
|
||||||
return "null";
|
return "null";
|
||||||
|
@ -22,7 +22,6 @@ import com.intellectualcrafters.plot.util.RegExUtil;
|
|||||||
import com.intellectualcrafters.plot.util.StringMan;
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.plotsquared.bukkit.BukkitMain;
|
|
||||||
import com.plotsquared.bukkit.object.BukkitLazyBlock;
|
import com.plotsquared.bukkit.object.BukkitLazyBlock;
|
||||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
@ -42,6 +41,7 @@ import org.bukkit.entity.Creature;
|
|||||||
import org.bukkit.entity.EnderDragon;
|
import org.bukkit.entity.EnderDragon;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.FallingBlock;
|
||||||
import org.bukkit.entity.Fireball;
|
import org.bukkit.entity.Fireball;
|
||||||
import org.bukkit.entity.Hanging;
|
import org.bukkit.entity.Hanging;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
@ -109,6 +109,7 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import org.bukkit.projectiles.BlockProjectileSource;
|
import org.bukkit.projectiles.BlockProjectileSource;
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -362,7 +363,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
BukkitPlayer pp = (BukkitPlayer) BukkitUtil.getPlayer(player);
|
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
Plot plot = pp.getCurrentPlot();
|
Plot plot = pp.getCurrentPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return;
|
return;
|
||||||
@ -464,8 +465,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void playerRespawn(PlayerRespawnEvent event) {
|
public void playerRespawn(PlayerRespawnEvent event) {
|
||||||
final Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
EventUtil.manager.doDeathTask(pp);
|
EventUtil.manager.doDeathTask(pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,14 +573,13 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onChat(AsyncPlayerChatEvent event) {
|
public void onChat(AsyncPlayerChatEvent event) {
|
||||||
Player player = event.getPlayer();
|
PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer());
|
||||||
PlotPlayer plr = BukkitUtil.getPlayer(player);
|
Location location = plotPlayer.getLocation();
|
||||||
Location loc = plr.getLocation();
|
PlotArea area = location.getPlotArea();
|
||||||
PlotArea area = loc.getPlotArea();
|
if (area == null || (!area.PLOT_CHAT && !plotPlayer.getAttribute("chat"))) {
|
||||||
if (area == null || (!area.PLOT_CHAT && !plr.getAttribute("chat"))) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot plot = area.getPlot(loc);
|
Plot plot = area.getPlot(location);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -614,7 +614,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void BlockDestroy(BlockBreakEvent event) {
|
public void blockDestroy(BlockBreakEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
|
Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
|
||||||
PlotArea area = loc.getPlotArea();
|
PlotArea area = loc.getPlotArea();
|
||||||
@ -737,7 +737,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
plotExit(pp, plot);
|
plotExit(pp, plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BukkitMain.worldEdit != null && PS.get().worldedit != null) {
|
if (true && PS.get().worldedit != null) {
|
||||||
if (!Permissions.hasPermission(pp, C.PERMISSION_WORLDEDIT_BYPASS)) {
|
if (!Permissions.hasPermission(pp, C.PERMISSION_WORLDEDIT_BYPASS)) {
|
||||||
if (pp.getAttribute("worldedit")) {
|
if (pp.getAttribute("worldedit")) {
|
||||||
pp.removeAttribute("worldedit");
|
pp.removeAttribute("worldedit");
|
||||||
@ -756,7 +756,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Entity e = event.getEntity();
|
Entity e = event.getEntity();
|
||||||
if (!(e instanceof org.bukkit.entity.FallingBlock)) {
|
if (!(e instanceof FallingBlock)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -773,20 +773,16 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBS(BlockSpreadEvent e) {
|
public void onBlockSpread(BlockSpreadEvent event) {
|
||||||
Block b = e.getBlock();
|
onBlockForm(event); //send to super class.
|
||||||
Location loc = BukkitUtil.getLocation(b.getLocation());
|
|
||||||
if (loc.isPlotRoad()) {
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBF(BlockFormEvent e) {
|
public void onBlockForm(BlockFormEvent event) {
|
||||||
Block b = e.getBlock();
|
Block block = event.getBlock();
|
||||||
Location loc = BukkitUtil.getLocation(b.getLocation());
|
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||||
if (loc.isPlotRoad()) {
|
if (loc.isPlotRoad()) {
|
||||||
e.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Ageable;
|
import org.bukkit.entity.Ageable;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
|
import org.bukkit.entity.Bat;
|
||||||
|
import org.bukkit.entity.EnderDragon;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Guardian;
|
import org.bukkit.entity.Guardian;
|
||||||
@ -16,6 +18,7 @@ import org.bukkit.entity.Horse;
|
|||||||
import org.bukkit.entity.Horse.Color;
|
import org.bukkit.entity.Horse.Color;
|
||||||
import org.bukkit.entity.Horse.Style;
|
import org.bukkit.entity.Horse.Style;
|
||||||
import org.bukkit.entity.Horse.Variant;
|
import org.bukkit.entity.Horse.Variant;
|
||||||
|
import org.bukkit.entity.IronGolem;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.ItemFrame;
|
import org.bukkit.entity.ItemFrame;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@ -25,6 +28,7 @@ import org.bukkit.entity.Rabbit.Type;
|
|||||||
import org.bukkit.entity.Sheep;
|
import org.bukkit.entity.Sheep;
|
||||||
import org.bukkit.entity.Skeleton;
|
import org.bukkit.entity.Skeleton;
|
||||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||||
|
import org.bukkit.entity.Slime;
|
||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
import org.bukkit.inventory.EntityEquipment;
|
import org.bukkit.inventory.EntityEquipment;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
@ -34,15 +38,15 @@ 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;
|
private final EntityBaseStats base = new EntityBaseStats();
|
||||||
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;
|
|
||||||
// Extended
|
// Extended
|
||||||
public ItemStack stack;
|
public ItemStack stack;
|
||||||
public ItemStack[] inventory;
|
public ItemStack[] inventory;
|
||||||
@ -52,10 +56,9 @@ public class EntityWrapper {
|
|||||||
public LivingEntityStats lived;
|
public LivingEntityStats lived;
|
||||||
public AgeableStats aged;
|
public AgeableStats aged;
|
||||||
public TameableStats tamed;
|
public TameableStats tamed;
|
||||||
|
ArmorStandStats stand;
|
||||||
private HorseStats horse;
|
private HorseStats horse;
|
||||||
private ArmorStandStats stand;
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public EntityWrapper(Entity entity, short depth) {
|
public EntityWrapper(Entity entity, short depth) {
|
||||||
this.hash = entity.getEntityId();
|
this.hash = entity.getEntityId();
|
||||||
this.depth = depth;
|
this.depth = depth;
|
||||||
@ -69,10 +72,9 @@ public class EntityWrapper {
|
|||||||
if (depth == 0) {
|
if (depth == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.base = new EntityBaseStats();
|
Entity passenger = entity.getPassenger();
|
||||||
Entity p = entity.getPassenger();
|
if (passenger != null) {
|
||||||
if (p != null) {
|
this.base.passenger = new EntityWrapper(passenger, depth);
|
||||||
this.base.passenger = new EntityWrapper(p, depth);
|
|
||||||
}
|
}
|
||||||
this.base.fall = entity.getFallDistance();
|
this.base.fall = entity.getFallDistance();
|
||||||
this.base.fire = (short) entity.getFireTicks();
|
this.base.fire = (short) entity.getFireTicks();
|
||||||
@ -168,10 +170,10 @@ public class EntityWrapper {
|
|||||||
this.horse.variant = getOrdinal(Variant.values(), horse.getVariant());
|
this.horse.variant = getOrdinal(Variant.values(), horse.getVariant());
|
||||||
this.horse.style = getOrdinal(Style.values(), horse.getStyle());
|
this.horse.style = getOrdinal(Style.values(), horse.getStyle());
|
||||||
this.horse.color = getOrdinal(Color.values(), horse.getColor());
|
this.horse.color = getOrdinal(Color.values(), horse.getColor());
|
||||||
storeTameable((Tameable) entity);
|
storeTameable(horse);
|
||||||
storeAgeable((Ageable) entity);
|
storeAgeable(horse);
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving(horse);
|
||||||
storeInventory((InventoryHolder) entity);
|
storeInventory(horse);
|
||||||
return;
|
return;
|
||||||
// END INVENTORY HOLDER //
|
// END INVENTORY HOLDER //
|
||||||
case WOLF:
|
case WOLF:
|
||||||
@ -185,8 +187,8 @@ public class EntityWrapper {
|
|||||||
Sheep sheep = (Sheep) entity;
|
Sheep sheep = (Sheep) entity;
|
||||||
this.dataByte = (byte) (sheep.isSheared() ? 1 : 0);
|
this.dataByte = (byte) (sheep.isSheared() ? 1 : 0);
|
||||||
this.dataByte2 = sheep.getColor().getDyeData();
|
this.dataByte2 = sheep.getColor().getDyeData();
|
||||||
storeAgeable((Ageable) entity);
|
storeAgeable(sheep);
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving(sheep);
|
||||||
return;
|
return;
|
||||||
case VILLAGER:
|
case VILLAGER:
|
||||||
case CHICKEN:
|
case CHICKEN:
|
||||||
@ -196,26 +198,25 @@ public class EntityWrapper {
|
|||||||
storeAgeable((Ageable) entity);
|
storeAgeable((Ageable) entity);
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
return;
|
return;
|
||||||
case RABBIT: // NEW
|
case RABBIT:
|
||||||
this.dataByte = getOrdinal(Type.values(), ((Rabbit) entity).getRabbitType());
|
this.dataByte = getOrdinal(Type.values(), ((Rabbit) entity).getRabbitType());
|
||||||
storeAgeable((Ageable) entity);
|
storeAgeable((Ageable) entity);
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
return;
|
return;
|
||||||
// END AGEABLE //
|
// END AGEABLE //
|
||||||
case GUARDIAN: // NEW
|
case GUARDIAN:
|
||||||
this.dataByte = (byte) (((Guardian) entity).isElder() ? 1 : 0);
|
this.dataByte = (byte) (((Guardian) entity).isElder() ? 1 : 0);
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
return;
|
return;
|
||||||
case SKELETON: // NEW
|
case SKELETON:
|
||||||
this.dataByte = (byte) ((Skeleton) entity).getSkeletonType().getId();
|
this.dataByte = (byte) ((Skeleton) entity).getSkeletonType().getId();
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
return;
|
return;
|
||||||
case ARMOR_STAND: // NEW
|
case ARMOR_STAND:
|
||||||
// CHECK positions
|
|
||||||
ArmorStand stand = (ArmorStand) entity;
|
ArmorStand stand = (ArmorStand) entity;
|
||||||
this.inventory = new ItemStack[]{stand.getItemInHand().clone(), stand.getHelmet().clone(), stand.getChestplate().clone(),
|
this.inventory = new ItemStack[]{stand.getItemInHand().clone(), stand.getHelmet().clone(), stand.getChestplate().clone(),
|
||||||
stand.getLeggings().clone(), stand.getBoots().clone()};
|
stand.getLeggings().clone(), stand.getBoots().clone()};
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving(stand);
|
||||||
this.stand = new ArmorStandStats();
|
this.stand = new ArmorStandStats();
|
||||||
|
|
||||||
EulerAngle head = stand.getHeadPose();
|
EulerAngle head = stand.getHeadPose();
|
||||||
@ -264,9 +265,19 @@ public class EntityWrapper {
|
|||||||
this.stand.small = true;
|
this.stand.small = true;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case ENDERMITE: // NEW
|
case ENDERMITE:
|
||||||
|
return;
|
||||||
case BAT:
|
case BAT:
|
||||||
|
if (((Bat) entity).isAwake()) {
|
||||||
|
this.dataByte = (byte) 1;
|
||||||
|
} else {
|
||||||
|
this.dataByte = (byte) 0;
|
||||||
|
}
|
||||||
|
return;
|
||||||
case ENDER_DRAGON:
|
case ENDER_DRAGON:
|
||||||
|
EnderDragon entity1 = (EnderDragon) entity;
|
||||||
|
this.dataByte = (byte) entity1.getPhase().ordinal();
|
||||||
|
return;
|
||||||
case GHAST:
|
case GHAST:
|
||||||
case MAGMA_CUBE:
|
case MAGMA_CUBE:
|
||||||
case SQUID:
|
case SQUID:
|
||||||
@ -283,8 +294,16 @@ public class EntityWrapper {
|
|||||||
case BLAZE:
|
case BLAZE:
|
||||||
case SHULKER:
|
case SHULKER:
|
||||||
case SNOWMAN:
|
case SNOWMAN:
|
||||||
case IRON_GOLEM:
|
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
|
return;
|
||||||
|
case IRON_GOLEM:
|
||||||
|
if (((IronGolem) entity).isPlayerCreated()) {
|
||||||
|
this.dataByte = (byte) 1;
|
||||||
|
} else {
|
||||||
|
this.dataByte = (byte) 0;
|
||||||
|
}
|
||||||
|
storeLiving((LivingEntity) entity);
|
||||||
|
return;
|
||||||
// END LIVING //
|
// END LIVING //
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,7 +322,7 @@ public class EntityWrapper {
|
|||||||
this.inventory = held.getInventory().getContents().clone();
|
this.inventory = held.getInventory().getContents().clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreLiving(LivingEntity entity) {
|
void restoreLiving(LivingEntity entity) {
|
||||||
entity.setCanPickupItems(this.lived.loot);
|
entity.setCanPickupItems(this.lived.loot);
|
||||||
if (this.lived.name != null) {
|
if (this.lived.name != null) {
|
||||||
entity.setCustomName(this.lived.name);
|
entity.setCustomName(this.lived.name);
|
||||||
@ -315,12 +334,7 @@ public class EntityWrapper {
|
|||||||
entity.setRemainingAir(this.lived.air);
|
entity.setRemainingAir(this.lived.air);
|
||||||
entity.setRemoveWhenFarAway(this.lived.persistent);
|
entity.setRemoveWhenFarAway(this.lived.persistent);
|
||||||
if (this.lived.equipped) {
|
if (this.lived.equipped) {
|
||||||
EntityEquipment equipment = entity.getEquipment();
|
this.restoreEquipment(entity);
|
||||||
equipment.setItemInHand(this.lived.hands);
|
|
||||||
equipment.setHelmet(this.lived.helmet);
|
|
||||||
equipment.setChestplate(this.lived.chestplate);
|
|
||||||
equipment.setLeggings(this.lived.leggings);
|
|
||||||
equipment.setBoots(this.lived.boots);
|
|
||||||
}
|
}
|
||||||
if (this.lived.leashed) {
|
if (this.lived.leashed) {
|
||||||
// TODO leashes
|
// TODO leashes
|
||||||
@ -331,6 +345,20 @@ public class EntityWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void restoreEquipment(LivingEntity entity) {
|
||||||
|
EntityEquipment equipment = entity.getEquipment();
|
||||||
|
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 0)) {
|
||||||
|
equipment.setItemInMainHand(this.lived.mainHand);
|
||||||
|
equipment.setItemInOffHand(this.lived.offHand);
|
||||||
|
} else {
|
||||||
|
equipment.setItemInHand(this.lived.mainHand);
|
||||||
|
}
|
||||||
|
equipment.setHelmet(this.lived.helmet);
|
||||||
|
equipment.setChestplate(this.lived.chestplate);
|
||||||
|
equipment.setLeggings(this.lived.leggings);
|
||||||
|
equipment.setBoots(this.lived.boots);
|
||||||
|
}
|
||||||
|
|
||||||
private void restoreInventory(InventoryHolder entity) {
|
private void restoreInventory(InventoryHolder entity) {
|
||||||
entity.getInventory().setContents(this.inventory);
|
entity.getInventory().setContents(this.inventory);
|
||||||
}
|
}
|
||||||
@ -354,14 +382,24 @@ public class EntityWrapper {
|
|||||||
EntityEquipment equipment = lived.getEquipment();
|
EntityEquipment equipment = lived.getEquipment();
|
||||||
this.lived.equipped = equipment != null;
|
this.lived.equipped = equipment != null;
|
||||||
if (this.lived.equipped) {
|
if (this.lived.equipped) {
|
||||||
this.lived.hands = equipment.getItemInHand().clone();
|
storeEquipment(equipment);
|
||||||
this.lived.boots = equipment.getBoots().clone();
|
|
||||||
this.lived.leggings = equipment.getLeggings().clone();
|
|
||||||
this.lived.chestplate = equipment.getChestplate().clone();
|
|
||||||
this.lived.helmet = equipment.getHelmet().clone();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void storeEquipment(EntityEquipment equipment) {
|
||||||
|
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 0)) {
|
||||||
|
this.lived.mainHand = equipment.getItemInMainHand().clone();
|
||||||
|
this.lived.offHand = equipment.getItemInOffHand().clone();
|
||||||
|
} else {
|
||||||
|
this.lived.mainHand = equipment.getItemInHand().clone();
|
||||||
|
this.lived.offHand = null;
|
||||||
|
}
|
||||||
|
this.lived.boots = equipment.getBoots().clone();
|
||||||
|
this.lived.leggings = equipment.getLeggings().clone();
|
||||||
|
this.lived.chestplate = equipment.getChestplate().clone();
|
||||||
|
this.lived.helmet = equipment.getHelmet().clone();
|
||||||
|
}
|
||||||
|
|
||||||
private void restoreTameable(Tameable entity) {
|
private void restoreTameable(Tameable entity) {
|
||||||
if (this.tamed.tamed) {
|
if (this.tamed.tamed) {
|
||||||
if (this.tamed.owner != null) {
|
if (this.tamed.owner != null) {
|
||||||
@ -394,7 +432,6 @@ public class EntityWrapper {
|
|||||||
this.tamed.tamed = tamed.isTamed();
|
this.tamed.tamed = tamed.isTamed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public Entity spawn(World world, int x_offset, int z_offset) {
|
public Entity spawn(World world, int x_offset, int z_offset) {
|
||||||
Location loc = new Location(world, this.x + x_offset, this.y, this.z + z_offset);
|
Location loc = new Location(world, this.x + x_offset, this.y, this.z + z_offset);
|
||||||
loc.setYaw(this.yaw);
|
loc.setYaw(this.yaw);
|
||||||
@ -449,6 +486,7 @@ public class EntityWrapper {
|
|||||||
case ENDER_CRYSTAL:
|
case ENDER_CRYSTAL:
|
||||||
case ENDER_PEARL:
|
case ENDER_PEARL:
|
||||||
case ENDER_SIGNAL:
|
case ENDER_SIGNAL:
|
||||||
|
case DROPPED_ITEM:
|
||||||
case EXPERIENCE_ORB:
|
case EXPERIENCE_ORB:
|
||||||
case FALLING_BLOCK:
|
case FALLING_BLOCK:
|
||||||
case FIREBALL:
|
case FIREBALL:
|
||||||
@ -463,11 +501,19 @@ public class EntityWrapper {
|
|||||||
case PLAYER:
|
case PLAYER:
|
||||||
case PRIMED_TNT:
|
case PRIMED_TNT:
|
||||||
case SLIME:
|
case SLIME:
|
||||||
|
((Slime) entity).setSize(this.dataByte);
|
||||||
|
return entity;
|
||||||
case SMALL_FIREBALL:
|
case SMALL_FIREBALL:
|
||||||
case SNOWBALL:
|
case SNOWBALL:
|
||||||
case SPLASH_POTION:
|
case SPLASH_POTION:
|
||||||
case THROWN_EXP_BOTTLE:
|
case THROWN_EXP_BOTTLE:
|
||||||
case WEATHER:
|
case WEATHER:
|
||||||
|
case TIPPED_ARROW:
|
||||||
|
case SPECTRAL_ARROW:
|
||||||
|
case SHULKER_BULLET:
|
||||||
|
case LINGERING_POTION:
|
||||||
|
case AREA_EFFECT_CLOUD:
|
||||||
|
case DRAGON_FIREBALL:
|
||||||
case WITHER_SKULL:
|
case WITHER_SKULL:
|
||||||
case MINECART_FURNACE:
|
case MINECART_FURNACE:
|
||||||
case UNKNOWN:
|
case UNKNOWN:
|
||||||
@ -503,10 +549,10 @@ public class EntityWrapper {
|
|||||||
horse.setVariant(Variant.values()[this.horse.variant]);
|
horse.setVariant(Variant.values()[this.horse.variant]);
|
||||||
horse.setStyle(Style.values()[this.horse.style]);
|
horse.setStyle(Style.values()[this.horse.style]);
|
||||||
horse.setColor(Color.values()[this.horse.color]);
|
horse.setColor(Color.values()[this.horse.color]);
|
||||||
restoreTameable((Tameable) entity);
|
restoreTameable(horse);
|
||||||
restoreAgeable((Ageable) entity);
|
restoreAgeable(horse);
|
||||||
restoreLiving((LivingEntity) entity);
|
restoreLiving(horse);
|
||||||
restoreInventory((InventoryHolder) entity);
|
restoreInventory(horse);
|
||||||
return entity;
|
return entity;
|
||||||
// END INVENTORY HOLDER //
|
// END INVENTORY HOLDER //
|
||||||
case WOLF:
|
case WOLF:
|
||||||
@ -524,9 +570,9 @@ public class EntityWrapper {
|
|||||||
if (this.dataByte2 != 0) {
|
if (this.dataByte2 != 0) {
|
||||||
sheep.setColor(DyeColor.getByDyeData(this.dataByte2));
|
sheep.setColor(DyeColor.getByDyeData(this.dataByte2));
|
||||||
}
|
}
|
||||||
restoreAgeable((Ageable) entity);
|
restoreAgeable(sheep);
|
||||||
restoreLiving((LivingEntity) entity);
|
restoreLiving(sheep);
|
||||||
return entity;
|
return sheep;
|
||||||
case VILLAGER:
|
case VILLAGER:
|
||||||
case CHICKEN:
|
case CHICKEN:
|
||||||
case COW:
|
case COW:
|
||||||
@ -536,26 +582,26 @@ public class EntityWrapper {
|
|||||||
restoreLiving((LivingEntity) entity);
|
restoreLiving((LivingEntity) entity);
|
||||||
return entity;
|
return entity;
|
||||||
// END AGEABLE //
|
// END AGEABLE //
|
||||||
case RABBIT: // NEW
|
case RABBIT:
|
||||||
if (this.dataByte != 0) {
|
if (this.dataByte != 0) {
|
||||||
((Rabbit) entity).setRabbitType(Type.values()[this.dataByte]);
|
((Rabbit) entity).setRabbitType(Type.values()[this.dataByte]);
|
||||||
}
|
}
|
||||||
restoreAgeable((Ageable) entity);
|
restoreAgeable((Ageable) entity);
|
||||||
restoreLiving((LivingEntity) entity);
|
restoreLiving((LivingEntity) entity);
|
||||||
return entity;
|
return entity;
|
||||||
case GUARDIAN: // NEW
|
case GUARDIAN:
|
||||||
if (this.dataByte != 0) {
|
if (this.dataByte != 0) {
|
||||||
((Guardian) entity).setElder(true);
|
((Guardian) entity).setElder(true);
|
||||||
}
|
}
|
||||||
restoreLiving((LivingEntity) entity);
|
restoreLiving((LivingEntity) entity);
|
||||||
return entity;
|
return entity;
|
||||||
case SKELETON: // NEW
|
case SKELETON:
|
||||||
if (this.dataByte != 0) {
|
if (this.dataByte != 0) {
|
||||||
((Skeleton) entity).setSkeletonType(SkeletonType.values()[this.dataByte]);
|
((Skeleton) entity).setSkeletonType(SkeletonType.values()[this.dataByte]);
|
||||||
}
|
}
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
return entity;
|
return entity;
|
||||||
case ARMOR_STAND: // NEW
|
case ARMOR_STAND:
|
||||||
// CHECK positions
|
// CHECK positions
|
||||||
ArmorStand stand = (ArmorStand) entity;
|
ArmorStand stand = (ArmorStand) entity;
|
||||||
if (this.inventory[0] != null) {
|
if (this.inventory[0] != null) {
|
||||||
@ -612,11 +658,21 @@ public class EntityWrapper {
|
|||||||
if (this.stand.small) {
|
if (this.stand.small) {
|
||||||
stand.setSmall(true);
|
stand.setSmall(true);
|
||||||
}
|
}
|
||||||
|
restoreLiving(stand);
|
||||||
|
return stand;
|
||||||
|
case BAT:
|
||||||
|
if (this.dataByte != 0) {
|
||||||
|
((Bat) entity).setAwake(true);
|
||||||
|
}
|
||||||
restoreLiving((LivingEntity) entity);
|
restoreLiving((LivingEntity) entity);
|
||||||
return entity;
|
return entity;
|
||||||
case ENDERMITE: // NEW
|
|
||||||
case BAT:
|
|
||||||
case ENDER_DRAGON:
|
case ENDER_DRAGON:
|
||||||
|
if (this.dataByte != 0) {
|
||||||
|
((EnderDragon) entity).setPhase(EnderDragon.Phase.values()[this.dataByte]);
|
||||||
|
}
|
||||||
|
restoreLiving((LivingEntity) entity);
|
||||||
|
return entity;
|
||||||
|
case ENDERMITE:
|
||||||
case GHAST:
|
case GHAST:
|
||||||
case MAGMA_CUBE:
|
case MAGMA_CUBE:
|
||||||
case SQUID:
|
case SQUID:
|
||||||
@ -632,7 +688,13 @@ public class EntityWrapper {
|
|||||||
case CREEPER:
|
case CREEPER:
|
||||||
case BLAZE:
|
case BLAZE:
|
||||||
case SNOWMAN:
|
case SNOWMAN:
|
||||||
|
case SHULKER:
|
||||||
|
restoreLiving((LivingEntity) entity);
|
||||||
|
return entity;
|
||||||
case IRON_GOLEM:
|
case IRON_GOLEM:
|
||||||
|
if (this.dataByte != 0) {
|
||||||
|
((IronGolem) entity).setPlayerCreated(true);
|
||||||
|
}
|
||||||
restoreLiving((LivingEntity) entity);
|
restoreLiving((LivingEntity) entity);
|
||||||
return entity;
|
return entity;
|
||||||
// END LIVING //
|
// END LIVING //
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package com.plotsquared.bukkit.object.entity;
|
package com.plotsquared.bukkit.object.entity;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
public class LivingEntityStats {
|
public class LivingEntityStats {
|
||||||
public boolean loot;
|
public boolean loot;
|
||||||
public String name;
|
public String name;
|
||||||
@ -17,10 +17,11 @@ public class LivingEntityStats {
|
|||||||
public short leash_y;
|
public short leash_y;
|
||||||
public short leash_z;
|
public short leash_z;
|
||||||
public boolean equipped;
|
public boolean equipped;
|
||||||
public ItemStack hands;
|
public ItemStack mainHand;
|
||||||
public ItemStack helmet;
|
public ItemStack helmet;
|
||||||
public ItemStack boots;
|
public ItemStack boots;
|
||||||
public ItemStack leggings;
|
public ItemStack leggings;
|
||||||
public ItemStack chestplate;
|
public ItemStack chestplate;
|
||||||
public Collection<PotionEffect> potions;
|
public Collection<PotionEffect> potions;
|
||||||
|
public ItemStack offHand;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -1,86 +1,14 @@
|
|||||||
package com.plotsquared.bukkit.titles;
|
package com.plotsquared.bukkit.titles;
|
||||||
|
|
||||||
import com.plotsquared.bukkit.chat.Reflection;
|
import com.plotsquared.bukkit.chat.Reflection;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
public class DefaultTitleManager extends TitleManager {
|
||||||
* [ PlotSquared DefaultTitleManager by Maxim Van de Wynckel ]
|
|
||||||
*
|
|
||||||
* @author Maxim Van de Wynckel
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class DefaultTitleManager {
|
|
||||||
|
|
||||||
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<>();
|
|
||||||
/* Title packet */
|
|
||||||
private Class<?> packetTitle;
|
|
||||||
/* Title packet actions ENUM */
|
|
||||||
private Class<?> packetActions;
|
|
||||||
/* Chat serializer */
|
|
||||||
private Class<?> nmsChatSerializer;
|
|
||||||
private Class<?> chatBaseComponent;
|
|
||||||
/* Title text and color */
|
|
||||||
private String title = "";
|
|
||||||
private ChatColor titleColor = ChatColor.WHITE;
|
|
||||||
/* Subtitle text and color */
|
|
||||||
private String subtitle = "";
|
|
||||||
private ChatColor subtitleColor = ChatColor.WHITE;
|
|
||||||
/* Title timings */
|
|
||||||
private int fadeInTime = -1;
|
|
||||||
private int stayTime = -1;
|
|
||||||
private int fadeOutTime = -1;
|
|
||||||
private boolean ticks = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new 1.8 title.
|
|
||||||
*
|
|
||||||
* @param title Title
|
|
||||||
* @throws ClassNotFoundException
|
|
||||||
*/
|
|
||||||
public DefaultTitleManager(String title) throws ClassNotFoundException {
|
|
||||||
this.title = title;
|
|
||||||
loadClasses();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new 1.8 title.
|
|
||||||
*
|
|
||||||
* @param title Title text
|
|
||||||
* @param subtitle Subtitle text
|
|
||||||
* @throws ClassNotFoundException
|
|
||||||
*/
|
|
||||||
public DefaultTitleManager(String title, String subtitle) throws ClassNotFoundException {
|
|
||||||
this.title = title;
|
|
||||||
this.subtitle = subtitle;
|
|
||||||
loadClasses();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy 1.8 title.
|
|
||||||
*
|
|
||||||
* @param title Title
|
|
||||||
* @throws ClassNotFoundException
|
|
||||||
*/
|
|
||||||
public DefaultTitleManager(DefaultTitleManager title) throws ClassNotFoundException {
|
|
||||||
// Copy title
|
|
||||||
this.title = title.title;
|
|
||||||
this.subtitle = title.subtitle;
|
|
||||||
this.titleColor = title.titleColor;
|
|
||||||
this.subtitleColor = title.subtitleColor;
|
|
||||||
this.fadeInTime = title.fadeInTime;
|
|
||||||
this.fadeOutTime = title.fadeOutTime;
|
|
||||||
this.stayTime = title.stayTime;
|
|
||||||
this.ticks = title.ticks;
|
|
||||||
loadClasses();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new 1.8 title.
|
* Create a new 1.8 title.
|
||||||
@ -90,16 +18,9 @@ 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 {
|
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
|
||||||
this.title = title;
|
|
||||||
this.subtitle = subtitle;
|
|
||||||
this.fadeInTime = fadeInTime;
|
|
||||||
this.stayTime = stayTime;
|
|
||||||
this.fadeOutTime = fadeOutTime;
|
|
||||||
loadClasses();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
||||||
@ -117,115 +38,20 @@ public class DefaultTitleManager {
|
|||||||
/**
|
/**
|
||||||
* Load spigot and NMS classes.
|
* Load spigot and NMS classes.
|
||||||
*/
|
*/
|
||||||
private void loadClasses() {
|
@Override void loadClasses() {
|
||||||
this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle");
|
this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle");
|
||||||
this.packetActions = Reflection.getNMSClass("EnumTitleAction");
|
this.packetActions = Reflection.getNMSClass("EnumTitleAction");
|
||||||
this.chatBaseComponent = Reflection.getNMSClass("IChatBaseComponent");
|
this.chatBaseComponent = Reflection.getNMSClass("IChatBaseComponent");
|
||||||
this.nmsChatSerializer = Reflection.getNMSClass("ChatSerializer");
|
this.nmsChatSerializer = Reflection.getNMSClass("ChatSerializer");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get title text.
|
|
||||||
*
|
|
||||||
* @return Title text
|
|
||||||
*/
|
|
||||||
public String getTitle() {
|
|
||||||
return this.title;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set title text.
|
|
||||||
*
|
|
||||||
* @param title Title
|
|
||||||
*/
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get subtitle text.
|
|
||||||
*
|
|
||||||
* @return Subtitle text
|
|
||||||
*/
|
|
||||||
public String getSubtitle() {
|
|
||||||
return this.subtitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set subtitle text.
|
|
||||||
*
|
|
||||||
* @param subtitle Subtitle text
|
|
||||||
*/
|
|
||||||
public void setSubtitle(String subtitle) {
|
|
||||||
this.subtitle = subtitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the title color.
|
|
||||||
*
|
|
||||||
* @param color Chat color
|
|
||||||
*/
|
|
||||||
public void setTitleColor(ChatColor color) {
|
|
||||||
this.titleColor = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the subtitle color.
|
|
||||||
*
|
|
||||||
* @param color Chat color
|
|
||||||
*/
|
|
||||||
public void setSubtitleColor(ChatColor color) {
|
|
||||||
this.subtitleColor = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set title fade in time.
|
|
||||||
*
|
|
||||||
* @param time Time
|
|
||||||
*/
|
|
||||||
public void setFadeInTime(int time) {
|
|
||||||
this.fadeInTime = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set title fade out time.
|
|
||||||
*
|
|
||||||
* @param time Time
|
|
||||||
*/
|
|
||||||
public void setFadeOutTime(int time) {
|
|
||||||
this.fadeOutTime = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set title stay time.
|
|
||||||
*
|
|
||||||
* @param time Time
|
|
||||||
*/
|
|
||||||
public void setStayTime(int time) {
|
|
||||||
this.stayTime = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set timings to ticks.
|
|
||||||
*/
|
|
||||||
public void setTimingsToTicks() {
|
|
||||||
this.ticks = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set timings to seconds.
|
|
||||||
*/
|
|
||||||
public void setTimingsToSeconds() {
|
|
||||||
this.ticks = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the title to a player.
|
* Send the title to a player.
|
||||||
*
|
*
|
||||||
* @param player Player
|
* @param player Player
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void send(Player player) throws Exception {
|
@Override public void send(Player player) throws Exception {
|
||||||
if (this.packetTitle != null) {
|
if (this.packetTitle != null) {
|
||||||
// First reset previous settings
|
// First reset previous settings
|
||||||
resetTitle(player);
|
resetTitle(player);
|
||||||
@ -243,13 +69,14 @@ public class DefaultTitleManager {
|
|||||||
}
|
}
|
||||||
// Send title
|
// Send title
|
||||||
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
||||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.title) + "\",color:" + this.titleColor.name().toLowerCase() + "}");
|
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getTitle()) + "\",color:" + this.titleColor.name().toLowerCase()
|
||||||
|
+ "}");
|
||||||
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[0], serialized);
|
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[0], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
if (!this.subtitle.isEmpty()) {
|
if (!this.getSubtitle().isEmpty()) {
|
||||||
// Send subtitle if present
|
// Send subtitle if present
|
||||||
serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
||||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.subtitle) + "\",color:" + this.subtitleColor.name()
|
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getSubtitle()) + "\",color:" + this.subtitleColor.name()
|
||||||
.toLowerCase() + "}");
|
.toLowerCase() + "}");
|
||||||
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[1], serialized);
|
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[1], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
@ -257,24 +84,13 @@ public class DefaultTitleManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Broadcast the title to all players.
|
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public void broadcast() throws Exception {
|
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
|
||||||
send(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the title.
|
* Clear the title.
|
||||||
*
|
*
|
||||||
* @param player Player
|
* @param player Player
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void clearTitle(Player player) throws Exception {
|
@Override public void clearTitle(Player player) throws Exception {
|
||||||
// Send timings first
|
// Send timings first
|
||||||
Object handle = getHandle(player);
|
Object handle = getHandle(player);
|
||||||
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||||
@ -290,7 +106,7 @@ public class DefaultTitleManager {
|
|||||||
* @param player Player
|
* @param player Player
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void resetTitle(Player player) throws Exception {
|
@Override public void resetTitle(Player player) throws Exception {
|
||||||
// Send timings first
|
// Send timings first
|
||||||
Object handle = getHandle(player);
|
Object handle = getHandle(player);
|
||||||
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||||
@ -300,29 +116,10 @@ public class DefaultTitleManager {
|
|||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Class<?> getPrimitiveType(Class<?> clazz) {
|
|
||||||
return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
|
|
||||||
int a = classes != null ? classes.length : 0;
|
|
||||||
Class<?>[] types = new Class<?>[a];
|
|
||||||
for (int i = 0; i < a; i++) {
|
|
||||||
types[i] = getPrimitiveType(classes[i]);
|
|
||||||
}
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object getHandle(Object obj) {
|
private Object getHandle(Object obj) {
|
||||||
try {
|
try {
|
||||||
return getMethod("getHandle", obj.getClass()).invoke(obj);
|
return getMethod("getHandle", obj.getClass()).invoke(obj);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -344,10 +141,7 @@ public class DefaultTitleManager {
|
|||||||
Field field = clazz.getDeclaredField(name);
|
Field field = clazz.getDeclaredField(name);
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
return field;
|
return field;
|
||||||
} catch (NoSuchFieldException e) {
|
} catch (NoSuchFieldException | SecurityException e) {
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
} catch (SecurityException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,87 +1,13 @@
|
|||||||
package com.plotsquared.bukkit.titles;
|
package com.plotsquared.bukkit.titles;
|
||||||
|
|
||||||
import com.plotsquared.bukkit.chat.Reflection;
|
import com.plotsquared.bukkit.chat.Reflection;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
public class DefaultTitleManager_183 extends TitleManager {
|
||||||
* [ PlotSquared DefaultTitleManager by Maxim Van de Wynckel ]
|
|
||||||
*
|
|
||||||
* @version 1.1.0
|
|
||||||
* @author Maxim Van de Wynckel
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class DefaultTitleManager_183 {
|
|
||||||
|
|
||||||
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<>();
|
|
||||||
/* Title packet */
|
|
||||||
private Class<?> packetTitle;
|
|
||||||
/* Title packet actions ENUM */
|
|
||||||
private Class<?> packetActions;
|
|
||||||
/* Chat serializer */
|
|
||||||
private Class<?> nmsChatSerializer;
|
|
||||||
private Class<?> chatBaseComponent;
|
|
||||||
/* Title text and color */
|
|
||||||
private String title = "";
|
|
||||||
private ChatColor titleColor = ChatColor.WHITE;
|
|
||||||
/* Subtitle text and color */
|
|
||||||
private String subtitle = "";
|
|
||||||
private ChatColor subtitleColor = ChatColor.WHITE;
|
|
||||||
/* Title timings */
|
|
||||||
private int fadeInTime = -1;
|
|
||||||
private int stayTime = -1;
|
|
||||||
private int fadeOutTime = -1;
|
|
||||||
private boolean ticks = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new 1.8 title
|
|
||||||
*
|
|
||||||
* @param title
|
|
||||||
* Title
|
|
||||||
* @throws ClassNotFoundException
|
|
||||||
*/
|
|
||||||
public DefaultTitleManager_183(String title) throws ClassNotFoundException {
|
|
||||||
this.title = title;
|
|
||||||
loadClasses();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new 1.8 title.
|
|
||||||
*
|
|
||||||
* @param title Title text
|
|
||||||
* @param subtitle Subtitle text
|
|
||||||
* @throws ClassNotFoundException
|
|
||||||
*/
|
|
||||||
public DefaultTitleManager_183(String title, String subtitle) throws ClassNotFoundException {
|
|
||||||
this.title = title;
|
|
||||||
this.subtitle = subtitle;
|
|
||||||
loadClasses();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy 1.8 title.
|
|
||||||
*
|
|
||||||
* @param title Title
|
|
||||||
* @throws ClassNotFoundException
|
|
||||||
*/
|
|
||||||
public DefaultTitleManager_183(DefaultTitleManager_183 title) throws ClassNotFoundException {
|
|
||||||
// Copy title
|
|
||||||
this.title = title.title;
|
|
||||||
this.subtitle = title.subtitle;
|
|
||||||
this.titleColor = title.titleColor;
|
|
||||||
this.subtitleColor = title.subtitleColor;
|
|
||||||
this.fadeInTime = title.fadeInTime;
|
|
||||||
this.fadeOutTime = title.fadeOutTime;
|
|
||||||
this.stayTime = title.stayTime;
|
|
||||||
this.ticks = title.ticks;
|
|
||||||
loadClasses();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new 1.8 title.
|
* Create a new 1.8 title.
|
||||||
@ -91,15 +17,9 @@ 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;
|
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
|
||||||
this.subtitle = subtitle;
|
|
||||||
this.fadeInTime = fadeInTime;
|
|
||||||
this.stayTime = stayTime;
|
|
||||||
this.fadeOutTime = fadeOutTime;
|
|
||||||
loadClasses();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
||||||
@ -117,7 +37,8 @@ public class DefaultTitleManager_183 {
|
|||||||
/**
|
/**
|
||||||
* Load spigot and NMS classes.
|
* Load spigot and NMS classes.
|
||||||
*/
|
*/
|
||||||
private void loadClasses() {
|
@Override
|
||||||
|
void loadClasses() {
|
||||||
this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle");
|
this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle");
|
||||||
this.chatBaseComponent = Reflection.getNMSClass("IChatBaseComponent");
|
this.chatBaseComponent = Reflection.getNMSClass("IChatBaseComponent");
|
||||||
this.packetActions = Reflection.getNMSClass("PacketPlayOutTitle$EnumTitleAction");
|
this.packetActions = Reflection.getNMSClass("PacketPlayOutTitle$EnumTitleAction");
|
||||||
@ -125,108 +46,7 @@ public class DefaultTitleManager_183 {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Get title text.
|
|
||||||
*
|
|
||||||
* @return Title text
|
|
||||||
*/
|
|
||||||
public String getTitle() {
|
|
||||||
return this.title;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set title text.
|
|
||||||
*
|
|
||||||
* @param title Title
|
|
||||||
*/
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get subtitle text.
|
|
||||||
*
|
|
||||||
* @return Subtitle text
|
|
||||||
*/
|
|
||||||
public String getSubtitle() {
|
|
||||||
return this.subtitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set subtitle text.
|
|
||||||
*
|
|
||||||
* @param subtitle Subtitle text
|
|
||||||
*/
|
|
||||||
public void setSubtitle(String subtitle) {
|
|
||||||
this.subtitle = subtitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the title color.
|
|
||||||
*
|
|
||||||
* @param color Chat color
|
|
||||||
*/
|
|
||||||
public void setTitleColor(ChatColor color) {
|
|
||||||
this.titleColor = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the subtitle color.
|
|
||||||
*
|
|
||||||
* @param color Chat color
|
|
||||||
*/
|
|
||||||
public void setSubtitleColor(ChatColor color) {
|
|
||||||
this.subtitleColor = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set title fade in time.
|
|
||||||
*
|
|
||||||
* @param time
|
|
||||||
* Time
|
|
||||||
*/
|
|
||||||
public void setFadeInTime(int time) {
|
|
||||||
this.fadeInTime = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set title fade out time.
|
|
||||||
*
|
|
||||||
* @param time Time
|
|
||||||
*/
|
|
||||||
public void setFadeOutTime(int time) {
|
|
||||||
this.fadeOutTime = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set title stay time.
|
|
||||||
*
|
|
||||||
* @param time Time
|
|
||||||
*/
|
|
||||||
public void setStayTime(int time) {
|
|
||||||
this.stayTime = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set timings to ticks.
|
|
||||||
*/
|
|
||||||
public void setTimingsToTicks() {
|
|
||||||
this.ticks = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set timings to seconds.
|
|
||||||
*/
|
|
||||||
public void setTimingsToSeconds() {
|
|
||||||
this.ticks = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send the title to a player.
|
|
||||||
*
|
|
||||||
* @param player Player
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public void send(Player player) throws Exception {
|
public void send(Player player) throws Exception {
|
||||||
if (this.packetTitle != null) {
|
if (this.packetTitle != null) {
|
||||||
// First reset previous settings
|
// First reset previous settings
|
||||||
@ -247,13 +67,14 @@ public class DefaultTitleManager_183 {
|
|||||||
}
|
}
|
||||||
// Send title
|
// Send title
|
||||||
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
||||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.title) + "\",color:" + this.titleColor.name().toLowerCase() + "}");
|
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getTitle()) + "\",color:" + this.titleColor.name().toLowerCase()
|
||||||
|
+ "}");
|
||||||
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[0], serialized);
|
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[0], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
if (!this.subtitle.isEmpty()) {
|
if (!this.getSubtitle().isEmpty()) {
|
||||||
// Send subtitle if present
|
// Send subtitle if present
|
||||||
serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
||||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.subtitle) + "\",color:" + this.subtitleColor.name()
|
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getSubtitle()) + "\",color:" + this.subtitleColor.name()
|
||||||
.toLowerCase() + "}");
|
.toLowerCase() + "}");
|
||||||
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[1], serialized);
|
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[1], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
@ -261,22 +82,13 @@ public class DefaultTitleManager_183 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Broadcast the title to all players.
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public void broadcast() throws Exception {
|
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
|
||||||
send(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the title.
|
* Clear the title.
|
||||||
*
|
*
|
||||||
* @param player Player
|
* @param player Player
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void clearTitle(Player player) throws Exception {
|
public void clearTitle(Player player) throws Exception {
|
||||||
// Send timings first
|
// Send timings first
|
||||||
Object handle = getHandle(player);
|
Object handle = getHandle(player);
|
||||||
@ -293,6 +105,7 @@ public class DefaultTitleManager_183 {
|
|||||||
* @param player Player
|
* @param player Player
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void resetTitle(Player player) throws Exception {
|
public void resetTitle(Player player) throws Exception {
|
||||||
// Send timings first
|
// Send timings first
|
||||||
Object handle = getHandle(player);
|
Object handle = getHandle(player);
|
||||||
@ -303,19 +116,6 @@ public class DefaultTitleManager_183 {
|
|||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Class<?> getPrimitiveType(Class<?> clazz) {
|
|
||||||
return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
|
|
||||||
int a = classes != null ? classes.length : 0;
|
|
||||||
Class<?>[] types = new Class<?>[a];
|
|
||||||
for (int i = 0; i < a; i++) {
|
|
||||||
types[i] = getPrimitiveType(classes[i]);
|
|
||||||
}
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object getHandle(Object obj) {
|
private Object getHandle(Object obj) {
|
||||||
try {
|
try {
|
||||||
return getMethod("getHandle", obj.getClass()).invoke(obj);
|
return getMethod("getHandle", obj.getClass()).invoke(obj);
|
||||||
|
@ -11,7 +11,7 @@ public class DefaultTitle_183 extends AbstractTitle {
|
|||||||
try {
|
try {
|
||||||
DefaultTitleManager_183 title = new DefaultTitleManager_183(head, sub, in, delay, out);
|
DefaultTitleManager_183 title = new DefaultTitleManager_183(head, sub, in, delay, out);
|
||||||
title.send(((BukkitPlayer) player).player);
|
title.send(((BukkitPlayer) player).player);
|
||||||
} catch (Throwable e) {
|
} catch (Exception e) {
|
||||||
AbstractTitle.TITLE_CLASS = new HackTitle();
|
AbstractTitle.TITLE_CLASS = new HackTitle();
|
||||||
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
|
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ public class HackTitle extends AbstractTitle {
|
|||||||
try {
|
try {
|
||||||
HackTitleManager title = new HackTitleManager(head, sub, in, delay, out);
|
HackTitleManager title = new HackTitleManager(head, sub, in, delay, out);
|
||||||
title.send(((BukkitPlayer) player).player);
|
title.send(((BukkitPlayer) player).player);
|
||||||
} catch (Throwable e) {
|
} catch (Exception e) {
|
||||||
PS.debug("&cYour server version does not support titles!");
|
PS.debug("&cYour server version does not support titles!");
|
||||||
Settings.TITLES = false;
|
Settings.TITLES = false;
|
||||||
AbstractTitle.TITLE_CLASS = null;
|
AbstractTitle.TITLE_CLASS = null;
|
||||||
|
@ -8,78 +8,8 @@ import org.bukkit.entity.Player;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
public class HackTitleManager extends TitleManager {
|
||||||
* Minecraft 1.8 Title.
|
|
||||||
*
|
|
||||||
* @version 1.0.4
|
|
||||||
* @author Maxim Van de Wynckel
|
|
||||||
*/
|
|
||||||
public class HackTitleManager {
|
|
||||||
|
|
||||||
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<>();
|
|
||||||
/* Title packet */
|
|
||||||
private Class<?> packetTitle;
|
|
||||||
/* Title packet actions ENUM */
|
|
||||||
private Class<?> packetActions;
|
|
||||||
/* Chat serializer */
|
|
||||||
private Class<?> nmsChatSerializer;
|
|
||||||
/* Title text and color */
|
|
||||||
private String title = "";
|
|
||||||
private ChatColor titleColor = ChatColor.WHITE;
|
|
||||||
/* Subtitle text and color */
|
|
||||||
private String subtitle = "";
|
|
||||||
private ChatColor subtitleColor = ChatColor.WHITE;
|
|
||||||
/* Title timings. */
|
|
||||||
private int fadeInTime = -1;
|
|
||||||
private int stayTime = -1;
|
|
||||||
private int fadeOutTime = -1;
|
|
||||||
private boolean ticks = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new 1.8 title.
|
|
||||||
*
|
|
||||||
* @param title Title
|
|
||||||
* @throws ClassNotFoundException NMS Error.
|
|
||||||
*/
|
|
||||||
public HackTitleManager(String title) throws ClassNotFoundException {
|
|
||||||
this.title = title;
|
|
||||||
loadClasses();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new 1.8 title.
|
|
||||||
*
|
|
||||||
* @param title Title text
|
|
||||||
* @param subtitle Subtitle text
|
|
||||||
* @throws ClassNotFoundException NMS Error
|
|
||||||
*/
|
|
||||||
public HackTitleManager(String title, String subtitle) throws ClassNotFoundException {
|
|
||||||
this.title = title;
|
|
||||||
this.subtitle = subtitle;
|
|
||||||
loadClasses();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy 1.8 title.
|
|
||||||
*
|
|
||||||
* @param title Title
|
|
||||||
* @throws ClassNotFoundException NMS Error
|
|
||||||
*/
|
|
||||||
public HackTitleManager(HackTitleManager title) throws ClassNotFoundException {
|
|
||||||
// Copy title
|
|
||||||
this.title = title.title;
|
|
||||||
this.subtitle = title.subtitle;
|
|
||||||
this.titleColor = title.titleColor;
|
|
||||||
this.subtitleColor = title.subtitleColor;
|
|
||||||
this.fadeInTime = title.fadeInTime;
|
|
||||||
this.fadeOutTime = title.fadeOutTime;
|
|
||||||
this.stayTime = title.stayTime;
|
|
||||||
this.ticks = title.ticks;
|
|
||||||
loadClasses();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new 1.8 title.
|
* Create a new 1.8 title.
|
||||||
@ -89,15 +19,9 @@ 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;
|
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
|
||||||
this.subtitle = subtitle;
|
|
||||||
this.fadeInTime = fadeInTime;
|
|
||||||
this.stayTime = stayTime;
|
|
||||||
this.fadeOutTime = fadeOutTime;
|
|
||||||
loadClasses();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
||||||
@ -115,114 +39,20 @@ public class HackTitleManager {
|
|||||||
/**
|
/**
|
||||||
* Load spigot and NMS classes.
|
* Load spigot and NMS classes.
|
||||||
*/
|
*/
|
||||||
private void loadClasses() {
|
@Override
|
||||||
|
void loadClasses() {
|
||||||
this.packetTitle = getClass("org.spigotmc.ProtocolInjector$PacketTitle");
|
this.packetTitle = getClass("org.spigotmc.ProtocolInjector$PacketTitle");
|
||||||
this.packetActions = getClass("org.spigotmc.ProtocolInjector$PacketTitle$Action");
|
this.packetActions = getClass("org.spigotmc.ProtocolInjector$PacketTitle$Action");
|
||||||
this.nmsChatSerializer = Reflection.getNMSClass("ChatSerializer");
|
this.nmsChatSerializer = Reflection.getNMSClass("ChatSerializer");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get title text.
|
|
||||||
*
|
|
||||||
* @return Title text
|
|
||||||
*/
|
|
||||||
public String getTitle() {
|
|
||||||
return this.title;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set title text.
|
|
||||||
*
|
|
||||||
* @param title Title
|
|
||||||
*/
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get subtitle text.
|
|
||||||
*
|
|
||||||
* @return Subtitle text
|
|
||||||
*/
|
|
||||||
public String getSubtitle() {
|
|
||||||
return this.subtitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set subtitle text.
|
|
||||||
*
|
|
||||||
* @param subtitle Subtitle text
|
|
||||||
*/
|
|
||||||
public void setSubtitle(String subtitle) {
|
|
||||||
this.subtitle = subtitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the title color.
|
|
||||||
*
|
|
||||||
* @param color Chat color
|
|
||||||
*/
|
|
||||||
public void setTitleColor(ChatColor color) {
|
|
||||||
this.titleColor = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the subtitle color.
|
|
||||||
*
|
|
||||||
* @param color Chat color
|
|
||||||
*/
|
|
||||||
public void setSubtitleColor(ChatColor color) {
|
|
||||||
this.subtitleColor = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set title fade in time.
|
|
||||||
*
|
|
||||||
* @param time Time
|
|
||||||
*/
|
|
||||||
public void setFadeInTime(int time) {
|
|
||||||
this.fadeInTime = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set title fade out time.
|
|
||||||
*
|
|
||||||
* @param time Time
|
|
||||||
*/
|
|
||||||
public void setFadeOutTime(int time) {
|
|
||||||
this.fadeOutTime = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set title stay time.
|
|
||||||
*
|
|
||||||
* @param time Time
|
|
||||||
*/
|
|
||||||
public void setStayTime(int time) {
|
|
||||||
this.stayTime = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set timings to ticks.
|
|
||||||
*/
|
|
||||||
public void setTimingsToTicks() {
|
|
||||||
this.ticks = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set timings to seconds.
|
|
||||||
*/
|
|
||||||
public void setTimingsToSeconds() {
|
|
||||||
this.ticks = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the title to a player.
|
* Send the title to a player.
|
||||||
*
|
*
|
||||||
* @param player Player
|
* @param player Player
|
||||||
* @throws Exception on NMS error
|
* @throws Exception on NMS error
|
||||||
*/
|
*/
|
||||||
public void send(Player player) throws Exception {
|
@Override public void send(Player player) throws Exception {
|
||||||
if ((getProtocolVersion(player) >= 47) && isSpigot() && (this.packetTitle != null)) {
|
if ((getProtocolVersion(player) >= 47) && isSpigot() && (this.packetTitle != null)) {
|
||||||
// First reset previous settings
|
// First reset previous settings
|
||||||
resetTitle(player);
|
resetTitle(player);
|
||||||
@ -241,14 +71,15 @@ public class HackTitleManager {
|
|||||||
}
|
}
|
||||||
// Send title
|
// Send title
|
||||||
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
||||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.title) + "\",color:" + this.titleColor.name().toLowerCase() + "}");
|
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getTitle()) + "\",color:" + this.titleColor.name().toLowerCase()
|
||||||
|
+ "}");
|
||||||
packet = this.packetTitle.getConstructor(this.packetActions, Reflection.getNMSClass("IChatBaseComponent"))
|
packet = this.packetTitle.getConstructor(this.packetActions, Reflection.getNMSClass("IChatBaseComponent"))
|
||||||
.newInstance(actions[0], serialized);
|
.newInstance(actions[0], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
if (!this.subtitle.isEmpty()) {
|
if (!this.getSubtitle().isEmpty()) {
|
||||||
// Send subtitle if present
|
// Send subtitle if present
|
||||||
serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
||||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.subtitle) + "\",color:" + this.subtitleColor.name()
|
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getSubtitle()) + "\",color:" + this.subtitleColor.name()
|
||||||
.toLowerCase() + "}");
|
.toLowerCase() + "}");
|
||||||
packet = this.packetTitle.getConstructor(this.packetActions, Reflection.getNMSClass("IChatBaseComponent"))
|
packet = this.packetTitle.getConstructor(this.packetActions, Reflection.getNMSClass("IChatBaseComponent"))
|
||||||
.newInstance(actions[1], serialized);
|
.newInstance(actions[1], serialized);
|
||||||
@ -257,23 +88,13 @@ public class HackTitleManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Broadcast the title to all players.
|
|
||||||
* @throws Exception on NMS Error
|
|
||||||
*/
|
|
||||||
public void broadcast() throws Exception {
|
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
|
||||||
send(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the title.
|
* Clear the title.
|
||||||
*
|
*
|
||||||
* @param player Player
|
* @param player Player
|
||||||
* @throws Exception on NMS Error
|
* @throws Exception on NMS Error
|
||||||
*/
|
*/
|
||||||
public void clearTitle(Player player) throws Exception {
|
@Override public void clearTitle(Player player) throws Exception {
|
||||||
if ((getProtocolVersion(player) >= 47) && isSpigot()) {
|
if ((getProtocolVersion(player) >= 47) && isSpigot()) {
|
||||||
// Send timings first
|
// Send timings first
|
||||||
Object handle = getHandle(player);
|
Object handle = getHandle(player);
|
||||||
@ -291,7 +112,7 @@ public class HackTitleManager {
|
|||||||
* @param player Player
|
* @param player Player
|
||||||
* @throws Exception on NMS error.
|
* @throws Exception on NMS error.
|
||||||
*/
|
*/
|
||||||
public void resetTitle(Player player) throws Exception {
|
@Override public void resetTitle(Player player) throws Exception {
|
||||||
if ((getProtocolVersion(player) >= 47) && isSpigot()) {
|
if ((getProtocolVersion(player) >= 47) && isSpigot()) {
|
||||||
// Send timings first
|
// Send timings first
|
||||||
Object handle = getHandle(player);
|
Object handle = getHandle(player);
|
||||||
@ -350,19 +171,6 @@ public class HackTitleManager {
|
|||||||
return f.get(obj);
|
return f.get(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Class<?> getPrimitiveType(Class<?> clazz) {
|
|
||||||
return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
|
|
||||||
int a = classes != null ? classes.length : 0;
|
|
||||||
Class<?>[] types = new Class<?>[a];
|
|
||||||
for (int i = 0; i < a; i++) {
|
|
||||||
types[i] = getPrimitiveType(classes[i]);
|
|
||||||
}
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object getHandle(Object obj) {
|
private Object getHandle(Object obj) {
|
||||||
try {
|
try {
|
||||||
return getMethod("getHandle", obj.getClass()).invoke(obj);
|
return getMethod("getHandle", obj.getClass()).invoke(obj);
|
||||||
|
@ -0,0 +1,204 @@
|
|||||||
|
package com.plotsquared.bukkit.titles;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public abstract class TitleManager {
|
||||||
|
|
||||||
|
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<>();
|
||||||
|
/* Title packet */
|
||||||
|
Class<?> packetTitle;
|
||||||
|
/* Title packet actions ENUM */
|
||||||
|
Class<?> packetActions;
|
||||||
|
/* Chat serializer */
|
||||||
|
Class<?> nmsChatSerializer;
|
||||||
|
Class<?> chatBaseComponent;
|
||||||
|
ChatColor titleColor = ChatColor.WHITE;
|
||||||
|
ChatColor subtitleColor = ChatColor.WHITE;
|
||||||
|
/* Title timings */
|
||||||
|
int fadeInTime = -1;
|
||||||
|
int stayTime = -1;
|
||||||
|
int fadeOutTime = -1;
|
||||||
|
boolean ticks = false;
|
||||||
|
/* Title text and color */
|
||||||
|
private String title = "";
|
||||||
|
/* Subtitle text and color */
|
||||||
|
private String subtitle = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new 1.8 title.
|
||||||
|
*
|
||||||
|
* @param title Title text
|
||||||
|
* @param subtitle Subtitle text
|
||||||
|
* @param fadeInTime Fade in time
|
||||||
|
* @param stayTime Stay on screen time
|
||||||
|
* @param fadeOutTime Fade out time
|
||||||
|
*/
|
||||||
|
TitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
|
||||||
|
this.title = title;
|
||||||
|
this.subtitle = subtitle;
|
||||||
|
this.fadeInTime = fadeInTime;
|
||||||
|
this.stayTime = stayTime;
|
||||||
|
this.fadeOutTime = fadeOutTime;
|
||||||
|
loadClasses();
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract void loadClasses();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get title text.
|
||||||
|
*
|
||||||
|
* @return Title text
|
||||||
|
*/
|
||||||
|
public final String getTitle() {
|
||||||
|
return this.title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set title text.
|
||||||
|
*
|
||||||
|
* @param title Title
|
||||||
|
*/
|
||||||
|
public final void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get subtitle text.
|
||||||
|
*
|
||||||
|
* @return Subtitle text
|
||||||
|
*/
|
||||||
|
public final String getSubtitle() {
|
||||||
|
return this.subtitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set subtitle text.
|
||||||
|
*
|
||||||
|
* @param subtitle Subtitle text
|
||||||
|
*/
|
||||||
|
public final void setSubtitle(String subtitle) {
|
||||||
|
this.subtitle = subtitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the title color.
|
||||||
|
*
|
||||||
|
* @param color Chat color
|
||||||
|
*/
|
||||||
|
public final void setTitleColor(ChatColor color) {
|
||||||
|
this.titleColor = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the subtitle color.
|
||||||
|
*
|
||||||
|
* @param color Chat color
|
||||||
|
*/
|
||||||
|
public final void setSubtitleColor(ChatColor color) {
|
||||||
|
this.subtitleColor = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set title fade in time.
|
||||||
|
*
|
||||||
|
* @param time Time
|
||||||
|
*/
|
||||||
|
public final void setFadeInTime(int time) {
|
||||||
|
this.fadeInTime = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set title fade out time.
|
||||||
|
*
|
||||||
|
* @param time Time
|
||||||
|
*/
|
||||||
|
public final void setFadeOutTime(int time) {
|
||||||
|
this.fadeOutTime = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set title stay time.
|
||||||
|
*
|
||||||
|
* @param time Time
|
||||||
|
*/
|
||||||
|
public final void setStayTime(int time) {
|
||||||
|
this.stayTime = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set timings to ticks.
|
||||||
|
*/
|
||||||
|
public final void setTimingsToTicks() {
|
||||||
|
this.ticks = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set timings to seconds.
|
||||||
|
*/
|
||||||
|
public final void setTimingsToSeconds() {
|
||||||
|
this.ticks = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the title to a player.
|
||||||
|
*
|
||||||
|
* @param player Player
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public abstract void send(Player player) throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Broadcast the title to all players.
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public final void broadcast() throws Exception {
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
|
send(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the title.
|
||||||
|
*
|
||||||
|
* @param player Player
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public abstract void clearTitle(Player player) throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the title settings.
|
||||||
|
*
|
||||||
|
* @param player Player
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public abstract void resetTitle(Player player) throws Exception;
|
||||||
|
|
||||||
|
private Class<?> getPrimitiveType(Class<?> clazz) {
|
||||||
|
if (CORRESPONDING_TYPES.containsKey(clazz)) {
|
||||||
|
return CORRESPONDING_TYPES.get(clazz);
|
||||||
|
} else {
|
||||||
|
return clazz;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
|
||||||
|
int a;
|
||||||
|
if (classes != null) {
|
||||||
|
a = classes.length;
|
||||||
|
} else {
|
||||||
|
a = 0;
|
||||||
|
}
|
||||||
|
Class<?>[] types = new Class<?>[a];
|
||||||
|
for (int i = 0; i < a; i++) {
|
||||||
|
types[i] = getPrimitiveType(classes[i]);
|
||||||
|
}
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -45,7 +45,7 @@ public class BukkitChatManager extends ChatManager<FancyMessage> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void send(PlotMessage m, PlotPlayer player) {
|
public void send(PlotMessage m, PlotPlayer player) {
|
||||||
if (ConsolePlayer.isConsole(player)) {
|
if (player instanceof ConsolePlayer) {
|
||||||
player.sendMessage(m.$(this).toOldMessageFormat());
|
player.sendMessage(m.$(this).toOldMessageFormat());
|
||||||
} else {
|
} else {
|
||||||
m.$(this).send(((BukkitPlayer) player).player);
|
m.$(this).send(((BukkitPlayer) player).player);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -4,9 +4,12 @@ import com.intellectualcrafters.plot.commands.MainCommand;
|
|||||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.plotsquared.bukkit.commands.DebugUUID;
|
import com.plotsquared.bukkit.commands.DebugUUID;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.bukkit.command.ProxiedCommandSender;
|
||||||
|
import org.bukkit.command.RemoteConsoleCommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -22,41 +25,19 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final CommandSender commandSender, org.bukkit.command.Command command, final String commandLabel, String[] args) {
|
public boolean onCommand(CommandSender commandSender, Command command, String commandLabel, String[] args) {
|
||||||
if (commandSender instanceof Player) {
|
if (commandSender instanceof Player) {
|
||||||
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), args);
|
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), args);
|
||||||
}
|
}
|
||||||
if (commandSender.getClass() == Bukkit.getConsoleSender().getClass()) {
|
if (commandSender instanceof ConsoleCommandSender || commandSender instanceof ProxiedCommandSender
|
||||||
|
|| commandSender instanceof RemoteConsoleCommandSender) {
|
||||||
return MainCommand.onCommand(ConsolePlayer.getConsole(), args);
|
return MainCommand.onCommand(ConsolePlayer.getConsole(), args);
|
||||||
}
|
}
|
||||||
@SuppressWarnings("deprecation")
|
return false;
|
||||||
ConsolePlayer sender = new ConsolePlayer() {
|
|
||||||
@Override
|
|
||||||
public void sendMessage(String message) {
|
|
||||||
commandSender.sendMessage(commandLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPermission(String permission) {
|
|
||||||
return commandSender.hasPermission(commandLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
if (commandSender.getName().equals("CONSOLE")) {
|
|
||||||
return "*";
|
|
||||||
}
|
|
||||||
return commandSender.getName();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
sender.teleport(ConsolePlayer.getConsole().getLocationFull());
|
|
||||||
boolean result = MainCommand.onCommand(sender, args);
|
|
||||||
ConsolePlayer.getConsole().teleport(sender.getLocationFull());
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender commandSender, org.bukkit.command.Command command, String s, String[] args) {
|
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] args) {
|
||||||
if (!(commandSender instanceof Player)) {
|
if (!(commandSender instanceof Player)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -72,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,16 +15,6 @@ public class BukkitEconHandler extends EconHandler {
|
|||||||
private Economy econ;
|
private Economy econ;
|
||||||
private Permission perms;
|
private Permission perms;
|
||||||
|
|
||||||
public Economy getEconomy() {
|
|
||||||
init();
|
|
||||||
return this.econ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Permission getPermissions() {
|
|
||||||
init();
|
|
||||||
return this.perms;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean init() {
|
public boolean init() {
|
||||||
if (this.econ == null || this.perms == null) {
|
if (this.econ == null || this.perms == null) {
|
||||||
setupPermissions();
|
setupPermissions();
|
||||||
|
@ -6,35 +6,41 @@ import org.bukkit.Bukkit;
|
|||||||
|
|
||||||
public class BukkitTaskManager extends TaskManager {
|
public class BukkitTaskManager extends TaskManager {
|
||||||
|
|
||||||
|
private final BukkitMain bukkitMain;
|
||||||
|
|
||||||
|
public BukkitTaskManager(BukkitMain bukkitMain) {
|
||||||
|
this.bukkitMain = bukkitMain;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int taskRepeat(Runnable runnable, int interval) {
|
public int taskRepeat(Runnable runnable, int interval) {
|
||||||
return BukkitMain.THIS.getServer().getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, runnable, interval, interval);
|
return this.bukkitMain.getServer().getScheduler().scheduleSyncRepeatingTask(this.bukkitMain, runnable, interval, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public int taskRepeatAsync(Runnable runnable, int interval) {
|
public int taskRepeatAsync(Runnable runnable, int interval) {
|
||||||
return BukkitMain.THIS.getServer().getScheduler().scheduleAsyncRepeatingTask(BukkitMain.THIS, runnable, interval, interval);
|
return this.bukkitMain.getServer().getScheduler().scheduleAsyncRepeatingTask(this.bukkitMain, runnable, interval, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void taskAsync(Runnable runnable) {
|
public void taskAsync(Runnable runnable) {
|
||||||
BukkitMain.THIS.getServer().getScheduler().runTaskAsynchronously(BukkitMain.THIS, runnable).getTaskId();
|
this.bukkitMain.getServer().getScheduler().runTaskAsynchronously(this.bukkitMain, runnable).getTaskId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void task(Runnable runnable) {
|
public void task(Runnable runnable) {
|
||||||
BukkitMain.THIS.getServer().getScheduler().runTask(BukkitMain.THIS, runnable).getTaskId();
|
this.bukkitMain.getServer().getScheduler().runTask(this.bukkitMain, runnable).getTaskId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void taskLater(Runnable runnable, int delay) {
|
public void taskLater(Runnable runnable, int delay) {
|
||||||
BukkitMain.THIS.getServer().getScheduler().runTaskLater(BukkitMain.THIS, runnable, delay).getTaskId();
|
this.bukkitMain.getServer().getScheduler().runTaskLater(this.bukkitMain, runnable, delay).getTaskId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void taskLaterAsync(Runnable runnable, int delay) {
|
public void taskLaterAsync(Runnable runnable, int delay) {
|
||||||
BukkitMain.THIS.getServer().getScheduler().runTaskLaterAsynchronously(BukkitMain.THIS, runnable, delay);
|
this.bukkitMain.getServer().getScheduler().runTaskLaterAsynchronously(this.bukkitMain, runnable, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -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");
|
||||||
|
@ -12,7 +12,6 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
|||||||
import com.intellectualcrafters.plot.util.SetQueue;
|
import com.intellectualcrafters.plot.util.SetQueue;
|
||||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
|
||||||
import com.plotsquared.bukkit.util.SendChunk;
|
import com.plotsquared.bukkit.util.SendChunk;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -370,7 +369,6 @@ public class FastQueue_1_8 extends SlowQueue {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void sendChunk(String world, Collection<ChunkLoc> locations) {
|
public void sendChunk(String world, Collection<ChunkLoc> locations) {
|
||||||
World worldObj = BukkitUtil.getWorld(world);
|
|
||||||
for (ChunkLoc loc : locations) {
|
for (ChunkLoc loc : locations) {
|
||||||
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
||||||
this.toUpdate.remove(wrapper);
|
this.toUpdate.remove(wrapper);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.plotsquared.bukkit.util.block;
|
package com.plotsquared.bukkit.util.block;
|
||||||
|
|
||||||
|
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
@ -14,6 +16,12 @@ import com.intellectualcrafters.plot.util.SetQueue;
|
|||||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.plotsquared.bukkit.util.SendChunk;
|
import com.plotsquared.bukkit.util.SendChunk;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.World.Environment;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -23,14 +31,6 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.World.Environment;
|
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
|
|
||||||
|
|
||||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
|
||||||
|
|
||||||
public class FastQueue_1_8_3 extends SlowQueue {
|
public class FastQueue_1_8_3 extends SlowQueue {
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
* @param plotChunk
|
* @param plotChunk
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(final PlotChunk<Chunk> plotChunk) {
|
public void execute(PlotChunk<Chunk> plotChunk) {
|
||||||
final FastChunk_1_9 fs = (FastChunk_1_9) plotChunk;
|
final FastChunk_1_9 fs = (FastChunk_1_9) plotChunk;
|
||||||
Chunk chunk = plotChunk.getChunk();
|
Chunk chunk = plotChunk.getChunk();
|
||||||
World world = chunk.getWorld();
|
World world = chunk.getWorld();
|
||||||
@ -413,7 +413,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
* @param locations
|
* @param locations
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void sendChunk(final String world, final Collection<ChunkLoc> locations) {
|
public void sendChunk(String world, Collection<ChunkLoc> locations) {
|
||||||
World worldObj = BukkitUtil.getWorld(world);
|
World worldObj = BukkitUtil.getWorld(world);
|
||||||
for (ChunkLoc loc : locations) {
|
for (ChunkLoc loc : locations) {
|
||||||
worldObj.refreshChunk(loc.x, loc.z);
|
worldObj.refreshChunk(loc.x, loc.z);
|
||||||
|
@ -9,13 +9,14 @@ import com.intellectualcrafters.plot.util.PlotQueue;
|
|||||||
import com.intellectualcrafters.plot.util.SetQueue;
|
import com.intellectualcrafters.plot.util.SetQueue;
|
||||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
|
|
||||||
public class SlowQueue implements PlotQueue<Chunk> {
|
public class SlowQueue implements PlotQueue<Chunk> {
|
||||||
|
|
||||||
|
@ -74,14 +74,14 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
HashBiMap<StringWrapper, UUID> toAdd = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
HashBiMap<StringWrapper, UUID> toAdd = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
||||||
PreparedStatement statement = getConnection().prepareStatement("SELECT `uuid`, `username` FROM `usercache`");
|
try (PreparedStatement statement = getConnection().prepareStatement("SELECT `uuid`, `username` FROM `usercache`");
|
||||||
ResultSet resultSet = statement.executeQuery();
|
ResultSet resultSet = statement.executeQuery()) {
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
StringWrapper username = new StringWrapper(resultSet.getString("username"));
|
StringWrapper username = new StringWrapper(resultSet.getString("username"));
|
||||||
UUID uuid = UUID.fromString(resultSet.getString("uuid"));
|
UUID uuid = UUID.fromString(resultSet.getString("uuid"));
|
||||||
toAdd.put(new StringWrapper(username.value), uuid);
|
toAdd.put(new StringWrapper(username.value), uuid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
statement.close();
|
|
||||||
add(toAdd);
|
add(toAdd);
|
||||||
add(new StringWrapper("*"), DBFunc.everyone);
|
add(new StringWrapper("*"), DBFunc.everyone);
|
||||||
|
|
||||||
|
@ -3,80 +3,82 @@ package com.intellectualcrafters.configuration;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a source of configurable options and settings
|
* Represents a source of configurable options and settings.
|
||||||
*/
|
*/
|
||||||
public interface Configuration extends ConfigurationSection {
|
public interface Configuration extends ConfigurationSection {
|
||||||
/**
|
/**
|
||||||
* Sets the default value of the given path as provided.
|
* Sets the default value of the given path as provided.
|
||||||
* <p>
|
*
|
||||||
* If no source {@link Configuration} was provided as a default
|
* <p>If no source {@link Configuration} was provided as a default
|
||||||
* collection, then a new {@link MemoryConfiguration} will be created to
|
* collection, then a new {@link MemoryConfiguration} will be created to
|
||||||
* hold the new default value.
|
* hold the new default value.</p>
|
||||||
* <p>
|
*
|
||||||
* If value is null, the value will be removed from the default
|
* <p>If value is null, the value will be removed from the default
|
||||||
* Configuration source.
|
* Configuration source.</p>
|
||||||
*
|
*
|
||||||
* @param path Path of the value to set.
|
* @param path Path of the value to set.
|
||||||
* @param value Value to set the default to.
|
* @param value Value to set the default to.
|
||||||
* @throws IllegalArgumentException Thrown if path is null.
|
* @throws IllegalArgumentException Thrown if path is null.
|
||||||
*/
|
*/
|
||||||
@Override void addDefault(final String path, final Object value);
|
@Override void addDefault(String path, Object value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default values of the given paths as provided.
|
* Sets the default values of the given paths as provided.
|
||||||
* <p>
|
*
|
||||||
* If no source {@link Configuration} was provided as a default
|
* <p>If no source {@link Configuration} was provided as a default
|
||||||
* collection, then a new {@link MemoryConfiguration} will be created to
|
* collection, then a new {@link MemoryConfiguration} will be created to
|
||||||
* hold the new default values.
|
* hold the new default values.</p>
|
||||||
*
|
*
|
||||||
* @param defaults A map of Path->Values to add to defaults.
|
* @param defaults A map of Path->Values to add to defaults.
|
||||||
* @throws IllegalArgumentException Thrown if defaults is null.
|
* @throws IllegalArgumentException Thrown if defaults is null.
|
||||||
*/
|
*/
|
||||||
void addDefaults(final Map<String, Object> defaults);
|
void addDefaults(Map<String, Object> defaults);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default values of the given paths as provided.
|
* Sets the default values of the given paths as provided.
|
||||||
* <p>
|
*
|
||||||
* If no source {@link Configuration} was provided as a default
|
* <p>If no source {@link Configuration} was provided as a default
|
||||||
* collection, then a new {@link MemoryConfiguration} will be created to
|
* collection, then a new {@link MemoryConfiguration} will be created to
|
||||||
* hold the new default value.
|
* hold the new default value.</p>
|
||||||
* <p>
|
*
|
||||||
* This method will not hold a reference to the specified Configuration,
|
* <p>This method will not hold a reference to the specified Configuration,
|
||||||
* nor will it automatically update if that Configuration ever changes. If
|
* nor will it automatically update if that Configuration ever changes. If
|
||||||
* you require this, you should set the default source with {@link
|
* you require this, you should set the default source with {@link
|
||||||
* #setDefaults(com.intellectualcrafters.configuration.Configuration)}.
|
* #setDefaults(Configuration)}.</p>
|
||||||
*
|
*
|
||||||
* @param defaults A configuration holding a list of defaults to copy.
|
* @param defaults A configuration holding a list of defaults to copy.
|
||||||
* @throws IllegalArgumentException Thrown if defaults is null or this.
|
* @throws IllegalArgumentException Thrown if defaults is null or this.
|
||||||
*/
|
*/
|
||||||
void addDefaults(final Configuration defaults);
|
void addDefaults(Configuration defaults);
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the source of all default values for this {@link Configuration}.
|
|
||||||
* <p>
|
|
||||||
* If a previous source was set, or previous default values were defined,
|
|
||||||
* then they will not be copied to the new source.
|
|
||||||
*
|
|
||||||
* @param defaults New source of default values for this configuration.
|
|
||||||
* @throws IllegalArgumentException Thrown if defaults is null or this.
|
|
||||||
*/
|
|
||||||
void setDefaults(final Configuration defaults);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the source {@link Configuration} for this configuration.
|
* Gets the source {@link Configuration} for this configuration.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If no configuration source was set, but default values were added, then
|
* If no configuration source was set, but default values were added, then
|
||||||
* a {@link MemoryConfiguration} will be returned. If no source was set
|
* a {@link MemoryConfiguration} will be returned. If no source was set
|
||||||
* and no defaults were set, then this method will return null.
|
* and no defaults were set, then this method will return null.</p>
|
||||||
*
|
*
|
||||||
* @return Configuration source for default values, or null if none exist.
|
* @return Configuration source for default values, or null if none exist.
|
||||||
*/
|
*/
|
||||||
Configuration getDefaults();
|
Configuration getDefaults();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link ConfigurationOptions} for this {@link Configuration}.
|
* Sets the source of all default values for this {@link Configuration}.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* All setters through this method are chainable.
|
* If a previous source was set, or previous default values were defined,
|
||||||
|
* then they will not be copied to the new source.</p>
|
||||||
|
*
|
||||||
|
* @param defaults New source of default values for this configuration.
|
||||||
|
* @throws IllegalArgumentException Thrown if defaults is null or this.
|
||||||
|
*/
|
||||||
|
void setDefaults(Configuration defaults);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link ConfigurationOptions} for this {@link Configuration}.
|
||||||
|
*
|
||||||
|
* <p>All setters through this method are chainable.</p>
|
||||||
*
|
*
|
||||||
* @return Options for this configuration
|
* @return Options for this configuration
|
||||||
*/
|
*/
|
||||||
|
@ -23,35 +23,35 @@ public class MemoryConfiguration extends MemorySection implements Configuration
|
|||||||
* @param defaults Default value provider
|
* @param defaults Default value provider
|
||||||
* @throws IllegalArgumentException Thrown if defaults is null
|
* @throws IllegalArgumentException Thrown if defaults is null
|
||||||
*/
|
*/
|
||||||
public MemoryConfiguration(final Configuration defaults) {
|
public MemoryConfiguration(Configuration defaults) {
|
||||||
this.defaults = defaults;
|
this.defaults = defaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addDefault(final String path, final Object value) {
|
public void addDefault(String path, Object value) {
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
throw new NullPointerException("Path may not be null");
|
throw new NullPointerException("Path may not be null");
|
||||||
}
|
}
|
||||||
if (defaults == null) {
|
if (this.defaults == null) {
|
||||||
defaults = new MemoryConfiguration();
|
this.defaults = new MemoryConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
defaults.set(path, value);
|
this.defaults.set(path, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addDefaults(final Map<String, Object> defaults) {
|
public void addDefaults(Map<String, Object> defaults) {
|
||||||
if (defaults == null) {
|
if (defaults == null) {
|
||||||
throw new NullPointerException("Defaults may not be null");
|
throw new NullPointerException("Defaults may not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final Map.Entry<String, Object> entry : defaults.entrySet()) {
|
for (Map.Entry<String, Object> entry : defaults.entrySet()) {
|
||||||
addDefault(entry.getKey(), entry.getValue());
|
addDefault(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addDefaults(final Configuration defaults) {
|
public void addDefaults(Configuration defaults) {
|
||||||
if (defaults == null) {
|
if (defaults == null) {
|
||||||
throw new NullPointerException("Defaults may not be null");
|
throw new NullPointerException("Defaults may not be null");
|
||||||
}
|
}
|
||||||
@ -60,7 +60,12 @@ public class MemoryConfiguration extends MemorySection implements Configuration
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDefaults(final Configuration defaults) {
|
public Configuration getDefaults() {
|
||||||
|
return this.defaults;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDefaults(Configuration defaults) {
|
||||||
if (defaults == null) {
|
if (defaults == null) {
|
||||||
throw new NullPointerException("Defaults may not be null");
|
throw new NullPointerException("Defaults may not be null");
|
||||||
}
|
}
|
||||||
@ -68,11 +73,6 @@ public class MemoryConfiguration extends MemorySection implements Configuration
|
|||||||
this.defaults = defaults;
|
this.defaults = defaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Configuration getDefaults() {
|
|
||||||
return defaults;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConfigurationSection getParent() {
|
public ConfigurationSection getParent() {
|
||||||
return null;
|
return null;
|
||||||
@ -80,10 +80,10 @@ public class MemoryConfiguration extends MemorySection implements Configuration
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MemoryConfigurationOptions options() {
|
public MemoryConfigurationOptions options() {
|
||||||
if (options == null) {
|
if (this.options == null) {
|
||||||
options = new MemoryConfigurationOptions(this);
|
this.options = new MemoryConfigurationOptions(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return options;
|
return this.options;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
|||||||
import com.intellectualcrafters.plot.util.area.QuadMap;
|
import com.intellectualcrafters.plot.util.area.QuadMap;
|
||||||
import com.plotsquared.listener.WESubscriber;
|
import com.plotsquared.listener.WESubscriber;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@ -89,6 +90,7 @@ import java.util.zip.ZipInputStream;
|
|||||||
public class PS {
|
public class PS {
|
||||||
|
|
||||||
private static PS instance;
|
private static PS instance;
|
||||||
|
public final IPlotMain IMP;
|
||||||
private final HashSet<Integer> plotAreaHashCheck = new HashSet<>();
|
private final HashSet<Integer> plotAreaHashCheck = new HashSet<>();
|
||||||
/**
|
/**
|
||||||
* All plot areas mapped by world (quick world access).
|
* All plot areas mapped by world (quick world access).
|
||||||
@ -98,6 +100,9 @@ public class PS {
|
|||||||
* All plot areas mapped by location (quick location based access).
|
* All plot areas mapped by location (quick location based access).
|
||||||
*/
|
*/
|
||||||
private final HashMap<String, QuadMap<PlotArea>> plotAreaGrid = new HashMap<>();
|
private final HashMap<String, QuadMap<PlotArea>> plotAreaGrid = new HashMap<>();
|
||||||
|
private final int[] version;
|
||||||
|
private final String platform;
|
||||||
|
private final Thread thread;
|
||||||
public HashMap<String, Set<PlotCluster>> clusters_tmp;
|
public HashMap<String, Set<PlotCluster>> clusters_tmp;
|
||||||
public HashMap<String, HashMap<PlotId, Plot>> plots_tmp;
|
public HashMap<String, HashMap<PlotId, Plot>> plots_tmp;
|
||||||
public File styleFile;
|
public File styleFile;
|
||||||
@ -108,7 +113,6 @@ public class PS {
|
|||||||
public YamlConfiguration config;
|
public YamlConfiguration config;
|
||||||
public YamlConfiguration storage;
|
public YamlConfiguration storage;
|
||||||
public YamlConfiguration commands;
|
public YamlConfiguration commands;
|
||||||
public IPlotMain IMP = null;
|
|
||||||
public TaskManager TASK;
|
public TaskManager TASK;
|
||||||
public WorldEdit worldedit;
|
public WorldEdit worldedit;
|
||||||
public URL update;
|
public URL update;
|
||||||
@ -117,25 +121,23 @@ public class PS {
|
|||||||
* All plot areas (quick global access).
|
* All plot areas (quick global access).
|
||||||
*/
|
*/
|
||||||
private PlotArea[] plotAreas = new PlotArea[0];
|
private PlotArea[] plotAreas = new PlotArea[0];
|
||||||
|
|
||||||
private File storageFile;
|
private File storageFile;
|
||||||
private File file = null; // This file
|
private File file = null; // This file
|
||||||
private int[] version;
|
|
||||||
private int[] lastVersion;
|
private int[] lastVersion;
|
||||||
private String platform = null;
|
|
||||||
private Database database;
|
private Database database;
|
||||||
private Thread thread;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize PlotSquared with the desired Implementation class.
|
* Initialize PlotSquared with the desired Implementation class.
|
||||||
* @param imp_class
|
* @param iPlotMain Implementation of {@link IPlotMain} used
|
||||||
|
* @param platform The platform being used
|
||||||
*/
|
*/
|
||||||
public PS(IPlotMain imp_class, String platform) {
|
public PS(IPlotMain iPlotMain, String platform) {
|
||||||
|
PS.instance = this;
|
||||||
|
this.thread = Thread.currentThread();
|
||||||
|
this.IMP = iPlotMain;
|
||||||
|
this.platform = platform;
|
||||||
|
this.version = this.IMP.getPluginVersion();
|
||||||
try {
|
try {
|
||||||
PS.instance = this;
|
|
||||||
this.thread = Thread.currentThread();
|
|
||||||
SetupUtils.generators = new HashMap<>();
|
|
||||||
this.IMP = imp_class;
|
|
||||||
new ReflectionUtils(this.IMP.getNMSPackage());
|
new ReflectionUtils(this.IMP.getNMSPackage());
|
||||||
try {
|
try {
|
||||||
URL url = PS.class.getProtectionDomain().getCodeSource().getLocation();
|
URL url = PS.class.getProtectionDomain().getCodeSource().getLocation();
|
||||||
@ -147,8 +149,6 @@ public class PS {
|
|||||||
this.file = new File(this.IMP.getDirectory().getParentFile(), "PlotSquared-" + platform + ".jar");
|
this.file = new File(this.IMP.getDirectory().getParentFile(), "PlotSquared-" + platform + ".jar");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.version = this.IMP.getPluginVersion();
|
|
||||||
this.platform = platform;
|
|
||||||
if (getJavaVersion() < 1.7) {
|
if (getJavaVersion() < 1.7) {
|
||||||
PS.log(C.CONSOLE_JAVA_OUTDATED_1_7);
|
PS.log(C.CONSOLE_JAVA_OUTDATED_1_7);
|
||||||
this.IMP.disable();
|
this.IMP.disable();
|
||||||
@ -200,50 +200,7 @@ public class PS {
|
|||||||
}
|
}
|
||||||
// create UUIDWrapper
|
// create UUIDWrapper
|
||||||
UUIDHandler.implementation = this.IMP.initUUIDHandler();
|
UUIDHandler.implementation = this.IMP.initUUIDHandler();
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
startUuidCatching();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
debug("Starting UUID caching");
|
|
||||||
UUIDHandler.startCaching(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
for (Plot plot : getPlots()) {
|
|
||||||
if (plot.hasOwner() && plot.temp != -1) {
|
|
||||||
if (UUIDHandler.getName(plot.owner) == null) {
|
|
||||||
UUIDHandler.implementation.unknown.add(plot.owner);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Auto clearing
|
|
||||||
if (Settings.AUTO_CLEAR) {
|
|
||||||
ExpireManager.IMP = new ExpireManager();
|
|
||||||
if (Settings.AUTO_CLEAR_CONFIRMATION) {
|
|
||||||
ExpireManager.IMP.runConfirmedTask();
|
|
||||||
} else {
|
|
||||||
ExpireManager.IMP.runAutomatedTask();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// PlotMe
|
|
||||||
if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) {
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (PS.this.IMP.initPlotMeConverter()) {
|
|
||||||
PS.log("&c=== IMPORTANT ===");
|
|
||||||
PS.log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!");
|
|
||||||
PS.log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
|
|
||||||
PS.log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
|
|
||||||
PS.log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the "
|
|
||||||
+ "'settings.yml'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, 20);
|
|
||||||
// create event util class
|
// create event util class
|
||||||
EventUtil.manager = this.IMP.initEventUtil();
|
EventUtil.manager = this.IMP.initEventUtil();
|
||||||
// create Hybrid utility class
|
// create Hybrid utility class
|
||||||
@ -354,10 +311,6 @@ public class PS {
|
|||||||
PS.get().IMP.log(StringMan.getString(message));
|
PS.get().IMP.log(StringMan.getString(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void stacktrace() {
|
|
||||||
System.err.println(StringMan.join(new Exception().getStackTrace(), "\n\tat "));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message to the IPlotMain logger.
|
* Log a message to the IPlotMain logger.
|
||||||
*
|
*
|
||||||
@ -370,6 +323,53 @@ public class PS {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startUuidCatching() {
|
||||||
|
TaskManager.runTaskLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
debug("Starting UUID caching");
|
||||||
|
UUIDHandler.startCaching(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (Plot plot : getPlots()) {
|
||||||
|
if (plot.hasOwner() && plot.temp != -1) {
|
||||||
|
if (UUIDHandler.getName(plot.owner) == null) {
|
||||||
|
UUIDHandler.implementation.unknown.add(plot.owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Auto clearing
|
||||||
|
if (Settings.AUTO_CLEAR) {
|
||||||
|
ExpireManager.IMP = new ExpireManager();
|
||||||
|
if (Settings.AUTO_CLEAR_CONFIRMATION) {
|
||||||
|
ExpireManager.IMP.runConfirmedTask();
|
||||||
|
} else {
|
||||||
|
ExpireManager.IMP.runAutomatedTask();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// PlotMe
|
||||||
|
if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) {
|
||||||
|
TaskManager.runTaskLater(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (PS.this.IMP.initPlotMeConverter()) {
|
||||||
|
PS.log("&c=== IMPORTANT ===");
|
||||||
|
PS.log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!");
|
||||||
|
PS.log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
|
||||||
|
PS.log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
|
||||||
|
PS.log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the "
|
||||||
|
+ "'settings.yml'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, 20);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isMainThread(Thread thread) {
|
public boolean isMainThread(Thread thread) {
|
||||||
return this.thread == thread;
|
return this.thread == thread;
|
||||||
}
|
}
|
||||||
@ -1324,14 +1324,18 @@ public class PS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called by the PlotGenerator class normally<br>
|
* This method is called by the PlotGenerator class normally.
|
||||||
* - Initializes the PlotArea and PlotManager classes<br>
|
* <ul>
|
||||||
* - Registers the PlotArea and PlotManager classes<br>
|
* <li>Initializes the PlotArea and PlotManager classes</li>
|
||||||
* - Loads (and/or generates) the PlotArea configuration<br>
|
* <li>Registers the PlotArea and PlotManager classes</li>
|
||||||
* - Sets up the world border if configured<br>
|
* <li>Loads (and/or generates) the PlotArea configuration</li>
|
||||||
* If loading an augmented plot world:<br>
|
* <li>Sets up the world border if configured</li>
|
||||||
* - Creates the AugmentedPopulator classes<br>
|
* </ul>
|
||||||
* - Injects the AugmentedPopulator classes if required
|
* If loading an augmented plot world:
|
||||||
|
* <ul>
|
||||||
|
* <li>Creates the AugmentedPopulator classes</li>
|
||||||
|
* <li>Injects the AugmentedPopulator classes if required</li>
|
||||||
|
* </ul>
|
||||||
* @param world The world to load
|
* @param world The world to load
|
||||||
* @param baseGenerator The generator for that world, or null if no generator
|
* @param baseGenerator The generator for that world, or null if no generator
|
||||||
*/
|
*/
|
||||||
@ -1470,14 +1474,14 @@ public class PS {
|
|||||||
}
|
}
|
||||||
for (String areaId : areasSection.getKeys(false)) {
|
for (String areaId : areasSection.getKeys(false)) {
|
||||||
PS.log(C.PREFIX + "&3 - " + areaId);
|
PS.log(C.PREFIX + "&3 - " + areaId);
|
||||||
int i1 = areaId.indexOf("-");
|
int i1 = areaId.indexOf('-');
|
||||||
int i2 = areaId.indexOf(";");
|
int i2 = areaId.indexOf(';');
|
||||||
if (i1 == -1 || i2 == -1) {
|
if (i1 == -1 || i2 == -1) {
|
||||||
throw new IllegalArgumentException("Invalid Area identifier: " + areaId + ". Expected form `<name>-<pos1>-<pos2>`");
|
throw new IllegalArgumentException("Invalid Area identifier: " + areaId + ". Expected form `<name>-<pos1>-<pos2>`");
|
||||||
}
|
}
|
||||||
String name = areaId.substring(0, i1);
|
String name = areaId.substring(0, i1);
|
||||||
String rest = areaId.substring(i1 + 1);
|
String rest = areaId.substring(i1 + 1);
|
||||||
int i3 = rest.indexOf("-", i2 - name.length() - 1);
|
int i3 = rest.indexOf('-', i2 - name.length() - 1);
|
||||||
PlotId pos1 = PlotId.fromString(rest.substring(0, i3));
|
PlotId pos1 = PlotId.fromString(rest.substring(0, i3));
|
||||||
PlotId pos2 = PlotId.fromString(rest.substring(i3 + 1));
|
PlotId pos2 = PlotId.fromString(rest.substring(i3 + 1));
|
||||||
if (pos1 == null || pos2 == null || name.isEmpty()) {
|
if (pos1 == null || pos2 == null || name.isEmpty()) {
|
||||||
@ -1543,8 +1547,10 @@ public class PS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the configuration for a plot world based on world arguments<br>
|
* Setup the configuration for a plot world based on world arguments.
|
||||||
* e.g. /mv create <world> normal -g PlotSquared:<args>
|
* <p>
|
||||||
|
* <i>e.g. /mv create <world> normal -g PlotSquared:<args></i>
|
||||||
|
* </p>
|
||||||
* @param world The name of the world
|
* @param world The name of the world
|
||||||
* @param args The arguments
|
* @param args The arguments
|
||||||
* @return boolean | if valid arguments were provided
|
* @return boolean | if valid arguments were provided
|
||||||
@ -1800,7 +1806,7 @@ public class PS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the default flags for PlotSquared<br>
|
* Setup the default flags for PlotSquared.
|
||||||
* - Create the flags
|
* - Create the flags
|
||||||
* - Register with FlagManager and parse raw flag values
|
* - Register with FlagManager and parse raw flag values
|
||||||
*/
|
*/
|
||||||
@ -2404,10 +2410,6 @@ public class PS {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPlotAreaCount(String world) {
|
|
||||||
return this.plotAreaMap.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<PlotArea> getPlotAreas() {
|
public Set<PlotArea> getPlotAreas() {
|
||||||
HashSet<PlotArea> set = new HashSet<>(this.plotAreas.length);
|
HashSet<PlotArea> set = new HashSet<>(this.plotAreas.length);
|
||||||
Collections.addAll(set, this.plotAreas);
|
Collections.addAll(set, this.plotAreas);
|
||||||
|
@ -4,6 +4,7 @@ import static com.intellectualcrafters.plot.PS.log;
|
|||||||
|
|
||||||
import com.intellectualcrafters.json.JSONArray;
|
import com.intellectualcrafters.json.JSONArray;
|
||||||
import com.intellectualcrafters.json.JSONObject;
|
import com.intellectualcrafters.json.JSONObject;
|
||||||
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.util.StringMan;
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@ -28,8 +29,10 @@ public class Updater {
|
|||||||
|
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log("&dCould not check for updates (0)");
|
log("&dCould not check for updates");
|
||||||
e.printStackTrace();
|
if (Settings.DEBUG) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (reader != null) {
|
if (reader != null) {
|
||||||
|
@ -43,46 +43,46 @@ import java.util.Set;
|
|||||||
public class Area extends SubCommand {
|
public class Area extends SubCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
case "c":
|
case "c":
|
||||||
case "setup":
|
case "setup":
|
||||||
case "create":
|
case "create":
|
||||||
if (!Permissions.hasPermission(plr, "plots.area.create")) {
|
if (!Permissions.hasPermission(player, "plots.area.create")) {
|
||||||
C.NO_PERMISSION.send(plr, "plots.area.create");
|
C.NO_PERMISSION.send(player, "plots.area.create");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
C.COMMAND_SYNTAX.send(player, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||||
return false;
|
return false;
|
||||||
case 2:
|
case 2:
|
||||||
switch (args[1].toLowerCase()) {
|
switch (args[1].toLowerCase()) {
|
||||||
case "pos1": { // Set position 1
|
case "pos1": { // Set position 1
|
||||||
HybridPlotWorld area = plr.getMeta("area_create_area");
|
HybridPlotWorld area = player.getMeta("area_create_area");
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
C.COMMAND_SYNTAX.send(player, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Location location = plr.getLocation();
|
Location location = player.getLocation();
|
||||||
plr.setMeta("area_pos1", location);
|
player.setMeta("area_pos1", location);
|
||||||
C.SET_ATTRIBUTE.send(plr, "area_pos1", location.getX() + "," + location.getZ());
|
C.SET_ATTRIBUTE.send(player, "area_pos1", location.getX() + "," + location.getZ());
|
||||||
MainUtil.sendMessage(plr, "You will now set pos2: /plot area create pos2"
|
MainUtil.sendMessage(player, "You will now set pos2: /plot area create pos2"
|
||||||
+ "\nNote: The chosen plot size may result in the created area not exactly matching your second position.");
|
+ "\nNote: The chosen plot size may result in the created area not exactly matching your second position.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "pos2": // Set position 2 and finish creation for type=2 (partial)
|
case "pos2": // Set position 2 and finish creation for type=2 (partial)
|
||||||
final HybridPlotWorld area = plr.getMeta("area_create_area");
|
final HybridPlotWorld area = player.getMeta("area_create_area");
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
C.COMMAND_SYNTAX.send(player, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Location pos1 = plr.getLocation();
|
Location pos1 = player.getLocation();
|
||||||
Location pos2 = plr.getMeta("area_pos1");
|
Location pos2 = player.getMeta("area_pos1");
|
||||||
int dx = Math.abs(pos1.getX() - pos2.getX());
|
int dx = Math.abs(pos1.getX() - pos2.getX());
|
||||||
int dz = Math.abs(pos1.getZ() - pos2.getZ());
|
int dz = Math.abs(pos1.getZ() - pos2.getZ());
|
||||||
int numX = Math.max(1, (dx + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
|
int numX = Math.max(1, (dx + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
|
||||||
@ -99,7 +99,7 @@ public class Area extends SubCommand {
|
|||||||
final RegionWrapper region = new RegionWrapper(bx, tx, bz, tz);
|
final RegionWrapper region = new RegionWrapper(bx, tx, bz, tz);
|
||||||
Set<PlotArea> areas = PS.get().getPlotAreas(area.worldname, region);
|
Set<PlotArea> areas = PS.get().getPlotAreas(area.worldname, region);
|
||||||
if (!areas.isEmpty()) {
|
if (!areas.isEmpty()) {
|
||||||
C.CLUSTER_INTERSECTION.send(plr, areas.iterator().next().toString());
|
C.CLUSTER_INTERSECTION.send(player, areas.iterator().next().toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final SetupObject object = new SetupObject();
|
final SetupObject object = new SetupObject();
|
||||||
@ -125,8 +125,8 @@ public class Area extends SubCommand {
|
|||||||
final String world = SetupUtils.manager.setupWorld(object);
|
final String world = SetupUtils.manager.setupWorld(object);
|
||||||
if (WorldUtil.IMP.isWorld(world)) {
|
if (WorldUtil.IMP.isWorld(world)) {
|
||||||
PS.get().loadWorld(world, null);
|
PS.get().loadWorld(world, null);
|
||||||
C.SETUP_FINISHED.send(plr);
|
C.SETUP_FINISHED.send(player);
|
||||||
plr.teleport(WorldUtil.IMP.getSpawn(world));
|
player.teleport(WorldUtil.IMP.getSpawn(world));
|
||||||
if (area.TERRAIN != 3) {
|
if (area.TERRAIN != 3) {
|
||||||
ChunkManager.largeRegionTask(world, region, new RunnableVal<ChunkLoc>() {
|
ChunkManager.largeRegionTask(world, region, new RunnableVal<ChunkLoc>() {
|
||||||
@Override
|
@Override
|
||||||
@ -136,12 +136,12 @@ public class Area extends SubCommand {
|
|||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MainUtil.sendMessage(plr, "An error occurred while creating the world: " + area.worldname);
|
MainUtil.sendMessage(player, "An error occurred while creating the world: " + area.worldname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (hasConfirmation(plr)) {
|
if (hasConfirmation(player)) {
|
||||||
CmdConfirm.addPending(plr, "/plot area create pos2 (Creates world)", run);
|
CmdConfirm.addPending(player, getCommandString() + " create pos2 (Creates world)", run);
|
||||||
} else {
|
} else {
|
||||||
run.run();
|
run.run();
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ public class Area extends SubCommand {
|
|||||||
final HybridPlotWorld pa = new HybridPlotWorld(object.world, id, new HybridGen(), null, null);
|
final HybridPlotWorld pa = new HybridPlotWorld(object.world, id, new HybridGen(), null, null);
|
||||||
PlotArea other = PS.get().getPlotArea(pa.worldname, id);
|
PlotArea other = PS.get().getPlotArea(pa.worldname, id);
|
||||||
if (other != null && Objects.equals(pa.id, other.id)) {
|
if (other != null && Objects.equals(pa.id, other.id)) {
|
||||||
C.SETUP_WORLD_TAKEN.send(plr, pa.toString());
|
C.SETUP_WORLD_TAKEN.send(player, pa.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Set<PlotArea> areas = PS.get().getPlotAreas(pa.worldname);
|
Set<PlotArea> areas = PS.get().getPlotAreas(pa.worldname);
|
||||||
@ -172,7 +172,7 @@ public class Area extends SubCommand {
|
|||||||
for (int i = 2; i < args.length; i++) {
|
for (int i = 2; i < args.length; i++) {
|
||||||
String[] pair = args[i].split("=");
|
String[] pair = args[i].split("=");
|
||||||
if (pair.length != 2) {
|
if (pair.length != 2) {
|
||||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
C.COMMAND_SYNTAX.send(player, getCommandString() + " create [world[:id]] [<modifier>=<value>]...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (pair[0].toLowerCase()) {
|
switch (pair[0].toLowerCase()) {
|
||||||
@ -218,13 +218,13 @@ public class Area extends SubCommand {
|
|||||||
object.type = pa.TYPE;
|
object.type = pa.TYPE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
C.COMMAND_SYNTAX.send(player, getCommandString() + " create [world[:id]] [<modifier>=<value>]...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pa.TYPE != 2) {
|
if (pa.TYPE != 2) {
|
||||||
if (WorldUtil.IMP.isWorld(pa.worldname)) {
|
if (WorldUtil.IMP.isWorld(pa.worldname)) {
|
||||||
C.SETUP_WORLD_TAKEN.send(plr, pa.worldname);
|
C.SETUP_WORLD_TAKEN.send(player, pa.worldname);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Runnable run = new Runnable() {
|
Runnable run = new Runnable() {
|
||||||
@ -241,10 +241,10 @@ public class Area extends SubCommand {
|
|||||||
object.setupGenerator = "PlotSquared";
|
object.setupGenerator = "PlotSquared";
|
||||||
String world = SetupUtils.manager.setupWorld(object);
|
String world = SetupUtils.manager.setupWorld(object);
|
||||||
if (WorldUtil.IMP.isWorld(world)) {
|
if (WorldUtil.IMP.isWorld(world)) {
|
||||||
C.SETUP_FINISHED.send(plr);
|
C.SETUP_FINISHED.send(player);
|
||||||
plr.teleport(WorldUtil.IMP.getSpawn(world));
|
player.teleport(WorldUtil.IMP.getSpawn(world));
|
||||||
} else {
|
} else {
|
||||||
MainUtil.sendMessage(plr, "An error occurred while creating the world: " + pa.worldname);
|
MainUtil.sendMessage(player, "An error occurred while creating the world: " + pa.worldname);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
PS.get().config.save(PS.get().configFile);
|
PS.get().config.save(PS.get().configFile);
|
||||||
@ -253,55 +253,55 @@ public class Area extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (hasConfirmation(plr)) {
|
if (hasConfirmation(player)) {
|
||||||
CmdConfirm.addPending(plr, "/plot area " + StringMan.join(args, " "), run);
|
CmdConfirm.addPending(player, getCommandString() + " " + StringMan.join(args, " "), run);
|
||||||
} else {
|
} else {
|
||||||
run.run();
|
run.run();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (pa.id == null) {
|
if (pa.id == null) {
|
||||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
C.COMMAND_SYNTAX.send(player, getCommandString() + " create [world[:id]] [<modifier>=<value>]...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (WorldUtil.IMP.isWorld(pa.worldname)) {
|
if (WorldUtil.IMP.isWorld(pa.worldname)) {
|
||||||
if (!plr.getLocation().getWorld().equals(pa.worldname)) {
|
if (!player.getLocation().getWorld().equals(pa.worldname)) {
|
||||||
plr.teleport(WorldUtil.IMP.getSpawn(pa.worldname));
|
player.teleport(WorldUtil.IMP.getSpawn(pa.worldname));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
object.terrain = 0;
|
object.terrain = 0;
|
||||||
object.type = 0;
|
object.type = 0;
|
||||||
SetupUtils.manager.setupWorld(object);
|
SetupUtils.manager.setupWorld(object);
|
||||||
plr.teleport(WorldUtil.IMP.getSpawn(pa.worldname));
|
player.teleport(WorldUtil.IMP.getSpawn(pa.worldname));
|
||||||
}
|
}
|
||||||
plr.setMeta("area_create_area", pa);
|
player.setMeta("area_create_area", pa);
|
||||||
MainUtil.sendMessage(plr, "$1Go to the first corner and use: $2/plot area create pos1");
|
MainUtil.sendMessage(player, "$1Go to the first corner and use: $2 " + getCommandString() + " create pos1");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case "i":
|
case "i":
|
||||||
case "info": {
|
case "info": {
|
||||||
if (!Permissions.hasPermission(plr, "plots.area.info")) {
|
if (!Permissions.hasPermission(player, "plots.area.info")) {
|
||||||
C.NO_PERMISSION.send(plr, "plots.area.info");
|
C.NO_PERMISSION.send(player, "plots.area.info");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotArea area;
|
PlotArea area;
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
area = plr.getApplicablePlotArea();
|
area = player.getApplicablePlotArea();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
area = PS.get().getPlotAreaByString(args[1]);
|
area = PS.get().getPlotAreaByString(args[1]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
C.COMMAND_SYNTAX.send(plr, "/plot area info [area]");
|
C.COMMAND_SYNTAX.send(player, getCommandString() + " info [area]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
C.NOT_VALID_PLOT_WORLD.send(plr, args[1]);
|
C.NOT_VALID_PLOT_WORLD.send(player, args[1]);
|
||||||
} else {
|
} else {
|
||||||
C.NOT_IN_PLOT_WORLD.send(plr);
|
C.NOT_IN_PLOT_WORLD.send(player);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -331,13 +331,13 @@ public class Area extends SubCommand {
|
|||||||
+ "\n$1Clusters: $2" + clusters
|
+ "\n$1Clusters: $2" + clusters
|
||||||
+ "\n$1Region: $2" + region
|
+ "\n$1Region: $2" + region
|
||||||
+ "\n$1Generator: $2" + generator;
|
+ "\n$1Generator: $2" + generator;
|
||||||
MainUtil.sendMessage(plr, C.PLOT_INFO_HEADER.s() + '\n' + value + '\n' + C.PLOT_INFO_FOOTER.s(), false);
|
MainUtil.sendMessage(player, C.PLOT_INFO_HEADER.s() + '\n' + value + '\n' + C.PLOT_INFO_FOOTER.s(), false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "l":
|
case "l":
|
||||||
case "list":
|
case "list":
|
||||||
if (!Permissions.hasPermission(plr, "plots.area.list")) {
|
if (!Permissions.hasPermission(player, "plots.area.list")) {
|
||||||
C.NO_PERMISSION.send(plr, "plots.area.list");
|
C.NO_PERMISSION.send(player, "plots.area.list");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int page;
|
int page;
|
||||||
@ -351,11 +351,11 @@ public class Area extends SubCommand {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
C.COMMAND_SYNTAX.send(plr, "/plot area list [#]");
|
C.COMMAND_SYNTAX.send(player, getCommandString() + " list [#]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ArrayList<PlotArea> areas = new ArrayList<>(PS.get().getPlotAreas());
|
ArrayList<PlotArea> areas = new ArrayList<>(PS.get().getPlotAreas());
|
||||||
paginate(plr, areas, 8, page, new RunnableVal3<Integer, PlotArea, PlotMessage>() {
|
paginate(player, areas, 8, page, new RunnableVal3<Integer, PlotArea, PlotMessage>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Integer i, PlotArea area, PlotMessage message) {
|
public void run(Integer i, PlotArea area, PlotMessage message) {
|
||||||
String name;
|
String name;
|
||||||
@ -388,7 +388,8 @@ public class Area extends SubCommand {
|
|||||||
message.text("[").color("$3")
|
message.text("[").color("$3")
|
||||||
.text(i + "").command(visit).tooltip(visit).color("$1")
|
.text(i + "").command(visit).tooltip(visit).color("$1")
|
||||||
.text("]").color("$3")
|
.text("]").color("$3")
|
||||||
.text(" " + name).tooltip(tooltip).command("/plot area info " + area).color("$1").text(" - ").color("$2")
|
.text(" " + name).tooltip(tooltip).command(getCommandString() + " info " + area).color("$1").text(" - ")
|
||||||
|
.color("$2")
|
||||||
.text(area.TYPE + ":" + area.TERRAIN).color("$3");
|
.text(area.TYPE + ":" + area.TERRAIN).color("$3");
|
||||||
}
|
}
|
||||||
}, "/plot area list", C.AREA_LIST_HEADER_PAGED.s());
|
}, "/plot area list", C.AREA_LIST_HEADER_PAGED.s());
|
||||||
@ -397,17 +398,17 @@ public class Area extends SubCommand {
|
|||||||
case "clear":
|
case "clear":
|
||||||
case "reset":
|
case "reset":
|
||||||
case "regenerate": {
|
case "regenerate": {
|
||||||
if (!Permissions.hasPermission(plr, "plots.area.regen")) {
|
if (!Permissions.hasPermission(player, "plots.area.regen")) {
|
||||||
C.NO_PERMISSION.send(plr, "plots.area.regen");
|
C.NO_PERMISSION.send(player, "plots.area.regen");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final PlotArea area = plr.getApplicablePlotArea();
|
final PlotArea area = player.getApplicablePlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
C.NOT_IN_PLOT_WORLD.send(plr);
|
C.NOT_IN_PLOT_WORLD.send(player);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (area.TYPE != 2) {
|
if (area.TYPE != 2) {
|
||||||
MainUtil.sendMessage(plr, "$4Stop the server and delete: " + area.worldname + "/region");
|
MainUtil.sendMessage(player, "$4Stop the server and delete: " + area.worldname + "/region");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ChunkManager.largeRegionTask(area.worldname, area.getRegion(), new RunnableVal<ChunkLoc>() {
|
ChunkManager.largeRegionTask(area.worldname, area.getRegion(), new RunnableVal<ChunkLoc>() {
|
||||||
@ -423,17 +424,17 @@ public class Area extends SubCommand {
|
|||||||
case "teleport":
|
case "teleport":
|
||||||
case "visit":
|
case "visit":
|
||||||
case "tp":
|
case "tp":
|
||||||
if (!Permissions.hasPermission(plr, "plots.area.tp")) {
|
if (!Permissions.hasPermission(player, "plots.area.tp")) {
|
||||||
C.NO_PERMISSION.send(plr, "plots.area.tp");
|
C.NO_PERMISSION.send(player, "plots.area.tp");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
C.COMMAND_SYNTAX.send(plr, "/plot visit [area]");
|
C.COMMAND_SYNTAX.send(player, "/plot visit [area]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotArea area = PS.get().getPlotAreaByString(args[1]);
|
PlotArea area = PS.get().getPlotAreaByString(args[1]);
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
C.NOT_VALID_PLOT_WORLD.send(plr, args[1]);
|
C.NOT_VALID_PLOT_WORLD.send(player, args[1]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Location center;
|
Location center;
|
||||||
@ -445,18 +446,18 @@ public class Area extends SubCommand {
|
|||||||
region.minZ + (region.maxZ - region.minZ) / 2);
|
region.minZ + (region.maxZ - region.minZ) / 2);
|
||||||
center.setY(WorldUtil.IMP.getHighestBlock(area.worldname, center.getX(), center.getZ()));
|
center.setY(WorldUtil.IMP.getHighestBlock(area.worldname, center.getX(), center.getZ()));
|
||||||
}
|
}
|
||||||
plr.teleport(center);
|
player.teleport(center);
|
||||||
return true;
|
return true;
|
||||||
case "delete":
|
case "delete":
|
||||||
case "remove":
|
case "remove":
|
||||||
MainUtil.sendMessage(plr, "$1World creation settings may be stored in multiple locations:"
|
MainUtil.sendMessage(player, "$1World creation settings may be stored in multiple locations:"
|
||||||
+ "\n$3 - $2Bukkit bukkit.yml"
|
+ "\n$3 - $2Bukkit bukkit.yml"
|
||||||
+ "\n$3 - $2PlotSquared settings.yml"
|
+ "\n$3 - $2PlotSquared settings.yml"
|
||||||
+ "\n$3 - $2Multiverse worlds.yml (or any world management plugin)"
|
+ "\n$3 - $2Multiverse worlds.yml (or any world management plugin)"
|
||||||
+ "\n$1Stop the server and delete it from these locations.");
|
+ "\n$1Stop the server and delete it from these locations.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import com.intellectualcrafters.plot.util.Permissions;
|
|||||||
import com.intellectualcrafters.plot.util.SetQueue;
|
import com.intellectualcrafters.plot.util.SetQueue;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@CommandDeclaration(command = "clear",
|
@CommandDeclaration(command = "clear",
|
||||||
@ -20,7 +21,7 @@ import java.util.Set;
|
|||||||
category = CommandCategory.APPEARANCE,
|
category = CommandCategory.APPEARANCE,
|
||||||
usage = "/plot clear [id]",
|
usage = "/plot clear [id]",
|
||||||
aliases = "reset",
|
aliases = "reset",
|
||||||
confirmation=true)
|
confirmation = true)
|
||||||
public class Clear extends SubCommand {
|
public class Clear extends SubCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -37,6 +37,7 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
|||||||
import com.plotsquared.general.commands.Command;
|
import com.plotsquared.general.commands.Command;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
import com.plotsquared.listener.WEManager;
|
import com.plotsquared.listener.WEManager;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@ -46,6 +47,7 @@ import java.util.Date;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.script.Bindings;
|
import javax.script.Bindings;
|
||||||
import javax.script.ScriptContext;
|
import javax.script.ScriptContext;
|
||||||
import javax.script.ScriptEngine;
|
import javax.script.ScriptEngine;
|
||||||
@ -145,7 +147,7 @@ public class DebugExec extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||||
java.util.List<String> allowed_params =
|
List<String> allowed_params =
|
||||||
Arrays.asList("calibrate-analysis", "remove-flag", "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "list-scripts");
|
Arrays.asList("calibrate-analysis", "remove-flag", "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "list-scripts");
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
String arg = args[0].toLowerCase();
|
String arg = args[0].toLowerCase();
|
||||||
@ -331,7 +333,7 @@ public class DebugExec extends SubCommand {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "list-scripts":
|
case "list-scripts":
|
||||||
final String path = PS.get().IMP.getDirectory() + File.separator + "scripts";
|
String path = PS.get().IMP.getDirectory() + File.separator + "scripts";
|
||||||
File folder = new File(path);
|
File folder = new File(path);
|
||||||
File[] filesArray = folder.listFiles();
|
File[] filesArray = folder.listFiles();
|
||||||
|
|
||||||
@ -355,8 +357,7 @@ public class DebugExec extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(Integer i, File file, PlotMessage message) {
|
public void run(Integer i, File file, PlotMessage message) {
|
||||||
String name;
|
String name = file.getName();
|
||||||
name = file.getName();
|
|
||||||
|
|
||||||
message.text("[").color("$3")
|
message.text("[").color("$3")
|
||||||
.text(i + "").color("$1")
|
.text(i + "").color("$1")
|
||||||
@ -416,7 +417,7 @@ public class DebugExec extends SubCommand {
|
|||||||
default:
|
default:
|
||||||
script = StringMan.join(args, " ");
|
script = StringMan.join(args, " ");
|
||||||
}
|
}
|
||||||
if (!ConsolePlayer.isConsole(player)) {
|
if (!(player instanceof ConsolePlayer)) {
|
||||||
MainUtil.sendMessage(player, C.NOT_CONSOLE);
|
MainUtil.sendMessage(player, C.NOT_CONSOLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -436,13 +437,13 @@ public class DebugExec extends SubCommand {
|
|||||||
} catch (ScriptException e) {
|
} catch (ScriptException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
ConsolePlayer.getConsole().sendMessage("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
|
PS.log("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Object result = this.engine.eval(script, this.scope);
|
Object result = this.engine.eval(script, this.scope);
|
||||||
ConsolePlayer.getConsole().sendMessage("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
|
PS.log("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (ScriptException e) {
|
} catch (ScriptException e) {
|
||||||
|
@ -11,6 +11,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
|||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
@ -21,7 +22,7 @@ import java.util.HashSet;
|
|||||||
aliases = {"dispose", "del"},
|
aliases = {"dispose", "del"},
|
||||||
category = CommandCategory.CLAIMING,
|
category = CommandCategory.CLAIMING,
|
||||||
requiredType = RequiredType.NONE,
|
requiredType = RequiredType.NONE,
|
||||||
confirmation=true)
|
confirmation = true)
|
||||||
public class Delete extends SubCommand {
|
public class Delete extends SubCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -59,7 +60,7 @@ public class Delete extends SubCommand {
|
|||||||
sendMessage(plr, C.ADDED_BALANCE, value + "");
|
sendMessage(plr, C.ADDED_BALANCE, value + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
|
MainUtil.sendMessage(plr, C.CLEARING_DONE, System.currentTimeMillis() - start);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (result) {
|
if (result) {
|
||||||
@ -70,7 +71,7 @@ public class Delete extends SubCommand {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (hasConfirmation(plr)) {
|
if (hasConfirmation(plr)) {
|
||||||
CmdConfirm.addPending(plr, "/plot delete " + plot.getId(), run);
|
CmdConfirm.addPending(plr, getCommandString() + ' ' + plot.getId(), run);
|
||||||
} else {
|
} else {
|
||||||
TaskManager.runTask(run);
|
TaskManager.runTask(run);
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,8 @@ public class Deny extends SubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||||
|
|
||||||
Location loc = plr.getLocation();
|
Location location = plr.getLocation();
|
||||||
Plot plot = loc.getPlotAbs();
|
Plot plot = location.getPlotAbs();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
|||||||
description = "Mark a plot as done",
|
description = "Mark a plot as done",
|
||||||
permission = "plots.done",
|
permission = "plots.done",
|
||||||
category = CommandCategory.SETTINGS,
|
category = CommandCategory.SETTINGS,
|
||||||
requiredType = RequiredType.NONE)
|
requiredType = RequiredType.PLAYER)
|
||||||
public class Done extends SubCommand {
|
public class Done extends SubCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,7 +22,7 @@ import java.net.URL;
|
|||||||
command = "download",
|
command = "download",
|
||||||
aliases = {"dl"},
|
aliases = {"dl"},
|
||||||
category = CommandCategory.SCHEMATIC,
|
category = CommandCategory.SCHEMATIC,
|
||||||
requiredType = RequiredType.NONE,
|
requiredType = RequiredType.PLAYER,
|
||||||
description = "Download your plot",
|
description = "Download your plot",
|
||||||
permission = "plots.download")
|
permission = "plots.download")
|
||||||
public class Download extends SubCommand {
|
public class Download extends SubCommand {
|
||||||
|
@ -13,6 +13,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
|||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.intellectualcrafters.plot.util.StringMan;
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -24,7 +25,7 @@ import java.util.Map;
|
|||||||
usage = "/plot flag <set|remove|add|list|info> <flag> <value>",
|
usage = "/plot flag <set|remove|add|list|info> <flag> <value>",
|
||||||
description = "Set plot flags",
|
description = "Set plot flags",
|
||||||
category = CommandCategory.SETTINGS,
|
category = CommandCategory.SETTINGS,
|
||||||
requiredType = RequiredType.NONE,
|
requiredType = RequiredType.PLAYER,
|
||||||
permission = "plots.flag")
|
permission = "plots.flag")
|
||||||
public class FlagCmd extends SubCommand {
|
public class FlagCmd extends SubCommand {
|
||||||
|
|
||||||
@ -75,18 +76,18 @@ public class FlagCmd extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info <flag>");
|
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info <flag>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
AbstractFlag af = FlagManager.getFlag(args[1]);
|
AbstractFlag flag = FlagManager.getFlag(args[1]);
|
||||||
if (af == null) {
|
if (flag == null) {
|
||||||
MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
|
MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
|
||||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info <flag>");
|
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info <flag>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// flag key
|
// flag key
|
||||||
MainUtil.sendMessage(player, C.FLAG_KEY, af.getKey());
|
MainUtil.sendMessage(player, C.FLAG_KEY, flag.getKey());
|
||||||
// flag type
|
// flag type
|
||||||
MainUtil.sendMessage(player, C.FLAG_TYPE, af.value.getClass().getSimpleName());
|
MainUtil.sendMessage(player, C.FLAG_TYPE, flag.value.getClass().getSimpleName());
|
||||||
// Flag type description
|
// Flag type description
|
||||||
MainUtil.sendMessage(player, C.FLAG_DESC, af.getValueDesc());
|
MainUtil.sendMessage(player, C.FLAG_DESC, flag.getValueDesc());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "set": {
|
case "set": {
|
||||||
@ -167,7 +168,7 @@ public class FlagCmd extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, C.FLAG_REMOVED);
|
MainUtil.sendMessage(player, C.FLAG_REMOVED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "add": {
|
case "add":
|
||||||
if (!Permissions.hasPermission(player, "plots.flag.add")) {
|
if (!Permissions.hasPermission(player, "plots.flag.add")) {
|
||||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flag.add");
|
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flag.add");
|
||||||
return false;
|
return false;
|
||||||
@ -206,7 +207,6 @@ public class FlagCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, C.FLAG_ADDED);
|
MainUtil.sendMessage(player, C.FLAG_ADDED);
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
case "list":
|
case "list":
|
||||||
if (!Permissions.hasPermission(player, "plots.flag.list")) {
|
if (!Permissions.hasPermission(player, "plots.flag.list")) {
|
||||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flag.list");
|
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flag.list");
|
||||||
@ -217,12 +217,12 @@ public class FlagCmd extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
HashMap<String, ArrayList<String>> flags = new HashMap<>();
|
HashMap<String, ArrayList<String>> flags = new HashMap<>();
|
||||||
for (AbstractFlag af : FlagManager.getFlags()) {
|
for (AbstractFlag flag1 : FlagManager.getFlags()) {
|
||||||
String type = af.value.getClass().getSimpleName().replaceAll("Value", "");
|
String type = flag1.value.getClass().getSimpleName().replaceAll("Value", "");
|
||||||
if (!flags.containsKey(type)) {
|
if (!flags.containsKey(type)) {
|
||||||
flags.put(type, new ArrayList<String>());
|
flags.put(type, new ArrayList<String>());
|
||||||
}
|
}
|
||||||
flags.get(type).add(af.getKey());
|
flags.get(type).add(flag1.getKey());
|
||||||
}
|
}
|
||||||
String message = "";
|
String message = "";
|
||||||
String prefix = "";
|
String prefix = "";
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
@ -66,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()) {
|
||||||
@ -155,9 +162,9 @@ public class Inbox extends SubCommand {
|
|||||||
sendMessage(player, C.NO_PERM_INBOX_MODIFY);
|
sendMessage(player, C.NO_PERM_INBOX_MODIFY);
|
||||||
}
|
}
|
||||||
inbox.clearInbox(plot);
|
inbox.clearInbox(plot);
|
||||||
ArrayList<PlotComment> comments = plot.getSettings().getComments(inbox.toString());
|
Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(inbox.toString());
|
||||||
if (comments != null) {
|
if (comments.isPresent()) {
|
||||||
plot.getSettings().removeComments(comments);
|
plot.getSettings().removeComments(comments.get());
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, C.COMMENT_REMOVED, "*");
|
MainUtil.sendMessage(player, C.COMMENT_REMOVED, "*");
|
||||||
return true;
|
return true;
|
||||||
@ -182,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;
|
||||||
|
@ -82,6 +82,7 @@ public class Info extends SubCommand {
|
|||||||
"&cAlias: &6" + plot.getAlias(),
|
"&cAlias: &6" + plot.getAlias(),
|
||||||
"&cBiome: &6" + plot.getBiome().replaceAll("_", "").toLowerCase(),
|
"&cBiome: &6" + plot.getBiome().replaceAll("_", "").toLowerCase(),
|
||||||
"&cCan Build: &6" + plot.isAdded(uuid),
|
"&cCan Build: &6" + plot.isAdded(uuid),
|
||||||
|
"&cExpires: &6" + plot.isAdded(uuid),
|
||||||
"&cIs Denied: &6" + plot.isDenied(uuid)));
|
"&cIs Denied: &6" + plot.isDenied(uuid)));
|
||||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted", "&cAmount: &6" + plot.getTrusted().size(),
|
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted", "&cAmount: &6" + plot.getTrusted().size(),
|
||||||
"&8Click to view a list of the trusted users"));
|
"&8Click to view a list of the trusted users"));
|
||||||
@ -109,8 +110,8 @@ public class Info extends SubCommand {
|
|||||||
info = getCaption(arg);
|
info = getCaption(arg);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
MainUtil.sendMessage(player,
|
MainUtil.sendMessage(player,
|
||||||
"&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, "
|
"&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aexpires&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, "
|
||||||
+ "&arating");
|
+ "&aowner&7, " + "&arating");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
full = true;
|
full = true;
|
||||||
@ -148,6 +149,8 @@ public class Info extends SubCommand {
|
|||||||
return C.PLOT_INFO_OWNER.s();
|
return C.PLOT_INFO_OWNER.s();
|
||||||
case "rating":
|
case "rating":
|
||||||
return C.PLOT_INFO_RATING.s();
|
return C.PLOT_INFO_RATING.s();
|
||||||
|
case "expires":
|
||||||
|
return C.PLOT_INFO_EXPIRES.s();
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@ public class Kick extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||||
Location loc = plr.getLocation();
|
Location location = plr.getLocation();
|
||||||
Plot plot = loc.getPlot();
|
Plot plot = location.getPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
@ -40,8 +40,8 @@ public class Kick extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Location otherLoc = player.getLocation();
|
Location location2 = player.getLocation();
|
||||||
if (!plr.getLocation().getWorld().equals(otherLoc.getWorld()) || !plot.equals(otherLoc.getPlot())) {
|
if (!plr.getLocation().getWorld().equals(location2.getWorld()) || !plot.equals(location2.getPlot())) {
|
||||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ public class Kick extends SubCommand {
|
|||||||
C.CANNOT_KICK_PLAYER.send(plr, player.getName());
|
C.CANNOT_KICK_PLAYER.send(plr, player.getName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Location spawn = WorldUtil.IMP.getSpawn(loc.getWorld());
|
Location spawn = WorldUtil.IMP.getSpawn(location.getWorld());
|
||||||
C.YOU_GOT_KICKED.send(player);
|
C.YOU_GOT_KICKED.send(player);
|
||||||
if (plot.equals(spawn.getPlot())) {
|
if (plot.equals(spawn.getPlot())) {
|
||||||
Location newSpawn = WorldUtil.IMP.getSpawn(player);
|
Location newSpawn = WorldUtil.IMP.getSpawn(player);
|
||||||
|
@ -14,6 +14,7 @@ import com.intellectualcrafters.plot.util.EconHandler;
|
|||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.plotsquared.general.commands.Command;
|
import com.plotsquared.general.commands.Command;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,14 +114,6 @@ public class MainCommand extends Command {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
/**
|
|
||||||
* @Deprecated legacy
|
|
||||||
*/
|
|
||||||
public void addCommand(SubCommand command) {
|
|
||||||
PS.debug("Command registration is now done during instantiation");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean onCommand(final PlotPlayer player, String... args) {
|
public static boolean onCommand(final PlotPlayer player, String... args) {
|
||||||
if (args.length >= 1 && args[0].contains(":")) {
|
if (args.length >= 1 && args[0].contains(":")) {
|
||||||
String[] split2 = args[0].split(":");
|
String[] split2 = args[0].split(":");
|
||||||
@ -181,6 +174,14 @@ public class MainCommand extends Command {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
/**
|
||||||
|
* @Deprecated legacy
|
||||||
|
*/
|
||||||
|
public void addCommand(SubCommand command) {
|
||||||
|
PS.debug("Command registration is now done during instantiation");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
||||||
// Clear perm caching //
|
// Clear perm caching //
|
||||||
@ -192,7 +193,8 @@ public class MainCommand extends Command {
|
|||||||
if (args.length >= 2) {
|
if (args.length >= 2) {
|
||||||
PlotArea area = player.getApplicablePlotArea();
|
PlotArea area = player.getApplicablePlotArea();
|
||||||
Plot newPlot = Plot.fromString(area, args[0]);
|
Plot newPlot = Plot.fromString(area, args[0]);
|
||||||
if (newPlot != null && (ConsolePlayer.isConsole(player) || newPlot.getArea().equals(area) || Permissions.hasPermission(player, C.PERMISSION_ADMIN)) && !newPlot.isDenied(player.getUUID())) {
|
if (newPlot != null && (player instanceof ConsolePlayer || newPlot.getArea().equals(area) || Permissions
|
||||||
|
.hasPermission(player, C.PERMISSION_ADMIN)) && !newPlot.isDenied(player.getUUID())) {
|
||||||
// Save meta
|
// Save meta
|
||||||
loc = player.getMeta("location");
|
loc = player.getMeta("location");
|
||||||
plot = player.getMeta("lastplot");
|
plot = player.getMeta("lastplot");
|
||||||
|
@ -22,8 +22,8 @@ import java.util.UUID;
|
|||||||
description = "Merge the plot you are standing on, with another plot",
|
description = "Merge the plot you are standing on, with another plot",
|
||||||
permission = "plots.merge", usage = "/plot merge <all|n|e|s|w> [removeroads]",
|
permission = "plots.merge", usage = "/plot merge <all|n|e|s|w> [removeroads]",
|
||||||
category = CommandCategory.SETTINGS,
|
category = CommandCategory.SETTINGS,
|
||||||
requiredType = RequiredType.NONE,
|
requiredType = RequiredType.PLAYER,
|
||||||
confirmation=true)
|
confirmation = true)
|
||||||
public class Merge extends SubCommand {
|
public class Merge extends SubCommand {
|
||||||
|
|
||||||
public static final String[] values = new String[]{"north", "east", "south", "west", "auto"};
|
public static final String[] values = new String[]{"north", "east", "south", "west", "auto"};
|
||||||
|
@ -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;
|
||||||
@ -24,7 +25,7 @@ import java.util.UUID;
|
|||||||
description = "Purge all plots for a world",
|
description = "Purge all plots for a world",
|
||||||
category = CommandCategory.ADMINISTRATION,
|
category = CommandCategory.ADMINISTRATION,
|
||||||
requiredType = RequiredType.CONSOLE,
|
requiredType = RequiredType.CONSOLE,
|
||||||
confirmation=true)
|
confirmation = true)
|
||||||
public class Purge extends SubCommand {
|
public class Purge extends SubCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -145,12 +146,15 @@ public class Purge extends SubCommand {
|
|||||||
Runnable run = new Runnable() {
|
Runnable run = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
HashSet<Integer> ids = new HashSet<Integer>();
|
HashSet<Integer> ids = new HashSet<>();
|
||||||
for (Plot plot : toDelete) {
|
for (Plot plot : toDelete) {
|
||||||
if (plot.temp != Integer.MAX_VALUE) {
|
if (plot.temp != Integer.MAX_VALUE) {
|
||||||
ids.add(plot.temp);
|
ids.add(plot.temp);
|
||||||
PlotArea area = plot.getArea();
|
|
||||||
plot.getArea().removePlot(plot.getId());
|
plot.getArea().removePlot(plot.getId());
|
||||||
|
for (PlotPlayer pp : plot.getPlayersInPlot()) {
|
||||||
|
PlotListener.plotEntry(pp, plot);
|
||||||
|
}
|
||||||
|
plot.removeSign();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DBFunc.purgeIds(ids);
|
DBFunc.purgeIds(ids);
|
||||||
|
@ -141,7 +141,7 @@ public class SchematicCmd extends SubCommand {
|
|||||||
// }
|
// }
|
||||||
case "saveall":
|
case "saveall":
|
||||||
case "exportall": {
|
case "exportall": {
|
||||||
if (!ConsolePlayer.isConsole(plr)) {
|
if (!(plr instanceof ConsolePlayer)) {
|
||||||
MainUtil.sendMessage(plr, C.NOT_CONSOLE);
|
MainUtil.sendMessage(plr, C.NOT_CONSOLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -197,10 +197,9 @@ public class SchematicCmd extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Plot p2 = plot;
|
|
||||||
loc.getWorld();
|
loc.getWorld();
|
||||||
Collection<Plot> plots = new ArrayList<Plot>();
|
Collection<Plot> plots = new ArrayList<Plot>();
|
||||||
plots.add(p2);
|
plots.add(plot);
|
||||||
boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() {
|
boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -15,7 +15,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
|||||||
usage = "/plot target <<plot>|nearest>",
|
usage = "/plot target <<plot>|nearest>",
|
||||||
description = "Target a plot with your compass",
|
description = "Target a plot with your compass",
|
||||||
permission = "plots.target",
|
permission = "plots.target",
|
||||||
requiredType = RequiredType.NONE,
|
requiredType = RequiredType.PLAYER,
|
||||||
category = CommandCategory.INFO)
|
category = CommandCategory.INFO)
|
||||||
public class Target extends SubCommand {
|
public class Target extends SubCommand {
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@ package com.intellectualcrafters.plot.config;
|
|||||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
|
||||||
import com.intellectualcrafters.plot.util.StringMan;
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
import com.plotsquared.general.commands.CommandCaller;
|
import com.plotsquared.general.commands.CommandCaller;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -453,6 +453,7 @@ public enum C {
|
|||||||
* Info
|
* Info
|
||||||
*/
|
*/
|
||||||
NONE("None", "Info"),
|
NONE("None", "Info"),
|
||||||
|
NEVER("Never", "Info"),
|
||||||
UNKNOWN("Unknown", "Info"),
|
UNKNOWN("Unknown", "Info"),
|
||||||
EVERYONE("Everyone", "Info"),
|
EVERYONE("Everyone", "Info"),
|
||||||
PLOT_UNOWNED("$2The current plot must have an owner to perform this action", "Info"),
|
PLOT_UNOWNED("$2The current plot must have an owner to perform this action", "Info"),
|
||||||
@ -464,6 +465,7 @@ public enum C {
|
|||||||
+ "$1Biome: $2%biome%$1&-"
|
+ "$1Biome: $2%biome%$1&-"
|
||||||
+ "$1Can Build: $2%build%$1&-"
|
+ "$1Can Build: $2%build%$1&-"
|
||||||
+ "$1Rating: $2%rating%&-"
|
+ "$1Rating: $2%rating%&-"
|
||||||
|
+ "$1Expires: $2%expires%&-"
|
||||||
+ "$1Trusted: $2%trusted%$1&-"
|
+ "$1Trusted: $2%trusted%$1&-"
|
||||||
+ "$1Members: $2%members%$1&-"
|
+ "$1Members: $2%members%$1&-"
|
||||||
+ "$1Denied: $2%denied%$1&-"
|
+ "$1Denied: $2%denied%$1&-"
|
||||||
@ -479,6 +481,7 @@ public enum C {
|
|||||||
PLOT_INFO_ID("$1ID:$2 %id%", "Info"),
|
PLOT_INFO_ID("$1ID:$2 %id%", "Info"),
|
||||||
PLOT_INFO_ALIAS("$1Alias:$2 %alias%", "Info"),
|
PLOT_INFO_ALIAS("$1Alias:$2 %alias%", "Info"),
|
||||||
PLOT_INFO_SIZE("$1Size:$2 %size%", "Info"),
|
PLOT_INFO_SIZE("$1Size:$2 %size%", "Info"),
|
||||||
|
PLOT_INFO_EXPIRES("$1Expires:$2 %expires%", "Info"),
|
||||||
PLOT_USER_LIST(" $1%user%$2,", "Info"),
|
PLOT_USER_LIST(" $1%user%$2,", "Info"),
|
||||||
INFO_SYNTAX_CONSOLE("$2/plot info X;Y", "Info"),
|
INFO_SYNTAX_CONSOLE("$2/plot info X;Y", "Info"),
|
||||||
/*
|
/*
|
||||||
@ -621,14 +624,14 @@ public enum C {
|
|||||||
* What locale category should this translation fall under.
|
* What locale category should this translation fall under.
|
||||||
*/
|
*/
|
||||||
private final String category;
|
private final String category;
|
||||||
/**
|
|
||||||
* Translated.
|
|
||||||
*/
|
|
||||||
private String s;
|
|
||||||
/**
|
/**
|
||||||
* Should the string be prefixed.
|
* Should the string be prefixed.
|
||||||
*/
|
*/
|
||||||
private final boolean prefix;
|
private final boolean prefix;
|
||||||
|
/**
|
||||||
|
* Translated.
|
||||||
|
*/
|
||||||
|
private String s;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@ -799,7 +802,7 @@ public enum C {
|
|||||||
public void send(CommandCaller plr, Object... args) {
|
public void send(CommandCaller plr, Object... args) {
|
||||||
String msg = format(this, args);
|
String msg = format(this, args);
|
||||||
if (plr == null) {
|
if (plr == null) {
|
||||||
ConsolePlayer.getConsole().sendMessage(msg);
|
PS.log(msg);
|
||||||
} else {
|
} else {
|
||||||
plr.sendMessage(msg);
|
plr.sendMessage(msg);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ public class ConfigurationNode {
|
|||||||
private final SettingValue type;
|
private final SettingValue type;
|
||||||
private Object value;
|
private Object value;
|
||||||
|
|
||||||
public ConfigurationNode(String constant, Object defaultValue, String description, SettingValue type, boolean required) {
|
public ConfigurationNode(String constant, Object defaultValue, String description, SettingValue type) {
|
||||||
this.constant = constant;
|
this.constant = constant;
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
@ -6,16 +6,11 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Updater and DB settings
|
* Updater and DB settings
|
||||||
*
|
*
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
public class Settings {
|
public class Settings {
|
||||||
public static boolean USE_SQLUUIDHANDLER = false;
|
public static boolean USE_SQLUUIDHANDLER = false;
|
||||||
|
|
||||||
public static boolean AUTO_PURGE = false;
|
public static boolean AUTO_PURGE = false;
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static boolean UPDATE_NOTIFICATIONS = true;
|
public static boolean UPDATE_NOTIFICATIONS = true;
|
||||||
|
|
||||||
public static boolean FAST_CLEAR = false;
|
public static boolean FAST_CLEAR = false;
|
||||||
@ -163,8 +158,6 @@ public class Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Database settings
|
* Database settings
|
||||||
*
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
public static class DB {
|
public static class DB {
|
||||||
/**
|
/**
|
||||||
|
@ -139,8 +139,7 @@ public interface AbstractDB {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set plot flags.
|
* Set plot flags.
|
||||||
*
|
* @param plot Plot Object
|
||||||
* @param plot Plot Object
|
|
||||||
* @param flags flags to set (flag[])
|
* @param flags flags to set (flag[])
|
||||||
*/
|
*/
|
||||||
void setFlags(Plot plot, Collection<Flag> flags);
|
void setFlags(Plot plot, Collection<Flag> flags);
|
||||||
|
@ -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);
|
||||||
|
@ -1443,18 +1443,19 @@ public class SQLManager implements AbstractDB {
|
|||||||
if (plot.temp > 0) {
|
if (plot.temp > 0) {
|
||||||
return plot.temp;
|
return plot.temp;
|
||||||
}
|
}
|
||||||
PreparedStatement stmt = this.connection.prepareStatement(
|
int id;
|
||||||
"SELECT `id` FROM `" + this.prefix + "plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC");
|
try (PreparedStatement statement = this.connection.prepareStatement(
|
||||||
stmt.setInt(1, plot.getId().x);
|
"SELECT `id` FROM `" + this.prefix + "plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC")) {
|
||||||
stmt.setInt(2, plot.getId().y);
|
statement.setInt(1, plot.getId().x);
|
||||||
stmt.setString(3, plot.getArea().toString());
|
statement.setInt(2, plot.getId().y);
|
||||||
ResultSet r = stmt.executeQuery();
|
statement.setString(3, plot.getArea().toString());
|
||||||
int id = Integer.MAX_VALUE;
|
try (ResultSet resultSet = statement.executeQuery()) {
|
||||||
while (r.next()) {
|
id = Integer.MAX_VALUE;
|
||||||
id = r.getInt("id");
|
while (resultSet.next()) {
|
||||||
|
id = resultSet.getInt("id");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
r.close();
|
|
||||||
stmt.close();
|
|
||||||
if (id == Integer.MAX_VALUE || id == 0) {
|
if (id == Integer.MAX_VALUE || id == 0) {
|
||||||
if (plot.temp > 0) {
|
if (plot.temp > 0) {
|
||||||
return plot.temp;
|
return plot.temp;
|
||||||
@ -1625,17 +1626,17 @@ public class SQLManager implements AbstractDB {
|
|||||||
/*
|
/*
|
||||||
* Getting plots
|
* Getting plots
|
||||||
*/
|
*/
|
||||||
Statement stmt = this.connection.createStatement();
|
Statement statement = this.connection.createStatement();
|
||||||
int id;
|
int id;
|
||||||
String o;
|
String o;
|
||||||
UUID user;
|
UUID user;
|
||||||
try (ResultSet r = stmt
|
try (ResultSet resultSet = statement
|
||||||
.executeQuery("SELECT `id`, `plot_id_x`, `plot_id_z`, `owner`, `world`, `timestamp` FROM `" + this.prefix + "plot`")) {
|
.executeQuery("SELECT `id`, `plot_id_x`, `plot_id_z`, `owner`, `world`, `timestamp` FROM `" + this.prefix + "plot`")) {
|
||||||
ArrayList<Integer> toDelete = new ArrayList<>();
|
ArrayList<Integer> toDelete = new ArrayList<>();
|
||||||
while (r.next()) {
|
while (resultSet.next()) {
|
||||||
PlotId plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z"));
|
PlotId plot_id = new PlotId(resultSet.getInt("plot_id_x"), resultSet.getInt("plot_id_z"));
|
||||||
id = r.getInt("id");
|
id = resultSet.getInt("id");
|
||||||
String areaid = r.getString("world");
|
String areaid = resultSet.getString("world");
|
||||||
if (!areas.contains(areaid)) {
|
if (!areas.contains(areaid)) {
|
||||||
if (Settings.AUTO_PURGE) {
|
if (Settings.AUTO_PURGE) {
|
||||||
toDelete.add(id);
|
toDelete.add(id);
|
||||||
@ -1649,13 +1650,13 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
o = r.getString("owner");
|
o = resultSet.getString("owner");
|
||||||
user = uuids.get(o);
|
user = uuids.get(o);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
user = UUID.fromString(o);
|
user = UUID.fromString(o);
|
||||||
uuids.put(o, user);
|
uuids.put(o, user);
|
||||||
}
|
}
|
||||||
Timestamp timestamp = r.getTimestamp("timestamp");
|
Timestamp timestamp = resultSet.getTimestamp("timestamp");
|
||||||
long time = timestamp.getTime();
|
long time = timestamp.getTime();
|
||||||
Plot p = new Plot(plot_id, user, new HashSet<UUID>(), new HashSet<UUID>(), new HashSet<UUID>(), "", null, null, null,
|
Plot p = new Plot(plot_id, user, new HashSet<UUID>(), new HashSet<UUID>(), new HashSet<UUID>(), "", null, null, null,
|
||||||
new boolean[]{false, false, false, false}, time, id);
|
new boolean[]{false, false, false, false}, time, id);
|
||||||
@ -1682,7 +1683,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
deleteRows(toDelete, this.prefix + "plot", "id");
|
deleteRows(toDelete, this.prefix + "plot", "id");
|
||||||
}
|
}
|
||||||
if (Settings.CACHE_RATINGS) {
|
if (Settings.CACHE_RATINGS) {
|
||||||
try (ResultSet r = stmt.executeQuery("SELECT `plot_plot_id`, `player`, `rating` FROM `" + this.prefix + "plot_rating`")) {
|
try (ResultSet r = statement.executeQuery("SELECT `plot_plot_id`, `player`, `rating` FROM `" + this.prefix + "plot_rating`")) {
|
||||||
ArrayList<Integer> toDelete = new ArrayList<>();
|
ArrayList<Integer> toDelete = new ArrayList<>();
|
||||||
while (r.next()) {
|
while (r.next()) {
|
||||||
id = r.getInt("plot_plot_id");
|
id = r.getInt("plot_plot_id");
|
||||||
@ -1709,7 +1710,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
/*
|
/*
|
||||||
* Getting helpers
|
* Getting helpers
|
||||||
*/
|
*/
|
||||||
try (ResultSet r = stmt.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + this.prefix + "plot_helpers`")) {
|
try (ResultSet r = statement.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + this.prefix + "plot_helpers`")) {
|
||||||
ArrayList<Integer> toDelete = new ArrayList<>();
|
ArrayList<Integer> toDelete = new ArrayList<>();
|
||||||
while (r.next()) {
|
while (r.next()) {
|
||||||
id = r.getInt("plot_plot_id");
|
id = r.getInt("plot_plot_id");
|
||||||
@ -1735,7 +1736,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
/*
|
/*
|
||||||
* Getting trusted
|
* Getting trusted
|
||||||
*/
|
*/
|
||||||
try (ResultSet r = stmt.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + this.prefix + "plot_trusted`")) {
|
try (ResultSet r = statement.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + this.prefix + "plot_trusted`")) {
|
||||||
ArrayList<Integer> toDelete = new ArrayList<>();
|
ArrayList<Integer> toDelete = new ArrayList<>();
|
||||||
while (r.next()) {
|
while (r.next()) {
|
||||||
id = r.getInt("plot_plot_id");
|
id = r.getInt("plot_plot_id");
|
||||||
@ -1761,7 +1762,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
/*
|
/*
|
||||||
* Getting denied
|
* Getting denied
|
||||||
*/
|
*/
|
||||||
try (ResultSet r = stmt.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + this.prefix + "plot_denied`")) {
|
try (ResultSet r = statement.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + this.prefix + "plot_denied`")) {
|
||||||
ArrayList<Integer> toDelete = new ArrayList<>();
|
ArrayList<Integer> toDelete = new ArrayList<>();
|
||||||
while (r.next()) {
|
while (r.next()) {
|
||||||
id = r.getInt("plot_plot_id");
|
id = r.getInt("plot_plot_id");
|
||||||
@ -1783,7 +1784,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
deleteRows(toDelete, this.prefix + "plot_denied", "plot_plot_id");
|
deleteRows(toDelete, this.prefix + "plot_denied", "plot_plot_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
try (ResultSet r = stmt.executeQuery("SELECT * FROM `" + this.prefix + "plot_settings`")) {
|
try (ResultSet r = statement.executeQuery("SELECT * FROM `" + this.prefix + "plot_settings`")) {
|
||||||
ArrayList<Integer> toDelete = new ArrayList<>();
|
ArrayList<Integer> toDelete = new ArrayList<>();
|
||||||
while (r.next()) {
|
while (r.next()) {
|
||||||
id = r.getInt("plot_plot_id");
|
id = r.getInt("plot_plot_id");
|
||||||
@ -1860,7 +1861,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
+ ".yml.");
|
+ ".yml.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stmt.close();
|
statement.close();
|
||||||
deleteRows(toDelete, this.prefix + "plot_settings", "plot_plot_id");
|
deleteRows(toDelete, this.prefix + "plot_settings", "plot_plot_id");
|
||||||
}
|
}
|
||||||
if (!plots.entrySet().isEmpty()) {
|
if (!plots.entrySet().isEmpty()) {
|
||||||
@ -2012,7 +2013,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
stmt_prefix = " OR `id` = ";
|
stmt_prefix = " OR `id` = ";
|
||||||
}
|
}
|
||||||
stmt_prefix = "";
|
stmt_prefix = "";
|
||||||
StringBuilder idstr = new StringBuilder("");
|
StringBuilder idstr = new StringBuilder();
|
||||||
for (Integer id : uniqueIds) {
|
for (Integer id : uniqueIds) {
|
||||||
idstr.append(stmt_prefix).append(id);
|
idstr.append(stmt_prefix).append(id);
|
||||||
stmt_prefix = " OR `plot_plot_id` = ";
|
stmt_prefix = " OR `plot_plot_id` = ";
|
||||||
@ -3146,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;
|
||||||
|
@ -6,6 +6,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public class Flag<T> implements Cloneable {
|
public class Flag<T> implements Cloneable {
|
||||||
|
|
||||||
private AbstractFlag key;
|
private AbstractFlag key;
|
||||||
private Object value;
|
private Object value;
|
||||||
private String name;
|
private String name;
|
||||||
@ -128,7 +129,8 @@ public class Flag<T> implements Cloneable {
|
|||||||
return new Flag(this.key, method.invoke(this.value));
|
return new Flag(this.key, method.invoke(this.value));
|
||||||
}
|
}
|
||||||
return new Flag(this.key, this.key.parseValueRaw(this.key.toString(this.value)));
|
return new Flag(this.key, this.key.parseValueRaw(this.key.toString(this.value)));
|
||||||
} catch (CloneNotSupportedException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | InvocationTargetException e) {
|
} catch (CloneNotSupportedException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException |
|
||||||
|
InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
@ -26,6 +26,10 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
public class FlagManager {
|
public class FlagManager {
|
||||||
|
|
||||||
|
//TODO Default Flags
|
||||||
|
public static final IntegerFlag MUSIC = new IntegerFlag("music");
|
||||||
|
|
||||||
|
|
||||||
private static final HashSet<String> reserved = new HashSet<>();
|
private static final HashSet<String> reserved = new HashSet<>();
|
||||||
|
|
||||||
private static final HashSet<AbstractFlag> flags = new HashSet<>();
|
private static final HashSet<AbstractFlag> flags = new HashSet<>();
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.intellectualcrafters.plot.flag;
|
||||||
|
|
||||||
|
public class IntegerFlag extends Flag<Integer> {
|
||||||
|
|
||||||
|
public IntegerFlag(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
}
|
@ -34,18 +34,18 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
|
|||||||
@Override
|
@Override
|
||||||
public ConfigurationNode[] getSettingNodes() {
|
public ConfigurationNode[] getSettingNodes() {
|
||||||
return new ConfigurationNode[] {
|
return new ConfigurationNode[] {
|
||||||
new ConfigurationNode("plot.height", this.PLOT_HEIGHT, "Plot height", Configuration.INTEGER, true),
|
new ConfigurationNode("plot.height", this.PLOT_HEIGHT, "Plot height", Configuration.INTEGER),
|
||||||
new ConfigurationNode("plot.size", this.PLOT_WIDTH, "Plot width", Configuration.INTEGER, true),
|
new ConfigurationNode("plot.size", this.PLOT_WIDTH, "Plot width", Configuration.INTEGER),
|
||||||
new ConfigurationNode("plot.filling", this.MAIN_BLOCK, "Plot block", Configuration.BLOCKLIST, true),
|
new ConfigurationNode("plot.filling", this.MAIN_BLOCK, "Plot block", Configuration.BLOCKLIST),
|
||||||
new ConfigurationNode("plot.floor", this.TOP_BLOCK, "Plot floor block", Configuration.BLOCKLIST, true),
|
new ConfigurationNode("plot.floor", this.TOP_BLOCK, "Plot floor block", Configuration.BLOCKLIST),
|
||||||
new ConfigurationNode("wall.block", this.WALL_BLOCK, "Top wall block", Configuration.BLOCK, true),
|
new ConfigurationNode("wall.block", this.WALL_BLOCK, "Top wall block", Configuration.BLOCK),
|
||||||
new ConfigurationNode("wall.block_claimed", this.CLAIMED_WALL_BLOCK, "Wall block (claimed)", Configuration.BLOCK, true),
|
new ConfigurationNode("wall.block_claimed", this.CLAIMED_WALL_BLOCK, "Wall block (claimed)", Configuration.BLOCK),
|
||||||
new ConfigurationNode("road.width", this.ROAD_WIDTH, "Road width", Configuration.INTEGER, true),
|
new ConfigurationNode("road.width", this.ROAD_WIDTH, "Road width", Configuration.INTEGER),
|
||||||
new ConfigurationNode("road.height", this.ROAD_HEIGHT, "Road height", Configuration.INTEGER, true),
|
new ConfigurationNode("road.height", this.ROAD_HEIGHT, "Road height", Configuration.INTEGER),
|
||||||
new ConfigurationNode("road.block", this.ROAD_BLOCK, "Road block", Configuration.BLOCK, true),
|
new ConfigurationNode("road.block", this.ROAD_BLOCK, "Road block", Configuration.BLOCK),
|
||||||
new ConfigurationNode("wall.filling", this.WALL_FILLING, "Wall filling block", Configuration.BLOCK, true),
|
new ConfigurationNode("wall.filling", this.WALL_FILLING, "Wall filling block", Configuration.BLOCK),
|
||||||
new ConfigurationNode("wall.height", this.WALL_HEIGHT, "Wall height", Configuration.INTEGER, true),
|
new ConfigurationNode("wall.height", this.WALL_HEIGHT, "Wall height", Configuration.INTEGER),
|
||||||
new ConfigurationNode("plot.bedrock", this.PLOT_BEDROCK, "Plot bedrock generation", Configuration.BOOLEAN, true)};
|
new ConfigurationNode("plot.bedrock", this.PLOT_BEDROCK, "Plot bedrock generation", Configuration.BOOLEAN)};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,6 +13,7 @@ import com.intellectualcrafters.plot.util.MathMan;
|
|||||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||||
import com.intellectualcrafters.plot.util.SchematicHandler.Dimension;
|
import com.intellectualcrafters.plot.util.SchematicHandler.Dimension;
|
||||||
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -163,11 +164,11 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCompatible(PlotArea plotworld) {
|
public boolean isCompatible(PlotArea plotArea) {
|
||||||
if (!(plotworld instanceof SquarePlotWorld)) {
|
if (!(plotArea instanceof SquarePlotWorld)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return ((SquarePlotWorld) plotworld).PLOT_WIDTH == this.PLOT_WIDTH;
|
return ((SquarePlotWorld) plotArea).PLOT_WIDTH == this.PLOT_WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupSchematics() {
|
public void setupSchematics() {
|
||||||
@ -213,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();
|
||||||
|
@ -9,8 +9,8 @@ import com.intellectualcrafters.plot.object.SetupObject;
|
|||||||
import com.intellectualcrafters.plot.util.PlotChunk;
|
import com.intellectualcrafters.plot.util.PlotChunk;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class allows for implementation independent world generation<br>
|
* This class allows for implementation independent world generation.
|
||||||
* - Sponge/Bukkit API<br><br>
|
* - Sponge/Bukkit API
|
||||||
* Use the specify method to get the generator for that platform.
|
* Use the specify method to get the generator for that platform.
|
||||||
*/
|
*/
|
||||||
public abstract class IndependentPlotGenerator {
|
public abstract class IndependentPlotGenerator {
|
||||||
|
@ -7,7 +7,7 @@ import com.intellectualcrafters.plot.object.SetupObject;
|
|||||||
|
|
||||||
public abstract class PlotGenerator<T> {
|
public abstract class PlotGenerator<T> {
|
||||||
|
|
||||||
public T generator;
|
public final T generator;
|
||||||
|
|
||||||
public PlotGenerator(T generator) {
|
public PlotGenerator(T generator) {
|
||||||
this.generator = generator;
|
this.generator = generator;
|
||||||
|
@ -39,10 +39,6 @@ public class ConsolePlayer extends PlotPlayer {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isConsole(PlotPlayer plr) {
|
|
||||||
return plr instanceof ConsolePlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getPreviousLogin() {
|
public long getPreviousLogin() {
|
||||||
return 0;
|
return 0;
|
||||||
@ -133,7 +129,7 @@ public class ConsolePlayer extends PlotPlayer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlotGameMode getGameMode() {
|
public PlotGameMode getGameMode() {
|
||||||
return PlotGameMode.CREATIVE;
|
return PlotGameMode.NOT_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,11 +3,6 @@ package com.intellectualcrafters.plot.object;
|
|||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.util.MathMan;
|
import com.intellectualcrafters.plot.util.MathMan;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created 2015-02-11 for PlotSquared
|
|
||||||
*
|
|
||||||
|
|
||||||
*/
|
|
||||||
public class Location implements Cloneable, Comparable<Location> {
|
public class Location implements Cloneable, Comparable<Location> {
|
||||||
|
|
||||||
private int x;
|
private int x;
|
||||||
@ -27,7 +22,7 @@ public class Location implements Cloneable, Comparable<Location> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Location() {
|
public Location() {
|
||||||
this("", 0, 0, 0, 0, 0);
|
this.world = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location(String world, int x, int y, int z) {
|
public Location(String world, int x, int y, int z) {
|
||||||
|
@ -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;
|
||||||
|
@ -67,7 +67,7 @@ public abstract class PlotArea {
|
|||||||
public int MAX_BUILD_HEIGHT = 256;
|
public int MAX_BUILD_HEIGHT = 256;
|
||||||
public int MIN_BUILD_HEIGHT = 1;
|
public int MIN_BUILD_HEIGHT = 1;
|
||||||
public PlotGameMode GAMEMODE = PlotGameMode.CREATIVE;
|
public PlotGameMode GAMEMODE = PlotGameMode.CREATIVE;
|
||||||
int hash;
|
private int hash;
|
||||||
private RegionWrapper region;
|
private RegionWrapper region;
|
||||||
private ConcurrentHashMap<String, Object> meta;
|
private ConcurrentHashMap<String, Object> meta;
|
||||||
private QuadMap<PlotCluster> clusters;
|
private QuadMap<PlotCluster> clusters;
|
||||||
@ -91,7 +91,7 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PlotArea object with no functionality/information<br>
|
* Create a new PlotArea object with no functionality/information.
|
||||||
* - Mainly used during startup before worlds are created as a temporary object
|
* - Mainly used during startup before worlds are created as a temporary object
|
||||||
* @param world
|
* @param world
|
||||||
* @return
|
* @return
|
||||||
@ -106,8 +106,9 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the region for this PlotArea or a RegionWrapper encompassing the whole world if none exists
|
* Returns the region for this PlotArea or a RegionWrapper encompassing
|
||||||
* @NotNull
|
* the whole world if none exists.
|
||||||
|
*
|
||||||
* @return RegionWrapper
|
* @return RegionWrapper
|
||||||
*/
|
*/
|
||||||
public RegionWrapper getRegion() {
|
public RegionWrapper getRegion() {
|
||||||
@ -119,7 +120,7 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the region for this PlotArea
|
* Returns the region for this PlotArea.
|
||||||
*
|
*
|
||||||
* @return RegionWrapper or null if no applicable region
|
* @return RegionWrapper or null if no applicable region
|
||||||
*/
|
*/
|
||||||
@ -135,7 +136,7 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the min PlotId
|
* Returns the min PlotId.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public PlotId getMin() {
|
public PlotId getMin() {
|
||||||
@ -143,7 +144,7 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the max PlotId
|
* Returns the max PlotId.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public PlotId getMax() {
|
public PlotId getMax() {
|
||||||
@ -151,7 +152,7 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the implementation independent generator for this area
|
* Get the implementation independent generator for this area.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -179,14 +180,14 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a PlotArea is compatible (move/copy etc)
|
* Check if a PlotArea is compatible (move/copy etc).
|
||||||
* @param plotarea
|
* @param plotArea
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isCompatible(PlotArea plotarea) {
|
public boolean isCompatible(PlotArea plotArea) {
|
||||||
ConfigurationSection section = PS.get().config.getConfigurationSection("worlds");
|
ConfigurationSection section = PS.get().config.getConfigurationSection("worlds");
|
||||||
for (ConfigurationNode setting : plotarea.getSettingNodes()) {
|
for (ConfigurationNode setting : plotArea.getSettingNodes()) {
|
||||||
Object constant = section.get(plotarea.worldname + "." + setting.getConstant());
|
Object constant = section.get(plotArea.worldname + "." + setting.getConstant());
|
||||||
if (constant == null) {
|
if (constant == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -198,7 +199,7 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a world is created, the following method will be called for each
|
* When a world is created, the following method will be called for each.
|
||||||
*
|
*
|
||||||
* @param config Configuration Section
|
* @param config Configuration Section
|
||||||
*/
|
*/
|
||||||
@ -358,7 +359,11 @@ public abstract class PlotArea {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.id == null ? this.worldname : this.worldname + ";" + this.id;
|
if (this.id == null) {
|
||||||
|
return this.worldname;
|
||||||
|
} else {
|
||||||
|
return this.worldname + ";" + this.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,7 +17,7 @@ public class PlotId {
|
|||||||
* @param x The plot x coordinate
|
* @param x The plot x coordinate
|
||||||
* @param y The plot y coordinate
|
* @param y The plot y coordinate
|
||||||
*/
|
*/
|
||||||
public PlotId(final int x, final int y) {
|
public PlotId(int x, int y) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
@ -29,11 +29,11 @@ public class PlotId {
|
|||||||
*
|
*
|
||||||
* @return null if the string is invalid
|
* @return null if the string is invalid
|
||||||
*/
|
*/
|
||||||
public static PlotId fromString(final String string) {
|
public static PlotId fromString(String string) {
|
||||||
if (string == null) {
|
if (string == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final String[] parts = string.split(";");
|
String[] parts = string.split(";");
|
||||||
if (parts.length < 2) {
|
if (parts.length < 2) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ public class PlotId {
|
|||||||
try {
|
try {
|
||||||
x = Integer.parseInt(parts[0]);
|
x = Integer.parseInt(parts[0]);
|
||||||
y = Integer.parseInt(parts[1]);
|
y = Integer.parseInt(parts[1]);
|
||||||
} catch (final Exception e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new PlotId(x, y);
|
return new PlotId(x, y);
|
||||||
@ -67,7 +67,7 @@ public class PlotId {
|
|||||||
* @param direction
|
* @param direction
|
||||||
* @return PlotId
|
* @return PlotId
|
||||||
*/
|
*/
|
||||||
public PlotId getRelative(final int direction) {
|
public PlotId getRelative(int direction) {
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case 0:
|
case 0:
|
||||||
return new PlotId(this.x, this.y - 1);
|
return new PlotId(this.x, this.y - 1);
|
||||||
@ -92,7 +92,7 @@ public class PlotId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -105,8 +105,8 @@ public class PlotId {
|
|||||||
if (getClass() != obj.getClass()) {
|
if (getClass() != obj.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final PlotId other = (PlotId) obj;
|
PlotId other = (PlotId) obj;
|
||||||
return x == other.x && y == other.y;
|
return this.x == other.x && this.y == other.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,7 +116,7 @@ public class PlotId {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return x + ";" + y;
|
return this.x + ";" + this.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,15 +125,15 @@ public class PlotId {
|
|||||||
* TODO maybe make x/y values private and add this to the mutators
|
* TODO maybe make x/y values private and add this to the mutators
|
||||||
*/
|
*/
|
||||||
public void recalculateHash() {
|
public void recalculateHash() {
|
||||||
hash = 0;
|
this.hash = 0;
|
||||||
hashCode();
|
hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
if (hash == 0) {
|
if (this.hash == 0) {
|
||||||
hash = (x << 16) | (y & 0xFFFF);
|
this.hash = (this.x << 16) | (this.y & 0xFFFF);
|
||||||
}
|
}
|
||||||
return hash;
|
return this.hash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,27 +4,27 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,49 +11,49 @@ public class 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;
|
package com.intellectualcrafters.plot.object;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||||
@ -151,17 +152,17 @@ public class PlotSettings {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<PlotComment> getComments(String inbox) {
|
public Optional<ArrayList<PlotComment>> getComments(String inbox) {
|
||||||
ArrayList<PlotComment> c = new ArrayList<>();
|
ArrayList<PlotComment> c = new ArrayList<>();
|
||||||
if (this.comments == null) {
|
if (this.comments == null) {
|
||||||
return null;
|
return Optional.absent();
|
||||||
}
|
}
|
||||||
for (PlotComment comment : this.comments) {
|
for (PlotComment comment : this.comments) {
|
||||||
if (comment.inbox.equals(inbox)) {
|
if (comment.inbox.equals(inbox)) {
|
||||||
c.add(comment);
|
c.add(comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return c;
|
return Optional.of(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setComments(List<PlotComment> comments) {
|
public void setComments(List<PlotComment> comments) {
|
||||||
|
@ -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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.intellectualcrafters.plot.object.comment;
|
package com.intellectualcrafters.plot.object.comment;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
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;
|
||||||
@ -14,13 +15,12 @@ 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
|
||||||
@ -29,30 +29,24 @@ public class InboxOwner extends CommentInbox {
|
|||||||
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 whenDone) {
|
public boolean getComments(final Plot plot, final RunnableVal<List<PlotComment>> whenDone) {
|
||||||
if ((plot == null) || (plot.owner == null)) {
|
Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(toString());
|
||||||
return false;
|
if (comments.isPresent()) {
|
||||||
}
|
whenDone.value = comments.get();
|
||||||
ArrayList<PlotComment> comments = plot.getSettings().getComments(toString());
|
|
||||||
if (comments != null) {
|
|
||||||
whenDone.value = comments;
|
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -75,7 +69,7 @@ public class InboxOwner extends CommentInbox {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addComment(Plot plot, PlotComment comment) {
|
public boolean addComment(Plot plot, PlotComment comment) {
|
||||||
if ((plot == null) || (plot.owner == null)) {
|
if (plot.owner == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
plot.getSettings().addComment(comment);
|
plot.getSettings().addComment(comment);
|
||||||
@ -88,21 +82,4 @@ public class InboxOwner extends CommentInbox {
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.intellectualcrafters.plot.object.comment;
|
package com.intellectualcrafters.plot.object.comment;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
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;
|
||||||
@ -14,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
|
||||||
@ -34,21 +34,19 @@ 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 whenDone) {
|
public boolean getComments(final Plot plot, final RunnableVal<List<PlotComment>> whenDone) {
|
||||||
if ((plot == null) || (plot.owner == null)) {
|
Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(toString());
|
||||||
return false;
|
if (comments.isPresent()) {
|
||||||
}
|
whenDone.value = comments.get();
|
||||||
ArrayList<PlotComment> comments = plot.getSettings().getComments(toString());
|
|
||||||
if (comments != null) {
|
|
||||||
whenDone.value = comments;
|
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -69,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 == null) || (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,21 +77,5 @@ public class InboxPublic extends CommentInbox {
|
|||||||
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,15 +33,16 @@ 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
|
||||||
public boolean getComments(Plot plot, final RunnableVal whenDone) {
|
public boolean getComments(Plot plot, final RunnableVal<List<PlotComment>> whenDone) {
|
||||||
DBFunc.getComments(null, toString(), new RunnableVal<List<PlotComment>>() {
|
DBFunc.getComments(null, toString(), new RunnableVal<List<PlotComment>>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(List<PlotComment> value) {
|
public void run(List<PlotComment> value) {
|
||||||
@ -52,7 +55,7 @@ public class InboxReport extends CommentInbox {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addComment(Plot plot, PlotComment comment) {
|
public boolean addComment(Plot plot, PlotComment comment) {
|
||||||
if ((plot == null) || (plot.owner == null)) {
|
if (plot.owner == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DBFunc.setComment(plot, comment);
|
DBFunc.setComment(plot, comment);
|
||||||
@ -64,21 +67,4 @@ public class InboxReport extends CommentInbox {
|
|||||||
return "report";
|
return "report";
|
||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -7,7 +7,7 @@ public abstract class AbstractTitle {
|
|||||||
public static AbstractTitle TITLE_CLASS;
|
public static AbstractTitle TITLE_CLASS;
|
||||||
|
|
||||||
public static void sendTitle(PlotPlayer player, String head, String sub) {
|
public static void sendTitle(PlotPlayer player, String head, String sub) {
|
||||||
if (ConsolePlayer.isConsole(player)) {
|
if (player instanceof ConsolePlayer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (TITLE_CLASS != null && !player.getAttribute("disabletitles")) {
|
if (TITLE_CLASS != null && !player.getAttribute("disabletitles")) {
|
||||||
|
@ -8,15 +8,15 @@ public abstract class ChatManager<T> {
|
|||||||
|
|
||||||
public abstract T builder();
|
public abstract T builder();
|
||||||
|
|
||||||
public abstract void color(final PlotMessage message, final String color);
|
public abstract void color(PlotMessage message, String color);
|
||||||
|
|
||||||
public abstract void tooltip(final PlotMessage message, final PlotMessage... tooltip);
|
public abstract void tooltip(PlotMessage message, PlotMessage... tooltip);
|
||||||
|
|
||||||
public abstract void command(final PlotMessage message, final String command);
|
public abstract void command(PlotMessage message, String command);
|
||||||
|
|
||||||
public abstract void text(final PlotMessage message, final String text);
|
public abstract void text(PlotMessage message, String text);
|
||||||
|
|
||||||
public abstract void send(final PlotMessage plotMessage, final PlotPlayer player);
|
public abstract void send(PlotMessage plotMessage, PlotPlayer player);
|
||||||
|
|
||||||
public abstract void suggest(final PlotMessage plotMessage, final String command);
|
public abstract void suggest(PlotMessage plotMessage, String command);
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,13 @@ package com.intellectualcrafters.plot.util;
|
|||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
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.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -114,7 +114,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;
|
||||||
}
|
}
|
||||||
@ -254,7 +254,7 @@ public abstract class ChunkManager {
|
|||||||
for (ChunkLoc loc : chunks) {
|
for (ChunkLoc loc : chunks) {
|
||||||
String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca";
|
String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca";
|
||||||
File file = new File(PS.get().IMP.getWorldContainer(), directory);
|
File file = new File(PS.get().IMP.getWorldContainer(), directory);
|
||||||
ConsolePlayer.getConsole().sendMessage("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
|
PS.log("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
|
@ -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())) {
|
||||||
|
@ -19,7 +19,7 @@ public abstract class EconHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public double getMoney(PlotPlayer player) {
|
public double getMoney(PlotPlayer player) {
|
||||||
if (ConsolePlayer.isConsole(player)) {
|
if (player instanceof ConsolePlayer) {
|
||||||
return Double.MAX_VALUE;
|
return Double.MAX_VALUE;
|
||||||
}
|
}
|
||||||
return getBalance(player);
|
return getBalance(player);
|
||||||
|
@ -15,6 +15,7 @@ import com.intellectualcrafters.plot.object.PlotId;
|
|||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.Rating;
|
import com.intellectualcrafters.plot.object.Rating;
|
||||||
import com.plotsquared.listener.PlayerBlockEventType;
|
import com.plotsquared.listener.PlayerBlockEventType;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -36,6 +36,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -601,7 +602,8 @@ public class MainUtil {
|
|||||||
public static boolean sendMessage(PlotPlayer player, String msg, boolean prefix) {
|
public static boolean sendMessage(PlotPlayer player, String msg, boolean prefix) {
|
||||||
if (!msg.isEmpty()) {
|
if (!msg.isEmpty()) {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
ConsolePlayer.getConsole().sendMessage((prefix ? C.PREFIX.s() : "") + msg);
|
String message = (prefix ? C.PREFIX.s() : "") + msg;
|
||||||
|
PS.log(message);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage((prefix ? C.PREFIX.s() : "") + C.color(msg));
|
player.sendMessage((prefix ? C.PREFIX.s() : "") + C.color(msg));
|
||||||
}
|
}
|
||||||
@ -638,7 +640,7 @@ public class MainUtil {
|
|||||||
public void run() {
|
public void run() {
|
||||||
String m = C.format(c, args);
|
String m = C.format(c, args);
|
||||||
if (plr == null) {
|
if (plr == null) {
|
||||||
ConsolePlayer.getConsole().sendMessage(m);
|
PS.log(m);
|
||||||
} else {
|
} else {
|
||||||
plr.sendMessage(m);
|
plr.sendMessage(m);
|
||||||
}
|
}
|
||||||
@ -703,7 +705,32 @@ public class MainUtil {
|
|||||||
String trusted = getPlayerList(plot.getTrusted());
|
String trusted = getPlayerList(plot.getTrusted());
|
||||||
String members = getPlayerList(plot.getMembers());
|
String members = getPlayerList(plot.getMembers());
|
||||||
String denied = getPlayerList(plot.getDenied());
|
String denied = getPlayerList(plot.getDenied());
|
||||||
|
String expires = C.UNKNOWN.s();
|
||||||
|
if (Settings.AUTO_CLEAR) {
|
||||||
|
if (plot.hasOwner()) {
|
||||||
|
Flag keep = plot.getFlag("keep");
|
||||||
|
if (keep != null) {
|
||||||
|
Object value = keep.getValue();
|
||||||
|
if (value instanceof Boolean) {
|
||||||
|
if (Boolean.TRUE.equals(value)) {
|
||||||
|
expires = C.NONE.s();
|
||||||
|
}
|
||||||
|
} else if (value instanceof Long) {
|
||||||
|
if ((Long) value > System.currentTimeMillis()) {
|
||||||
|
long l = System.currentTimeMillis() - (long) value;
|
||||||
|
expires = String.format("%d days", TimeUnit.MILLISECONDS.toDays(l));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
long timestamp = ExpireManager.IMP.getTimestamp(plot.owner);
|
||||||
|
long compared = System.currentTimeMillis() - timestamp;
|
||||||
|
long l = Settings.AUTO_CLEAR_DAYS - TimeUnit.MILLISECONDS.toDays(compared);
|
||||||
|
expires = String.format("%d days", l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
expires = C.NEVER.s();
|
||||||
|
}
|
||||||
Flag descriptionFlag = FlagManager.getPlotFlagRaw(plot, "description");
|
Flag descriptionFlag = FlagManager.getPlotFlagRaw(plot, "description");
|
||||||
String description = descriptionFlag == null ? C.NONE.s() : descriptionFlag.getValueString();
|
String description = descriptionFlag == null ? C.NONE.s() : descriptionFlag.getValueString();
|
||||||
|
|
||||||
@ -729,6 +756,7 @@ public class MainUtil {
|
|||||||
info = info.replaceAll("%trusted%", trusted);
|
info = info.replaceAll("%trusted%", trusted);
|
||||||
info = info.replaceAll("%helpers%", members);
|
info = info.replaceAll("%helpers%", members);
|
||||||
info = info.replaceAll("%denied%", denied);
|
info = info.replaceAll("%denied%", denied);
|
||||||
|
info = info.replaceAll("%expires%", expires);
|
||||||
info = info.replaceAll("%flags%", Matcher.quoteReplacement(flags));
|
info = info.replaceAll("%flags%", Matcher.quoteReplacement(flags));
|
||||||
info = info.replaceAll("%build%", build + "");
|
info = info.replaceAll("%build%", build + "");
|
||||||
info = info.replaceAll("%desc%", "No description set.");
|
info = info.replaceAll("%desc%", "No description set.");
|
||||||
@ -746,6 +774,10 @@ public class MainUtil {
|
|||||||
String rating = "";
|
String rating = "";
|
||||||
String prefix = "";
|
String prefix = "";
|
||||||
double[] ratings = MainUtil.getAverageRatings(plot);
|
double[] ratings = MainUtil.getAverageRatings(plot);
|
||||||
|
for (double v : ratings) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < ratings.length; i++) {
|
for (int i = 0; i < ratings.length; i++) {
|
||||||
rating += prefix + Settings.RATING_CATEGORIES.get(i) + "=" + String.format("%.1f", ratings[i]);
|
rating += prefix + Settings.RATING_CATEGORIES.get(i) + "=" + String.format("%.1f", ratings[i]);
|
||||||
prefix = ",";
|
prefix = ",";
|
||||||
|
@ -24,6 +24,7 @@ import com.intellectualcrafters.plot.object.PlotArea;
|
|||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -705,7 +706,7 @@ public abstract class SchematicHandler {
|
|||||||
* @return Map of block location to tag
|
* @return Map of block location to tag
|
||||||
*/
|
*/
|
||||||
public HashMap<BlockLoc, CompoundTag> getTiles() {
|
public HashMap<BlockLoc, CompoundTag> getTiles() {
|
||||||
return this.tiles == null ? new HashMap<BlockLoc, CompoundTag>() : tiles;
|
return this.tiles == null ? new HashMap<BlockLoc, CompoundTag>() : this.tiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,6 +2,7 @@ package com.intellectualcrafters.plot.util;
|
|||||||
|
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
@ -150,7 +151,7 @@ public class SetQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void regenerateChunk(String world, ChunkLoc loc) {
|
public void regenerateChunk(String world, ChunkLoc loc) {
|
||||||
queue.regenerateChunk(world, loc);
|
this.queue.regenerateChunk(world, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ChunkWrapper {
|
public class ChunkWrapper {
|
||||||
|
@ -11,10 +11,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
public abstract class TaskManager {
|
public abstract class TaskManager {
|
||||||
|
|
||||||
public static HashSet<String> TELEPORT_QUEUE = new HashSet<>();
|
public static final HashSet<String> TELEPORT_QUEUE = new HashSet<>();
|
||||||
|
public static final HashMap<Integer, Integer> tasks = new HashMap<>();
|
||||||
public static AtomicInteger index = new AtomicInteger(0);
|
public static AtomicInteger index = new AtomicInteger(0);
|
||||||
public static HashMap<Integer, Integer> tasks = new HashMap<>();
|
|
||||||
|
|
||||||
public static int runTaskRepeat(Runnable runnable, int interval) {
|
public static int runTaskRepeat(Runnable runnable, int interval) {
|
||||||
if (runnable != null) {
|
if (runnable != null) {
|
||||||
|
@ -7,7 +7,6 @@ import com.intellectualcrafters.plot.PS;
|
|||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
|
||||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
@ -25,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 UUIDWrapper uuidWrapper = null;
|
public final HashSet<UUID> unknown = new HashSet<>();
|
||||||
public HashSet<UUID> unknown = new HashSet<>();
|
public UUIDWrapper uuidWrapper;
|
||||||
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>());
|
||||||
|
|
||||||
@ -97,7 +96,7 @@ public abstract class UUIDHandlerImplementation {
|
|||||||
try {
|
try {
|
||||||
this.unknown.add(uuid);
|
this.unknown.add(uuid);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ConsolePlayer.getConsole().sendMessage("&c(minor) Invalid UUID mapping: " + uuid);
|
PS.log("&c(minor) Invalid UUID mapping: " + uuid);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -182,7 +181,6 @@ public abstract class UUIDHandlerImplementation {
|
|||||||
public void handleShutdown() {
|
public void handleShutdown() {
|
||||||
this.players.clear();
|
this.players.clear();
|
||||||
this.uuidMap.clear();
|
this.uuidMap.clear();
|
||||||
this.uuidWrapper = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName(UUID uuid) {
|
public String getName(UUID uuid) {
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
package com.plotsquared.general.commands;
|
package com.plotsquared.general.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotArea;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
|
||||||
|
|
||||||
public abstract class Argument<T> {
|
public abstract class Argument<T> {
|
||||||
|
|
||||||
@ -37,24 +33,18 @@ public abstract class Argument<T> {
|
|||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static Argument<String> PlayerName = new Argument<String>("PlayerName", "Dinnerbone") {
|
public static final Argument<String> PlayerName = new Argument<String>("PlayerName", "Dinnerbone") {
|
||||||
@Override
|
@Override
|
||||||
public String parse(String in) {
|
public String parse(String in) {
|
||||||
return in.length() <= 16 ? in : null;
|
return in.length() <= 16 ? in : null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static Argument<PlotId> PlotID = new Argument<PlotId>("PlotID", new PlotId(-6, 3)) {
|
public static final Argument<PlotId> PlotID = new Argument<PlotId>("PlotID", new PlotId(-6, 3)) {
|
||||||
@Override
|
@Override
|
||||||
public PlotId parse(String in) {
|
public PlotId parse(String in) {
|
||||||
return PlotId.fromString(in);
|
return PlotId.fromString(in);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static Argument<Plot> Plot = new Argument<Plot>("Plot", new Plot(PlotArea.createGeneric("world"), new PlotId(3, -6), null)) {
|
|
||||||
@Override
|
|
||||||
public Plot parse(String in) {
|
|
||||||
return MainUtil.getPlotFromString(ConsolePlayer.getConsole(), in, false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final T example;
|
private final T example;
|
||||||
|
|
||||||
|
@ -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("[");
|
||||||
@ -477,7 +477,7 @@ public abstract class Command {
|
|||||||
return getCommandString() + " " + args + "]";
|
return getCommandString() + " " + args + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection tab(PlotPlayer player, String[] args, boolean space) {
|
public Collection<Command> tab(PlotPlayer player, String[] args, boolean space) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
return this.allCommands;
|
return this.allCommands;
|
||||||
@ -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
|
||||||
|
@ -64,6 +64,7 @@ import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
|
|||||||
import org.spongepowered.api.plugin.Plugin;
|
import org.spongepowered.api.plugin.Plugin;
|
||||||
import org.spongepowered.api.plugin.PluginContainer;
|
import org.spongepowered.api.plugin.PluginContainer;
|
||||||
import org.spongepowered.api.profile.GameProfileManager;
|
import org.spongepowered.api.profile.GameProfileManager;
|
||||||
|
import org.spongepowered.api.world.Chunk;
|
||||||
import org.spongepowered.api.world.World;
|
import org.spongepowered.api.world.World;
|
||||||
import org.spongepowered.api.world.gen.GenerationPopulator;
|
import org.spongepowered.api.world.gen.GenerationPopulator;
|
||||||
import org.spongepowered.api.world.gen.WorldGenerator;
|
import org.spongepowered.api.world.gen.WorldGenerator;
|
||||||
@ -165,7 +166,7 @@ public class SpongeMain implements IPlotMain {
|
|||||||
@Override
|
@Override
|
||||||
public int[] getPluginVersion() {
|
public int[] getPluginVersion() {
|
||||||
PluginContainer plugin = this.game.getPluginManager().fromInstance(this).get();
|
PluginContainer plugin = this.game.getPluginManager().fromInstance(this).get();
|
||||||
String version = plugin.getVersion().get();
|
String version = plugin.getVersion().orElse("");
|
||||||
String[] split = version.split("\\.");
|
String[] split = version.split("\\.");
|
||||||
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), split.length == 3 ? Integer.parseInt(split[2]) : 0};
|
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), split.length == 3 ? Integer.parseInt(split[2]) : 0};
|
||||||
}
|
}
|
||||||
@ -217,7 +218,7 @@ public class SpongeMain implements IPlotMain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskManager getTaskManager() {
|
public TaskManager getTaskManager() {
|
||||||
return new SpongeTaskManager();
|
return new SpongeTaskManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -370,7 +371,7 @@ public class SpongeMain implements IPlotMain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlotQueue initPlotQueue() {
|
public PlotQueue<Chunk> initPlotQueue() {
|
||||||
if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) {
|
if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) {
|
||||||
try {
|
try {
|
||||||
MainUtil.canSendChunk = true;
|
MainUtil.canSendChunk = true;
|
||||||
|
@ -286,7 +286,7 @@ public class MainListener {
|
|||||||
|
|
||||||
public void onNotifyNeighborBlock(NotifyNeighborBlockEvent event) throws Exception {
|
public void onNotifyNeighborBlock(NotifyNeighborBlockEvent event) throws Exception {
|
||||||
AtomicBoolean cancelled = new AtomicBoolean(false);
|
AtomicBoolean cancelled = new AtomicBoolean(false);
|
||||||
// SpongeUtil.printCause("physics", event.getCause());
|
// SpongeUtil.printCause("physics", event.getCause());
|
||||||
// PlotArea area = plotloc.getPlotArea();
|
// PlotArea area = plotloc.getPlotArea();
|
||||||
// event.filterDirections(new Predicate<Direction>() {
|
// event.filterDirections(new Predicate<Direction>() {
|
||||||
//
|
//
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public class SpongeChatManager extends ChatManager<Text.Builder> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void color(final PlotMessage m, final String color) {
|
public void color(PlotMessage m, String color) {
|
||||||
TextColor tc = null;
|
TextColor tc = null;
|
||||||
TextStyle ts = null;
|
TextStyle ts = null;
|
||||||
switch (color.charAt(1)) {
|
switch (color.charAt(1)) {
|
||||||
@ -114,10 +114,10 @@ public class SpongeChatManager extends ChatManager<Text.Builder> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tooltip(final PlotMessage m, final PlotMessage... tooltips) {
|
public void tooltip(PlotMessage m, PlotMessage... tooltips) {
|
||||||
final Text.Builder builder = Text.builder();
|
Text.Builder builder = Text.builder();
|
||||||
boolean lb = false;
|
boolean lb = false;
|
||||||
for (final PlotMessage tooltip : tooltips) {
|
for (PlotMessage tooltip : tooltips) {
|
||||||
if (lb) {
|
if (lb) {
|
||||||
builder.append(Text.of("\n"));
|
builder.append(Text.of("\n"));
|
||||||
}
|
}
|
||||||
@ -128,18 +128,18 @@ public class SpongeChatManager extends ChatManager<Text.Builder> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void command(final PlotMessage m, final String command) {
|
public void command(PlotMessage m, String command) {
|
||||||
apply(m, getChild(m).onClick(TextActions.runCommand(command)));
|
apply(m, getChild(m).onClick(TextActions.runCommand(command)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void text(final PlotMessage m, final String text) {
|
public void text(PlotMessage m, String text) {
|
||||||
m.$(this).append(SpongeUtil.getText(text));
|
m.$(this).append(SpongeUtil.getText(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void send(final PlotMessage m, final PlotPlayer player) {
|
public void send(PlotMessage m, PlotPlayer player) {
|
||||||
if (ConsolePlayer.isConsole(player)) {
|
if (player instanceof ConsolePlayer) {
|
||||||
player.sendMessage(m.$(this).build().toPlain());
|
player.sendMessage(m.$(this).build().toPlain());
|
||||||
} else {
|
} else {
|
||||||
((SpongePlayer) player).player.sendMessage(m.$(this).build());
|
((SpongePlayer) player).player.sendMessage(m.$(this).build());
|
||||||
@ -147,7 +147,7 @@ public class SpongeChatManager extends ChatManager<Text.Builder> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void suggest(final PlotMessage m, final String command) {
|
public void suggest(PlotMessage m, String command) {
|
||||||
apply(m, getChild(m).onClick(TextActions.suggestCommand(command)));
|
apply(m, getChild(m).onClick(TextActions.suggestCommand(command)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,6 @@ import com.intellectualcrafters.plot.object.Location;
|
|||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
import org.spongepowered.api.entity.Entity;
|
import org.spongepowered.api.entity.Entity;
|
||||||
import org.spongepowered.api.entity.living.Living;
|
import org.spongepowered.api.entity.living.Living;
|
||||||
import org.spongepowered.api.entity.living.animal.Animal;
|
import org.spongepowered.api.entity.living.animal.Animal;
|
||||||
@ -15,6 +12,10 @@ import org.spongepowered.api.entity.living.monster.Monster;
|
|||||||
import org.spongepowered.api.world.Chunk;
|
import org.spongepowered.api.world.Chunk;
|
||||||
import org.spongepowered.api.world.World;
|
import org.spongepowered.api.world.World;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class SpongeChunkManager extends ChunkManager {
|
public class SpongeChunkManager extends ChunkManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -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>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,25 +36,25 @@ public class SpongeEventUtil extends EventUtil {
|
|||||||
public EventManager events;
|
public EventManager events;
|
||||||
|
|
||||||
public SpongeEventUtil() {
|
public SpongeEventUtil() {
|
||||||
events = SpongeMain.THIS.getGame().getEventManager();
|
this.events = SpongeMain.THIS.getGame().getEventManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean callEvent(final Event event) {
|
public boolean callEvent(Event event) {
|
||||||
return !events.post(event);
|
return !this.events.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean callClaim(final PlotPlayer player, final Plot plot, final boolean auto) {
|
public boolean callClaim(PlotPlayer player, Plot plot, boolean auto) {
|
||||||
return callEvent(new PlayerClaimPlotEvent(SpongeUtil.getPlayer(player), plot, auto));
|
return callEvent(new PlayerClaimPlotEvent(SpongeUtil.getPlayer(player), plot, auto));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean callTeleport(final PlotPlayer player, final Location from, final Plot plot) {
|
public boolean callTeleport(PlotPlayer player, Location from, Plot plot) {
|
||||||
return callEvent(new PlayerTeleportToPlotEvent(SpongeUtil.getPlayer(player), from, plot));
|
return callEvent(new PlayerTeleportToPlotEvent(SpongeUtil.getPlayer(player), from, plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean callClear(final Plot plot) {
|
public boolean callClear(Plot plot) {
|
||||||
return callEvent(new PlotClearEvent(plot));
|
return callEvent(new PlotClearEvent(plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,59 +64,59 @@ public class SpongeEventUtil extends EventUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean callFlagAdd(final Flag flag, final Plot plot) {
|
public boolean callFlagAdd(Flag flag, Plot plot) {
|
||||||
return callEvent(new PlotFlagAddEvent(flag, plot));
|
return callEvent(new PlotFlagAddEvent(flag, plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean callFlagRemove(final Flag flag, final Plot plot) {
|
public boolean callFlagRemove(Flag flag, Plot plot) {
|
||||||
return callEvent(new PlotFlagRemoveEvent(flag, plot));
|
return callEvent(new PlotFlagRemoveEvent(flag, plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean callMerge(final Plot plot, final ArrayList<PlotId> plots) {
|
public boolean callMerge(Plot plot, ArrayList<PlotId> plots) {
|
||||||
return callEvent(new PlotMergeEvent(SpongeUtil.getWorld(plot.getArea().worldname), plot, plots));
|
return callEvent(new PlotMergeEvent(SpongeUtil.getWorld(plot.getArea().worldname), plot, plots));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean callUnlink(final PlotArea area, final ArrayList<PlotId> plots) {
|
public boolean callUnlink(PlotArea area, ArrayList<PlotId> plots) {
|
||||||
return callEvent(new PlotUnlinkEvent(SpongeUtil.getWorld(area.worldname), plots));
|
return callEvent(new PlotUnlinkEvent(SpongeUtil.getWorld(area.worldname), plots));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void callEntry(final PlotPlayer player, final Plot plot) {
|
public void callEntry(PlotPlayer player, Plot plot) {
|
||||||
callEvent(new PlayerEnterPlotEvent(SpongeUtil.getPlayer(player), plot));
|
callEvent(new PlayerEnterPlotEvent(SpongeUtil.getPlayer(player), plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void callLeave(final PlotPlayer player, final Plot plot) {
|
public void callLeave(PlotPlayer player, Plot plot) {
|
||||||
callEvent(new PlayerLeavePlotEvent(SpongeUtil.getPlayer(player), plot));
|
callEvent(new PlayerLeavePlotEvent(SpongeUtil.getPlayer(player), plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void callDenied(final PlotPlayer initiator, final Plot plot, final UUID player, final boolean added) {
|
public void callDenied(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||||
callEvent(new PlayerPlotDeniedEvent(SpongeUtil.getPlayer(initiator), plot, player, added));
|
callEvent(new PlayerPlotDeniedEvent(SpongeUtil.getPlayer(initiator), plot, player, added));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void callTrusted(final PlotPlayer initiator, final Plot plot, final UUID player, final boolean added) {
|
public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||||
callEvent(new PlayerPlotHelperEvent(SpongeUtil.getPlayer(initiator), plot, player, added));
|
callEvent(new PlayerPlotHelperEvent(SpongeUtil.getPlayer(initiator), plot, player, added));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void callMember(final PlotPlayer initiator, final Plot plot, final UUID player, final boolean added) {
|
public void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||||
callEvent(new PlayerPlotTrustedEvent(SpongeUtil.getPlayer(initiator), plot, player, added));
|
callEvent(new PlayerPlotTrustedEvent(SpongeUtil.getPlayer(initiator), plot, player, added));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean callFlagRemove(final Flag flag, final PlotCluster cluster) {
|
public boolean callFlagRemove(Flag flag, PlotCluster cluster) {
|
||||||
return callEvent(new ClusterFlagRemoveEvent(flag, cluster));
|
return callEvent(new ClusterFlagRemoveEvent(flag, cluster));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Rating callRating(final PlotPlayer player, final Plot plot, final Rating rating) {
|
public Rating callRating(PlotPlayer player, Plot plot, Rating rating) {
|
||||||
final PlotRateEvent event = new PlotRateEvent(player, rating, plot);
|
PlotRateEvent event = new PlotRateEvent(player, rating, plot);
|
||||||
events.post(event);
|
this.events.post(event);
|
||||||
return event.getRating();
|
return event.getRating();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,13 +12,18 @@ public class SpongeTaskManager extends TaskManager {
|
|||||||
private final AtomicInteger i = new AtomicInteger();
|
private final AtomicInteger i = new AtomicInteger();
|
||||||
|
|
||||||
private final HashMap<Integer, Task> tasks = new HashMap<>();
|
private final HashMap<Integer, Task> tasks = new HashMap<>();
|
||||||
|
private final SpongeMain spongeMain;
|
||||||
|
|
||||||
|
public SpongeTaskManager(SpongeMain spongeMain) {
|
||||||
|
this.spongeMain = spongeMain;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int taskRepeat(Runnable runnable, int interval) {
|
public int taskRepeat(Runnable runnable, int interval) {
|
||||||
int val = this.i.incrementAndGet();
|
int val = this.i.incrementAndGet();
|
||||||
Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
Task.Builder builder = this.spongeMain.getGame().getScheduler().createTaskBuilder();
|
||||||
Task.Builder built = builder.delayTicks(interval).intervalTicks(interval).execute(runnable);
|
Task.Builder built = builder.delayTicks(interval).intervalTicks(interval).execute(runnable);
|
||||||
Task task = built.submit(SpongeMain.THIS.getPlugin());
|
Task task = built.submit(this.spongeMain.getPlugin());
|
||||||
this.tasks.put(val, task);
|
this.tasks.put(val, task);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@ -26,35 +31,35 @@ public class SpongeTaskManager extends TaskManager {
|
|||||||
@Override
|
@Override
|
||||||
public int taskRepeatAsync(Runnable runnable, int interval) {
|
public int taskRepeatAsync(Runnable runnable, int interval) {
|
||||||
int val = this.i.incrementAndGet();
|
int val = this.i.incrementAndGet();
|
||||||
Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
Task.Builder builder = this.spongeMain.getGame().getScheduler().createTaskBuilder();
|
||||||
Task.Builder built = builder.delayTicks(interval).async().intervalTicks(interval).execute(runnable);
|
Task.Builder built = builder.delayTicks(interval).async().intervalTicks(interval).execute(runnable);
|
||||||
Task task = built.submit(SpongeMain.THIS.getPlugin());
|
Task task = built.submit(this.spongeMain.getPlugin());
|
||||||
this.tasks.put(val, task);
|
this.tasks.put(val, task);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void taskAsync(Runnable runnable) {
|
public void taskAsync(Runnable runnable) {
|
||||||
Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
Task.Builder builder = this.spongeMain.getGame().getScheduler().createTaskBuilder();
|
||||||
builder.async().execute(runnable).submit(SpongeMain.THIS.getPlugin());
|
builder.async().execute(runnable).submit(this.spongeMain.getPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void task(Runnable runnable) {
|
public void task(Runnable runnable) {
|
||||||
Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
Task.Builder builder = this.spongeMain.getGame().getScheduler().createTaskBuilder();
|
||||||
builder.execute(runnable).submit(SpongeMain.THIS.getPlugin());
|
builder.execute(runnable).submit(this.spongeMain.getPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void taskLater(Runnable runnable, int delay) {
|
public void taskLater(Runnable runnable, int delay) {
|
||||||
Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
Task.Builder builder = this.spongeMain.getGame().getScheduler().createTaskBuilder();
|
||||||
builder.delayTicks(delay).execute(runnable).submit(SpongeMain.THIS.getPlugin());
|
builder.delayTicks(delay).execute(runnable).submit(this.spongeMain.getPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void taskLaterAsync(Runnable runnable, int delay) {
|
public void taskLaterAsync(Runnable runnable, int delay) {
|
||||||
Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
Task.Builder builder = this.spongeMain.getGame().getScheduler().createTaskBuilder();
|
||||||
builder.async().delayTicks(delay).execute(runnable).submit(SpongeMain.THIS.getPlugin());
|
builder.async().delayTicks(delay).execute(runnable).submit(this.spongeMain.getPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,13 +17,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
|||||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||||
import com.plotsquared.sponge.SpongeMain;
|
import com.plotsquared.sponge.SpongeMain;
|
||||||
import com.plotsquared.sponge.object.SpongePlayer;
|
import com.plotsquared.sponge.object.SpongePlayer;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Optional;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.world.biome.BiomeGenBase;
|
import net.minecraft.world.biome.BiomeGenBase;
|
||||||
import org.apache.commons.lang3.NotImplementedException;
|
import org.apache.commons.lang3.NotImplementedException;
|
||||||
@ -49,6 +42,14 @@ import org.spongepowered.api.world.biome.BiomeType;
|
|||||||
import org.spongepowered.api.world.biome.BiomeTypes;
|
import org.spongepowered.api.world.biome.BiomeTypes;
|
||||||
import org.spongepowered.api.world.extent.Extent;
|
import org.spongepowered.api.world.extent.Extent;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class SpongeUtil extends WorldUtil {
|
public class SpongeUtil extends WorldUtil {
|
||||||
|
|
||||||
public static Cause CAUSE = Cause.of(NamedCause.source("PlotSquared"));
|
public static Cause CAUSE = Cause.of(NamedCause.source("PlotSquared"));
|
||||||
|
@ -10,17 +10,17 @@ import com.intellectualcrafters.plot.util.PlotQueue;
|
|||||||
import com.intellectualcrafters.plot.util.SetQueue;
|
import com.intellectualcrafters.plot.util.SetQueue;
|
||||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||||
import com.plotsquared.sponge.util.SpongeUtil;
|
import com.plotsquared.sponge.util.SpongeUtil;
|
||||||
import java.util.Optional;
|
|
||||||
import net.minecraft.world.chunk.IChunkProvider;
|
import net.minecraft.world.chunk.IChunkProvider;
|
||||||
import net.minecraft.world.gen.ChunkProviderServer;
|
import net.minecraft.world.gen.ChunkProviderServer;
|
||||||
import org.spongepowered.api.block.BlockState;
|
import org.spongepowered.api.block.BlockState;
|
||||||
import org.spongepowered.api.world.Chunk;
|
import org.spongepowered.api.world.Chunk;
|
||||||
|
import org.spongepowered.api.world.World;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import org.spongepowered.api.world.World;
|
|
||||||
|
|
||||||
public class SlowQueue implements PlotQueue<Chunk> {
|
public class SlowQueue implements PlotQueue<Chunk> {
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ public class SlowQueue implements PlotQueue<Chunk> {
|
|||||||
else {
|
else {
|
||||||
PS.debug("CHUNK IS NULL!?");
|
PS.debug("CHUNK IS NULL!?");
|
||||||
}*/
|
}*/
|
||||||
} catch (Throwable e){
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,21 +13,21 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class SpongeUUIDHandler extends UUIDHandlerImplementation {
|
public class SpongeUUIDHandler extends UUIDHandlerImplementation {
|
||||||
|
|
||||||
public SpongeUUIDHandler(final UUIDWrapper wrapper) {
|
public SpongeUUIDHandler(UUIDWrapper wrapper) {
|
||||||
super(wrapper);
|
super(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean startCaching(final Runnable whenDone) {
|
public boolean startCaching(Runnable whenDone) {
|
||||||
if (!super.startCaching(whenDone)) {
|
if (!super.startCaching(whenDone)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return cache(whenDone);
|
return cache(whenDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean cache(final Runnable whenDone) {
|
public boolean cache(Runnable whenDone) {
|
||||||
add(new StringWrapper("*"), DBFunc.everyone);
|
add(new StringWrapper("*"), DBFunc.everyone);
|
||||||
for (final GameProfile profile : SpongeMain.THIS.getResolver().getCachedProfiles()) {
|
for (GameProfile profile : SpongeMain.THIS.getServer().getGameProfileManager().getCache().getProfiles()) {
|
||||||
String name = profile.getName().orElse(null);
|
String name = profile.getName().orElse(null);
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
add(new StringWrapper(name), profile.getUniqueId());
|
add(new StringWrapper(name), profile.getUniqueId());
|
||||||
@ -37,11 +37,11 @@ public class SpongeUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fetchUUID(final String name, final RunnableVal<UUID> ifFetch) {
|
public void fetchUUID(String name, RunnableVal<UUID> ifFetch) {
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ifFetch.value = uuidWrapper.getUUID(name);
|
ifFetch.value = SpongeUUIDHandler.this.uuidWrapper.getUUID(name);
|
||||||
TaskManager.runTask(ifFetch);
|
TaskManager.runTask(ifFetch);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user