mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2026-11-04 09:02:07 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
578e802368 | ||
|
|
49ebc79b7d | ||
|
|
31c9320db3 | ||
|
|
8ec5e8a7e0 | ||
|
|
fa605e6a19 | ||
|
|
048bd2addd | ||
|
|
d002474ec6 | ||
|
|
a156c07ab3 | ||
|
|
f0239b632c | ||
|
|
7c38af4c7a | ||
|
|
da6bfb3b95 | ||
|
|
1439345adc | ||
|
|
f310e93a5b | ||
|
|
ab33d3fdc5 | ||
|
|
d1a3193754 | ||
|
|
e42d8bcda7 | ||
|
|
20eb298cac | ||
|
|
b4914ef8cd | ||
|
|
3e9e1c84ef | ||
|
|
8783e2bac6 | ||
|
|
aa5160334b | ||
|
|
caa121c12a | ||
|
|
86a1fa6ee9 | ||
|
|
ab48a66237 | ||
|
|
aa254c80e0 | ||
|
|
f6a0a0b415 | ||
|
|
0a9eb447d6 | ||
|
|
02a8fd4c17 | ||
|
|
8cbce96a2c | ||
|
|
bb3fdcc880 | ||
|
|
8d5953a550 | ||
|
|
129ae6c971 | ||
|
|
b67fd01ebd | ||
|
|
62be386626 | ||
|
|
741f9e231b | ||
|
|
bc63119373 | ||
|
|
3549f04a33 |
No files matched your search
+33
-1
@@ -1,2 +1,34 @@
|
||||
*.java diff=java
|
||||
* text=auto eol=lf
|
||||
# Force Batch files to CRLF
|
||||
*.bat eol=crlf -text
|
||||
|
||||
# Java sources
|
||||
*.java text diff=java
|
||||
*.kt text diff=java
|
||||
*.gradle text diff=java
|
||||
*.gradle.kts text diff=java
|
||||
|
||||
# These files are text and should be normalized (Convert crlf => lf)
|
||||
*.css text diff=css
|
||||
*.df text
|
||||
*.htm text diff=html
|
||||
*.html text diff=html
|
||||
*.js text
|
||||
*.jsp text
|
||||
*.jspf text
|
||||
*.jspx text
|
||||
*.properties text
|
||||
*.tld text
|
||||
*.tag text
|
||||
*.tagx text
|
||||
*.xml text
|
||||
|
||||
# These files are binary and should be left untouched
|
||||
# (binary is a macro for -text -diff)
|
||||
*.class binary
|
||||
*.dll binary
|
||||
*.ear binary
|
||||
*.jar binary
|
||||
*.so binary
|
||||
*.war binary
|
||||
*.jks binary
|
||||
@@ -0,0 +1,48 @@
|
||||
name: Gradle Build
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'version/*'
|
||||
pull_request:
|
||||
merge_group:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build WorldGuard on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: 25
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v5
|
||||
with:
|
||||
cache-read-only: ${{ !(github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/version/')) }}
|
||||
|
||||
- name: Execute Gradle build
|
||||
run: ./gradlew build -s
|
||||
|
||||
- uses: actions/upload-artifact@v6
|
||||
name: Archive Reports
|
||||
if: always()
|
||||
with:
|
||||
name: reports for ${{ matrix.os }}
|
||||
path: '**/build/reports/**'
|
||||
|
||||
- uses: actions/upload-artifact@v6
|
||||
name: Archive Logs
|
||||
if: always()
|
||||
with:
|
||||
name: logs for ${{ matrix.os }}
|
||||
path: '**/*.log'
|
||||
@@ -1,5 +1,19 @@
|
||||
# Changelog
|
||||
|
||||
## 7.0.18
|
||||
|
||||
* Add lava-harden flag for cobblestone/stone/obsidian/basalt forming.
|
||||
* Replace PigZapEvent on Paper to avoid startup warnings.
|
||||
* Avoid unnecessary NPC checks to improve performance in some situations.
|
||||
* Filtered "multiple regions" messages in commands to only show regions that the player has permission to use the command on.
|
||||
* Fixed potential corruption that can occur in extreme region / slow hardware setups where it hasn't finished saving by the next save attempt.
|
||||
|
||||
## 7.0.17
|
||||
|
||||
* Fix cocoa not being treated as a crop in relevant flags.
|
||||
* Fix overlapping game mode flags sometimes not storing the expected previous game mode.
|
||||
* Replace PaperLib functionality that doesn't behave as expected on MC 26.1+.
|
||||
|
||||
## 7.0.16
|
||||
|
||||
* Update to 1.21.11.
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
Compiling
|
||||
=========
|
||||
|
||||
You can compile WorldGuard as long as you have some version of Java greater than or equal to 21 installed.
|
||||
Gradle will download JDK 21 specifically if needed, but it needs some version of Java to bootstrap from.
|
||||
You can compile WorldGuard as long as you have some version of Java greater than or equal to 25 installed.
|
||||
Gradle will download JDK 25 specifically if needed, but it needs some version of Java to bootstrap from.
|
||||
|
||||
The build process uses Gradle, which you do *not* need to download. WorldGuard is a multi-module project with three modules:
|
||||
|
||||
|
||||
@@ -3,19 +3,23 @@ plugins {
|
||||
}
|
||||
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven {
|
||||
name = "EngineHub Repository"
|
||||
url = uri("https://maven.enginehub.org/repo/")
|
||||
name = "EngineHub"
|
||||
url = uri("https://repo.enginehub.org/libs-release/")
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(gradleApi())
|
||||
implementation(libs.licenser)
|
||||
implementation(libs.grgit)
|
||||
implementation(libs.crankcase.java)
|
||||
implementation(libs.crankcase.javaLibrary)
|
||||
implementation(libs.crankcase.common)
|
||||
implementation(libs.crankcase.licensing)
|
||||
implementation(libs.crankcase.git)
|
||||
implementation(libs.crankcase.publishing)
|
||||
implementation(libs.shadow)
|
||||
implementation(libs.jfrog.buildinfo)
|
||||
implementation(libs.gson)
|
||||
|
||||
constraints {
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
import org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention
|
||||
import org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask
|
||||
|
||||
plugins {
|
||||
id("com.jfrog.artifactory")
|
||||
}
|
||||
|
||||
val ARTIFACTORY_CONTEXT_URL = "artifactory_contextUrl"
|
||||
val ARTIFACTORY_USER = "artifactory_user"
|
||||
val ARTIFACTORY_PASSWORD = "artifactory_password"
|
||||
|
||||
if (!project.hasProperty(ARTIFACTORY_CONTEXT_URL)) ext[ARTIFACTORY_CONTEXT_URL] = "http://localhost"
|
||||
if (!project.hasProperty(ARTIFACTORY_USER)) ext[ARTIFACTORY_USER] = "guest"
|
||||
if (!project.hasProperty(ARTIFACTORY_PASSWORD)) ext[ARTIFACTORY_PASSWORD] = ""
|
||||
|
||||
configure<ArtifactoryPluginConvention> {
|
||||
setContextUrl("${project.property(ARTIFACTORY_CONTEXT_URL)}")
|
||||
clientConfig.publisher.run {
|
||||
repoKey = when {
|
||||
"${project.version}".contains("SNAPSHOT") -> "libs-snapshot-local"
|
||||
else -> "libs-release-local"
|
||||
}
|
||||
username = "${project.property(ARTIFACTORY_USER)}"
|
||||
password = "${project.property(ARTIFACTORY_PASSWORD)}"
|
||||
isMaven = true
|
||||
isIvy = false
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named<ArtifactoryTask>("artifactoryPublish") {
|
||||
isSkip = true
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
plugins {
|
||||
id("com.jfrog.artifactory")
|
||||
}
|
||||
|
||||
// Artifactory eagerly evaluates publications, so this must run after all changes to artifacts are done
|
||||
afterEvaluate {
|
||||
tasks.named<org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask>("artifactoryPublish") {
|
||||
publications("maven")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
plugins {
|
||||
id("org.enginehub.crankcase.java-library")
|
||||
id("buildlogic.common-java")
|
||||
}
|
||||
@@ -5,61 +5,25 @@ plugins {
|
||||
id("eclipse")
|
||||
id("idea")
|
||||
id("checkstyle")
|
||||
id("org.enginehub.crankcase.java")
|
||||
id("buildlogic.common")
|
||||
}
|
||||
|
||||
tasks
|
||||
.withType<JavaCompile>()
|
||||
.matching { it.name == "compileJava" || it.name == "compileTestJava" }
|
||||
.configureEach {
|
||||
val disabledLint = listOf(
|
||||
"processing", "path", "fallthrough", "serial", "overloads",
|
||||
)
|
||||
options.release.set(21)
|
||||
options.compilerArgs.addAll(listOf("-Xlint:all") + disabledLint.map { "-Xlint:-$it" })
|
||||
options.isDeprecation = true
|
||||
options.encoding = "UTF-8"
|
||||
options.compilerArgs.add("-parameters")
|
||||
//options.compilerArgs.add("-Werror")
|
||||
}
|
||||
crankcaseJava {
|
||||
javaRelease = 25
|
||||
disabledLints = listOf("processing", "path", "fallthrough", "serial", "overloads")
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
// TODO Remove this when we're able
|
||||
options.compilerArgs.remove("-Werror")
|
||||
}
|
||||
|
||||
configure<CheckstyleExtension> {
|
||||
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
|
||||
toolVersion = "10.16.0"
|
||||
}
|
||||
|
||||
tasks.withType<Test>().configureEach {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
"compileOnly"(stringyLibs.getLibrary("jsr305"))
|
||||
"testImplementation"(platform(stringyLibs.getLibrary("junit-bom")))
|
||||
"testImplementation"(stringyLibs.getLibrary("junit-jupiter-api"))
|
||||
"testImplementation"(stringyLibs.getLibrary("junit-jupiter-params"))
|
||||
"testRuntimeOnly"(stringyLibs.getLibrary("junit-jupiter-engine"))
|
||||
}
|
||||
|
||||
// Java 8 turns on doclint which we fail
|
||||
tasks.withType<Javadoc>().configureEach {
|
||||
options.encoding = "UTF-8"
|
||||
(options as StandardJavadocDocletOptions).apply {
|
||||
//addBooleanOption("Werror", true)
|
||||
addBooleanOption("Xdoclint:all", true)
|
||||
addBooleanOption("Xdoclint:-missing", true)
|
||||
tags(
|
||||
"apiNote:a:API Note:",
|
||||
"implSpec:a:Implementation Requirements:",
|
||||
"implNote:a:Implementation Note:"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
configure<JavaPluginExtension> {
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
tasks.named("check").configure {
|
||||
dependsOn("checkstyleMain", "checkstyleTest")
|
||||
}
|
||||
@@ -1,37 +1,15 @@
|
||||
import buildlogic.getLibrary
|
||||
import buildlogic.stringyLibs
|
||||
import org.gradle.plugins.ide.idea.model.IdeaModel
|
||||
|
||||
plugins {
|
||||
id("org.cadixdev.licenser")
|
||||
id("org.enginehub.crankcase.common")
|
||||
id("org.enginehub.crankcase.licensing")
|
||||
id("org.enginehub.crankcase.git")
|
||||
}
|
||||
|
||||
group = rootProject.group
|
||||
version = rootProject.version
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "EngineHub"
|
||||
url = uri("https://maven.enginehub.org/repo/")
|
||||
}
|
||||
mavenCentral()
|
||||
afterEvaluate {
|
||||
killNonEngineHubRepositories()
|
||||
}
|
||||
}
|
||||
|
||||
configurations.all {
|
||||
resolutionStrategy {
|
||||
cacheChangingModulesFor(1, TimeUnit.DAYS)
|
||||
}
|
||||
}
|
||||
|
||||
plugins.withId("java") {
|
||||
the<JavaPluginExtension>().toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
for (conf in listOf("implementation", "api")) {
|
||||
if (!configurations.names.contains(conf)) {
|
||||
@@ -55,18 +33,3 @@ dependencies {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
license {
|
||||
header(rootProject.file("HEADER.txt"))
|
||||
include("**/*.java")
|
||||
include("**/*.kt")
|
||||
}
|
||||
|
||||
plugins.withId("idea") {
|
||||
configure<IdeaModel> {
|
||||
module {
|
||||
isDownloadSources = true
|
||||
isDownloadJavadoc = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
plugins {
|
||||
id("java")
|
||||
id("maven-publish")
|
||||
id("buildlogic.common-java")
|
||||
id("buildlogic.artifactory-sub")
|
||||
id("buildlogic.common-java-library")
|
||||
id("org.enginehub.crankcase.publishing")
|
||||
}
|
||||
|
||||
ext["internalVersion"] = "$version+${rootProject.ext["gitCommitHash"]}"
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
register<MavenPublication>("maven") {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
plugins {
|
||||
id("java-base")
|
||||
id("maven-publish")
|
||||
id("com.github.johnrengelman.shadow")
|
||||
id("com.jfrog.artifactory")
|
||||
id("com.gradleup.shadow")
|
||||
id("buildlogic.common")
|
||||
id("buildlogic.artifactory-sub")
|
||||
id("org.enginehub.crankcase.publishing")
|
||||
}
|
||||
|
||||
// A horrible hack because `softwareComponentFactory` has to be gotten via plugin
|
||||
@@ -119,7 +118,7 @@ val apiElements = project.configurations.register("apiElements") {
|
||||
attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY))
|
||||
attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.SHADOWED))
|
||||
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR))
|
||||
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21)
|
||||
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 25)
|
||||
}
|
||||
outgoing.artifact(tasks.named("jar"))
|
||||
}
|
||||
@@ -134,7 +133,7 @@ val runtimeElements = project.configurations.register("runtimeElements") {
|
||||
attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY))
|
||||
attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.SHADOWED))
|
||||
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR))
|
||||
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21)
|
||||
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 25)
|
||||
}
|
||||
outgoing.artifact(tasks.named("jar"))
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
plugins {
|
||||
id("com.github.johnrengelman.shadow")
|
||||
id("com.gradleup.shadow")
|
||||
id("buildlogic.core-and-platform")
|
||||
}
|
||||
|
||||
shadow {
|
||||
addShadowVariantIntoJavaComponent = false
|
||||
}
|
||||
|
||||
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
||||
archiveClassifier.set("dist")
|
||||
dependencies {
|
||||
@@ -20,11 +24,6 @@ tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJ
|
||||
exclude("META-INF/maven/**")
|
||||
minimize()
|
||||
}
|
||||
val javaComponent = components["java"] as AdhocComponentWithVariants
|
||||
// I don't think we want this published (it's the shadow jar)
|
||||
javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) {
|
||||
skip()
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
tasks.named<Jar>("jar") {
|
||||
|
||||
@@ -7,7 +7,9 @@ import org.gradle.api.artifacts.VersionCatalogsExtension
|
||||
import org.gradle.api.artifacts.VersionConstraint
|
||||
import org.gradle.api.plugins.ExtraPropertiesExtension
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.enginehub.crankcase.git.GitExtension
|
||||
import org.gradle.kotlin.dsl.getByType
|
||||
import org.gradle.kotlin.dsl.the
|
||||
|
||||
val Project.ext: ExtraPropertiesExtension
|
||||
get() = extensions.getByType()
|
||||
@@ -15,6 +17,12 @@ val Project.ext: ExtraPropertiesExtension
|
||||
val Project.stringyLibs: VersionCatalog
|
||||
get() = extensions.getByType<VersionCatalogsExtension>().named("libs")
|
||||
|
||||
val Project.internalVersion: Provider<String>
|
||||
get() {
|
||||
val version = version.toString()
|
||||
return the<GitExtension>().commitHash.map { "$version+$it" }
|
||||
}
|
||||
|
||||
fun VersionCatalog.getLibrary(name: String): Provider<MinimalExternalModuleDependency> = findLibrary(name).orElseThrow {
|
||||
error("Library $name not found in version catalog")
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import org.gradle.api.artifacts.dsl.RepositoryHandler
|
||||
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
|
||||
import org.gradle.api.logging.Logging
|
||||
|
||||
// The primary point of this is repository up-time. We replace most other repositories with EngineHub's repository.
|
||||
// This is because we have stronger up-time guarantees for our repository. However, Maven Central and Sonatype are
|
||||
// clearly even better, so we allow those as well. We also allow Gradle's plugin repository.
|
||||
private val ALLOWED_PREFIXES = listOf(
|
||||
"https://maven.enginehub.org",
|
||||
"https://repo.maven.apache.org/maven2/",
|
||||
"https://s01.oss.sonatype.org/content/repositories/snapshots/",
|
||||
"https://plugins.gradle.org",
|
||||
"file:"
|
||||
)
|
||||
private val LOGGER = Logging.getLogger("repositoriesHelper")
|
||||
|
||||
fun RepositoryHandler.killNonEngineHubRepositories() {
|
||||
val toRemove = mutableListOf<MavenArtifactRepository>()
|
||||
for (repo in this) {
|
||||
if (repo is MavenArtifactRepository && !ALLOWED_PREFIXES.any { repo.url.toString().startsWith(it) }) {
|
||||
LOGGER.info("Removing non-EngineHub repository: {}", repo.url)
|
||||
toRemove.add(repo)
|
||||
}
|
||||
}
|
||||
toRemove.forEach { remove(it) }
|
||||
}
|
||||
@@ -1,17 +1,3 @@
|
||||
import org.ajoberstar.grgit.Grgit
|
||||
|
||||
plugins {
|
||||
id("buildlogic.common")
|
||||
id("buildlogic.artifactory-root")
|
||||
}
|
||||
|
||||
if (!project.hasProperty("gitCommitHash")) {
|
||||
apply(plugin = "org.ajoberstar.grgit")
|
||||
ext["gitCommitHash"] = try {
|
||||
extensions.getByName<Grgit>("grgit").head()?.abbreviatedId
|
||||
} catch (e: Exception) {
|
||||
logger.warn("Error getting commit hash", e)
|
||||
|
||||
"no.git.id"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.api.plugins.quality.CheckstyleExtension
|
||||
import org.gradle.api.tasks.compile.JavaCompile
|
||||
import org.gradle.api.tasks.javadoc.Javadoc
|
||||
import org.gradle.api.tasks.testing.Test
|
||||
import org.gradle.external.javadoc.StandardJavadocDocletOptions
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.dependencies
|
||||
import org.gradle.kotlin.dsl.get
|
||||
import org.gradle.kotlin.dsl.withType
|
||||
|
||||
fun Project.applyCommonJavaConfiguration(sourcesJar: Boolean, javaRelease: Int = 8, banSlf4j: Boolean = true) {
|
||||
applyCommonConfiguration()
|
||||
apply(plugin = "eclipse")
|
||||
apply(plugin = "idea")
|
||||
apply(plugin = "checkstyle")
|
||||
|
||||
tasks
|
||||
.withType<JavaCompile>()
|
||||
.matching { it.name == "compileJava" || it.name == "compileTestJava" }
|
||||
.configureEach {
|
||||
val disabledLint = listOf(
|
||||
"processing", "path", "fallthrough", "serial"
|
||||
)
|
||||
options.release.set(javaRelease)
|
||||
options.compilerArgs.addAll(listOf("-Xlint:all") + disabledLint.map { "-Xlint:-$it" })
|
||||
options.isDeprecation = true
|
||||
options.encoding = "UTF-8"
|
||||
options.compilerArgs.add("-parameters")
|
||||
}
|
||||
|
||||
configure<CheckstyleExtension> {
|
||||
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
|
||||
toolVersion = "9.1"
|
||||
}
|
||||
|
||||
tasks.withType<Test>().configureEach {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
"compileOnly"("com.google.code.findbugs:jsr305:${Versions.FINDBUGS}")
|
||||
"testImplementation"("org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT}")
|
||||
"testImplementation"("org.junit.jupiter:junit-jupiter-params:${Versions.JUNIT}")
|
||||
"testImplementation"("org.mockito:mockito-core:${Versions.MOCKITO}")
|
||||
"testImplementation"("org.mockito:mockito-junit-jupiter:${Versions.MOCKITO}")
|
||||
"testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT}")
|
||||
}
|
||||
|
||||
// Java 8 turns on doclint which we fail
|
||||
tasks.withType<Javadoc>().configureEach {
|
||||
options.encoding = "UTF-8"
|
||||
(options as StandardJavadocDocletOptions).apply {
|
||||
addStringOption("Xdoclint:none", "-quiet")
|
||||
tags(
|
||||
"apiNote:a:API Note:",
|
||||
"implSpec:a:Implementation Requirements:",
|
||||
"implNote:a:Implementation Note:"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
configure<JavaPluginExtension> {
|
||||
disableAutoTargetJvm()
|
||||
withJavadocJar()
|
||||
if (sourcesJar) {
|
||||
withSourcesJar()
|
||||
}
|
||||
}
|
||||
|
||||
if (banSlf4j) {
|
||||
configurations["compileClasspath"].apply {
|
||||
resolutionStrategy.componentSelection {
|
||||
withModule("org.slf4j:slf4j-api") {
|
||||
reject("No SLF4J allowed on compile classpath")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named("check").configure {
|
||||
dependsOn("checkstyleMain", "checkstyleTest")
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
group=com.sk89q.worldguard
|
||||
version=7.0.16
|
||||
version=7.1.0-SNAPSHOT
|
||||
|
||||
org.gradle.parallel=true
|
||||
@@ -1,2 +1,2 @@
|
||||
#This file is generated by updateDaemonJvm
|
||||
toolchainVersion=21
|
||||
toolchainVersion=25
|
||||
+15
-15
@@ -1,5 +1,6 @@
|
||||
[versions]
|
||||
worldedit = "7.3.18"
|
||||
worldedit = "7.4.4"
|
||||
crankcase = "0.1.0"
|
||||
|
||||
# Minimum versions we apply to make dependencies support newer Java
|
||||
minimumAsm = "9.7"
|
||||
@@ -10,10 +11,14 @@ minimumTinyRemapper = "0.8.11"
|
||||
|
||||
[libraries]
|
||||
|
||||
licenser = "gradle.plugin.org.cadixdev.gradle:licenser:0.6.1"
|
||||
grgit = "org.ajoberstar.grgit:grgit-gradle:5.2.2"
|
||||
shadow = "com.github.johnrengelman:shadow:8.1.1"
|
||||
jfrog-buildinfo = "org.jfrog.buildinfo:build-info-extractor-gradle:5.2.0"
|
||||
crankcase-java = { module = "org.enginehub.crankcase:java", version.ref = "crankcase" }
|
||||
crankcase-javaLibrary = { module = "org.enginehub.crankcase:java-library", version.ref = "crankcase" }
|
||||
crankcase-common = { module = "org.enginehub.crankcase:common", version.ref = "crankcase" }
|
||||
crankcase-licensing = { module = "org.enginehub.crankcase:licensing", version.ref = "crankcase" }
|
||||
crankcase-git = { module = "org.enginehub.crankcase:git", version.ref = "crankcase" }
|
||||
crankcase-publishing = { module = "org.enginehub.crankcase:publishing", version.ref = "crankcase" }
|
||||
|
||||
shadow = "com.gradleup.shadow:com.gradleup.shadow.gradle.plugin:9.3.2"
|
||||
|
||||
squirrelid = "org.enginehub:squirrelid:0.3.2"
|
||||
|
||||
@@ -22,12 +27,7 @@ autoService = "com.google.auto.service:auto-service:1.1.1"
|
||||
jsr305 = "com.google.code.findbugs:jsr305:3.0.2"
|
||||
jetbrains-annotations = "org.jetbrains:annotations:24.1.0"
|
||||
|
||||
junit-bom = "org.junit:junit-bom:5.10.2"
|
||||
junit-jupiter-api.module = "org.junit.jupiter:junit-jupiter-api"
|
||||
junit-jupiter-params.module = "org.junit.jupiter:junit-jupiter-params"
|
||||
junit-jupiter-engine.module = "org.junit.jupiter:junit-jupiter-engine"
|
||||
|
||||
paperApi = "io.papermc.paper:paper-api:1.21.11-R0.1-SNAPSHOT"
|
||||
paperApi = "io.papermc.paper:paper-api:26.2.build.+"
|
||||
paperLib = "io.papermc:paperlib:1.0.8"
|
||||
|
||||
dummypermscompat = "com.sk89q:dummypermscompat:1.10"
|
||||
@@ -42,10 +42,10 @@ commandbook = "com.sk89q:commandbook:2.3"
|
||||
hamcrest-library = "org.hamcrest:hamcrest-library:2.2"
|
||||
|
||||
# Mojang-provided libraries, CHECK AGAINST MINECRAFT for versions
|
||||
guava = "com.google.guava:guava:33.5.0-jre!!"
|
||||
log4j-bom = "org.apache.logging.log4j:log4j-bom:2.24.1!!"
|
||||
gson = "com.google.code.gson:gson:2.13.2!!"
|
||||
fastutil = "it.unimi.dsi:fastutil:8.5.18!!"
|
||||
guava = "com.google.guava:guava:33.6.0-jre"
|
||||
log4j-bom = "org.apache.logging.log4j:log4j-bom:2.25.2"
|
||||
gson = "com.google.code.gson:gson:2.14.0"
|
||||
fastutil = "it.unimi.dsi:fastutil:8.5.18"
|
||||
|
||||
# Bukkit-provided libraries, CHECK AGAINST SPIGOT for versions
|
||||
# Note that we need to balance support for older MC versus working at all on newer ones, so the exact versions here
|
||||
|
||||
+3
-1
@@ -1,7 +1,9 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
|
||||
networkTimeout=10000
|
||||
retries=0
|
||||
retryBackOffMs=500
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
+40
-20
@@ -1,38 +1,58 @@
|
||||
pluginManagement {
|
||||
// pluginManagement repositories resolve plugins before the repo-reconfiguration plugin can
|
||||
// apply, so they must point at EngineHub mirrors directly rather than upstream URLs.
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven {
|
||||
name = "EngineHub"
|
||||
url = uri("https://maven.enginehub.org/repo/")
|
||||
url = uri("https://repo.enginehub.org/libs-release/")
|
||||
mavenContent {
|
||||
releasesOnly()
|
||||
includeGroupAndSubgroups("com.sk89q")
|
||||
includeGroupAndSubgroups("org.enginehub")
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = "EngineHub Maven Central Mirror"
|
||||
url = uri("https://repo.enginehub.org/internal/maven-central-proxy/")
|
||||
mavenContent {
|
||||
releasesOnly()
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = "EngineHub Gradle Plugin Portal Mirror"
|
||||
url = uri("https://repo.enginehub.org/internal/plugin-portal-proxy/")
|
||||
mavenContent {
|
||||
releasesOnly()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
plugins {
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
|
||||
id("org.enginehub.crankcase.repo-reconfiguration") version "0.1.0"
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
maven {
|
||||
name = "EngineHub"
|
||||
url = uri("https://maven.enginehub.org/repo/")
|
||||
name = "PaperMC"
|
||||
url = uri("https://repo.papermc.io/repository/maven-public/")
|
||||
}
|
||||
gradle.settingsEvaluated {
|
||||
// Duplicates repositoriesHelper.kt, since we can't import it
|
||||
val allowedPrefixes = listOf(
|
||||
"https://maven.enginehub.org",
|
||||
"https://repo.maven.apache.org/maven2/",
|
||||
"file:"
|
||||
)
|
||||
|
||||
for (repo in this@repositories) {
|
||||
if (repo is MavenArtifactRepository) {
|
||||
val urlString = repo.url.toString()
|
||||
check(allowedPrefixes.any { urlString.startsWith(it) }) {
|
||||
"Only EngineHub/Central repositories are allowed: ${repo.url} found"
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = "EngineHub (Non-Mirrored)"
|
||||
url = uri("https://repo.enginehub.org/libs-release/")
|
||||
}
|
||||
maven {
|
||||
name = "EngineHub Legacy Third-Party"
|
||||
url = uri("https://repo.enginehub.org/artifactory/libs-release/")
|
||||
content {
|
||||
includeGroup("org.khelekore")
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "Minecraft Libraries"
|
||||
url = uri("https://libraries.minecraft.net/")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import buildlogic.internalVersion
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
id("buildlogic.platform")
|
||||
}
|
||||
|
||||
@@ -26,17 +26,18 @@ dependencies {
|
||||
}
|
||||
|
||||
tasks.named<Copy>("processResources") {
|
||||
val internalVersion = project.ext["internalVersion"]
|
||||
val internalVersion = project.internalVersion
|
||||
inputs.property("internalVersion", internalVersion)
|
||||
filesMatching("plugin.yml") {
|
||||
expand("internalVersion" to internalVersion)
|
||||
expand("internalVersion" to internalVersion.get())
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
dependencies {
|
||||
include(dependency(":worldguard-core"))
|
||||
include(dependency("org.bstats:"))
|
||||
include(dependency("org.bstats:bstats-bukkit"))
|
||||
include(dependency("org.bstats:bstats-base"))
|
||||
include(dependency("io.papermc:paperlib"))
|
||||
|
||||
relocate("org.bstats", "com.sk89q.worldguard.bukkit.bstats")
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.util.PaperInterop;
|
||||
import com.sk89q.worldguard.util.MessagingUtil;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.BanList.Type;
|
||||
@@ -188,7 +189,7 @@ public class BukkitPlayer extends com.sk89q.worldedit.bukkit.BukkitPlayer implem
|
||||
|
||||
@Override
|
||||
public void teleport(Location location, String successMessage, String failMessage) {
|
||||
PaperLib.teleportAsync(getPlayer(), BukkitAdapter.adapt(location))
|
||||
PaperInterop.teleportAsync(getPlayer(), BukkitAdapter.adapt(location))
|
||||
.thenApply(success -> {
|
||||
if (success) {
|
||||
// The success message can be cleared via flag
|
||||
|
||||
+8
-1
@@ -40,6 +40,7 @@ import org.bukkit.event.world.WorldUnloadEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -62,6 +63,7 @@ public class BukkitRegionContainer extends RegionContainer {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
Bukkit.getPluginManager().registerEvents(new Listener() {
|
||||
@@ -95,7 +97,12 @@ public class BukkitRegionContainer extends RegionContainer {
|
||||
}, plugin);
|
||||
|
||||
if (WorldGuardPlugin.inst().isFolia()) {
|
||||
Bukkit.getGlobalRegionScheduler().runAtFixedRate(plugin, scheduledTask -> cache.invalidateAll(), CACHE_INVALIDATION_INTERVAL, CACHE_INVALIDATION_INTERVAL);
|
||||
Bukkit.getGlobalRegionScheduler().runAtFixedRate(plugin, new Consumer() {
|
||||
@Override
|
||||
public void accept(Object ignored) {
|
||||
cache.invalidateAll();
|
||||
}
|
||||
}, CACHE_INVALIDATION_INTERVAL, CACHE_INVALIDATION_INTERVAL);
|
||||
} else {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, cache::invalidateAll, CACHE_INVALIDATION_INTERVAL, CACHE_INVALIDATION_INTERVAL);
|
||||
}
|
||||
|
||||
+1
@@ -286,6 +286,7 @@ public class BukkitWorldConfiguration extends YamlWorldConfiguration {
|
||||
disableSoilMoistureChange = getBoolean("dynamics.disable-soil-moisture-change", false);
|
||||
disableCoralBlockFade = getBoolean("dynamics.disable-coral-block-fade", false);
|
||||
disableCopperBlockFade = getBoolean("dynamics.disable-copper-block-fade", false);
|
||||
disableLavaHarden = getBoolean("dynamics.disable-lava-harden", false);
|
||||
allowedSnowFallOver = new HashSet<>(convertLegacyBlocks(getStringList("dynamics.snow-fall-blocks", null)));
|
||||
|
||||
useRegions = getBoolean("regions.enable", true);
|
||||
|
||||
@@ -67,6 +67,7 @@ import com.sk89q.worldguard.bukkit.util.Events;
|
||||
import com.sk89q.worldguard.commands.GeneralCommands;
|
||||
import com.sk89q.worldguard.commands.ProtectionCommands;
|
||||
import com.sk89q.worldguard.commands.ToggleCommands;
|
||||
import com.sk89q.worldguard.domains.registry.SimpleDomainRegistry;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry;
|
||||
@@ -99,6 +100,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -141,6 +143,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
* Called on plugin enable.
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public void onEnable() {
|
||||
// Catch bad things being done by naughty plugins that include WorldGuard's classes
|
||||
ClassSourceValidator verifier = new ClassSourceValidator(this);
|
||||
@@ -169,7 +172,12 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
if (this.isFolia()) {
|
||||
getServer().getGlobalRegionScheduler().runAtFixedRate(this, scheduledTask -> sessionManager.run(), BukkitSessionManager.RUN_DELAY, BukkitSessionManager.RUN_DELAY);
|
||||
getServer().getGlobalRegionScheduler().runAtFixedRate(this, new Consumer() {
|
||||
@Override
|
||||
public void accept(Object ignored) {
|
||||
sessionManager.run();
|
||||
}
|
||||
}, BukkitSessionManager.RUN_DELAY, BukkitSessionManager.RUN_DELAY);
|
||||
} else {
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, sessionManager, BukkitSessionManager.RUN_DELAY, BukkitSessionManager.RUN_DELAY);
|
||||
}
|
||||
@@ -215,9 +223,12 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
|
||||
if (this.isFolia()) {
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
player.getScheduler().run(this, scheduledTask -> {
|
||||
ProcessPlayerEvent event = new ProcessPlayerEvent(player);
|
||||
Events.fire(event);
|
||||
player.getScheduler().run(this, new Consumer() {
|
||||
@Override
|
||||
public void accept(Object ignored) {
|
||||
ProcessPlayerEvent event = new ProcessPlayerEvent(player);
|
||||
Events.fire(event);
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
} else {
|
||||
@@ -230,6 +241,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
((SimpleFlagRegistry) WorldGuard.getInstance().getFlagRegistry()).setInitialized(true);
|
||||
((SimpleDomainRegistry) WorldGuard.getInstance().getDomainRegistry()).setInitialized(true);
|
||||
|
||||
// Enable metrics
|
||||
final Metrics metrics = new Metrics(this, BSTATS_PLUGIN_ID); // bStats plugin id
|
||||
@@ -546,6 +558,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
public PlayerMoveListener getPlayerMoveListener() {
|
||||
return playerMoveListener;
|
||||
}
|
||||
|
||||
private final LazyReference<Boolean> folia = LazyReference.from(() -> {
|
||||
try {
|
||||
// Folia is Paper-based, so this is a good first check.
|
||||
|
||||
+17
-10
@@ -44,6 +44,7 @@ import com.sk89q.worldguard.bukkit.util.Blocks;
|
||||
import com.sk89q.worldguard.bukkit.util.Entities;
|
||||
import com.sk89q.worldguard.bukkit.util.Events;
|
||||
import com.sk89q.worldguard.bukkit.util.Materials;
|
||||
import com.sk89q.worldguard.bukkit.util.PaperInterop;
|
||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import io.papermc.lib.PaperLib;
|
||||
@@ -163,6 +164,7 @@ import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class EventAbstractionListener extends AbstractListener {
|
||||
@@ -1014,15 +1016,16 @@ public class EventAbstractionListener extends AbstractListener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||
InventoryHolder holder = PaperLib.getHolder(event.getInventory(), false).getHolder();
|
||||
InventoryHolder holder = PaperInterop.getHolder(event.getInventory(), false);
|
||||
if (holder instanceof Entity && holder == event.getPlayer()) return;
|
||||
|
||||
handleInventoryHolderUse(event, create(event.getPlayer()), holder);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public void onInventoryMoveItem(InventoryMoveItemEvent event) {
|
||||
InventoryHolder causeHolder = PaperLib.getHolder(event.getInitiator(), false).getHolder();
|
||||
InventoryHolder causeHolder = PaperInterop.getHolder(event.getInitiator(), false);
|
||||
|
||||
WorldConfiguration wcfg = null;
|
||||
if (causeHolder instanceof Hopper
|
||||
@@ -1036,8 +1039,8 @@ public class EventAbstractionListener extends AbstractListener {
|
||||
Entry entry;
|
||||
|
||||
if ((entry = moveItemDebounce.tryDebounce(event)) != null) {
|
||||
InventoryHolder sourceHolder = PaperLib.getHolder(event.getSource(), false).getHolder();
|
||||
InventoryHolder targetHolder = PaperLib.getHolder(event.getDestination(), false).getHolder();
|
||||
InventoryHolder sourceHolder = PaperInterop.getHolder(event.getSource(), false);
|
||||
InventoryHolder targetHolder = PaperInterop.getHolder(event.getDestination(), false);
|
||||
|
||||
Cause cause;
|
||||
|
||||
@@ -1057,14 +1060,18 @@ public class EventAbstractionListener extends AbstractListener {
|
||||
handleInventoryHolderUse(event, cause, targetHolder);
|
||||
}
|
||||
|
||||
if (event.isCancelled() && causeHolder instanceof Hopper && wcfg.breakDeniedHoppers) {
|
||||
Hopper hopper = (Hopper) causeHolder;
|
||||
if (event.isCancelled() && causeHolder instanceof Hopper hopper && wcfg.breakDeniedHoppers) {
|
||||
Runnable task = () -> hopper.getBlock().breakNaturally();
|
||||
|
||||
if (WorldGuardPlugin.inst().isFolia()) {
|
||||
Bukkit.getRegionScheduler().run(getPlugin(), hopper.getLocation(),
|
||||
(scheduledTask) -> hopper.getBlock().breakNaturally());
|
||||
Bukkit.getRegionScheduler().run(getPlugin(), hopper.getLocation(), new Consumer() {
|
||||
@Override
|
||||
public void accept(Object ignored) {
|
||||
task.run();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(),
|
||||
() -> hopper.getBlock().breakNaturally());
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), task);
|
||||
}
|
||||
} else {
|
||||
entry.setCancelled(event.isCancelled());
|
||||
|
||||
+26
-29
@@ -58,28 +58,27 @@ public class InvincibilityListener extends AbstractListener {
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
Entity victim = event.getEntity();
|
||||
if (Entities.isNPC(victim)) return;
|
||||
if (!(victim instanceof Player player)) return;
|
||||
if (Entities.isNPC(player)) return;
|
||||
|
||||
if (victim instanceof Player player) {
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
|
||||
if (isInvincible(localPlayer)) {
|
||||
player.setFireTicks(0);
|
||||
event.setCancelled(true);
|
||||
if (isInvincible(localPlayer)) {
|
||||
player.setFireTicks(0);
|
||||
event.setCancelled(true);
|
||||
|
||||
if (event instanceof EntityDamageByEntityEvent) {
|
||||
EntityDamageByEntityEvent byEntityEvent = (EntityDamageByEntityEvent) event;
|
||||
Entity attacker = byEntityEvent.getDamager();
|
||||
if (event instanceof EntityDamageByEntityEvent) {
|
||||
EntityDamageByEntityEvent byEntityEvent = (EntityDamageByEntityEvent) event;
|
||||
Entity attacker = byEntityEvent.getDamager();
|
||||
|
||||
if (attacker instanceof Projectile && ((Projectile) attacker).getShooter() instanceof Entity) {
|
||||
attacker = (Entity) ((Projectile) attacker).getShooter();
|
||||
}
|
||||
if (attacker instanceof Projectile && ((Projectile) attacker).getShooter() instanceof Entity) {
|
||||
attacker = (Entity) ((Projectile) attacker).getShooter();
|
||||
}
|
||||
|
||||
if (getWorldConfig(player.getWorld()).regionInvinciblityRemovesMobs
|
||||
&& attacker instanceof LivingEntity && !(attacker instanceof Player)
|
||||
&& !(attacker instanceof Tameable && ((Tameable) attacker).isTamed())) {
|
||||
attacker.remove();
|
||||
}
|
||||
if (getWorldConfig(player.getWorld()).regionInvinciblityRemovesMobs
|
||||
&& attacker instanceof LivingEntity && !(attacker instanceof Player)
|
||||
&& !(attacker instanceof Tameable && ((Tameable) attacker).isTamed())) {
|
||||
attacker.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,27 +87,25 @@ public class InvincibilityListener extends AbstractListener {
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEntityCombust(EntityCombustEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
if (Entities.isNPC(entity)) return;
|
||||
if (!(entity instanceof Player player)) return;
|
||||
if (Entities.isNPC(player)) return;
|
||||
|
||||
if (entity instanceof Player player) {
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
|
||||
if (isInvincible(localPlayer)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (isInvincible(localPlayer)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
if (Entities.isNPC(event.getEntity())) return;
|
||||
if (!(event.getEntity() instanceof Player player)) return;
|
||||
if (Entities.isNPC(player)) return;
|
||||
|
||||
if (event.getEntity() instanceof Player player) {
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
|
||||
if (event.getFoodLevel() < player.getFoodLevel() && isInvincible(localPlayer)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (event.getFoodLevel() < player.getFoodLevel() && isInvincible(localPlayer)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+32
-18
@@ -23,6 +23,7 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.util.PaperInterop;
|
||||
import com.sk89q.worldguard.session.MoveType;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import io.papermc.lib.PaperLib;
|
||||
@@ -42,6 +43,8 @@ import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class PlayerMoveListener extends AbstractListener {
|
||||
|
||||
public PlayerMoveListener(WorldGuardPlugin plugin) {
|
||||
@@ -77,6 +80,7 @@ public class PlayerMoveListener extends AbstractListener {
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
Location from = event.getFrom();
|
||||
Location to = event.getTo();
|
||||
@@ -120,35 +124,29 @@ public class PlayerMoveListener extends AbstractListener {
|
||||
vehicle.setVelocity(new Vector());
|
||||
if (vehicle instanceof LivingEntity) {
|
||||
Location vehicleTeleportLocation = override.clone();
|
||||
if (getPlugin().isFolia()) {
|
||||
PaperLib.teleportAsync(vehicle, vehicleTeleportLocation);
|
||||
} else {
|
||||
vehicle.teleport(vehicleTeleportLocation);
|
||||
}
|
||||
teleport(vehicle, vehicleTeleportLocation);
|
||||
} else {
|
||||
Location dismountLocation = override.clone().add(0, 1, 0);
|
||||
if (getPlugin().isFolia()) {
|
||||
PaperLib.teleportAsync(vehicle, dismountLocation);
|
||||
} else {
|
||||
vehicle.teleport(dismountLocation);
|
||||
}
|
||||
teleport(vehicle, dismountLocation);
|
||||
}
|
||||
current = current.getVehicle();
|
||||
}
|
||||
|
||||
Location playerDismountLocation = override.clone().add(0, 1, 0);
|
||||
if (getPlugin().isFolia()) {
|
||||
PaperLib.teleportAsync(player, playerDismountLocation);
|
||||
} else {
|
||||
player.teleport(playerDismountLocation);
|
||||
}
|
||||
teleport(player, playerDismountLocation);
|
||||
|
||||
|
||||
Location delayedDismountLocation = override.clone().add(0, 1, 0);
|
||||
Runnable task = () -> teleport(player, delayedDismountLocation);
|
||||
if (getPlugin().isFolia()) {
|
||||
player.getScheduler().runDelayed(getPlugin(), scheduledTask -> PaperLib.teleportAsync(player, delayedDismountLocation), null, 1);
|
||||
player.getScheduler().runDelayed(getPlugin(), new Consumer() {
|
||||
@Override
|
||||
public void accept(Object ignored) {
|
||||
task.run();
|
||||
}
|
||||
}, null, 1);
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskLater(getPlugin(), () -> player.teleport(delayedDismountLocation), 1);
|
||||
Bukkit.getScheduler().runTaskLater(getPlugin(), task, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -164,7 +162,7 @@ public class PlayerMoveListener extends AbstractListener {
|
||||
BukkitAdapter.adapt(event.getPlayer().getLocation()), MoveType.OTHER_CANCELLABLE); // white lie
|
||||
if (loc != null) {
|
||||
if (getPlugin().isFolia()) {
|
||||
PaperLib.teleportAsync(player, BukkitAdapter.adapt(loc));
|
||||
PaperInterop.teleportAsync(player, BukkitAdapter.adapt(loc));
|
||||
} else {
|
||||
player.teleport(BukkitAdapter.adapt(loc));
|
||||
}
|
||||
@@ -173,6 +171,22 @@ public class PlayerMoveListener extends AbstractListener {
|
||||
session.uninitialize(localPlayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Small utility method to teleport via async or sync methods depending on platform.
|
||||
*
|
||||
* <p>Ideally we can make this use PaperLib in the future once it's better tested.</p>
|
||||
*
|
||||
* @param entity The entity to teleport
|
||||
* @param location The location to teleport to
|
||||
*/
|
||||
private void teleport(Entity entity, Location location) {
|
||||
if (getPlugin().isFolia()) {
|
||||
PaperInterop.teleportAsync(entity, location);
|
||||
} else {
|
||||
entity.teleport(location);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityMount(EntityMountEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
+1
-1
@@ -119,8 +119,8 @@ public class RegionFlagsListener extends AbstractListener {
|
||||
World world = entity.getWorld();
|
||||
if (!isRegionSupportEnabled(world)) return; // Region support disabled
|
||||
|
||||
if (Entities.isNPC(entity)) return;
|
||||
if (!(entity instanceof Player player)) return;
|
||||
if (Entities.isNPC(player)) return;
|
||||
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
|
||||
|
||||
+1
-1
@@ -410,7 +410,7 @@ public class RegionProtectionListener extends AbstractListener {
|
||||
final Entity entity = event.getEntity();
|
||||
final EntityType type = entity.getType();
|
||||
if (Entities.isHostile(entity) || Entities.isAmbient(entity)
|
||||
|| Entities.isNPC(entity) || entity instanceof Player) {
|
||||
|| entity instanceof Player || Entities.isNPC(entity)) {
|
||||
canUse = event.getRelevantFlags().isEmpty() || query.queryState(BukkitAdapter.adapt(target), associable, combine(event)) != State.DENY;
|
||||
what = "use that";
|
||||
/* Paintings, item frames, etc. */
|
||||
|
||||
+18
-4
@@ -478,7 +478,8 @@ public class WorldGuardBlockListener extends AbstractListener {
|
||||
|
||||
WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
|
||||
|
||||
Material type = event.getNewState().getType();
|
||||
Material oldType = event.getBlock().getType();
|
||||
Material newType = event.getNewState().getType();
|
||||
|
||||
if (event instanceof EntityBlockFormEvent) {
|
||||
if (((EntityBlockFormEvent) event).getEntity() instanceof Snowman) {
|
||||
@@ -490,7 +491,7 @@ public class WorldGuardBlockListener extends AbstractListener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == Material.ICE) {
|
||||
if (newType == Material.ICE) {
|
||||
if (wcfg.disableIceFormation) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@@ -502,7 +503,7 @@ public class WorldGuardBlockListener extends AbstractListener {
|
||||
}
|
||||
}
|
||||
|
||||
if (type == Material.SNOW) {
|
||||
if (newType == Material.SNOW) {
|
||||
if (wcfg.disableSnowFormation) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@@ -522,7 +523,7 @@ public class WorldGuardBlockListener extends AbstractListener {
|
||||
}
|
||||
}
|
||||
|
||||
if (Materials.isUnwaxedCopper(event.getBlock().getType())) {
|
||||
if (Materials.isUnwaxedCopper(oldType)) {
|
||||
if (wcfg.disableCopperBlockFade) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@@ -533,6 +534,19 @@ public class WorldGuardBlockListener extends AbstractListener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (oldType == Material.LAVA && !Materials.isLiquid(newType)) {
|
||||
if (wcfg.disableLavaHarden) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.LAVA_HARDEN))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+35
-4
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.destroystokyo.paper.event.entity.EntityZapEvent;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
@@ -39,6 +40,7 @@ import com.sk89q.worldguard.protection.flags.StateFlag.State;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@@ -66,8 +68,10 @@ import org.bukkit.entity.Wither;
|
||||
import org.bukkit.entity.WitherSkull;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.event.entity.CreeperPowerEvent;
|
||||
@@ -90,6 +94,7 @@ import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||
import org.bukkit.event.world.PortalCreateEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
import java.util.Set;
|
||||
@@ -108,6 +113,18 @@ public class WorldGuardEntityListener extends AbstractListener {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerEvents() {
|
||||
super.registerEvents();
|
||||
|
||||
PluginManager pm = getPlugin().getServer().getPluginManager();
|
||||
if (PaperLib.isPaper()) {
|
||||
pm.registerEvents(new PaperListener(), getPlugin());
|
||||
} else {
|
||||
pm.registerEvents(new SpigotListener(), getPlugin());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onEntityInteract(EntityInteractEvent event) {
|
||||
Block block = event.getBlock();
|
||||
@@ -741,9 +758,7 @@ public class WorldGuardEntityListener extends AbstractListener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPigZap(PigZapEvent event) {
|
||||
final Entity entity = event.getEntity();
|
||||
private static void handlePigZap(Entity entity, Cancellable event) {
|
||||
WorldConfiguration wcfg = getWorldConfig(entity.getWorld());
|
||||
|
||||
if (wcfg.disablePigZap) {
|
||||
@@ -789,8 +804,8 @@ public class WorldGuardEntityListener extends AbstractListener {
|
||||
public void onFoodChange(FoodLevelChangeEvent event) {
|
||||
if (event.getItem() != null) return;
|
||||
HumanEntity ent = event.getEntity();
|
||||
if (Entities.isNPC(ent)) return;
|
||||
if (!(ent instanceof Player bukkitPlayer)) return;
|
||||
if (Entities.isNPC(bukkitPlayer)) return;
|
||||
if (event.getFoodLevel() > ent.getFoodLevel()) return;
|
||||
|
||||
LocalPlayer player = WorldGuardPlugin.inst().wrapPlayer(bukkitPlayer);
|
||||
@@ -883,4 +898,20 @@ public class WorldGuardEntityListener extends AbstractListener {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class PaperListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onEntityZap(EntityZapEvent event) {
|
||||
if (event.getEntityType() == EntityType.PIG) {
|
||||
handlePigZap(event.getEntity(), event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class SpigotListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPigZap(PigZapEvent event) {
|
||||
handlePigZap(event.getEntity(), event);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -25,10 +25,10 @@ import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.util.Entities;
|
||||
import com.sk89q.worldguard.bukkit.util.PaperInterop;
|
||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
import com.sk89q.worldguard.session.MoveType;
|
||||
import com.sk89q.worldguard.util.Locations;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
@@ -69,7 +69,7 @@ public class WorldGuardVehicleListener extends AbstractListener {
|
||||
.testMoveTo(localPlayer, BukkitAdapter.adapt(to), MoveType.RIDE)) != null) {
|
||||
vehicle.setVelocity(new Vector(0, 0, 0));
|
||||
if (getPlugin().isFolia()) {
|
||||
PaperLib.teleportAsync(vehicle, from);
|
||||
PaperInterop.teleportAsync(vehicle, from);
|
||||
} else {
|
||||
vehicle.teleport(from);
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class WorldGuardVehicleListener extends AbstractListener {
|
||||
Vector dir = player.getLocation().getDirection();
|
||||
org.bukkit.Location playerTeleportLocation = BukkitAdapter.adapt(lastValid).setDirection(dir);
|
||||
if (getPlugin().isFolia()) {
|
||||
PaperLib.teleportAsync(player, playerTeleportLocation);
|
||||
PaperInterop.teleportAsync(player, playerTeleportLocation);
|
||||
} else {
|
||||
player.teleport(playerTeleportLocation);
|
||||
}
|
||||
|
||||
+4
-3
@@ -20,6 +20,7 @@
|
||||
package com.sk89q.worldguard.bukkit.listener.debounce.legacy;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.listener.debounce.legacy.InventoryMoveItemEventDebounce.Key;
|
||||
import com.sk89q.worldguard.bukkit.util.PaperInterop;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -45,9 +46,9 @@ public class InventoryMoveItemEventDebounce extends AbstractEventDebounce<Key> {
|
||||
private final Object target;
|
||||
|
||||
public Key(InventoryMoveItemEvent event) {
|
||||
cause = transform(PaperLib.getHolder(event.getInitiator(), false).getHolder());
|
||||
source = transform(PaperLib.getHolder(event.getSource(), false).getHolder());
|
||||
target = transform(PaperLib.getHolder(event.getDestination(), false).getHolder());
|
||||
cause = transform(PaperInterop.getHolder(event.getInitiator(), false));
|
||||
source = transform(PaperInterop.getHolder(event.getSource(), false));
|
||||
target = transform(PaperInterop.getHolder(event.getDestination(), false));
|
||||
}
|
||||
|
||||
private Object transform(InventoryHolder holder) {
|
||||
|
||||
+28
-19
@@ -33,7 +33,8 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
/**
|
||||
* Keeps tracks of sessions and also does session-related handling
|
||||
@@ -46,23 +47,25 @@ public class BukkitSessionManager extends AbstractSessionManager implements Runn
|
||||
* information for all players.
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public void resetAllStates() {
|
||||
Collection<? extends Player> players = Bukkit.getServer().getOnlinePlayers();
|
||||
for (Player player : players) {
|
||||
if (WorldGuardPlugin.inst().isFolia()) {
|
||||
player.getScheduler().run(WorldGuardPlugin.inst(), scheduledTask -> {
|
||||
BukkitPlayer bukkitPlayer = new BukkitPlayer(WorldGuardPlugin.inst(), player);
|
||||
Session session = getIfPresent(bukkitPlayer);
|
||||
if (session != null) {
|
||||
session.resetState(bukkitPlayer);
|
||||
}
|
||||
}, null);
|
||||
} else {
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
Runnable task = () -> {
|
||||
BukkitPlayer bukkitPlayer = new BukkitPlayer(WorldGuardPlugin.inst(), player);
|
||||
Session session = getIfPresent(bukkitPlayer);
|
||||
if (session != null) {
|
||||
session.resetState(bukkitPlayer);
|
||||
}
|
||||
};
|
||||
if (WorldGuardPlugin.inst().isFolia()) {
|
||||
player.getScheduler().run(WorldGuardPlugin.inst(), new Consumer() {
|
||||
@Override
|
||||
public void accept(Object ignored) {
|
||||
task.run();
|
||||
}
|
||||
}, null);
|
||||
} else {
|
||||
task.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,16 +78,22 @@ public class BukkitSessionManager extends AbstractSessionManager implements Runn
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public void run() {
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (WorldGuardPlugin.inst().isFolia()) {
|
||||
player.getScheduler().run(WorldGuardPlugin.inst(), (scheduledTask) -> {
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
get(localPlayer).tick(localPlayer);
|
||||
}, null);
|
||||
} else {
|
||||
Runnable task = () -> {
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
get(localPlayer).tick(localPlayer);
|
||||
};
|
||||
if (WorldGuardPlugin.inst().isFolia()) {
|
||||
player.getScheduler().run(WorldGuardPlugin.inst(), new Consumer() {
|
||||
@Override
|
||||
public void accept(Object ignored) {
|
||||
task.run();
|
||||
}
|
||||
}, null);
|
||||
} else {
|
||||
task.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,7 +105,7 @@ public class BukkitSessionManager extends AbstractSessionManager implements Runn
|
||||
&& WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(world).fakePlayerBuildOverride) {
|
||||
return true;
|
||||
}
|
||||
if (!((BukkitPlayer) player).getPlayer().isOnline()) {
|
||||
if (!bukkitPlayer.getPlayer().isOnline()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.util;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
@@ -46,15 +45,13 @@ public final class Blocks {
|
||||
* @return a list of connected blocks, not including the given block
|
||||
*/
|
||||
public static List<Block> getConnected(Block block) {
|
||||
BlockState state = PaperLib.getBlockState(block, false).getState();
|
||||
BlockState state = PaperInterop.getBlockState(block, false);
|
||||
BlockData data = state.getBlockData();
|
||||
|
||||
if (data instanceof Bed) {
|
||||
Bed bed = (Bed) data;
|
||||
if (data instanceof Bed bed) {
|
||||
return Collections.singletonList(block.getRelative(bed.getPart() == Bed.Part.FOOT
|
||||
? bed.getFacing() : bed.getFacing().getOppositeFace()));
|
||||
} else if (data instanceof Chest) {
|
||||
final Chest chest = (Chest) data;
|
||||
} else if (data instanceof Chest chest) {
|
||||
Chest.Type type = chest.getType();
|
||||
if (type == Chest.Type.SINGLE) {
|
||||
return Collections.emptyList();
|
||||
|
||||
@@ -30,20 +30,17 @@ import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.EnderCrystal;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Enemy;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.entity.Flying;
|
||||
import org.bukkit.entity.Hanging;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.NPC;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Shulker;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.SpectralArrow;
|
||||
import org.bukkit.entity.Steerable;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
@@ -173,11 +170,7 @@ public final class Entities {
|
||||
* @return true if hostile
|
||||
*/
|
||||
public static boolean isHostile(Entity entity) {
|
||||
return entity instanceof Monster
|
||||
|| entity instanceof Slime
|
||||
|| entity instanceof Flying
|
||||
|| entity instanceof EnderDragon
|
||||
|| entity instanceof Shulker;
|
||||
return entity instanceof Enemy;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -258,55 +258,9 @@ public final class Materials {
|
||||
MATERIAL_FLAGS.put(Material.BARRIER, 0);
|
||||
MATERIAL_FLAGS.put(Material.STRUCTURE_VOID, 0);
|
||||
// 1.12
|
||||
MATERIAL_FLAGS.put(Material.BLACK_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.BLUE_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.BROWN_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.CYAN_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.GRAY_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.GREEN_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.LIGHT_BLUE_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.YELLOW_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.LIGHT_GRAY_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.LIME_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.MAGENTA_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.ORANGE_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.PINK_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.PURPLE_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.RED_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.WHITE_CONCRETE, 0);
|
||||
MATERIAL_FLAGS.put(Material.BLACK_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.BLUE_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.BROWN_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.CYAN_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.GRAY_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.GREEN_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.LIGHT_BLUE_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.YELLOW_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.LIGHT_GRAY_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.LIME_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.MAGENTA_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.ORANGE_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.PINK_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.PURPLE_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.RED_CONCRETE_POWDER, 0);
|
||||
MATERIAL_FLAGS.put(Material.WHITE_CONCRETE_POWDER, 0);
|
||||
|
||||
MATERIAL_FLAGS.put(Material.WHITE_GLAZED_TERRACOTTA, 0);
|
||||
MATERIAL_FLAGS.put(Material.ORANGE_GLAZED_TERRACOTTA, 0);
|
||||
MATERIAL_FLAGS.put(Material.MAGENTA_GLAZED_TERRACOTTA, 0);
|
||||
MATERIAL_FLAGS.put(Material.LIGHT_BLUE_GLAZED_TERRACOTTA, 0);
|
||||
MATERIAL_FLAGS.put(Material.YELLOW_GLAZED_TERRACOTTA, 0);
|
||||
MATERIAL_FLAGS.put(Material.LIME_GLAZED_TERRACOTTA, 0);
|
||||
MATERIAL_FLAGS.put(Material.PINK_GLAZED_TERRACOTTA, 0);
|
||||
MATERIAL_FLAGS.put(Material.GRAY_GLAZED_TERRACOTTA, 0);
|
||||
MATERIAL_FLAGS.put(Material.LIGHT_GRAY_GLAZED_TERRACOTTA, 0);
|
||||
MATERIAL_FLAGS.put(Material.CYAN_GLAZED_TERRACOTTA, 0);
|
||||
MATERIAL_FLAGS.put(Material.PURPLE_GLAZED_TERRACOTTA, 0);
|
||||
MATERIAL_FLAGS.put(Material.BLUE_GLAZED_TERRACOTTA, 0);
|
||||
MATERIAL_FLAGS.put(Material.BROWN_GLAZED_TERRACOTTA, 0);
|
||||
MATERIAL_FLAGS.put(Material.GREEN_GLAZED_TERRACOTTA, 0);
|
||||
MATERIAL_FLAGS.put(Material.RED_GLAZED_TERRACOTTA, 0);
|
||||
MATERIAL_FLAGS.put(Material.BLACK_GLAZED_TERRACOTTA, 0);
|
||||
putMaterialTag(Tag.CONCRETE, 0);
|
||||
putMaterialTag(Tag.CONCRETE_POWDERS, 0);
|
||||
putMaterialTag(Tag.GLAZED_TERRACOTTA, 0);
|
||||
|
||||
// 1.13
|
||||
MATERIAL_FLAGS.put(Material.ANDESITE, 0);
|
||||
@@ -726,7 +680,6 @@ public final class Materials {
|
||||
MATERIAL_FLAGS.put(Material.POLISHED_DEEPSLATE, 0);
|
||||
MATERIAL_FLAGS.put(Material.CALCITE, 0);
|
||||
MATERIAL_FLAGS.put(Material.TUFF, 0);
|
||||
MATERIAL_FLAGS.put(Material.DRIPSTONE_BLOCK, 0);
|
||||
MATERIAL_FLAGS.put(Material.ROOTED_DIRT, 0);
|
||||
|
||||
MATERIAL_FLAGS.put(Material.RAW_IRON_BLOCK, 0);
|
||||
@@ -980,6 +933,21 @@ public final class Materials {
|
||||
MATERIAL_FLAGS.put(Material.NETHERITE_HORSE_ARMOR, 0);
|
||||
putMaterialTag(Tag.ITEMS_SPEARS, 0);
|
||||
|
||||
// 26.1
|
||||
MATERIAL_FLAGS.put(Material.GOLDEN_DANDELION, 0);
|
||||
|
||||
// 26.2
|
||||
MATERIAL_FLAGS.put(Material.CINNABAR, 0);
|
||||
MATERIAL_FLAGS.put(Material.POLISHED_CINNABAR, 0);
|
||||
MATERIAL_FLAGS.put(Material.CINNABAR_BRICKS, 0);
|
||||
MATERIAL_FLAGS.put(Material.CHISELED_CINNABAR, 0);
|
||||
MATERIAL_FLAGS.put(Material.POTENT_SULFUR, 0);
|
||||
MATERIAL_FLAGS.put(Material.SULFUR, 0);
|
||||
MATERIAL_FLAGS.put(Material.POLISHED_SULFUR, 0);
|
||||
MATERIAL_FLAGS.put(Material.SULFUR_BRICKS, 0);
|
||||
MATERIAL_FLAGS.put(Material.CHISELED_SULFUR, 0);
|
||||
putMaterialTag(Tag.SPELEOTHEMS, 0);
|
||||
|
||||
Stream.concat(Stream.concat(
|
||||
Tag.CORAL_BLOCKS.getValues().stream(),
|
||||
Tag.CORALS.getValues().stream()),
|
||||
@@ -1314,6 +1282,7 @@ public final class Materials {
|
||||
case SQUID_SPAWN_EGG -> EntityType.SQUID;
|
||||
case STRAY_SPAWN_EGG -> EntityType.STRAY;
|
||||
case STRIDER_SPAWN_EGG -> EntityType.STRIDER;
|
||||
case SULFUR_CUBE_SPAWN_EGG -> EntityType.SULFUR_CUBE;
|
||||
case TADPOLE_SPAWN_EGG -> EntityType.TADPOLE;
|
||||
case TRADER_LLAMA_SPAWN_EGG -> EntityType.TRADER_LLAMA;
|
||||
case TROPICAL_FISH_SPAWN_EGG -> EntityType.TROPICAL_FISH;
|
||||
@@ -1362,7 +1331,7 @@ public final class Materials {
|
||||
// yea, that's not all, there are some more
|
||||
return switch (type) {
|
||||
case PUMPKIN, MELON, CACTUS, SUGAR_CANE, BAMBOO, BAMBOO_SAPLING,
|
||||
SWEET_BERRY_BUSH, NETHER_WART, CAVE_VINES, CAVE_VINES_PLANT ->
|
||||
SWEET_BERRY_BUSH, NETHER_WART, CAVE_VINES, CAVE_VINES_PLANT, COCOA ->
|
||||
true;
|
||||
default -> false;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.util;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* This class is mainly here to replace PaperLib, as it no longer fully functions on MC 26.1+.
|
||||
*/
|
||||
public class PaperInterop {
|
||||
private PaperInterop() {
|
||||
}
|
||||
|
||||
public static @Nullable InventoryHolder getHolder(@Nonnull Inventory inventory, boolean useSnapshot) {
|
||||
if (PaperLib.isPaper()) {
|
||||
return inventory.getHolder(useSnapshot);
|
||||
}
|
||||
|
||||
return inventory.getHolder();
|
||||
}
|
||||
|
||||
public static BlockState getBlockState(@Nonnull Block block, boolean useSnapshot) {
|
||||
if (PaperLib.isPaper()) {
|
||||
return block.getState(useSnapshot);
|
||||
}
|
||||
|
||||
return block.getState();
|
||||
}
|
||||
|
||||
public static CompletableFuture<Boolean> teleportAsync(@Nonnull Entity entity, @Nonnull Location location) {
|
||||
if (PaperLib.isPaper()) {
|
||||
return entity.teleportAsync(location);
|
||||
}
|
||||
|
||||
return CompletableFuture.completedFuture(entity.teleport(location));
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,5 @@ name: WorldGuard
|
||||
main: com.sk89q.worldguard.bukkit.WorldGuardPlugin
|
||||
version: "${internalVersion}"
|
||||
depend: [WorldEdit]
|
||||
api-version: "1.21.11"
|
||||
folia-supported: true
|
||||
api-version: "26.2"
|
||||
folia-supported: true
|
||||
@@ -1,7 +1,4 @@
|
||||
import org.cadixdev.gradle.licenser.LicenseExtension
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
id("buildlogic.core-and-platform")
|
||||
}
|
||||
|
||||
@@ -37,12 +34,6 @@ tasks.compileJava {
|
||||
options.compilerArgs.add("-Aarg.name.key.prefix=")
|
||||
}
|
||||
|
||||
configure<LicenseExtension> {
|
||||
exclude {
|
||||
it.file.startsWith(project.layout.buildDirectory.get().asFile)
|
||||
}
|
||||
}
|
||||
|
||||
configure<PublishingExtension> {
|
||||
publications.named<MavenPublication>("maven") {
|
||||
artifactId = the<BasePluginExtension>().archivesName.get()
|
||||
|
||||
@@ -24,6 +24,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.worldguard.domains.registry.DomainRegistry;
|
||||
import com.sk89q.worldguard.domains.registry.SimpleDomainRegistry;
|
||||
import com.sk89q.worldguard.util.profile.cache.HashMapCache;
|
||||
import com.sk89q.worldguard.util.profile.cache.ProfileCache;
|
||||
import com.sk89q.worldguard.util.profile.cache.SQLiteCache;
|
||||
@@ -55,6 +57,7 @@ public final class WorldGuard {
|
||||
|
||||
private WorldGuardPlatform platform;
|
||||
private final SimpleFlagRegistry flagRegistry = new SimpleFlagRegistry();
|
||||
private final SimpleDomainRegistry domainRegistry = new SimpleDomainRegistry();
|
||||
private final Supervisor supervisor = new SimpleSupervisor();
|
||||
private ProfileCache profileCache;
|
||||
private ProfileService profileService;
|
||||
@@ -116,6 +119,16 @@ public final class WorldGuard {
|
||||
return this.flagRegistry;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the domain registry.
|
||||
*
|
||||
* @return the domain registry
|
||||
*/
|
||||
public DomainRegistry getDomainRegistry() {
|
||||
return this.domainRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the supervisor.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.commands;
|
||||
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class CommandInputContext<T extends Exception> {
|
||||
protected final Actor sender;
|
||||
protected final String input;
|
||||
|
||||
protected Map<String, Object> context;
|
||||
|
||||
protected CommandInputContext(Actor sender, String input, Map<String, Object> values) {
|
||||
this.sender = sender;
|
||||
this.input = input;
|
||||
this.context = values;
|
||||
}
|
||||
|
||||
public void put(String name, Object value) {
|
||||
context.put(name, value);
|
||||
}
|
||||
|
||||
public Actor getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public String getUserInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the CommandSender as a player.
|
||||
*
|
||||
* @return Player
|
||||
* @throws T if the sender is not a player
|
||||
*/
|
||||
public LocalPlayer getPlayerSender() throws T {
|
||||
if (sender.isPlayer() && sender instanceof LocalPlayer) {
|
||||
return (LocalPlayer) sender;
|
||||
} else {
|
||||
throw createException("Not a player");
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getUserInputAsInt() throws T {
|
||||
try {
|
||||
return Integer.parseInt(input);
|
||||
} catch (NumberFormatException e) {
|
||||
throw createException("Not a number: " + input);
|
||||
}
|
||||
}
|
||||
|
||||
public Double getUserInputAsDouble() throws T {
|
||||
try {
|
||||
return Double.parseDouble(input);
|
||||
} catch (NumberFormatException e) {
|
||||
throw createException("Not a number: " + input);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract T createException(String str);
|
||||
|
||||
/**
|
||||
* Get an object from the context by key name.
|
||||
* May return null if the object does not exist in the context.
|
||||
*
|
||||
* @param name key name of the object
|
||||
* @return the object matching the key, or null
|
||||
*/
|
||||
@Nullable
|
||||
public Object get(String name) {
|
||||
return get(name, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an object from the context by key name.
|
||||
* Will only return null if
|
||||
* a) you provide null as the default
|
||||
* b) the key has explicity been set to null
|
||||
*
|
||||
* @param name key name of the object
|
||||
* @return the object matching the key
|
||||
*/
|
||||
@Nullable
|
||||
public Object get(String name, Object defaultValue) {
|
||||
Object obj;
|
||||
return (((obj = context.get(name)) != null) || context.containsKey(name)
|
||||
? obj : defaultValue);
|
||||
}
|
||||
}
|
||||
+20
-2
@@ -25,16 +25,27 @@ import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissionsException;
|
||||
import com.sk89q.worldedit.command.util.AsyncCommandBuilder;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||
import com.sk89q.worldedit.util.formatting.component.ErrorFormat;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.domains.registry.DomainFactory;
|
||||
import com.sk89q.worldguard.domains.registry.DomainRegistry;
|
||||
import com.sk89q.worldguard.internal.permission.RegionPermissionModel;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.util.DomainInputResolver;
|
||||
import com.sk89q.worldguard.protection.util.DomainInputResolver.UserLocatorPolicy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class MemberCommands extends RegionCommandsBase {
|
||||
@@ -67,6 +78,8 @@ public class MemberCommands extends RegionCommandsBase {
|
||||
DomainInputResolver resolver = new DomainInputResolver(
|
||||
WorldGuard.getInstance().getProfileService(), args.getParsedPaddedSlice(1, 0));
|
||||
resolver.setLocatorPolicy(args.hasFlag('n') ? UserLocatorPolicy.NAME_ONLY : UserLocatorPolicy.UUID_ONLY);
|
||||
resolver.setActor(sender);
|
||||
resolver.setRegion(region);
|
||||
|
||||
|
||||
final String description = String.format("Adding members to the region '%s' on '%s'", region.getId(), world.getName());
|
||||
@@ -101,7 +114,8 @@ public class MemberCommands extends RegionCommandsBase {
|
||||
DomainInputResolver resolver = new DomainInputResolver(
|
||||
WorldGuard.getInstance().getProfileService(), args.getParsedPaddedSlice(1, 0));
|
||||
resolver.setLocatorPolicy(args.hasFlag('n') ? UserLocatorPolicy.NAME_ONLY : UserLocatorPolicy.UUID_ONLY);
|
||||
|
||||
resolver.setActor(sender);
|
||||
resolver.setRegion(region);
|
||||
|
||||
final String description = String.format("Adding owners to the region '%s' on '%s'", region.getId(), world.getName());
|
||||
AsyncCommandBuilder.wrap(checkedAddOwners(sender, manager, region, world, resolver), sender)
|
||||
@@ -174,6 +188,8 @@ public class MemberCommands extends RegionCommandsBase {
|
||||
DomainInputResolver resolver = new DomainInputResolver(
|
||||
WorldGuard.getInstance().getProfileService(), args.getParsedPaddedSlice(1, 0));
|
||||
resolver.setLocatorPolicy(args.hasFlag('n') ? UserLocatorPolicy.NAME_ONLY : UserLocatorPolicy.UUID_AND_NAME);
|
||||
resolver.setActor(sender);
|
||||
resolver.setRegion(region);
|
||||
|
||||
callable = resolver;
|
||||
}
|
||||
@@ -217,6 +233,8 @@ public class MemberCommands extends RegionCommandsBase {
|
||||
DomainInputResolver resolver = new DomainInputResolver(
|
||||
WorldGuard.getInstance().getProfileService(), args.getParsedPaddedSlice(1, 0));
|
||||
resolver.setLocatorPolicy(args.hasFlag('n') ? UserLocatorPolicy.NAME_ONLY : UserLocatorPolicy.UUID_AND_NAME);
|
||||
resolver.setActor(sender);
|
||||
resolver.setRegion(region);
|
||||
|
||||
callable = resolver;
|
||||
}
|
||||
|
||||
+12
-11
@@ -59,7 +59,7 @@ import com.sk89q.worldguard.protection.FlagValueCalculator;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.FlagContext;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
|
||||
import com.sk89q.worldguard.protection.flags.InvalidFlagFormatException;
|
||||
import com.sk89q.worldguard.protection.flags.RegionGroup;
|
||||
import com.sk89q.worldguard.protection.flags.RegionGroupFlag;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
||||
@@ -76,7 +76,6 @@ import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion.CircularInheritanceException;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import com.sk89q.worldguard.protection.util.DomainInputResolver.UserLocatorPolicy;
|
||||
import com.sk89q.worldguard.protection.util.WorldEditRegionConverter;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import com.sk89q.worldguard.util.Enums;
|
||||
@@ -160,7 +159,7 @@ public final class RegionCommands extends RegionCommandsBase {
|
||||
region = checkRegionFromSelection(sender, id);
|
||||
}
|
||||
|
||||
RegionAdder task = new RegionAdder(manager, region);
|
||||
RegionAdder task = new RegionAdder(manager, region, sender);
|
||||
task.addOwnersFromCommand(args, 2);
|
||||
|
||||
final String description = String.format("Adding region '%s'", region.getId());
|
||||
@@ -214,7 +213,7 @@ public final class RegionCommands extends RegionCommandsBase {
|
||||
|
||||
region.copyFrom(existing);
|
||||
|
||||
RegionAdder task = new RegionAdder(manager, region);
|
||||
RegionAdder task = new RegionAdder(manager, region, sender);
|
||||
|
||||
final String description = String.format("Updating region '%s'", region.getId());
|
||||
AsyncCommandBuilder.wrap(task, sender)
|
||||
@@ -351,6 +350,7 @@ public final class RegionCommands extends RegionCommandsBase {
|
||||
World world = checkWorld(args, sender, 'w');
|
||||
RegionManager manager = checkRegionManager(world);
|
||||
ProtectedRegion existing;
|
||||
RegionPermissionModel permissionModel = getPermissionModel(sender);
|
||||
|
||||
// If no arguments were given, get the region that the player is inside
|
||||
if (args.argsLength() == 0) {
|
||||
@@ -359,13 +359,13 @@ public final class RegionCommands extends RegionCommandsBase {
|
||||
throw new CommandException("Please specify a region name."); // just don't allow that
|
||||
}
|
||||
world = player.getWorld();
|
||||
existing = checkRegionStandingIn(manager, player, "/rg select -w \"" + world.getName() + "\" %id%");
|
||||
existing = checkRegionStandingIn(manager, player, "/rg select -w \"" + world.getName() + "\" %id%", permissionModel::maySelect);
|
||||
} else {
|
||||
existing = checkExistingRegion(manager, args.getString(0), false);
|
||||
}
|
||||
|
||||
// Check permissions
|
||||
if (!getPermissionModel(sender).maySelect(existing)) {
|
||||
if (!permissionModel.maySelect(existing)) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ public final class RegionCommands extends RegionCommandsBase {
|
||||
}
|
||||
|
||||
existing = checkRegionStandingIn(manager, (LocalPlayer) sender, true,
|
||||
"/rg info -w \"" + world.getName() + "\" %id%" + (args.hasFlag('u') ? " -u" : "") + (args.hasFlag('s') ? " -s" : ""));
|
||||
"/rg info -w \"" + world.getName() + "\" %id%" + (args.hasFlag('u') ? " -u" : "") + (args.hasFlag('s') ? " -s" : ""), permModel::mayLookup);
|
||||
} else { // Get region from the ID
|
||||
existing = checkExistingRegion(manager, args.getString(0), true);
|
||||
}
|
||||
@@ -587,7 +587,7 @@ public final class RegionCommands extends RegionCommandsBase {
|
||||
// the [value] part throws an error.
|
||||
try {
|
||||
groupValue = groupFlag.parseInput(FlagContext.create().setSender(sender).setInput(group).setObject("region", existing).build());
|
||||
} catch (InvalidFlagFormat e) {
|
||||
} catch (InvalidFlagFormatException e) {
|
||||
throw new CommandException(e.getMessage());
|
||||
}
|
||||
|
||||
@@ -598,7 +598,7 @@ public final class RegionCommands extends RegionCommandsBase {
|
||||
// Set the flag if [value] was given even if [-g group] was given as well
|
||||
try {
|
||||
value = setFlag(existing, foundFlag, sender, value).toString();
|
||||
} catch (InvalidFlagFormat e) {
|
||||
} catch (InvalidFlagFormatException e) {
|
||||
throw new CommandException(e.getMessage());
|
||||
}
|
||||
|
||||
@@ -661,18 +661,19 @@ public final class RegionCommands extends RegionCommandsBase {
|
||||
// Lookup the existing region
|
||||
RegionManager manager = checkRegionManager(world);
|
||||
ProtectedRegion region;
|
||||
final RegionPermissionModel perms = getPermissionModel(sender);
|
||||
|
||||
if (args.argsLength() == 0) { // Get region from where the player is
|
||||
if (!(sender instanceof LocalPlayer)) {
|
||||
throw new CommandException("Please specify the region with /region flags -w world_name region_name.");
|
||||
}
|
||||
|
||||
region = checkRegionStandingIn(manager, (LocalPlayer) sender, true,
|
||||
"/rg flags -w \"" + world.getName() + "\" %id%");
|
||||
"/rg flags -w \"" + world.getName() + "\" %id%", perms::mayLookup);
|
||||
} else { // Get region from the ID
|
||||
region = checkExistingRegion(manager, args.getString(0), true);
|
||||
}
|
||||
|
||||
final RegionPermissionModel perms = getPermissionModel(sender);
|
||||
if (!perms.mayLookup(region)) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
+31
-19
@@ -32,15 +32,12 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector;
|
||||
import com.sk89q.worldedit.util.formatting.component.ErrorFormat;
|
||||
import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextDecoration;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
@@ -48,7 +45,7 @@ import com.sk89q.worldguard.internal.permission.RegionPermissionModel;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.FlagContext;
|
||||
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
|
||||
import com.sk89q.worldguard.protection.flags.InvalidFlagFormatException;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
@@ -59,6 +56,7 @@ import com.sk89q.worldguard.protection.regions.RegionQuery.QueryOption;
|
||||
import com.sk89q.worldguard.protection.util.WorldEditRegionConverter;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class RegionCommandsBase {
|
||||
@@ -178,11 +176,13 @@ class RegionCommandsBase {
|
||||
*
|
||||
* @param regionManager the region manager
|
||||
* @param player the player
|
||||
* @param rgCmd the command to construct when clicking one of multiple items
|
||||
* @param permissionPredicate a predicate to filter regions based on permission access
|
||||
* @return a region
|
||||
* @throws CommandException thrown if no region was found
|
||||
*/
|
||||
protected static ProtectedRegion checkRegionStandingIn(RegionManager regionManager, LocalPlayer player, String rgCmd) throws CommandException {
|
||||
return checkRegionStandingIn(regionManager, player, false, rgCmd);
|
||||
protected static ProtectedRegion checkRegionStandingIn(RegionManager regionManager, LocalPlayer player, String rgCmd, Predicate<ProtectedRegion> permissionPredicate) throws CommandException {
|
||||
return checkRegionStandingIn(regionManager, player, false, rgCmd, permissionPredicate);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,10 +197,12 @@ class RegionCommandsBase {
|
||||
* @param regionManager the region manager
|
||||
* @param player the player
|
||||
* @param allowGlobal whether to search for a global region if no others are found
|
||||
* @param rgCmd the command to construct when clicking one of multiple items
|
||||
* @param permissionPredicate a predicate to filter regions based on permission access
|
||||
* @return a region
|
||||
* @throws CommandException thrown if no region was found
|
||||
*/
|
||||
protected static ProtectedRegion checkRegionStandingIn(RegionManager regionManager, LocalPlayer player, boolean allowGlobal, String rgCmd) throws CommandException {
|
||||
protected static ProtectedRegion checkRegionStandingIn(RegionManager regionManager, LocalPlayer player, boolean allowGlobal, String rgCmd, Predicate<ProtectedRegion> permissionPredicate) throws CommandException {
|
||||
ApplicableRegionSet set = regionManager.getApplicableRegions(player.getLocation().toVector().toBlockPoint(), QueryOption.SORT);
|
||||
|
||||
if (set.size() == 0) {
|
||||
@@ -215,20 +217,30 @@ class RegionCommandsBase {
|
||||
"Specify an ID if you want to select a specific region.");
|
||||
} else if (set.size() > 1) {
|
||||
boolean first = true;
|
||||
Set<ProtectedRegion> filteredRegions = set.getRegions().stream().filter(permissionPredicate).collect(Collectors.toSet());
|
||||
int hiddenRegions = set.size() - filteredRegions.size();
|
||||
|
||||
final TextComponent.Builder builder = TextComponent.builder("");
|
||||
builder.append(TextComponent.of("Current regions: ", TextColor.GOLD));
|
||||
for (ProtectedRegion region : set) {
|
||||
if (!first) {
|
||||
builder.append(TextComponent.of(", "));
|
||||
if (!filteredRegions.isEmpty()) {
|
||||
builder.append(TextComponent.of("Current regions: ", TextColor.GOLD));
|
||||
for (ProtectedRegion region : filteredRegions) {
|
||||
if (!first) {
|
||||
builder.append(TextComponent.of(", "));
|
||||
}
|
||||
first = false;
|
||||
TextComponent regionComp = TextComponent.of(region.getId(), TextColor.AQUA);
|
||||
if (rgCmd != null && rgCmd.contains("%id%")) {
|
||||
regionComp = regionComp.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to pick this region")))
|
||||
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, rgCmd.replace("%id%", region.getId())));
|
||||
}
|
||||
builder.append(regionComp);
|
||||
}
|
||||
first = false;
|
||||
TextComponent regionComp = TextComponent.of(region.getId(), TextColor.AQUA);
|
||||
if (rgCmd != null && rgCmd.contains("%id%")) {
|
||||
regionComp = regionComp.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to pick this region")))
|
||||
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, rgCmd.replace("%id%", region.getId())));
|
||||
if (hiddenRegions > 0) {
|
||||
builder.append(TextComponent.of(", and " + hiddenRegions + " hidden regions", TextColor.GRAY));
|
||||
}
|
||||
builder.append(regionComp);
|
||||
} else {
|
||||
builder.append(TextComponent.of("Current regions: ", TextColor.GOLD));
|
||||
builder.append(TextComponent.of(hiddenRegions + " hidden regions", TextColor.GRAY));
|
||||
}
|
||||
player.print(builder.build());
|
||||
throw new CommandException("You're standing in several regions (please pick one).");
|
||||
@@ -418,9 +430,9 @@ class RegionCommandsBase {
|
||||
* @param flag the flag
|
||||
* @param sender the sender
|
||||
* @param value the value
|
||||
* @throws InvalidFlagFormat thrown if the value is invalid
|
||||
* @throws InvalidFlagFormatException thrown if the value is invalid
|
||||
*/
|
||||
protected static <V> V setFlag(ProtectedRegion region, Flag<V> flag, Actor sender, String value) throws InvalidFlagFormat {
|
||||
protected static <V> V setFlag(ProtectedRegion region, Flag<V> flag, Actor sender, String value) throws InvalidFlagFormatException {
|
||||
V val = flag.parseInput(FlagContext.create().setSender(sender).setInput(value).setObject("region", region).build());
|
||||
region.setFlag(flag, val);
|
||||
return val;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package com.sk89q.worldguard.commands.task;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
@@ -39,6 +40,7 @@ public class RegionAdder implements Callable<ProtectedRegion> {
|
||||
|
||||
private final RegionManager manager;
|
||||
private final ProtectedRegion region;
|
||||
private final Actor actor;
|
||||
@Nullable
|
||||
private String[] ownersInput;
|
||||
private UserLocatorPolicy locatorPolicy = UserLocatorPolicy.UUID_ONLY;
|
||||
@@ -46,15 +48,26 @@ public class RegionAdder implements Callable<ProtectedRegion> {
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param manager the manage
|
||||
* @param manager the manager
|
||||
* @param region the region
|
||||
*/
|
||||
public RegionAdder(RegionManager manager, ProtectedRegion region) {
|
||||
this(manager, region, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
* @param manager the manager
|
||||
* @param region the region
|
||||
* @param actor the actor
|
||||
*/
|
||||
public RegionAdder(RegionManager manager, ProtectedRegion region, Actor actor) {
|
||||
checkNotNull(manager);
|
||||
checkNotNull(region);
|
||||
|
||||
this.manager = manager;
|
||||
this.region = region;
|
||||
this.actor = actor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,6 +88,9 @@ public class RegionAdder implements Callable<ProtectedRegion> {
|
||||
if (ownersInput != null) {
|
||||
DomainInputResolver resolver = new DomainInputResolver(WorldGuard.getInstance().getProfileService(), ownersInput);
|
||||
resolver.setLocatorPolicy(locatorPolicy);
|
||||
resolver.setActor(actor);
|
||||
resolver.setRegion(region);
|
||||
|
||||
DefaultDomain domain = resolver.call();
|
||||
region.getOwners().addAll(domain);
|
||||
}
|
||||
|
||||
@@ -170,6 +170,7 @@ public abstract class WorldConfiguration {
|
||||
public boolean disableSoilMoistureChange;
|
||||
public boolean disableCoralBlockFade;
|
||||
public boolean disableCopperBlockFade;
|
||||
public boolean disableLavaHarden;
|
||||
public Set<String> allowedSnowFallOver;
|
||||
public boolean regionInvinciblityRemovesMobs;
|
||||
public boolean regionCancelEmptyChatEvents;
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.domains;
|
||||
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.domains.registry.CustomDomainContext;
|
||||
import com.sk89q.worldguard.domains.registry.InvalidDomainFormatException;
|
||||
import com.sk89q.worldguard.util.ChangeTracked;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public abstract class CustomDomain implements Domain, ChangeTracked {
|
||||
private static final Pattern VALID_NAME = Pattern.compile("^[a-z0-9\\-]{1,40}$");
|
||||
|
||||
private final String name;
|
||||
private boolean dirty;
|
||||
|
||||
public CustomDomain(String name) {
|
||||
if (name == null ||!isValidName(name)) {
|
||||
throw new IllegalArgumentException("Invalid Domain name used.");
|
||||
}
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the domain resolver.
|
||||
*
|
||||
* @return The name of the domain
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a given input to fill the context of the CustomDomain.
|
||||
*
|
||||
* @param context the {@link CustomDomainContext}
|
||||
* @throws InvalidDomainFormatException Raised if the input is invalid
|
||||
*/
|
||||
public abstract void parseInput(CustomDomainContext context) throws InvalidDomainFormatException;
|
||||
|
||||
/**
|
||||
* Convert a raw type that was loaded (from a YAML file, for example)
|
||||
* into the custom domain.
|
||||
*
|
||||
* @param o The object
|
||||
*/
|
||||
public abstract void unmarshal(Object o);
|
||||
|
||||
/**
|
||||
* Convert the current Domain to a storable foramt
|
||||
*
|
||||
* @return The marshalled type
|
||||
*/
|
||||
public abstract Object marshal();
|
||||
|
||||
/**
|
||||
* Test whether a flag name is valid.
|
||||
*
|
||||
* @param name The flag name
|
||||
* @return Whether the name is valid
|
||||
*/
|
||||
public static boolean isValidName(String name) {
|
||||
checkNotNull(name, "name");
|
||||
// g is already reserved by the group domain
|
||||
return VALID_NAME.matcher(name).matches() && !name.equalsIgnoreCase("g");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean contains(LocalPlayer player) {
|
||||
return contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirty() {
|
||||
return dirty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirty(boolean dirty) {
|
||||
this.dirty = dirty;
|
||||
}
|
||||
}
|
||||
@@ -22,8 +22,6 @@ package com.sk89q.worldguard.domains;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.sk89q.worldguard.util.profile.Profile;
|
||||
import com.sk89q.worldguard.util.profile.cache.ProfileCache;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
||||
@@ -31,14 +29,19 @@ import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.util.ChangeTracked;
|
||||
import com.sk89q.worldguard.util.profile.Profile;
|
||||
import com.sk89q.worldguard.util.profile.cache.ProfileCache;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@@ -50,6 +53,9 @@ public class DefaultDomain implements Domain, ChangeTracked {
|
||||
private PlayerDomain playerDomain = new PlayerDomain();
|
||||
private GroupDomain groupDomain = new GroupDomain();
|
||||
|
||||
private final Map<String, CustomDomain> customDomains = new ConcurrentHashMap<>();
|
||||
private boolean customDomainsChanged = false;
|
||||
|
||||
/**
|
||||
* Create a new domain.
|
||||
*/
|
||||
@@ -64,6 +70,7 @@ public class DefaultDomain implements Domain, ChangeTracked {
|
||||
public DefaultDomain(DefaultDomain existing) {
|
||||
setPlayerDomain(existing.getPlayerDomain());
|
||||
setGroupDomain(existing.getGroupDomain());
|
||||
setCustomDomains(existing.customDomains);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,6 +111,72 @@ public class DefaultDomain implements Domain, ChangeTracked {
|
||||
this.groupDomain = new GroupDomain(groupDomain);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new custom domains
|
||||
*
|
||||
* @param customDomain a domain
|
||||
*/
|
||||
public void addCustomDomain(CustomDomain customDomain) {
|
||||
checkNotNull(customDomain);
|
||||
this.customDomains.put(customDomain.getName(), customDomain);
|
||||
this.customDomainsChanged = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a custom domain matched by the name
|
||||
*
|
||||
* @param name the name
|
||||
*/
|
||||
public void removeCustomDomain(String name) {
|
||||
checkNotNull(name);
|
||||
if (this.customDomains.remove(name) != null) {
|
||||
this.customDomainsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a custom domain
|
||||
*
|
||||
* @param customDomain a domain
|
||||
*/
|
||||
public void removeCustomDomain(CustomDomain customDomain) {
|
||||
checkNotNull(customDomain);
|
||||
if (this.customDomains.remove(customDomain.getName()) != null) {
|
||||
this.customDomainsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the api domains to a specified value
|
||||
*
|
||||
* @param customDomains the domains
|
||||
*/
|
||||
public void setCustomDomains(Map<String, CustomDomain> customDomains) {
|
||||
checkNotNull(customDomains);
|
||||
this.customDomains.clear();
|
||||
this.customDomains.putAll(customDomains);
|
||||
this.customDomainsChanged = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all api domains
|
||||
*
|
||||
* @return a unmodifiable copy of the domains
|
||||
*/
|
||||
public Collection<CustomDomain> getCustomDomains() {
|
||||
return Collections.unmodifiableCollection(this.customDomains.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the api domain specified by its name
|
||||
*
|
||||
* @param name the name of the domain
|
||||
* @return the custom domain
|
||||
*/
|
||||
public @Nullable CustomDomain getCustomDomain(String name) {
|
||||
return this.customDomains.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given player to the domain, identified by the player's name.
|
||||
*
|
||||
@@ -175,6 +248,9 @@ public class DefaultDomain implements Domain, ChangeTracked {
|
||||
for (String group : other.getGroups()) {
|
||||
addGroup(group);
|
||||
}
|
||||
for (CustomDomain domain : other.getCustomDomains()) {
|
||||
addCustomDomain(domain);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,6 +269,9 @@ public class DefaultDomain implements Domain, ChangeTracked {
|
||||
for (String group : other.getGroups()) {
|
||||
removeGroup(group);
|
||||
}
|
||||
for (CustomDomain domain : other.getCustomDomains()) {
|
||||
removeCustomDomain(domain.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,12 +321,12 @@ public class DefaultDomain implements Domain, ChangeTracked {
|
||||
|
||||
@Override
|
||||
public boolean contains(LocalPlayer player) {
|
||||
return playerDomain.contains(player) || groupDomain.contains(player);
|
||||
return playerDomain.contains(player) || groupDomain.contains(player) || customDomains.values().stream().anyMatch(d -> d.contains(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(UUID uniqueId) {
|
||||
return playerDomain.contains(uniqueId);
|
||||
return playerDomain.contains(uniqueId) || customDomains.values().stream().anyMatch(d -> d.contains(uniqueId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -257,7 +336,7 @@ public class DefaultDomain implements Domain, ChangeTracked {
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return groupDomain.size() + playerDomain.size();
|
||||
return groupDomain.size() + playerDomain.size() + customDomains.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -275,7 +354,6 @@ public class DefaultDomain implements Domain, ChangeTracked {
|
||||
}
|
||||
|
||||
public String toPlayersString(@Nullable ProfileCache cache) {
|
||||
StringBuilder str = new StringBuilder();
|
||||
List<String> output = new ArrayList<>();
|
||||
|
||||
for (String name : playerDomain.getPlayers()) {
|
||||
@@ -299,13 +377,7 @@ public class DefaultDomain implements Domain, ChangeTracked {
|
||||
}
|
||||
|
||||
output.sort(String.CASE_INSENSITIVE_ORDER);
|
||||
for (Iterator<String> it = output.iterator(); it.hasNext();) {
|
||||
str.append(it.next());
|
||||
if (it.hasNext()) {
|
||||
str.append(", ");
|
||||
}
|
||||
}
|
||||
return str.toString();
|
||||
return String.join(", ", output);
|
||||
}
|
||||
|
||||
public String toGroupsString() {
|
||||
@@ -320,25 +392,20 @@ public class DefaultDomain implements Domain, ChangeTracked {
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
public String toUserFriendlyString() {
|
||||
StringBuilder str = new StringBuilder();
|
||||
|
||||
if (playerDomain.size() > 0) {
|
||||
str.append(toPlayersString());
|
||||
public String toCustomDomainsString() {
|
||||
List<String> output = new ArrayList<>();
|
||||
for (CustomDomain customDomain : customDomains.values()) {
|
||||
output.add(customDomain.getName() + ":" + customDomain.toString());
|
||||
}
|
||||
|
||||
if (groupDomain.size() > 0) {
|
||||
if (str.length() > 0) {
|
||||
str.append("; ");
|
||||
}
|
||||
|
||||
str.append(toGroupsString());
|
||||
}
|
||||
|
||||
return str.toString();
|
||||
output.sort(String.CASE_INSENSITIVE_ORDER);
|
||||
return String.join(", ", output);
|
||||
}
|
||||
|
||||
public String toUserFriendlyString(ProfileCache cache) {
|
||||
public String toUserFriendlyString() {
|
||||
return toUserFriendlyString(null);
|
||||
}
|
||||
|
||||
public String toUserFriendlyString(@Nullable ProfileCache cache) {
|
||||
StringBuilder str = new StringBuilder();
|
||||
|
||||
if (playerDomain.size() > 0) {
|
||||
@@ -352,6 +419,12 @@ public class DefaultDomain implements Domain, ChangeTracked {
|
||||
|
||||
str.append(toGroupsString());
|
||||
}
|
||||
if (!customDomains.isEmpty()) {
|
||||
if (str.length() > 0) {
|
||||
str.append("; ");
|
||||
}
|
||||
str.append(toCustomDomainsString());
|
||||
}
|
||||
|
||||
return str.toString();
|
||||
}
|
||||
@@ -367,6 +440,12 @@ public class DefaultDomain implements Domain, ChangeTracked {
|
||||
}
|
||||
builder.append(toGroupsComponent());
|
||||
}
|
||||
if (!customDomains.isEmpty()) {
|
||||
if (playerDomain.size() > 0 || groupDomain.size() > 0) {
|
||||
builder.append(TextComponent.of("; "));
|
||||
}
|
||||
builder.append(toCustomDomainsComponent());
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@@ -442,21 +521,39 @@ public class DefaultDomain implements Domain, ChangeTracked {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private Component toCustomDomainsComponent() {
|
||||
final TextComponent.Builder builder = TextComponent.builder("");
|
||||
for (Iterator<CustomDomain> it = customDomains.values().iterator(); it.hasNext(); ) {
|
||||
CustomDomain domain = it.next();
|
||||
builder.append(TextComponent.of(domain.getName() + ":", TextColor.LIGHT_PURPLE))
|
||||
.append(TextComponent.of(domain.toString(), TextColor.GOLD));
|
||||
if (it.hasNext()) {
|
||||
builder.append(TextComponent.of(", "));
|
||||
}
|
||||
}
|
||||
return builder.build().hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("CustomDomain")));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isDirty() {
|
||||
return playerDomain.isDirty() || groupDomain.isDirty();
|
||||
return playerDomain.isDirty() || groupDomain.isDirty() ||
|
||||
customDomainsChanged || customDomains.values().stream().anyMatch(ChangeTracked::isDirty);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirty(boolean dirty) {
|
||||
playerDomain.setDirty(dirty);
|
||||
groupDomain.setDirty(dirty);
|
||||
customDomainsChanged = dirty;
|
||||
customDomains.values().forEach(d -> d.setDirty(dirty));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{players=" + playerDomain +
|
||||
", groups=" + groupDomain +
|
||||
", custom=" + customDomains +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.domains.registry;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldguard.commands.CommandInputContext;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
|
||||
public final class CustomDomainContext extends CommandInputContext<InvalidDomainFormatException> {
|
||||
|
||||
private CustomDomainContext(Actor sender, String input, Map<String, Object> values) {
|
||||
super(sender, input, values);
|
||||
}
|
||||
|
||||
|
||||
public static CustomDomainContext.CustomDomainContextBuilder create() {
|
||||
return new CustomDomainContext.CustomDomainContextBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a copy of this CustomDomainContext, with optional substitutions for values
|
||||
*
|
||||
* <p>If any supplied variable is null, it will be ignored.
|
||||
* If a map is supplied, it will override this CustomDomainContext's values of the same key,
|
||||
* but unprovided keys will not be overriden and will be returned as shallow copies.</p>
|
||||
*
|
||||
* @param commandSender CommandSender for the new CustomDomainContext to run under
|
||||
* @param s String of the user input for the new CustomDomainContext
|
||||
* @param values map of values to override from the current CustomDomainContext
|
||||
* @return a copy of this CustomDomainContext
|
||||
*/
|
||||
public CustomDomainContext copyWith(@Nullable Actor commandSender, @Nullable String s, @Nullable Map<String, Object> values) {
|
||||
Map<String, Object> map = Maps.newHashMap();
|
||||
map.putAll(context);
|
||||
if (values != null) {
|
||||
map.putAll(values);
|
||||
}
|
||||
return new CustomDomainContext(commandSender == null ? this.sender : commandSender, s == null ? this.input : s, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InvalidDomainFormatException createException(String str) {
|
||||
return new InvalidDomainFormatException(str);
|
||||
}
|
||||
|
||||
public static class CustomDomainContextBuilder {
|
||||
private Actor sender;
|
||||
private String input;
|
||||
private Map<String, Object> map = Maps.newHashMap();
|
||||
|
||||
public CustomDomainContextBuilder setSender(Actor sender) {
|
||||
this.sender = sender;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CustomDomainContextBuilder setInput(String input) {
|
||||
this.input = input;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CustomDomainContextBuilder setObject(String key, Object value) {
|
||||
this.map.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean tryAddToMap(String key, Object value) {
|
||||
if (map.containsKey(key)) return false;
|
||||
this.map.put(key, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
public CustomDomainContext build() {
|
||||
return new CustomDomainContext(sender, input, map);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.domains.registry;
|
||||
|
||||
public class DomainConflictException extends RuntimeException {
|
||||
public DomainConflictException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.sk89q.worldguard.domains.registry;
|
||||
|
||||
import com.sk89q.worldguard.domains.CustomDomain;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface DomainFactory<T extends CustomDomain> {
|
||||
T create(String name);
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.domains.registry;
|
||||
|
||||
import com.sk89q.worldguard.domains.CustomDomain;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface DomainRegistry extends Iterable<DomainFactory<?>> {
|
||||
|
||||
/**
|
||||
* Register a new Domain
|
||||
*
|
||||
* <p>There may be an appropiate time to register domains. if domains are
|
||||
* registered outside this time, then an exception may be thrown.</p>
|
||||
*
|
||||
* @param domain The domain
|
||||
* @throws DomainConflictException Thrown when already an existing domain exists with the same name
|
||||
* @throws IllegalStateException If it is not the right time to register new domains
|
||||
*/
|
||||
void register(String name, DomainFactory<?> domain) throws DomainConflictException;
|
||||
|
||||
/**
|
||||
* Register a collection of domains.
|
||||
*
|
||||
* <p>There may be an appropriate time to register domains. If domains are
|
||||
* registered outside this time, then an exception may be thrown.</p>
|
||||
*
|
||||
* <p>If there is a domain conflict, then an error will be logged but
|
||||
* no exception will be thrown.</p>
|
||||
*
|
||||
* @param domains a collection of domain factories
|
||||
* @throws IllegalStateException If it is not the right time to register new domains
|
||||
*/
|
||||
void registerAll(Map<String, DomainFactory<?>> domains);
|
||||
|
||||
/**
|
||||
* Get the domain by its name.
|
||||
*
|
||||
* @param name The name
|
||||
* @return The domain, if it has been registered
|
||||
*/
|
||||
@Nullable
|
||||
DomainFactory<?> get(String name);
|
||||
|
||||
/**
|
||||
* Try to get a domain by its name
|
||||
*/
|
||||
@Nullable
|
||||
CustomDomain createDomain(String name);
|
||||
|
||||
/**
|
||||
* Get all domains keyed by the registered name
|
||||
*
|
||||
* @return All domains
|
||||
*/
|
||||
Map<String, DomainFactory<?>> getAll();
|
||||
|
||||
/**
|
||||
* Unmarshal a raw map of values into a list of domains with their
|
||||
* unmarshalled values.
|
||||
*
|
||||
* @param rawValues The raw values map
|
||||
* @param createUnknown Whether "just in time" domains should be created for unknown domains
|
||||
* @return The unmarshalled domain list
|
||||
*/
|
||||
Map<String, CustomDomain> unmarshal(Map<String, Object> rawValues, boolean createUnknown);
|
||||
|
||||
/**
|
||||
* Get the number of registered domains.
|
||||
*
|
||||
* @return The number of registered domains
|
||||
*/
|
||||
int size();
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.domains.registry;
|
||||
|
||||
public class InvalidDomainFormatException extends Exception {
|
||||
private static final long serialVersionUID = 8101615074524004172L;
|
||||
|
||||
public InvalidDomainFormatException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.domains.registry;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.sk89q.worldguard.domains.CustomDomain;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class SimpleDomainRegistry implements DomainRegistry {
|
||||
private static final Logger log = Logger.getLogger(SimpleDomainRegistry.class.getCanonicalName());
|
||||
|
||||
private final Object lock = new Object();
|
||||
private final ConcurrentMap<String, DomainFactory<?>> domains = Maps.newConcurrentMap();
|
||||
private boolean initialized = false;
|
||||
|
||||
public boolean isInitialized() {
|
||||
return initialized;
|
||||
}
|
||||
|
||||
public void setInitialized(boolean initialized) {
|
||||
this.initialized = initialized;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(String name, DomainFactory<?> domain) throws DomainConflictException {
|
||||
synchronized (lock) {
|
||||
if (initialized) {
|
||||
throw new IllegalStateException("New domains cannot be registered at this time");
|
||||
}
|
||||
|
||||
forceRegister(name, domain);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAll(Map<String, DomainFactory<?>> domains) {
|
||||
synchronized (lock) {
|
||||
for (Map.Entry<String, DomainFactory<?>> entry : domains.entrySet()) {
|
||||
try {
|
||||
register(entry.getKey(), entry.getValue());
|
||||
} catch (DomainConflictException e) {
|
||||
log.log(Level.WARNING, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends DomainFactory<?>> T forceRegister(String name, T domain) throws DomainConflictException {
|
||||
checkNotNull(domain, "domain");
|
||||
checkNotNull(name, "name");
|
||||
|
||||
if (!CustomDomain.isValidName(name)) {
|
||||
throw new IllegalArgumentException("Invalid Domain name used.");
|
||||
}
|
||||
|
||||
synchronized (lock) {
|
||||
if (domains.containsKey(name)) {
|
||||
throw new DomainConflictException("A domain already exists by the name " + name);
|
||||
}
|
||||
|
||||
domains.put(name, domain);
|
||||
}
|
||||
|
||||
return domain;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public DomainFactory<?> get(String name) {
|
||||
checkNotNull(name, "name");
|
||||
return domains.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public CustomDomain createDomain(String name) {
|
||||
DomainFactory<?> factory = get(name);
|
||||
if (factory == null) return null;
|
||||
return factory.create(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, DomainFactory<?>> getAll() {
|
||||
return ImmutableMap.copyOf(domains);
|
||||
}
|
||||
|
||||
private CustomDomain getOrCreate(String name, Object value, boolean createUnknown) {
|
||||
CustomDomain customDomain = createDomain(name);
|
||||
|
||||
if (customDomain != null) {
|
||||
customDomain.unmarshal(value);
|
||||
return customDomain;
|
||||
}
|
||||
|
||||
synchronized (lock) {
|
||||
customDomain = createDomain(name); // Load again because the previous load was not synchronized
|
||||
if (customDomain != null) {
|
||||
customDomain.unmarshal(value);
|
||||
return customDomain;
|
||||
}
|
||||
if (createUnknown) {
|
||||
DomainFactory<UnknownDomain> unknownFactory = forceRegister(name, UnknownDomain.FACTORY);
|
||||
if (unknownFactory != null) {
|
||||
customDomain = unknownFactory.create(name);
|
||||
if (customDomain != null) customDomain.unmarshal(value);
|
||||
return customDomain;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map<String, CustomDomain> unmarshal(Map<String, Object> rawValues, boolean createUnknown) {
|
||||
checkNotNull(rawValues, "rawValues");
|
||||
|
||||
Map<String, CustomDomain> domains = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, Object> entry : rawValues.entrySet()) {
|
||||
try {
|
||||
CustomDomain domain = getOrCreate(entry.getKey(), entry.getValue(), createUnknown);
|
||||
domains.put(domain.getName(), domain);
|
||||
} catch (Throwable e) {
|
||||
log.log(Level.WARNING, "Failed to unmarshal domain for " + entry.getKey(), e);
|
||||
}
|
||||
}
|
||||
return domains;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return domains.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<DomainFactory<?>> iterator() {
|
||||
return Iterators.unmodifiableIterator(domains.values().iterator());
|
||||
}
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.domains.registry;
|
||||
|
||||
import com.sk89q.worldguard.domains.CustomDomain;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class UnknownDomain extends CustomDomain {
|
||||
public static DomainFactory<UnknownDomain> FACTORY = UnknownDomain::new;
|
||||
|
||||
private boolean isDirty = false;
|
||||
private Object o;
|
||||
|
||||
public UnknownDomain(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseInput(CustomDomainContext context) throws InvalidDomainFormatException {
|
||||
throw new InvalidDomainFormatException("The plugin that registered this domain is not currently installed");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unmarshal(Object o) {
|
||||
this.o = o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object marshal() {
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(UUID uniqueId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(String playerName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
isDirty = true;
|
||||
o = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirty(boolean dirty) {
|
||||
isDirty = dirty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirty() {
|
||||
return isDirty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UnknownDomain{" +
|
||||
"o=" + o +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -176,13 +176,14 @@ public class RegionPermissionModel extends AbstractPermissionModel {
|
||||
public boolean mayRemoveOwners(ProtectedRegion region) {
|
||||
return hasPatternPermission("removeowner", region);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks to see if the given sender has permission to modify the given region
|
||||
* using the region permission pattern.
|
||||
*
|
||||
* @param perm the name of the node
|
||||
* @param region the region
|
||||
* @return whether the actor has the permission
|
||||
*/
|
||||
private boolean hasPatternPermission(String perm, ProtectedRegion region) {
|
||||
if (!(getSender() instanceof Player)) {
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ public class BooleanFlag extends Flag<Boolean> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
public Boolean parseInput(FlagContext context) throws InvalidFlagFormatException {
|
||||
String input = context.getUserInput();
|
||||
|
||||
if (input.equalsIgnoreCase("true") || input.equalsIgnoreCase("yes")
|
||||
@@ -45,7 +45,7 @@ public class BooleanFlag extends Flag<Boolean> {
|
||||
|| input.equalsIgnoreCase("0")) {
|
||||
return false;
|
||||
} else {
|
||||
throw new InvalidFlagFormat("Not a yes/no value: " + input);
|
||||
throw new InvalidFlagFormatException("Not a yes/no value: " + input);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public class CommandStringFlag extends Flag<String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
public String parseInput(FlagContext context) throws InvalidFlagFormatException {
|
||||
String input = context.getUserInput();
|
||||
input = input.trim();
|
||||
if (!input.startsWith("/")) {
|
||||
|
||||
@@ -33,7 +33,7 @@ public class DoubleFlag extends NumberFlag<Double> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
public Double parseInput(FlagContext context) throws InvalidFlagFormatException {
|
||||
return context.getUserInputAsDouble();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -40,12 +40,12 @@ public class EntityTypeFlag extends Flag<EntityType> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
public EntityType parseInput(FlagContext context) throws InvalidFlagFormatException {
|
||||
String input = context.getUserInput();
|
||||
input = input.trim();
|
||||
EntityType entityType = unmarshal(input);
|
||||
if (entityType == null) {
|
||||
throw new InvalidFlagFormat("Unknown entity type: " + input);
|
||||
throw new InvalidFlagFormatException("Unknown entity type: " + input);
|
||||
}
|
||||
return entityType;
|
||||
}
|
||||
|
||||
@@ -74,12 +74,12 @@ public class EnumFlag<T extends Enum<T>> extends Flag<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
public T parseInput(FlagContext context) throws InvalidFlagFormatException {
|
||||
String input = context.getUserInput();
|
||||
try {
|
||||
return findValue(input);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new InvalidFlagFormat("Unknown value '" + input + "' in "
|
||||
throw new InvalidFlagFormatException("Unknown value '" + input + "' in "
|
||||
+ enumClass.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,9 +181,9 @@ public abstract class Flag<T> {
|
||||
*
|
||||
* @param context the {@link FlagContext}
|
||||
* @return The coerced type
|
||||
* @throws InvalidFlagFormat Raised if the input is invalid
|
||||
* @throws InvalidFlagFormatException Raised if the input is invalid
|
||||
*/
|
||||
public abstract T parseInput(FlagContext context) throws InvalidFlagFormat;
|
||||
public abstract T parseInput(FlagContext context) throws InvalidFlagFormatException;
|
||||
|
||||
/**
|
||||
* Convert a raw type that was loaded (from a YAML file, for example)
|
||||
|
||||
+12
-85
@@ -21,106 +21,28 @@ package com.sk89q.worldguard.protection.flags;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
|
||||
import java.util.Map;
|
||||
import com.sk89q.worldguard.commands.CommandInputContext;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
|
||||
public final class FlagContext {
|
||||
|
||||
private final Actor sender;
|
||||
private final String input;
|
||||
|
||||
private Map<String, Object> context;
|
||||
public final class FlagContext extends CommandInputContext<InvalidFlagFormatException> {
|
||||
|
||||
private FlagContext(Actor sender, String input, Map<String, Object> values) {
|
||||
this.sender = sender;
|
||||
this.input = input;
|
||||
this.context = values;
|
||||
super(sender, input, values);
|
||||
}
|
||||
|
||||
public static FlagContextBuilder create() {
|
||||
public static FlagContext.FlagContextBuilder create() {
|
||||
return new FlagContextBuilder();
|
||||
}
|
||||
|
||||
public void put(String name, Object value) {
|
||||
context.put(name, value);
|
||||
}
|
||||
|
||||
public Actor getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public String getUserInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the CommandSender as a player.
|
||||
*
|
||||
* @return Player
|
||||
* @throws InvalidFlagFormat if the sender is not a player
|
||||
*/
|
||||
public LocalPlayer getPlayerSender() throws InvalidFlagFormat {
|
||||
if (sender.isPlayer() && sender instanceof LocalPlayer) {
|
||||
return (LocalPlayer) sender;
|
||||
} else {
|
||||
throw new InvalidFlagFormat("Not a player");
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getUserInputAsInt() throws InvalidFlagFormat {
|
||||
try {
|
||||
return Integer.parseInt(input);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new InvalidFlagFormat("Not a number: " + input);
|
||||
}
|
||||
}
|
||||
|
||||
public Double getUserInputAsDouble() throws InvalidFlagFormat {
|
||||
try {
|
||||
return Double.parseDouble(input);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new InvalidFlagFormat("Not a number: " + input);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an object from the context by key name.
|
||||
* May return null if the object does not exist in the context.
|
||||
*
|
||||
* @param name key name of the object
|
||||
* @return the object matching the key, or null
|
||||
*/
|
||||
@Nullable
|
||||
public Object get(String name) {
|
||||
return get(name, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an object from the context by key name.
|
||||
* Will only return null if
|
||||
* a) you provide null as the default
|
||||
* b) the key has explicity been set to null
|
||||
*
|
||||
* @param name key name of the object
|
||||
* @return the object matching the key
|
||||
*/
|
||||
@Nullable
|
||||
public Object get(String name, Object defaultValue) {
|
||||
Object obj;
|
||||
return (((obj = context.get(name)) != null) || context.containsKey(name)
|
||||
? obj : defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a copy of this FlagContext, with optional substitutions for values
|
||||
*
|
||||
* If any supplied variable is null, it will be ignored.
|
||||
* <p>If any supplied variable is null, it will be ignored.
|
||||
* If a map is supplied, it will override this FlagContext's values of the same key,
|
||||
* but unprovided keys will not be overriden and will be returned as shallow copies.
|
||||
* but unprovided keys will not be overriden and will be returned as shallow copies.</p>
|
||||
*
|
||||
* @param commandSender CommandSender for the new FlagContext to run under
|
||||
* @param s String of the user input for the new FlagContext
|
||||
@@ -136,6 +58,11 @@ public final class FlagContext {
|
||||
return new FlagContext(commandSender == null ? this.sender : commandSender, s == null ? this.input : s, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InvalidFlagFormatException createException(String str) {
|
||||
return new InvalidFlagFormatException(str);
|
||||
}
|
||||
|
||||
public static class FlagContextBuilder {
|
||||
private Actor sender;
|
||||
private String input;
|
||||
|
||||
@@ -131,6 +131,7 @@ public final class Flags {
|
||||
public static final StateFlag WATER_FLOW = register(new StateFlag("water-flow", true));
|
||||
public static final StateFlag LAVA_FLOW = register(new StateFlag("lava-flow", true));
|
||||
public static final StateFlag MOISTURE_CHANGE = register(new StateFlag("moisture-change", true));
|
||||
public static final StateFlag LAVA_HARDEN = register(new StateFlag("lava-harden", true));
|
||||
|
||||
public static final RegistryFlag<WeatherType> WEATHER_LOCK = register(new RegistryFlag<>("weather-lock", WeatherType.REGISTRY));
|
||||
public static final StringFlag TIME_LOCK = register(new StringFlag("time-lock"));
|
||||
|
||||
+2
-2
@@ -40,12 +40,12 @@ public class GameModeTypeFlag extends Flag<GameMode> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameMode parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
public GameMode parseInput(FlagContext context) throws InvalidFlagFormatException {
|
||||
String input = context.getUserInput();
|
||||
input = input.trim();
|
||||
GameMode gamemode = unmarshal(input);
|
||||
if (gamemode == null) {
|
||||
throw new InvalidFlagFormat("Unknown game mode: " + input);
|
||||
throw new InvalidFlagFormatException("Unknown game mode: " + input);
|
||||
}
|
||||
return gamemode;
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public class IntegerFlag extends NumberFlag<Integer> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
public Integer parseInput(FlagContext context) throws InvalidFlagFormatException {
|
||||
return context.getUserInputAsInt();
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -19,6 +19,10 @@
|
||||
|
||||
package com.sk89q.worldguard.protection.flags;
|
||||
|
||||
/**
|
||||
* @deprecated replaced by {@link InvalidFlagFormatException}. Will be removed in WorldGuard 8
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class InvalidFlagFormat extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 8101615074524004172L;
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.protection.flags;
|
||||
|
||||
public class InvalidFlagFormatException extends InvalidFlagFormat {
|
||||
private static final long serialVersionUID = 8101615074524004172L;
|
||||
|
||||
public InvalidFlagFormatException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -41,7 +41,7 @@ public class LocationFlag extends Flag<Location> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
public Location parseInput(FlagContext context) throws InvalidFlagFormatException {
|
||||
String input = context.getUserInput();
|
||||
Player player = context.getPlayerSender();
|
||||
|
||||
@@ -76,7 +76,7 @@ public class LocationFlag extends Flag<Location> {
|
||||
player.printDebug("WARNING: Flag location is outside of region.");
|
||||
} else {
|
||||
// no permission
|
||||
throw new InvalidFlagFormat("You can't set that flag outside of the region boundaries.");
|
||||
throw new InvalidFlagFormatException("You can't set that flag outside of the region boundaries.");
|
||||
}
|
||||
}
|
||||
// clamp height to world limits
|
||||
@@ -86,7 +86,7 @@ public class LocationFlag extends Flag<Location> {
|
||||
}
|
||||
return loc;
|
||||
}
|
||||
throw new InvalidFlagFormat("Expected 'here' or x,y,z.");
|
||||
throw new InvalidFlagFormatException("Expected 'here' or x,y,z.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -70,7 +70,7 @@ public class MapFlag<K, V> extends Flag<Map<K, V>> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<K, V> parseInput(final FlagContext context) throws InvalidFlagFormat {
|
||||
public Map<K, V> parseInput(final FlagContext context) throws InvalidFlagFormatException {
|
||||
|
||||
final String input = context.getUserInput();
|
||||
if (input.isEmpty()) {
|
||||
@@ -83,7 +83,7 @@ public class MapFlag<K, V> extends Flag<Map<K, V>> {
|
||||
final char split = str.indexOf('=') == -1 ? ':' : '=';
|
||||
final String[] keyVal = str.split(String.valueOf(split));
|
||||
if (keyVal.length != 2) {
|
||||
throw new InvalidFlagFormat("Input must be in a 'key:value,key1=value1' format. Either ':' or '=' can be used.");
|
||||
throw new InvalidFlagFormatException("Input must be in a 'key:value,key1=value1' format. Either ':' or '=' can be used.");
|
||||
}
|
||||
|
||||
final FlagContext key = context.copyWith(null, keyVal[0], null);
|
||||
|
||||
+2
-2
@@ -44,10 +44,10 @@ public class RegistryFlag<T extends Keyed> extends Flag<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
public T parseInput(FlagContext context) throws InvalidFlagFormatException {
|
||||
final String key = context.getUserInput().trim().toLowerCase(Locale.ROOT);
|
||||
return Optional.ofNullable(registry.get(key))
|
||||
.orElseThrow(() -> new InvalidFlagFormat("Unknown " + registry.getName() + ": " + key));
|
||||
.orElseThrow(() -> new InvalidFlagFormatException("Unknown " + registry.getName() + ": " + key));
|
||||
}
|
||||
|
||||
public Registry<T> getRegistry() {
|
||||
|
||||
@@ -58,7 +58,7 @@ public class SetFlag<T> extends Flag<Set<T>> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<T> parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
public Set<T> parseInput(FlagContext context) throws InvalidFlagFormatException {
|
||||
String input = context.getUserInput();
|
||||
if (input.isEmpty()) {
|
||||
return Sets.newHashSet();
|
||||
|
||||
@@ -78,7 +78,7 @@ public class StateFlag extends Flag<StateFlag.State> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public State parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
public State parseInput(FlagContext context) throws InvalidFlagFormatException {
|
||||
String input = context.getUserInput();
|
||||
|
||||
if (input.equalsIgnoreCase("allow")) {
|
||||
@@ -88,7 +88,7 @@ public class StateFlag extends Flag<StateFlag.State> {
|
||||
} else if (input.equalsIgnoreCase("none")) {
|
||||
return null;
|
||||
} else {
|
||||
throw new InvalidFlagFormat("Expected none/allow/deny but got '" + input + "'");
|
||||
throw new InvalidFlagFormatException("Expected none/allow/deny but got '" + input + "'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public class StringFlag extends Flag<String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
public String parseInput(FlagContext context) throws InvalidFlagFormatException {
|
||||
String lines = context.getUserInput().replaceAll("(?<!\\\\)\\\\n", "\n").replaceAll("\\\\\\\\n", "\\\\n");
|
||||
// Add color codes
|
||||
lines = CommandUtils.replaceColorMacros(lines);
|
||||
|
||||
+3
-3
@@ -48,7 +48,7 @@ public class TimestampFlag extends Flag<Instant> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instant parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
public Instant parseInput(FlagContext context) throws InvalidFlagFormatException {
|
||||
String input = context.getUserInput();
|
||||
if ("now".equalsIgnoreCase(input)) {
|
||||
return Instant.now();
|
||||
@@ -61,10 +61,10 @@ public class TimestampFlag extends Flag<Instant> {
|
||||
} else if (parsed instanceof ZonedDateTime) {
|
||||
return ((ZonedDateTime) parsed).toInstant();
|
||||
} else {
|
||||
throw new InvalidFlagFormat("Unrecognized input.");
|
||||
throw new InvalidFlagFormatException("Unrecognized input.");
|
||||
}
|
||||
} catch (DateTimeParseException ignored) {
|
||||
throw new InvalidFlagFormat("Expected 'now' or ISO 8601 formatted input.");
|
||||
throw new InvalidFlagFormatException("Expected 'now' or ISO 8601 formatted input.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class UUIDFlag extends Flag<UUID> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
public UUID parseInput(FlagContext context) throws InvalidFlagFormatException {
|
||||
String input = context.getUserInput();
|
||||
if ("self".equalsIgnoreCase(input)) {
|
||||
return context.getSender().getUniqueId();
|
||||
@@ -41,7 +41,7 @@ public class UUIDFlag extends Flag<UUID> {
|
||||
try {
|
||||
return UUID.fromString(input);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new InvalidFlagFormat("Not a valid uuid: " + input);
|
||||
throw new InvalidFlagFormatException("Not a valid uuid: " + input);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public class VectorFlag extends Flag<Vector3> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3 parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
public Vector3 parseInput(FlagContext context) throws InvalidFlagFormatException {
|
||||
String input = context.getUserInput();
|
||||
|
||||
if ("here".equalsIgnoreCase(input)) {
|
||||
@@ -56,7 +56,7 @@ public class VectorFlag extends Flag<Vector3> {
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidFlagFormat("Expected 'here' or x,y,z.");
|
||||
throw new InvalidFlagFormatException("Expected 'here' or x,y,z.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -40,12 +40,12 @@ public class WeatherTypeFlag extends Flag<WeatherType> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WeatherType parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
public WeatherType parseInput(FlagContext context) throws InvalidFlagFormatException {
|
||||
String input = context.getUserInput();
|
||||
input = input.trim();
|
||||
WeatherType weatherType = unmarshal(input);
|
||||
if (weatherType == null) {
|
||||
throw new InvalidFlagFormat("Unknown weather type: " + input);
|
||||
throw new InvalidFlagFormatException("Unknown weather type: " + input);
|
||||
}
|
||||
return weatherType;
|
||||
}
|
||||
|
||||
+3
-3
@@ -21,7 +21,7 @@ package com.sk89q.worldguard.protection.flags.registry;
|
||||
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.FlagContext;
|
||||
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
|
||||
import com.sk89q.worldguard.protection.flags.InvalidFlagFormatException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -32,8 +32,8 @@ public class UnknownFlag extends Flag<Object> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
throw new InvalidFlagFormat("The plugin that registered this flag is not currently installed");
|
||||
public Object parseInput(FlagContext context) throws InvalidFlagFormatException {
|
||||
throw new InvalidFlagFormatException("The plugin that registered this flag is not currently installed");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+64
-46
@@ -27,6 +27,8 @@ import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.domains.CustomDomain;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.flags.FlagUtil;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
||||
@@ -194,64 +196,66 @@ public class YamlRegionFile implements RegionDatabase {
|
||||
public void saveAll(Set<ProtectedRegion> regions) throws StorageException {
|
||||
checkNotNull(regions);
|
||||
|
||||
File tempFile = new File(file.getParentFile(), file.getName() + ".tmp");
|
||||
YAMLProcessor config = createYamlProcessor(tempFile);
|
||||
synchronized (YamlRegionFile.class) {
|
||||
File tempFile = new File(file.getParentFile(), file.getName() + ".tmp");
|
||||
YAMLProcessor config = createYamlProcessor(tempFile);
|
||||
|
||||
config.clear();
|
||||
config.clear();
|
||||
|
||||
YAMLNode regionsNode = config.addNode("regions");
|
||||
Map<String, Object> map = regionsNode.getMap();
|
||||
YAMLNode regionsNode = config.addNode("regions");
|
||||
Map<String, Object> map = regionsNode.getMap();
|
||||
|
||||
for (ProtectedRegion region : regions) {
|
||||
Map<String, Object> nodeMap = new HashMap<>();
|
||||
map.put(region.getId(), nodeMap);
|
||||
YAMLNode node = new YAMLNode(nodeMap, false);
|
||||
for (ProtectedRegion region : regions) {
|
||||
Map<String, Object> nodeMap = new HashMap<>();
|
||||
map.put(region.getId(), nodeMap);
|
||||
YAMLNode node = new YAMLNode(nodeMap, false);
|
||||
|
||||
if (region instanceof ProtectedCuboidRegion) {
|
||||
ProtectedCuboidRegion cuboid = (ProtectedCuboidRegion) region;
|
||||
node.setProperty("type", "cuboid");
|
||||
node.setProperty("min", cuboid.getMinimumPoint());
|
||||
node.setProperty("max", cuboid.getMaximumPoint());
|
||||
} else if (region instanceof ProtectedPolygonalRegion) {
|
||||
ProtectedPolygonalRegion poly = (ProtectedPolygonalRegion) region;
|
||||
node.setProperty("type", "poly2d");
|
||||
node.setProperty("min-y", poly.getMinimumPoint().y());
|
||||
node.setProperty("max-y", poly.getMaximumPoint().y());
|
||||
if (region instanceof ProtectedCuboidRegion) {
|
||||
ProtectedCuboidRegion cuboid = (ProtectedCuboidRegion) region;
|
||||
node.setProperty("type", "cuboid");
|
||||
node.setProperty("min", cuboid.getMinimumPoint());
|
||||
node.setProperty("max", cuboid.getMaximumPoint());
|
||||
} else if (region instanceof ProtectedPolygonalRegion) {
|
||||
ProtectedPolygonalRegion poly = (ProtectedPolygonalRegion) region;
|
||||
node.setProperty("type", "poly2d");
|
||||
node.setProperty("min-y", poly.getMinimumPoint().y());
|
||||
node.setProperty("max-y", poly.getMaximumPoint().y());
|
||||
|
||||
List<Map<String, Object>> points = new ArrayList<>();
|
||||
for (BlockVector2 point : poly.getPoints()) {
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("x", point.x());
|
||||
data.put("z", point.z());
|
||||
points.add(data);
|
||||
List<Map<String, Object>> points = new ArrayList<>();
|
||||
for (BlockVector2 point : poly.getPoints()) {
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("x", point.x());
|
||||
data.put("z", point.z());
|
||||
points.add(data);
|
||||
}
|
||||
|
||||
node.setProperty("points", points);
|
||||
} else if (region instanceof GlobalProtectedRegion) {
|
||||
node.setProperty("type", "global");
|
||||
} else {
|
||||
node.setProperty("type", region.getClass().getCanonicalName());
|
||||
}
|
||||
|
||||
node.setProperty("points", points);
|
||||
} else if (region instanceof GlobalProtectedRegion) {
|
||||
node.setProperty("type", "global");
|
||||
} else {
|
||||
node.setProperty("type", region.getClass().getCanonicalName());
|
||||
node.setProperty("priority", region.getPriority());
|
||||
node.setProperty("flags", getFlagData(region));
|
||||
node.setProperty("owners", getDomainData(region.getOwners()));
|
||||
node.setProperty("members", getDomainData(region.getMembers()));
|
||||
|
||||
ProtectedRegion parent = region.getParent();
|
||||
if (parent != null) {
|
||||
node.setProperty("parent", parent.getId());
|
||||
}
|
||||
}
|
||||
|
||||
node.setProperty("priority", region.getPriority());
|
||||
node.setProperty("flags", getFlagData(region));
|
||||
node.setProperty("owners", getDomainData(region.getOwners()));
|
||||
node.setProperty("members", getDomainData(region.getMembers()));
|
||||
config.setHeader(FILE_HEADER);
|
||||
config.save();
|
||||
|
||||
ProtectedRegion parent = region.getParent();
|
||||
if (parent != null) {
|
||||
node.setProperty("parent", parent.getId());
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
file.delete();
|
||||
if (!tempFile.renameTo(file)) {
|
||||
throw new StorageException("Failed to rename temporary regions file to " + file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
config.setHeader(FILE_HEADER);
|
||||
config.save();
|
||||
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
file.delete();
|
||||
if (!tempFile.renameTo(file)) {
|
||||
throw new StorageException("Failed to rename temporary regions file to " + file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -286,6 +290,12 @@ public class YamlRegionFile implements RegionDatabase {
|
||||
}
|
||||
}
|
||||
|
||||
YAMLNode apiDomains = node.getNode("custom");
|
||||
if (apiDomains != null) {
|
||||
Map<String, CustomDomain> parsedDomains = WorldGuard.getInstance().getDomainRegistry().unmarshal(apiDomains.getMap(), true);
|
||||
domain.setCustomDomains(parsedDomains);
|
||||
}
|
||||
|
||||
return domain;
|
||||
}
|
||||
|
||||
@@ -306,6 +316,14 @@ public class YamlRegionFile implements RegionDatabase {
|
||||
setDomainData(domainData, "unique-ids", domain.getUniqueIds());
|
||||
setDomainData(domainData, "groups", domain.getGroups());
|
||||
|
||||
if (!domain.getCustomDomains().isEmpty()) {
|
||||
Map<String, Object> values = new HashMap<>();
|
||||
for (CustomDomain customDomain : domain.getCustomDomains()) {
|
||||
values.put(customDomain.getName(), customDomain.marshal());
|
||||
}
|
||||
domainData.put("custom", values);
|
||||
}
|
||||
|
||||
return domainData;
|
||||
}
|
||||
|
||||
|
||||
+48
-5
@@ -21,6 +21,12 @@ package com.sk89q.worldguard.protection.util;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.domains.CustomDomain;
|
||||
import com.sk89q.worldguard.domains.registry.CustomDomainContext;
|
||||
import com.sk89q.worldguard.domains.registry.InvalidDomainFormatException;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.util.profile.Profile;
|
||||
import com.sk89q.worldguard.util.profile.resolver.ProfileService;
|
||||
import com.sk89q.worldguard.util.profile.util.UUIDs;
|
||||
@@ -43,6 +49,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
public class DomainInputResolver implements Callable<DefaultDomain> {
|
||||
|
||||
private static final Pattern GROUP_PATTERN = Pattern.compile("(?i)^[G]:(.+)$");
|
||||
private static final Pattern CUSTOM_PATTERN = Pattern.compile("(?i)^([A-Za-z0-9\\-]{1,40}):(.*)$");
|
||||
|
||||
/**
|
||||
* The policy for locating users.
|
||||
@@ -56,6 +63,8 @@ public class DomainInputResolver implements Callable<DefaultDomain> {
|
||||
private final ProfileService profileService;
|
||||
private final String[] input;
|
||||
private UserLocatorPolicy locatorPolicy = UserLocatorPolicy.UUID_ONLY;
|
||||
private ProtectedRegion region;
|
||||
private Actor actor;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@@ -89,20 +98,54 @@ public class DomainInputResolver implements Callable<DefaultDomain> {
|
||||
this.locatorPolicy = locatorPolicy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the region for the Resolver
|
||||
* @param region the region
|
||||
*/
|
||||
public void setRegion(ProtectedRegion region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current region from the Resolver
|
||||
* @return the region
|
||||
*/
|
||||
public @Nullable ProtectedRegion getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the actor of the Resolver
|
||||
* @param actor the actor
|
||||
*/
|
||||
public void setActor(Actor actor) {
|
||||
this.actor = actor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultDomain call() throws UnresolvedNamesException {
|
||||
public DefaultDomain call() throws UnresolvedNamesException, InvalidDomainFormatException {
|
||||
DefaultDomain domain = new DefaultDomain();
|
||||
List<String> namesToQuery = new ArrayList<>();
|
||||
|
||||
for (String s : input) {
|
||||
Matcher m = GROUP_PATTERN.matcher(s);
|
||||
if (m.matches()) {
|
||||
domain.addGroup(m.group(1));
|
||||
Matcher groupMatcher = GROUP_PATTERN.matcher(s);
|
||||
Matcher customMatcher = CUSTOM_PATTERN.matcher(s);
|
||||
if (groupMatcher.matches()) {
|
||||
domain.addGroup(groupMatcher.group(1));
|
||||
} else if (customMatcher.matches()) {
|
||||
String domainName = customMatcher.group(1);
|
||||
CustomDomain customDomain = WorldGuard.getInstance().getDomainRegistry().createDomain(domainName);
|
||||
if (customDomain == null) {
|
||||
throw new InvalidDomainFormatException("No domain named '" + domainName + "' found.");
|
||||
}
|
||||
customDomain.parseInput(CustomDomainContext.create()
|
||||
.setSender(actor).setInput(customMatcher.group(2)).setObject("region", region).build());
|
||||
domain.addCustomDomain(customDomain);
|
||||
} else {
|
||||
UUID uuid = parseUUID(s);
|
||||
if (uuid != null) {
|
||||
// Try to add any UUIDs given
|
||||
domain.addPlayer(UUID.fromString(UUIDs.addDashes(s.replaceAll("^uuid:", ""))));
|
||||
domain.addPlayer(uuid);
|
||||
} else {
|
||||
switch (locatorPolicy) {
|
||||
case NAME_ONLY:
|
||||
|
||||
+3
-1
@@ -59,7 +59,9 @@ public class GameModeFlag extends FlagValueChangeHandler<GameMode> {
|
||||
private void updateGameMode(LocalPlayer player, @Nullable GameMode newValue, World world) {
|
||||
if (!getSession().getManager().hasBypass(player, world) && newValue != null) {
|
||||
if (player.getGameMode() != newValue) {
|
||||
originalGameMode = player.getGameMode();
|
||||
if (originalGameMode == null) {
|
||||
originalGameMode = player.getGameMode();
|
||||
}
|
||||
player.setGameMode(newValue);
|
||||
} else if (originalGameMode == null) {
|
||||
originalGameMode = WorldGuard.getInstance().getPlatform().getDefaultGameMode();
|
||||
|
||||
+6
@@ -26,6 +26,7 @@ import com.sk89q.worldedit.internal.command.exception.ExceptionMatch;
|
||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||
import com.sk89q.worldedit.util.formatting.component.InvalidComponentException;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.domains.registry.InvalidDomainFormatException;
|
||||
import com.sk89q.worldguard.protection.managers.storage.StorageException;
|
||||
import com.sk89q.worldguard.protection.util.UnresolvedNamesException;
|
||||
|
||||
@@ -91,6 +92,11 @@ public class WorldGuardExceptionConverter extends ExceptionConverterHelper {
|
||||
throw newCommandException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
@ExceptionMatch
|
||||
public void convert(InvalidDomainFormatException e) throws CommandException {
|
||||
throw newCommandException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
@ExceptionMatch
|
||||
public void convert(AuthorizationException e) throws CommandException {
|
||||
throw newCommandException("You don't have permission to do that.", e);
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.domains;
|
||||
|
||||
import com.sk89q.worldguard.domains.registry.CustomDomainContext;
|
||||
import com.sk89q.worldguard.domains.registry.InvalidDomainFormatException;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CustomUUIDDomain extends CustomDomain {
|
||||
private UUID test;
|
||||
|
||||
public CustomUUIDDomain(String name, UUID test) {
|
||||
super(name);
|
||||
this.test = test;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseInput(CustomDomainContext context) throws InvalidDomainFormatException {
|
||||
throw new InvalidDomainFormatException("not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unmarshal(Object o) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object marshal() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(UUID uniqueId) {
|
||||
return Objects.equals(test, uniqueId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(String playerName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
test = null;
|
||||
}
|
||||
}
|
||||
@@ -112,5 +112,11 @@ public class DefaultDomainTest {
|
||||
assertFalse(domain.contains(player1));
|
||||
assertTrue(domain.contains(player2));
|
||||
assertTrue(domain.contains(player3));
|
||||
|
||||
domain = new DefaultDomain();
|
||||
domain.addCustomDomain(new CustomUUIDDomain("test", player2.getUniqueId()));
|
||||
assertTrue(domain.contains(player2));
|
||||
assertFalse(domain.contains(player2.getName()));
|
||||
assertFalse(domain.contains(player3));
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 614.24 143.11"><defs><style>.cls-1{fill:none;}.cls-2{fill:#2d2d2d;}.cls-3{clip-path:url(#clip-path);}.cls-4{fill:url(#New_Gradient_Swatch_copy);}.cls-5{mask:url(#mask);}.cls-6{opacity:0.1;}.cls-7{fill:url(#New_Gradient_Swatch_copy-2);}.cls-8{mask:url(#mask-2);}.cls-9{fill:url(#New_Gradient_Swatch_copy-3);}.cls-10{mask:url(#mask-3);}.cls-11{fill:#fff;}.cls-12{filter:url(#luminosity-invert);}</style><clipPath id="clip-path"><path class="cls-1" d="M78.54,138.1c-3.85,3.85-10.45,3.45-14.33-.42L5.07,78.54a9.85,9.85,0,0,1-.07-14L63.63,6c3.85-3.85,11.25-4.68,15.13-.8l59,59c3.88,3.88,3.63,11.13-.23,15Z"/></clipPath><linearGradient id="New_Gradient_Swatch_copy" x1="71.56" y1="3.86" x2="71.56" y2="141.19" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#006bff"/><stop offset="1" stop-color="#004dff"/></linearGradient><filter id="luminosity-invert" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feColorMatrix values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0"/></filter><mask id="mask" x="29.59" y="-2.48" width="83" height="42" maskUnits="userSpaceOnUse"><g class="cls-12"><image width="83" height="42" transform="translate(29.59 -2.48)" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFMAAAAqCAYAAADPn2cJAAAACXBIWXMAAAsSAAALEgHS3X78AAAGoklEQVRoQ+2bWXObQBCEGxDLcsjR6eT//7vEcbmcyDE3eVD11jBaST50PXiqKKILlo+entnFCQAM+IqTRHjsC1/x9pgc+8I1IwxDRFEEAAiCAH3fu+0W42ZhTiYTWGthjHFA27ZF0zQoyxJt2x45wuXjJmHGcYyiKJDn+Qhm13Wo6xovLy/YbDZomubIkS4bNwczSRJ8+/ZtBDMMt9be9z3qukaSJDDG4Pn5GWVZHjni5eKmYFprMZ/PcXd3h+l0iizLEMfxSJlN0yBJEsRxjDAM8fT0dDNAbwamtRar1Qrz+RzT6RRFUcBaiyRJRsqsqsq9T9CPj494fX09cobzx03ATNMUq9UKy+USs9kM0+kUeZ7DWutVZlmWDuZkMkEYhnh4eLg60KvDzLIM6/Uay+USi8Vi5JcynYGtMpum2VFnGIYO6MvLy5Ezni+uCjPLMtzf32O9XmOxWGA2m+Hu7g5FUSDLsqMwqcwoihBFEYIgwK9fv64G9Gow8zzH9+/fsVqtnFfOZjMURYGiKJCm6VGYxhgkSeKABkHggG42myMjOH1cBSZB3t/fY7lcOq+UKU6Y9ERgC7NtW5Rl6dKcfShhhmGIIAgwDMPFFXpxmHme48ePH1iv1zteOZ1OXUskZz+yALVtizRNXREyxjhl0juB7fTz58+f+Pv376HhnDQuCpMg6ZMEOZ/PnSqZ4tITtTLZa/pAMtX5m2EYLpbyF4MpQcr0plfKwpOmKYwxDlYQBAC2YNq2Hc2C4jh27ROhEugwbFcXL6XQi8DUINlTEiRTPM/zUYpLSMA2zdlr1nU9quZSmQB29pdQ6Nlh7gMp05sznizLXEtEmNIHufwmYUpF+mACuJhCzwpTVm16pATJ2Q5hsoLLmQ+rNLCF0nXdTmrr9GYMw+A2vu77/mxV/mwwsyxzINlLMrUlSO2VcprI4iNhsggRIj1Vf88XUqHnSPmzwCTI9Xq9k9bSIyVImd5siWSKM/q+dxClGiVIqUTeAG7y9b9//3bG/pk4OUw5RZQgZ7PZCKT2SRYdVnCpNBm+NkiDPASRewAnn3qeFGaapg6iVCIhUolylsOeUk4NtRp1BEHgKjxjH8S2bV0X0HXd6BkSv3uq1aaTwbTW7i0yhJjnuYNorXUeqRX51pBAj0H0Ae26DsMw4OHh4SQpfxKYXNhdLBYupaUS8zzfUaNuut8LkhGG2yeYcRyPWqc0TdG2rZsxyb0EK2/CZ1fsPw3TWrvTN/Kxg0xpLkxob5RN90eClVxWd2MM2raFtXYEVkLVYIdhwO/fvz8F9FMwkyQZtToSopzNSIi67ZF95EdDzsfDMHTHj+PYeXFd10jT1DX8hEmgVOfj4yOqqjp2Sm98GKYxZm9hkRCPLUicImRf6QNLK+F4rLXIsswpVKq073s8PT19COiHYMZx7CBKkNIPZfMtZyq6jem6zr2/rx06FLLosPUhXAmWFqChUq3SBgj0vc/l3w0zjmPXJ3JxgtWZ00C9AEFAsopybZKf6dXyQ1D19JBFR6YtVeYDK9VqrUVVVQ6qLE5//vx5F9B3wZxMJsjz/CBELk7oKSDhUQEsOPJzpqZWqJ4mcs/CIW+O9kQJlsciVN50+qq11v2Wv9tsNm/+U5w3w4yiCFmWjSD65tEMDZEApUrbtt2xAl4o4F9G41436F3XOYAEUpYlqqryFhuGzwKste77fb+ddr4F6JtgRlHkTFtDlKnpA1hVlVeF2g58xWlfuyS9UcKUyqdCq6oabbLg8Di+gmWMgbXWwX99fUXXdd7xMI7CZDr4WhupGF5IXdcjlTINeZGEKCu8hikVrL1TqpLH3geUCvVBresadV2PFMjzyX61abaPSLpu+0djh4AehEmQvqeAvKtahTqNm6aBMQZVVY18VTfsPK5UOuCHyb2u5NI7pUK5EWJVVc4C+J60AILluIwxo4ImbULGXpi8MAlQp7IuJBosZzoaYByPV8hl1ZcprkEyOAad6hKo9FCtVKlWKlT6qwTHsVCt8rw6vDClh2hYhwAyfSU8mc4yrWkFMq0lUI7DFzrVJVyCkJXcp9Z9gOVGsARHqLxxGuhemNIPOTipTJ6cSpOK0/B8RUaD9MHkWGTINJfj03uqVO4JWO6leiVwvecxfHwYOzA1RN4ZqtIHR9rBIWhvUeIhkAx5AT6VcuPYtbdqwNoe+Fqrm+/viwDY/a8rvouTfqY3Hxyf2uSmzyP3vrEwfF7lU6v+t7YD32v9md58x5bhhfkVH4uPLSJ+hTf+A45XAcRn3tf4AAAAAElFTkSuQmCC"/></g></mask><linearGradient id="New_Gradient_Swatch_copy-2" x1="71.55" y1="3.86" x2="71.55" y2="141.19" xlink:href="#New_Gradient_Swatch_copy"/><mask id="mask-2" x="-2.41" y="45.52" width="148" height="51" maskUnits="userSpaceOnUse"><g class="cls-12"><image width="148" height="51" transform="translate(-2.41 45.52)" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJQAAAAzCAYAAABxJSGCAAAACXBIWXMAAAsSAAALEgHS3X78AAAInklEQVR4Xu1d63arvA4cY65J3/9BdxpuBnN+5IwRhiRA0n609azFSgMJYGk0koWztwIwICDgTYiefSAgYAviZx/4Diil3Cs3iWEYJttvB8cfRdHENgRtcES7HIJQAKC1RhzHiKJoYshhGGCtRd/3bjuK8b4ScRzPbEJYa2GtRdd1h7PJIQgVRRHiOEaSJEiSBFprZ0Aarus6GGNgrT2M8b4KURRBa40sy5CmqSOVUmoSYG3bomkaWGufnfLbcAhCKaWgtUaSJMiybEYorTWUUuj7fpYOfyOUUs4WaZoiSZKJavd9j67rnE2MMU/O+H04BKGAW8qj8RiRwI1QjExjzJ8hFANM2oRj77oOURRhGIbJ/iPgEISiAVkzcGOtAEyV6reD9mAZwLTHwGKw9X0/Cb6tWCr0X8VbCPXqjbHoJJEo8VprVzORcH+BUL4tZF0pCdV13UsKpZRy53xXbfoyoRhNwI1Mfd8/+cYcURQ5o3F2o7XGMAwz9eK1fjN8O8jZHm1irZ2o+R6QuMA4+Xm1wN93J/8Hb4jKYa11g/Z7I/xb9lUYIXmeu/NQmRiFSinEcYy+75EkCfI8n02V3xFZ/xV8e2itnT18UsnUJtWrKAo3E37Uk+K1mBFkbcZZozFmlygQuwkli0ZJKDqb9c/SACWZ0jR15+BAeQyAk3gSLU3TWQvBP//RCeanKI5X2kMGGMfuE4JES9MURVGgaRpnewBOzfxr0HfMCvRdkiSo6xpN06DrOuzBLkJxEHmeOzIAcIQyxswiRjqZg5MGI5G4yc9KAjKKGUVSon0VPDKWxiiVyB+ztIt/nJmC9gamtpDnj+MYWZY5dSKhhmGYzLCrqtpFqs2EoiSfTqdJ042FHfOw73BfNbhf67HwJnxS8fu8xiMFPLine truncated
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" viewBox="0 0 614.2 143.1" xml:space="preserve"><style>.st4{opacity:.1}.st7{fill:#fff}</style><g id="Layer_2_00000052784576965984388860000017441764153098466226_"><g id="Layer_4"><path d="m242.9 32.2-17.2 64h-10.4l-11.8-38.9-11.8 38.9h-10.4l-17.1-64h13.1l9.9 40.4 11.7-40.4h9.4L220 72.6l10-40.4h12.9zm40.3 40.5c.1 3.6-.3 7.2-1.1 10.7-.7 2.8-2.2 5.5-4.2 7.6-3.7 3.8-8.5 5.8-14.6 5.8s-10.9-1.9-14.5-5.8c-2-2.1-3.5-4.7-4.2-7.6-.8-3.5-1.2-7.1-1.1-10.7 0-8.4 1.8-14.5 5.4-18.3 3.6-3.8 8.4-5.7 14.4-5.7 6.1 0 10.9 1.9 14.5 5.7s5.4 9.9 5.4 18.3zm-11.8 0c0-5.8-.9-9.5-2.7-11.3a7.2 7.2 0 0 0-5.4-2.1 7 7 0 0 0-5.3 2.1c-1.8 1.8-2.7 5.6-2.7 11.3s.9 9.6 2.7 11.4a7 7 0 0 0 5.3 2.1c2 .1 4-.7 5.4-2.1 1.8-1.8 2.7-5.6 2.7-11.4zm52.7-19.5-8.8 8.9a8.6 8.6 0 0 0-6.2-2.8 7 7 0 0 0-5.1 2.1 8.6 8.6 0 0 0-2.4 6.6v28.2h-11.7V49.3h11.4v4.5c2.8-3.3 6.8-5 11.8-5a15 15 0 0 1 11 4.4zm22 43h-6.7c-4.5 0-8-1.4-10.5-4.2a13.3 13.3 0 0 1-3.2-9.2V32.2h11.8v49.9c0 2.8 1.4 4.2 4.1 4.2h4.5v9.9zm42.3 0H377v-4.4a14.6 14.6 0 0 1-11.6 4.9c-4.9 0-8.7-1.4-11.5-4.2a15.8 15.8 0 0 1-4.1-9c-.5-3.6-.7-7.2-.6-10.8-.1-3.6.1-7.2.6-10.7.7-3.9 2-6.9 4.1-9 2.8-2.8 6.6-4.2 11.4-4.2 4.8 0 8.6 1.6 11.4 4.7V32.2h11.8l-.1 64zm-11.8-23.5c0-4.4-.5-7.6-1.3-9.5-1.2-2.6-3.4-3.9-6.6-3.9-3.4 0-5.7 1.5-6.9 4.5-.7 1.8-1 4.8-1 8.9s.3 7.1 1 8.9c1 2.9 3.8 4.8 6.9 4.6 3.2 0 5.4-1.3 6.6-3.9.9-1.9 1.3-5.1 1.3-9.6zm66.5-3c0 9-2 15.5-5.9 19.7a23.7 23.7 0 0 1-17.9 7.4c-6.5.1-12.7-2.4-17.3-7-3-3-4.9-6.9-5.6-11.1-.5-2.7-.7-7.5-.7-14.5s.2-11.8.7-14.5c.7-4.2 2.6-8 5.6-11.1a23.7 23.7 0 0 1 17.3-7c3.8-.1 7.5.5 11 1.9 3.2 1.6 6.2 3.7 8.6 6.3l-8.5 8.5c-1.5-1.6-3.2-3-5-4.1a13 13 0 0 0-6.1-1.3c-3-.1-6 1.1-8 3.4-1.6 1.8-2.5 4.7-2.9 8.6a139 139 0 0 0 0 18.7c.4 4 1.3 6.9 2.9 8.7 2 2.2 5 3.5 8 3.3a11 11 0 0 0 8.5-3.6c1.9-2 2.8-4.9 2.8-8.7V71h-11.4V60.5H443v9.2zm45.2 26.5h-11.4v-4.3c-3 3.2-7.3 5-11.7 4.8-4.6 0-8.3-1.4-11.1-4.1a18 18 0 0 1-4.8-13.3v-30h11.8v28.4c0 2.9.8 5.2 2.5 6.7 1.4 1.3 3.3 2 5.2 1.9 1.9.1 3.8-.6 5.2-1.9 1.7-1.5 2.5-3.7 2.5-6.7V49.3h11.8v46.9zm44.1 0H521v-4a16 16 0 0 1-11.5 4.5c-5.3 0-9.2-1.3-11.9-4.1a14.4 14.4 0 0 1-4-10.6 13 13 0 0 1 4.1-9.8c2.7-2.6 6.7-3.8 11.9-3.8h11V66c0-4.9-2.9-7.4-8.7-7.4-3.4-.2-6.8 1.3-9 3.9l-7.4-7.3c2-2.3 4.5-4 7.3-5.1 3.1-1 6.4-1.5 9.6-1.3 13.3 0 20 5.5 20 16.5v30.9zm-11.8-17.3v-2.5h-9.2c-4.4 0-6.5 1.8-6.5 5.3s2.2 5.4 6.7 5.4c4 0 6.6-1 8-3 .8-1.6 1.1-3.4 1-5.2zm54.1-25.7-8.8 8.9a8.6 8.6 0 0 0-6.2-2.8 7 7 0 0 0-5.1 2.1 8.6 8.6 0 0 0-2.4 6.6v28.2h-11.7V49.3h11.4v4.5c2.8-3.3 6.8-5 11.8-5 4-.1 8 1.5 11 4.4zm39.5 43h-11.4v-4.4a14.6 14.6 0 0 1-11.6 4.9c-4.9 0-8.7-1.4-11.5-4.2a15.8 15.8 0 0 1-4.1-9c-.5-3.6-.7-7.2-.6-10.8-.1-3.6.1-7.2.6-10.7.7-3.9 2-6.9 4.1-9 2.8-2.8 6.6-4.2 11.4-4.2 4.8 0 8.6 1.6 11.4 4.7V32.2h11.8v64zm-11.7-23.5c0-4.4-.4-7.6-1.3-9.5-1.2-2.6-3.4-3.9-6.6-3.9-3.4 0-5.7 1.5-6.8 4.5-.7 1.8-1 4.8-1 8.9s.3 7.1 1 8.9c1 2.9 3.8 4.8 6.8 4.6 3.2 0 5.4-1.3 6.6-3.9.8-1.9 1.3-5.1 1.3-9.6z" fill="#2d2d2d" stroke="#fff" stroke-miterlimit="10"/><g><defs><path id="SVGID_1_" d="M78.5 138.1c-3.8 3.9-10.4 3.4-14.3-.4L5.1 78.5A9.8 9.8 0 0 1 5 64.6l.1-.1L63.6 6c3.9-3.8 11.3-4.7 15.1-.8l59 59c3.9 3.9 3.6 11.1-.2 15l-59 58.9z"/></defs><clipPath id="SVGID_00000145029192010834712300000017443068230347339956_"><use xlink:href="#SVGID_1_" overflow="visible"/></clipPath><g clip-path="url(#SVGID_00000145029192010834712300000017443068230347339956_)"><path fill="none" d="M56.1 65.2h45.2v3H56.1z"/><linearGradient id="SVGID_00000069364478787755211970000003740009090250123963_" gradientUnits="userSpaceOnUse" x1="71.6" y1="142.1" x2="71.6" y2="4.8" gradientTransform="matrix(1 0 0 -1 0 146)"><stop offset="0" stop-color="#006bff"/><stop offset="1" stop-color="#004dff"/></linearGradient><path d="M74.9 1.4a4.8 4.8 0 0 0-6.8 0L32.5 37.1h78.1L74.9 1.4z" fill="url(#SVGID_00000069364478787755211970000003740009090250123963_)"/><g><g class="st4"><path d="M74.9 1.4a4.8 4.8 0 0 0-6.8 0L32.5 37.1h78.1L74.9 1.4z"/></g></g><linearGradient id="SVGID_00000084519624245935921250000012172575822901895094_" gradientUnits="userSpaceOnUse" x1="71.5" y1="142.1" x2="71.5" y2="4.8" gradientTransform="matrix(1 0 0 -1 0 146)"><stop offset="0" stop-color="#006bff"/><stop offset="1" stop-color="#004dff"/></linearGradient><path d="m141.7 68.2-16.4-16.4v4.3h-14v-8h-12v8H42v-8H31v8H16.9v-3.5L1.4 68.2a4.8 4.8 0 0 0 0 6.8l18.5 18.5V60.1H31v11h11v-11h57.2v11h12v-11h11v34.2l19.4-19.4c1.9-1.8 2-4.8.1-6.7z" fill="url(#SVGID_00000084519624245935921250000012172575822901895094_)"/><g><g class="st4"><path d="m141.7 68.2-16.4-16.4v4.3h-14v-8h-12v8H42v-8H31v8H16.9v-3.5L1.4 68.2a4.8 4.8 0 0 0 0 6.8l18.5 18.5V60.1H31v11h11v-11h57.2v11h12v-11h11v34.2l19.4-19.4c1.9-1.8 2-4.8.1-6.7z"/></g></g><linearGradient id="SVGID_00000102525750365294681190000017673805805378204844_" gradientUnits="userSpaceOnUse" x1="71.6" y1="142.2" x2="71.6" y2="4.8" gradientTransform="matrix(1 0 0 -1 0 146)"><stop offset="0" stop-color="#006bff"/><Line truncated
|
||||
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 5.4 KiB |
Reference in new issue
Block a user