mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8_3.java # Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java
This commit is contained in:
@ -3,80 +3,82 @@ package com.intellectualcrafters.configuration;
|
||||
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 {
|
||||
/**
|
||||
* 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
|
||||
* hold the new default value.
|
||||
* <p>
|
||||
* If value is null, the value will be removed from the default
|
||||
* Configuration source.
|
||||
* hold the new default value.</p>
|
||||
*
|
||||
* <p>If value is null, the value will be removed from the default
|
||||
* Configuration source.</p>
|
||||
*
|
||||
* @param path Path of the value to set.
|
||||
* @param value Value to set the default to.
|
||||
* @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.
|
||||
* <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
|
||||
* hold the new default values.
|
||||
* hold the new default values.</p>
|
||||
*
|
||||
* @param defaults A map of Path->Values to add to defaults.
|
||||
* @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.
|
||||
* <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
|
||||
* hold the new default value.
|
||||
* <p>
|
||||
* This method will not hold a reference to the specified Configuration,
|
||||
* hold the new default value.</p>
|
||||
*
|
||||
* <p>This method will not hold a reference to the specified Configuration,
|
||||
* nor will it automatically update if that Configuration ever changes. If
|
||||
* 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.
|
||||
* @throws IllegalArgumentException Thrown if defaults is null or this.
|
||||
*/
|
||||
void addDefaults(final 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);
|
||||
void addDefaults(Configuration defaults);
|
||||
|
||||
/**
|
||||
* Gets the source {@link Configuration} for this configuration.
|
||||
*
|
||||
* <p>
|
||||
* If no configuration source was set, but default values were added, then
|
||||
* 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.
|
||||
*/
|
||||
Configuration getDefaults();
|
||||
|
||||
/**
|
||||
* Gets the {@link ConfigurationOptions} for this {@link Configuration}.
|
||||
* Sets the source of all default values for this {@link Configuration}.
|
||||
*
|
||||
* <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
|
||||
*/
|
||||
|
@ -23,35 +23,35 @@ public class MemoryConfiguration extends MemorySection implements Configuration
|
||||
* @param defaults Default value provider
|
||||
* @throws IllegalArgumentException Thrown if defaults is null
|
||||
*/
|
||||
public MemoryConfiguration(final Configuration defaults) {
|
||||
public MemoryConfiguration(Configuration defaults) {
|
||||
this.defaults = defaults;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDefault(final String path, final Object value) {
|
||||
public void addDefault(String path, Object value) {
|
||||
if (path == null) {
|
||||
throw new NullPointerException("Path may not be null");
|
||||
}
|
||||
if (defaults == null) {
|
||||
defaults = new MemoryConfiguration();
|
||||
if (this.defaults == null) {
|
||||
this.defaults = new MemoryConfiguration();
|
||||
}
|
||||
|
||||
defaults.set(path, value);
|
||||
|
||||
this.defaults.set(path, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDefaults(final Map<String, Object> defaults) {
|
||||
public void addDefaults(Map<String, Object> defaults) {
|
||||
if (defaults == 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());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDefaults(final Configuration defaults) {
|
||||
public void addDefaults(Configuration defaults) {
|
||||
if (defaults == null) {
|
||||
throw new NullPointerException("Defaults may not be null");
|
||||
}
|
||||
@ -60,19 +60,19 @@ public class MemoryConfiguration extends MemorySection implements Configuration
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaults(final Configuration defaults) {
|
||||
public Configuration getDefaults() {
|
||||
return this.defaults;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaults(Configuration defaults) {
|
||||
if (defaults == null) {
|
||||
throw new NullPointerException("Defaults may not be null");
|
||||
}
|
||||
|
||||
|
||||
this.defaults = defaults;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Configuration getDefaults() {
|
||||
return defaults;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurationSection getParent() {
|
||||
return null;
|
||||
@ -80,10 +80,10 @@ public class MemoryConfiguration extends MemorySection implements Configuration
|
||||
|
||||
@Override
|
||||
public MemoryConfigurationOptions options() {
|
||||
if (options == null) {
|
||||
options = new MemoryConfigurationOptions(this);
|
||||
if (this.options == null) {
|
||||
this.options = new MemoryConfigurationOptions(this);
|
||||
}
|
||||
|
||||
return options;
|
||||
|
||||
return this.options;
|
||||
}
|
||||
}
|
||||
|
@ -537,16 +537,16 @@ public class MemorySection implements ConfigurationSection {
|
||||
|
||||
@Override
|
||||
public List<String> getStringList(String path) {
|
||||
final List<?> list = getList(path);
|
||||
List<?> list = getList(path);
|
||||
|
||||
if (list == null) {
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
|
||||
final List<String> result = new ArrayList<>();
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
for (final Object object : list) {
|
||||
if ((object instanceof String) || (isPrimitiveWrapper(object))) {
|
||||
for (Object object : list) {
|
||||
if ((object instanceof String) || isPrimitiveWrapper(object)) {
|
||||
result.add(String.valueOf(object));
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.intellectualcrafters.plot.util.area.QuadMap;
|
||||
import com.plotsquared.listener.WESubscriber;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@ -89,6 +90,7 @@ import java.util.zip.ZipInputStream;
|
||||
public class PS {
|
||||
|
||||
private static PS instance;
|
||||
public final IPlotMain IMP;
|
||||
private final HashSet<Integer> plotAreaHashCheck = new HashSet<>();
|
||||
/**
|
||||
* All plot areas mapped by world (quick world access).
|
||||
@ -98,6 +100,9 @@ public class PS {
|
||||
* All plot areas mapped by location (quick location based access).
|
||||
*/
|
||||
private final HashMap<String, QuadMap<PlotArea>> plotAreaGrid = new HashMap<>();
|
||||
private final int[] version;
|
||||
private final String platform;
|
||||
private final Thread thread;
|
||||
public HashMap<String, Set<PlotCluster>> clusters_tmp;
|
||||
public HashMap<String, HashMap<PlotId, Plot>> plots_tmp;
|
||||
public File styleFile;
|
||||
@ -108,7 +113,6 @@ public class PS {
|
||||
public YamlConfiguration config;
|
||||
public YamlConfiguration storage;
|
||||
public YamlConfiguration commands;
|
||||
public IPlotMain IMP = null;
|
||||
public TaskManager TASK;
|
||||
public WorldEdit worldedit;
|
||||
public URL update;
|
||||
@ -117,25 +121,23 @@ public class PS {
|
||||
* All plot areas (quick global access).
|
||||
*/
|
||||
private PlotArea[] plotAreas = new PlotArea[0];
|
||||
|
||||
private File storageFile;
|
||||
private File file = null; // This file
|
||||
private int[] version;
|
||||
private int[] lastVersion;
|
||||
private String platform = null;
|
||||
private Database database;
|
||||
private Thread thread;
|
||||
|
||||
/**
|
||||
* Initialize PlotSquared with the desired Implementation class.
|
||||
* @param imp_class
|
||||
* @param iPlotMain Implementation of {@link IPlotMain} used
|
||||
* @param platform The platform being used
|
||||
*/
|
||||
public PS(IPlotMain imp_class, String platform) {
|
||||
public PS(IPlotMain iPlotMain, String platform) {
|
||||
PS.instance = this;
|
||||
this.thread = Thread.currentThread();
|
||||
this.IMP = iPlotMain;
|
||||
this.platform = platform;
|
||||
this.version = this.IMP.getPluginVersion();
|
||||
try {
|
||||
PS.instance = this;
|
||||
this.thread = Thread.currentThread();
|
||||
SetupUtils.generators = new HashMap<>();
|
||||
this.IMP = imp_class;
|
||||
new ReflectionUtils(this.IMP.getNMSPackage());
|
||||
try {
|
||||
URL url = PS.class.getProtectionDomain().getCodeSource().getLocation();
|
||||
@ -147,8 +149,6 @@ public class PS {
|
||||
this.file = new File(this.IMP.getDirectory().getParentFile(), "PlotSquared-" + platform + ".jar");
|
||||
}
|
||||
}
|
||||
this.version = this.IMP.getPluginVersion();
|
||||
this.platform = platform;
|
||||
if (getJavaVersion() < 1.7) {
|
||||
PS.log(C.CONSOLE_JAVA_OUTDATED_1_7);
|
||||
this.IMP.disable();
|
||||
@ -200,50 +200,7 @@ public class PS {
|
||||
}
|
||||
// create UUIDWrapper
|
||||
UUIDHandler.implementation = this.IMP.initUUIDHandler();
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
debug("Starting UUID caching");
|
||||
UUIDHandler.startCaching(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Plot plot : getPlots()) {
|
||||
if (plot.hasOwner() && plot.temp != -1) {
|
||||
if (UUIDHandler.getName(plot.owner) == null) {
|
||||
UUIDHandler.implementation.unknown.add(plot.owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Auto clearing
|
||||
if (Settings.AUTO_CLEAR) {
|
||||
ExpireManager.IMP = new ExpireManager();
|
||||
if (Settings.AUTO_CLEAR_CONFIRMATION) {
|
||||
ExpireManager.IMP.runConfirmedTask();
|
||||
} else {
|
||||
ExpireManager.IMP.runAutomatedTask();
|
||||
}
|
||||
}
|
||||
// PlotMe
|
||||
if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) {
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (PS.this.IMP.initPlotMeConverter()) {
|
||||
PS.log("&c=== IMPORTANT ===");
|
||||
PS.log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!");
|
||||
PS.log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
|
||||
PS.log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
|
||||
PS.log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the "
|
||||
+ "'settings.yml'");
|
||||
}
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 20);
|
||||
startUuidCatching();
|
||||
// create event util class
|
||||
EventUtil.manager = this.IMP.initEventUtil();
|
||||
// create Hybrid utility class
|
||||
@ -354,10 +311,6 @@ public class PS {
|
||||
PS.get().IMP.log(StringMan.getString(message));
|
||||
}
|
||||
|
||||
public static void stacktrace() {
|
||||
System.err.println(StringMan.join(new Exception().getStackTrace(), "\n\tat "));
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a message to the IPlotMain logger.
|
||||
*
|
||||
@ -370,6 +323,53 @@ public class PS {
|
||||
}
|
||||
}
|
||||
|
||||
private void startUuidCatching() {
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
debug("Starting UUID caching");
|
||||
UUIDHandler.startCaching(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Plot plot : getPlots()) {
|
||||
if (plot.hasOwner() && plot.temp != -1) {
|
||||
if (UUIDHandler.getName(plot.owner) == null) {
|
||||
UUIDHandler.implementation.unknown.add(plot.owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Auto clearing
|
||||
if (Settings.AUTO_CLEAR) {
|
||||
ExpireManager.IMP = new ExpireManager();
|
||||
if (Settings.AUTO_CLEAR_CONFIRMATION) {
|
||||
ExpireManager.IMP.runConfirmedTask();
|
||||
} else {
|
||||
ExpireManager.IMP.runAutomatedTask();
|
||||
}
|
||||
}
|
||||
// PlotMe
|
||||
if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) {
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (PS.this.IMP.initPlotMeConverter()) {
|
||||
PS.log("&c=== IMPORTANT ===");
|
||||
PS.log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!");
|
||||
PS.log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
|
||||
PS.log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
|
||||
PS.log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the "
|
||||
+ "'settings.yml'");
|
||||
}
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
|
||||
public boolean isMainThread(Thread thread) {
|
||||
return this.thread == thread;
|
||||
}
|
||||
@ -1324,14 +1324,18 @@ public class PS {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by the PlotGenerator class normally<br>
|
||||
* - Initializes the PlotArea and PlotManager classes<br>
|
||||
* - Registers the PlotArea and PlotManager classes<br>
|
||||
* - Loads (and/or generates) the PlotArea configuration<br>
|
||||
* - Sets up the world border if configured<br>
|
||||
* If loading an augmented plot world:<br>
|
||||
* - Creates the AugmentedPopulator classes<br>
|
||||
* - Injects the AugmentedPopulator classes if required
|
||||
* This method is called by the PlotGenerator class normally.
|
||||
* <ul>
|
||||
* <li>Initializes the PlotArea and PlotManager classes</li>
|
||||
* <li>Registers the PlotArea and PlotManager classes</li>
|
||||
* <li>Loads (and/or generates) the PlotArea configuration</li>
|
||||
* <li>Sets up the world border if configured</li>
|
||||
* </ul>
|
||||
* If loading an augmented plot world:
|
||||
* <ul>
|
||||
* <li>Creates the AugmentedPopulator classes</li>
|
||||
* <li>Injects the AugmentedPopulator classes if required</li>
|
||||
* </ul>
|
||||
* @param world The world to load
|
||||
* @param baseGenerator The generator for that world, or null if no generator
|
||||
*/
|
||||
@ -1470,14 +1474,14 @@ public class PS {
|
||||
}
|
||||
for (String areaId : areasSection.getKeys(false)) {
|
||||
PS.log(C.PREFIX + "&3 - " + areaId);
|
||||
int i1 = areaId.indexOf("-");
|
||||
int i2 = areaId.indexOf(";");
|
||||
int i1 = areaId.indexOf('-');
|
||||
int i2 = areaId.indexOf(';');
|
||||
if (i1 == -1 || i2 == -1) {
|
||||
throw new IllegalArgumentException("Invalid Area identifier: " + areaId + ". Expected form `<name>-<pos1>-<pos2>`");
|
||||
}
|
||||
String name = areaId.substring(0, i1);
|
||||
String rest = areaId.substring(i1 + 1);
|
||||
int i3 = rest.indexOf("-", i2 - name.length() - 1);
|
||||
int i3 = rest.indexOf('-', i2 - name.length() - 1);
|
||||
PlotId pos1 = PlotId.fromString(rest.substring(0, i3));
|
||||
PlotId pos2 = PlotId.fromString(rest.substring(i3 + 1));
|
||||
if (pos1 == null || pos2 == null || name.isEmpty()) {
|
||||
@ -1543,8 +1547,10 @@ public class PS {
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the configuration for a plot world based on world arguments<br>
|
||||
* e.g. /mv create <world> normal -g PlotSquared:<args>
|
||||
* Setup the configuration for a plot world based on world arguments.
|
||||
* <p>
|
||||
* <i>e.g. /mv create <world> normal -g PlotSquared:<args></i>
|
||||
* </p>
|
||||
* @param world The name of the world
|
||||
* @param args The arguments
|
||||
* @return boolean | if valid arguments were provided
|
||||
@ -1800,7 +1806,7 @@ public class PS {
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the default flags for PlotSquared<br>
|
||||
* Setup the default flags for PlotSquared.
|
||||
* - Create the flags
|
||||
* - Register with FlagManager and parse raw flag values
|
||||
*/
|
||||
@ -2404,10 +2410,6 @@ public class PS {
|
||||
return count;
|
||||
}
|
||||
|
||||
public int getPlotAreaCount(String world) {
|
||||
return this.plotAreaMap.size();
|
||||
}
|
||||
|
||||
public Set<PlotArea> getPlotAreas() {
|
||||
HashSet<PlotArea> set = new HashSet<>(this.plotAreas.length);
|
||||
Collections.addAll(set, this.plotAreas);
|
||||
|
@ -4,6 +4,7 @@ import static com.intellectualcrafters.plot.PS.log;
|
||||
|
||||
import com.intellectualcrafters.json.JSONArray;
|
||||
import com.intellectualcrafters.json.JSONObject;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@ -28,8 +29,10 @@ public class Updater {
|
||||
|
||||
return buffer.toString();
|
||||
} catch (IOException e) {
|
||||
log("&dCould not check for updates (0)");
|
||||
e.printStackTrace();
|
||||
log("&dCould not check for updates");
|
||||
if (Settings.DEBUG) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (reader != null) {
|
||||
|
@ -43,46 +43,46 @@ import java.util.Set;
|
||||
public class Area extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
if (args.length == 0) {
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "c":
|
||||
case "setup":
|
||||
case "create":
|
||||
if (!Permissions.hasPermission(plr, "plots.area.create")) {
|
||||
C.NO_PERMISSION.send(plr, "plots.area.create");
|
||||
if (!Permissions.hasPermission(player, "plots.area.create")) {
|
||||
C.NO_PERMISSION.send(player, "plots.area.create");
|
||||
return false;
|
||||
}
|
||||
switch (args.length) {
|
||||
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;
|
||||
case 2:
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "pos1": { // Set position 1
|
||||
HybridPlotWorld area = plr.getMeta("area_create_area");
|
||||
HybridPlotWorld area = player.getMeta("area_create_area");
|
||||
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;
|
||||
}
|
||||
Location location = plr.getLocation();
|
||||
plr.setMeta("area_pos1", location);
|
||||
C.SET_ATTRIBUTE.send(plr, "area_pos1", location.getX() + "," + location.getZ());
|
||||
MainUtil.sendMessage(plr, "You will now set pos2: /plot area create pos2"
|
||||
Location location = player.getLocation();
|
||||
player.setMeta("area_pos1", location);
|
||||
C.SET_ATTRIBUTE.send(player, "area_pos1", location.getX() + "," + location.getZ());
|
||||
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.");
|
||||
return true;
|
||||
}
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
Location pos1 = plr.getLocation();
|
||||
Location pos2 = plr.getMeta("area_pos1");
|
||||
Location pos1 = player.getLocation();
|
||||
Location pos2 = player.getMeta("area_pos1");
|
||||
int dx = Math.abs(pos1.getX() - pos2.getX());
|
||||
int dz = Math.abs(pos1.getZ() - pos2.getZ());
|
||||
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);
|
||||
Set<PlotArea> areas = PS.get().getPlotAreas(area.worldname, region);
|
||||
if (!areas.isEmpty()) {
|
||||
C.CLUSTER_INTERSECTION.send(plr, areas.iterator().next().toString());
|
||||
C.CLUSTER_INTERSECTION.send(player, areas.iterator().next().toString());
|
||||
return false;
|
||||
}
|
||||
final SetupObject object = new SetupObject();
|
||||
@ -125,8 +125,8 @@ public class Area extends SubCommand {
|
||||
final String world = SetupUtils.manager.setupWorld(object);
|
||||
if (WorldUtil.IMP.isWorld(world)) {
|
||||
PS.get().loadWorld(world, null);
|
||||
C.SETUP_FINISHED.send(plr);
|
||||
plr.teleport(WorldUtil.IMP.getSpawn(world));
|
||||
C.SETUP_FINISHED.send(player);
|
||||
player.teleport(WorldUtil.IMP.getSpawn(world));
|
||||
if (area.TERRAIN != 3) {
|
||||
ChunkManager.largeRegionTask(world, region, new RunnableVal<ChunkLoc>() {
|
||||
@Override
|
||||
@ -136,12 +136,12 @@ public class Area extends SubCommand {
|
||||
}, null);
|
||||
}
|
||||
} 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)) {
|
||||
CmdConfirm.addPending(plr, "/plot area create pos2 (Creates world)", run);
|
||||
if (hasConfirmation(player)) {
|
||||
CmdConfirm.addPending(player, getCommandString() + " create pos2 (Creates world)", run);
|
||||
} else {
|
||||
run.run();
|
||||
}
|
||||
@ -160,7 +160,7 @@ public class Area extends SubCommand {
|
||||
final HybridPlotWorld pa = new HybridPlotWorld(object.world, id, new HybridGen(), null, null);
|
||||
PlotArea other = PS.get().getPlotArea(pa.worldname, 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;
|
||||
}
|
||||
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++) {
|
||||
String[] pair = args[i].split("=");
|
||||
if (pair.length != 2) {
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||
C.COMMAND_SYNTAX.send(player, getCommandString() + " create [world[:id]] [<modifier>=<value>]...");
|
||||
return false;
|
||||
}
|
||||
switch (pair[0].toLowerCase()) {
|
||||
@ -218,13 +218,13 @@ public class Area extends SubCommand {
|
||||
object.type = pa.TYPE;
|
||||
break;
|
||||
default:
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||
C.COMMAND_SYNTAX.send(player, getCommandString() + " create [world[:id]] [<modifier>=<value>]...");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (pa.TYPE != 2) {
|
||||
if (WorldUtil.IMP.isWorld(pa.worldname)) {
|
||||
C.SETUP_WORLD_TAKEN.send(plr, pa.worldname);
|
||||
C.SETUP_WORLD_TAKEN.send(player, pa.worldname);
|
||||
return false;
|
||||
}
|
||||
Runnable run = new Runnable() {
|
||||
@ -241,10 +241,10 @@ public class Area extends SubCommand {
|
||||
object.setupGenerator = "PlotSquared";
|
||||
String world = SetupUtils.manager.setupWorld(object);
|
||||
if (WorldUtil.IMP.isWorld(world)) {
|
||||
C.SETUP_FINISHED.send(plr);
|
||||
plr.teleport(WorldUtil.IMP.getSpawn(world));
|
||||
C.SETUP_FINISHED.send(player);
|
||||
player.teleport(WorldUtil.IMP.getSpawn(world));
|
||||
} 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 {
|
||||
PS.get().config.save(PS.get().configFile);
|
||||
@ -253,55 +253,55 @@ public class Area extends SubCommand {
|
||||
}
|
||||
}
|
||||
};
|
||||
if (hasConfirmation(plr)) {
|
||||
CmdConfirm.addPending(plr, "/plot area " + StringMan.join(args, " "), run);
|
||||
if (hasConfirmation(player)) {
|
||||
CmdConfirm.addPending(player, getCommandString() + " " + StringMan.join(args, " "), run);
|
||||
} else {
|
||||
run.run();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (pa.id == null) {
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||
C.COMMAND_SYNTAX.send(player, getCommandString() + " create [world[:id]] [<modifier>=<value>]...");
|
||||
return false;
|
||||
}
|
||||
if (WorldUtil.IMP.isWorld(pa.worldname)) {
|
||||
if (!plr.getLocation().getWorld().equals(pa.worldname)) {
|
||||
plr.teleport(WorldUtil.IMP.getSpawn(pa.worldname));
|
||||
if (!player.getLocation().getWorld().equals(pa.worldname)) {
|
||||
player.teleport(WorldUtil.IMP.getSpawn(pa.worldname));
|
||||
}
|
||||
} else {
|
||||
object.terrain = 0;
|
||||
object.type = 0;
|
||||
SetupUtils.manager.setupWorld(object);
|
||||
plr.teleport(WorldUtil.IMP.getSpawn(pa.worldname));
|
||||
player.teleport(WorldUtil.IMP.getSpawn(pa.worldname));
|
||||
}
|
||||
plr.setMeta("area_create_area", pa);
|
||||
MainUtil.sendMessage(plr, "$1Go to the first corner and use: $2/plot area create pos1");
|
||||
player.setMeta("area_create_area", pa);
|
||||
MainUtil.sendMessage(player, "$1Go to the first corner and use: $2 " + getCommandString() + " create pos1");
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
case "i":
|
||||
case "info": {
|
||||
if (!Permissions.hasPermission(plr, "plots.area.info")) {
|
||||
C.NO_PERMISSION.send(plr, "plots.area.info");
|
||||
if (!Permissions.hasPermission(player, "plots.area.info")) {
|
||||
C.NO_PERMISSION.send(player, "plots.area.info");
|
||||
return false;
|
||||
}
|
||||
PlotArea area;
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
area = plr.getApplicablePlotArea();
|
||||
area = player.getApplicablePlotArea();
|
||||
break;
|
||||
case 2:
|
||||
area = PS.get().getPlotAreaByString(args[1]);
|
||||
break;
|
||||
default:
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area info [area]");
|
||||
C.COMMAND_SYNTAX.send(player, getCommandString() + " info [area]");
|
||||
return false;
|
||||
}
|
||||
if (area == null) {
|
||||
if (args.length == 2) {
|
||||
C.NOT_VALID_PLOT_WORLD.send(plr, args[1]);
|
||||
C.NOT_VALID_PLOT_WORLD.send(player, args[1]);
|
||||
} else {
|
||||
C.NOT_IN_PLOT_WORLD.send(plr);
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -331,13 +331,13 @@ public class Area extends SubCommand {
|
||||
+ "\n$1Clusters: $2" + clusters
|
||||
+ "\n$1Region: $2" + region
|
||||
+ "\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;
|
||||
}
|
||||
case "l":
|
||||
case "list":
|
||||
if (!Permissions.hasPermission(plr, "plots.area.list")) {
|
||||
C.NO_PERMISSION.send(plr, "plots.area.list");
|
||||
if (!Permissions.hasPermission(player, "plots.area.list")) {
|
||||
C.NO_PERMISSION.send(player, "plots.area.list");
|
||||
return false;
|
||||
}
|
||||
int page;
|
||||
@ -351,11 +351,11 @@ public class Area extends SubCommand {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area list [#]");
|
||||
C.COMMAND_SYNTAX.send(player, getCommandString() + " list [#]");
|
||||
return false;
|
||||
}
|
||||
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
|
||||
public void run(Integer i, PlotArea area, PlotMessage message) {
|
||||
String name;
|
||||
@ -388,7 +388,8 @@ public class Area extends SubCommand {
|
||||
message.text("[").color("$3")
|
||||
.text(i + "").command(visit).tooltip(visit).color("$1")
|
||||
.text("]").color("$3")
|
||||
.text(" " + name).tooltip(tooltip).command("/plot area info " + area).color("$1").text(" - ").color("$2")
|
||||
.text(" " + name).tooltip(tooltip).command(getCommandString() + " info " + area).color("$1").text(" - ")
|
||||
.color("$2")
|
||||
.text(area.TYPE + ":" + area.TERRAIN).color("$3");
|
||||
}
|
||||
}, "/plot area list", C.AREA_LIST_HEADER_PAGED.s());
|
||||
@ -397,17 +398,17 @@ public class Area extends SubCommand {
|
||||
case "clear":
|
||||
case "reset":
|
||||
case "regenerate": {
|
||||
if (!Permissions.hasPermission(plr, "plots.area.regen")) {
|
||||
C.NO_PERMISSION.send(plr, "plots.area.regen");
|
||||
if (!Permissions.hasPermission(player, "plots.area.regen")) {
|
||||
C.NO_PERMISSION.send(player, "plots.area.regen");
|
||||
return false;
|
||||
}
|
||||
final PlotArea area = plr.getApplicablePlotArea();
|
||||
final PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(plr);
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
ChunkManager.largeRegionTask(area.worldname, area.getRegion(), new RunnableVal<ChunkLoc>() {
|
||||
@ -423,17 +424,17 @@ public class Area extends SubCommand {
|
||||
case "teleport":
|
||||
case "visit":
|
||||
case "tp":
|
||||
if (!Permissions.hasPermission(plr, "plots.area.tp")) {
|
||||
C.NO_PERMISSION.send(plr, "plots.area.tp");
|
||||
if (!Permissions.hasPermission(player, "plots.area.tp")) {
|
||||
C.NO_PERMISSION.send(player, "plots.area.tp");
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot visit [area]");
|
||||
C.COMMAND_SYNTAX.send(player, "/plot visit [area]");
|
||||
return false;
|
||||
}
|
||||
PlotArea area = PS.get().getPlotAreaByString(args[1]);
|
||||
if (area == null) {
|
||||
C.NOT_VALID_PLOT_WORLD.send(plr, args[1]);
|
||||
C.NOT_VALID_PLOT_WORLD.send(player, args[1]);
|
||||
return false;
|
||||
}
|
||||
Location center;
|
||||
@ -445,18 +446,18 @@ public class Area extends SubCommand {
|
||||
region.minZ + (region.maxZ - region.minZ) / 2);
|
||||
center.setY(WorldUtil.IMP.getHighestBlock(area.worldname, center.getX(), center.getZ()));
|
||||
}
|
||||
plr.teleport(center);
|
||||
player.teleport(center);
|
||||
return true;
|
||||
case "delete":
|
||||
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 - $2PlotSquared settings.yml"
|
||||
+ "\n$3 - $2Multiverse worlds.yml (or any world management plugin)"
|
||||
+ "\n$1Stop the server and delete it from these locations.");
|
||||
return true;
|
||||
}
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@CommandDeclaration(command = "clear",
|
||||
@ -20,7 +21,7 @@ import java.util.Set;
|
||||
category = CommandCategory.APPEARANCE,
|
||||
usage = "/plot clear [id]",
|
||||
aliases = "reset",
|
||||
confirmation=true)
|
||||
confirmation = true)
|
||||
public class Clear extends SubCommand {
|
||||
|
||||
@Override
|
||||
|
@ -37,6 +37,7 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
import com.plotsquared.listener.WEManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@ -46,6 +47,7 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.script.Bindings;
|
||||
import javax.script.ScriptContext;
|
||||
import javax.script.ScriptEngine;
|
||||
@ -145,7 +147,7 @@ public class DebugExec extends SubCommand {
|
||||
|
||||
@Override
|
||||
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");
|
||||
if (args.length > 0) {
|
||||
String arg = args[0].toLowerCase();
|
||||
@ -331,7 +333,7 @@ public class DebugExec extends SubCommand {
|
||||
}
|
||||
break;
|
||||
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[] filesArray = folder.listFiles();
|
||||
|
||||
@ -355,8 +357,7 @@ public class DebugExec extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void run(Integer i, File file, PlotMessage message) {
|
||||
String name;
|
||||
name = file.getName();
|
||||
String name = file.getName();
|
||||
|
||||
message.text("[").color("$3")
|
||||
.text(i + "").color("$1")
|
||||
@ -416,7 +417,7 @@ public class DebugExec extends SubCommand {
|
||||
default:
|
||||
script = StringMan.join(args, " ");
|
||||
}
|
||||
if (!ConsolePlayer.isConsole(player)) {
|
||||
if (!(player instanceof ConsolePlayer)) {
|
||||
MainUtil.sendMessage(player, C.NOT_CONSOLE);
|
||||
return false;
|
||||
}
|
||||
@ -436,13 +437,13 @@ public class DebugExec extends SubCommand {
|
||||
} catch (ScriptException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ConsolePlayer.getConsole().sendMessage("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
|
||||
PS.log("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
long start = System.currentTimeMillis();
|
||||
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;
|
||||
} catch (ScriptException e) {
|
||||
|
@ -11,6 +11,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
@CommandDeclaration(
|
||||
@ -21,7 +22,7 @@ import java.util.HashSet;
|
||||
aliases = {"dispose", "del"},
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE,
|
||||
confirmation=true)
|
||||
confirmation = true)
|
||||
public class Delete extends SubCommand {
|
||||
|
||||
@Override
|
||||
@ -59,7 +60,7 @@ public class Delete extends SubCommand {
|
||||
sendMessage(plr, C.ADDED_BALANCE, value + "");
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
|
||||
MainUtil.sendMessage(plr, C.CLEARING_DONE, System.currentTimeMillis() - start);
|
||||
}
|
||||
});
|
||||
if (result) {
|
||||
@ -70,7 +71,7 @@ public class Delete extends SubCommand {
|
||||
}
|
||||
};
|
||||
if (hasConfirmation(plr)) {
|
||||
CmdConfirm.addPending(plr, "/plot delete " + plot.getId(), run);
|
||||
CmdConfirm.addPending(plr, getCommandString() + ' ' + plot.getId(), run);
|
||||
} else {
|
||||
TaskManager.runTask(run);
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ public class Deny extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
Location location = plr.getLocation();
|
||||
Plot plot = location.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
description = "Mark a plot as done",
|
||||
permission = "plots.done",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE)
|
||||
requiredType = RequiredType.PLAYER)
|
||||
public class Done extends SubCommand {
|
||||
|
||||
@Override
|
||||
|
@ -22,7 +22,7 @@ import java.net.URL;
|
||||
command = "download",
|
||||
aliases = {"dl"},
|
||||
category = CommandCategory.SCHEMATIC,
|
||||
requiredType = RequiredType.NONE,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
description = "Download your plot",
|
||||
permission = "plots.download")
|
||||
public class Download extends SubCommand {
|
||||
|
@ -13,6 +13,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@ -24,7 +25,7 @@ import java.util.Map;
|
||||
usage = "/plot flag <set|remove|add|list|info> <flag> <value>",
|
||||
description = "Set plot flags",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
permission = "plots.flag")
|
||||
public class FlagCmd extends SubCommand {
|
||||
|
||||
@ -75,18 +76,18 @@ public class FlagCmd extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info <flag>");
|
||||
return false;
|
||||
}
|
||||
AbstractFlag af = FlagManager.getFlag(args[1]);
|
||||
if (af == null) {
|
||||
AbstractFlag flag = FlagManager.getFlag(args[1]);
|
||||
if (flag == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info <flag>");
|
||||
return false;
|
||||
}
|
||||
// flag key
|
||||
MainUtil.sendMessage(player, C.FLAG_KEY, af.getKey());
|
||||
MainUtil.sendMessage(player, C.FLAG_KEY, flag.getKey());
|
||||
// flag type
|
||||
MainUtil.sendMessage(player, C.FLAG_TYPE, af.value.getClass().getSimpleName());
|
||||
MainUtil.sendMessage(player, C.FLAG_TYPE, flag.value.getClass().getSimpleName());
|
||||
// Flag type description
|
||||
MainUtil.sendMessage(player, C.FLAG_DESC, af.getValueDesc());
|
||||
MainUtil.sendMessage(player, C.FLAG_DESC, flag.getValueDesc());
|
||||
return true;
|
||||
}
|
||||
case "set": {
|
||||
@ -167,7 +168,7 @@ public class FlagCmd extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.FLAG_REMOVED);
|
||||
return true;
|
||||
}
|
||||
case "add": {
|
||||
case "add":
|
||||
if (!Permissions.hasPermission(player, "plots.flag.add")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flag.add");
|
||||
return false;
|
||||
@ -206,7 +207,6 @@ public class FlagCmd extends SubCommand {
|
||||
}
|
||||
MainUtil.sendMessage(player, C.FLAG_ADDED);
|
||||
return true;
|
||||
}
|
||||
case "list":
|
||||
if (!Permissions.hasPermission(player, "plots.flag.list")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flag.list");
|
||||
@ -217,12 +217,12 @@ public class FlagCmd extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
HashMap<String, ArrayList<String>> flags = new HashMap<>();
|
||||
for (AbstractFlag af : FlagManager.getFlags()) {
|
||||
String type = af.value.getClass().getSimpleName().replaceAll("Value", "");
|
||||
for (AbstractFlag flag1 : FlagManager.getFlags()) {
|
||||
String type = flag1.value.getClass().getSimpleName().replaceAll("Value", "");
|
||||
if (!flags.containsKey(type)) {
|
||||
flags.put(type, new ArrayList<String>());
|
||||
}
|
||||
flags.get(type).add(af.getKey());
|
||||
flags.get(type).add(flag1.getKey());
|
||||
}
|
||||
String message = "";
|
||||
String prefix = "";
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
@ -66,8 +67,14 @@ public class Inbox extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
sendMessage(player, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
} else if (!plot.hasOwner()) {
|
||||
sendMessage(player, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox [inbox] [delete <index>|clear|page]");
|
||||
for (final CommentInbox inbox : CommentManager.inboxes.values()) {
|
||||
@ -155,9 +162,9 @@ public class Inbox extends SubCommand {
|
||||
sendMessage(player, C.NO_PERM_INBOX_MODIFY);
|
||||
}
|
||||
inbox.clearInbox(plot);
|
||||
ArrayList<PlotComment> comments = plot.getSettings().getComments(inbox.toString());
|
||||
if (comments != null) {
|
||||
plot.getSettings().removeComments(comments);
|
||||
Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(inbox.toString());
|
||||
if (comments.isPresent()) {
|
||||
plot.getSettings().removeComments(comments.get());
|
||||
}
|
||||
MainUtil.sendMessage(player, C.COMMENT_REMOVED, "*");
|
||||
return true;
|
||||
@ -182,11 +189,7 @@ public class Inbox extends SubCommand {
|
||||
displayComments(player, value, page);
|
||||
}
|
||||
})) {
|
||||
if (plot == null) {
|
||||
sendMessage(player, C.NOT_IN_PLOT);
|
||||
} else {
|
||||
sendMessage(player, C.PLOT_UNOWNED);
|
||||
}
|
||||
sendMessage(player, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -82,6 +82,7 @@ public class Info extends SubCommand {
|
||||
"&cAlias: &6" + plot.getAlias(),
|
||||
"&cBiome: &6" + plot.getBiome().replaceAll("_", "").toLowerCase(),
|
||||
"&cCan Build: &6" + plot.isAdded(uuid),
|
||||
"&cExpires: &6" + plot.isAdded(uuid),
|
||||
"&cIs Denied: &6" + plot.isDenied(uuid)));
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted", "&cAmount: &6" + plot.getTrusted().size(),
|
||||
"&8Click to view a list of the trusted users"));
|
||||
@ -109,8 +110,8 @@ public class Info extends SubCommand {
|
||||
info = getCaption(arg);
|
||||
if (info == null) {
|
||||
MainUtil.sendMessage(player,
|
||||
"&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, "
|
||||
+ "&arating");
|
||||
"&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aexpires&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, "
|
||||
+ "&aowner&7, " + "&arating");
|
||||
return false;
|
||||
}
|
||||
full = true;
|
||||
@ -148,6 +149,8 @@ public class Info extends SubCommand {
|
||||
return C.PLOT_INFO_OWNER.s();
|
||||
case "rating":
|
||||
return C.PLOT_INFO_RATING.s();
|
||||
case "expires":
|
||||
return C.PLOT_INFO_EXPIRES.s();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ public class Kick extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot = loc.getPlot();
|
||||
Location location = plr.getLocation();
|
||||
Plot plot = location.getPlot();
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -40,8 +40,8 @@ public class Kick extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
}
|
||||
Location otherLoc = player.getLocation();
|
||||
if (!plr.getLocation().getWorld().equals(otherLoc.getWorld()) || !plot.equals(otherLoc.getPlot())) {
|
||||
Location location2 = player.getLocation();
|
||||
if (!plr.getLocation().getWorld().equals(location2.getWorld()) || !plot.equals(location2.getPlot())) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
}
|
||||
@ -49,7 +49,7 @@ public class Kick extends SubCommand {
|
||||
C.CANNOT_KICK_PLAYER.send(plr, player.getName());
|
||||
return false;
|
||||
}
|
||||
Location spawn = WorldUtil.IMP.getSpawn(loc.getWorld());
|
||||
Location spawn = WorldUtil.IMP.getSpawn(location.getWorld());
|
||||
C.YOU_GOT_KICKED.send(player);
|
||||
if (plot.equals(spawn.getPlot())) {
|
||||
Location newSpawn = WorldUtil.IMP.getSpawn(player);
|
||||
|
@ -14,6 +14,7 @@ import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
@ -113,14 +114,6 @@ public class MainCommand extends Command {
|
||||
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) {
|
||||
if (args.length >= 1 && args[0].contains(":")) {
|
||||
String[] split2 = args[0].split(":");
|
||||
@ -181,6 +174,14 @@ public class MainCommand extends Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
/**
|
||||
* @Deprecated legacy
|
||||
*/
|
||||
public void addCommand(SubCommand command) {
|
||||
PS.debug("Command registration is now done during instantiation");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
||||
// Clear perm caching //
|
||||
@ -192,7 +193,8 @@ public class MainCommand extends Command {
|
||||
if (args.length >= 2) {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
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
|
||||
loc = player.getMeta("location");
|
||||
plot = player.getMeta("lastplot");
|
||||
|
@ -22,8 +22,8 @@ import java.util.UUID;
|
||||
description = "Merge the plot you are standing on, with another plot",
|
||||
permission = "plots.merge", usage = "/plot merge <all|n|e|s|w> [removeroads]",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE,
|
||||
confirmation=true)
|
||||
requiredType = RequiredType.PLAYER,
|
||||
confirmation = true)
|
||||
public class Merge extends SubCommand {
|
||||
|
||||
public static final String[] values = new String[]{"north", "east", "south", "west", "auto"};
|
||||
|
@ -11,6 +11,7 @@ import com.intellectualcrafters.plot.util.CmdConfirm;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -24,7 +25,7 @@ import java.util.UUID;
|
||||
description = "Purge all plots for a world",
|
||||
category = CommandCategory.ADMINISTRATION,
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
confirmation=true)
|
||||
confirmation = true)
|
||||
public class Purge extends SubCommand {
|
||||
|
||||
@Override
|
||||
@ -145,12 +146,15 @@ public class Purge extends SubCommand {
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
HashSet<Integer> ids = new HashSet<Integer>();
|
||||
HashSet<Integer> ids = new HashSet<>();
|
||||
for (Plot plot : toDelete) {
|
||||
if (plot.temp != Integer.MAX_VALUE) {
|
||||
ids.add(plot.temp);
|
||||
PlotArea area = plot.getArea();
|
||||
plot.getArea().removePlot(plot.getId());
|
||||
for (PlotPlayer pp : plot.getPlayersInPlot()) {
|
||||
PlotListener.plotEntry(pp, plot);
|
||||
}
|
||||
plot.removeSign();
|
||||
}
|
||||
}
|
||||
DBFunc.purgeIds(ids);
|
||||
|
@ -141,7 +141,7 @@ public class SchematicCmd extends SubCommand {
|
||||
// }
|
||||
case "saveall":
|
||||
case "exportall": {
|
||||
if (!ConsolePlayer.isConsole(plr)) {
|
||||
if (!(plr instanceof ConsolePlayer)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_CONSOLE);
|
||||
return false;
|
||||
}
|
||||
@ -197,10 +197,9 @@ public class SchematicCmd extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
Plot p2 = plot;
|
||||
loc.getWorld();
|
||||
Collection<Plot> plots = new ArrayList<Plot>();
|
||||
plots.add(p2);
|
||||
plots.add(plot);
|
||||
boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -15,7 +15,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
usage = "/plot target <<plot>|nearest>",
|
||||
description = "Target a plot with your compass",
|
||||
permission = "plots.target",
|
||||
requiredType = RequiredType.NONE,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
category = CommandCategory.INFO)
|
||||
public class Target extends SubCommand {
|
||||
|
||||
|
@ -3,9 +3,9 @@ package com.intellectualcrafters.plot.config;
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.CommandCaller;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
@ -453,6 +453,7 @@ public enum C {
|
||||
* Info
|
||||
*/
|
||||
NONE("None", "Info"),
|
||||
NEVER("Never", "Info"),
|
||||
UNKNOWN("Unknown", "Info"),
|
||||
EVERYONE("Everyone", "Info"),
|
||||
PLOT_UNOWNED("$2The current plot must have an owner to perform this action", "Info"),
|
||||
@ -464,6 +465,7 @@ public enum C {
|
||||
+ "$1Biome: $2%biome%$1&-"
|
||||
+ "$1Can Build: $2%build%$1&-"
|
||||
+ "$1Rating: $2%rating%&-"
|
||||
+ "$1Expires: $2%expires%&-"
|
||||
+ "$1Trusted: $2%trusted%$1&-"
|
||||
+ "$1Members: $2%members%$1&-"
|
||||
+ "$1Denied: $2%denied%$1&-"
|
||||
@ -479,6 +481,7 @@ public enum C {
|
||||
PLOT_INFO_ID("$1ID:$2 %id%", "Info"),
|
||||
PLOT_INFO_ALIAS("$1Alias:$2 %alias%", "Info"),
|
||||
PLOT_INFO_SIZE("$1Size:$2 %size%", "Info"),
|
||||
PLOT_INFO_EXPIRES("$1Expires:$2 %expires%", "Info"),
|
||||
PLOT_USER_LIST(" $1%user%$2,", "Info"),
|
||||
INFO_SYNTAX_CONSOLE("$2/plot info X;Y", "Info"),
|
||||
/*
|
||||
@ -621,14 +624,14 @@ public enum C {
|
||||
* What locale category should this translation fall under.
|
||||
*/
|
||||
private final String category;
|
||||
/**
|
||||
* Translated.
|
||||
*/
|
||||
private String s;
|
||||
/**
|
||||
* Should the string be prefixed.
|
||||
*/
|
||||
private final boolean prefix;
|
||||
/**
|
||||
* Translated.
|
||||
*/
|
||||
private String s;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -799,7 +802,7 @@ public enum C {
|
||||
public void send(CommandCaller plr, Object... args) {
|
||||
String msg = format(this, args);
|
||||
if (plr == null) {
|
||||
ConsolePlayer.getConsole().sendMessage(msg);
|
||||
PS.log(msg);
|
||||
} else {
|
||||
plr.sendMessage(msg);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class ConfigurationNode {
|
||||
private final SettingValue type;
|
||||
private Object value;
|
||||
|
||||
public ConfigurationNode(String constant, Object defaultValue, String description, SettingValue type, boolean required) {
|
||||
public ConfigurationNode(String constant, Object defaultValue, String description, SettingValue type) {
|
||||
this.constant = constant;
|
||||
this.defaultValue = defaultValue;
|
||||
this.description = description;
|
||||
|
@ -6,16 +6,11 @@ import java.util.List;
|
||||
/**
|
||||
* Updater and DB settings
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
public class Settings {
|
||||
public static boolean USE_SQLUUIDHANDLER = false;
|
||||
|
||||
public static boolean AUTO_PURGE = false;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static boolean UPDATE_NOTIFICATIONS = true;
|
||||
|
||||
public static boolean FAST_CLEAR = false;
|
||||
@ -163,8 +158,6 @@ public class Settings {
|
||||
|
||||
/**
|
||||
* Database settings
|
||||
*
|
||||
|
||||
*/
|
||||
public static class DB {
|
||||
/**
|
||||
|
@ -139,8 +139,7 @@ public interface AbstractDB {
|
||||
|
||||
/**
|
||||
* Set plot flags.
|
||||
*
|
||||
* @param plot Plot Object
|
||||
* @param plot Plot Object
|
||||
* @param flags flags to set (flag[])
|
||||
*/
|
||||
void setFlags(Plot plot, Collection<Flag> flags);
|
||||
|
@ -290,7 +290,7 @@ public class DBFunc {
|
||||
* @param comment
|
||||
*/
|
||||
public static void removeComment(Plot plot, PlotComment comment) {
|
||||
if (plot != null && plot.temp == -1) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
DBFunc.dbManager.removeComment(plot, comment);
|
||||
|
@ -1443,18 +1443,19 @@ public class SQLManager implements AbstractDB {
|
||||
if (plot.temp > 0) {
|
||||
return plot.temp;
|
||||
}
|
||||
PreparedStatement stmt = this.connection.prepareStatement(
|
||||
"SELECT `id` FROM `" + this.prefix + "plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC");
|
||||
stmt.setInt(1, plot.getId().x);
|
||||
stmt.setInt(2, plot.getId().y);
|
||||
stmt.setString(3, plot.getArea().toString());
|
||||
ResultSet r = stmt.executeQuery();
|
||||
int id = Integer.MAX_VALUE;
|
||||
while (r.next()) {
|
||||
id = r.getInt("id");
|
||||
int id;
|
||||
try (PreparedStatement statement = this.connection.prepareStatement(
|
||||
"SELECT `id` FROM `" + this.prefix + "plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC")) {
|
||||
statement.setInt(1, plot.getId().x);
|
||||
statement.setInt(2, plot.getId().y);
|
||||
statement.setString(3, plot.getArea().toString());
|
||||
try (ResultSet resultSet = statement.executeQuery()) {
|
||||
id = Integer.MAX_VALUE;
|
||||
while (resultSet.next()) {
|
||||
id = resultSet.getInt("id");
|
||||
}
|
||||
}
|
||||
}
|
||||
r.close();
|
||||
stmt.close();
|
||||
if (id == Integer.MAX_VALUE || id == 0) {
|
||||
if (plot.temp > 0) {
|
||||
return plot.temp;
|
||||
@ -1625,17 +1626,17 @@ public class SQLManager implements AbstractDB {
|
||||
/*
|
||||
* Getting plots
|
||||
*/
|
||||
Statement stmt = this.connection.createStatement();
|
||||
Statement statement = this.connection.createStatement();
|
||||
int id;
|
||||
String o;
|
||||
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`")) {
|
||||
ArrayList<Integer> toDelete = new ArrayList<>();
|
||||
while (r.next()) {
|
||||
PlotId plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z"));
|
||||
id = r.getInt("id");
|
||||
String areaid = r.getString("world");
|
||||
while (resultSet.next()) {
|
||||
PlotId plot_id = new PlotId(resultSet.getInt("plot_id_x"), resultSet.getInt("plot_id_z"));
|
||||
id = resultSet.getInt("id");
|
||||
String areaid = resultSet.getString("world");
|
||||
if (!areas.contains(areaid)) {
|
||||
if (Settings.AUTO_PURGE) {
|
||||
toDelete.add(id);
|
||||
@ -1649,13 +1650,13 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
}
|
||||
}
|
||||
o = r.getString("owner");
|
||||
o = resultSet.getString("owner");
|
||||
user = uuids.get(o);
|
||||
if (user == null) {
|
||||
user = UUID.fromString(o);
|
||||
uuids.put(o, user);
|
||||
}
|
||||
Timestamp timestamp = r.getTimestamp("timestamp");
|
||||
Timestamp timestamp = resultSet.getTimestamp("timestamp");
|
||||
long time = timestamp.getTime();
|
||||
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);
|
||||
@ -1682,7 +1683,7 @@ public class SQLManager implements AbstractDB {
|
||||
deleteRows(toDelete, this.prefix + "plot", "id");
|
||||
}
|
||||
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<>();
|
||||
while (r.next()) {
|
||||
id = r.getInt("plot_plot_id");
|
||||
@ -1709,7 +1710,7 @@ public class SQLManager implements AbstractDB {
|
||||
/*
|
||||
* 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<>();
|
||||
while (r.next()) {
|
||||
id = r.getInt("plot_plot_id");
|
||||
@ -1735,7 +1736,7 @@ public class SQLManager implements AbstractDB {
|
||||
/*
|
||||
* 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<>();
|
||||
while (r.next()) {
|
||||
id = r.getInt("plot_plot_id");
|
||||
@ -1761,7 +1762,7 @@ public class SQLManager implements AbstractDB {
|
||||
/*
|
||||
* 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<>();
|
||||
while (r.next()) {
|
||||
id = r.getInt("plot_plot_id");
|
||||
@ -1783,7 +1784,7 @@ public class SQLManager implements AbstractDB {
|
||||
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<>();
|
||||
while (r.next()) {
|
||||
id = r.getInt("plot_plot_id");
|
||||
@ -1860,7 +1861,7 @@ public class SQLManager implements AbstractDB {
|
||||
+ ".yml.");
|
||||
}
|
||||
}
|
||||
stmt.close();
|
||||
statement.close();
|
||||
deleteRows(toDelete, this.prefix + "plot_settings", "plot_plot_id");
|
||||
}
|
||||
if (!plots.entrySet().isEmpty()) {
|
||||
@ -2012,7 +2013,7 @@ public class SQLManager implements AbstractDB {
|
||||
stmt_prefix = " OR `id` = ";
|
||||
}
|
||||
stmt_prefix = "";
|
||||
StringBuilder idstr = new StringBuilder("");
|
||||
StringBuilder idstr = new StringBuilder();
|
||||
for (Integer id : uniqueIds) {
|
||||
idstr.append(stmt_prefix).append(id);
|
||||
stmt_prefix = " OR `plot_plot_id` = ";
|
||||
@ -3146,7 +3147,7 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
public abstract class UniqueStatement {
|
||||
|
||||
public String method;
|
||||
public final String method;
|
||||
|
||||
public UniqueStatement(String method) {
|
||||
this.method = method;
|
||||
|
@ -6,6 +6,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class Flag<T> implements Cloneable {
|
||||
|
||||
private AbstractFlag key;
|
||||
private Object value;
|
||||
private String name;
|
||||
@ -33,7 +34,7 @@ public class Flag<T> implements Cloneable {
|
||||
throw new IllegalArgumentException(key.getValueDesc() + " (" + value + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Warning: Unchecked
|
||||
* @param key
|
||||
@ -47,7 +48,7 @@ public class Flag<T> implements Cloneable {
|
||||
public Flag(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the AbstractFlag used in creating the flag.
|
||||
*
|
||||
@ -56,7 +57,7 @@ public class Flag<T> implements Cloneable {
|
||||
public AbstractFlag getAbstractFlag() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the key for the AbstractFlag.
|
||||
*
|
||||
@ -81,11 +82,11 @@ public class Flag<T> implements Cloneable {
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
|
||||
public String getValueString() {
|
||||
return this.key.toString(this.value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if ("".equals(this.value)) {
|
||||
@ -93,7 +94,7 @@ public class Flag<T> implements Cloneable {
|
||||
}
|
||||
return this.key + ":" + getValueString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
@ -108,12 +109,12 @@ public class Flag<T> implements Cloneable {
|
||||
Flag other = (Flag) obj;
|
||||
return this.key.getKey().equals(other.key.getKey()) && this.value.equals(other.value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.key.getKey().hashCode();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Object clone() {
|
||||
try {
|
||||
@ -128,7 +129,8 @@ public class Flag<T> implements Cloneable {
|
||||
return new Flag(this.key, method.invoke(this.value));
|
||||
}
|
||||
return new Flag(this.key, this.key.parseValueRaw(this.key.toString(this.value)));
|
||||
} catch (CloneNotSupportedException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | InvocationTargetException e) {
|
||||
} catch (CloneNotSupportedException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException |
|
||||
InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return this;
|
||||
|
@ -26,6 +26,10 @@ import java.util.Set;
|
||||
*/
|
||||
public class FlagManager {
|
||||
|
||||
//TODO Default Flags
|
||||
public static final IntegerFlag MUSIC = new IntegerFlag("music");
|
||||
|
||||
|
||||
private static final HashSet<String> reserved = new HashSet<>();
|
||||
|
||||
private static final HashSet<AbstractFlag> flags = new HashSet<>();
|
||||
|
@ -0,0 +1,8 @@
|
||||
package com.intellectualcrafters.plot.flag;
|
||||
|
||||
public class IntegerFlag extends Flag<Integer> {
|
||||
|
||||
public IntegerFlag(String name) {
|
||||
super(name);
|
||||
}
|
||||
}
|
@ -34,18 +34,18 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
|
||||
@Override
|
||||
public ConfigurationNode[] getSettingNodes() {
|
||||
return new ConfigurationNode[] {
|
||||
new ConfigurationNode("plot.height", this.PLOT_HEIGHT, "Plot height", Configuration.INTEGER, true),
|
||||
new ConfigurationNode("plot.size", this.PLOT_WIDTH, "Plot width", Configuration.INTEGER, true),
|
||||
new ConfigurationNode("plot.filling", this.MAIN_BLOCK, "Plot block", Configuration.BLOCKLIST, true),
|
||||
new ConfigurationNode("plot.floor", this.TOP_BLOCK, "Plot floor block", Configuration.BLOCKLIST, true),
|
||||
new ConfigurationNode("wall.block", this.WALL_BLOCK, "Top wall block", Configuration.BLOCK, true),
|
||||
new ConfigurationNode("wall.block_claimed", this.CLAIMED_WALL_BLOCK, "Wall block (claimed)", Configuration.BLOCK, true),
|
||||
new ConfigurationNode("road.width", this.ROAD_WIDTH, "Road width", Configuration.INTEGER, true),
|
||||
new ConfigurationNode("road.height", this.ROAD_HEIGHT, "Road height", Configuration.INTEGER, true),
|
||||
new ConfigurationNode("road.block", this.ROAD_BLOCK, "Road block", Configuration.BLOCK, true),
|
||||
new ConfigurationNode("wall.filling", this.WALL_FILLING, "Wall filling block", Configuration.BLOCK, true),
|
||||
new ConfigurationNode("wall.height", this.WALL_HEIGHT, "Wall height", Configuration.INTEGER, true),
|
||||
new ConfigurationNode("plot.bedrock", this.PLOT_BEDROCK, "Plot bedrock generation", Configuration.BOOLEAN, true)};
|
||||
new ConfigurationNode("plot.height", this.PLOT_HEIGHT, "Plot height", Configuration.INTEGER),
|
||||
new ConfigurationNode("plot.size", this.PLOT_WIDTH, "Plot width", Configuration.INTEGER),
|
||||
new ConfigurationNode("plot.filling", this.MAIN_BLOCK, "Plot block", Configuration.BLOCKLIST),
|
||||
new ConfigurationNode("plot.floor", this.TOP_BLOCK, "Plot floor block", Configuration.BLOCKLIST),
|
||||
new ConfigurationNode("wall.block", this.WALL_BLOCK, "Top wall block", Configuration.BLOCK),
|
||||
new ConfigurationNode("wall.block_claimed", this.CLAIMED_WALL_BLOCK, "Wall block (claimed)", Configuration.BLOCK),
|
||||
new ConfigurationNode("road.width", this.ROAD_WIDTH, "Road width", Configuration.INTEGER),
|
||||
new ConfigurationNode("road.height", this.ROAD_HEIGHT, "Road height", Configuration.INTEGER),
|
||||
new ConfigurationNode("road.block", this.ROAD_BLOCK, "Road block", Configuration.BLOCK),
|
||||
new ConfigurationNode("wall.filling", this.WALL_FILLING, "Wall filling block", Configuration.BLOCK),
|
||||
new ConfigurationNode("wall.height", this.WALL_HEIGHT, "Wall height", Configuration.INTEGER),
|
||||
new ConfigurationNode("plot.bedrock", this.PLOT_BEDROCK, "Plot bedrock generation", Configuration.BOOLEAN)};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,6 +13,7 @@ import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Dimension;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -163,11 +164,11 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompatible(PlotArea plotworld) {
|
||||
if (!(plotworld instanceof SquarePlotWorld)) {
|
||||
public boolean isCompatible(PlotArea plotArea) {
|
||||
if (!(plotArea instanceof SquarePlotWorld)) {
|
||||
return false;
|
||||
}
|
||||
return ((SquarePlotWorld) plotworld).PLOT_WIDTH == this.PLOT_WIDTH;
|
||||
return ((SquarePlotWorld) plotArea).PLOT_WIDTH == this.PLOT_WIDTH;
|
||||
}
|
||||
|
||||
public void setupSchematics() {
|
||||
@ -213,7 +214,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
}
|
||||
}
|
||||
HashMap<BlockLoc, CompoundTag> items = schematic3.getTiles();
|
||||
if (items.size() > 0) {
|
||||
if (!items.isEmpty()) {
|
||||
this.G_SCH_STATE = new HashMap<>();
|
||||
for (Map.Entry<BlockLoc, CompoundTag> entry : items.entrySet()) {
|
||||
BlockLoc loc = entry.getKey();
|
||||
|
@ -9,8 +9,8 @@ import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.util.PlotChunk;
|
||||
|
||||
/**
|
||||
* This class allows for implementation independent world generation<br>
|
||||
* - Sponge/Bukkit API<br><br>
|
||||
* This class allows for implementation independent world generation.
|
||||
* - Sponge/Bukkit API
|
||||
* Use the specify method to get the generator for that platform.
|
||||
*/
|
||||
public abstract class IndependentPlotGenerator {
|
||||
|
@ -7,7 +7,7 @@ import com.intellectualcrafters.plot.object.SetupObject;
|
||||
|
||||
public abstract class PlotGenerator<T> {
|
||||
|
||||
public T generator;
|
||||
public final T generator;
|
||||
|
||||
public PlotGenerator(T generator) {
|
||||
this.generator = generator;
|
||||
|
@ -39,10 +39,6 @@ public class ConsolePlayer extends PlotPlayer {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static boolean isConsole(PlotPlayer plr) {
|
||||
return plr instanceof ConsolePlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPreviousLogin() {
|
||||
return 0;
|
||||
@ -133,7 +129,7 @@ public class ConsolePlayer extends PlotPlayer {
|
||||
|
||||
@Override
|
||||
public PlotGameMode getGameMode() {
|
||||
return PlotGameMode.CREATIVE;
|
||||
return PlotGameMode.NOT_SET;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,11 +3,6 @@ package com.intellectualcrafters.plot.object;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
|
||||
/**
|
||||
* Created 2015-02-11 for PlotSquared
|
||||
*
|
||||
|
||||
*/
|
||||
public class Location implements Cloneable, Comparable<Location> {
|
||||
|
||||
private int x;
|
||||
@ -27,7 +22,7 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
}
|
||||
|
||||
public Location() {
|
||||
this("", 0, 0, 0, 0, 0);
|
||||
this.world = "";
|
||||
}
|
||||
|
||||
public Location(String world, int x, int y, int z) {
|
||||
|
@ -20,6 +20,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.PathIterator;
|
||||
@ -765,8 +766,8 @@ public class Plot {
|
||||
@Override
|
||||
public void run() {
|
||||
if (queue.isEmpty()) {
|
||||
final AtomicInteger finished = new AtomicInteger(0);
|
||||
final Runnable run = new Runnable() {
|
||||
AtomicInteger finished = new AtomicInteger(0);
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (RegionWrapper region : regions) {
|
||||
@ -794,11 +795,11 @@ public class Plot {
|
||||
manager.clearPlot(Plot.this.area, current, this);
|
||||
}
|
||||
};
|
||||
if (!isMerged() && area.getRegion().equals(getLargestRegion())) {
|
||||
ChunkManager.largeRegionTask(area.worldname, area.getRegion(), new RunnableVal<ChunkLoc>() {
|
||||
if (!isMerged() && this.area.getRegion().equals(getLargestRegion())) {
|
||||
ChunkManager.largeRegionTask(this.area.worldname, this.area.getRegion(), new RunnableVal<ChunkLoc>() {
|
||||
@Override
|
||||
public void run(ChunkLoc value) {
|
||||
ChunkManager.manager.regenerateChunk(area.worldname, value);
|
||||
ChunkManager.manager.regenerateChunk(Plot.this.area.worldname, value);
|
||||
}
|
||||
}, whenDone);
|
||||
} else {
|
||||
@ -1773,7 +1774,7 @@ public class Plot {
|
||||
* Upload this plot as a world file<br>
|
||||
* - The mca files are each 512x512, so depending on the plot size it may also download adjacent plots<br>
|
||||
* - Works best when (plot width + road width) % 512 == 0<br>
|
||||
* @see com.intellectualcrafters.plot.util.WorldUtil
|
||||
* @see WorldUtil
|
||||
* @param whenDone
|
||||
*/
|
||||
public void uploadWorld(RunnableVal<URL> whenDone) {
|
||||
@ -1784,7 +1785,7 @@ public class Plot {
|
||||
* Upload this plot as a BO3<br>
|
||||
* - May not work on non default generator<br>
|
||||
* - BO3 includes flags/ignores plot main/floor block<br>
|
||||
* @see com.intellectualcrafters.plot.util.BO3Handler
|
||||
* @see BO3Handler
|
||||
* @param whenDone
|
||||
*/
|
||||
public void uploadBO3(RunnableVal<URL> whenDone) {
|
||||
@ -1991,8 +1992,6 @@ public class Plot {
|
||||
int index = caption.indexOf("%plr%");
|
||||
if (index == -1) {
|
||||
continue;
|
||||
} else if (index < -1) {
|
||||
PS.debug("This should NEVER happen. Seriously, it's impossible.");
|
||||
}
|
||||
String line = lines[i - 1];
|
||||
if (line.length() <= index) {
|
||||
@ -2487,7 +2486,7 @@ public class Plot {
|
||||
RegionWrapper max = null;
|
||||
double area = Double.NEGATIVE_INFINITY;
|
||||
for (RegionWrapper region : regions) {
|
||||
double current = ((region.maxX - (double) region.minX + 1)) * (region.maxZ - (double) region.minZ + 1);
|
||||
double current = (region.maxX - (double) region.minX + 1) * (region.maxZ - (double) region.minZ + 1);
|
||||
if (current > area) {
|
||||
max = region;
|
||||
area = current;
|
||||
|
@ -19,7 +19,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class PlotAnalysis {
|
||||
|
||||
public static PlotAnalysis MODIFIERS = new PlotAnalysis();
|
||||
public static final PlotAnalysis MODIFIERS = new PlotAnalysis();
|
||||
public static boolean running = false;
|
||||
public int changes;
|
||||
public int faces;
|
||||
|
@ -67,7 +67,7 @@ public abstract class PlotArea {
|
||||
public int MAX_BUILD_HEIGHT = 256;
|
||||
public int MIN_BUILD_HEIGHT = 1;
|
||||
public PlotGameMode GAMEMODE = PlotGameMode.CREATIVE;
|
||||
int hash;
|
||||
private int hash;
|
||||
private RegionWrapper region;
|
||||
private ConcurrentHashMap<String, Object> meta;
|
||||
private QuadMap<PlotCluster> clusters;
|
||||
@ -91,7 +91,7 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new PlotArea object with no functionality/information<br>
|
||||
* Create a new PlotArea object with no functionality/information.
|
||||
* - Mainly used during startup before worlds are created as a temporary object
|
||||
* @param world
|
||||
* @return
|
||||
@ -106,8 +106,9 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the region for this PlotArea or a RegionWrapper encompassing the whole world if none exists
|
||||
* @NotNull
|
||||
* Returns the region for this PlotArea or a RegionWrapper encompassing
|
||||
* the whole world if none exists.
|
||||
*
|
||||
* @return RegionWrapper
|
||||
*/
|
||||
public RegionWrapper getRegion() {
|
||||
@ -119,7 +120,7 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the region for this PlotArea
|
||||
* Returns the region for this PlotArea.
|
||||
*
|
||||
* @return RegionWrapper or null if no applicable region
|
||||
*/
|
||||
@ -135,7 +136,7 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the min PlotId
|
||||
* Returns the min PlotId.
|
||||
* @return
|
||||
*/
|
||||
public PlotId getMin() {
|
||||
@ -143,7 +144,7 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the max PlotId
|
||||
* Returns the max PlotId.
|
||||
* @return
|
||||
*/
|
||||
public PlotId getMax() {
|
||||
@ -151,7 +152,7 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the implementation independent generator for this area
|
||||
* Get the implementation independent generator for this area.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ -179,14 +180,14 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a PlotArea is compatible (move/copy etc)
|
||||
* @param plotarea
|
||||
* Check if a PlotArea is compatible (move/copy etc).
|
||||
* @param plotArea
|
||||
* @return
|
||||
*/
|
||||
public boolean isCompatible(PlotArea plotarea) {
|
||||
public boolean isCompatible(PlotArea plotArea) {
|
||||
ConfigurationSection section = PS.get().config.getConfigurationSection("worlds");
|
||||
for (ConfigurationNode setting : plotarea.getSettingNodes()) {
|
||||
Object constant = section.get(plotarea.worldname + "." + setting.getConstant());
|
||||
for (ConfigurationNode setting : plotArea.getSettingNodes()) {
|
||||
Object constant = section.get(plotArea.worldname + "." + setting.getConstant());
|
||||
if (constant == null) {
|
||||
return false;
|
||||
}
|
||||
@ -198,7 +199,7 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
/**
|
||||
* When a world is created, the following method will be called for each
|
||||
* When a world is created, the following method will be called for each.
|
||||
*
|
||||
* @param config Configuration Section
|
||||
*/
|
||||
@ -358,7 +359,11 @@ public abstract class PlotArea {
|
||||
|
||||
@Override
|
||||
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
|
||||
|
@ -17,7 +17,7 @@ public class PlotId {
|
||||
* @param x The plot x 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.y = y;
|
||||
}
|
||||
@ -29,11 +29,11 @@ public class PlotId {
|
||||
*
|
||||
* @return null if the string is invalid
|
||||
*/
|
||||
public static PlotId fromString(final String string) {
|
||||
public static PlotId fromString(String string) {
|
||||
if (string == null) {
|
||||
return null;
|
||||
}
|
||||
final String[] parts = string.split(";");
|
||||
String[] parts = string.split(";");
|
||||
if (parts.length < 2) {
|
||||
return null;
|
||||
}
|
||||
@ -42,7 +42,7 @@ public class PlotId {
|
||||
try {
|
||||
x = Integer.parseInt(parts[0]);
|
||||
y = Integer.parseInt(parts[1]);
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
return new PlotId(x, y);
|
||||
@ -67,7 +67,7 @@ public class PlotId {
|
||||
* @param direction
|
||||
* @return PlotId
|
||||
*/
|
||||
public PlotId getRelative(final int direction) {
|
||||
public PlotId getRelative(int direction) {
|
||||
switch (direction) {
|
||||
case 0:
|
||||
return new PlotId(this.x, this.y - 1);
|
||||
@ -92,7 +92,7 @@ public class PlotId {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
@ -105,8 +105,8 @@ public class PlotId {
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final PlotId other = (PlotId) obj;
|
||||
return x == other.x && y == other.y;
|
||||
PlotId other = (PlotId) obj;
|
||||
return this.x == other.x && this.y == other.y;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,7 +116,7 @@ public class PlotId {
|
||||
*/
|
||||
@Override
|
||||
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
|
||||
*/
|
||||
public void recalculateHash() {
|
||||
hash = 0;
|
||||
this.hash = 0;
|
||||
hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (hash == 0) {
|
||||
hash = (x << 16) | (y & 0xFFFF);
|
||||
if (this.hash == 0) {
|
||||
this.hash = (this.x << 16) | (this.y & 0xFFFF);
|
||||
}
|
||||
return hash;
|
||||
return this.hash;
|
||||
}
|
||||
}
|
||||
|
@ -3,28 +3,28 @@ package com.intellectualcrafters.plot.object;
|
||||
public class PlotLoc {
|
||||
public int x;
|
||||
public int z;
|
||||
|
||||
public PlotLoc(final int x, final int z) {
|
||||
|
||||
public PlotLoc(int x, int z) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int prime = 31;
|
||||
int result = 1;
|
||||
result = (prime * result) + x;
|
||||
result = (prime * result) + z;
|
||||
result = (prime * result) + this.x;
|
||||
result = (prime * result) + this.z;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return x + "," + z;
|
||||
return this.x + "," + this.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
@ -34,7 +34,7 @@ public class PlotLoc {
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final PlotLoc other = (PlotLoc) obj;
|
||||
return ((x == other.x) && (z == other.z));
|
||||
PlotLoc other = (PlotLoc) obj;
|
||||
return (this.x == other.x) && (this.z == other.z);
|
||||
}
|
||||
}
|
||||
|
@ -10,50 +10,50 @@ public class PlotMessage {
|
||||
public PlotMessage() {
|
||||
reset(ChatManager.manager);
|
||||
}
|
||||
|
||||
public <T> T $(final ChatManager<T> manager) {
|
||||
return (T) builder;
|
||||
}
|
||||
|
||||
public PlotMessage(final String text) {
|
||||
|
||||
public PlotMessage(String text) {
|
||||
this();
|
||||
text(text);
|
||||
}
|
||||
|
||||
public <T> T reset(ChatManager<T> manager) {
|
||||
return (T) (builder = manager.builder());
|
||||
public <T> T $(ChatManager<T> manager) {
|
||||
return (T) this.builder;
|
||||
}
|
||||
|
||||
public PlotMessage text(final String text) {
|
||||
|
||||
public <T> T reset(ChatManager<T> manager) {
|
||||
return (T) (this.builder = manager.builder());
|
||||
}
|
||||
|
||||
public PlotMessage text(String text) {
|
||||
ChatManager.manager.text(this, text);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PlotMessage tooltip(final PlotMessage... tooltip) {
|
||||
|
||||
public PlotMessage tooltip(PlotMessage... tooltip) {
|
||||
ChatManager.manager.tooltip(this, tooltip);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PlotMessage tooltip(final String tooltip) {
|
||||
|
||||
public PlotMessage tooltip(String tooltip) {
|
||||
return tooltip(new PlotMessage(tooltip));
|
||||
}
|
||||
|
||||
public PlotMessage command(final String command) {
|
||||
|
||||
public PlotMessage command(String command) {
|
||||
ChatManager.manager.command(this, command);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PlotMessage suggest(final String command) {
|
||||
|
||||
public PlotMessage suggest(String command) {
|
||||
ChatManager.manager.suggest(this, command);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PlotMessage color(final String color) {
|
||||
|
||||
public PlotMessage color(String color) {
|
||||
ChatManager.manager.color(this, C.color(color));
|
||||
return this;
|
||||
}
|
||||
|
||||
public void send(final PlotPlayer player) {
|
||||
|
||||
public void send(PlotPlayer player) {
|
||||
ChatManager.manager.send(this, player);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||
@ -151,17 +152,17 @@ public class PlotSettings {
|
||||
return "";
|
||||
}
|
||||
|
||||
public ArrayList<PlotComment> getComments(String inbox) {
|
||||
public Optional<ArrayList<PlotComment>> getComments(String inbox) {
|
||||
ArrayList<PlotComment> c = new ArrayList<>();
|
||||
if (this.comments == null) {
|
||||
return null;
|
||||
return Optional.absent();
|
||||
}
|
||||
for (PlotComment comment : this.comments) {
|
||||
if (comment.inbox.equals(inbox)) {
|
||||
c.add(comment);
|
||||
}
|
||||
}
|
||||
return c;
|
||||
return Optional.of(c);
|
||||
}
|
||||
|
||||
public void setComments(List<PlotComment> comments) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.intellectualcrafters.plot.object.comment;
|
||||
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
@ -18,7 +19,7 @@ public abstract class CommentInbox {
|
||||
public abstract boolean canModify(Plot plot, PlotPlayer player);
|
||||
|
||||
/**
|
||||
* The plot may be null if the user is not standing in a plot. Return false if this is not a plot-less inbox.
|
||||
*
|
||||
* <br>
|
||||
* The `whenDone` parameter should be executed when it's done fetching the comments.
|
||||
* The value should be set to List of comments
|
||||
@ -31,7 +32,11 @@ public abstract class CommentInbox {
|
||||
|
||||
public abstract boolean addComment(Plot plot, PlotComment comment);
|
||||
|
||||
public abstract boolean removeComment(Plot plot, PlotComment comment);
|
||||
public void removeComment(Plot plot, PlotComment comment) {
|
||||
DBFunc.removeComment(plot, comment);
|
||||
}
|
||||
|
||||
public abstract boolean clearInbox(Plot plot);
|
||||
public void clearInbox(Plot plot) {
|
||||
DBFunc.clearInbox(plot, toString());
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.intellectualcrafters.plot.object.comment;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
@ -11,48 +12,41 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InboxOwner extends CommentInbox {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canRead(Plot plot, PlotPlayer player) {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(player, "plots.inbox.read." + toString());
|
||||
if (Permissions.hasPermission(player, "plots.inbox.read." + toString())) {
|
||||
if (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.read." + toString() + ".other")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, "plots.inbox.read."
|
||||
+ toString()
|
||||
+ ".other"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canWrite(Plot plot, PlotPlayer player) {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(player, "plots.inbox.write." + toString());
|
||||
}
|
||||
return Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, "plots.inbox.write."
|
||||
+ toString()
|
||||
+ ".other"));
|
||||
.hasPermission(player, "plots.inbox.write." + toString() + ".other"));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canModify(Plot plot, PlotPlayer player) {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(player, "plots.inbox.modify." + toString());
|
||||
if (Permissions.hasPermission(player, "plots.inbox.modify." + toString())) {
|
||||
if (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.modify." + toString() + ".other")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, "plots.inbox.modify."
|
||||
+ toString()
|
||||
+ ".other"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getComments(final Plot plot, final RunnableVal whenDone) {
|
||||
if ((plot == null) || (plot.owner == null)) {
|
||||
return false;
|
||||
}
|
||||
ArrayList<PlotComment> comments = plot.getSettings().getComments(toString());
|
||||
if (comments != null) {
|
||||
whenDone.value = comments;
|
||||
public boolean getComments(final Plot plot, final RunnableVal<List<PlotComment>> whenDone) {
|
||||
Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(toString());
|
||||
if (comments.isPresent()) {
|
||||
whenDone.value = comments.get();
|
||||
TaskManager.runTask(whenDone);
|
||||
return true;
|
||||
}
|
||||
@ -72,37 +66,20 @@ public class InboxOwner extends CommentInbox {
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean addComment(Plot plot, PlotComment comment) {
|
||||
if ((plot == null) || (plot.owner == null)) {
|
||||
if (plot.owner == null) {
|
||||
return false;
|
||||
}
|
||||
plot.getSettings().addComment(comment);
|
||||
DBFunc.setComment(plot, comment);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "owner";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeComment(Plot plot, PlotComment comment) {
|
||||
if ((plot == null) || (plot.owner == null)) {
|
||||
return false;
|
||||
}
|
||||
DBFunc.removeComment(plot, comment);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean clearInbox(Plot plot) {
|
||||
if (plot == null || plot.owner == null) {
|
||||
return false;
|
||||
}
|
||||
DBFunc.clearInbox(plot, this.toString());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.intellectualcrafters.plot.object.comment;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
@ -14,13 +15,12 @@ public class InboxPublic extends CommentInbox {
|
||||
|
||||
@Override
|
||||
public boolean canRead(Plot plot, PlotPlayer player) {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(player, "plots.inbox.read." + toString());
|
||||
if (Permissions.hasPermission(player, "plots.inbox.read." + toString())) {
|
||||
if (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.read." + toString() + ".other")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, "plots.inbox.read."
|
||||
+ toString()
|
||||
+ ".other"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -34,21 +34,19 @@ public class InboxPublic extends CommentInbox {
|
||||
|
||||
@Override
|
||||
public boolean canModify(Plot plot, PlotPlayer player) {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(player, "plots.inbox.modify." + toString());
|
||||
if (Permissions.hasPermission(player, "plots.inbox.modify." + toString())) {
|
||||
if (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.modify." + toString() + ".other")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, "plots.inbox.modify." + toString() + ".other"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getComments(final Plot plot, final RunnableVal whenDone) {
|
||||
if ((plot == null) || (plot.owner == null)) {
|
||||
return false;
|
||||
}
|
||||
ArrayList<PlotComment> comments = plot.getSettings().getComments(toString());
|
||||
if (comments != null) {
|
||||
whenDone.value = comments;
|
||||
public boolean getComments(final Plot plot, final RunnableVal<List<PlotComment>> whenDone) {
|
||||
Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(toString());
|
||||
if (comments.isPresent()) {
|
||||
whenDone.value = comments.get();
|
||||
TaskManager.runTask(whenDone);
|
||||
return true;
|
||||
}
|
||||
@ -69,9 +67,6 @@ public class InboxPublic extends CommentInbox {
|
||||
|
||||
@Override
|
||||
public boolean addComment(Plot plot, PlotComment comment) {
|
||||
if ((plot == null) || (plot.owner == null)) {
|
||||
return false;
|
||||
}
|
||||
plot.getSettings().addComment(comment);
|
||||
DBFunc.setComment(plot, comment);
|
||||
return true;
|
||||
@ -81,22 +76,6 @@ public class InboxPublic extends CommentInbox {
|
||||
public String toString() {
|
||||
return "public";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeComment(Plot plot, PlotComment comment) {
|
||||
if ((plot == null) || (plot.owner == null)) {
|
||||
return false;
|
||||
}
|
||||
DBFunc.removeComment(plot, comment);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean clearInbox(Plot plot) {
|
||||
if (plot == null || plot.owner == null) {
|
||||
return false;
|
||||
}
|
||||
DBFunc.clearInbox(plot, this.toString());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -13,11 +13,13 @@ public class InboxReport extends CommentInbox {
|
||||
|
||||
@Override
|
||||
public boolean canRead(Plot plot, PlotPlayer player) {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(player, "plots.inbox.read." + toString());
|
||||
if (Permissions.hasPermission(player, "plots.inbox.read." + toString())) {
|
||||
if (plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, "plots.inbox.read." + toString() + ".other")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, "plots.inbox.read." + toString() + ".other"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -31,15 +33,16 @@ public class InboxReport extends CommentInbox {
|
||||
|
||||
@Override
|
||||
public boolean canModify(Plot plot, PlotPlayer player) {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(player, "plots.inbox.modify." + toString());
|
||||
if (Permissions.hasPermission(player, "plots.inbox.modify." + toString())) {
|
||||
if (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.modify." + toString() + ".other")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, "plots.inbox.modify." + toString() + ".other"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
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>>() {
|
||||
@Override
|
||||
public void run(List<PlotComment> value) {
|
||||
@ -52,7 +55,7 @@ public class InboxReport extends CommentInbox {
|
||||
|
||||
@Override
|
||||
public boolean addComment(Plot plot, PlotComment comment) {
|
||||
if ((plot == null) || (plot.owner == null)) {
|
||||
if (plot.owner == null) {
|
||||
return false;
|
||||
}
|
||||
DBFunc.setComment(plot, comment);
|
||||
@ -64,21 +67,4 @@ public class InboxReport extends CommentInbox {
|
||||
return "report";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeComment(Plot plot, PlotComment comment) {
|
||||
if (plot == null || plot.owner == null) {
|
||||
return false;
|
||||
}
|
||||
DBFunc.removeComment(plot, comment);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean clearInbox(Plot plot) {
|
||||
if (plot == null || plot.owner == null) {
|
||||
return false;
|
||||
}
|
||||
DBFunc.clearInbox(plot, this.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
package com.intellectualcrafters.plot.object.schematic;
|
||||
|
||||
public class PlotItem {
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
public short[] id;
|
||||
public byte[] data;
|
||||
public byte[] amount;
|
||||
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int z;
|
||||
public final short[] id;
|
||||
public final byte[] data;
|
||||
public final byte[] amount;
|
||||
|
||||
public PlotItem(short x, short y, short z, short[] id, byte[] data, byte[] amount) {
|
||||
this.x = x;
|
||||
|
@ -7,7 +7,7 @@ public abstract class AbstractTitle {
|
||||
public static AbstractTitle TITLE_CLASS;
|
||||
|
||||
public static void sendTitle(PlotPlayer player, String head, String sub) {
|
||||
if (ConsolePlayer.isConsole(player)) {
|
||||
if (player instanceof ConsolePlayer) {
|
||||
return;
|
||||
}
|
||||
if (TITLE_CLASS != null && !player.getAttribute("disabletitles")) {
|
||||
|
@ -7,16 +7,16 @@ public abstract class ChatManager<T> {
|
||||
public static ChatManager<?> manager;
|
||||
|
||||
public abstract T builder();
|
||||
|
||||
public abstract void color(final PlotMessage message, final String color);
|
||||
|
||||
public abstract void tooltip(final PlotMessage message, final PlotMessage... tooltip);
|
||||
|
||||
public abstract void command(final PlotMessage message, final String command);
|
||||
|
||||
public abstract void text(final PlotMessage message, final String text);
|
||||
|
||||
public abstract void send(final PlotMessage plotMessage, final PlotPlayer player);
|
||||
|
||||
public abstract void suggest(final PlotMessage plotMessage, final String command);
|
||||
|
||||
public abstract void color(PlotMessage message, String color);
|
||||
|
||||
public abstract void tooltip(PlotMessage message, PlotMessage... tooltip);
|
||||
|
||||
public abstract void command(PlotMessage message, String command);
|
||||
|
||||
public abstract void text(PlotMessage message, String text);
|
||||
|
||||
public abstract void send(PlotMessage plotMessage, PlotPlayer player);
|
||||
|
||||
public abstract void suggest(PlotMessage plotMessage, String command);
|
||||
}
|
||||
|
@ -2,13 +2,13 @@ package com.intellectualcrafters.plot.util;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -114,7 +114,7 @@ public abstract class ChunkManager {
|
||||
Runnable smallTask = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (regions.size() == 0) {
|
||||
if (regions.isEmpty()) {
|
||||
TaskManager.runTask(whenDone);
|
||||
return;
|
||||
}
|
||||
@ -254,7 +254,7 @@ public abstract class ChunkManager {
|
||||
for (ChunkLoc loc : chunks) {
|
||||
String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca";
|
||||
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()) {
|
||||
file.delete();
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class CommentManager {
|
||||
|
||||
public static HashMap<String, CommentInbox> inboxes = new HashMap<>();
|
||||
public static final HashMap<String, CommentInbox> inboxes = new HashMap<>();
|
||||
|
||||
public static void sendTitle(final PlotPlayer player, final Plot plot) {
|
||||
if (!Settings.COMMENT_NOTIFICATIONS || !plot.isOwner(player.getUUID())) {
|
||||
|
@ -19,7 +19,7 @@ public abstract class EconHandler {
|
||||
}
|
||||
|
||||
public double getMoney(PlotPlayer player) {
|
||||
if (ConsolePlayer.isConsole(player)) {
|
||||
if (player instanceof ConsolePlayer) {
|
||||
return Double.MAX_VALUE;
|
||||
}
|
||||
return getBalance(player);
|
||||
|
@ -15,6 +15,7 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.Rating;
|
||||
import com.plotsquared.listener.PlayerBlockEventType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
@ -36,6 +36,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
/**
|
||||
@ -601,7 +602,8 @@ public class MainUtil {
|
||||
public static boolean sendMessage(PlotPlayer player, String msg, boolean prefix) {
|
||||
if (!msg.isEmpty()) {
|
||||
if (player == null) {
|
||||
ConsolePlayer.getConsole().sendMessage((prefix ? C.PREFIX.s() : "") + msg);
|
||||
String message = (prefix ? C.PREFIX.s() : "") + msg;
|
||||
PS.log(message);
|
||||
} else {
|
||||
player.sendMessage((prefix ? C.PREFIX.s() : "") + C.color(msg));
|
||||
}
|
||||
@ -638,7 +640,7 @@ public class MainUtil {
|
||||
public void run() {
|
||||
String m = C.format(c, args);
|
||||
if (plr == null) {
|
||||
ConsolePlayer.getConsole().sendMessage(m);
|
||||
PS.log(m);
|
||||
} else {
|
||||
plr.sendMessage(m);
|
||||
}
|
||||
@ -703,7 +705,32 @@ public class MainUtil {
|
||||
String trusted = getPlayerList(plot.getTrusted());
|
||||
String members = getPlayerList(plot.getMembers());
|
||||
String denied = getPlayerList(plot.getDenied());
|
||||
|
||||
String expires = C.UNKNOWN.s();
|
||||
if (Settings.AUTO_CLEAR) {
|
||||
if (plot.hasOwner()) {
|
||||
Flag keep = plot.getFlag("keep");
|
||||
if (keep != null) {
|
||||
Object value = keep.getValue();
|
||||
if (value instanceof Boolean) {
|
||||
if (Boolean.TRUE.equals(value)) {
|
||||
expires = C.NONE.s();
|
||||
}
|
||||
} else if (value instanceof Long) {
|
||||
if ((Long) value > System.currentTimeMillis()) {
|
||||
long l = System.currentTimeMillis() - (long) value;
|
||||
expires = String.format("%d days", TimeUnit.MILLISECONDS.toDays(l));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
long timestamp = ExpireManager.IMP.getTimestamp(plot.owner);
|
||||
long compared = System.currentTimeMillis() - timestamp;
|
||||
long l = Settings.AUTO_CLEAR_DAYS - TimeUnit.MILLISECONDS.toDays(compared);
|
||||
expires = String.format("%d days", l);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
expires = C.NEVER.s();
|
||||
}
|
||||
Flag descriptionFlag = FlagManager.getPlotFlagRaw(plot, "description");
|
||||
String description = descriptionFlag == null ? C.NONE.s() : descriptionFlag.getValueString();
|
||||
|
||||
@ -729,6 +756,7 @@ public class MainUtil {
|
||||
info = info.replaceAll("%trusted%", trusted);
|
||||
info = info.replaceAll("%helpers%", members);
|
||||
info = info.replaceAll("%denied%", denied);
|
||||
info = info.replaceAll("%expires%", expires);
|
||||
info = info.replaceAll("%flags%", Matcher.quoteReplacement(flags));
|
||||
info = info.replaceAll("%build%", build + "");
|
||||
info = info.replaceAll("%desc%", "No description set.");
|
||||
@ -746,6 +774,10 @@ public class MainUtil {
|
||||
String rating = "";
|
||||
String prefix = "";
|
||||
double[] ratings = MainUtil.getAverageRatings(plot);
|
||||
for (double v : ratings) {
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < ratings.length; i++) {
|
||||
rating += prefix + Settings.RATING_CATEGORIES.get(i) + "=" + String.format("%.1f", ratings[i]);
|
||||
prefix = ",";
|
||||
|
@ -24,6 +24,7 @@ import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -705,7 +706,7 @@ public abstract class SchematicHandler {
|
||||
* @return Map of block location to tag
|
||||
*/
|
||||
public HashMap<BlockLoc, CompoundTag> getTiles() {
|
||||
return this.tiles == null ? new HashMap<BlockLoc, CompoundTag>() : tiles;
|
||||
return this.tiles == null ? new HashMap<BlockLoc, CompoundTag>() : this.tiles;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,7 @@ package com.intellectualcrafters.plot.util;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@ -150,7 +151,7 @@ public class SetQueue {
|
||||
}
|
||||
|
||||
public void regenerateChunk(String world, ChunkLoc loc) {
|
||||
queue.regenerateChunk(world, loc);
|
||||
this.queue.regenerateChunk(world, loc);
|
||||
}
|
||||
|
||||
public class ChunkWrapper {
|
||||
|
@ -11,10 +11,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public abstract class TaskManager {
|
||||
|
||||
public static HashSet<String> TELEPORT_QUEUE = new HashSet<>();
|
||||
|
||||
public static final HashSet<String> TELEPORT_QUEUE = new HashSet<>();
|
||||
public static final HashMap<Integer, Integer> tasks = new HashMap<>();
|
||||
public static AtomicInteger index = new AtomicInteger(0);
|
||||
public static HashMap<Integer, Integer> tasks = new HashMap<>();
|
||||
|
||||
public static int runTaskRepeat(Runnable runnable, int interval) {
|
||||
if (runnable != null) {
|
||||
|
@ -7,7 +7,6 @@ import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
@ -25,8 +24,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public abstract class UUIDHandlerImplementation {
|
||||
|
||||
public final ConcurrentHashMap<String, PlotPlayer> players;
|
||||
public UUIDWrapper uuidWrapper = null;
|
||||
public HashSet<UUID> unknown = new HashSet<>();
|
||||
public final HashSet<UUID> unknown = new HashSet<>();
|
||||
public UUIDWrapper uuidWrapper;
|
||||
private boolean cached = false;
|
||||
private BiMap<StringWrapper, UUID> uuidMap = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
||||
|
||||
@ -97,7 +96,7 @@ public abstract class UUIDHandlerImplementation {
|
||||
try {
|
||||
this.unknown.add(uuid);
|
||||
} catch (Exception e) {
|
||||
ConsolePlayer.getConsole().sendMessage("&c(minor) Invalid UUID mapping: " + uuid);
|
||||
PS.log("&c(minor) Invalid UUID mapping: " + uuid);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
@ -182,7 +181,6 @@ public abstract class UUIDHandlerImplementation {
|
||||
public void handleShutdown() {
|
||||
this.players.clear();
|
||||
this.uuidMap.clear();
|
||||
this.uuidWrapper = null;
|
||||
}
|
||||
|
||||
public String getName(UUID uuid) {
|
||||
|
@ -1,10 +1,6 @@
|
||||
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.util.MainUtil;
|
||||
|
||||
public abstract class Argument<T> {
|
||||
|
||||
@ -37,24 +33,18 @@ public abstract class Argument<T> {
|
||||
return in;
|
||||
}
|
||||
};
|
||||
public static Argument<String> PlayerName = new Argument<String>("PlayerName", "Dinnerbone") {
|
||||
public static final Argument<String> PlayerName = new Argument<String>("PlayerName", "Dinnerbone") {
|
||||
@Override
|
||||
public String parse(String in) {
|
||||
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
|
||||
public PlotId parse(String 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 T example;
|
||||
|
||||
|
@ -459,13 +459,13 @@ public abstract class Command {
|
||||
}
|
||||
|
||||
public String getUsage() {
|
||||
if (this.usage != null && this.usage.length() != 0) {
|
||||
if (this.usage != null && !this.usage.isEmpty()) {
|
||||
if (this.usage.startsWith("/")) {
|
||||
return this.usage;
|
||||
}
|
||||
return getCommandString() + " " + this.usage;
|
||||
}
|
||||
if (this.allCommands.size() == 0) {
|
||||
if (this.allCommands.isEmpty()) {
|
||||
return getCommandString();
|
||||
}
|
||||
StringBuilder args = new StringBuilder("[");
|
||||
@ -477,7 +477,7 @@ public abstract class Command {
|
||||
return getCommandString() + " " + args + "]";
|
||||
}
|
||||
|
||||
public Collection tab(PlotPlayer player, String[] args, boolean space) {
|
||||
public Collection<Command> tab(PlotPlayer player, String[] args, boolean space) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
return this.allCommands;
|
||||
@ -511,7 +511,7 @@ public abstract class Command {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.aliases.size() > 0 ? this.aliases.get(0) : this.id;
|
||||
return !this.aliases.isEmpty() ? this.aliases.get(0) : this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user