result = this.getNames(Collections.singletonList(uuid));
@@ -92,7 +92,7 @@ public class SquirrelIdUUIDService implements UUIDService {
results.add(result.get(0));
}
} else if (uuids.size() == 1 && Settings.DEBUG) {
- logger.info("[P2] (UUID) Found invalid UUID: {}", uuids.get(0));
+ logger.info("(UUID) Found invalid UUID: {}", uuids.get(0));
}
}
} catch (IOException | InterruptedException e) {
diff --git a/Core/src/main/java/com/plotsquared/core/Platform.java b/Core/src/main/java/com/plotsquared/core/Platform.java
index 3a9eb42e1..ff5187bae 100644
--- a/Core/src/main/java/com/plotsquared/core/Platform.java
+++ b/Core/src/main/java/com/plotsquared/core/Platform.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core;
diff --git a/Core/src/main/java/com/plotsquared/core/PlotAPI.java b/Core/src/main/java/com/plotsquared/core/PlotAPI.java
index 3dc756732..71dbf5c07 100644
--- a/Core/src/main/java/com/plotsquared/core/PlotAPI.java
+++ b/Core/src/main/java/com/plotsquared/core/PlotAPI.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core;
diff --git a/Core/src/main/java/com/plotsquared/core/PlotPlatform.java b/Core/src/main/java/com/plotsquared/core/PlotPlatform.java
index 6daa02a07..17c8c84fd 100644
--- a/Core/src/main/java/com/plotsquared/core/PlotPlatform.java
+++ b/Core/src/main/java/com/plotsquared/core/PlotPlatform.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core;
@@ -86,11 +86,13 @@ public interface PlotPlatform extends LocaleHolder {
/**
* Gets the version of Minecraft that is running.
+ * @return server version as array of numbers
*/
int[] getServerVersion();
/**
* Gets the server implementation name and version
+ * @return server implementationa and version as string
*/
String getServerImplementation();
@@ -254,6 +256,11 @@ public interface PlotPlatform
extends LocaleHolder {
*/
@Nonnull Audience getConsoleAudience();
+ /**
+ * Load the caption maps
+ */
+ void copyCaptionMaps();
+
/**
* Get the {@link PermissionHandler} implementation for the platform
*
diff --git a/Core/src/main/java/com/plotsquared/core/PlotSquared.java b/Core/src/main/java/com/plotsquared/core/PlotSquared.java
index 83ae671a1..3cc968a1e 100644
--- a/Core/src/main/java/com/plotsquared/core/PlotSquared.java
+++ b/Core/src/main/java/com/plotsquared/core/PlotSquared.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core;
@@ -90,7 +90,6 @@ import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
-import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.sql.SQLException;
import java.util.ArrayDeque;
@@ -141,7 +140,7 @@ public class PlotSquared {
public HashMap> plots_tmp;
private YamlConfiguration config;
// Localization
- private Map captionMaps;
+ private final Map captionMaps = new HashMap<>();
// Platform / Version / Update URL
private PlotVersion version;
// Files and configuration
@@ -174,6 +173,13 @@ public class PlotSquared {
//
ConfigurationSerialization.registerClass(BlockBucket.class, "BlockBucket");
+ // Load caption map
+ try {
+ this.loadCaptionMap();
+ } catch (final Exception e) {
+ logger.error("Failed to load caption map", e);
+ }
+
// Setup the global flag container
GlobalFlagContainer.setup();
@@ -197,8 +203,6 @@ public class PlotSquared {
return;
}
- this.captionMaps = new HashMap<>();
-
this.worldedit = WorldEdit.getInstance();
// Create Event utility class
@@ -224,16 +228,19 @@ public class PlotSquared {
}
}
- public void loadCaptionMap() throws IOException {
+ public void loadCaptionMap() throws Exception {
+ this.platform.copyCaptionMaps();
// Setup localization
CaptionMap captionMap;
if (Settings.Enabled_Components.PER_USER_LOCALE) {
- captionMap = CaptionLoader.loadAll(Paths.get("lang"));
+ captionMap = CaptionLoader.loadAll(new File(this.platform.getDirectory(), "lang").toPath());
} else {
String fileName = "messages_" + Settings.Enabled_Components.DEFAULT_LOCALE + ".json";
- captionMap = CaptionLoader.loadSingle(Paths.get("lang", fileName));
+ captionMap = CaptionLoader.loadSingle(new File(new File(this.platform.getDirectory(), "lang"), fileName).toPath());
}
this.captionMaps.put(TranslatableCaption.DEFAULT_NAMESPACE, captionMap);
+ logger.info("Loaded caption map for namespace 'plotsquared': {}",
+ this.captionMaps.get(TranslatableCaption.DEFAULT_NAMESPACE).getClass().getCanonicalName());
}
/**
@@ -384,16 +391,16 @@ public class PlotSquared {
regionInts.forEach(l -> regions.add(BlockVector2.at(l[0], l[1])));
chunkInts.forEach(l -> chunks.add(BlockVector2.at(l[0], l[1])));
int height = (int) list.get(2);
- logger.info("[P2] Incomplete road regeneration found. Restarting in world {} with height {}", plotArea.getWorldName(), height);
- logger.info("[P2] - Regions: {}", regions.size());
- logger.info("[P2] - Chunks: {}", chunks.size());
+ logger.info("Incomplete road regeneration found. Restarting in world {} with height {}", plotArea.getWorldName(), height);
+ logger.info(" - Regions: {}", regions.size());
+ logger.info(" - Chunks: {}", chunks.size());
HybridUtils.UPDATE = true;
PlotSquared.platform().getHybridUtils().scheduleRoadUpdate(plotArea, regions, height, chunks);
} catch (IOException | ClassNotFoundException e) {
- logger.error("[P2] Error restarting road regeneration", e);
+ logger.error("Error restarting road regeneration", e);
} finally {
if (!file.delete()) {
- logger.error("[P2] Error deleting persistent_regen_data_{}. Please delete this file manually", plotArea.getId());
+ logger.error("Error deleting persistent_regen_data_{}. Please delete this file manually", plotArea.getId());
}
}
});
@@ -796,10 +803,10 @@ public class PlotSquared {
// Conventional plot generator
PlotArea plotArea = plotGenerator.getNewPlotArea(world, null, null, null);
PlotManager plotManager = plotArea.getPlotManager();
- logger.info("[P2] Detected world load for '{}'", world);
- logger.info("[P2] - generator: {}>{}", baseGenerator, plotGenerator);
- logger.info("[P2] - plot world: {}", plotArea.getClass().getCanonicalName());
- logger.info("[P2] - plot area manager: {}", plotManager.getClass().getCanonicalName());
+ logger.info("Detected world load for '{}'", world);
+ logger.info(" - generator: {}>{}", baseGenerator, plotGenerator);
+ logger.info(" - plot world: {}", plotArea.getClass().getCanonicalName());
+ logger.info("- plot area manager: {}", plotManager.getClass().getCanonicalName());
if (!this.worldConfiguration.contains(path)) {
this.worldConfiguration.createSection(path);
worldSection = this.worldConfiguration.getConfigurationSection(path);
@@ -823,7 +830,7 @@ public class PlotSquared {
if (getPlotAreaManager().getPlotAreas(world, null).length != 0) {
return;
}
- logger.info("[P2] Detected world load for '{}'", world);
+ logger.info("Detected world load for '{}'", world);
String gen_string = worldSection.getString("generator.plugin", platform.getPluginName());
if (type == PlotAreaType.PARTIAL) {
Set clusters =
@@ -839,7 +846,7 @@ public class PlotSquared {
String fullId = name + "-" + pos1 + "-" + pos2;
worldSection.createSection("areas." + fullId);
DBFunc.replaceWorld(world, world + ";" + name, pos1, pos2); // NPE
- logger.info("[P2] - {}-{}-{}", name, pos1, pos2);
+ logger.info(" - {}-{}-{}", name, pos1, pos2);
GeneratorWrapper> areaGen = this.platform.getGenerator(world, gen_string);
if (areaGen == null) {
throw new IllegalArgumentException("Invalid Generator: " + gen_string);
@@ -853,10 +860,10 @@ public class PlotSquared {
} catch (IOException e) {
e.printStackTrace();
}
- logger.info("[P2] | generator: {}>{}", baseGenerator, areaGen);
- logger.info("[P2] | plot world: {}", pa);
- logger.info("[P2] | manager: {}", pa);
- logger.info("[P2] Note: Area created for cluster '{}' (invalid or old configuration?)", name);
+ logger.info(" | generator: {}>{}", baseGenerator, areaGen);
+ logger.info(" | plot world: {}", pa);
+ logger.info(" | manager: {}", pa);
+ logger.info("Note: Area created for cluster '{}' (invalid or old configuration?)", name);
areaGen.getPlotGenerator().initialize(pa);
areaGen.augment(pa);
toLoad.add(pa);
@@ -878,9 +885,9 @@ public class PlotSquared {
} catch (IOException e) {
e.printStackTrace();
}
- logger.info("[P2] - generator: {}>{}", baseGenerator, areaGen);
- logger.info("[P2] - plot world: {}", pa);
- logger.info("[P2] - plot area manager: {}", pa.getPlotManager());
+ logger.info(" - generator: {}>{}", baseGenerator, areaGen);
+ logger.info(" - plot world: {}", pa);
+ logger.info(" - plot area manager: {}", pa.getPlotManager());
areaGen.getPlotGenerator().initialize(pa);
areaGen.augment(pa);
addPlotArea(pa);
@@ -892,7 +899,7 @@ public class PlotSquared {
+ PlotAreaType.AUGMENTED + "`");
}
for (String areaId : areasSection.getKeys(false)) {
- logger.info("[P2] - {}", areaId);
+ logger.info(" - {}", areaId);
String[] split = areaId.split("(?<=[^;-])-");
if (split.length != 3) {
throw new IllegalArgumentException("Invalid Area identifier: " + areaId
@@ -954,10 +961,10 @@ public class PlotSquared {
} catch (IOException e) {
e.printStackTrace();
}
- logger.info("[P2] Detected area load for '{}'", world);
- logger.info("[P2] | generator: {}>{}", baseGenerator, areaGen);
- logger.info("[P2] | plot world: {}", pa);
- logger.info("[P2] | manager: {}", pa.getPlotManager());
+ logger.info("Detected area load for '{}'", world);
+ logger.info(" | generator: {}>{}", baseGenerator, areaGen);
+ logger.info(" | plot world: {}", pa);
+ logger.info(" | manager: {}", pa.getPlotManager());
areaGen.getPlotGenerator().initialize(pa);
areaGen.augment(pa);
addPlotArea(pa);
@@ -1028,7 +1035,7 @@ public class PlotSquared {
for (String element : split) {
String[] pair = element.split("=");
if (pair.length != 2) {
- logger.error("[P2] No value provided for '{}'", element);
+ logger.error("No value provided for '{}'", element);
return false;
}
String key = pair[0].toLowerCase();
@@ -1076,11 +1083,11 @@ public class PlotSquared {
ConfigurationUtil.BLOCK_BUCKET.parseString(value).toString());
break;
default:
- logger.error("[P2] Key not found: {}", element);
+ logger.error("Key not found: {}", element);
return false;
}
} catch (Exception e) {
- logger.error("[P2] Invalid value '{}' for arg '{}'", value, element);
+ logger.error("Invalid value '{}' for arg '{}'", value, element);
e.printStackTrace();
return false;
}
@@ -1148,7 +1155,7 @@ public class PlotSquared {
}
}
} catch (IOException e) {
- logger.error("[P2] Could not save {}", file);
+ logger.error("Could not save {}", file);
e.printStackTrace();
}
}
@@ -1171,7 +1178,7 @@ public class PlotSquared {
// Close the connection
DBFunc.close();
} catch (NullPointerException throwable) {
- logger.error("[P2] Could not close database connection", throwable);
+ logger.error("Could not close database connection", throwable);
throwable.printStackTrace();
}
}
@@ -1184,9 +1191,9 @@ public class PlotSquared {
HybridUtils.regions.isEmpty() && HybridUtils.chunks.isEmpty())) {
return;
}
- logger.info("[P2] Road regeneration incomplete. Saving incomplete regions to disk");
- logger.info("[P2] - regions: {}", HybridUtils.regions.size());
- logger.info("[P2] - chunks: {}", HybridUtils.chunks.size());
+ logger.info("Road regeneration incomplete. Saving incomplete regions to disk");
+ logger.info(" - regions: {}", HybridUtils.regions.size());
+ logger.info(" - chunks: {}", HybridUtils.chunks.size());
ArrayList regions = new ArrayList<>();
ArrayList chunks = new ArrayList<>();
for (BlockVector2 r : HybridUtils.regions) {
@@ -1203,14 +1210,14 @@ public class PlotSquared {
this.platform.getDirectory() + File.separator + "persistent_regen_data_" + HybridUtils.area
.getId() + "_" + HybridUtils.area.getWorldName());
if (file.exists() && !file.delete()) {
- logger.error("[P2] persistent_regene_data file already exists and could not be deleted");
+ logger.error("persistent_regene_data file already exists and could not be deleted");
return;
}
try (ObjectOutputStream oos = new ObjectOutputStream(
Files.newOutputStream(file.toPath(), StandardOpenOption.CREATE_NEW))) {
oos.writeObject(list);
} catch (IOException e) {
- logger.error("[P2] Error creating persistent_region_data file", e);
+ logger.error("Error creating persistent_region_data file", e);
}
}
@@ -1230,7 +1237,7 @@ public class PlotSquared {
File file = FileUtils.getFile(platform.getDirectory(), Storage.SQLite.DB + ".db");
database = new SQLite(file);
} else {
- logger.error("[P2] No storage type is set. Disabling PlotSquared");
+ logger.error("No storage type is set. Disabling PlotSquared");
this.platform.shutdown(); //shutdown used instead of disable because no database is set
return;
}
@@ -1248,11 +1255,11 @@ public class PlotSquared {
}
this.clustersTmp = DBFunc.getClusters();
} catch (ClassNotFoundException | SQLException e) {
- logger.error("[P2] Failed to open database connection ({}). Disabling PlotSquared", Storage.MySQL.USE ? "MySQL" : "SQLite");
- logger.error("[P2] ==== Here is an ugly stacktrace, if you are interested in those things ===");
+ logger.error("Failed to open database connection ({}). Disabling PlotSquared", Storage.MySQL.USE ? "MySQL" : "SQLite");
+ logger.error("==== Here is an ugly stacktrace, if you are interested in those things ===");
e.printStackTrace();
- logger.error("[P2] &d==== End of stacktrace ====");
- logger.error("[P2] &6Please go to the {} 'storage.yml' and configure the database correctly",
+ logger.error("==== End of stacktrace ====");
+ logger.error("Please go to the {} 'storage.yml' and configure the database correctly",
platform.getPluginName());
this.platform.shutdown(); //shutdown used instead of disable because of database error
}
@@ -1278,7 +1285,7 @@ public class PlotSquared {
try {
worldConfiguration.save(worldsFile);
} catch (IOException e) {
- logger.error("[P2] Failed to save worlds.yml", e);
+ logger.error("Failed to save worlds.yml", e);
e.printStackTrace();
}
}
@@ -1306,16 +1313,18 @@ public class PlotSquared {
* Setup all configuration files
* - Config: settings.yml
* - Storage: storage.yml
+ *
+ * @return success or not
*/
public boolean setupConfigs() {
File folder = new File(this.platform.getDirectory(), "config");
if (!folder.exists() && !folder.mkdirs()) {
- logger.error("[P2] Failed to create the /plugins/config folder. Please create it manually");
+ logger.error("Failed to create the /plugins/PlotSquared/config folder. Please create it manually");
}
try {
this.worldsFile = new File(folder, "worlds.yml");
if (!this.worldsFile.exists() && !this.worldsFile.createNewFile()) {
- logger.error("[P2] Could not create the worlds file. Please create 'worlds.yml' manually");
+ logger.error("Could not create the worlds file. Please create 'worlds.yml' manually");
}
this.worldConfiguration = YamlConfiguration.loadConfiguration(this.worldsFile);
@@ -1325,20 +1334,20 @@ public class PlotSquared {
.equalsIgnoreCase(LegacyConverter.CONFIGURATION_VERSION) && !this.worldConfiguration
.getString("configuration_version").equalsIgnoreCase("v5"))) {
// Conversion needed
- logger.info("[P2] &aA legacy configuration file was detected. Conversion will be attempted.");
+ logger.info("A legacy configuration file was detected. Conversion will be attempted.");
try {
com.google.common.io.Files
.copy(this.worldsFile, new File(folder, "worlds.yml.old"));
- logger.info("[P2] &6A copy of worlds.yml has been saved in the file worlds.yml.old");
+ logger.info("A copy of worlds.yml has been saved in the file worlds.yml.old");
final ConfigurationSection worlds =
this.worldConfiguration.getConfigurationSection("worlds");
final LegacyConverter converter = new LegacyConverter(worlds);
converter.convert();
this.worldConfiguration.set("worlds", worlds);
this.setConfigurationVersion(LegacyConverter.CONFIGURATION_VERSION);
- logger.info("[P2] &aThe conversion has finished. PlotSquared will now be disabled and the new configuration file will be used at next startup. Please review the new worlds.yml file. Please note that schematics will not be converted, as we are now using WorldEdit to handle schematics. You need to re-generate the schematics.");
+ logger.info("The conversion has finished. PlotSquared will now be disabled and the new configuration file will be used at next startup. Please review the new worlds.yml file. Please note that schematics will not be converted, as we are now using WorldEdit to handle schematics. You need to re-generate the schematics.");
} catch (final Exception e) {
- logger.error("[P2] &cFailed to convert the legacy configuration file. See stack trace for information.", e);
+ logger.error("Failed to convert the legacy configuration file. See stack trace for information.", e);
}
// Disable plugin
this.platform.shutdown();
@@ -1348,27 +1357,27 @@ public class PlotSquared {
this.worldConfiguration.set("configuration_version", LegacyConverter.CONFIGURATION_VERSION);
}
} catch (IOException ignored) {
- logger.error("[P2] Failed to save worlds.yml");
+ logger.error("Failed to save worlds.yml");
}
try {
this.configFile = new File(folder, "settings.yml");
if (!this.configFile.exists() && !this.configFile.createNewFile()) {
- logger.error("[P2] Could not create the settings file. Please create 'settings.yml' manually");
+ logger.error("Could not create the settings file. Please create 'settings.yml' manually");
}
this.config = YamlConfiguration.loadConfiguration(this.configFile);
setupConfig();
} catch (IOException ignored) {
- logger.error("[P2] Failed to save settings.yml");
+ logger.error("Failed to save settings.yml");
}
try {
this.storageFile = new File(folder, "storage.yml");
if (!this.storageFile.exists() && !this.storageFile.createNewFile()) {
- logger.error("[P2] Could not create the storage settings file. Please create 'storage.yml' manually");
+ logger.error("Could not create the storage settings file. Please create 'storage.yml' manually");
}
YamlConfiguration.loadConfiguration(this.storageFile);
setupStorage();
} catch (IOException ignored) {
- logger.error("[P2] Failed to save storage.yml");
+ logger.error("Failed to save storage.yml");
}
return true;
}
@@ -1399,7 +1408,7 @@ public class PlotSquared {
if (Settings.DEBUG) {
Map components = Settings.getFields(Settings.Enabled_Components.class);
for (Entry component : components.entrySet()) {
- logger.info("[P2] Key: {} | Value: {}", component.getKey(), component.getValue());
+ logger.info("Key: {} | Value: {}", component.getKey(), component.getValue());
}
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/PlotVersion.java b/Core/src/main/java/com/plotsquared/core/PlotVersion.java
index 86f3e8d58..019f23af3 100644
--- a/Core/src/main/java/com/plotsquared/core/PlotVersion.java
+++ b/Core/src/main/java/com/plotsquared/core/PlotVersion.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core;
diff --git a/Core/src/main/java/com/plotsquared/core/backup/Backup.java b/Core/src/main/java/com/plotsquared/core/backup/Backup.java
index e1af86eff..3fee60455 100644
--- a/Core/src/main/java/com/plotsquared/core/backup/Backup.java
+++ b/Core/src/main/java/com/plotsquared/core/backup/Backup.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.backup;
diff --git a/Core/src/main/java/com/plotsquared/core/backup/BackupManager.java b/Core/src/main/java/com/plotsquared/core/backup/BackupManager.java
index e1f7249d9..64da6c0ae 100644
--- a/Core/src/main/java/com/plotsquared/core/backup/BackupManager.java
+++ b/Core/src/main/java/com/plotsquared/core/backup/BackupManager.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.backup;
diff --git a/Core/src/main/java/com/plotsquared/core/backup/BackupProfile.java b/Core/src/main/java/com/plotsquared/core/backup/BackupProfile.java
index 5482cbcf7..fc6310ecf 100644
--- a/Core/src/main/java/com/plotsquared/core/backup/BackupProfile.java
+++ b/Core/src/main/java/com/plotsquared/core/backup/BackupProfile.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.backup;
diff --git a/Core/src/main/java/com/plotsquared/core/backup/NullBackupManager.java b/Core/src/main/java/com/plotsquared/core/backup/NullBackupManager.java
index a46e3b1d1..c237b49a6 100644
--- a/Core/src/main/java/com/plotsquared/core/backup/NullBackupManager.java
+++ b/Core/src/main/java/com/plotsquared/core/backup/NullBackupManager.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.backup;
diff --git a/Core/src/main/java/com/plotsquared/core/backup/NullBackupProfile.java b/Core/src/main/java/com/plotsquared/core/backup/NullBackupProfile.java
index b160e0e8f..12460e9c5 100644
--- a/Core/src/main/java/com/plotsquared/core/backup/NullBackupProfile.java
+++ b/Core/src/main/java/com/plotsquared/core/backup/NullBackupProfile.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.backup;
diff --git a/Core/src/main/java/com/plotsquared/core/backup/PlayerBackupProfile.java b/Core/src/main/java/com/plotsquared/core/backup/PlayerBackupProfile.java
index 84feafee4..8366fe5bf 100644
--- a/Core/src/main/java/com/plotsquared/core/backup/PlayerBackupProfile.java
+++ b/Core/src/main/java/com/plotsquared/core/backup/PlayerBackupProfile.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.backup;
diff --git a/Core/src/main/java/com/plotsquared/core/backup/SimpleBackupManager.java b/Core/src/main/java/com/plotsquared/core/backup/SimpleBackupManager.java
index 7c957b286..2d0794d4b 100644
--- a/Core/src/main/java/com/plotsquared/core/backup/SimpleBackupManager.java
+++ b/Core/src/main/java/com/plotsquared/core/backup/SimpleBackupManager.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.backup;
diff --git a/Core/src/main/java/com/plotsquared/core/collection/ArrayUtil.java b/Core/src/main/java/com/plotsquared/core/collection/ArrayUtil.java
index cd72475e7..83e8ee272 100644
--- a/Core/src/main/java/com/plotsquared/core/collection/ArrayUtil.java
+++ b/Core/src/main/java/com/plotsquared/core/collection/ArrayUtil.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.collection;
diff --git a/Core/src/main/java/com/plotsquared/core/collection/ByteArrayUtilities.java b/Core/src/main/java/com/plotsquared/core/collection/ByteArrayUtilities.java
index b21ced106..119879e76 100644
--- a/Core/src/main/java/com/plotsquared/core/collection/ByteArrayUtilities.java
+++ b/Core/src/main/java/com/plotsquared/core/collection/ByteArrayUtilities.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.collection;
diff --git a/Core/src/main/java/com/plotsquared/core/collection/FlatRandomCollection.java b/Core/src/main/java/com/plotsquared/core/collection/FlatRandomCollection.java
index 0834f0d4f..1a0896988 100644
--- a/Core/src/main/java/com/plotsquared/core/collection/FlatRandomCollection.java
+++ b/Core/src/main/java/com/plotsquared/core/collection/FlatRandomCollection.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.collection;
diff --git a/Core/src/main/java/com/plotsquared/core/collection/QuadMap.java b/Core/src/main/java/com/plotsquared/core/collection/QuadMap.java
index d5b4e9394..efe9caa14 100644
--- a/Core/src/main/java/com/plotsquared/core/collection/QuadMap.java
+++ b/Core/src/main/java/com/plotsquared/core/collection/QuadMap.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.collection;
diff --git a/Core/src/main/java/com/plotsquared/core/collection/RandomCollection.java b/Core/src/main/java/com/plotsquared/core/collection/RandomCollection.java
index f6209ceb6..2be11b956 100644
--- a/Core/src/main/java/com/plotsquared/core/collection/RandomCollection.java
+++ b/Core/src/main/java/com/plotsquared/core/collection/RandomCollection.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.collection;
diff --git a/Core/src/main/java/com/plotsquared/core/collection/SimpleRandomCollection.java b/Core/src/main/java/com/plotsquared/core/collection/SimpleRandomCollection.java
index 905c69cfd..c63461325 100644
--- a/Core/src/main/java/com/plotsquared/core/collection/SimpleRandomCollection.java
+++ b/Core/src/main/java/com/plotsquared/core/collection/SimpleRandomCollection.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.collection;
diff --git a/Core/src/main/java/com/plotsquared/core/command/Add.java b/Core/src/main/java/com/plotsquared/core/command/Add.java
index e126c57f2..836ed2d11 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Add.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Add.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -48,7 +48,6 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeoutException;
@CommandDeclaration(command = "add",
- description = "Allow a user to build in a plot while the plot owner is online.",
usage = "/plot add ",
category = CommandCategory.SETTINGS,
permission = "plots.add",
diff --git a/Core/src/main/java/com/plotsquared/core/command/Alias.java b/Core/src/main/java/com/plotsquared/core/command/Alias.java
index 14c47eb2a..ce12ed780 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Alias.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Alias.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -44,7 +44,6 @@ import java.util.concurrent.TimeoutException;
@CommandDeclaration(command = "alias",
permission = "plots.alias",
- description = "Set the plot name",
usage = "/plot alias ",
aliases = {"setalias", "sa", "name", "rename", "setname", "seta", "nameplot"},
category = CommandCategory.SETTINGS,
diff --git a/Core/src/main/java/com/plotsquared/core/command/Area.java b/Core/src/main/java/com/plotsquared/core/command/Area.java
index 283006d07..8d1bc9a75 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Area.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Area.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -93,7 +93,6 @@ import java.util.UUID;
permission = "plots.area",
category = CommandCategory.ADMINISTRATION,
requiredType = RequiredType.NONE,
- description = "Create a new PlotArea",
aliases = "world",
usage = "/plot area ",
confirmation = true)
diff --git a/Core/src/main/java/com/plotsquared/core/command/Argument.java b/Core/src/main/java/com/plotsquared/core/command/Argument.java
index 42a9858c8..3ccd4aed3 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Argument.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Argument.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -58,7 +58,7 @@ public abstract class Argument {
}
};
public static final Argument PlayerName =
- new Argument("PlayerName", "") {
+ new Argument("PlayerName", "") {
@Override public String parse(String in) {
return in.length() <= 16 ? in : null;
}
diff --git a/Core/src/main/java/com/plotsquared/core/command/Auto.java b/Core/src/main/java/com/plotsquared/core/command/Auto.java
index d8682eba1..467757d85 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Auto.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Auto.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -64,7 +64,6 @@ import java.util.stream.Collectors;
permission = "plots.auto",
category = CommandCategory.CLAIMING,
requiredType = RequiredType.NONE,
- description = "Claim the nearest plot",
aliases = "a",
usage = "/plot auto [length, width]")
public class Auto extends SubCommand {
diff --git a/Core/src/main/java/com/plotsquared/core/command/Backup.java b/Core/src/main/java/com/plotsquared/core/command/Backup.java
index 9c0f459fd..5ba71cc03 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Backup.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Backup.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -57,7 +57,6 @@ import java.util.stream.Stream;
@CommandDeclaration(command = "backup",
usage = "/plot backup ",
- description = "Manage plot backups",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.PLAYER,
permission = "plots.backup")
@@ -123,7 +122,6 @@ public final class Backup extends Command {
@CommandDeclaration(command = "save",
usage = "/plot backup save",
- description = "Create a plot backup",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.PLAYER,
permission = "plots.backup.save")
@@ -174,7 +172,6 @@ public final class Backup extends Command {
@CommandDeclaration(command = "list",
usage = "/plot backup list",
- description = "List available plot backups",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.PLAYER,
permission = "plots.backup.list")
@@ -241,7 +238,6 @@ public final class Backup extends Command {
@CommandDeclaration(command = "load",
usage = "/plot backup load <#>",
- description = "Restore a plot backup",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.PLAYER,
permission = "plots.backup.load")
diff --git a/Core/src/main/java/com/plotsquared/core/command/Biome.java b/Core/src/main/java/com/plotsquared/core/command/Biome.java
index ffe5b0139..de6c46fbb 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Biome.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Biome.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -40,7 +40,6 @@ import java.util.stream.Collectors;
@CommandDeclaration(command = "setbiome",
permission = "plots.set.biome",
- description = "Set the plot biome",
usage = "/plot biome [biome]",
aliases = {"biome", "sb", "setb", "b"},
category = CommandCategory.APPEARANCE,
@@ -67,7 +66,7 @@ public class Biome extends SetCommand {
return false;
}
plot.addRunning();
- plot.setBiome(biome, () -> {
+ plot.getPlotModificationManager().setBiome(biome, () -> {
plot.removeRunning();
player.sendMessage(
TranslatableCaption.of("biome.biome_set_to"),
@@ -78,8 +77,7 @@ public class Biome extends SetCommand {
}
@Override
- public Collection tab(final PlotPlayer player, final String[] args,
- final boolean space) {
+ public Collection tab(final PlotPlayer> player, final String[] args, final boolean space) {
return SuggestionHelper.getNamespacedRegistrySuggestions(BiomeType.REGISTRY, args[0])
.map(value -> value.toLowerCase(Locale.ENGLISH).replace("minecraft:", ""))
.filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH)))
diff --git a/Core/src/main/java/com/plotsquared/core/command/Buy.java b/Core/src/main/java/com/plotsquared/core/command/Buy.java
index 74287404e..f49d0d238 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Buy.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Buy.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -46,7 +46,6 @@ import java.util.Set;
import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "buy",
- description = "Buy the plot you are standing on",
usage = "/plot buy",
permission = "plots.buy",
category = CommandCategory.CLAIMING,
diff --git a/Core/src/main/java/com/plotsquared/core/command/Caps.java b/Core/src/main/java/com/plotsquared/core/command/Caps.java
index 20d512e07..9f495cd9c 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Caps.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Caps.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -47,7 +47,6 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
@CommandDeclaration(command = "caps",
category = CommandCategory.INFO,
- description = "Show plot entity caps",
usage = "/plot caps")
public class Caps extends SubCommand {
diff --git a/Core/src/main/java/com/plotsquared/core/command/Chat.java b/Core/src/main/java/com/plotsquared/core/command/Chat.java
index 4a2d4a986..e0f44813d 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Chat.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Chat.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -29,7 +29,6 @@ import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.player.PlotPlayer;
@CommandDeclaration(command = "chat",
- description = "Toggles plot chat on or off",
usage = "/plot chat",
permission = "plots.chat",
category = CommandCategory.CHAT,
diff --git a/Core/src/main/java/com/plotsquared/core/command/Claim.java b/Core/src/main/java/com/plotsquared/core/command/Claim.java
index a136b599d..1906c1713 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Claim.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Claim.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -55,7 +55,6 @@ import javax.annotation.Nullable;
@CommandDeclaration(
command = "claim",
aliases = "c",
- description = "Claim the current plot you're standing on",
category = CommandCategory.CLAIMING,
requiredType = RequiredType.PLAYER, permission = "plots.claim",
usage = "/plot claim")
@@ -175,8 +174,7 @@ public class Claim extends SubCommand {
try {
TaskManager.getPlatformImplementation().sync(() -> {
if (!plot.claim(player, true, finalSchematic, false)) {
- logger.info(TranslatableCaption.of("core.prefix") + String
- .format("Failed to claim plot %s", plot.getId().toCommaSeparatedString()));
+ logger.info("Failed to claim plot {}", plot.getId().toCommaSeparatedString());
player.sendMessage(TranslatableCaption.of("working.plot_not_claimed"));
plot.setOwnerAbs(null);
} else if (area.isAutoMerge()) {
@@ -188,7 +186,7 @@ public class Claim extends SubCommand {
Template.of("value", "Auto merge on claim")
);
} else {
- plot.autoMerge(mergeEvent.getDir(), mergeEvent.getMax(), player.getUUID(), true);
+ plot.getPlotModificationManager().autoMerge(mergeEvent.getDir(), mergeEvent.getMax(), player.getUUID(), true);
}
}
return null;
@@ -197,9 +195,7 @@ public class Claim extends SubCommand {
e.printStackTrace();
}
}, () -> {
- logger.info(TranslatableCaption.of("core.prefix") + String
- .format("Failed to add plot %s to the database",
- plot.getId().toCommaSeparatedString()));
+ logger.info("Failed to add plot to database: {}", plot.getId().toCommaSeparatedString());
player.sendMessage(TranslatableCaption.of("working.plot_not_claimed"));
plot.setOwnerAbs(null);
});
diff --git a/Core/src/main/java/com/plotsquared/core/command/Clear.java b/Core/src/main/java/com/plotsquared/core/command/Clear.java
index bd9478cd6..da40ef248 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Clear.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Clear.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -47,7 +47,6 @@ import javax.annotation.Nonnull;
import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "clear",
- description = "Clear the plot you stand on",
requiredType = RequiredType.NONE,
permission = "plots.clear",
category = CommandCategory.APPEARANCE,
@@ -92,8 +91,8 @@ public class Clear extends Command {
confirm.run(this, () -> {
BackupManager.backup(player, plot, () -> {
final long start = System.currentTimeMillis();
- boolean result = plot.clear(true, false, () -> {
- plot.unlink();
+ boolean result = plot.getPlotModificationManager().clear(true, false, () -> {
+ plot.getPlotModificationManager().unlink();
TaskManager.runTask(() -> {
plot.removeRunning();
// If the state changes, then mark it as no longer done
diff --git a/Core/src/main/java/com/plotsquared/core/command/Cluster.java b/Core/src/main/java/com/plotsquared/core/command/Cluster.java
index 610007fcb..4a4ae37f2 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Cluster.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Cluster.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -53,8 +53,7 @@ import java.util.concurrent.TimeoutException;
aliases = "clusters",
category = CommandCategory.ADMINISTRATION,
requiredType = RequiredType.NONE,
- permission = "plots.cluster",
- description = "Manage a plot cluster")
+ permission = "plots.cluster")
public class Cluster extends SubCommand {
@Override public boolean onCommand(PlotPlayer> player, String[] args) {
@@ -270,7 +269,7 @@ public class Cluster extends SubCommand {
} else {
cluster = area.getCluster(player.getLocation());
if (cluster == null) {
- player.sendMessage(TranslatableCaption.of("cluster.not_in_cluster"));
+ player.sendMessage(TranslatableCaption.of("errors.not_in_cluster"));
return false;
}
}
@@ -298,7 +297,7 @@ public class Cluster extends SubCommand {
if (args.length != 3) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
- Template.of("value", "/plot cluster delete [name]")
+ Template.of("value", "/plot cluster resize [name]")
);
return false;
}
@@ -609,10 +608,7 @@ public class Cluster extends SubCommand {
}
return true;
}
- case "members":
- case "admin":
- case "helper":
- case "helpers": {
+ case "members": {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_HELPERS)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
@@ -623,7 +619,7 @@ public class Cluster extends SubCommand {
if (args.length != 3) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
- Template.of("value", "/plot cluster helpers ")
+ Template.of("value", "/plot cluster members ")
);
return false;
}
@@ -658,7 +654,7 @@ public class Cluster extends SubCommand {
} else {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
- Template.of("value", "/plot cluster helpers ")
+ Template.of("value", "/plot cluster members ")
);
}
}
@@ -690,7 +686,7 @@ public class Cluster extends SubCommand {
PlotCluster cluster = area.getCluster(args[1]);
if (cluster == null) {
player.sendMessage(
- TranslatableCaption.of("cluster.invalid_cluster"),
+ TranslatableCaption.of("cluster.invalid_cluster_name"),
Template.of("cluster", args[1])
);
return false;
@@ -733,7 +729,7 @@ public class Cluster extends SubCommand {
if (args.length == 2) {
cluster = area.getCluster(args[1]);
player.sendMessage(
- TranslatableCaption.of("cluster.invalid_cluster"),
+ TranslatableCaption.of("cluster.invalid_cluster_name"),
Template.of("cluster", args[1])
);
} else {
diff --git a/Core/src/main/java/com/plotsquared/core/command/CmdConfirm.java b/Core/src/main/java/com/plotsquared/core/command/CmdConfirm.java
index e0b9bbbb3..3b91d7cf1 100644
--- a/Core/src/main/java/com/plotsquared/core/command/CmdConfirm.java
+++ b/Core/src/main/java/com/plotsquared/core/command/CmdConfirm.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
diff --git a/Core/src/main/java/com/plotsquared/core/command/CmdInstance.java b/Core/src/main/java/com/plotsquared/core/command/CmdInstance.java
index 7dbd19407..b0a66685e 100644
--- a/Core/src/main/java/com/plotsquared/core/command/CmdInstance.java
+++ b/Core/src/main/java/com/plotsquared/core/command/CmdInstance.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
diff --git a/Core/src/main/java/com/plotsquared/core/command/Command.java b/Core/src/main/java/com/plotsquared/core/command/Command.java
index dbb872e24..006b93433 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Command.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Command.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -71,7 +71,7 @@ public abstract class Command {
private List aliases;
private RequiredType required;
private String usage;
- private String description;
+ private Caption description;
private String permission;
private boolean confirmation;
private CommandCategory category;
@@ -171,7 +171,7 @@ public abstract class Command {
return this.aliases;
}
- public String getDescription() {
+ public Caption getDescription() {
return this.description;
}
@@ -198,7 +198,21 @@ public abstract class Command {
aliasOptions.addAll(Arrays.asList(declaration.aliases()));
this.aliases = aliasOptions;
- this.description = declaration.description();
+ if (declaration.description().isEmpty()) {
+ Command parent = getParent();
+ // we're collecting the "path" of the command
+ List path = new ArrayList<>();
+ path.add(this.id);
+ while (parent != null && !parent.equals(MainCommand.getInstance())) {
+ path.add(parent.getId());
+ parent = parent.getParent();
+ }
+ Collections.reverse(path);
+ String descriptionKey = String.join(".", path);
+ this.description = TranslatableCaption.of(String.format("commands.description.%s", descriptionKey));
+ } else {
+ this.description = StaticCaption.of(declaration.description());
+ }
this.usage = declaration.usage();
this.confirmation = declaration.confirmation();
@@ -280,9 +294,10 @@ public abstract class Command {
}
/**
- * @param player Caller
- * @param args Arguments
- * @param confirm Instance, Success, Failure
+ * @param player Caller
+ * @param args Arguments
+ * @param confirm Instance, Success, Failure
+ * @param whenDone task to run when done
* @return CompletableFuture true if the command executed fully, false in
* any other case
*/
@@ -334,7 +349,7 @@ public abstract class Command {
String[] allArgs = setArgs.toArray(new String[0]);
int best = 0;
for (Command current : commands) {
- int match = getMatch(allArgs, current);
+ int match = getMatch(allArgs, current, player);
if (match > best) {
cmd = current;
}
@@ -384,12 +399,12 @@ public abstract class Command {
return true;
}
- public int getMatch(String[] args, Command cmd) {
+ public int getMatch(String[] args, Command cmd, PlotPlayer> player) {
String perm = cmd.getPermission();
HashSet desc = new HashSet<>();
int count = cmd.getAliases().stream().filter(alias -> alias.startsWith(args[0]))
.mapToInt(alias -> 5).sum();
- Collections.addAll(desc, cmd.getDescription().split(" "));
+ Collections.addAll(desc, cmd.getDescription().getComponent(player).split(" "));
for (String arg : args) {
if (perm.startsWith(arg)) {
count++;
diff --git a/Core/src/main/java/com/plotsquared/core/command/CommandCaller.java b/Core/src/main/java/com/plotsquared/core/command/CommandCaller.java
index 46720f24a..e2e804e68 100644
--- a/Core/src/main/java/com/plotsquared/core/command/CommandCaller.java
+++ b/Core/src/main/java/com/plotsquared/core/command/CommandCaller.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -48,6 +48,7 @@ public interface CommandCaller {
* Check the player's permissions. Will be cached if permission caching is enabled.
*
* @param permission the name of the permission
+ * @return if permission is had
*/
boolean hasPermission(@Nonnull String permission);
diff --git a/Core/src/main/java/com/plotsquared/core/command/CommandCategory.java b/Core/src/main/java/com/plotsquared/core/command/CommandCategory.java
index 67895187e..5544edf6a 100644
--- a/Core/src/main/java/com/plotsquared/core/command/CommandCategory.java
+++ b/Core/src/main/java/com/plotsquared/core/command/CommandCategory.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
diff --git a/Core/src/main/java/com/plotsquared/core/command/CommandDeclaration.java b/Core/src/main/java/com/plotsquared/core/command/CommandDeclaration.java
index 105543ba0..8213300f9 100644
--- a/Core/src/main/java/com/plotsquared/core/command/CommandDeclaration.java
+++ b/Core/src/main/java/com/plotsquared/core/command/CommandDeclaration.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
diff --git a/Core/src/main/java/com/plotsquared/core/command/Comment.java b/Core/src/main/java/com/plotsquared/core/command/Comment.java
index fe472a543..25766f3f0 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Comment.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Comment.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -41,7 +41,6 @@ import java.util.Locale;
@CommandDeclaration(command = "comment",
aliases = {"msg"},
- description = "Comment on a plot",
category = CommandCategory.CHAT,
requiredType = RequiredType.PLAYER,
permission = "plots.comment")
diff --git a/Core/src/main/java/com/plotsquared/core/command/Condense.java b/Core/src/main/java/com/plotsquared/core/command/Condense.java
index fa1144f40..01891ca56 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Condense.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Condense.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -51,7 +51,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
@CommandDeclaration(command = "condense",
permission = "plots.admin",
usage = "/plot condense [radius]",
- description = "Condense a plotworld",
category = CommandCategory.ADMINISTRATION,
requiredType = RequiredType.CONSOLE)
public class Condense extends SubCommand {
@@ -71,7 +70,7 @@ public class Condense extends SubCommand {
if (args.length != 2 && args.length != 3) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
- Template.of("value", "/plot condense [radius]")
+ Template.of("value", "/plot condense [radius]")
);
return false;
}
@@ -179,7 +178,7 @@ public class Condense extends SubCommand {
i++;
final AtomicBoolean result = new AtomicBoolean(false);
try {
- result.set(origin.move(possible, () -> {
+ result.set(origin.getPlotModificationManager().move(possible, () -> {
if (result.get()) {
player.sendMessage(
TranslatableCaption.of("condense.moving"),
diff --git a/Core/src/main/java/com/plotsquared/core/command/Confirm.java b/Core/src/main/java/com/plotsquared/core/command/Confirm.java
index eda912b9a..98fc3b39a 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Confirm.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Confirm.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -32,7 +32,6 @@ import com.plotsquared.core.util.task.TaskManager;
@CommandDeclaration(command = "confirm",
permission = "plots.use",
- description = "Confirm an action",
category = CommandCategory.INFO)
public class Confirm extends SubCommand {
diff --git a/Core/src/main/java/com/plotsquared/core/command/Continue.java b/Core/src/main/java/com/plotsquared/core/command/Continue.java
index 627a3b511..49ffeca04 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Continue.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Continue.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -42,7 +42,6 @@ import net.kyori.adventure.text.minimessage.Template;
import javax.annotation.Nonnull;
@CommandDeclaration(command = "continue",
- description = "Continue a plot that was previously marked as done",
permission = "plots.continue",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.PLAYER)
diff --git a/Core/src/main/java/com/plotsquared/core/command/Copy.java b/Core/src/main/java/com/plotsquared/core/command/Copy.java
index 41e1e60fd..64ae43b8a 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Copy.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Copy.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -37,7 +37,6 @@ import net.kyori.adventure.text.minimessage.Template;
permission = "plots.copy",
aliases = {"copypaste"},
category = CommandCategory.CLAIMING,
- description = "Copy a plot",
usage = "/plot copy ",
requiredType = RequiredType.NONE)
public class Copy extends SubCommand {
@@ -77,11 +76,15 @@ public class Copy extends SubCommand {
player.sendMessage(TranslatableCaption.of("errors.plotworld_incompatible"));
return false;
}
- if (plot1.copy(plot2, () -> player.sendMessage(TranslatableCaption.of("move.copy_success")))) {
- return true;
- } else {
- player.sendMessage(TranslatableCaption.of("move.requires_unowned"));
- return false;
- }
+
+ plot1.getPlotModificationManager().copy(plot2).thenAccept(result -> {
+ if (result) {
+ player.sendMessage(TranslatableCaption.of("move.copy_success"));
+ } else {
+ player.sendMessage(TranslatableCaption.of("move.requires_unowned"));
+ }
+ });
+
+ return true;
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java b/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java
index ebdab6c65..da4d67b42 100644
--- a/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java
+++ b/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -41,7 +41,6 @@ import javax.annotation.Nonnull;
category = CommandCategory.ADMINISTRATION,
requiredType = RequiredType.PLAYER,
permission = "plots.createroadschematic",
- description = "Add a road schematic to your world using the roads around your current plot",
usage = "/plot createroadschematic")
public class CreateRoadSchematic extends SubCommand {
diff --git a/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java b/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java
index 1611d6cd0..09382ca9a 100644
--- a/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java
+++ b/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -48,7 +48,6 @@ import com.plotsquared.core.util.FileUtils;
import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template;
-import sun.net.TransferProtocolClient;
import javax.annotation.Nonnull;
import java.io.File;
@@ -63,7 +62,6 @@ import java.util.Map.Entry;
aliases = {"convert"},
category = CommandCategory.ADMINISTRATION,
permission = "plots.database",
- description = "Convert/Backup Storage",
requiredType = RequiredType.CONSOLE,
usage = "/plot database [area] ")
public class DatabaseCommand extends SubCommand {
@@ -104,7 +102,7 @@ public class DatabaseCommand extends SubCommand {
if (args.length < 1) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
- Template.of("value", "/plot database [area] ")
+ Template.of("value", "/plot database [area] ")
);
return false;
}
@@ -178,7 +176,11 @@ public class DatabaseCommand extends SubCommand {
continue;
}
}
- player.sendMessage(StaticCaption.of("Skipping duplicate plot: " + plot + " | id=" + plot.temp));
+ player.sendMessage(
+ TranslatableCaption.of("database.skipping_duplicated_plot"),
+ Template.of("plot", String.valueOf(plot)),
+ Template.of("id", String.valueOf(plot.temp))
+ );
continue;
}
plot.setArea(pa);
@@ -225,17 +227,17 @@ public class DatabaseCommand extends SubCommand {
return true;
} catch (ClassNotFoundException | SQLException e) {
player.sendMessage(TranslatableCaption.of("database.failed_to_save_plots"));
- player.sendMessage(StaticCaption.of(("=== Begin of stacktrace. ===")));
+ player.sendMessage(TranslatableCaption.of("errors.stacktrace_begin"));
e.printStackTrace();
- player.sendMessage(StaticCaption.of(("=== End of stacktrace. ===")));
+ player.sendMessage(TranslatableCaption.of(("errors.stacktrace_end")));
player.sendMessage(TranslatableCaption.of("database.invalid_args"));
return false;
}
} catch (ClassNotFoundException | SQLException e) {
player.sendMessage(TranslatableCaption.of("database.failed_to_open"));
- player.sendMessage(StaticCaption.of(("=== Begin of stacktrace. ===")));
+ player.sendMessage(TranslatableCaption.of("errors.stacktrace_begin"));
e.printStackTrace();
- player.sendMessage(StaticCaption.of(("=== End of stacktrace. ===")));
+ player.sendMessage(TranslatableCaption.of("errors.stacktrace_end"));
player.sendMessage(TranslatableCaption.of("database.invalid_args"));
return false;
}
diff --git a/Core/src/main/java/com/plotsquared/core/command/Debug.java b/Core/src/main/java/com/plotsquared/core/command/Debug.java
index 19e59ecf9..67eb61d3f 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Debug.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Debug.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -55,7 +55,6 @@ import java.util.Set;
@CommandDeclaration(command = "debug",
category = CommandCategory.DEBUG,
- description = "Show debug information",
usage = "/plot debug [msg]",
permission = "plots.admin")
public class Debug extends SubCommand {
@@ -72,6 +71,10 @@ public class Debug extends SubCommand {
}
@Override public boolean onCommand(PlotPlayer> player, String[] args) {
+ if (args.length == 0 ) {
+ player.sendMessage(TranslatableCaption.of("commandconfig.command_syntax"),
+ Template.of("value", "/plot debug "));
+ }
if (args.length > 0) {
if ("player".equalsIgnoreCase(args[0])) {
for (Map.Entry meta : player.getMeta().entrySet()) {
@@ -83,7 +86,7 @@ public class Debug extends SubCommand {
final long start = System.currentTimeMillis();
player.sendMessage(TranslatableCaption.of("debug.fetching_loaded_chunks"));
TaskManager.runTaskAsync(() -> player.sendMessage(StaticCaption
- .of("Loaded chunks: " + this.worldUtil.getChunkChunks(player.getLocation().getWorldName()).size() + "(" + (System.currentTimeMillis()
+ .of("Loaded chunks: " + this.worldUtil.getChunkChunks(player.getLocation().getWorldName()).size() + " (" + (System.currentTimeMillis()
- start) + "ms) using thread: " + Thread.currentThread().getName())));
return true;
}
@@ -106,10 +109,10 @@ public class Debug extends SubCommand {
return true;
}
if (args.length > 0 && "logging".equalsIgnoreCase(args[0])) {
- logger.info("[P2] Info!");
- logger.warn("[P2] Warning!");
- logger.error("[P2] Error!", new RuntimeException());
- logger.debug("[P2] Debug!");
+ logger.info("Info!");
+ logger.warn("Warning!");
+ logger.error("Error!", new RuntimeException());
+ logger.debug("Debug!");
return true;
}
if (args.length > 0 && "entitytypes".equalsIgnoreCase(args[0])) {
@@ -121,7 +124,7 @@ public class Debug extends SubCommand {
for (final EntityType entityType : category.getAll()) {
builder.append(entityType.getId()).append(" ");
}
- player.sendMessage(StaticCaption.of("core.prefix" + builder.toString()));
+ player.sendMessage(StaticCaption.of("" + builder.toString()));
});
EntityType.REGISTRY.values().stream().sorted(Comparator.comparing(EntityType::getId))
.forEach(entityType -> {
@@ -130,7 +133,7 @@ public class Debug extends SubCommand {
if (categoryCount > 0) {
return;
}
- player.sendMessage(StaticCaption.of("core.prefix" + entityType.getName() + " is in "
+ player.sendMessage(StaticCaption.of("" + entityType.getName() + " is in "
+ categoryCount + " categories"));
});
return true;
diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugAllowUnsafe.java b/Core/src/main/java/com/plotsquared/core/command/DebugAllowUnsafe.java
index 37bad8d20..08948bc29 100644
--- a/Core/src/main/java/com/plotsquared/core/command/DebugAllowUnsafe.java
+++ b/Core/src/main/java/com/plotsquared/core/command/DebugAllowUnsafe.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -33,7 +33,6 @@ import java.util.List;
import java.util.UUID;
@CommandDeclaration(command = "debugallowunsafe",
- description = "Allow unsafe actions until toggled off",
usage = "/plot debugallowunsafe",
category = CommandCategory.DEBUG,
requiredType = RequiredType.NONE,
diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java
index eb196760b..5d0ffbc37 100644
--- a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java
+++ b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -89,7 +89,6 @@ import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "debugexec",
permission = "plots.admin",
- description = "Mutli-purpose debug command",
aliases = {"exec", "$"},
category = CommandCategory.DEBUG)
public class DebugExec extends SubCommand {
@@ -230,7 +229,10 @@ public class DebugExec extends SubCommand {
player.sendMessage(TranslatableCaption.of("debugexec.starting_task"));
this.hybridUtils.analyzePlot(plot, new RunnableVal() {
@Override public void run(PlotAnalysis value) {
- player.sendMessage(StaticCaption.of("&6Done: &7Use &6/plot debugexec analyze &7for more information."));
+ player.sendMessage(
+ TranslatableCaption.of("debugexec.analyze_done"),
+ Template.of("command", "/plot debugexec analyze")
+ );
}
});
return true;
@@ -331,11 +333,9 @@ public class DebugExec extends SubCommand {
} else {
player.sendMessage(TranslatableCaption.of("debugexec.expiry_already_started"));
}
- case "h":
- case "he":
case "?":
case "help":
- player.sendMessage(StaticCaption.of("Possible sub commands: /plot debugexec <" + StringMan.join(allowed_params, "|") + ">"));
+ player.sendMessage(StaticCaption.of("Possible sub commands: /plot debugexec <" + StringMan.join(allowed_params, " | ") + ">"));
return false;
case "addcmd":
try {
@@ -422,7 +422,7 @@ public class DebugExec extends SubCommand {
message.set(StaticCaption.of(MINI_MESSAGE.serialize(MINI_MESSAGE
.parse(TranslatableCaption.of("debugexec.script_list_item").getComponent(player), numTemplate, nameTemplate))));
}
- }, "/plot debugexec list-scripts", StaticCaption.of("List of scripts"));
+ }, "/plot debugexec list-scripts", TranslatableCaption.of("scripts.script_list"));
return true;
case "all":
if (args.length < 3) {
@@ -458,12 +458,12 @@ public class DebugExec extends SubCommand {
} catch (ScriptException e) {
e.printStackTrace();
}
- logger.info("[P2] > {}ms -> {}", System.currentTimeMillis() - start, result);
+ logger.info("{}ms -> {}", System.currentTimeMillis() - start, result);
});
} else {
long start = System.currentTimeMillis();
Object result = this.engine.eval(script, this.scope);
- logger.info("[P2] > {}ms -> {}", System.currentTimeMillis() - start, result);
+ logger.info("{}ms -> {}", System.currentTimeMillis() - start, result);
}
return true;
} catch (ScriptException e) {
diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugImportWorlds.java b/Core/src/main/java/com/plotsquared/core/command/DebugImportWorlds.java
index ec12c1bc4..22282d5e5 100644
--- a/Core/src/main/java/com/plotsquared/core/command/DebugImportWorlds.java
+++ b/Core/src/main/java/com/plotsquared/core/command/DebugImportWorlds.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -45,7 +45,6 @@ import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "debugimportworlds",
permission = "plots.admin",
- description = "Import worlds by player name",
requiredType = RequiredType.CONSOLE,
category = CommandCategory.TELEPORT)
public class DebugImportWorlds extends Command {
diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugLoadTest.java b/Core/src/main/java/com/plotsquared/core/command/DebugLoadTest.java
index 387c5204e..00aa27558 100644
--- a/Core/src/main/java/com/plotsquared/core/command/DebugLoadTest.java
+++ b/Core/src/main/java/com/plotsquared/core/command/DebugLoadTest.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -31,7 +31,6 @@ import com.plotsquared.core.player.PlotPlayer;
@CommandDeclaration(command = "debugloadtest",
permission = "plots.debugloadtest",
- description = "This debug command will force the reload of all plots in the DB",
usage = "/plot debugloadtest",
category = CommandCategory.DEBUG,
requiredType = RequiredType.CONSOLE)
diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java b/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java
index f4a21e60a..a79a8a240 100644
--- a/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java
+++ b/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -56,7 +56,6 @@ import java.util.stream.Collectors;
@CommandDeclaration(command = "debugpaste",
aliases = "dp",
usage = "/plot debugpaste",
- description = "Upload settings.yml, worlds.yml, your latest.log and Multiverse's worlds.yml (if being used) to https://athion.net/ISPaster/paste",
permission = "plots.debugpaste",
category = CommandCategory.DEBUG,
confirmation = true,
@@ -146,25 +145,30 @@ public class DebugPaste extends SubCommand {
final File logFile =
new File(PlotSquared.platform().getDirectory(), "../../logs/latest.log");
if (Files.size(logFile.toPath()) > 14_000_000) {
- throw new IOException("Too big...");
+ throw new IOException("The latest.log is larger than 14MB. Please reboot your server and submit a new paste.");
}
incendoPaster
.addFile(new IncendoPaster.PasteFile("latest.log", readFile(logFile)));
} catch (IOException ignored) {
- player.sendMessage(StaticCaption.of("&clatest.log is too big to be pasted, please reboot your server and submit a new paste."));
+ player.sendMessage(
+ TranslatableCaption.of("debugpaste.latest_log"),
+ Template.of("file", "latest.log"),
+ Template.of("size", "14MB"));
}
try {
incendoPaster.addFile(new IncendoPaster.PasteFile("settings.yml",
readFile(this.configFile)));
} catch (final IllegalArgumentException ignored) {
- player.sendMessage(StaticCaption.of("&cSkipping settings.yml because it's empty."));
+ player.sendMessage(TranslatableCaption.of("debugpaste.empty_file"),
+ Template.of("file", "settings.yml"));
}
try {
incendoPaster.addFile(new IncendoPaster.PasteFile("worlds.yml",
readFile(this.worldfile)));
} catch (final IllegalArgumentException ignored) {
- player.sendMessage(StaticCaption.of("&cSkipping worlds.yml because it's empty."));
+ player.sendMessage(TranslatableCaption.of("debugpaste.empty_file"),
+ Template.of("file", "worlds.yml"));
}
try {
@@ -173,7 +177,8 @@ public class DebugPaste extends SubCommand {
incendoPaster.addFile(new IncendoPaster.PasteFile("MultiverseCore/worlds.yml",
readFile(MultiverseWorlds)));
} catch (final IOException ignored) {
- player.sendMessage(StaticCaption.of("&cSkipping Multiverse world's.yml because Multiverse is not in use."));
+ player.sendMessage(TranslatableCaption.of("debugpaste.skip_multiverse"),
+ Template.of("file", "worlds.yml"));
}
try {
diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java b/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java
index 08afc831a..d95bbff35 100644
--- a/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java
+++ b/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -43,7 +43,6 @@ import java.util.Arrays;
@CommandDeclaration(command = "debugroadregen",
usage = DebugRoadRegen.USAGE,
requiredType = RequiredType.NONE,
- description = "Regenerate roads in the plot or region the user is, based on the road schematic",
category = CommandCategory.DEBUG,
permission = "plots.debugroadregen")
public class DebugRoadRegen extends SubCommand {
@@ -140,7 +139,7 @@ public class DebugRoadRegen extends SubCommand {
Plot plot = player.getCurrentPlot();
PlotManager manager = area.getPlotManager();
if (!(manager instanceof HybridPlotManager)) {
- player.sendMessage(TranslatableCaption.of("errors.not_valid_plot_world"));
+ player.sendMessage(TranslatableCaption.of("errors.invalid_plot_world"));
return true;
}
player.sendMessage(TranslatableCaption.of("debugroadregen.schematic"),
diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugSaveTest.java b/Core/src/main/java/com/plotsquared/core/command/DebugSaveTest.java
index 02a2669b7..1274fb531 100644
--- a/Core/src/main/java/com/plotsquared/core/command/DebugSaveTest.java
+++ b/Core/src/main/java/com/plotsquared/core/command/DebugSaveTest.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -37,8 +37,7 @@ import java.util.List;
permission = "plots.debugsavetest",
category = CommandCategory.DEBUG,
requiredType = RequiredType.CONSOLE,
- usage = "/plot debugsavetest",
- description = "This command will force the recreation of all plots in the DB")
+ usage = "/plot debugsavetest")
public class DebugSaveTest extends SubCommand {
@Override public boolean onCommand(final PlotPlayer> player, String[] args) {
diff --git a/Core/src/main/java/com/plotsquared/core/command/Delete.java b/Core/src/main/java/com/plotsquared/core/command/Delete.java
index 908151ff7..be4774982 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Delete.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Delete.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -47,7 +47,6 @@ import javax.annotation.Nullable;
@CommandDeclaration(command = "delete",
permission = "plots.delete",
- description = "Delete the plot you stand on",
usage = "/plot delete",
aliases = {"dispose", "del"},
category = CommandCategory.CLAIMING,
@@ -99,7 +98,7 @@ public class Delete extends SubCommand {
return;
}
final long start = System.currentTimeMillis();
- boolean result = plot.deletePlot(() -> {
+ boolean result = plot.getPlotModificationManager().deletePlot(() -> {
plot.removeRunning();
if ((this.econHandler != null) && plotArea.useEconomy()) {
Expression valueExr = plotArea.getPrices().get("sell");
diff --git a/Core/src/main/java/com/plotsquared/core/command/Deny.java b/Core/src/main/java/com/plotsquared/core/command/Deny.java
index 3bf0b5eb1..cfe357c42 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Deny.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Deny.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -50,7 +50,6 @@ import java.util.concurrent.TimeoutException;
@CommandDeclaration(command = "deny",
aliases = {"d", "ban"},
- description = "Deny a user from entering a plot",
usage = "/plot deny ",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.PLAYER)
diff --git a/Core/src/main/java/com/plotsquared/core/command/Desc.java b/Core/src/main/java/com/plotsquared/core/command/Desc.java
index ed25b6730..24d3f165a 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Desc.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Desc.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -40,7 +40,6 @@ import javax.annotation.Nonnull;
@CommandDeclaration(command = "setdescription",
permission = "plots.set.desc",
- description = "Set the plot description",
usage = "/plot desc ",
aliases = {"desc", "setdesc", "setd", "description"},
category = CommandCategory.SETTINGS,
diff --git a/Core/src/main/java/com/plotsquared/core/command/Dislike.java b/Core/src/main/java/com/plotsquared/core/command/Dislike.java
index 2d603f814..3e4db188c 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Dislike.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Dislike.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -32,7 +32,6 @@ import javax.annotation.Nonnull;
@CommandDeclaration(command = "dislike",
permission = "plots.dislike",
- description = "Dislike the plot",
usage = "/plot dislike [next|purge]",
category = CommandCategory.INFO,
requiredType = RequiredType.PLAYER)
diff --git a/Core/src/main/java/com/plotsquared/core/command/Done.java b/Core/src/main/java/com/plotsquared/core/command/Done.java
index ebe46201d..ab38a329b 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Done.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Done.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -49,7 +49,6 @@ import javax.annotation.Nonnull;
@CommandDeclaration(command = "done",
aliases = {"submit"},
- description = "Mark a plot as done",
permission = "plots.done",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE)
@@ -93,7 +92,7 @@ public class Done extends SubCommand {
return false;
}
plot.addRunning();
- player.sendMessage(TranslatableCaption.of("web.generating_lin"));
+ player.sendMessage(TranslatableCaption.of("web.generating_link"));
final Settings.Auto_Clear doneRequirements = Settings.AUTO_CLEAR.get("done");
if (ExpireManager.IMP == null || doneRequirements == null) {
finish(plot, player, true);
diff --git a/Core/src/main/java/com/plotsquared/core/command/Download.java b/Core/src/main/java/com/plotsquared/core/command/Download.java
index fcfcec3b6..b83eb4703 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Download.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Download.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -45,12 +45,11 @@ import net.kyori.adventure.text.minimessage.Template;
import javax.annotation.Nonnull;
import java.net.URL;
-@CommandDeclaration(usage = "/plot download [schematic|world]",
+@CommandDeclaration(usage = "/plot download [schematic | world]",
command = "download",
aliases = {"dl"},
category = CommandCategory.SCHEMATIC,
requiredType = RequiredType.NONE,
- description = "Download your plot",
permission = "plots.download")
public class Download extends SubCommand {
@@ -111,7 +110,9 @@ public class Download extends SubCommand {
player.sendMessage(TranslatableCaption.of("web.generating_link_failed"));
return;
}
- player.sendMessage(StaticCaption.of(url.toString())
+ player.sendMessage(
+ TranslatableCaption.of("web.generation_link_success"),
+ Template.of("url", url.toString())
);
}
});
diff --git a/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java b/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java
index 766d2361b..b383a0db9 100644
--- a/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java
+++ b/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -71,7 +71,6 @@ import java.util.stream.Stream;
@CommandDeclaration(command = "flag",
aliases = {"f", "flag"},
usage = "/plot flag ",
- description = "Manage plot flags",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE,
permission = "plots.flag")
@@ -282,7 +281,6 @@ public final class FlagCommand extends Command {
@CommandDeclaration(command = "set",
aliases = {"s", "set"},
usage = "/plot flag set ",
- description = "Set a plot flag",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE,
permission = "plots.set.flag")
@@ -335,7 +333,6 @@ public final class FlagCommand extends Command {
@CommandDeclaration(command = "add",
aliases = {"a", "add"},
usage = "/plot flag add ",
- description = "Add a plot flag value",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE,
permission = "plots.flag.add")
@@ -399,7 +396,6 @@ public final class FlagCommand extends Command {
@CommandDeclaration(command = "remove",
aliases = {"r", "remove", "delete"},
usage = "/plot flag remove [values]",
- description = "Remove a flag",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE,
permission = "plots.flag.remove")
@@ -503,7 +499,6 @@ public final class FlagCommand extends Command {
@CommandDeclaration(command = "list",
aliases = {"l", "list", "flags"},
usage = "/plot flag list",
- description = "List all available plot flags",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE,
permission = "plots.flag.list")
@@ -543,7 +538,6 @@ public final class FlagCommand extends Command {
@CommandDeclaration(command = "info",
aliases = {"i", "info"},
usage = "/plot flag info ",
- description = "View information about a flag",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE,
permission = "plots.flag.info")
diff --git a/Core/src/main/java/com/plotsquared/core/command/Grant.java b/Core/src/main/java/com/plotsquared/core/command/Grant.java
index 33c3f042b..1745eec0c 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Grant.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Grant.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -40,10 +40,14 @@ import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template;
+import java.util.Collection;
+import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeoutException;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
@CommandDeclaration(command = "grant",
category = CommandCategory.CLAIMING,
@@ -89,7 +93,7 @@ public class Grant extends Command {
PlayerMetaDataKeys.PERSISTENT_GRANTED_PLOTS)) {
if (args[0].equalsIgnoreCase("check")) {
player.sendMessage(TranslatableCaption.of("grants.granted_plots"),
- Template.of("grants", String.valueOf(access.get().orElse(0))));
+ Template.of("amount", String.valueOf(access.get().orElse(0))));
} else {
access.set(access.get().orElse(0) + 1);
}
@@ -131,4 +135,10 @@ public class Grant extends Command {
sendUsage(player);
return CompletableFuture.completedFuture(true);
}
+ @Override public Collection tab(final PlotPlayer player, String[] args, boolean space) {
+ return Stream.of("check", "add")
+ .filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH)))
+ .map(value -> new Command(null, false, value, "plots.grant", RequiredType.NONE, null) {
+ }).collect(Collectors.toList());
+ }
}
diff --git a/Core/src/main/java/com/plotsquared/core/command/Help.java b/Core/src/main/java/com/plotsquared/core/command/Help.java
index f417e51d6..8ec4f7e40 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Help.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Help.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -39,7 +39,6 @@ import net.kyori.adventure.text.minimessage.Template;
import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "help",
- description = "Get this help menu",
aliases = "?",
category = CommandCategory.INFO,
usage = "help [category|#]",
diff --git a/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java b/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java
index 71b3de593..24f2a544c 100644
--- a/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java
+++ b/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -50,7 +50,6 @@ import java.util.List;
import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "home",
- description = "Teleport to your plot(s)",
permission = "plots.home",
usage = "/plot home [ | | | | ]",
aliases = {"h"},
diff --git a/Core/src/main/java/com/plotsquared/core/command/Inbox.java b/Core/src/main/java/com/plotsquared/core/command/Inbox.java
index aa177b427..b722c2caa 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Inbox.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Inbox.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -44,8 +44,7 @@ import net.kyori.adventure.text.minimessage.Template;
import java.util.List;
@CommandDeclaration(command = "inbox",
- description = "Review the comments for a plot",
- usage = "/plot inbox [inbox] [delete |clear|page]",
+ usage = "/plot inbox [inbox] [delete | clear | page]",
permission = "plots.inbox",
category = CommandCategory.CHAT,
requiredType = RequiredType.PLAYER)
@@ -208,7 +207,7 @@ public class Inbox extends SubCommand {
}
PlotComment comment = value.get(index - 1);
inbox.removeComment(plot, comment);
- boolean success = plot.removeComment(comment);
+ boolean success = plot.getPlotCommentContainer().removeComment(comment);
if (success) {
player.sendMessage(
TranslatableCaption.of("comment.comment_removed_success"),
@@ -231,9 +230,9 @@ public class Inbox extends SubCommand {
player.sendMessage(TranslatableCaption.of("comment.no_perm_inbox_modify"));
}
inbox.clearInbox(plot);
- List comments = plot.getComments(inbox.toString());
+ List comments = plot.getPlotCommentContainer().getComments(inbox.toString());
if (!comments.isEmpty()) {
- plot.removeComments(comments);
+ plot.getPlotCommentContainer().removeComments(comments);
}
player.sendMessage(
TranslatableCaption.of("comment.comment_removed_success"),
diff --git a/Core/src/main/java/com/plotsquared/core/command/Info.java b/Core/src/main/java/com/plotsquared/core/command/Info.java
index 20c678fd3..dde661891 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Info.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Info.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -38,8 +38,7 @@ import net.kyori.adventure.text.minimessage.Template;
@CommandDeclaration(command = "info",
aliases = "i",
- description = "Display plot info",
- usage = "/plot info [-f, to force info]",
+ usage = "/plot info [-f to force info]",
category = CommandCategory.INFO)
public class Info extends SubCommand {
diff --git a/Core/src/main/java/com/plotsquared/core/command/Kick.java b/Core/src/main/java/com/plotsquared/core/command/Kick.java
index b8a4bc1b2..11fb6352e 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Kick.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Kick.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -50,7 +50,6 @@ import java.util.concurrent.TimeoutException;
@CommandDeclaration(command = "kick",
aliases = "k",
- description = "Kick a player from your plot",
permission = "plots.kick",
usage = "/plot kick ",
category = CommandCategory.TELEPORT,
diff --git a/Core/src/main/java/com/plotsquared/core/command/Leave.java b/Core/src/main/java/com/plotsquared/core/command/Leave.java
index b7cb17d74..7afa25ff7 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Leave.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Leave.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -39,7 +39,6 @@ import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "leave",
- description = "Removes self from being trusted or a member of the plot",
permission = "plots.leave",
usage = "/plot leave",
category = CommandCategory.CLAIMING,
diff --git a/Core/src/main/java/com/plotsquared/core/command/Like.java b/Core/src/main/java/com/plotsquared/core/command/Like.java
index d14cd28c3..199bd09e3 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Like.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Like.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -50,7 +50,6 @@ import java.util.UUID;
@CommandDeclaration(command = "like",
permission = "plots.like",
- description = "Like the plot",
usage = "/plot like [next | purge]",
category = CommandCategory.INFO,
requiredType = RequiredType.PLAYER)
@@ -172,6 +171,7 @@ public class Like extends SubCommand {
/**
* Get the likes to dislike ratio of a plot as a percentage (in decimal form)
*
+ * @param plot plot
* @return likes to dislike ratio, returns zero if the plot has no likes
*/
public static double getLikesPercentage(final Plot plot) {
diff --git a/Core/src/main/java/com/plotsquared/core/command/ListCmd.java b/Core/src/main/java/com/plotsquared/core/command/ListCmd.java
index 8d79848a5..d01e3ea3e 100644
--- a/Core/src/main/java/com/plotsquared/core/command/ListCmd.java
+++ b/Core/src/main/java/com/plotsquared/core/command/ListCmd.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -72,7 +72,6 @@ import java.util.stream.Collectors;
@CommandDeclaration(command = "list",
aliases = {"l", "find", "search"},
- description = "List plots",
permission = "plots.list",
category = CommandCategory.INFO,
usage = "/plot list > [#]")
diff --git a/Core/src/main/java/com/plotsquared/core/command/Load.java b/Core/src/main/java/com/plotsquared/core/command/Load.java
index 3e8ab1b41..585a41234 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Load.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Load.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -54,7 +54,6 @@ import java.util.List;
aliases = "restore",
category = CommandCategory.SCHEMATIC,
requiredType = RequiredType.NONE,
- description = "Load your plot",
permission = "plots.load",
usage = "/plot load")
public class Load extends SubCommand {
diff --git a/Core/src/main/java/com/plotsquared/core/command/MainCommand.java b/Core/src/main/java/com/plotsquared/core/command/MainCommand.java
index d3c817747..4e9b366cf 100644
--- a/Core/src/main/java/com/plotsquared/core/command/MainCommand.java
+++ b/Core/src/main/java/com/plotsquared/core/command/MainCommand.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -42,6 +42,8 @@ import com.plotsquared.core.util.Expression;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.LinkedList;
@@ -55,6 +57,8 @@ import java.util.concurrent.CompletableFuture;
aliases = {"plots", "p", "plotsquared", "plot2", "p2", "ps", "2", "plotme", "plotz", "ap"})
public class MainCommand extends Command {
+ private static final Logger logger = LoggerFactory.getLogger("P2/" + MainCommand.class.getSimpleName());
+
private static MainCommand instance;
public Help help;
public Toggle toggle;
@@ -144,7 +148,12 @@ public class MainCommand extends Command {
}
for (final Class extends Command> command : commands) {
- injector.getInstance(command);
+ try {
+ injector.getInstance(command);
+ } catch (final Exception e) {
+ logger.error("Failed to register command {}", command.getCanonicalName());
+ e.printStackTrace();
+ }
}
// Referenced commands
@@ -301,12 +310,13 @@ public class MainCommand extends Command {
throw e;
} catch (Throwable e) {
e.printStackTrace();
- String message = e.getLocalizedMessage();
+ String message = e.getMessage();
if (message != null) {
player.sendMessage(TranslatableCaption.of("errors.error"),
net.kyori.adventure.text.minimessage.Template.of("value", message));
} else {
- player.sendMessage(TranslatableCaption.of("errors.error"));
+ player.sendMessage(
+ TranslatableCaption.of("errors.error_console"));
}
}
// Reset command scope //
diff --git a/Core/src/main/java/com/plotsquared/core/command/Merge.java b/Core/src/main/java/com/plotsquared/core/command/Merge.java
index ebb9de4e1..12d0a5ec6 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Merge.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Merge.java
@@ -21,19 +21,19 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared;
-import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.events.PlotMergeEvent;
import com.plotsquared.core.events.Result;
import com.plotsquared.core.location.Direction;
import com.plotsquared.core.location.Location;
+import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
@@ -42,7 +42,6 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Expression;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.StringMan;
-import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template;
import javax.annotation.Nonnull;
@@ -51,7 +50,6 @@ import java.util.UUID;
@CommandDeclaration(command = "merge",
aliases = "m",
- description = "Merge the plot you are standing on with another plot",
permission = "plots.merge",
usage = "/plot merge [removeroads]",
category = CommandCategory.SETTINGS,
@@ -182,7 +180,7 @@ public class Merge extends SubCommand {
);
return true;
}
- if (plot.autoMerge(Direction.ALL, maxSize, uuid, terrain)) {
+ if (plot.getPlotModificationManager().autoMerge(Direction.ALL, maxSize, uuid, terrain)) {
if (this.econHandler != null && plotArea.useEconomy() && price > 0d) {
this.econHandler.withdrawMoney(player, price);
player.sendMessage(
@@ -226,7 +224,7 @@ public class Merge extends SubCommand {
);
return true;
}
- if (plot.autoMerge(direction, maxSize - size, uuid, terrain)) {
+ if (plot.getPlotModificationManager().autoMerge(direction, maxSize - size, uuid, terrain)) {
if (this.econHandler != null && plotArea.useEconomy() && price > 0d) {
this.econHandler.withdrawMoney(player, price);
player.sendMessage(
@@ -234,12 +232,12 @@ public class Merge extends SubCommand {
Template.of("money", String.valueOf(price))
);
}
- player.sendMessage(TranslatableCaption.of("success_merge"));
+ player.sendMessage(TranslatableCaption.of("merge.success_merge"));
return true;
}
Plot adjacent = plot.getRelative(direction);
if (adjacent == null || !adjacent.hasOwner() || adjacent
- .getMerged((direction.getIndex() + 2) % 4) || (!force && adjacent.isOwner(uuid))) {
+ .isMerged((direction.getIndex() + 2) % 4) || (!force && adjacent.isOwner(uuid))) {
player.sendMessage(TranslatableCaption.of("merge.no_available_automerge"));
return false;
}
@@ -261,8 +259,8 @@ public class Merge extends SubCommand {
final Direction dir = direction;
Runnable run = () -> {
accepter.sendMessage(TranslatableCaption.of("merge.merge_accepted"));
- plot.autoMerge(dir, maxSize - size, owner, terrain);
- PlotPlayer plotPlayer = PlotSquared.platform().getPlayerManager().getPlayerIfExists(player.getUUID());
+ plot.getPlotModificationManager().autoMerge(dir, maxSize - size, owner, terrain);
+ PlotPlayer> plotPlayer = PlotSquared.platform().getPlayerManager().getPlayerIfExists(player.getUUID());
if (plotPlayer == null) {
accepter.sendMessage(TranslatableCaption.of("merge.merge_not_valid"));
return;
diff --git a/Core/src/main/java/com/plotsquared/core/command/Middle.java b/Core/src/main/java/com/plotsquared/core/command/Middle.java
index 5ea239c3d..a8342c6df 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Middle.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Middle.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -36,7 +36,6 @@ import com.plotsquared.core.plot.Plot;
*/
@CommandDeclaration(command = "middle",
aliases = {"center", "centre"},
- description = "Teleports you to the center of the plot",
usage = "/plot middle",
category = CommandCategory.TELEPORT,
requiredType = RequiredType.PLAYER)
@@ -50,6 +49,7 @@ public class Middle extends SubCommand {
return false;
}
plot.getCenter(center -> player.teleport(center, TeleportCause.COMMAND));
+ player.sendMessage(TranslatableCaption.of("teleport.teleported_to_plot"));
return true;
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/command/Move.java b/Core/src/main/java/com/plotsquared/core/command/Move.java
index a9feb3080..e4c2a64d3 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Move.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Move.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -43,7 +43,6 @@ import java.util.concurrent.CompletableFuture;
@CommandDeclaration(usage = "/plot move ",
command = "move",
- description = "Move a plot",
permission = "plots.move",
category = CommandCategory.CLAIMING,
requiredType = RequiredType.PLAYER)
@@ -107,7 +106,7 @@ public class Move extends SubCommand {
return CompletableFuture.completedFuture(false);
}
- return plot1.move(plot2, () -> {
+ return plot1.getPlotModificationManager().move(plot2, () -> {
}, false).thenApply(result -> {
if (result) {
player.sendMessage(TranslatableCaption.of("move.move_success"));
diff --git a/Core/src/main/java/com/plotsquared/core/command/Music.java b/Core/src/main/java/com/plotsquared/core/command/Music.java
index f9c0ce8d9..ffab80dcf 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Music.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Music.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -48,7 +48,6 @@ import java.util.Locale;
@CommandDeclaration(command = "music",
permission = "plots.music",
- description = "Play music in your plot",
usage = "/plot music",
category = CommandCategory.APPEARANCE,
requiredType = RequiredType.PLAYER)
@@ -57,7 +56,7 @@ public class Music extends SubCommand {
private static final Collection DISCS = Arrays
.asList("music_disc_13", "music_disc_cat", "music_disc_blocks", "music_disc_chirp",
"music_disc_far", "music_disc_mall", "music_disc_mellohi", "music_disc_stal",
- "music_disc_strad", "music_disc_ward", "music_disc_11", "music_disc_wait");
+ "music_disc_strad", "music_disc_ward", "music_disc_11", "music_disc_wait", "music_disc_pigstep");
private final InventoryUtil inventoryUtil;
@@ -87,27 +86,27 @@ public class Music extends SubCommand {
.createFlagInstance(item.getType());
PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(plotFlag, plot);
if (event.getEventResult() == Result.DENY) {
- player.sendMessage(
+ getPlayer().sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Music removal"));
return true;
}
plot.removeFlag(event.getFlag());
- player.sendMessage(TranslatableCaption.of("flag.flag_removed"));
- } else if (item.name.toLowerCase(Locale.ENGLISH).contains("disc")) {
+ getPlayer().sendMessage(TranslatableCaption.of("flag.flag_removed"));
+ } else if (item.getName().toLowerCase(Locale.ENGLISH).contains("disc")) {
PlotFlag, ?> plotFlag = plot.getFlagContainer().getFlag(MusicFlag.class)
.createFlagInstance(item.getType());
PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot);
if (event.getEventResult() == Result.DENY) {
- player.sendMessage(
+ getPlayer().sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Music addition"));
return true;
}
plot.setFlag(event.getFlag());
- player.sendMessage(TranslatableCaption.of("flag.flag_added"));
+ getPlayer().sendMessage(TranslatableCaption.of("flag.flag_added"));
} else {
- player.sendMessage(TranslatableCaption.of("flag.flag_not_added"));
+ getPlayer().sendMessage(TranslatableCaption.of("flag.flag_not_added"));
}
return false;
}
@@ -115,16 +114,16 @@ public class Music extends SubCommand {
int index = 0;
for (final String disc : DISCS) {
- final String name = String.format("&r&6%s", disc);
- final String[] lore = {"&r&aClick to play!"};
+ final String name = String.format("%s", disc);
+ final String[] lore = {"Click to play!"};
final PlotItemStack item = new PlotItemStack(disc, 1, name, lore);
inv.setItem(index++, item);
}
// Always add the cancel button
// if (player.getMeta("music") != null) {
- String name = "&r&6Cancel music";
- String[] lore = {"&r&cClick to cancel!"};
+ String name = "Cancel music";
+ String[] lore = {"Click to remove the music!"};
inv.setItem(index, new PlotItemStack("bedrock", 1, name, lore));
// }
diff --git a/Core/src/main/java/com/plotsquared/core/command/Near.java b/Core/src/main/java/com/plotsquared/core/command/Near.java
index 91e5230d0..e14b14ddc 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Near.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Near.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -37,7 +37,6 @@ import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "near",
aliases = "n",
- description = "Display nearby players",
usage = "/plot near",
category = CommandCategory.INFO,
requiredType = RequiredType.PLAYER)
diff --git a/Core/src/main/java/com/plotsquared/core/command/Owner.java b/Core/src/main/java/com/plotsquared/core/command/Owner.java
index 292ccdff1..c29034584 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Owner.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Owner.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -49,7 +49,6 @@ import java.util.function.Consumer;
@CommandDeclaration(command = "setowner",
permission = "plots.set.owner",
- description = "Set the plot owner",
usage = "/plot setowner ",
aliases = {"owner", "so", "seto"},
category = CommandCategory.CLAIMING,
@@ -106,11 +105,11 @@ public class Owner extends SetCommand {
Template.of("value", "Unlink on owner change"));
return;
}
- plot.unlinkPlot(unlinkEvent.isCreateRoad(), unlinkEvent.isCreateRoad());
+ plot.getPlotModificationManager().unlinkPlot(unlinkEvent.isCreateRoad(), unlinkEvent.isCreateRoad());
Set connected = plot.getConnectedPlots();
for (Plot current : connected) {
current.unclaim();
- current.removeSign();
+ current.getPlotModificationManager().removeSign();
}
player.sendMessage(TranslatableCaption.of("owner.set_owner"));
return;
@@ -148,7 +147,7 @@ public class Owner extends SetCommand {
if (plot.setOwner(finalUUID, player)) {
if (removeDenied)
plot.removeDenied(finalUUID);
- plot.setSign(finalName);
+ plot.getPlotModificationManager().setSign(finalName);
player.sendMessage(TranslatableCaption.of("owner.set_owner"));
if (other != null) {
other.sendMessage(
diff --git a/Core/src/main/java/com/plotsquared/core/command/PluginCmd.java b/Core/src/main/java/com/plotsquared/core/command/PluginCmd.java
index cc8ab09af..695b045f6 100644
--- a/Core/src/main/java/com/plotsquared/core/command/PluginCmd.java
+++ b/Core/src/main/java/com/plotsquared/core/command/PluginCmd.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -34,7 +34,6 @@ import net.kyori.adventure.text.minimessage.Template;
@CommandDeclaration(command = "plugin",
permission = "plots.use",
- description = "Show plugin information",
usage = "/plot plugin",
aliases = "version",
category = CommandCategory.INFO)
@@ -47,7 +46,7 @@ public class PluginCmd extends SubCommand {
Template.of("version", String.valueOf(PlotSquared.get().getVersion()))
);
player.sendMessage(StaticCaption.of(" >> Authors: Citymonstret & Empire92 & MattBDev & dordsor21 & NotMyFault & SirYwell"));
- player.sendMessage(StaticCaption.of(" >> Wiki: https://wiki.intellectualsites.com/plotsquared/home"));
+ player.sendMessage(StaticCaption.of(" >> Wiki: https://wiki.intellectualsites.com/plotsquared/home"));
player.sendMessage(
StaticCaption.of(" >> Premium: "),
Template.of("value", String.valueOf(PremiumVerification.isPremium()))
diff --git a/Core/src/main/java/com/plotsquared/core/command/Purge.java b/Core/src/main/java/com/plotsquared/core/command/Purge.java
index 19ee68a92..2d75807b8 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Purge.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Purge.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -51,10 +51,9 @@ import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
-@CommandDeclaration(usage = "/plot purge world: area: id: owner: shared: unknown:[true|false] clear:[true|false]",
+@CommandDeclaration(usage = "/plot purge world: area: id: owner: shared: unknown:[true | false] clear:[true | false]",
command = "purge",
permission = "plots.admin",
- description = "Purge all plots for a world",
category = CommandCategory.ADMINISTRATION,
requiredType = RequiredType.CONSOLE,
confirmation = true)
@@ -201,7 +200,7 @@ public class Purge extends SubCommand {
boolean finalClear = clear;
Runnable run = () -> {
if (Settings.DEBUG) {
- logger.info("[P2] Calculating plots to purge, please wait...");
+ logger.info("Calculating plots to purge, please wait...");
}
HashSet ids = new HashSet<>();
Iterator iterator = toDelete.iterator();
@@ -215,20 +214,20 @@ public class Purge extends SubCommand {
try {
ids.add(plot.temp);
if (finalClear) {
- plot.clear(false, true, () -> {
+ plot.getPlotModificationManager().clear(false, true, () -> {
if (Settings.DEBUG) {
- logger.info("[P2] Plot {} cleared by purge", plot.getId());
+ logger.info("Plot {} cleared by purge", plot.getId());
}
});
} else {
- plot.removeSign();
+ plot.getPlotModificationManager().removeSign();
}
plot.getArea().removePlot(plot.getId());
for (PlotPlayer> pp : plot.getPlayersInPlot()) {
Purge.this.plotListener.plotEntry(pp, plot);
}
} catch (NullPointerException e) {
- logger.error("[P2] NullPointer during purge detected. This is likely"
+ logger.error("NullPointer during purge detected. This is likely"
+ " because you are deleting a world that has been removed", e);
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/command/Rate.java b/Core/src/main/java/com/plotsquared/core/command/Rate.java
index fe732005f..035ed41d3 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Rate.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Rate.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -54,7 +54,6 @@ import java.util.UUID;
@CommandDeclaration(command = "rate",
permission = "plots.rate",
- description = "Rate the plot",
usage = "/plot rate [# | next | purge]",
aliases = "rt",
category = CommandCategory.INFO,
@@ -160,19 +159,19 @@ public class Rate extends SubCommand {
if (index.getValue() >= Settings.Ratings.CATEGORIES.size()) {
int rV = rating.getValue();
PlotRateEvent event = Rate.this.eventDispatcher
- .callRating(this.player, plot, new Rating(rV));
+ .callRating(this.getPlayer(), plot, new Rating(rV));
if (event.getRating() != null) {
- plot.addRating(this.player.getUUID(), event.getRating());
- player.sendMessage(
+ plot.addRating(this.getPlayer().getUUID(), event.getRating());
+ getPlayer().sendMessage(
TranslatableCaption.of("ratings.rating_applied"),
Template.of("plot", plot.getId().toString())
);
if (Permissions
- .hasPermission(this.player, Permission.PERMISSION_COMMENT)) {
+ .hasPermission(this.getPlayer(), Permission.PERMISSION_COMMENT)) {
Command command =
MainCommand.getInstance().getCommand(Comment.class);
if (command != null) {
- player.sendMessage(
+ getPlayer().sendMessage(
TranslatableCaption.of("tutorial.comment_this"),
Template.of("plot", "/plot rate")
);
@@ -241,7 +240,7 @@ public class Rate extends SubCommand {
plot.addRating(uuid, event.getRating());
player.sendMessage(
TranslatableCaption.of("ratings.rating_applied"),
- Template.of("value", plot.getId().toString())
+ Template.of("plot", plot.getId().toString())
);
}
};
diff --git a/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java b/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java
index 478fb29d3..7b5e0651f 100644
--- a/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java
+++ b/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -38,7 +38,6 @@ import net.kyori.adventure.text.minimessage.Template;
import javax.annotation.Nonnull;
@CommandDeclaration(command = "regenallroads",
- description = "Regenerate all roads in the map using the set road schematic",
aliases = {"rgar"},
usage = "/plot regenallroads [height]",
category = CommandCategory.ADMINISTRATION,
@@ -89,7 +88,7 @@ public class RegenAllRoads extends SubCommand {
String name = args[0];
PlotManager manager = area.getPlotManager();
if (!(manager instanceof HybridPlotManager)) {
- player.sendMessage(TranslatableCaption.of("errors.not_valid_plot_world"));
+ player.sendMessage(TranslatableCaption.of("errors.invalid_plot_world"));
return false;
}
//Set chunks = ChunkManager.manager.getChunkChunks(name);
diff --git a/Core/src/main/java/com/plotsquared/core/command/Relight.java b/Core/src/main/java/com/plotsquared/core/command/Relight.java
index 3737902b1..184a99571 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Relight.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Relight.java
@@ -21,11 +21,11 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
-import com.plotsquared.core.configuration.caption.StaticCaption;
+import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
@@ -33,7 +33,6 @@ import com.plotsquared.core.util.task.RunnableVal3;
import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "relight",
- description = "Relight your plot",
usage = "/plot relight",
category = CommandCategory.DEBUG,
requiredType = RequiredType.PLAYER)
@@ -46,7 +45,7 @@ public class Relight extends Command {
public CompletableFuture execute(final PlotPlayer> player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) {
- player.sendMessage(StaticCaption.of("Not implemented."));
+ player.sendMessage(TranslatableCaption.of("errors.not_implemented"));
/* final Plot plot = player.getCurrentPlot();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
diff --git a/Core/src/main/java/com/plotsquared/core/command/Reload.java b/Core/src/main/java/com/plotsquared/core/command/Reload.java
index f709c6bbf..1d4e1298d 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Reload.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Reload.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -39,13 +39,11 @@ import com.plotsquared.core.plot.world.PlotAreaManager;
import javax.annotation.Nonnull;
import java.io.File;
-import java.io.IOException;
import java.util.Objects;
@CommandDeclaration(command = "reload",
aliases = "rl",
permission = "plots.admin.command.reload",
- description = "Reload translations and world settings",
usage = "/plot reload",
category = CommandCategory.ADMINISTRATION)
public class Reload extends SubCommand {
@@ -117,7 +115,7 @@ public class Reload extends SubCommand {
});
this.worldConfiguration.save(this.worldFile);
player.sendMessage(TranslatableCaption.of("reload.reloaded_configs"));
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
player.sendMessage(TranslatableCaption.of("reload.reload_failed"));
}
diff --git a/Core/src/main/java/com/plotsquared/core/command/Remove.java b/Core/src/main/java/com/plotsquared/core/command/Remove.java
index ae8b12765..aeee2a30d 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Remove.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Remove.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -46,7 +46,6 @@ import java.util.concurrent.TimeoutException;
@CommandDeclaration(command = "remove",
aliases = {"r", "untrust", "ut", "undeny", "unban", "ud"},
- description = "Remove a player from a plot",
usage = "/plot remove ",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE,
diff --git a/Core/src/main/java/com/plotsquared/core/command/RequiredType.java b/Core/src/main/java/com/plotsquared/core/command/RequiredType.java
index c474680f6..e09866aca 100644
--- a/Core/src/main/java/com/plotsquared/core/command/RequiredType.java
+++ b/Core/src/main/java/com/plotsquared/core/command/RequiredType.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -32,8 +32,8 @@ import com.plotsquared.core.configuration.caption.TranslatableCaption;
import javax.annotation.Nonnull;
public enum RequiredType {
- CONSOLE(TranslatableCaption.of("console.is_console")),
- PLAYER(TranslatableCaption.of("console.not_console")),
+ CONSOLE(TranslatableCaption.of("console.not_console")),
+ PLAYER(TranslatableCaption.of("console.is_console")),
NONE(StaticCaption.of("Something went wrong: RequiredType=NONE")); // this caption should never be sent
private final Caption caption;
diff --git a/Core/src/main/java/com/plotsquared/core/command/Save.java b/Core/src/main/java/com/plotsquared/core/command/Save.java
index 1690d1380..636096943 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Save.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Save.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -47,7 +47,6 @@ import java.util.List;
import java.util.UUID;
@CommandDeclaration(command = "save",
- description = "Save your plot",
category = CommandCategory.SCHEMATIC,
requiredType = RequiredType.NONE,
permission = "plots.save")
diff --git a/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java b/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java
index ea031c0cf..2146c81ab 100644
--- a/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java
+++ b/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -52,7 +52,6 @@ import java.util.UUID;
@CommandDeclaration(command = "schematic",
permission = "plots.schematic",
- description = "Schematic command",
aliases = {"sch", "schem"},
category = CommandCategory.SCHEMATIC,
usage = "/plot schematic ")
@@ -72,7 +71,7 @@ public class SchematicCmd extends SubCommand {
if (args.length < 1) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
- Template.of("value", "Possible values: save, paste , exportall, list")
+ Template.of("value", "Possible values: save, paste, exportall, list")
);
return true;
}
@@ -89,7 +88,7 @@ public class SchematicCmd extends SubCommand {
if (args.length < 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
- Template.of("value", "Possible values: save, paste , exportall, list")
+ Template.of("value", "Possible values: save, paste, exportall, list")
);
break;
}
@@ -266,7 +265,7 @@ public class SchematicCmd extends SubCommand {
default:
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
- Template.of("value", "Possible values: save, paste , exportall, list")
+ Template.of("value", "Possible values: save, paste, exportall, list")
);
break;
}
diff --git a/Core/src/main/java/com/plotsquared/core/command/Set.java b/Core/src/main/java/com/plotsquared/core/command/Set.java
index 90211a409..11015b70d 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Set.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Set.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -58,7 +58,6 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
@CommandDeclaration(command = "set",
- description = "Set a plot value",
aliases = {"s"},
usage = "/plot set ",
permission = "plots.set",
@@ -154,8 +153,8 @@ public class Set extends SubCommand {
BackupManager.backup(player, plot, () -> {
plot.addRunning();
QueueCoordinator queue = plotArea.getQueue();
- for (Plot current : plot.getConnectedPlots()) {
- current.setComponent(component, pattern, queue);
+ for (final Plot current : plot.getConnectedPlots()) {
+ current.getPlotModificationManager().setComponent(component, pattern, queue);
}
queue.setCompleteTask(plot::removeRunning);
queue.enqueue();
diff --git a/Core/src/main/java/com/plotsquared/core/command/SetCommand.java b/Core/src/main/java/com/plotsquared/core/command/SetCommand.java
index a8e4a973c..025baee87 100644
--- a/Core/src/main/java/com/plotsquared/core/command/SetCommand.java
+++ b/Core/src/main/java/com/plotsquared/core/command/SetCommand.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
diff --git a/Core/src/main/java/com/plotsquared/core/command/SetHome.java b/Core/src/main/java/com/plotsquared/core/command/SetHome.java
index e0a7497fc..95940ea39 100644
--- a/Core/src/main/java/com/plotsquared/core/command/SetHome.java
+++ b/Core/src/main/java/com/plotsquared/core/command/SetHome.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -34,7 +34,6 @@ import net.kyori.adventure.text.minimessage.Template;
@CommandDeclaration(command = "sethome",
permission = "plots.set.home",
- description = "Set the plot home to your current position",
usage = "/plot sethome [none]",
aliases = {"sh", "seth"},
category = CommandCategory.SETTINGS,
diff --git a/Core/src/main/java/com/plotsquared/core/command/Setup.java b/Core/src/main/java/com/plotsquared/core/command/Setup.java
index 5bf6fb974..eb870880b 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Setup.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Setup.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -47,7 +47,6 @@ import java.util.Map.Entry;
@CommandDeclaration(command = "setup",
permission = "plots.admin.command.setup",
- description = "Setup wizard for plot worlds",
usage = "/plot setup",
aliases = {"create"},
category = CommandCategory.ADMINISTRATION)
@@ -61,14 +60,14 @@ public class Setup extends SubCommand {
public void displayGenerators(PlotPlayer> player) {
StringBuilder message = new StringBuilder();
- message.append("&6What generator do you want?");
+ message.append("What generator do you want?");
for (Entry> entry : SetupUtils.generators.entrySet()) {
if (entry.getKey().equals(PlotSquared.platform().getPluginName())) {
- message.append("\n&8 - &2").append(entry.getKey()).append(" (Default Generator)");
+ message.append("\n - ").append(entry.getKey()).append(" (Default Generator)");
} else if (entry.getValue().isFull()) {
- message.append("\n&8 - &7").append(entry.getKey()).append(" (Plot Generator)");
+ message.append("\n - ").append(entry.getKey()).append(" (Plot Generator)");
} else {
- message.append("\n&8 - &7").append(entry.getKey()).append(" (Unknown structure)");
+ message.append("\n - ").append(entry.getKey()).append(" (Unknown structure)");
}
}
player.sendMessage(StaticCaption.of(message.toString()));
diff --git a/Core/src/main/java/com/plotsquared/core/command/SubCommand.java b/Core/src/main/java/com/plotsquared/core/command/SubCommand.java
index ad7665522..7b6768270 100644
--- a/Core/src/main/java/com/plotsquared/core/command/SubCommand.java
+++ b/Core/src/main/java/com/plotsquared/core/command/SubCommand.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
diff --git a/Core/src/main/java/com/plotsquared/core/command/Swap.java b/Core/src/main/java/com/plotsquared/core/command/Swap.java
index 0432ca643..6bb379c6c 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Swap.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Swap.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -39,7 +39,6 @@ import java.util.concurrent.CompletableFuture;
@CommandDeclaration(usage = "/plot swap ",
command = "swap",
- description = "Swap two plots",
aliases = {"switch"},
category = CommandCategory.CLAIMING,
requiredType = RequiredType.PLAYER)
@@ -85,7 +84,7 @@ public class Swap extends SubCommand {
return CompletableFuture.completedFuture(false);
}
- return plot1.move(plot2, () -> {
+ return plot1.getPlotModificationManager().move(plot2, () -> {
}, true).thenApply(result -> {
if (result) {
player.sendMessage(TranslatableCaption.of("swap.swap_success"));
diff --git a/Core/src/main/java/com/plotsquared/core/command/Target.java b/Core/src/main/java/com/plotsquared/core/command/Target.java
index 321e8bfd4..eccb5056a 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Target.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Target.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -30,12 +30,18 @@ import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.StringMan;
+import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.query.PlotQuery;
import net.kyori.adventure.text.minimessage.Template;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Locale;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
@CommandDeclaration(command = "target",
- usage = "/plot target < | nearest>",
- description = "Target a plot with your compass",
+ usage = "/plot target < | nearest>",
permission = "plots.target",
requiredType = RequiredType.PLAYER,
category = CommandCategory.INFO)
@@ -54,7 +60,7 @@ public class Target extends SubCommand {
if (args.length == 0) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
- Template.of("value", "/plot target < | nearest>")
+ Template.of("value", "/plot target < | nearest>")
);
return false;
}
@@ -79,4 +85,10 @@ public class Target extends SubCommand {
player.sendMessage(TranslatableCaption.of("compass.compass_target"));
return true;
}
+ @Override public Collection tab(final PlotPlayer player, String[] args, boolean space) {
+ return Stream.of("", "nearest")
+ .filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH)))
+ .map(value -> new Command(null, false, value, "plots.target", RequiredType.NONE, null) {
+ }).collect(Collectors.toList());
+ }
}
diff --git a/Core/src/main/java/com/plotsquared/core/command/Template.java b/Core/src/main/java/com/plotsquared/core/command/Template.java
index 1cf1e8c33..a384c74ac 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Template.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Template.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -54,14 +54,17 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.util.Collection;
+import java.util.Locale;
import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
@CommandDeclaration(command = "template",
permission = "plots.admin",
- description = "Create or use a world template",
usage = "/plot template [import | export] ",
category = CommandCategory.ADMINISTRATION)
public class Template extends SubCommand {
@@ -239,7 +242,8 @@ public class Template extends SubCommand {
}
final PlotArea area = this.plotAreaManager.getPlotAreaByString(world);
if (area == null) {
- player.sendMessage(TranslatableCaption.of("errors.not_valid_plot_world"));
+ player.sendMessage(TranslatableCaption.of("errors.not_valid_plot_world"),
+ net.kyori.adventure.text.minimessage.Template.of("value", args[1]));
return false;
}
final PlotManager manager = area.getPlotManager();
@@ -262,4 +266,10 @@ public class Template extends SubCommand {
}
return false;
}
+ @Override public Collection tab(final PlotPlayer player, String[] args, boolean space) {
+ return Stream.of("import", "export")
+ .filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH)))
+ .map(value -> new Command(null, false, value, "plots.admin", RequiredType.NONE, null) {
+ }).collect(Collectors.toList());
+ }
}
diff --git a/Core/src/main/java/com/plotsquared/core/command/Toggle.java b/Core/src/main/java/com/plotsquared/core/command/Toggle.java
index 53c94440a..66a34a4d3 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Toggle.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Toggle.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -35,7 +35,6 @@ import net.kyori.adventure.text.minimessage.Template;
aliases = {"attribute"},
permission = "plots.use",
usage = "/plot toggle ",
- description = "Toggle per user settings",
requiredType = RequiredType.NONE,
category = CommandCategory.SETTINGS)
public class Toggle extends Command {
@@ -45,8 +44,7 @@ public class Toggle extends Command {
@CommandDeclaration(command = "chatspy",
aliases = {"spy"},
- permission = "plots.admin.command.chat",
- description = "Toggle plot chat spy")
+ permission = "plots.admin.command.chat")
public void chatspy(Command command, PlotPlayer> player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) {
@@ -65,8 +63,7 @@ public class Toggle extends Command {
@CommandDeclaration(command = "worldedit",
aliases = {"we", "wea"},
- permission = "plots.worldedit.bypass",
- description = "Toggle worldedit area restrictions")
+ permission = "plots.worldedit.bypass")
public void worldedit(Command command, PlotPlayer> player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) {
@@ -84,8 +81,7 @@ public class Toggle extends Command {
}
@CommandDeclaration(command = "chat",
- permission = "plots.toggle.chat",
- description = "Toggle plot chat")
+ permission = "plots.toggle.chat")
public void chat(Command command, PlotPlayer> player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) {
@@ -103,8 +99,7 @@ public class Toggle extends Command {
}
@CommandDeclaration(command = "clear-confirmation",
- permission = "plots.admin.command.autoclear",
- description = "Toggle autoclear confirmation")
+ permission = "plots.admin.command.autoclear")
public void clearConfirmation(Command command, PlotPlayer> player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) {
@@ -122,8 +117,7 @@ public class Toggle extends Command {
}
@CommandDeclaration(command = "titles",
- permission = "plots.toggle.titles",
- description = "Toggle plot title messages")
+ permission = "plots.toggle.titles")
public void titles(Command command, PlotPlayer> player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) {
@@ -141,8 +135,7 @@ public class Toggle extends Command {
}
@CommandDeclaration(command = "time",
- permission = "plots.toggle.time",
- description = "Toggle plot time settings")
+ permission = "plots.toggle.time")
public void time(Command command, PlotPlayer> player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) {
@@ -160,8 +153,7 @@ public class Toggle extends Command {
}
@CommandDeclaration(command = "debug",
- permission = "plots.toggle.debug",
- description = "Toggle plot debugging")
+ permission = "plots.toggle.debug")
public void debug(Command command, PlotPlayer> player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) {
diff --git a/Core/src/main/java/com/plotsquared/core/command/Trim.java b/Core/src/main/java/com/plotsquared/core/command/Trim.java
index 0c471dc9b..7116f588c 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Trim.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Trim.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -57,7 +57,6 @@ import java.util.Set;
@CommandDeclaration(command = "trim",
permission = "plots.admin",
- description = "Delete unmodified portions of your plotworld",
usage = "/plot trim [regenerate]",
requiredType = RequiredType.CONSOLE,
category = CommandCategory.ADMINISTRATION)
@@ -86,7 +85,7 @@ public class Trim extends SubCommand {
*
* @param world The world
* @param result (viable = .mcr to trim, nonViable = .mcr keep)
- * @return
+ * @return success or not
*/
public static boolean getTrimRegions(String world,
final RunnableVal2, Set> result) {
@@ -145,15 +144,15 @@ public class Trim extends SubCommand {
@Override public void run(Set viable, final Set nonViable) {
Runnable regenTask;
if (regen) {
- logger.info("[P2] Starting regen task");
- logger.info("[P2] - This is a VERY slow command");
- logger.info("[P2] - It will say 'Trim done!' when complete");
+ logger.info("Starting regen task");
+ logger.info(" - This is a VERY slow command");
+ logger.info(" - It will say 'Trim done!' when complete");
regenTask = new Runnable() {
@Override public void run() {
if (nonViable.isEmpty()) {
Trim.TASK = false;
player.sendMessage(TranslatableCaption.of("trim.trim_done"));
- logger.info("[P2] Trim done!");
+ logger.info("Trim done!");
return;
}
Iterator iterator = nonViable.iterator();
@@ -203,7 +202,7 @@ public class Trim extends SubCommand {
regenTask = () -> {
Trim.TASK = false;
player.sendMessage(TranslatableCaption.of("trim.trim_done"));
- logger.info("[P2] Trim done!");
+ logger.info("Trim done!");
};
}
regionManager.deleteRegionFiles(world, viable, regenTask);
diff --git a/Core/src/main/java/com/plotsquared/core/command/Trust.java b/Core/src/main/java/com/plotsquared/core/command/Trust.java
index 736719745..965315f5a 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Trust.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Trust.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -52,7 +52,6 @@ import java.util.concurrent.TimeoutException;
aliases = {"t"},
requiredType = RequiredType.PLAYER,
usage = "/plot trust ",
- description = "Allow a user to build in a plot and use WorldEdit while the plot owner is offline.",
category = CommandCategory.SETTINGS)
public class Trust extends Command {
diff --git a/Core/src/main/java/com/plotsquared/core/command/Unlink.java b/Core/src/main/java/com/plotsquared/core/command/Unlink.java
index 46b3650ff..1ee3fe370 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Unlink.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Unlink.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -43,7 +43,6 @@ import javax.annotation.Nonnull;
@CommandDeclaration(command = "unlink",
aliases = {"u", "unmerge"},
- description = "Unlink a mega-plot",
usage = "/plot unlink [createroads]",
requiredType = RequiredType.PLAYER,
category = CommandCategory.SETTINGS,
@@ -96,7 +95,7 @@ public class Unlink extends SubCommand {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
}
Runnable runnable = () -> {
- if (!plot.unlinkPlot(createRoad, createRoad)) {
+ if (!plot.getPlotModificationManager().unlinkPlot(createRoad, createRoad)) {
player.sendMessage(TranslatableCaption.of("merge.unmerge_cancelled"));
return;
}
diff --git a/Core/src/main/java/com/plotsquared/core/command/Visit.java b/Core/src/main/java/com/plotsquared/core/command/Visit.java
index 0d6f300ad..b75182ee0 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Visit.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Visit.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -57,7 +57,6 @@ import java.util.concurrent.TimeoutException;
@CommandDeclaration(command = "visit",
permission = "plots.visit",
- description = "Visit someones plot",
usage = "/plot visit | | [area]|[#] [#]",
aliases = {"v", "tp", "teleport", "goto", "warp"},
requiredType = RequiredType.PLAYER,
diff --git a/Core/src/main/java/com/plotsquared/core/command/WE_Anywhere.java b/Core/src/main/java/com/plotsquared/core/command/WE_Anywhere.java
index 50cda457a..110a67cdc 100644
--- a/Core/src/main/java/com/plotsquared/core/command/WE_Anywhere.java
+++ b/Core/src/main/java/com/plotsquared/core/command/WE_Anywhere.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.command;
@@ -29,7 +29,6 @@ import com.plotsquared.core.player.PlotPlayer;
@CommandDeclaration(command = "weanywhere",
permission = "plots.worldedit.bypass",
- description = "Force bypass of WorldEdit restrictions",
aliases = {"wea"},
usage = "/plot weanywhere",
requiredType = RequiredType.NONE,
diff --git a/Core/src/main/java/com/plotsquared/core/components/ComponentCommand.java b/Core/src/main/java/com/plotsquared/core/components/ComponentCommand.java
index 8c158c417..c2f45b58e 100644
--- a/Core/src/main/java/com/plotsquared/core/components/ComponentCommand.java
+++ b/Core/src/main/java/com/plotsquared/core/components/ComponentCommand.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.components;
diff --git a/Core/src/main/java/com/plotsquared/core/components/ComponentPreset.java b/Core/src/main/java/com/plotsquared/core/components/ComponentPreset.java
index f56668805..298d122a2 100644
--- a/Core/src/main/java/com/plotsquared/core/components/ComponentPreset.java
+++ b/Core/src/main/java/com/plotsquared/core/components/ComponentPreset.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.components;
diff --git a/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java b/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java
index 87fb16dac..9143257cf 100644
--- a/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java
+++ b/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.components;
@@ -83,7 +83,7 @@ public class ComponentPresetManager {
e.printStackTrace();
}
if (!created) {
- logger.error("[P2] Failed to create components.yml");
+ logger.error("Failed to create components.yml");
this.guiName = "&cInvalid!";
this.presets = new ArrayList<>();
return;
@@ -99,7 +99,7 @@ public class ComponentPresetManager {
try {
yamlConfiguration.save(file);
} catch (IOException e) {
- logger.error("[P2] Failed to save default values to components.yml", e);
+ logger.error("Failed to save default values to components.yml", e);
}
}
this.guiName = yamlConfiguration.getString("title", "&6Plot Components");
@@ -109,13 +109,13 @@ public class ComponentPresetManager {
.collect(Collectors.toList());
} else {
final List defaultPreset = Collections.singletonList(
- new ComponentPreset(ClassicPlotManagerComponent.FLOOR, "##wool", 0, "", "&6D&ai&cs&ec&bo &2F&3l&do&9o&4r",
- Arrays.asList("&6Spice up your plot floor"), ItemTypes.YELLOW_WOOL));
+ new ComponentPreset(ClassicPlotManagerComponent.FLOOR, "##wool", 0, "", "Disco Floor",
+ Arrays.asList("Spice up your plot floor"), ItemTypes.YELLOW_WOOL));
yamlConfiguration.set("presets", defaultPreset.stream().map(ComponentPreset::serialize).collect(Collectors.toList()));
try {
yamlConfiguration.save(file);
} catch (final IOException e) {
- logger.error("[P2] Failed to save default values to components.yml", e);
+ logger.error("Failed to save default values to components.yml", e);
}
this.presets = defaultPreset;
}
@@ -128,6 +128,7 @@ public class ComponentPresetManager {
* if the player is in a compatible plot, and sends appropriate
* error messages if not
*
+ * @param player player
* @return Build inventory, if it could be created
*/
@Nullable public PlotInventory buildInventory(final PlotPlayer> player) {
@@ -154,7 +155,7 @@ public class ComponentPresetManager {
final int size = (int) Math.ceil((double) allowedPresets.size() / 9.0D);
final PlotInventory plotInventory = new PlotInventory(this.inventoryUtil, player, size, this.guiName) {
@Override public boolean onClick(final int index) {
- if (!player.getCurrentPlot().equals(plot)) {
+ if (!getPlayer().getCurrentPlot().equals(plot)) {
return false;
}
@@ -168,36 +169,36 @@ public class ComponentPresetManager {
}
if (plot.getRunning() > 0) {
- player.sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
+ getPlayer().sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
return false;
}
final Pattern pattern = PatternUtil.parse(null, componentPreset.getPattern(), false);
if (pattern == null) {
- player.sendMessage(TranslatableCaption.of("preset.preset_invalid"));
+ getPlayer().sendMessage(TranslatableCaption.of("preset.preset_invalid"));
return false;
}
if (componentPreset.getCost() > 0.0D && econHandler != null && plot.getArea().useEconomy()) {
- if (econHandler.getMoney(player) < componentPreset.getCost()) {
- player.sendMessage(TranslatableCaption.of("preset.preset_cannot_afford"));
+ if (econHandler.getMoney(getPlayer()) < componentPreset.getCost()) {
+ getPlayer().sendMessage(TranslatableCaption.of("preset.preset_cannot_afford"));
return false;
} else {
- econHandler.withdrawMoney(player, componentPreset.getCost());
- player.sendMessage(TranslatableCaption.of("economy.removed_balance"),
+ econHandler.withdrawMoney(getPlayer(), componentPreset.getCost());
+ getPlayer().sendMessage(TranslatableCaption.of("economy.removed_balance"),
Template.of("money", componentPreset.getCost() + ""));
}
}
- BackupManager.backup(player, plot, () -> {
+ BackupManager.backup(getPlayer(), plot, () -> {
plot.addRunning();
QueueCoordinator queue = plot.getArea().getQueue();
for (Plot current : plot.getConnectedPlots()) {
- current.setComponent(componentPreset.getComponent().name(), pattern, queue);
+ current.getPlotModificationManager().setComponent(componentPreset.getComponent().name(), pattern, queue);
}
queue.setCompleteTask(plot::removeRunning);
queue.enqueue();
- player.sendMessage(TranslatableCaption.of("working.generating_component"));
+ getPlayer().sendMessage(TranslatableCaption.of("working.generating_component"));
});
return false;
}
diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Config.java b/Core/src/main/java/com/plotsquared/core/configuration/Config.java
index 3995ff964..7ae47fab6 100644
--- a/Core/src/main/java/com/plotsquared/core/configuration/Config.java
+++ b/Core/src/main/java/com/plotsquared/core/configuration/Config.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.configuration;
@@ -53,10 +53,10 @@ public class Config {
* Get the value for a node
* Probably throws some error if you try to get a non existent key
*
- * @param key
- * @param root
- * @param
- * @return
+ * @param key configuration key
+ * @param root configuration class
+ * @param value type
+ * @return value
*/
public static T get(String key, Class> root) {
String[] split = key.split("\\.");
@@ -80,7 +80,7 @@ public class Config {
*
* @param key config node
* @param value value
- * @param root
+ * @param root configuration class
*/
public static void set(String key, Object value, Class extends Config> root) {
String[] split = key.split("\\.");
@@ -98,12 +98,12 @@ public class Config {
field.set(instance, value);
return;
} catch (final Throwable e) {
- logger.error("[P2] Invalid configuration value '{}: {}' in {}", key, value, root.getSimpleName());
+ logger.error("Invalid configuration value '{}: {}' in {}", key, value, root.getSimpleName());
e.printStackTrace();
}
}
}
- logger.error("[P2] Failed to set config option '{}: {}' | {}", key, value, instance);
+ logger.error("Failed to set config option '{}: {}' | {}", key, value, instance);
}
public static boolean load(File file, Class extends Config> root) {
@@ -124,8 +124,8 @@ public class Config {
/**
* Set all values in the file (load first to avoid overwriting)
*
- * @param file
- * @param root
+ * @param file file
+ * @param root configuration file class
*/
public static void save(File file, Class extends Config> root) {
try {
@@ -145,8 +145,8 @@ public class Config {
/**
* Get the static fields in a section.
*
- * @param clazz
- * @return
+ * @param clazz config section
+ * @return map or string against object of static fields
*/
public static Map getFields(Class clazz) {
HashMap map = new HashMap<>();
@@ -289,7 +289,7 @@ public class Config {
setAccessible(field);
return field;
} catch (final Throwable e) {
- logger.error("[P2] Invalid config field: {} for {}",
+ logger.error("Invalid config field: {} for {}",
StringMan.join(split, "."), toNodeName(instance.getClass().getSimpleName()));
e.printStackTrace();
return null;
diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Configuration.java b/Core/src/main/java/com/plotsquared/core/configuration/Configuration.java
index 0e17c3cfb..207262133 100644
--- a/Core/src/main/java/com/plotsquared/core/configuration/Configuration.java
+++ b/Core/src/main/java/com/plotsquared/core/configuration/Configuration.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.configuration;
@@ -33,11 +33,9 @@ import java.util.Map;
public interface Configuration extends ConfigurationSection {
/**
* Sets the default value of the given path as provided.
- *
*
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.
- *
*
If value is null, the value will be removed from the default
* Configuration source.
*
@@ -49,7 +47,6 @@ public interface Configuration extends ConfigurationSection {
/**
* Sets the default values of the given paths as provided.
- *
*
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.
@@ -61,11 +58,9 @@ public interface Configuration extends ConfigurationSection {
/**
* Sets the default values of the given paths as provided.
- *
*
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.
- *
*
This method will not hold a reference to the specified Configuration,
* nor will it automatically update if that Configuration ever changes. If
* you check this, you should set the default source with {@link
@@ -78,9 +73,8 @@ public interface Configuration extends ConfigurationSection {
/**
* Gets the source {@link Configuration} for this configuration.
- *
- *
- * If no configuration source was set, but default values were added, then
+ *
+ *
If no configuration source was set, but default values were added, then
* a {@link MemoryConfiguration} will be returned. If no source was set
* and no defaults were set, then this method will return null.
*
@@ -90,9 +84,8 @@ public interface Configuration extends ConfigurationSection {
/**
* Sets the source of all default values for this {@link Configuration}.
- *
- *
- * If a previous source was set, or previous default values were defined,
+ *
+ *
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.
@@ -102,7 +95,6 @@ public interface Configuration extends ConfigurationSection {
/**
* Gets the {@link ConfigurationOptions} for this {@link Configuration}.
- *
*
All setters through this method are chainable.
*
* @return Options for this configuration
diff --git a/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationNode.java b/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationNode.java
index 89b130d46..71d9399c0 100644
--- a/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationNode.java
+++ b/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationNode.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.configuration;
diff --git a/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationOptions.java b/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationOptions.java
index 293af2257..b7f4c457a 100644
--- a/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationOptions.java
+++ b/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationOptions.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.configuration;
diff --git a/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationSection.java b/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationSection.java
index ddd14735e..8cc73f860 100644
--- a/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationSection.java
+++ b/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationSection.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.configuration;
diff --git a/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationUtil.java b/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationUtil.java
index b370deae2..2e2444bbc 100644
--- a/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationUtil.java
+++ b/Core/src/main/java/com/plotsquared/core/configuration/ConfigurationUtil.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.configuration;
diff --git a/Core/src/main/java/com/plotsquared/core/configuration/InvalidConfigurationException.java b/Core/src/main/java/com/plotsquared/core/configuration/InvalidConfigurationException.java
index 03c7353bb..5b87b8e18 100644
--- a/Core/src/main/java/com/plotsquared/core/configuration/InvalidConfigurationException.java
+++ b/Core/src/main/java/com/plotsquared/core/configuration/InvalidConfigurationException.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.configuration;
diff --git a/Core/src/main/java/com/plotsquared/core/configuration/MemoryConfiguration.java b/Core/src/main/java/com/plotsquared/core/configuration/MemoryConfiguration.java
index 88b8433ba..0e1ac50e4 100644
--- a/Core/src/main/java/com/plotsquared/core/configuration/MemoryConfiguration.java
+++ b/Core/src/main/java/com/plotsquared/core/configuration/MemoryConfiguration.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.configuration;
diff --git a/Core/src/main/java/com/plotsquared/core/configuration/MemoryConfigurationOptions.java b/Core/src/main/java/com/plotsquared/core/configuration/MemoryConfigurationOptions.java
index 961c72586..b0f0833cc 100644
--- a/Core/src/main/java/com/plotsquared/core/configuration/MemoryConfigurationOptions.java
+++ b/Core/src/main/java/com/plotsquared/core/configuration/MemoryConfigurationOptions.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.configuration;
diff --git a/Core/src/main/java/com/plotsquared/core/configuration/MemorySection.java b/Core/src/main/java/com/plotsquared/core/configuration/MemorySection.java
index 580730998..561947288 100644
--- a/Core/src/main/java/com/plotsquared/core/configuration/MemorySection.java
+++ b/Core/src/main/java/com/plotsquared/core/configuration/MemorySection.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.configuration;
diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java
index 4ccadcd8c..e59c73677 100644
--- a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java
+++ b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.configuration;
@@ -186,10 +186,7 @@ public class Settings extends Config {
// Miscellaneous
DEBUG = config.getBoolean("debug", DEBUG);
- Chat.CONSOLE_COLOR = config.getBoolean("console.color", Chat.CONSOLE_COLOR);
Chat.INTERACTIVE = config.getBoolean("chat.fancy", Chat.INTERACTIVE);
- Enabled_Components.BSTATS =
- config.getBoolean("bstats", Enabled_Components.BSTATS);
Enabled_Components.DATABASE_PURGER =
config.getBoolean("auto-purge", Enabled_Components.DATABASE_PURGER);
@@ -284,7 +281,7 @@ public class Settings extends Config {
INVALID_BLOCKS = Arrays.asList(
// Acacia Stuff
"acacia_button", "acacia_fence_gate", "acacia_door", "acacia_pressure_plate",
- "acaia_trapdoor", "acacia_sapling", "acacia_sign", "acacia_wall_sign", "acacia_leaves",
+ "acacia_trapdoor", "acacia_sapling", "acacia_sign", "acacia_wall_sign", "acacia_leaves",
// Birch Stuff
"birch_button", "birch_fence_gate", "birch_door", "birch_pressure_plate",
"birch_trapdoor", "birch_sapling", "birch_sign", "birch_wall_sign", "birch_leaves",
@@ -438,8 +435,6 @@ public class Settings extends Config {
@Comment("Chat related settings")
public static final class Chat {
- @Comment("Sometimes console color doesn't work, you can disable it here")
- public static boolean CONSOLE_COLOR = true;
@Comment("Should the chat be interactive?") public static boolean INTERACTIVE = true;
}
@@ -592,8 +587,6 @@ public class Settings extends Config {
public static boolean EXTENDED_USERNAME_COMPLETION = true;
@Comment("Command aliases that will be tab completed")
public static List TAB_COMPLETED_ALIASES = Arrays.asList("plot", "plots", "p", "plotsquared", "plot2", "p2", "ps", "2", "plotme", "plotz", "ap");
- @Comment({"Send anonymous PlotSquared statistics to https://bstats.org/.",
- "Please keep this setting enabled. It helps us identifying which parts of PlotSquared are used the most to organize future updates better."}) public static boolean BSTATS = true;
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Storage.java b/Core/src/main/java/com/plotsquared/core/configuration/Storage.java
index 44a0be29b..4a3bc2626 100644
--- a/Core/src/main/java/com/plotsquared/core/configuration/Storage.java
+++ b/Core/src/main/java/com/plotsquared/core/configuration/Storage.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.configuration;
diff --git a/Core/src/main/java/com/plotsquared/core/configuration/caption/Caption.java b/Core/src/main/java/com/plotsquared/core/configuration/caption/Caption.java
index 07a871d4f..f826b7ed2 100644
--- a/Core/src/main/java/com/plotsquared/core/configuration/caption/Caption.java
+++ b/Core/src/main/java/com/plotsquared/core/configuration/caption/Caption.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.configuration.caption;
diff --git a/Core/src/main/java/com/plotsquared/core/configuration/caption/CaptionHolder.java b/Core/src/main/java/com/plotsquared/core/configuration/caption/CaptionHolder.java
index 42605bcd8..347c8e0fb 100644
--- a/Core/src/main/java/com/plotsquared/core/configuration/caption/CaptionHolder.java
+++ b/Core/src/main/java/com/plotsquared/core/configuration/caption/CaptionHolder.java
@@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.configuration.caption;
diff --git a/Core/src/main/java/com/plotsquared/core/configuration/caption/CaptionLoader.java b/Core/src/main/java/com/plotsquared/core/configuration/caption/CaptionLoader.java
index a5d95296d..0e2d65c7f 100644
--- a/Core/src/main/java/com/plotsquared/core/configuration/caption/CaptionLoader.java
+++ b/Core/src/main/java/com/plotsquared/core/configuration/caption/CaptionLoader.java
@@ -21,21 +21,30 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*/
package com.plotsquared.core.configuration.caption;
+import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -44,27 +53,74 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+/**
+ * This class handles loading and updating of message files.
+ */
public final class CaptionLoader {
+ private static final Logger logger = LoggerFactory.getLogger("P2/" + CaptionLoader.class.getSimpleName());
- private static final Gson GSON = new GsonBuilder().create();
- private static final Pattern FILE_NAME_PATTERN = Pattern.compile("messages_(.*)\\.json");
+ private static final Map DEFAULT_MESSAGES;
+ private static final Locale DEFAULT_LOCALE;
+ private static final Gson GSON;
+ private static final Pattern FILE_NAME_PATTERN;
+
+ static {
+ FILE_NAME_PATTERN = Pattern.compile("messages_(.*)\\.json");
+ GSON = new GsonBuilder()
+ .setPrettyPrinting()
+ .disableHtmlEscaping()
+ .create();
+ DEFAULT_LOCALE = Locale.ENGLISH;
+ Map temp;
+ try {
+ temp = loadResource(DEFAULT_LOCALE);
+ } catch (Exception e) {
+ logger.error("Failed to load default messages", e);
+ temp = Collections.emptyMap();
+ }
+ DEFAULT_MESSAGES = temp;
+ }
private CaptionLoader() {
}
- public static CaptionMap loadAll(@Nonnull final Path directory) throws IOException {
+ /**
+ * Load all message files in the given directory into a new CaptionMap.
+ *
+ * @param directory The directory to load files from
+ * @return A new CaptionMap containing the loaded messages
+ * @throws IOException if the files in the given path can't be listed
+ * @see Files#list(Path)
+ * @see #loadSingle(Path)
+ */
+ @Nonnull public static CaptionMap loadAll(@Nonnull final Path directory) throws IOException {
final Map localeMaps = new HashMap<>();
- try (Stream files = Files.list(directory)) {
- List captionFiles = files.filter(Files::isRegularFile).collect(Collectors.toList());
+ try (final Stream files = Files.list(directory)) {
+ final List captionFiles = files.filter(Files::isRegularFile).collect(Collectors.toList());
for (Path file : captionFiles) {
- CaptionMap localeMap = loadSingle(file);
- localeMaps.put(localeMap.getLocale(), localeMap);
+ try {
+ final CaptionMap localeMap = loadSingle(file);
+ localeMaps.put(localeMap.getLocale(), localeMap);
+ } catch (Exception e) {
+ logger.error("Failed to load language file '{}'", file.getFileName().toString(), e);
+ }
}
+ logger.info("Loaded {} message files. Loaded Languages: {}", localeMaps.size(), localeMaps.keySet());
return new PerUserLocaleCaptionMap(localeMaps);
}
}
- public static CaptionMap loadSingle(@Nonnull final Path file) throws IOException {
+ /**
+ * Load a message file into a new CaptionMap. The file name must match
+ * the pattern {@code messages_.json} where {@code }
+ * is a valid {@link Locale} string.
+ *
+ * @param file The file to load
+ * @return A new CaptionMap containing the loaded messages
+ * @throws IOException if the file couldn't be accessed or read successfully.
+ * @throws IllegalArgumentException if the file name doesn't match the specified format.
+ */
+ @Nonnull public static CaptionMap loadSingle(@Nonnull final Path file) throws IOException {
final String fileName = file.getFileName().toString();
final Matcher matcher = FILE_NAME_PATTERN.matcher(fileName);
final Locale locale;
@@ -73,15 +129,77 @@ public final class CaptionLoader {
} else {
throw new IllegalArgumentException(fileName + " is an invalid message file (cannot extract locale)");
}
- JsonObject object = GSON.fromJson(
- Files.newBufferedReader(file, StandardCharsets.UTF_16),
- JsonObject.class);
- Map captions = new HashMap<>();
- for (Map.Entry entry : object.entrySet()) {
- TranslatableCaption key = TranslatableCaption.of(entry.getKey());
- captions.put(key, entry.getValue().getAsString());
+ try (final BufferedReader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) {
+ Map map = loadFromReader(reader);
+ if (patch(map, locale)) {
+ save(file, map); // update the file using the modified map
+ }
+ return new LocalizedCaptionMap(locale, map.entrySet().stream()
+ .collect(Collectors.toMap(entry -> TranslatableCaption.of(entry.getKey()), Map.Entry::getValue)));
}
- return new LocalizedCaptionMap(locale, captions);
}
+ @SuppressWarnings("UnstableApiUsage")
+ private static Map loadFromReader(final Reader reader) {
+ final Type type = new TypeToken