diff --git a/Bukkit/build.gradle b/Bukkit/build.gradle index ddddb16b5..d4c4d5994 100644 --- a/Bukkit/build.gradle +++ b/Bukkit/build.gradle @@ -98,13 +98,24 @@ task copyFiles { } } +def adventureVersion = '4.0.0-SNAPSHOT' shadowJar { dependencies { include(dependency(":PlotSquared-Core")) include(dependency("io.papermc:paperlib:1.0.4")) - include(dependency("net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT")) + include(dependency("net.kyori:adventure-platform-bukkit:${adventureVersion}")) include(dependency("net.kyori:adventure-text-minimessage:3.0.0-SNAPSHOT")) + include(dependency("net.kyori:adventure-text-serializer-bungeecord:${adventureVersion}")) + include(dependency("net.kyori:adventure-text-serializer-legacy:${adventureVersion}")) + include(dependency("net.kyori:adventure-text-serializer-gson:${adventureVersion}")) + include(dependency("net.kyori:adventure-api:${adventureVersion}")) + include(dependency("net.kyori:adventure-platform-api:${adventureVersion}")) + include(dependency("net.kyori:adventure-platform-common:${adventureVersion}")) + include(dependency("net.kyori:adventure-platform-viaversion:${adventureVersion}")) + include(dependency("net.kyori:adventure-nbt:${adventureVersion}")) + include(dependency("net.kyori:examination-api:1.0.0-SNAPSHOT")) + include(dependency("net.kyori:examination-string:1.0.0-SNAPSHOT")) include(dependency("org.bstats:bstats-bukkit:1.7")) include(dependency("org.khelekore:prtree:1.7.0-SNAPSHOT")) include(dependency("com.sk89q:squirrelid:1.0.0-SNAPSHOT")) @@ -118,7 +129,7 @@ shadowJar { include(dependency('com.intellectualsites:Pipeline:1.4.0-SNAPSHOT')) } - relocate('net.kyori.text', 'com.plotsquared.formatting.text') + relocate('net.kyori.adventure', 'com.plotsquared.core.configuration.adventure') relocate("io.papermc.lib", "com.plotsquared.bukkit.paperlib") relocate("org.bstats", "com.plotsquared.metrics") relocate('com.sk89q.squirrelid', 'com.plotsquared.squirrelid') @@ -126,6 +137,7 @@ shadowJar { relocate('org.apache.logging.slf4j', 'com.plotsquared.logging.apache') relocate('org.slf4j', 'com.plotsquared.logging.slf4j') relocate('com.google.inject', 'com.plotsquared.google') + relocate('javax.inject', 'com.plotsquared.core.inject.javax') archiveFileName = "${project.name}-${parent.version}.jar" destinationDirectory = file "../target" diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitCommand.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitCommand.java index 19a83fba8..1ba24bbde 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitCommand.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitCommand.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.bukkit; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java index b5779ac6d..8e2f4945b 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.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.bukkit; @@ -29,6 +29,7 @@ import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; +import com.google.inject.Singleton; import com.google.inject.Stage; import com.google.inject.TypeLiteral; import com.plotsquared.bukkit.generator.BukkitPlotGenerator; @@ -161,7 +162,7 @@ import static com.plotsquared.core.util.PremiumVerification.getResourceID; import static com.plotsquared.core.util.PremiumVerification.getUserID; import static com.plotsquared.core.util.ReflectionUtils.getRefClass; -@SuppressWarnings("unused") +@SuppressWarnings("unused") @Singleton public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPlatform { private static final Logger logger = LoggerFactory.getLogger("P2/" + BukkitPlatform.class.getSimpleName()); @@ -256,12 +257,12 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl } if (PremiumVerification.isPremium()) { - logger.info("[P2] PlotSquared version licensed to Spigot user {}", getUserID()); - logger.info("[P2] https://www.spigotmc.org/resources/{}", getResourceID()); - logger.info("[P2] Download ID: {}", getDownloadID()); - logger.info("[P2] Thanks for supporting us :)"); + logger.info("PlotSquared version licensed to Spigot user {}", getUserID()); + logger.info("https://www.spigotmc.org/resources/{}", getResourceID()); + logger.info("Download ID: {}", getDownloadID()); + logger.info("Thanks for supporting us :)"); } else { - logger.info("[P2] Couldn't verify purchase :("); + logger.info("Couldn't verify purchase :("); } // Database @@ -273,7 +274,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl if (!plotSquared.getConfigurationVersion().equalsIgnoreCase("v5")) { // Perform upgrade if (DBFunc.dbManager.convertFlags()) { - logger.info("[P2] Flags were converted successfully!"); + logger.info("Flags were converted successfully!"); // Update the config version try { plotSquared.setConfigurationVersion("v5"); @@ -297,13 +298,13 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl // WorldEdit if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) { try { - logger.info("[P2] {} hooked into WorldEdit", this.getPluginName()); + logger.info("{} hooked into WorldEdit", this.getPluginName()); WorldEdit.getInstance().getEventBus().register(this.getInjector().getInstance(WESubscriber.class)); if (Settings.Enabled_Components.COMMANDS) { new WE_Anywhere(); } } catch (Throwable e) { - logger.error("[P2] Incompatible version of WorldEdit, please upgrade: https://builds.enginehub.org/job/worldedit?branch=master"); + logger.error("Incompatible version of WorldEdit, please upgrade: https://builds.enginehub.org/job/worldedit?branch=master"); } } @@ -346,7 +347,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl try { getInjector().getInstance(ComponentPresetManager.class); } catch (final Exception e) { - logger.error("[P2] Failed to initialize the preset system", e); + logger.error("Failed to initialize the preset system", e); } } @@ -369,11 +370,11 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl continue; } if (!worldUtil.isWorld(world) && !world.equals("*")) { - logger.warn("[P2] `{}` was not properly loaded - {} will now try to load it properly", world, this.getPluginName()); + logger.warn("`{}` was not properly loaded - {} will now try to load it properly", world, this.getPluginName()); logger.warn( - "[P2] - Are you trying to delete this world? Remember to remove it from the worlds.yml, bukkit.yml and multiverse worlds.yml"); - logger.warn("[P2] - Your world management plugin may be faulty (or non existent)"); - logger.warn("[P2] This message may also be a false positive and could be ignored."); + " - Are you trying to delete this world? Remember to remove it from the worlds.yml, bukkit.yml and multiverse worlds.yml"); + logger.warn(" - Your world management plugin may be faulty (or non existent)"); + logger.warn(" This message may also be a false positive and could be ignored."); this.setGenerator(world); } } @@ -393,7 +394,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl final OfflineModeUUIDService offlineModeUUIDService = new OfflineModeUUIDService(); this.impromptuPipeline.registerService(offlineModeUUIDService); this.backgroundPipeline.registerService(offlineModeUUIDService); - logger.info("[P2] (UUID) Using the offline mode UUID service"); + logger.info("(UUID) Using the offline mode UUID service"); } if (Settings.UUID.SERVICE_BUKKIT) { @@ -414,7 +415,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl final LuckPermsUUIDService luckPermsUUIDService; if (Settings.UUID.SERVICE_LUCKPERMS && Bukkit.getPluginManager().getPlugin("LuckPerms") != null) { luckPermsUUIDService = new LuckPermsUUIDService(); - logger.info("[P2] (UUID) Using LuckPerms as a complementary UUID service"); + logger.info("(UUID) Using LuckPerms as a complementary UUID service"); } else { luckPermsUUIDService = null; } @@ -422,7 +423,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl final BungeePermsUUIDService bungeePermsUUIDService; if (Settings.UUID.SERVICE_BUNGEE_PERMS && Bukkit.getPluginManager().getPlugin("BungeePerms") != null) { bungeePermsUUIDService = new BungeePermsUUIDService(); - logger.info("[P2] (UUID) Using BungeePerms as a complementary UUID service"); + logger.info("(UUID) Using BungeePerms as a complementary UUID service"); } else { bungeePermsUUIDService = null; } @@ -430,7 +431,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl final EssentialsUUIDService essentialsUUIDService; if (Settings.UUID.SERVICE_ESSENTIALSX && Bukkit.getPluginManager().getPlugin("Essentials") != null) { essentialsUUIDService = new EssentialsUUIDService(); - logger.info("[P2] (UUID) Using EssentialsX as a complementary UUID service"); + logger.info("(UUID) Using EssentialsX as a complementary UUID service"); } else { essentialsUUIDService = null; } @@ -441,7 +442,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl final PaperUUIDService paperUUIDService = new PaperUUIDService(); this.impromptuPipeline.registerService(paperUUIDService); this.backgroundPipeline.registerService(paperUUIDService); - logger.info("[P2] (UUID) Using Paper as a complementary UUID service"); + logger.info("(UUID) Using Paper as a complementary UUID service"); } this.impromptuPipeline.registerService(sqLiteUUIDService); @@ -495,17 +496,12 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl if (Settings.Enabled_Components.EXTERNAL_PLACEHOLDERS) { ChatFormatter.formatters.add(getInjector().getInstance(PlaceholderFormatter.class)); } - logger.info("[P2] PlotSquared hooked into PlaceholderAPI"); + logger.info("PlotSquared hooked into PlaceholderAPI"); } else { - logger.info("[P2] PlaceholderAPI is not in use. Hook deactivated"); + logger.info("PlaceholderAPI is not in use. Hook deactivated"); } - if (Settings.Enabled_Components.BSTATS) { - this.startMetrics(); - } - else { - logger.info("[P2] bStats is disabled. Please enable it in /plugins/PlotSquared/config/settings.yml. It helps the developers to identify the features most used and organize future updates better. Cheers."); - } + this.startMetrics(); if (Settings.Enabled_Components.WORLDS) { TaskManager.getPlatformImplementation().taskRepeat(this::unload, TaskTime.seconds(1L)); @@ -574,7 +570,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl final Chunk[] chunks = world.getLoadedChunks(); if (chunks.length == 0) { if (!Bukkit.unloadWorld(world, true)) { - logger.warn("[P2] Failed to unload {}", world.getName()); + logger.warn("Failed to unload {}", world.getName()); } return; } else { @@ -623,7 +619,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl } }); - logger.info("[P2] (UUID) {} UUIDs will be cached", uuidQueue.size()); + logger.info("(UUID) {} UUIDs will be cached", uuidQueue.size()); Executors.newSingleThreadScheduledExecutor().schedule(() -> { // Begin by reading all the SQLite cache at once @@ -631,7 +627,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl // Now fetch names for all known UUIDs final int totalSize = uuidQueue.size(); int read = 0; - logger.info("[P2] (UUID) PlotSquared will fetch UUIDs in groups of {}", Settings.UUID.BACKGROUND_LIMIT); + logger.info("(UUID) PlotSquared will fetch UUIDs in groups of {}", Settings.UUID.BACKGROUND_LIMIT); final List uuidList = new ArrayList<>(Settings.UUID.BACKGROUND_LIMIT); // Used to indicate that the second retrieval has been attempted @@ -639,7 +635,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl while (!uuidQueue.isEmpty() || !uuidList.isEmpty()) { if (!uuidList.isEmpty() && secondRun) { - logger.warn("[P2] (UUID) Giving up on last batch. Fetching new batch instead"); + logger.warn("(UUID) Giving up on last batch. Fetching new batch instead"); uuidList.clear(); } if (uuidList.isEmpty()) { @@ -663,13 +659,13 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl // Print progress final double percentage = ((double) read / (double) totalSize) * 100.0D; if (Settings.DEBUG) { - logger.info("[P2] (UUID) PlotSquared has cached {} of UUIDs", String.format("%.1f%%", percentage)); + logger.info("(UUID) PlotSquared has cached {} of UUIDs", String.format("%.1f%%", percentage)); } } catch (final InterruptedException | ExecutionException e) { - logger.error("[P2] (UUID) Failed to retrieve last batch. Will try again", e); + logger.error("(UUID) Failed to retrieve last batch. Will try again", e); } } - logger.info("[P2] (UUID) PlotSquared has cached all UUIDs"); + logger.info("(UUID) PlotSquared has cached all UUIDs"); }, 10, TimeUnit.SECONDS); } @@ -701,7 +697,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl } @SuppressWarnings("deprecation") private void runEntityTask() { - logger.info("[P2] KillAllEntities started"); + logger.info("KillAllEntities started"); TaskManager.runTaskRepeat(() -> this.plotAreaManager.forEachPlotArea(plotArea -> { final World world = Bukkit.getWorld(plotArea.getWorldName()); try { @@ -979,7 +975,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl return; } this.metricsStarted = true; - Metrics metrics = new Metrics(this, BSTATS_ID);// bstats + Metrics metrics = new Metrics(this, BSTATS_ID); // bstats metrics.addCustomChart(new Metrics.DrilldownPie("area_types", () -> { final Map> map = new HashMap<>(); for (final PlotAreaType plotAreaType : PlotAreaType.values()) { @@ -1022,7 +1018,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl SetGenCB.setGenerator(BukkitUtil.getWorld(worldName)); } } catch (final Exception e) { - logger.error("[P2] Failed to reload world: {} | {}", world, e.getMessage()); + logger.error("Failed to reload world: {} | {}", world, e.getMessage()); Bukkit.getServer().unloadWorld(world, false); return; } @@ -1093,4 +1089,15 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl return (PlayerManager) getInjector().getInstance(PlayerManager.class); } + @Override public void copyCaptionMaps() { + /* Make this prettier at some point */ + final String[] languages = new String[] { "en" }; + for (final String language : languages) { + if (!new File(new File(this.getDataFolder(), "lang"), String.format("messages_%s.json", language)).exists()) { + this.saveResource(String.format("lang/messages_%s.json", language), false); + logger.info("Copied language file 'messages_{}.json'", language); + } + } + } + } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/AgeableStats.java b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/AgeableStats.java index 5b9e5ace5..21efd616e 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/AgeableStats.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/AgeableStats.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.bukkit.entity; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ArmorStandStats.java b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ArmorStandStats.java index 8c49e1f2a..bd81de12d 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ArmorStandStats.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ArmorStandStats.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.bukkit.entity; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/EntityBaseStats.java b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/EntityBaseStats.java index 6a99e7771..b2be16c84 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/EntityBaseStats.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/EntityBaseStats.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.bukkit.entity; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/EntityWrapper.java b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/EntityWrapper.java index 7cf12c1e0..581fded37 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/EntityWrapper.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/EntityWrapper.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.bukkit.entity; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/HorseStats.java b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/HorseStats.java index af97ac055..360125a46 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/HorseStats.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/HorseStats.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.bukkit.entity; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/LivingEntityStats.java b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/LivingEntityStats.java index cbad9f8f8..6445370aa 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/LivingEntityStats.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/LivingEntityStats.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.bukkit.entity; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ReplicatingEntityWrapper.java b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ReplicatingEntityWrapper.java index 74dfbdf07..7b92b499f 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ReplicatingEntityWrapper.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ReplicatingEntityWrapper.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.bukkit.entity; @@ -391,7 +391,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { try { entity.getInventory().setContents(this.inventory); } catch (IllegalArgumentException e) { - logger.error("[P2] Failed to restore inventory", e); + logger.error("Failed to restore inventory", e); } } @@ -738,7 +738,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { return entity; default: if (Settings.DEBUG) { - logger.info("[P2] Could not identify entity: {}", entity.getType()); + logger.info("Could not identify entity: {}", entity.getType()); } return entity; // END LIVING diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/TameableStats.java b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/TameableStats.java index b844495ac..e4e6ae54e 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/TameableStats.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/TameableStats.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.bukkit.entity; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/TeleportEntityWrapper.java b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/TeleportEntityWrapper.java index 2393d2fa4..c829c0739 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/TeleportEntityWrapper.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/TeleportEntityWrapper.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.bukkit.entity; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BlockStatePopulator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BlockStatePopulator.java index 9a05dd773..662ff8703 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BlockStatePopulator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BlockStatePopulator.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.bukkit.generator; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitAugmentedGenerator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitAugmentedGenerator.java index d46612201..dc8a6a5ef 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitAugmentedGenerator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitAugmentedGenerator.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.bukkit.generator; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java index c1db952e2..67b177770 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.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.bukkit.generator; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/DelegatePlotGenerator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/DelegatePlotGenerator.java index 6a0a3ce7d..dcd896b49 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/DelegatePlotGenerator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/DelegatePlotGenerator.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.bukkit.generator; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/inject/BackupModule.java b/Bukkit/src/main/java/com/plotsquared/bukkit/inject/BackupModule.java index d97cf5d05..e155a99b2 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/inject/BackupModule.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/inject/BackupModule.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.bukkit.inject; @@ -46,8 +46,8 @@ public class BackupModule extends AbstractModule { .implement(BackupProfile.class, PlayerBackupProfile.class).build(PlayerBackupProfileFactory.class)); bind(BackupManager.class).to(SimpleBackupManager.class); } catch (final Exception e) { - logger.error("[P2] Failed to initialize backup manager", e); - logger.error("[P2] Backup features will be disabled"); + logger.error("Failed to initialize backup manager", e); + logger.error("Backup features will be disabled"); bind(BackupManager.class).to(NullBackupManager.class); } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/inject/BukkitModule.java b/Bukkit/src/main/java/com/plotsquared/bukkit/inject/BukkitModule.java index a5702d156..64c1c9720 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/inject/BukkitModule.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/inject/BukkitModule.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.bukkit.inject; @@ -84,6 +84,7 @@ public class BukkitModule extends AbstractModule { bind(PlayerManager.class).to(BukkitPlayerManager.class); bind(JavaPlugin.class).toInstance(bukkitPlatform); bind(PlotPlatform.class).toInstance(bukkitPlatform); + bind(BukkitPlatform.class).toInstance(bukkitPlatform); bind(IndependentPlotGenerator.class).annotatedWith(DefaultGenerator.class).to(HybridGen.class); // Console actor @Nonnull ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/inject/PermissionModule.java b/Bukkit/src/main/java/com/plotsquared/bukkit/inject/PermissionModule.java index de42d884a..2f2cc97fa 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/inject/PermissionModule.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/inject/PermissionModule.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.bukkit.inject; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/inject/WorldManagerModule.java b/Bukkit/src/main/java/com/plotsquared/bukkit/inject/WorldManagerModule.java index f098192b5..413662ca1 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/inject/WorldManagerModule.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/inject/WorldManagerModule.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.bukkit.inject; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java index 3f4e75acc..6085f6a1a 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.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.bukkit.listener; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java index bf756fcf0..703cd631b 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.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.bukkit.listener; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java index 27e63ec9a..6da88779e 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.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.bukkit.listener; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java index 24d22e6a0..21152b8e4 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.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.bukkit.listener; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ForceFieldListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ForceFieldListener.java index abd6cc1d8..b3a5802d2 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ForceFieldListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ForceFieldListener.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.bukkit.listener; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java index 347258f7f..70413d799 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.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.bukkit.listener; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java index 2678a7484..713780bcb 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.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.bukkit.listener; @@ -126,6 +126,7 @@ import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLocaleChangeEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerRespawnEvent; @@ -148,6 +149,7 @@ import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import java.util.UUID; import java.util.regex.Pattern; @@ -1624,4 +1626,10 @@ public class PlayerEventListener extends PlotListener implements Listener { } } } + + @EventHandler public void onLocaleChange(final PlayerLocaleChangeEvent event) { + BukkitPlayer player = BukkitUtil.adapt(event.getPlayer()); + // we're stripping the country code as we con't want to differ between countries + player.setLocale(Locale.forLanguageTag(event.getLocale().substring(0, 2))); + } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ProjectileEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ProjectileEventListener.java index 4f16b390a..623b76190 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ProjectileEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ProjectileEventListener.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.bukkit.listener; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ServerListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ServerListener.java index ee824795e..9c20fd425 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ServerListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ServerListener.java @@ -21,10 +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.bukkit.listener; +import com.google.inject.Inject; import com.plotsquared.bukkit.BukkitPlatform; import com.plotsquared.bukkit.placeholder.MVdWPlaceholders; import com.plotsquared.core.PlotSquared; @@ -35,11 +36,13 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.server.ServerLoadEvent; +import javax.annotation.Nonnull; + public class ServerListener implements Listener { private final BukkitPlatform plugin; - public ServerListener(BukkitPlatform plugin) { + @Inject public ServerListener(@Nonnull final BukkitPlatform plugin) { this.plugin = plugin; } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/SingleWorldListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/SingleWorldListener.java index a5885d733..5c550bf2f 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/SingleWorldListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/SingleWorldListener.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.bukkit.listener; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/WorldEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/WorldEvents.java index 7e9f32d04..7498b9b01 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/WorldEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/WorldEvents.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.bukkit.listener; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/managers/BukkitWorldManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/managers/BukkitWorldManager.java index d85e46115..eec3c2b42 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/managers/BukkitWorldManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/managers/BukkitWorldManager.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.bukkit.managers; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/managers/HyperverseWorldManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/managers/HyperverseWorldManager.java index 1c6be936d..1ef8cadd9 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/managers/HyperverseWorldManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/managers/HyperverseWorldManager.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.bukkit.managers; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/managers/MultiverseWorldManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/managers/MultiverseWorldManager.java index 6abb07e81..1477148f7 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/managers/MultiverseWorldManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/managers/MultiverseWorldManager.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.bukkit.managers; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/permissions/BukkitPermissionHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/permissions/BukkitPermissionHandler.java index 6aca7ea62..66b47fec3 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/permissions/BukkitPermissionHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/permissions/BukkitPermissionHandler.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.bukkit.permissions; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/permissions/VaultPermissionHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/permissions/VaultPermissionHandler.java index b7b08a49f..51d7cf2b2 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/permissions/VaultPermissionHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/permissions/VaultPermissionHandler.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.bukkit.permissions; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/MVdWPlaceholders.java b/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/MVdWPlaceholders.java index 66fcbf679..f1876ccd3 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/MVdWPlaceholders.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/MVdWPlaceholders.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.bukkit.placeholder; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/PAPIPlaceholders.java b/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/PAPIPlaceholders.java index 9a5ebdb82..5e05f5e95 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/PAPIPlaceholders.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/PAPIPlaceholders.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.bukkit.placeholder; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/PlaceholderFormatter.java b/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/PlaceholderFormatter.java index 8efdc3fba..050b881e1 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/PlaceholderFormatter.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/PlaceholderFormatter.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.bukkit.placeholder; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitOfflinePlayer.java b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitOfflinePlayer.java index 799fbf2b1..13e34166d 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitOfflinePlayer.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitOfflinePlayer.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.bukkit.player; @@ -45,6 +45,9 @@ public class BukkitOfflinePlayer implements OfflinePlotPlayer { /** * Please do not use this method. Instead use BukkitUtil.getPlayer(Player), * as it caches player objects. + * + * @param player Bukkit OfflinePlayer player to convert + * @param permissionHandler Permission Profile to be used */ public BukkitOfflinePlayer(@Nonnull final OfflinePlayer player, @Nonnull final PermissionHandler permissionHandler) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java index 4f526bc11..4d6e36e44 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.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.bukkit.player; @@ -78,7 +78,11 @@ public class BukkitPlayer extends PlotPlayer { *

Please do not use this method. Instead use * BukkitUtil.getPlayer(Player), as it caches player objects.

* + * @param plotAreaManager PlotAreaManager instance + * @param eventDispatcher EventDispatcher instance * @param player Bukkit player instance + * @param econHandler EconHandler instance + * @param permissionHandler PermissionHandler instance */ public BukkitPlayer(@Nonnull final PlotAreaManager plotAreaManager, @Nonnull final EventDispatcher eventDispatcher, @Nonnull final Player player, @Nullable final EconHandler econHandler, @Nonnull final PermissionHandler permissionHandler) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayerManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayerManager.java index 3666f407b..48ea59b68 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayerManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayerManager.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.bukkit.player; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java index 3ab6e31c0..8d50f7a11 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.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.bukkit.queue; @@ -55,7 +55,7 @@ import java.util.function.Consumer; * and allows the caller to specify a sink for the loaded chunks. The * coordinator will prevent the chunks from being unloaded until the sink * has fully consumed the chunk - *

+ *

**/ public final class BukkitChunkCoordinator extends ChunkCoordinator { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitQueueCoordinator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitQueueCoordinator.java index 460d6ac1e..a0e5b028f 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitQueueCoordinator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitQueueCoordinator.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.bukkit.queue; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/ChunkCoordinator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/ChunkCoordinator.java index 4831e3238..97d2f6eab 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/ChunkCoordinator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/ChunkCoordinator.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.bukkit.queue; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/GenChunk.java b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/GenChunk.java index ea22947dd..4ccbdf6a1 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/GenChunk.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/GenChunk.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.bukkit.queue; @@ -71,6 +71,8 @@ public class GenChunk extends ScopedQueueCoordinator { /** * Set the internal Bukkit chunk data + * + * @param chunkData Bukkit ChunkData */ public void setChunkData(@Nonnull ChunkData chunkData) { this.chunkData = chunkData; @@ -88,6 +90,8 @@ public class GenChunk extends ScopedQueueCoordinator { /** * Set the chunk being represented + * + * @param chunk Bukkit Chunk */ public void setChunk(@Nonnull Chunk chunk) { this.chunk = chunk; @@ -96,6 +100,8 @@ public class GenChunk extends ScopedQueueCoordinator { /** * Set the world and XZ of the chunk being represented via {@link ChunkWrapper} + * + * @param wrap P2 ChunkWrapper */ public void setChunk(@Nonnull ChunkWrapper wrap) { chunk = null; @@ -146,6 +152,12 @@ public class GenChunk extends ScopedQueueCoordinator { /** * Set the in the whole column of XZ + * + * @param x Relative x location within the chunk (0 - 15) + * @param z Relative z location within the chunk (0 - 15) + * @param biome Bukkit biome to set + * + * @return if successful */ public boolean setBiome(int x, int z, @Nonnull Biome biome) { if (this.biomeGrid != null) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/schematic/BukkitSchematicHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/schematic/BukkitSchematicHandler.java index f03428726..4d10fc316 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/schematic/BukkitSchematicHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/schematic/BukkitSchematicHandler.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.bukkit.schematic; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/schematic/StateWrapper.java b/Bukkit/src/main/java/com/plotsquared/bukkit/schematic/StateWrapper.java index 93b9a26b2..9c51d2663 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/schematic/StateWrapper.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/schematic/StateWrapper.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.bukkit.schematic; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitBlockUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitBlockUtil.java index f73fad786..67ac72cf7 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitBlockUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitBlockUtil.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.bukkit.util; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java index 8086d805a..502c5696c 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.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.bukkit.util; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEconHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEconHandler.java index ae42296b9..0a24a2657 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEconHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEconHandler.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.bukkit.util; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java index d080d53f6..356b2615f 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.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.bukkit.util; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitInventoryUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitInventoryUtil.java index 46edc15d9..dd312fe51 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitInventoryUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitInventoryUtil.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.bukkit.util; @@ -32,6 +32,7 @@ import com.plotsquared.core.plot.PlotInventory; import com.plotsquared.core.plot.PlotItemStack; import com.plotsquared.core.util.InventoryUtil; import com.sk89q.worldedit.bukkit.BukkitAdapter; +import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -49,11 +50,11 @@ import java.util.stream.IntStream; @Singleton public class BukkitInventoryUtil extends InventoryUtil { @Override public void open(PlotInventory inv) { - BukkitPlayer bp = (BukkitPlayer) inv.player; - Inventory inventory = Bukkit.createInventory(null, inv.size * 9, + BukkitPlayer bp = (BukkitPlayer) inv.getPlayer(); + Inventory inventory = Bukkit.createInventory(null, inv.getLines() * 9, ChatColor.translateAlternateColorCodes('&', inv.getTitle())); PlotItemStack[] items = inv.getItems(); - for (int i = 0; i < inv.size * 9; i++) { + for (int i = 0; i < inv.getLines() * 9; i++) { PlotItemStack item = items[i]; if (item != null) { inventory.setItem(i, getItem(item)); @@ -66,12 +67,12 @@ import java.util.stream.IntStream; if (!inv.isOpen()) { return; } - BukkitPlayer bp = (BukkitPlayer) inv.player; + BukkitPlayer bp = (BukkitPlayer) inv.getPlayer(); bp.player.closeInventory(); } @Override public void setItem(PlotInventory inv, int index, PlotItemStack item) { - BukkitPlayer bp = (BukkitPlayer) inv.player; + BukkitPlayer bp = (BukkitPlayer) inv.getPlayer(); InventoryView opened = bp.player.getOpenInventory(); if (!inv.isOpen()) { return; @@ -84,18 +85,19 @@ import java.util.stream.IntStream; if (item == null) { return null; } - ItemStack stack = new ItemStack(BukkitAdapter.adapt(item.getType()), item.amount); + ItemStack stack = new ItemStack(BukkitAdapter.adapt(item.getType()), item.getAmount()); ItemMeta meta = null; - if (item.name != null) { + if (item.getName() != null) { meta = stack.getItemMeta(); - meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', item.name)); + Component nameComponent = BukkitUtil.MINI_MESSAGE.parse(item.getName()); + meta.setDisplayName(BukkitUtil.LEGACY_COMPONENT_SERIALIZER.serialize(nameComponent)); } - if (item.lore != null) { + if (item.getLore() != null) { if (meta == null) { meta = stack.getItemMeta(); } List lore = new ArrayList<>(); - for (String entry : item.lore) { + for (String entry : item.getLore()) { lore.add(BukkitUtil.LEGACY_COMPONENT_SERIALIZER.serialize(BukkitUtil.MINI_MESSAGE.deserialize(entry))); } meta.setLore(lore); @@ -141,7 +143,7 @@ import java.util.stream.IntStream; if (!plotInventory.isOpen()) { return false; } - BukkitPlayer bp = (BukkitPlayer) plotInventory.player; + BukkitPlayer bp = (BukkitPlayer) plotInventory.getPlayer(); InventoryView opened = bp.player.getOpenInventory(); if (plotInventory.isOpen()) { if (opened.getType() == InventoryType.CRAFTING) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitRegionManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitRegionManager.java index 01e7bf769..11c98a27b 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitRegionManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitRegionManager.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.bukkit.util; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java index 336bbd798..c403b0e36 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.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.bukkit.util; @@ -37,7 +37,6 @@ import com.plotsquared.core.inject.annotations.WorldConfig; import com.plotsquared.core.inject.annotations.WorldFile; import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotAreaType; -import com.plotsquared.core.plot.SetupObject; import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.setup.PlotAreaBuilder; import com.plotsquared.core.util.SetupUtils; @@ -118,111 +117,6 @@ import java.util.Objects; Bukkit.unloadWorld(world, false); } - @Deprecated @Override public String setupWorld(SetupObject object) { - this.updateGenerators(); - ConfigurationNode[] steps = object.step == null ? new ConfigurationNode[0] : object.step; - String world = object.world; - PlotAreaType type = object.type; - String worldPath = "worlds." + object.world; - switch (type) { - case PARTIAL: { - if (object.id != null) { - if (!this.worldConfiguration.contains(worldPath)) { - this.worldConfiguration.createSection(worldPath); - } - ConfigurationSection worldSection = this.worldConfiguration.getConfigurationSection(worldPath); - String areaName = object.id + "-" + object.min + "-" + object.max; - String areaPath = "areas." + areaName; - if (!worldSection.contains(areaPath)) { - worldSection.createSection(areaPath); - } - ConfigurationSection areaSection = - worldSection.getConfigurationSection(areaPath); - HashMap options = new HashMap<>(); - for (ConfigurationNode step : steps) { - options.put(step.getConstant(), step.getValue()); - } - options.put("generator.type", object.type.toString()); - options.put("generator.terrain", object.terrain.toString()); - options.put("generator.plugin", object.plotManager); - if (object.setupGenerator != null && !object.setupGenerator - .equals(object.plotManager)) { - options.put("generator.init", object.setupGenerator); - } - for (Entry entry : options.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - if (worldSection.contains(key)) { - Object current = worldSection.get(key); - if (!Objects.equals(value, current)) { - areaSection.set(key, value); - } - } else { - worldSection.set(key, value); - } - } - } - GeneratorWrapper gen = SetupUtils.generators.get(object.setupGenerator); - if (gen != null && gen.isFull()) { - object.setupGenerator = null; - } - break; - } - case AUGMENTED: { - if (!object.plotManager.endsWith(":single")) { - if (!this.worldConfiguration.contains(worldPath)) { - this.worldConfiguration.createSection(worldPath); - } - if (steps.length != 0) { - ConfigurationSection worldSection = this.worldConfiguration.getConfigurationSection(worldPath); - for (ConfigurationNode step : steps) { - worldSection.set(step.getConstant(), step.getValue()); - } - } - this.worldConfiguration.set("worlds." + world + ".generator.type", object.type.toString()); - this.worldConfiguration.set("worlds." + world + ".generator.terrain", object.terrain.toString()); - this.worldConfiguration.set("worlds." + world + ".generator.plugin", object.plotManager); - if (object.setupGenerator != null && !object.setupGenerator - .equals(object.plotManager)) { - this.worldConfiguration.set("worlds." + world + ".generator.init", object.setupGenerator); - } - } - GeneratorWrapper gen = SetupUtils.generators.get(object.setupGenerator); - if (gen != null && gen.isFull()) { - object.setupGenerator = null; - } - break; - } - case NORMAL: { - if (steps.length != 0) { - if (!this.worldConfiguration.contains(worldPath)) { - this.worldConfiguration.createSection(worldPath); - } - ConfigurationSection worldSection = this.worldConfiguration.getConfigurationSection(worldPath); - for (ConfigurationNode step : steps) { - worldSection.set(step.getConstant(), step.getValue()); - } - } - break; - } - } - - try { - this.worldConfiguration.save(this.worldFile); - } catch (IOException e) { - e.printStackTrace(); - } - - Objects.requireNonNull(PlotSquared.platform()).getWorldManager() - .handleWorldCreation(object.world, object.setupGenerator); - - if (Bukkit.getWorld(world) != null) { - return world; - } - - return object.world; - } - @Override public String setupWorld(PlotAreaBuilder builder) { this.updateGenerators(); ConfigurationNode[] steps = builder.settingsNodesWrapper() == null ? diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java index 962af3de8..5632f4103 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.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.bukkit.util; @@ -116,7 +116,7 @@ public class BukkitUtil extends WorldUtil { private static final Logger logger = LoggerFactory.getLogger("P2/" + BukkitUtil.class.getSimpleName()); public static final BukkitAudiences BUKKIT_AUDIENCES = BukkitAudiences.create(BukkitPlatform.getPlugin(BukkitPlatform.class)); - public static final LegacyComponentSerializer LEGACY_COMPONENT_SERIALIZER = LegacyComponentSerializer.legacyAmpersand(); + public static final LegacyComponentSerializer LEGACY_COMPONENT_SERIALIZER = LegacyComponentSerializer.legacySection(); public static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build(); private final Collection tileEntityTypes = new HashSet<>(); @@ -334,7 +334,7 @@ public class BukkitUtil extends WorldUtil { final Sign sign = (Sign) blockstate; for (int i = 0; i < lines.length; i++) { sign.setLine(i, LEGACY_COMPONENT_SERIALIZER - .serialize(MINI_MESSAGE.parse(lines[i].getComponent(LocaleHolder.console())))); + .serialize(MINI_MESSAGE.parse(lines[i].getComponent(LocaleHolder.console()), replacements))); } sign.update(true); } @@ -349,7 +349,7 @@ public class BukkitUtil extends WorldUtil { @Override public void setBiomes(@Nonnull final String worldName, @Nonnull final CuboidRegion region, @Nonnull final BiomeType biomeType) { final World world = getWorld(worldName); if (world == null) { - logger.warn("[P2] An error occured while setting the biome because the world was null", new RuntimeException()); + logger.warn("An error occurred while setting the biome because the world was null", new RuntimeException()); return; } final Biome biome = BukkitAdapter.adapt(biomeType); @@ -459,7 +459,7 @@ public class BukkitUtil extends WorldUtil { } break; default: { - logger.error("[P2] Unknown entity category requested: {}", category); + logger.error("Unknown entity category requested: {}", category); } break; } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitWorld.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitWorld.java index d06c87d33..8fdcede9d 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitWorld.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitWorld.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.bukkit.util; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/ContentMap.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/ContentMap.java index 03e46582f..ceeb6e6b1 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/ContentMap.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/ContentMap.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.bukkit.util; @@ -126,7 +126,7 @@ public class ContentMap { try { entity.spawn(world, xOffset, zOffset); } catch (Exception e) { - logger.error("[P2] Failed to restore entity", e); + logger.error("Failed to restore entity", e); } } this.entities.clear(); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/SetGenCB.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/SetGenCB.java index 1f6b7e5cb..ccfe40be0 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/SetGenCB.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/SetGenCB.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.bukkit.util; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/UpdateUtility.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/UpdateUtility.java index 45fc4f2fb..faa9d8817 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/UpdateUtility.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/UpdateUtility.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.bukkit.util; @@ -72,22 +72,22 @@ public class UpdateUtility implements Listener { .getAsJsonObject(); spigotVersion = result.get("current_version").getAsString(); } catch (IOException e) { - logger.error("[P2] Unable to check for updates. Error: {}", e.getMessage()); + logger.error("Unable to check for updates. Error: {}", e.getMessage()); return; } if (internalVersion.isLaterVersion(spigotVersion)) { - logger.info("[P2] There appears to be a PlotSquared update available!"); - logger.info("[P2] You are running version {}, the latest version is {}", + logger.info("There appears to be a PlotSquared update available!"); + logger.info("You are running version {}, the latest version is {}", internalVersion.versionString(), spigotVersion); - logger.info("[P2] https://www.spigotmc.org/resources/77506/updates"); + logger.info("https://www.spigotmc.org/resources/77506/updates"); hasUpdate = true; if (Settings.UpdateChecker.NOTIFY_ONCE) { cancelTask(); } } else if (notify) { notify = false; - logger.info("[P2] Congratulations! You are running the latest PlotSquared version"); + logger.info("Congratulations! You are running the latest PlotSquared version"); } }, 0L, Settings.UpdateChecker.POLL_RATE * 60 * 20); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/task/BukkitPlotSquaredTask.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/task/BukkitPlotSquaredTask.java index 3d09903b4..4e293d409 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/task/BukkitPlotSquaredTask.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/task/BukkitPlotSquaredTask.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.bukkit.util.task; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/task/BukkitTaskManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/task/BukkitTaskManager.java index 3bd904d3d..df47e48a2 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/task/BukkitTaskManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/task/BukkitTaskManager.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.bukkit.util.task; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/task/PaperTimeConverter.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/task/PaperTimeConverter.java index 53fd535c2..c5bfb44cf 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/task/PaperTimeConverter.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/task/PaperTimeConverter.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.bukkit.util.task; @@ -36,12 +36,14 @@ import javax.annotation.Nonnegative; */ public final class PaperTimeConverter implements TaskTime.TimeConverter { + private static final long MIN_MS_PER_TICKS = 50L; + @Override public long msToTicks(@Nonnegative final long ms) { - return Math.max(1L, (long) (ms / Bukkit.getAverageTickTime())); + return Math.max(1L, (long) (ms / Math.max(MIN_MS_PER_TICKS, Bukkit.getAverageTickTime()))); } @Override public long ticksToMs(@Nonnegative final long ticks) { - return Math.max(1L, (long) (ticks * Bukkit.getAverageTickTime())); + return Math.max(1L, (long) (ticks * Math.max(MIN_MS_PER_TICKS, Bukkit.getAverageTickTime()))); } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/task/SpigotTimeConverter.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/task/SpigotTimeConverter.java index 1605e7b77..862e22c50 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/task/SpigotTimeConverter.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/task/SpigotTimeConverter.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.bukkit.util.task; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/BungeePermsUUIDService.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/BungeePermsUUIDService.java index 1a8068a9b..aab2f2d4c 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/BungeePermsUUIDService.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/BungeePermsUUIDService.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.bukkit.uuid; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/EssentialsUUIDService.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/EssentialsUUIDService.java index 890a966e7..e03fc3317 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/EssentialsUUIDService.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/EssentialsUUIDService.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.bukkit.uuid; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/LuckPermsUUIDService.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/LuckPermsUUIDService.java index df0c8c681..be5ca5c7f 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/LuckPermsUUIDService.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/LuckPermsUUIDService.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.bukkit.uuid; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/OfflinePlayerUUIDService.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/OfflinePlayerUUIDService.java index 89557f2d2..7351f240d 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/OfflinePlayerUUIDService.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/OfflinePlayerUUIDService.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.bukkit.uuid; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/PaperUUIDService.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/PaperUUIDService.java index a06bb4e10..3700171d1 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/PaperUUIDService.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/PaperUUIDService.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.bukkit.uuid; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLiteUUIDService.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLiteUUIDService.java index d0ee06337..8f1bbe684 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLiteUUIDService.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLiteUUIDService.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.bukkit.uuid; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SquirrelIdUUIDService.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SquirrelIdUUIDService.java index 57f365bf0..f3438fae9 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SquirrelIdUUIDService.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SquirrelIdUUIDService.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.bukkit.uuid; @@ -82,7 +82,7 @@ public class SquirrelIdUUIDService implements UUIDService { // if (uuids.size() >= 2) { if (Settings.DEBUG) { - logger.info("[P2] (UUID) Found invalid UUID in batch. Will try each UUID individually."); + logger.info("(UUID) Found invalid UUID in batch. Will try each UUID individually."); } for (final UUID uuid : uuids) { final List 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 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]