Merge branch 'v6' into features/v6/queue-features

# Conflicts:
#	Core/src/main/java/com/plotsquared/core/generator/SquarePlotManager.java
#	Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotManager.java
#	Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java
This commit is contained in:
dordsor21 2020-10-09 15:23:09 +01:00
commit 914429ab4f
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
43 changed files with 613 additions and 994 deletions

8
.gitignore vendored
View File

@ -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/

View File

@ -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)

99
Bukkit/build.gradle.kts Normal file
View File

@ -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>("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()
}

View File

@ -1,198 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.plotsquared</groupId>
<artifactId>PlotSquared-Bukkit</artifactId>
<version>latest</version>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20200518</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>1.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.plotsquared</groupId>
<artifactId>PlotSquared-Core</artifactId>
<version>6.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.16.2-R0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.2.0-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>bukkit</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.papermc</groupId>
<artifactId>paperlib</artifactId>
<version>1.0.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>bukkit</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>se.hyperver.hyperverse</groupId>
<artifactId>Core</artifactId>
<version>0.6.0-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>squirrelid</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>be.maximvdw</groupId>
<artifactId>MVdWPlaceholderAPI</artifactId>
<version>3.1.1-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-core</artifactId>
<version>7.2.0-SNAPSHOT</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<artifactId>dummypermscompat</artifactId>
<groupId>*</groupId>
</exclusion>
<exclusion>
<artifactId>bukkit-classloader-check</artifactId>
<groupId>*</groupId>
</exclusion>
<exclusion>
<artifactId>mockito-core</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>21.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.2-R0.1-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>text-adapter-bukkit</artifactId>
<version>3.0.3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.10.6</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>EssentialsX</artifactId>
<version>2.18.0</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<artifactId>paperlib</artifactId>
<groupId>io.papermc</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.alpenblock</groupId>
<artifactId>BungeePerms</artifactId>
<version>4.0-dev-106</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.0.0-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.0.0-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.8.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -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<Map.Entry<Map.Entry<String, String>, Boolean>> getPluginIds() {
List<Map.Entry<Map.Entry<String, String>, Boolean>> names = new ArrayList<>();
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
Map.Entry<String, String> 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() {

View File

@ -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);
}

View File

@ -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) {

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
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<BungeePerms> 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<UUIDMapping> getNames(@Nonnull final List<UUID> uuids) {
final List<UUIDMapping> 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<UUIDMapping> getUUIDs(@Nonnull final List<String> usernames) {
final List<UUIDMapping> 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;
}
}

View File

@ -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:

View File

@ -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)

58
Core/build.gradle.kts Normal file
View File

@ -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"))
)
}
}

View File

@ -1,138 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.plotsquared</groupId>
<artifactId>PlotSquared-Core</artifactId>
<version>latest</version>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20200518</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-assistedinject</artifactId>
<version>4.2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-core</artifactId>
<version>7.2.0-SNAPSHOT</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<artifactId>dummypermscompat</artifactId>
<groupId>*</groupId>
</exclusion>
<exclusion>
<artifactId>bukkit-classloader-check</artifactId>
<groupId>*</groupId>
</exclusion>
<exclusion>
<artifactId>mockito-core</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>21.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.26</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.3.72</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>20.0.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.khelekore</groupId>
<artifactId>prtree</artifactId>
<version>1.7.0-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.0.0-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.0.0-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.8.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.intellectualsites</groupId>
<artifactId>Pipeline</artifactId>
<version>1.4.0-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -142,8 +142,6 @@ public interface PlotPlatform<P> extends LocaleHolder {
return getInjector().getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class));
}
List<Map.Entry<Map.Entry<String, String>, Boolean>> getPluginIds();
/**
* Get the backup manager instance
*
@ -256,6 +254,8 @@ public interface PlotPlatform<P> extends LocaleHolder {
*/
@Nonnull Audience getConsoleAudience();
String getPluginList();
/**
* Load the caption maps
*/

View File

@ -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();

View File

@ -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"));
}
}));
}

View File

@ -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<Map.Entry<String, String>, Boolean> pluginInfo : PlotSquared
.platform().getPluginIds()) {
Map.Entry<String, String> 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"))

View File

@ -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<Integer> access = pp.accessPersistentMetaData(
PlayerMetaDataKeys.PERSISTENT_GRANTED_PLOTS)) {
@ -99,7 +101,7 @@ public class Grant extends Command {
}
}
} else {
DBFunc.getPersistentMeta(uuid, new RunnableVal<Map<String, byte[]>>() {
DBFunc.getPersistentMeta(uuid.getUuid(), new RunnableVal<Map<String, byte[]>>() {
@Override public void run(Map<String, byte[]> 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<Command> 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<Command> tab(final PlotPlayer<?> player, final String[] args, final boolean space) {
if (args.length == 1) {
final List<String> 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<Command> 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());
}
}

View File

@ -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") {

View File

@ -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<Command> tab(final PlotPlayer player, final String[] args,
final boolean space) {
public Collection<Command> 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<String> 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<Command> 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();

View File

@ -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<Command> 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<Command> tab(final PlotPlayer<?> player, final String[] args, final boolean space) {
if (args.length == 1) {
final List<String> 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<Command> 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());
}
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}

View File

@ -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"),

View File

@ -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<P> 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);
}

View File

@ -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);
}

View File

@ -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<PlotId> plotIds, @Nullable QueueCoordinator queue) {
@Override public boolean startPlotMerge(@Nonnull List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
return false;
}
@Override public boolean startPlotUnlink(@NotNull List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
@Override public boolean startPlotUnlink(@Nonnull List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
return false;
}
@Override public boolean finishPlotMerge(@NotNull List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
@Override public boolean finishPlotMerge(@Nonnull List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
return false;
}
@Override public boolean finishPlotUnlink(@NotNull List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
@Override public boolean finishPlotUnlink(@Nonnull List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
return false;
}

View File

@ -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;
});
}

View File

@ -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<String> 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<String> 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;

View File

@ -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;
}

