diff --git a/.gitignore b/.gitignore index 3423dd222..a33dda199 100644 --- a/.gitignore +++ b/.gitignore @@ -2,11 +2,7 @@ *.cmd *.sh *.prefs -Sponge/build Core/build -Bukkit/build -Nukkit/build -buildSrc/ ### Maven ### /mvn @@ -134,12 +130,8 @@ local.properties # STS (Spring Tool Suite) .springBeans /target/ -Nukkit/build/classes/ -Nukkit/build/dependency-cache/ checkstyle.xml classes/ -p2error.txt *.bat -Nukkit/build/resources/main/plugin.yml docs/ build/ diff --git a/Bukkit/build.gradle b/Bukkit/build.gradle deleted file mode 100644 index 0b8bf2714..000000000 --- a/Bukkit/build.gradle +++ /dev/null @@ -1,152 +0,0 @@ -plugins { - id "com.github.johnrengelman.shadow" -} -repositories { - mavenLocal() - maven { url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" } - maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" } - maven { url = "https://jitpack.io" } - maven { url = "https://repo.codemc.org/repository/maven-public" } - maven { url = "https://repo.extendedclip.com/content/repositories/placeholderapi/" } - maven { - name = "papermc" - url = "https://papermc.io/repo/repository/maven-public/" - } - maven { url = "https://ci.ender.zone/plugin/repository/everything/" } - maven { url = "https://mvn.intellectualsites.com/content/repositories/snapshots" } - maven { url = "https://repo.wea-ondara.net/repository/public/" } - maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" } - maven { url = "http://repo.mvdw-software.be/content/groups/public/" } -} - - -dependencies { - implementation(project(":PlotSquared-Core")) - compile("org.bstats:bstats-bukkit:1.7") - compile(project(":PlotSquared-Core")) - compile("com.destroystokyo.paper:paper-api:1.16.2-R0.1-SNAPSHOT") - implementation("org.spigotmc:spigot-api:1.16.2-R0.1-SNAPSHOT") - compile(group: "com.sk89q.worldedit", name: "worldedit-bukkit", version: "7.2.0-SNAPSHOT") { - exclude(module: "bukkit") - - } - compile("io.papermc:paperlib:1.0.4") - implementation("net.kyori:text-adapter-bukkit:3.0.3") - compile("com.github.MilkBowl:VaultAPI:1.7") { - exclude(module: "bukkit") - } - implementation("me.clip:placeholderapi:2.10.6") - implementation("net.luckperms:api:5.1") - implementation("net.ess3:EssentialsX:2.18.0") { - exclude(group: "io.papermc", module: "paperlib") - } - implementation("net.alpenblock:BungeePerms:4.0-dev-106") - implementation("net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT") - implementation('net.kyori:adventure-text-minimessage:4.0.0-SNAPSHOT') - compile("se.hyperver.hyperverse:Core:0.6.0-SNAPSHOT"){ transitive = false } - compile('com.sk89q:squirrelid:1.0.0-SNAPSHOT'){ transitive = false } - compile('be.maximvdw:MVdWPlaceholderAPI:3.1.1-SNAPSHOT'){ transitive = false } - // logging - implementation('org.apache.logging.log4j:log4j-slf4j-impl:2.8.1') -} - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - -processResources { - from("src/main/resources") { - include("plugin.yml") - expand( - name: project.parent.name, - version: project.parent.version - ) - } -} - -//noinspection GroovyAssignabilityCheck -jar.archiveFileName = "PlotSquared-Bukkit-${project.parent.version}.jar" -jar.destinationDirectory = file("../mvn/com/plotsquared/PlotSquared-Bukkit/" + project.parent.version) -task createPom { - doLast { - pom { - project { - groupId = rootProject.group - artifactId = "PlotSquared-Bukkit" - version = rootProject.version - } - }.writeTo("../mvn/com/plotsquared/PlotSquared-Bukkit/${project.parent.version}/PlotSquared-Bukkit-${project.parent.version}.pom") - pom { - project { - groupId = rootProject.group - artifactId = "PlotSquared-Bukkit" - version = "latest" - } - }.writeTo("../mvn/com/plotsquared/PlotSquared-Bukkit/latest/PlotSquared-Bukkit-latest.pom") - .writeTo("pom.xml") - } -} - -task copyFiles { - doLast { - copy { - from("../mvn/com/plotsquared/PlotSquared-Bukkit/${project.parent.version}/") - into("../mvn/com/plotsquared/PlotSquared-Bukkit/latest/") - include("PlotSquared-Bukkit*.jar") - rename("PlotSquared-Bukkit-${project.parent.version}.jar", "PlotSquared-Bukkit-latest.jar") - } - } -} - -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:${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")) - include(dependency("com.google.inject:guice:4.2.3")) - include(dependency("com.google.inject.extensions:guice-assistedinject:4.2.3")) - include(dependency("javax.annotation:javax-annotation-api")) - include(dependency('org.apache.logging.log4j:log4j-slf4j-impl')) - include(dependency('org.slf4j:slf4j-api')) - include(dependency('javax.inject:javax.inject:1')) - include(dependency('aopalliance:aopalliance:1.0')) - include(dependency('com.intellectualsites:Pipeline:1.4.0-SNAPSHOT')) - } - - 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') - relocate('org.khelekore.prtree', 'com.plotsquared.prtree') - 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" -} - -shadowJar.doLast { - task -> - ant.checksum file: task.archivePath -} - -build.dependsOn(shadowJar) -build.finalizedBy(copyFiles) -copyFiles.dependsOn(createPom) diff --git a/Bukkit/build.gradle.kts b/Bukkit/build.gradle.kts new file mode 100644 index 000000000..59ccb1f70 --- /dev/null +++ b/Bukkit/build.gradle.kts @@ -0,0 +1,99 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +repositories { + maven { + name = "SpigotMC" + url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") + } + + maven { + name = "CodeMC" + url = uri("https://repo.codemc.org/repository/maven-public") + } + + maven { + name = "PlaceholderAPI" + url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/") + } + + maven { + name = "PaperMC" + url = uri("https://papermc.io/repo/repository/maven-public/") + } + + maven { + name = "EssentialsX" + url = uri("https://ci.ender.zone/plugin/repository/everything/") + } + + maven { + name = "IntellectualSites" + url = uri("https://mvn.intellectualsites.com/content/repositories/releases") + } +} + +dependencies { + api(project(":PlotSquared-Core")) + + // + // Implementation details + // + + // ~~Spyware~~ Metrics + implementation("org.bstats:bstats-bukkit:1.7") + + // Minecraft + compileOnlyApi("com.destroystokyo.paper:paper-api:1.16.3-R0.1-SNAPSHOT") + implementation("io.papermc:paperlib:1.0.4") + + // Plugins + compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT") { + exclude(group = "org.bukkit") + exclude(group = "org.spigotmc") + } + compileOnly("com.github.MilkBowl:VaultAPI:1.7") { + exclude(group = "org.bukkit") + } + compileOnly("me.clip:placeholderapi:2.10.6") + compileOnly("net.luckperms:api:5.1") + compileOnly("net.ess3:EssentialsX:2.18.0") + compileOnly("se.hyperver.hyperverse:Core:0.6.0-SNAPSHOT") { isTransitive = false } + compileOnly("be.maximvdw:MVdWPlaceholderAPI:3.1.1") { isTransitive = false } + + // Other libraries + implementation("com.sk89q:squirrelid:1.0.0-SNAPSHOT") { isTransitive = false } + + // Adventure + implementation("net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT") +} + +tasks.processResources { + filesMatching("plugin.yml") { + expand("version" to project.version) + } +} + +tasks.named("shadowJar") { + dependencies { + exclude(dependency("org.checkerframework:")) + } + + relocate("net.kyori.adventure", "com.plotsquared.core.configuration.adventure") + relocate("net.kyori.examination", "com.plotsquared.core.configuration.examination") + relocate("io.papermc.lib", "com.plotsquared.bukkit.paperlib") + relocate("org.bstats", "com.plotsquared.metrics") + relocate("com.sk89q.squirrelid", "com.plotsquared.squirrelid") + relocate("org.khelekore.prtree", "com.plotsquared.prtree") + relocate("org.apache.logging.log4j", "com.plotsquared.logging.apache.log4j") + relocate("org.apache.logging.slf4j", "com.plotsquared.logging.apache.slf4j") + relocate("org.slf4j", "com.plotsquared.logging.slf4j") + relocate("com.google.inject", "com.plotsquared.google") + relocate("javax.inject", "com.plotsquared.core.inject.javax") + relocate("org.aopalliance", "com.plotsquared.core.aopalliance") + relocate("com.intellectualsites.services", "com.plotsquared.core.services") + + // Get rid of all the libs which are 100% unused. + minimize() + + mergeServiceFiles() +} diff --git a/Bukkit/pom.xml b/Bukkit/pom.xml deleted file mode 100644 index 291bb536c..000000000 --- a/Bukkit/pom.xml +++ /dev/null @@ -1,198 +0,0 @@ - - - 4.0.0 - com.plotsquared - PlotSquared-Bukkit - latest - - - org.json - json - 20200518 - compile - - - javax.annotation - javax.annotation-api - 1.3.2 - compile - - - org.bstats - bstats-bukkit - 1.7 - compile - - - com.plotsquared - PlotSquared-Core - 6.0.0-SNAPSHOT - compile - - - com.destroystokyo.paper - paper-api - 1.16.2-R0.1-SNAPSHOT - compile - - - com.sk89q.worldedit - worldedit-bukkit - 7.2.0-SNAPSHOT - compile - - - bukkit - * - - - - - io.papermc - paperlib - 1.0.4 - compile - - - com.github.MilkBowl - VaultAPI - 1.7 - compile - - - bukkit - * - - - - - se.hyperver.hyperverse - Core - 0.6.0-SNAPSHOT - compile - - - * - * - - - - - com.sk89q - squirrelid - 1.0.0-SNAPSHOT - compile - - - * - * - - - - - be.maximvdw - MVdWPlaceholderAPI - 3.1.1-SNAPSHOT - compile - - - * - * - - - - - com.sk89q.worldedit - worldedit-core - 7.2.0-SNAPSHOT - runtime - - - dummypermscompat - * - - - bukkit-classloader-check - * - - - mockito-core - * - - - - - com.google.guava - guava - 21.0 - runtime - - - org.spigotmc - spigot-api - 1.16.2-R0.1-SNAPSHOT - runtime - - - net.kyori - text-adapter-bukkit - 3.0.3 - runtime - - - me.clip - placeholderapi - 2.10.6 - runtime - - - net.luckperms - api - 5.1 - runtime - - - net.ess3 - EssentialsX - 2.18.0 - runtime - - - paperlib - io.papermc - - - - - net.alpenblock - BungeePerms - 4.0-dev-106 - runtime - - - net.kyori - adventure-platform-bukkit - 4.0.0-SNAPSHOT - runtime - - - net.kyori - adventure-text-minimessage - 4.0.0-SNAPSHOT - runtime - - - org.apache.logging.log4j - log4j-slf4j-impl - 2.8.1 - runtime - - - junit - junit - 4.13 - test - - - diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java index bca3318cf..ead142a36 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java @@ -59,7 +59,6 @@ import com.plotsquared.bukkit.util.UpdateUtility; import com.plotsquared.bukkit.util.task.BukkitTaskManager; import com.plotsquared.bukkit.util.task.PaperTimeConverter; import com.plotsquared.bukkit.util.task.SpigotTimeConverter; -import com.plotsquared.bukkit.uuid.BungeePermsUUIDService; import com.plotsquared.bukkit.uuid.EssentialsUUIDService; import com.plotsquared.bukkit.uuid.LuckPermsUUIDService; import com.plotsquared.bukkit.uuid.OfflinePlayerUUIDService; @@ -141,7 +140,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.io.File; import java.lang.reflect.Method; -import java.util.AbstractMap; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -237,9 +235,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl final PlotSquared plotSquared = new PlotSquared(this, "Bukkit"); if (PlotSquared.platform().getServerVersion()[1] < 13) { - System.out.println("You can't use this version of PlotSquared on a server less than Minecraft 1.13.2."); - System.out.println("Please check the download page for the link to the legacy versions."); - System.out.println("The server will now be shutdown to prevent any corruption."); + logger.error("You can't use this version of PlotSquared on a server less than Minecraft 1.13.2."); + logger.error("Please check the download page for the link to the legacy versions."); + logger.error("The server will now be shutdown to prevent any corruption."); Bukkit.shutdown(); return; } @@ -423,14 +421,6 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl luckPermsUUIDService = null; } - final BungeePermsUUIDService bungeePermsUUIDService; - if (Settings.UUID.SERVICE_BUNGEE_PERMS && Bukkit.getPluginManager().getPlugin("BungeePerms") != null) { - bungeePermsUUIDService = new BungeePermsUUIDService(); - logger.info("(UUID) Using BungeePerms as a complementary UUID service"); - } else { - bungeePermsUUIDService = null; - } - final EssentialsUUIDService essentialsUUIDService; if (Settings.UUID.SERVICE_ESSENTIALSX && Bukkit.getPluginManager().getPlugin("Essentials") != null) { essentialsUUIDService = new EssentialsUUIDService(); @@ -463,10 +453,6 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl this.impromptuPipeline.registerService(luckPermsUUIDService); this.backgroundPipeline.registerService(luckPermsUUIDService); } - if (bungeePermsUUIDService != null) { - this.impromptuPipeline.registerService(bungeePermsUUIDService); - this.backgroundPipeline.registerService(bungeePermsUUIDService); - } if (essentialsUUIDService != null) { this.impromptuPipeline.registerService(essentialsUUIDService); this.backgroundPipeline.registerService(essentialsUUIDService); @@ -500,8 +486,6 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl ChatFormatter.formatters.add(getInjector().getInstance(PlaceholderFormatter.class)); } logger.info("PlotSquared hooked into PlaceholderAPI"); - } else { - logger.info("PlaceholderAPI is not in use. Hook deactivated"); } this.startMetrics(); @@ -700,7 +684,6 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl } @SuppressWarnings("deprecation") private void runEntityTask() { - logger.info("KillAllEntities started"); TaskManager.runTaskRepeat(() -> this.plotAreaManager.forEachPlotArea(plotArea -> { final World world = Bukkit.getWorld(plotArea.getWorldName()); try { @@ -1047,13 +1030,21 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl return new BukkitPlotGenerator(world, generator, this.plotAreaManager); } - @Override public List, Boolean>> getPluginIds() { - List, Boolean>> names = new ArrayList<>(); - for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) { - Map.Entry id = new AbstractMap.SimpleEntry<>(plugin.getName(), plugin.getDescription().getVersion()); - names.add(new AbstractMap.SimpleEntry<>(id, plugin.isEnabled())); + @Override public String getPluginList() { + StringBuilder msg = new StringBuilder(); + Plugin[] plugins = Bukkit.getServer().getPluginManager().getPlugins(); + msg.append("Plugins (").append(plugins.length).append("): \n"); + for (Plugin p : plugins) { + msg.append(" - ").append(p.getName()).append(":").append("\n") + .append(" • Version: ").append(p.getDescription().getVersion()).append("\n") + .append(" • Enabled: ").append(p.isEnabled()).append("\n") + .append(" • Main: ").append(p.getDescription().getMain()).append("\n") + .append(" • Authors: ").append(p.getDescription().getAuthors()).append("\n") + .append(" • Load Before: ").append(p.getDescription().getLoadBefore()).append("\n") + .append(" • Dependencies: ").append(p.getDescription().getDepend()).append("\n") + .append(" • Soft Dependencies: ").append(p.getDescription().getSoftDepend()).append("\n"); } - return names; + return msg.toString(); } @Override @Nonnull public com.plotsquared.core.location.World getPlatformWorld(@Nonnull final String worldName) { @@ -1061,7 +1052,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl } @Override @Nonnull public Audience getConsoleAudience() { - return BukkitUtil.BUKKIT_AUDIENCES.audience(Bukkit.getConsoleSender()); + return BukkitUtil.BUKKIT_AUDIENCES.console(); } @Override public String getPluginName() { 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 70413d799..73a823ffe 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java @@ -229,18 +229,24 @@ public class PaperListener implements Listener { } Plot plot = location.getOwnedPlotAbs(); if (plot == null) { + EntityType type = event.getType(); if (!area.isMobSpawning()) { - EntityType type = event.getType(); switch (type) { case DROPPED_ITEM: if (Settings.Enabled_Components.KILL_ROAD_ITEMS) { event.setShouldAbortSpawn(true); event.setCancelled(true); - break; + return; } case PLAYER: return; } + if (type.isAlive()) { + event.setShouldAbortSpawn(true); + event.setCancelled(true); + } + } + if (!area.isMiscSpawnUnowned() && !type.isAlive()) { event.setShouldAbortSpawn(true); event.setCancelled(true); } 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 713780bcb..496d19482 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java @@ -90,6 +90,7 @@ import org.bukkit.FluidCollisionMode; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Waterlogged; import org.bukkit.command.PluginCommand; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; @@ -1118,9 +1119,16 @@ public class PlayerEventListener extends PlotListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBucketEmpty(PlayerBucketEmptyEvent event) { BlockFace bf = event.getBlockFace(); - Block block = - event.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()) - .getBlock(); + final Block block; + // if the block can be waterlogged, the event might waterlog the block + // sometimes + if (event.getBlockClicked().getBlockData() instanceof Waterlogged) { + block = event.getBlockClicked(); + } else { + block = event.getBlockClicked().getLocation() + .add(bf.getModX(), bf.getModY(), bf.getModZ()) + .getBlock(); + } Location location = BukkitUtil.adapt(block.getLocation()); PlotArea area = location.getPlotArea(); if (area == null) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/BungeePermsUUIDService.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/BungeePermsUUIDService.java deleted file mode 100644 index aab2f2d4c..000000000 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/BungeePermsUUIDService.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * _____ _ _ _____ _ - * | __ \| | | | / ____| | | - * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| | - * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` | - * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| | - * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_| - * | | - * |_| - * PlotSquared plot management system for Minecraft - * Copyright (C) 2020 IntellectualSites - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.plotsquared.bukkit.uuid; - -import com.plotsquared.core.uuid.UUIDMapping; -import com.plotsquared.core.uuid.UUIDService; -import net.alpenblock.bungeeperms.BungeePerms; -import net.alpenblock.bungeeperms.io.UUIDPlayerDB; -import org.bukkit.Bukkit; -import org.bukkit.plugin.RegisteredServiceProvider; - -import javax.annotation.Nonnull; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -/** - * UUID service that uses the BungeePerms API - */ -public class BungeePermsUUIDService implements UUIDService { - - private final BungeePerms bp; - - public BungeePermsUUIDService() { - final RegisteredServiceProvider provider = Bukkit.getServicesManager().getRegistration(BungeePerms.class); - if (provider != null) { - this.bp = provider.getProvider(); - } else { - throw new IllegalStateException("BungeePerms is not available"); - } - } - - @Override @Nonnull public List getNames(@Nonnull final List uuids) { - final List mappings = new ArrayList<>(uuids.size()); - final UUIDPlayerDB uuiddb = BungeePerms.getInstance().getPermissionsManager().getUUIDPlayerDB(); - for (final UUID uuid : uuids) { - try { - final String username = uuiddb.getPlayerName(uuid); - if (username != null) { - mappings.add(new UUIDMapping(uuid, username)); - } - } catch (final Exception ignored) {} - } - return mappings; - } - - @Override @Nonnull public List getUUIDs(@Nonnull final List usernames) { - final List mappings = new ArrayList<>(usernames.size()); - final UUIDPlayerDB uuiddb = BungeePerms.getInstance().getPermissionsManager().getUUIDPlayerDB(); - for (final String username : usernames) { - try { - final UUID uuid = uuiddb.getUUID(username); - if (username != null) { - mappings.add(new UUIDMapping(uuid, username)); - } - } catch (final Exception ignored) {} - } - return mappings; - } - -} diff --git a/Bukkit/src/main/resources/plugin.yml b/Bukkit/src/main/resources/plugin.yml index b3a485d72..91579acdb 100644 --- a/Bukkit/src/main/resources/plugin.yml +++ b/Bukkit/src/main/resources/plugin.yml @@ -1,4 +1,4 @@ -name: ${name} +name: PlotSquared main: com.plotsquared.bukkit.BukkitPlatform api-version: "1.13" version: "${version}" @@ -214,6 +214,8 @@ permissions: default: false plots.admin.caps.other: default: false + plots.admin.music.other: + default: false plots.admin.destroy.unowned: default: false plots.admin.destroy.groundlevel: diff --git a/Core/build.gradle b/Core/build.gradle deleted file mode 100644 index 167600f33..000000000 --- a/Core/build.gradle +++ /dev/null @@ -1,102 +0,0 @@ -repositories { - maven { url = "https://jitpack.io" } - maven { url = "https://mvn.intellectualsites.com/content/repositories/snapshots" } - maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" } -} -def textVersion = "3.0.2" - -dependencies { - implementation("org.yaml:snakeyaml:1.26") - implementation("com.google.code.gson:gson:2.8.6") { - because("Minecraft uses GSON 2.8.0") - force = true - } - implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.72") - implementation("org.jetbrains:annotations:20.0.0") - implementation("org.khelekore:prtree:1.7.0-SNAPSHOT") - // Adventure related stuff - implementation('net.kyori:adventure-api:4.0.0-SNAPSHOT') - implementation('net.kyori:adventure-text-minimessage:4.0.0-SNAPSHOT') - compile("com.google.inject:guice:4.2.3") - compile("com.google.inject.extensions:guice-assistedinject:4.2.3") - compile group: 'com.google.code.findbugs', name: 'annotations', version: '3.0.1' - compile group: 'javax.inject', name: 'javax.inject', version: '1' - compile group: 'aopalliance', name: 'aopalliance', version: '1.0' - // logging - implementation("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1") - implementation('com.intellectualsites:Pipeline:1.4.0-SNAPSHOT') -} - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - -processResources { - from("src/main/resources") { - include "plugin.properties" - expand( - version: "${project.parent.version}", - name: project.parent.name, - commit: "${git.head().abbreviatedId}", - date: "${git.head().getDate().format("yy.MM.dd")}", - ) - } -} - -//noinspection GroovyAssignabilityCheck -jar.archiveFileName = "PlotSquared-Core-${project.parent.version}.jar" -jar.destinationDirectory = file("../mvn/com/plotsquared/PlotSquared-Core/" + project.parent.version) -task createPom { - doLast { - pom { - project { - groupId = rootProject.group - artifactId = "PlotSquared-Core" - version = project.parent.version - } - }.writeTo("../mvn/com/plotsquared/PlotSquared-Core/${project.parent.version}/PlotSquared-Core-${project.parent.version}.pom") - pom { - project { - groupId = rootProject.group - artifactId = "PlotSquared-Core" - version = "latest" - } - }.writeTo("../mvn/com/plotsquared/PlotSquared-Core/latest/PlotSquared-Core-latest.pom") - .writeTo("pom.xml") - } -} - -task copyFiles { - doLast { - copy { - from("../mvn/com/plotsquared/PlotSquared-Core/${project.parent.version}/") - into("../mvn/com/plotsquared/PlotSquared-Core/latest/") - include("PlotSquared-Core*.jar") - rename("PlotSquared-Core-${project.parent.version}.jar", "PlotSquared-Core-latest.jar") - } - } -} - -shadowJar { - dependencies { - include(dependency('net.kyori:adventure-api:4.0.0-SNAPSHOT')) - include(dependency('net.kyori:adventure-gson:4.0.0-SNAPSHOT')) - include(dependency('net.kyori:adventure-legacy:4.0.0-SNAPSHOT')) - include(dependency('net.kyori:adventure-plain:4.0.0-SNAPSHOT')) - include(dependency('net.kyori:adventure-text-minimessage:4.0.0-SNAPSHOT')) - include(dependency('org.khelekore:prtree:1.7.0-SNAPSHOT')) - } - relocate('net.kyori.text', 'com.plotsquared.formatting.text') - relocate("org.json", "com.plotsquared.json") { - exclude "org/json/simple/**" - } -} - -shadowJar.doLast { - task -> - ant.checksum file: task.archivePath -} - -build.dependsOn(shadowJar) - -build.finalizedBy(copyFiles) -copyFiles.dependsOn(createPom) diff --git a/Core/build.gradle.kts b/Core/build.gradle.kts new file mode 100644 index 000000000..b886a9407 --- /dev/null +++ b/Core/build.gradle.kts @@ -0,0 +1,58 @@ +import java.time.format.DateTimeFormatter + +dependencies { + // Expected everywhere. + compileOnlyApi("javax.annotation:javax.annotation-api:1.3.2") + + // Minecraft expectations + compileOnlyApi("com.google.guava:guava:21.0") // Minecraft uses v21.0 + compileOnlyApi("com.google.code.gson:gson:2.8.0") // Minecraft uses v2.8.0 + + // Platform expectations + compileOnlyApi("org.yaml:snakeyaml:1.26") // Some platforms provide this + + // Adventure stuff + api("net.kyori:adventure-api:4.0.0-SNAPSHOT") + api("net.kyori:adventure-text-minimessage:4.0.0-SNAPSHOT") + + // Guice + api("com.google.inject:guice:4.2.3") { + exclude(group = "com.google.guava") + } + api("com.google.inject.extensions:guice-assistedinject:4.2.3") { + exclude("com.google.inject", "guice") + } + compileOnlyApi("com.google.code.findbugs:annotations:3.0.1") + compileOnlyApi("javax.inject:javax.inject:1") + + // Plugins + compileOnlyApi("com.sk89q.worldedit:worldedit-core:7.2.0-SNAPSHOT") { + exclude(group = "bukkit-classloader-check") + exclude(group = "mockito-core") + exclude(group = "dummypermscompat") + } + testImplementation("com.sk89q.worldedit:worldedit-core:7.2.0-SNAPSHOT") + + // Logging + api("org.slf4j:slf4j-api:1.7.25") + runtimeOnly("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1") { + exclude(group = "org.slf4j") + } + + // Other libraries + api("org.khelekore:prtree:1.7.0-SNAPSHOT") + api("aopalliance:aopalliance:1.0") + api("com.intellectualsites:Pipeline:1.4.0-SNAPSHOT") { + exclude(group = "com.google.guava") + } +} + +tasks.processResources { + filesMatching("plugin.properties") { + expand( + "version" to project.version.toString(), + "commit" to rootProject.grgit.head().abbreviatedId, + "date" to rootProject.grgit.head().dateTime.format(DateTimeFormatter.ofPattern("yy.MM.dd")) + ) + } +} diff --git a/Core/pom.xml b/Core/pom.xml deleted file mode 100644 index 50a5c1be6..000000000 --- a/Core/pom.xml +++ /dev/null @@ -1,138 +0,0 @@ - - - 4.0.0 - com.plotsquared - PlotSquared-Core - latest - - - org.json - json - 20200518 - compile - - - javax.annotation - javax.annotation-api - 1.3.2 - compile - - - com.google.inject - guice - 4.2.3 - compile - - - com.google.inject.extensions - guice-assistedinject - 4.2.3 - compile - - - com.google.code.findbugs - annotations - 3.0.1 - compile - - - javax.inject - javax.inject - 1 - compile - - - aopalliance - aopalliance - 1.0 - compile - - - com.sk89q.worldedit - worldedit-core - 7.2.0-SNAPSHOT - runtime - - - dummypermscompat - * - - - bukkit-classloader-check - * - - - mockito-core - * - - - - - com.google.guava - guava - 21.0 - runtime - - - org.yaml - snakeyaml - 1.26 - runtime - - - com.google.code.gson - gson - 2.8.6 - runtime - - - org.jetbrains.kotlin - kotlin-stdlib - 1.3.72 - runtime - - - org.jetbrains - annotations - 20.0.0 - runtime - - - org.khelekore - prtree - 1.7.0-SNAPSHOT - runtime - - - net.kyori - adventure-api - 4.0.0-SNAPSHOT - runtime - - - net.kyori - adventure-text-minimessage - 4.0.0-SNAPSHOT - runtime - - - org.apache.logging.log4j - log4j-slf4j-impl - 2.8.1 - runtime - - - com.intellectualsites - Pipeline - 1.4.0-SNAPSHOT - runtime - - - junit - junit - 4.13 - test - - - diff --git a/Core/src/main/java/com/plotsquared/core/PlotPlatform.java b/Core/src/main/java/com/plotsquared/core/PlotPlatform.java index 84bf76ec2..3d6387bec 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotPlatform.java +++ b/Core/src/main/java/com/plotsquared/core/PlotPlatform.java @@ -142,8 +142,6 @@ public interface PlotPlatform

