mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
Optionals introduced, code cleaned, potential purge fix
This commit is contained in:
parent
3edfd39af9
commit
8243e0118a
@ -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;
|
||||||
@ -156,7 +157,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 +177,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 +212,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 +232,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 +257,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 +289,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 +315,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 +333,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 +393,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 +404,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 +416,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 +469,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 +639,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,12 +73,6 @@ 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.Location;
|
import org.bukkit.Location;
|
||||||
@ -93,6 +87,13 @@ 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 BukkitMain THIS;
|
||||||
@ -449,18 +450,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
|
||||||
|
@ -113,29 +113,22 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
|||||||
try {
|
try {
|
||||||
byte[] bytes = resultSet.getBytes(column);
|
byte[] bytes = resultSet.getBytes(column);
|
||||||
if (bytes != null) {
|
if (bytes != null) {
|
||||||
try {
|
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
long high = bb.getLong();
|
||||||
long high = bb.getLong();
|
long low = bb.getLong();
|
||||||
long low = bb.getLong();
|
owner = new UUID(high, low);
|
||||||
owner = new UUID(high, low);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
owner = UUID.nameUUIDFromBytes(bytes);
|
|
||||||
}
|
|
||||||
UUIDHandler.add(new StringWrapper(name), owner);
|
UUIDHandler.add(new StringWrapper(name), owner);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
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);
|
||||||
@ -183,15 +176,10 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
|||||||
try {
|
try {
|
||||||
byte[] bytes = resultSet.getBytes("playerid");
|
byte[] bytes = resultSet.getBytes("playerid");
|
||||||
if (bytes != null) {
|
if (bytes != null) {
|
||||||
try {
|
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
long mostSigBits = bb.getLong();
|
||||||
long high = bb.getLong();
|
long leastSigBits = bb.getLong();
|
||||||
long low = bb.getLong();
|
denied = new UUID(mostSigBits, leastSigBits);
|
||||||
denied = new UUID(high, low);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
denied = UUID.nameUUIDFromBytes(bytes);
|
|
||||||
}
|
|
||||||
UUIDHandler.add(new StringWrapper(name), denied);
|
UUIDHandler.add(new StringWrapper(name), denied);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -227,15 +215,10 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
|||||||
try {
|
try {
|
||||||
byte[] bytes = resultSet.getBytes("playerid");
|
byte[] bytes = resultSet.getBytes("playerid");
|
||||||
if (bytes != null) {
|
if (bytes != null) {
|
||||||
try {
|
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
long mostSigBits = bb.getLong();
|
||||||
long high = bb.getLong();
|
long leastSigBits = bb.getLong();
|
||||||
long low = bb.getLong();
|
helper = new UUID(mostSigBits, leastSigBits);
|
||||||
helper = new UUID(high, low);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
helper = UUID.nameUUIDFromBytes(bytes);
|
|
||||||
}
|
|
||||||
UUIDHandler.add(new StringWrapper(name), helper);
|
UUIDHandler.add(new StringWrapper(name), helper);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
@ -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) {
|
||||||
@ -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("PlotMe", 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("PlotMe", 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("PlotMe", "bukkit.yml");
|
||||||
updateWorldYml(this.plugin, "plugins/Multiverse-Core/worlds.yml");
|
updateWorldYml("PlotMe", "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 {
|
||||||
@ -131,8 +130,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 +178,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<>();
|
||||||
|
@ -15,16 +15,17 @@ 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.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.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;
|
||||||
@ -56,11 +57,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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -212,12 +213,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);
|
||||||
}
|
}
|
||||||
|
@ -28,16 +28,6 @@ import com.plotsquared.bukkit.object.BukkitPlayer;
|
|||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.plotsquared.listener.PlayerBlockEventType;
|
import com.plotsquared.listener.PlayerBlockEventType;
|
||||||
import com.plotsquared.listener.PlotListener;
|
import com.plotsquared.listener.PlotListener;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -52,6 +42,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;
|
||||||
@ -119,6 +110,17 @@ 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.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Player Events involving plots.
|
* Player Events involving plots.
|
||||||
*
|
*
|
||||||
@ -361,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;
|
||||||
@ -564,14 +566,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;
|
||||||
}
|
}
|
||||||
@ -606,7 +607,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();
|
||||||
@ -745,7 +746,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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,19 +60,19 @@ 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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, "/plot area 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, "/plot area 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, "/plot area 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, "/plot area " + 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, "/plot area 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/plot area 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, "/plot area 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, "/plot area 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;
|
||||||
@ -397,17 +397,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 +423,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 +445,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();
|
||||||
|
|
||||||
@ -416,7 +418,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 +438,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
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
@ -155,9 +156,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;
|
||||||
|
@ -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");
|
||||||
|
@ -23,7 +23,7 @@ import java.util.UUID;
|
|||||||
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.NONE,
|
||||||
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"};
|
||||||
|
@ -24,7 +24,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 +145,14 @@ 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 plotPlayer : plot.getPlayersInPlot()) {
|
||||||
|
plotPlayer.deleteMeta("lastplot");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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() {
|
||||||
|
@ -3,7 +3,6 @@ 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;
|
||||||
|
|
||||||
@ -621,14 +620,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 +798,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);
|
||||||
}
|
}
|
||||||
|
@ -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` = ";
|
||||||
|
@ -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() {
|
||||||
|
@ -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) {
|
||||||
|
@ -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;
|
||||||
@ -180,13 +180,13 @@ 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;
|
||||||
}
|
}
|
||||||
@ -358,7 +358,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.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;
|
||||||
@ -46,13 +47,13 @@ public class InboxOwner extends CommentInbox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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)) {
|
if ((plot == null) || (plot.owner == null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ArrayList<PlotComment> comments = plot.getSettings().getComments(toString());
|
Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(toString());
|
||||||
if (comments != null) {
|
if (comments.isPresent()) {
|
||||||
whenDone.value = comments;
|
whenDone.value = comments.get();
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -75,7 +76,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);
|
||||||
|
@ -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;
|
||||||
@ -42,13 +43,13 @@ public class InboxPublic extends CommentInbox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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)) {
|
if (plot.owner == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ArrayList<PlotComment> comments = plot.getSettings().getComments(toString());
|
Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(toString());
|
||||||
if (comments != null) {
|
if (comments.isPresent()) {
|
||||||
whenDone.value = comments;
|
whenDone.value = comments.get();
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -69,7 +70,7 @@ 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)) {
|
if (plot.owner == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
plot.getSettings().addComment(comment);
|
plot.getSettings().addComment(comment);
|
||||||
|
@ -39,7 +39,7 @@ public class InboxReport extends CommentInbox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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 +52,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);
|
||||||
@ -66,7 +66,7 @@ public class InboxReport extends CommentInbox {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeComment(Plot plot, PlotComment comment) {
|
public boolean removeComment(Plot plot, PlotComment comment) {
|
||||||
if (plot == null || plot.owner == null) {
|
if (plot.owner == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DBFunc.removeComment(plot, comment);
|
DBFunc.removeComment(plot, comment);
|
||||||
|
@ -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")) {
|
||||||
|
@ -2,12 +2,12 @@ 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.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;
|
||||||
@ -239,7 +239,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();
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
@ -601,7 +601,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 +639,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);
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
@ -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;
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -76,10 +76,6 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by robin on 01/11/2014
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Plugin(id = "com.plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.", url = "https://github.com/IntellectualSites/PlotSquared", version = "3.3.3")
|
@Plugin(id = "com.plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.", url = "https://github.com/IntellectualSites/PlotSquared", version = "3.3.3")
|
||||||
public class SpongeMain implements IPlotMain {
|
public class SpongeMain implements IPlotMain {
|
||||||
public static SpongeMain THIS;
|
public static SpongeMain THIS;
|
||||||
@ -169,7 +165,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};
|
||||||
}
|
}
|
||||||
|
@ -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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ subprojects {
|
|||||||
compile(group: 'com.sk89q', name: 'worldedit', version:'6.0.0-SNAPSHOT') {
|
compile(group: 'com.sk89q', name: 'worldedit', version:'6.0.0-SNAPSHOT') {
|
||||||
exclude(module: 'bukkit-classloader-check')
|
exclude(module: 'bukkit-classloader-check')
|
||||||
}
|
}
|
||||||
|
compile 'com.google.guava:guava:10.0'
|
||||||
}
|
}
|
||||||
clean{
|
clean{
|
||||||
delete file("../target")
|
delete file("../target")
|
||||||
|
Loading…
Reference in New Issue
Block a user