View File

@ -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<String, Placeholder> 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<PlotPlayer<?>, String> placeholderFunction) {
@SuppressWarnings("ALL") public void createPlaceholder(@Nonnull final String key,
@Nonnull final Function<PlotPlayer<?>, 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<PlotPlayer<?>, Plot, String> placeholderFunction) {
public void createPlaceholder(@Nonnull final String key,
@Nonnull final BiFunction<PlotPlayer<?>, 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<Placeholder> getPlaceholders() {
@Nonnull public Collection<Placeholder> getPlaceholders() {
return Collections.unmodifiableCollection(this.placeholders.values());
}

View File

@ -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 "";
}

View File

@ -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);
}

View File

@ -220,6 +220,7 @@
"commandconfig.not_valid_subcommand": "<prefix><gray>That is not a valid subcommand.</gray>",
"commandconfig.did_you_mean": "<prefix><gray>Did you mean: <gold><value></gold></gray>",
"commandconfig.subcommand_set_options_header": "<prefix><gray>Possible Values: <values>",
"commandconfig.subcommand_set_options_header_only": "<prefix><gray>Possible Values: ",
"commandconfig.command_syntax": "<prefix><gold>Usage: </gold><gray><value></gray>",
"commandconfig.command_syntax_extended": "<prefix><gold>Usage: </gold><gray><value1> <value2></gray>",
"commandconfig.flag_tutorial_usage": "<prefix><gold>Have an admin set the flag: </gold><gray><flag></gray>",
@ -472,6 +473,7 @@
"category.command_category_administration": "<gray>Admin</gray>",
"grants.granted_plots": "<prefix><gold>Result: <gray><amount> </gray>grants left.</gold>",
"grants.added": "<prefix><gold><grants></gold> <gray>grant(s) have been added.</gray>",
"events.event_denied": "<prefix><gold><value> </gold><gray>Cancelled by external plugin.</gray>",
@ -671,6 +673,7 @@
"commands.description.comment": "<gray>Comment on a plot.</gray>",
"commands.description.condense": "<gray>Condense a plotworld.</gray>",
"commands.description.confirm": "<gray>Confirm an action.</gray>",
"commands.description.continue": "<gray>Continue a plot that was previously marked as done.</gray>",
"commands.description.copy": "<gray>Copy a plot.</gray>",
"commands.description.createroadschematic": "<gray>Add a road schematic to your world using the roads around your current plot.</gray>",
"commands.description.database": "<gray>Convert/Backup Storage.</gray>",

View File

@ -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<? extends Collection> 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<Set<BlockType>> flag2 = plot.getFlag(Flags.USE);
// if (flag2.isPresent()) {
// // assertThat(flag2.get(), (Matcher<? super Set<BlockType>>) IsCollectionContaining.hasItem(testBlock));

View File

@ -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);
}
}

View File

@ -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

View File

@ -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
}
}
}

206
build.gradle.kts Normal file
View File

@ -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<JavaPlugin>()
plugin<JavaLibraryPlugin>()
plugin<MavenPublishPlugin>()
plugin<ShadowPlugin>()
plugin<Licenser>()
plugin<EclipsePlugin>()
plugin<IdeaPlugin>()
}
tasks {
// This is to create the target dir under the root project with all jars.
val assembleTargetDir = create<Copy>("assembleTargetDirectory") {
destinationDir = rootDir.resolve("target")
into(destinationDir)
from(withType<Jar>())
}
named("build") {
dependsOn(assembleTargetDir)
}
}
}
allprojects {
dependencies {
// Tests
testImplementation("junit:junit:4.13")
}
configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = sourceCompatibility
}
configure<LicenseExtension> {
header = rootProject.file("HEADER.txt")
include("**/*.java")
newLine = false
}
java {
withSourcesJar()
withJavadocJar()
}
publishing {
publications {
create<MavenPublication>("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<Delete>("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"))
}
}
}

View File

@ -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

View File

@ -1,6 +0,0 @@
rootProject.name = 'PlotSquared'
include 'Core', 'Bukkit'
project(':Core').name = 'PlotSquared-Core'
project(':Bukkit').name = 'PlotSquared-Bukkit'

6
settings.gradle.kts Normal file
View File

@ -0,0 +1,6 @@
rootProject.name = "PlotSquared"
include("Core", "Bukkit")
project(":Core").name = "PlotSquared-Core"
project(":Bukkit").name = "PlotSquared-Bukkit"