extends LocaleHolder { return getInjector().getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class)); } - List, Boolean>> getPluginIds(); - /** * Get the backup manager instance * @@ -256,6 +254,8 @@ public interface PlotPlatform

extends LocaleHolder { */ @Nonnull Audience getConsoleAudience(); + String getPluginList(); + /** * Load the caption maps */ diff --git a/Core/src/main/java/com/plotsquared/core/PlotSquared.java b/Core/src/main/java/com/plotsquared/core/PlotSquared.java index 3cc968a1e..ebc6ccad2 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotSquared.java +++ b/Core/src/main/java/com/plotsquared/core/PlotSquared.java @@ -1300,7 +1300,6 @@ public class PlotSquared { String commitString = br.readLine(); String dateString = br.readLine(); this.version = PlotVersion.tryParse(versionString, commitString, dateString); - System.out.println("Version is " + this.version); } } catch (IOException throwable) { throwable.printStackTrace(); 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 b75955912..c2fe616aa 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Backup.java +++ b/Core/src/main/java/com/plotsquared/core/command/Backup.java @@ -322,7 +322,7 @@ public final class Backup extends Command { Template.of("reason", error.getMessage()) ); } else { - player.sendMessage(TranslatableCaption.of("backup_load_success")); + player.sendMessage(TranslatableCaption.of("backups.backup_load_success")); } })); } 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 a79a8a240..7d67e2b29 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java @@ -103,28 +103,21 @@ public class DebugPaste extends SubCommand { .append("\n"); b.append("online_mode: ").append(!Settings.UUID.OFFLINE).append(';') .append(!Settings.UUID.OFFLINE).append('\n'); - b.append("Plugins:"); - for (Map.Entry, Boolean> pluginInfo : PlotSquared - .platform().getPluginIds()) { - Map.Entry nameVersion = pluginInfo.getKey(); - String name = nameVersion.getKey(); - String version = nameVersion.getValue(); - boolean enabled = pluginInfo.getValue(); - b.append("\n ").append(name).append(":\n ").append("version: '") - .append(version).append('\'').append("\n enabled: ").append(enabled); - } + b.append(PlotSquared.platform().getPluginList()); b.append("\n\n# YAY! Now, let's see what we can find in your JVM\n"); Runtime runtime = Runtime.getRuntime(); RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean(); - b.append("Uptime: ").append( - TimeUnit.MINUTES.convert(rb.getUptime(), TimeUnit.MILLISECONDS) + " minutes") + b.append("Uptime: ") + .append(TimeUnit.MINUTES.convert(rb.getUptime(), TimeUnit.MILLISECONDS)) + .append(" minutes") .append('\n'); b.append("JVM Flags: ").append(rb.getInputArguments()).append('\n'); - b.append("Free Memory: ").append(runtime.freeMemory() / 1024 / 1024 + " MB") + b.append("Free Memory: ").append(runtime.freeMemory() / 1024 / 1024).append(" MB") .append('\n'); - b.append("Max Memory: ").append(runtime.maxMemory() / 1024 / 1024 + " MB") + b.append("Max Memory: ").append(runtime.maxMemory() / 1024 / 1024).append(" MB") + .append('\n'); + b.append("Total Memory: ").append(runtime.totalMemory() / 1024 / 1024).append(" MB") .append('\n'); - b.append("Total Memory: ").append(runtime.totalMemory() / 1024 / 1024 + " MB").append('\n'); b.append("Available Processors: ").append(runtime.availableProcessors()).append('\n'); b.append("Java Name: ").append(rb.getVmName()).append('\n'); b.append("Java Version: '").append(System.getProperty("java.version")) 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 1745eec0c..aaea5a68a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Grant.java +++ b/Core/src/main/java/com/plotsquared/core/command/Grant.java @@ -35,19 +35,21 @@ import com.plotsquared.core.player.PlayerMetaDataKeys; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlayerManager; +import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.task.RunnableVal; 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.Collections; +import java.util.LinkedList; +import java.util.List; +import net.kyori.adventure.text.minimessage.Template; +import com.plotsquared.core.uuid.UUIDMapping; + 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, @@ -86,8 +88,8 @@ public class Grant extends Command { Template.of("value", String.valueOf(uuids)) ); } else { - final UUID uuid = uuids.toArray(new UUID[0])[0]; - PlotPlayer pp = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid); + final UUIDMapping uuid = uuids.toArray(new UUIDMapping[0])[0]; + PlotPlayer pp = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid.getUuid()); if (pp != null) { try (final MetaDataAccess access = pp.accessPersistentMetaData( PlayerMetaDataKeys.PERSISTENT_GRANTED_PLOTS)) { @@ -99,7 +101,7 @@ public class Grant extends Command { } } } else { - DBFunc.getPersistentMeta(uuid, new RunnableVal>() { + DBFunc.getPersistentMeta(uuid.getUuid(), new RunnableVal>() { @Override public void run(Map value) { final byte[] array = value.get("grantedPlots"); if (arg0.equals("check")) { // check @@ -123,7 +125,11 @@ public class Grant extends Command { boolean replace = array != null; String key = "grantedPlots"; byte[] rawData = Ints.toByteArray(amount); - DBFunc.addPersistentMeta(uuid, key, rawData, replace); + DBFunc.addPersistentMeta(uuid.getUuid(), key, rawData, replace); + player.sendMessage( + TranslatableCaption.of("grants.added"), + Template.of("grants", String.valueOf(amount)) + ); } } }); @@ -135,10 +141,22 @@ 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()); + @Override public Collection tab(final PlotPlayer player, final String[] args, final boolean space) { + if (args.length == 1) { + final List completions = new LinkedList<>(); + if (Permissions.hasPermission(player, "plots.grant.add")) { + completions.add("add"); + } + if (Permissions.hasPermission(player, "plots.grant.check")) { + completions.add("check"); + } + final List commands = completions.stream().filter(completion -> completion.toLowerCase().startsWith(args[0].toLowerCase())) + .map(completion -> new Command(null, true, completion, "", RequiredType.NONE, CommandCategory.ADMINISTRATION) { + }).collect(Collectors.toCollection(LinkedList::new)); + if (Permissions.hasPermission(player, "plots.grant") && args[0].length() > 0) { + commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList())); + } + return commands; + } return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList()); } } 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 ffab80dcf..ad10fdde0 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Music.java +++ b/Core/src/main/java/com/plotsquared/core/command/Music.java @@ -38,6 +38,7 @@ import com.plotsquared.core.plot.PlotItemStack; import com.plotsquared.core.plot.flag.PlotFlag; import com.plotsquared.core.plot.flag.implementations.MusicFlag; import com.plotsquared.core.util.InventoryUtil; +import com.plotsquared.core.util.Permissions; import com.sk89q.worldedit.world.item.ItemTypes; import net.kyori.adventure.text.minimessage.Template; @@ -71,8 +72,11 @@ public class Music extends SubCommand { player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); return false; } - if (!plot.isAdded(player.getUUID())) { - player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); + if (!plot.isAdded(player.getUUID()) && !Permissions + .hasPermission(player, "plots.admin.music.other")) { + player.sendMessage( + TranslatableCaption.of("permission.no_permission"), + Template.of("node", "plots.admin.music.other")); return true; } PlotInventory inv = new PlotInventory(this.inventoryUtil, player, 2, "Plot Jukebox") { 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 ee4ca8833..25d9b9b8d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Set.java +++ b/Core/src/main/java/com/plotsquared/core/command/Set.java @@ -45,6 +45,8 @@ import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.world.block.BlockCategory; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; +import java.util.Collections; +import java.util.LinkedList; import net.kyori.adventure.text.minimessage.Template; import javax.annotation.Nonnull; @@ -180,7 +182,7 @@ public class Set extends SubCommand { if (plot != null) { newValues.addAll(Arrays.asList(plot.getManager().getPlotComponents(plot.getId()))); } - player.sendMessage(StaticCaption.of(TranslatableCaption.of("commandconfig.subcommand_set_options_header").getComponent(player) + StringMan + player.sendMessage(StaticCaption.of(TranslatableCaption.of("commandconfig.subcommand_set_options_header_only").getComponent(player) + StringMan .join(newValues, TranslatableCaption.of("blocklist.block_list_separator").getComponent(player)))); return false; } @@ -213,15 +215,51 @@ public class Set extends SubCommand { } @Override - public Collection tab(final PlotPlayer player, final String[] args, - final boolean space) { + public Collection tab(final PlotPlayer player, String[] args, boolean space) { if (args.length == 1) { - return Stream - .of("biome", "alias", "home", "main", "floor", "air", "all", "border", "wall", - "outline", "middle") - .filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH))) - .map(value -> new Command(null, false, value, "", RequiredType.NONE, null) { - }).collect(Collectors.toList()); + final List completions = new LinkedList<>(); + + if (Permissions.hasPermission(player, "plots.set.biome")) { + completions.add("biome"); + } + if (Permissions.hasPermission(player, "plots.set.alias")) { + completions.add("alias"); + } + if (Permissions.hasPermission(player, "plots.set.home")) { + completions.add("home"); + } + if (Permissions.hasPermission(player, "plots.set.main")) { + completions.add("main"); + } + if (Permissions.hasPermission(player, "plots.set.floor")) { + completions.add("floor"); + } + if (Permissions.hasPermission(player, "plots.set.air")) { + completions.add("air"); + } + if (Permissions.hasPermission(player, "plots.set.all")) { + completions.add("all"); + } + if (Permissions.hasPermission(player, "plots.set.border")) { + completions.add("border"); + } + if (Permissions.hasPermission(player, "plots.set.wall")) { + completions.add("wall"); + } + if (Permissions.hasPermission(player, "plots.set.outline")) { + completions.add("outline"); + } + if (Permissions.hasPermission(player, "plots.set.middle")) { + completions.add("middle"); + } + final List commands = completions.stream().filter(completion -> completion.toLowerCase().startsWith(args[0].toLowerCase())) + .map(completion -> new Command(null, true, completion, "", RequiredType.NONE, CommandCategory.APPEARANCE) { + }).collect(Collectors.toCollection(LinkedList::new)); + + if (Permissions.hasPermission(player, "plots.set") && args[0].length() > 0) { + commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList())); + } + return commands; } else if (args.length > 1) { // Additional checks Plot plot = player.getCurrentPlot(); 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 a384c74ac..71e81ffd8 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Template.java +++ b/Core/src/main/java/com/plotsquared/core/command/Template.java @@ -45,10 +45,15 @@ import com.plotsquared.core.setup.PlotAreaBuilder; import com.plotsquared.core.setup.SettingsNodesWrapper; import com.plotsquared.core.util.FileBytes; import com.plotsquared.core.util.FileUtils; +import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.SetupUtils; +import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.task.TaskManager; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; import javax.annotation.Nonnull; import java.io.File; import java.io.FileInputStream; @@ -266,10 +271,22 @@ public class Template extends SubCommand { } return false; } - @Override public Collection tab(final PlotPlayer player, String[] args, boolean space) { - return Stream.of("import", "export") - .filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH))) - .map(value -> new Command(null, false, value, "plots.admin", RequiredType.NONE, null) { - }).collect(Collectors.toList()); + @Override public Collection tab(final PlotPlayer player, final String[] args, final boolean space) { + if (args.length == 1) { + final List completions = new LinkedList<>(); + if (Permissions.hasPermission(player, "plots.template.export")) { + completions.add("export"); + } + if (Permissions.hasPermission(player, "plots.template.import")) { + completions.add("import"); + } + final List commands = completions.stream().filter(completion -> completion.toLowerCase().startsWith(args[0].toLowerCase())) + .map(completion -> new Command(null, true, completion, "", RequiredType.NONE, CommandCategory.ADMINISTRATION) { + }).collect(Collectors.toCollection(LinkedList::new)); + if (Permissions.hasPermission(player, "plots.template") && args[0].length() > 0) { + commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList())); + } + return commands; + } return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList()); } } diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java index 450978c38..443c0230c 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java @@ -267,8 +267,6 @@ public class Settings extends Config { public static boolean SERVICE_BUKKIT = true; @Comment("Whether the EssentialsX service is enabled") public static boolean SERVICE_ESSENTIALSX = true; - @Comment("Whether the BungeePerms service is enabled") - public static boolean SERVICE_BUNGEE_PERMS = true; } diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java index 83e8cba16..d6ec19f1d 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java @@ -47,7 +47,6 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; -import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -265,7 +264,7 @@ public class HybridPlotManager extends ClassicPlotManager { * @param plot The plot * @return The location where a sign should be */ - @Override public Location getSignLoc(@Nonnull final @NotNull Plot plot) { + @Override public Location getSignLoc(@Nonnull final Plot plot) { return hybridPlotWorld.getSignLocation(plot); } diff --git a/Core/src/main/java/com/plotsquared/core/generator/SquarePlotManager.java b/Core/src/main/java/com/plotsquared/core/generator/SquarePlotManager.java index e69c5c63a..13398ea7b 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/SquarePlotManager.java +++ b/Core/src/main/java/com/plotsquared/core/generator/SquarePlotManager.java @@ -35,7 +35,6 @@ import com.plotsquared.core.queue.QueueCoordinator; import com.plotsquared.core.util.HashUtil; import com.plotsquared.core.util.RegionManager; import com.sk89q.worldedit.regions.CuboidRegion; -import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,7 +59,7 @@ public abstract class SquarePlotManager extends GridPlotManager { this.regionManager = regionManager; } - @Override public boolean clearPlot(final @NotNull Plot plot, + @Override public boolean clearPlot(final @Nonnull Plot plot, final @Nullable Runnable whenDone, @Nullable PlotPlayer actor, @Nullable QueueCoordinator queue) { @@ -85,7 +84,7 @@ public abstract class SquarePlotManager extends GridPlotManager { return true; } - @Override public Location getPlotTopLocAbs(@NotNull PlotId plotId) { + @Override public Location getPlotTopLocAbs(@Nonnull PlotId plotId) { int px = plotId.getX(); int pz = plotId.getY(); int x = (squarePlotWorld.ROAD_OFFSET_X + (px * (squarePlotWorld.ROAD_WIDTH + squarePlotWorld.PLOT_WIDTH))) - (int) Math @@ -246,7 +245,7 @@ public abstract class SquarePlotManager extends GridPlotManager { /** * Get the bottom plot loc (some basic math). */ - @Override public Location getPlotBottomLocAbs(@NotNull PlotId plotId) { + @Override public Location getPlotBottomLocAbs(@Nonnull PlotId plotId) { int px = plotId.getX(); int pz = plotId.getY(); int x = (squarePlotWorld.ROAD_OFFSET_X + (px * (squarePlotWorld.ROAD_WIDTH + squarePlotWorld.PLOT_WIDTH))) - squarePlotWorld.PLOT_WIDTH diff --git a/Core/src/main/java/com/plotsquared/core/inject/factory/ChunkCoordinatorBuilderFactory.java b/Core/src/main/java/com/plotsquared/core/inject/factory/ChunkCoordinatorBuilderFactory.java index aad7be0de..95d9ce52b 100644 --- a/Core/src/main/java/com/plotsquared/core/inject/factory/ChunkCoordinatorBuilderFactory.java +++ b/Core/src/main/java/com/plotsquared/core/inject/factory/ChunkCoordinatorBuilderFactory.java @@ -28,12 +28,11 @@ package com.plotsquared.core.inject.factory; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import com.plotsquared.core.queue.ChunkCoordinatorBuilder; -import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull; public interface ChunkCoordinatorBuilderFactory { - @Inject @Nonnull ChunkCoordinatorBuilder create(@Assisted @NotNull ChunkCoordinatorFactory chunkCoordinatorFactory); + @Inject @Nonnull ChunkCoordinatorBuilder create(@Assisted @Nonnull ChunkCoordinatorFactory chunkCoordinatorFactory); } diff --git a/Core/src/main/java/com/plotsquared/core/permissions/Permission.java b/Core/src/main/java/com/plotsquared/core/permissions/Permission.java index 27aa9fce8..dc8604c60 100644 --- a/Core/src/main/java/com/plotsquared/core/permissions/Permission.java +++ b/Core/src/main/java/com/plotsquared/core/permissions/Permission.java @@ -53,6 +53,7 @@ public enum Permission { PERMISSION_MERGE_OTHER("plots.merge.other"), PERMISSION_MERGE_KEEP_ROAD("plots.merge.keeproad"), PERMISSION_ADMIN_CAPS_OTHER("plots.admin.caps.other"), + PERMISSION_ADMIN_MUSIC_OTHER("plots.admin.music.other"), PERMISSION_ADMIN_DESTROY_UNOWNED("plots.admin.destroy.unowned"), PERMISSION_ADMIN_DESTROY_GROUNDLEVEL("plots.admin.destroy.groundlevel"), PERMISSION_ADMIN_DESTROY_OTHER("plots.admin.destroy.other"), diff --git a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java index 593afdc3e..57ed5ae6e 100644 --- a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java +++ b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java @@ -68,7 +68,6 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.title.Title; -import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -851,7 +850,7 @@ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer, } // Redefine from PermissionHolder as it's required from CommandCaller - @Override public boolean hasPermission(@NotNull String permission) { + @Override public boolean hasPermission(@Nonnull String permission) { return hasPermission(null, permission); } diff --git a/Core/src/main/java/com/plotsquared/core/plot/BlockBucket.java b/Core/src/main/java/com/plotsquared/core/plot/BlockBucket.java index e09dead4d..027948fbe 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/BlockBucket.java +++ b/Core/src/main/java/com/plotsquared/core/plot/BlockBucket.java @@ -36,7 +36,6 @@ import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockType; -import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull; import java.util.Arrays; @@ -57,21 +56,21 @@ public final class BlockBucket implements ConfigurationSerializable { private BlockState single; private Pattern pattern; - public BlockBucket(@NotNull final BlockType type) { + public BlockBucket(@Nonnull final BlockType type) { this(type.getId()); this.single = type.getDefaultState(); this.pattern = new BlockPattern(this.single); this.compiled = true; } - public BlockBucket(@NotNull final BlockState state) { + public BlockBucket(@Nonnull final BlockState state) { this(state.getAsString()); this.single = state; this.pattern = new BlockPattern(this.single); this.compiled = true; } - public BlockBucket(@NotNull final String input) { + public BlockBucket(@Nonnull final String input) { this.input = new StringBuilder(input); } diff --git a/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotManager.java b/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotManager.java index 1dd291ef1..5f9a5ba07 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotManager.java +++ b/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotManager.java @@ -36,7 +36,6 @@ import com.plotsquared.core.queue.QueueCoordinator; import com.plotsquared.core.util.FileUtils; import com.plotsquared.core.util.task.TaskManager; import com.sk89q.worldedit.function.pattern.Pattern; -import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -57,15 +56,15 @@ public class SinglePlotManager extends PlotManager { return PlotId.of(0, 0); } - @Override public Location getPlotBottomLocAbs(@Nonnull final @NotNull PlotId plotId) { + @Override public Location getPlotBottomLocAbs(@Nonnull final PlotId plotId) { return Location.at(plotId.toCommaSeparatedString(), -30000000, 0, -30000000); } - @Override public Location getPlotTopLocAbs(@Nonnull final @NotNull PlotId plotId) { + @Override public Location getPlotTopLocAbs(@Nonnull final PlotId plotId) { return Location.at(plotId.toCommaSeparatedString(), 30000000, 0, 30000000); } - @Override public boolean clearPlot(@NotNull Plot plot, final Runnable whenDone, @Nullable PlotPlayer actor, @Nullable QueueCoordinator queue) { + @Override public boolean clearPlot(@Nonnull Plot plot, final Runnable whenDone, @Nullable PlotPlayer actor, @Nullable QueueCoordinator queue) { PlotSquared.platform().getSetupUtils().unload(plot.getWorldName(), false); final File worldFolder = new File(PlotSquared.platform().getWorldContainer(), plot.getWorldName()); TaskManager.getPlatformImplementation().taskAsync(() -> { @@ -77,71 +76,71 @@ public class SinglePlotManager extends PlotManager { return true; } - @Override public boolean claimPlot(@NotNull Plot plot, @Nullable QueueCoordinator queue) { + @Override public boolean claimPlot(@Nonnull Plot plot, @Nullable QueueCoordinator queue) { // TODO return true; } - @Override public boolean unClaimPlot(@NotNull Plot plot, Runnable whenDone, @Nullable QueueCoordinator queue) { + @Override public boolean unClaimPlot(@Nonnull Plot plot, Runnable whenDone, @Nullable QueueCoordinator queue) { if (whenDone != null) { whenDone.run(); } return true; } - @Override public Location getSignLoc(@NotNull Plot plot) { + @Override public Location getSignLoc(@Nonnull Plot plot) { return null; } - @Override public String[] getPlotComponents(@NotNull PlotId plotId) { + @Override public String[] getPlotComponents(@Nonnull PlotId plotId) { return new String[0]; } - @Override public boolean setComponent(@NotNull PlotId plotId, - @NotNull String component, - @NotNull Pattern blocks, + @Override public boolean setComponent(@Nonnull PlotId plotId, + @Nonnull String component, + @Nonnull Pattern blocks, @Nullable PlotPlayer actor, @Nullable QueueCoordinator queue) { return false; } - @Override public boolean createRoadEast(@NotNull Plot plot, @Nullable QueueCoordinator queue) { + @Override public boolean createRoadEast(@Nonnull Plot plot, @Nullable QueueCoordinator queue) { return false; } - @Override public boolean createRoadSouth(@NotNull Plot plot, @Nullable QueueCoordinator queue) { + @Override public boolean createRoadSouth(@Nonnull Plot plot, @Nullable QueueCoordinator queue) { return false; } - @Override public boolean createRoadSouthEast(@NotNull Plot plot, @Nullable QueueCoordinator queue) { + @Override public boolean createRoadSouthEast(@Nonnull Plot plot, @Nullable QueueCoordinator queue) { return false; } - @Override public boolean removeRoadEast(@NotNull Plot plot, @Nullable QueueCoordinator queue) { + @Override public boolean removeRoadEast(@Nonnull Plot plot, @Nullable QueueCoordinator queue) { return false; } - @Override public boolean removeRoadSouth(@NotNull Plot plot, @Nullable QueueCoordinator queue) { + @Override public boolean removeRoadSouth(@Nonnull Plot plot, @Nullable QueueCoordinator queue) { return false; } - @Override public boolean removeRoadSouthEast(@NotNull Plot plot, @Nullable QueueCoordinator queue) { + @Override public boolean removeRoadSouthEast(@Nonnull Plot plot, @Nullable QueueCoordinator queue) { return false; } - @Override public boolean startPlotMerge(@NotNull List plotIds, @Nullable QueueCoordinator queue) { + @Override public boolean startPlotMerge(@Nonnull List plotIds, @Nullable QueueCoordinator queue) { return false; } - @Override public boolean startPlotUnlink(@NotNull List plotIds, @Nullable QueueCoordinator queue) { + @Override public boolean startPlotUnlink(@Nonnull List plotIds, @Nullable QueueCoordinator queue) { return false; } - @Override public boolean finishPlotMerge(@NotNull List plotIds, @Nullable QueueCoordinator queue) { + @Override public boolean finishPlotMerge(@Nonnull List plotIds, @Nullable QueueCoordinator queue) { return false; } - @Override public boolean finishPlotUnlink(@NotNull List plotIds, @Nullable QueueCoordinator queue) { + @Override public boolean finishPlotUnlink(@Nonnull List plotIds, @Nullable QueueCoordinator queue) { return false; } diff --git a/Core/src/main/java/com/plotsquared/core/setup/CommonSetupSteps.java b/Core/src/main/java/com/plotsquared/core/setup/CommonSetupSteps.java index f4ea7b178..fadc2821f 100644 --- a/Core/src/main/java/com/plotsquared/core/setup/CommonSetupSteps.java +++ b/Core/src/main/java/com/plotsquared/core/setup/CommonSetupSteps.java @@ -269,7 +269,7 @@ public enum CommonSetupSteps implements SetupStep { private static boolean isValidWorldName(String s) { return s.chars().allMatch((i) -> { - return i == 95 || i == 45 || i >= 97 && i <= 122 || i >= 48 && i <= 57 || i == 46; + return i == 95 || i == 45 || i >= 97 && i <= 122 || i >= 65 && i <= 90 || i >= 48 && i <= 57 || i == 46; }); } diff --git a/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java b/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java index d405ce210..3ee907cb5 100644 --- a/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java +++ b/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java @@ -26,6 +26,9 @@ package com.plotsquared.core.util; import com.google.inject.Inject; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonParseException; import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.generator.ClassicPlotWorld; @@ -63,8 +66,6 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; -import org.json.JSONArray; -import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -109,6 +110,7 @@ import java.util.zip.GZIPOutputStream; public abstract class SchematicHandler { private static final Logger logger = LoggerFactory.getLogger("P2/" + SchematicHandler.class.getSimpleName()); + private static final Gson GSON = new Gson(); public static SchematicHandler manager; private final WorldUtil worldUtil; private boolean exportAll = false; @@ -462,7 +464,7 @@ public abstract class SchematicHandler { } public List getSaves(UUID uuid) { - String rawJSON = ""; + String rawJSON; try { String website = Settings.Web.URL + "list.php?" + uuid.toString(); URL url = new URL(website); @@ -471,14 +473,14 @@ public abstract class SchematicHandler { try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { rawJSON = reader.lines().collect(Collectors.joining()); } - JSONArray array = new JSONArray(rawJSON); + JsonArray array = GSON.fromJson(rawJSON, JsonArray.class); List schematics = new ArrayList<>(); - for (int i = 0; i < array.length(); i++) { - String schematic = array.getString(i); + for (int i = 0; i < array.size(); i++) { + String schematic = array.get(i).getAsString(); schematics.add(schematic); } return schematics; - } catch (JSONException | IOException e) { + } catch (JsonParseException | IOException e) { e.printStackTrace(); } return null; diff --git a/Core/src/main/java/com/plotsquared/core/util/placeholders/Placeholder.java b/Core/src/main/java/com/plotsquared/core/util/placeholders/Placeholder.java index 478a4053f..49071f9bc 100644 --- a/Core/src/main/java/com/plotsquared/core/util/placeholders/Placeholder.java +++ b/Core/src/main/java/com/plotsquared/core/util/placeholders/Placeholder.java @@ -27,7 +27,8 @@ package com.plotsquared.core.util.placeholders; import com.google.common.base.Preconditions; import com.plotsquared.core.player.PlotPlayer; -import org.jetbrains.annotations.NotNull; + +import javax.annotation.Nonnull; /** * A placeholder is a keyed value that gets replaced by a {@link PlotPlayer player}-specific value at runtime @@ -36,7 +37,7 @@ public abstract class Placeholder { private final String key; - public Placeholder(@NotNull final String key) { + public Placeholder(@Nonnull final String key) { this.key = Preconditions.checkNotNull(key, "Key may not be null"); } @@ -46,14 +47,14 @@ public abstract class Placeholder { * @param player Player * @return Placeholder value. Return {@code ""} if no placeholder value can be returned */ - @NotNull public abstract String getValue(@NotNull final PlotPlayer player); + @Nonnull public abstract String getValue(@Nonnull final PlotPlayer player); /** * Get the placeholder key * * @return Placeholder key */ - @NotNull public final String getKey() { + @Nonnull public final String getKey() { return this.key; } diff --git a/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java b/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java index e9f1847cd..ab4ed8778 100644 --- a/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java +++ b/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java @@ -34,9 +34,9 @@ import com.plotsquared.core.plot.flag.GlobalFlagContainer; import com.plotsquared.core.plot.flag.PlotFlag; import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.PlayerManager; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.Collection; import java.util.Collections; import java.util.Locale; @@ -52,7 +52,7 @@ public final class PlaceholderRegistry { private final Map placeholders; private final EventDispatcher eventDispatcher; - public PlaceholderRegistry(@NotNull final EventDispatcher eventDispatcher) { + public PlaceholderRegistry(@Nonnull final EventDispatcher eventDispatcher) { this.placeholders = Maps.newHashMap(); this.eventDispatcher = eventDispatcher; this.registerDefault(); @@ -124,10 +124,10 @@ public final class PlaceholderRegistry { * @param key Placeholder key * @param placeholderFunction Placeholder generator. Cannot return null */ - @SuppressWarnings("ALL") public void createPlaceholder(@NotNull final String key, - @NotNull final Function, String> placeholderFunction) { + @SuppressWarnings("ALL") public void createPlaceholder(@Nonnull final String key, + @Nonnull final Function, String> placeholderFunction) { this.registerPlaceholder(new Placeholder(key) { - @Override @NotNull public String getValue(@NotNull final PlotPlayer player) { + @Override @Nonnull public String getValue(@Nonnull final PlotPlayer player) { return placeholderFunction.apply(player); } }); @@ -139,10 +139,10 @@ public final class PlaceholderRegistry { * @param key Placeholder key * @param placeholderFunction Placeholder generator. Cannot return null */ - public void createPlaceholder(@NotNull final String key, - @NotNull final BiFunction, Plot, String> placeholderFunction) { + public void createPlaceholder(@Nonnull final String key, + @Nonnull final BiFunction, Plot, String> placeholderFunction) { this.registerPlaceholder(new PlotSpecificPlaceholder(key) { - @Override @NotNull public String getValue(@NotNull final PlotPlayer player, @NotNull final Plot plot) { + @Override @Nonnull public String getValue(@Nonnull final PlotPlayer player, @Nonnull final Plot plot) { return placeholderFunction.apply(player, plot); } }); @@ -153,7 +153,7 @@ public final class PlaceholderRegistry { * * @param placeholder Placeholder instance */ - public void registerPlaceholder(@NotNull final Placeholder placeholder) { + public void registerPlaceholder(@Nonnull final Placeholder placeholder) { final Placeholder previous = this.placeholders .put(placeholder.getKey().toLowerCase(Locale.ENGLISH), Preconditions.checkNotNull(placeholder, "Placeholder may not be null")); @@ -168,7 +168,7 @@ public final class PlaceholderRegistry { * @param key Placeholder key * @return Placeholder value */ - @Nullable public Placeholder getPlaceholder(@NotNull final String key) { + @Nullable public Placeholder getPlaceholder(@Nonnull final String key) { return this.placeholders.get( Preconditions.checkNotNull(key, "Key may not be null").toLowerCase(Locale.ENGLISH)); } @@ -181,8 +181,8 @@ public final class PlaceholderRegistry { * @param player Player to evaluate for * @return Replacement value */ - @NotNull public String getPlaceholderValue(@NotNull final String key, - @NotNull final PlotPlayer player) { + @Nonnull public String getPlaceholderValue(@Nonnull final String key, + @Nonnull final PlotPlayer player) { final Placeholder placeholder = getPlaceholder(key); if (placeholder == null) { return ""; @@ -209,7 +209,7 @@ public final class PlaceholderRegistry { * * @return Unmodifiable collection of placeholders */ - @NotNull public Collection getPlaceholders() { + @Nonnull public Collection getPlaceholders() { return Collections.unmodifiableCollection(this.placeholders.values()); } diff --git a/Core/src/main/java/com/plotsquared/core/util/placeholders/PlotFlagPlaceholder.java b/Core/src/main/java/com/plotsquared/core/util/placeholders/PlotFlagPlaceholder.java index 777db3ab9..acde17fac 100644 --- a/Core/src/main/java/com/plotsquared/core/util/placeholders/PlotFlagPlaceholder.java +++ b/Core/src/main/java/com/plotsquared/core/util/placeholders/PlotFlagPlaceholder.java @@ -29,20 +29,21 @@ import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.flag.GlobalFlagContainer; import com.plotsquared.core.plot.flag.PlotFlag; -import org.jetbrains.annotations.NotNull; + +import javax.annotation.Nonnull; public final class PlotFlagPlaceholder extends PlotSpecificPlaceholder { private final PlotFlag flag; private final boolean local; - public PlotFlagPlaceholder(@NotNull final PlotFlag flag, final boolean local) { + public PlotFlagPlaceholder(@Nonnull final PlotFlag flag, final boolean local) { super(String.format("currentplot_%sflag_%s", local ? "local": "", flag.getName())); this.flag = flag; this.local = local; } - @Override @NotNull public String getValue(@NotNull final PlotPlayer player, @NotNull final Plot plot) { + @Override @Nonnull public String getValue(@Nonnull final PlotPlayer player, @Nonnull final Plot plot) { return this.getFlagValue(plot, this.flag.getName(), !this.local); } @@ -57,7 +58,7 @@ public final class PlotFlagPlaceholder extends PlotSpecificPlaceholder { * @param inherit Define if it returns only the flag set on the current plot or also inherited flags * @return The value of flag serialized in string */ - @NotNull private String getFlagValue(@NotNull final Plot plot, @NotNull final String flagName, final boolean inherit) { + @Nonnull private String getFlagValue(@Nonnull final Plot plot, @Nonnull final String flagName, final boolean inherit) { if (flagName.isEmpty()) { return ""; } diff --git a/Core/src/main/java/com/plotsquared/core/util/placeholders/PlotSpecificPlaceholder.java b/Core/src/main/java/com/plotsquared/core/util/placeholders/PlotSpecificPlaceholder.java index 6a19e86fb..c7dc029b8 100644 --- a/Core/src/main/java/com/plotsquared/core/util/placeholders/PlotSpecificPlaceholder.java +++ b/Core/src/main/java/com/plotsquared/core/util/placeholders/PlotSpecificPlaceholder.java @@ -27,18 +27,19 @@ package com.plotsquared.core.util.placeholders; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; -import org.jetbrains.annotations.NotNull; + +import javax.annotation.Nonnull; /** * A {@link Placeholder placeholder} that requires a {@link com.plotsquared.core.plot.Plot plot} */ public abstract class PlotSpecificPlaceholder extends Placeholder { - public PlotSpecificPlaceholder(@NotNull final String key) { + public PlotSpecificPlaceholder(@Nonnull final String key) { super(key); } - @Override @NotNull public final String getValue(@NotNull final PlotPlayer player) { + @Override @Nonnull public final String getValue(@Nonnull final PlotPlayer player) { final Plot plot = player.getCurrentPlot(); if (plot == null) { return ""; @@ -53,7 +54,7 @@ public abstract class PlotSpecificPlaceholder extends Placeholder { * @param plot Plot that the player is in * @return Placeholder value, or {@code ""} if the placeholder does not apply */ - @NotNull public abstract String getValue(@NotNull final PlotPlayer player, - @NotNull final Plot plot); + @Nonnull public abstract String getValue(@Nonnull final PlotPlayer player, + @Nonnull final Plot plot); } diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index d7a8046ad..052333a0a 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -220,6 +220,7 @@ "commandconfig.not_valid_subcommand": "That is not a valid subcommand.", "commandconfig.did_you_mean": "Did you mean: ", "commandconfig.subcommand_set_options_header": "Possible Values: ", + "commandconfig.subcommand_set_options_header_only": "Possible Values: ", "commandconfig.command_syntax": "Usage: ", "commandconfig.command_syntax_extended": "Usage: ", "commandconfig.flag_tutorial_usage": "Have an admin set the flag: ", @@ -472,6 +473,7 @@ "category.command_category_administration": "Admin", "grants.granted_plots": "Result: grants left.", + "grants.added": " grant(s) have been added.", "events.event_denied": " Cancelled by external plugin.", @@ -671,6 +673,7 @@ "commands.description.comment": "Comment on a plot.", "commands.description.condense": "Condense a plotworld.", "commands.description.confirm": "Confirm an action.", + "commands.description.continue": "Continue a plot that was previously marked as done.", "commands.description.copy": "Copy a plot.", "commands.description.createroadschematic": "Add a road schematic to your world using the roads around your current plot.", "commands.description.database": "Convert/Backup Storage.", diff --git a/Core/src/test/java/com/plotsquared/core/plot/FlagTest.java b/Core/src/test/java/com/plotsquared/core/plot/FlagTest.java index 7d6e8f7a5..1ef3e116f 100644 --- a/Core/src/test/java/com/plotsquared/core/plot/FlagTest.java +++ b/Core/src/test/java/com/plotsquared/core/plot/FlagTest.java @@ -32,11 +32,15 @@ import com.plotsquared.core.plot.flag.implementations.UseFlag; import com.sk89q.worldedit.world.item.ItemType; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import static org.junit.Assert.assertEquals; public class FlagTest { + private static final Logger logger = LoggerFactory.getLogger("P2/" + FlagTest.class.getSimpleName()); + private ItemType testBlock; @Before public void setUp() throws Exception { @@ -50,11 +54,11 @@ public class FlagTest { // //plot.setFlag(use, use.parseValue("33,33:1,6:4")); //TODO fix this so FlagTest will run during compile // Optional flag = plot.getFlag(use); // if (flag.isPresent()) { -// System.out.println(Flags.USE.valueToString(flag.get())); +// logger.info(Flags.USE.valueToString(flag.get())); // testBlock = ItemTypes.BONE_BLOCK; // flag.get().add(testBlock); // } -// flag.ifPresent(collection -> System.out.println(Flags.USE.valueToString(collection))); +// flag.ifPresent(collection -> logger.info(Flags.USE.valueToString(collection))); // Optional> flag2 = plot.getFlag(Flags.USE); // if (flag2.isPresent()) { // // assertThat(flag2.get(), (Matcher>) IsCollectionContaining.hasItem(testBlock)); diff --git a/Core/src/test/java/com/plotsquared/core/plot/PlotVersionTest.java b/Core/src/test/java/com/plotsquared/core/plot/PlotVersionTest.java index 26ddf72cc..be0b43e41 100644 --- a/Core/src/test/java/com/plotsquared/core/plot/PlotVersionTest.java +++ b/Core/src/test/java/com/plotsquared/core/plot/PlotVersionTest.java @@ -27,13 +27,17 @@ package com.plotsquared.core.plot; import com.plotsquared.core.PlotVersion; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PlotVersionTest { + private static final Logger logger = LoggerFactory.getLogger("P2/" + PlotVersionTest.class.getSimpleName()); + @Test public void tryParse() { //These are all random values chosen to form the test class. PlotVersion version = new PlotVersion("4.340", "f06903f", "19.08.05"); - System.out.println(version.versionString); + logger.info(version.versionString); } } diff --git a/HEADER b/HEADER.txt similarity index 95% rename from HEADER rename to HEADER.txt index 9e41cc6a5..0dfea1578 100644 --- a/HEADER +++ b/HEADER.txt @@ -7,7 +7,7 @@ | | |_| PlotSquared plot management system for Minecraft - Copyright (C) ${year} IntellectualSites + Copyright (C) 2020 IntellectualSites This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 3ca0cf1ba..000000000 --- a/build.gradle +++ /dev/null @@ -1,147 +0,0 @@ -import org.ajoberstar.grgit.Grgit - -buildscript { - repositories { - mavenCentral() - maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" } - jcenter() - } - dependencies { - classpath("com.github.jengelman.gradle.plugins:shadow:5.0.0") - classpath 'gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.14.0' - classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1' - } - configurations.all { - resolutionStrategy { - force("org.ow2.asm:asm:8.0.1") - force("org.jetbrains:annotations:20.1.0") - } - } -} - -plugins { - id "maven-publish" - id "org.ajoberstar.grgit" version "4.0.2" -} - -group = "com.plotsquared" - -ext { - git = Grgit.open(dir: new File(rootDir.toString() + "/.git")) -} - -def ver = "6.0.0" -def versuffix = "-SNAPSHOT" -ext { - if (project.hasProperty("versionsuffix")) { - versuffix = "-$versionsuffix" - } -} -version = ver + versuffix - -description = rootProject.name - -allprojects { - apply(plugin: 'com.github.hierynomus.license') - apply(plugin: 'com.bmuschko.nexus') - - gradle.projectsEvaluated { - tasks.withType(JavaCompile) { - options.compilerArgs << "-Xmaxerrs" << "1000" - } - } - license { - header rootProject.file('HEADER') - mapping 'java', 'SLASHSTAR_STYLE' - ext.year = 2020 - includes(["**/*.java","**/*.js"]) - } - nexus { - sign = false - repositoryUrl = 'https://mvn.intellectualsites.com/content/repositories/releases/' - snapshotRepositoryUrl = 'https://mvn.intellectualsites.com/content/repositories/snapshots/' - } -} - -subprojects { subproject -> - apply(plugin: "java") - apply(plugin: "maven") - apply(plugin: "eclipse") - apply(plugin: "idea") - apply(plugin: "com.github.johnrengelman.shadow") - - group = "com.plotsquared" - - clean.doFirst { - delete("../target") - } - - javadoc.options.encoding = 'UTF-8' - - dependencies { - compile group: 'org.json', name: 'json', version: '20200518' - implementation("com.sk89q.worldedit:worldedit-core:7.2.0-SNAPSHOT") { - exclude(module: "bukkit-classloader-check") - exclude(module: "mockito-core") - exclude(module: "dummypermscompat") - } - implementation("com.google.guava:guava:21.0") { - because("Minecraft uses Guava 21 as of 1.13") - } - testImplementation("junit:junit:4.13") - compile group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2' - } - - configurations.all { - resolutionStrategy { - force("junit:junit:4.12") - force("com.google.guava:guava:21.0") - force("org.jetbrains:annotations:20.1.0") - force("com.google.code.findbugs:jsr305:3.0.2") - } - } - - repositories { - mavenLocal() - mavenCentral() - maven { url = "https://maven.enginehub.org/repo/" } - maven { url = "https://repo.maven.apache.org/maven2" } - maven { url = "https://jitpack.io" } - } - - shadowJar { - dependencies { - include(dependency("org.json:json:20200518")) - include(dependency("net.kyori:text-api:3.0.2")) - include(dependency("javax.inject:javax.inject:1")) - include(dependency("aopalliance:aopalliance:1.0")) - } - relocate("io.papermc.lib", "com.plotsquared.bukkit.paperlib") - relocate("org.json", "com.plotsquared.json") { - exclude "org/json/simple/**" - } - archiveFileName = "${project.name}-${parent.version}.jar" - destinationDirectory = file "../target" - } - - version = rootProject.version -} - -task aggregatedJavadocs(type: Javadoc, description: "Generate javadocs from all child projects as if it was a single project", group: "Documentation") { - destinationDir = file("./docs/javadoc") - title = "$project.name $version API" - options.author true - options.links "http://docs.spring.io/spring/docs/4.3.x/javadoc-api/", "http://docs.oracle.com/javase/8/docs/api/", "http://docs.spring.io/spring-ws/docs/2.3.0.RELEASE/api/", "http://docs.spring.io/spring-security/site/docs/4.0.4.RELEASE/apidocs/" - options.addStringOption("Xdoclint:none", "-quiet") - - delete("./docs") - - subprojects.each { proj -> - proj.tasks.withType(Javadoc).each { javadocTask -> - source += javadocTask.source - classpath += javadocTask.classpath - excludes += javadocTask.excludes - includes += javadocTask.includes - } - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 000000000..723417229 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,206 @@ +import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin +import net.minecrell.gradle.licenser.LicenseExtension +import net.minecrell.gradle.licenser.Licenser + +plugins { + java + `java-library` + `maven-publish` + id("com.github.johnrengelman.shadow") version "6.0.0" + id("net.minecrell.licenser") version "0.4.1" + id("org.ajoberstar.grgit") version "4.1.0" + + eclipse + idea +} + +var ver by extra("6.0.0") +var versuffix by extra("-SNAPSHOT") +val versionsuffix: String? by project +if (versionsuffix != null) { + versuffix = "-$versionsuffix" +} +version = ver + versuffix + +allprojects { + group = "com.plotsquared" + version = rootProject.version + + repositories { + mavenCentral() + jcenter() + + maven { + name = "Sonatype OSS" + url = uri("https://oss.sonatype.org/content/repositories/snapshots/") + } + + maven { + name = "Jitpack" + url = uri("https://jitpack.io") + } + + maven { + name = "IntellectualSites Repository" + url = uri("https://mvn.intellectualsites.com/content/repositories/snapshots") + } + + maven { + name = "EngineHub Repository" + url = uri("https://maven.enginehub.org/repo/") + } + } +} + +subprojects { + apply { + plugin() + plugin() + plugin() + plugin() + plugin() + + plugin() + plugin() + } + + tasks { + // This is to create the target dir under the root project with all jars. + val assembleTargetDir = create("assembleTargetDirectory") { + destinationDir = rootDir.resolve("target") + into(destinationDir) + from(withType()) + } + named("build") { + dependsOn(assembleTargetDir) + } + } +} + +allprojects { + dependencies { + // Tests + testImplementation("junit:junit:4.13") + } + + configure { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = sourceCompatibility + } + + configure { + header = rootProject.file("HEADER.txt") + include("**/*.java") + newLine = false + } + + java { + withSourcesJar() + withJavadocJar() + } + + publishing { + publications { + create("maven") { + // This includes not only the original jar (i.e. not shadowJar), + // but also sources & javadocs due to the above java block. + from(components["java"]) + + pom { + licenses { + license { + name.set("GNU General Public License, Version 3.0") + url.set("https://www.gnu.org/licenses/gpl-3.0.html") + distribution.set("repo") + } + } + + developers { + developer { + id.set("Saulitired") + name.set("Alexander Söderberg") + } + developer { + id.set("N0tMyFaultOG") + name.set("NotMyFault") + } + } + + scm { + url.set("https://github.com/IntellectualSites/PlotSquared") + connection.set("scm:https://IntellectualSites@github.com/IntellectualSites/PlotSquared.git") + developerConnection.set("scm:git://github.com/IntellectualSites/PlotSquared.git") + } + } + } + } + + repositories { + mavenLocal() // Install to own local repository + + // Accept String? to not err if they're not present. + // Check that they both exist before adding the repo, such that + // `credentials` doesn't err if one is null. + // It's not pretty, but this way it can compile. + val nexusUsername: String? by project + val nexusPassword: String? by project + if (nexusUsername != null && nexusPassword != null) { + maven { + val repositoryUrl = "https://mvn.intellectualsites.com/content/repositories/releases/" + val snapshotRepositoryUrl = "https://mvn.intellectualsites.com/content/repositories/snapshots/" + url = uri( + if (version.toString().endsWith("-SNAPSHOT")) snapshotRepositoryUrl + else repositoryUrl + ) + + credentials { + username = nexusUsername + password = nexusPassword + } + } + } else { + logger.warn("No nexus repository is added; nexusUsername or nexusPassword is null.") + } + } + } + + val javadocDir = rootDir.resolve("docs").resolve("javadoc").resolve(project.name) + tasks { + named("clean") { + doFirst { + rootDir.resolve("target").deleteRecursively() + javadocDir.deleteRecursively() + } + } + + compileJava { + options.compilerArgs.addAll(arrayOf("-Xmaxerrs", "1000")) + options.compilerArgs.add("-Xlint:all") + for (disabledLint in arrayOf("processing", "path", "fallthrough", "serial")) + options.compilerArgs.add("-Xlint:$disabledLint") + options.isDeprecation = true + options.encoding = "UTF-8" + } + + javadoc { + val opt = options as StandardJavadocDocletOptions + opt.addStringOption("Xdoclint:none", "-quiet") + opt.tags( + "apiNote:a:API Note:", + "implSpec:a:Implementation Requirements:", + "implNote:a:Implementation Note:" + ) + opt.destinationDirectory = javadocDir + } + + shadowJar { + this.archiveClassifier.set(null as String?) + this.archiveFileName.set("${project.name}-${project.version}.${this.archiveExtension.getOrElse("jar")}") + this.destinationDirectory.set(rootProject.tasks.shadowJar.get().destinationDirectory.get()) + } + + named("build") { + dependsOn(named("shadowJar")) + } + } +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6c9a22477..88fe4c8a2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-rc-3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index f06101f70..000000000 --- a/settings.gradle +++ /dev/null @@ -1,6 +0,0 @@ -rootProject.name = 'PlotSquared' - -include 'Core', 'Bukkit' - -project(':Core').name = 'PlotSquared-Core' -project(':Bukkit').name = 'PlotSquared-Bukkit' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 000000000..c06a2cd45 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,6 @@ +rootProject.name = "PlotSquared" + +include("Core", "Bukkit") + +project(":Core").name = "PlotSquared-Core" +project(":Bukkit").name = "PlotSquared-Bukkit" \ No newline at end of file