Compare commits
83 Commits
Author | SHA1 | Date |
---|---|---|
Joo200 | aa254c80e0 | |
Joo200 | 2f93b26be0 | |
wizjany | 6bbf49314d | |
Madeline Miller | f6a0a0b415 | |
Joo200 | 4ad11151fe | |
Joo200 | c29edf7467 | |
Joo200 | da3c81a88d | |
Joo200 | c65dd83a7e | |
Joo200 | 694195435d | |
Madeline Miller | 0d824d375b | |
aromaa | c7319f10dc | |
Joo200 | c2b95f59a8 | |
Joo200 | 5fa6f2a858 | |
Joo200 | 0a9eb447d6 | |
Joo200 | 02a8fd4c17 | |
wizjany | 3201cee1b7 | |
wizjany | 16a3c85005 | |
Joo200 | 5934e49489 | |
Joo200 | 58fbb6f008 | |
Joo200 | fba8333de3 | |
Joo200 | 8cbce96a2c | |
Madeline Miller | fffb0c1f98 | |
Madeline Miller | 223b80c590 | |
Joo200 | 853631139d | |
Joo200 | c61e9f1fe0 | |
Joo200 | 64ccda4615 | |
Joo200 | 16887c8540 | |
Joo200 | 2c448f1ba2 | |
wizjany | c0cbe27efc | |
Joo200 | bb3fdcc880 | |
JOO200 | 8d5953a550 | |
Joo200 | 4a26e306b6 | |
wizjany | 129ae6c971 | |
wizjany | 44d0735412 | |
wizjany | 33cdb4a6a8 | |
wizjany | feb548aa84 | |
wizjany | 961461c23c | |
wizjany | ad6d5af592 | |
wizjany | 7ae7a04721 | |
wizjany | 40adfe9cef | |
Joo200 | 78498491dd | |
stonar96 | ca636d20af | |
Joo200 | b67fd01ebd | |
Joo200 | bddfbdd353 | |
JOO200 | ece376a69e | |
wizjany | 1e81a91d4d | |
JOO200 | 216f95f87c | |
JOO200 | ca6e228f61 | |
Joo200 | fd1cb1e4bd | |
Joo200 | 8c8a8092b5 | |
Maddy Miller | 1729e5e3d6 | |
Madeline Miller | 46dfb69fb1 | |
Joo200 | 9ceecf5d3a | |
Maddy Miller | 20044a72d3 | |
JOO200 | 8bc7ff49ab | |
Joo200 | 6f749b058b | |
Joo200 | 91380a8316 | |
Joo200 | ba55cc79c2 | |
Joo200 | 62be386626 | |
aromaa | cb100bb797 | |
Joo200 | 741f9e231b | |
Joni Aromaa | bd1d772faa | |
wizjany | f1f1e8aa7d | |
wizjany | 598c441718 | |
wizjany | cbb2ba7216 | |
dordsor21 | e756d127c5 | |
Joo200 | 0d2ed8205f | |
JOO200 | 6efdb1089e | |
wizjany | 4a21bf43e7 | |
JOO200 | 3a181a230f | |
JOO200 | 857f7468d8 | |
JOO200 | f8e8d0f01e | |
JOO200 | 23521858fd | |
JOO200 | 0fddd2a573 | |
JOO200 | 85dd012b85 | |
wizjany | dc23af7947 | |
JOO200 | b698941378 | |
wizjany | 271b32aa1d | |
wizjany | 938f0c3b66 | |
wizjany | bc63119373 | |
wizjany | 3549f04a33 | |
wizjany | 216b061172 | |
wizjany | 27dca2b506 |
|
@ -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
|
||||
|
|
24
CHANGELOG.md
24
CHANGELOG.md
|
@ -1,5 +1,29 @@
|
|||
# Changelog
|
||||
|
||||
## 7.0.10
|
||||
|
||||
* Add support for MC 1.20.5 and 1.20.6, drop support for other 1.20 versions
|
||||
|
||||
## 7.0.9
|
||||
* Add support for MC 1.20, drop support for MC 1.19
|
||||
* Made entities spawned via the `/summon` command get treated as plugin-spawned entities
|
||||
* Add sniffer egg trample protection options
|
||||
|
||||
## 7.0.8
|
||||
* Add support for MC 1.19
|
||||
* Add skulk-growth flag and config option
|
||||
* Add copper-fade flag
|
||||
* Add data packs to report output
|
||||
* Add protection for allay inventory slot
|
||||
* Categorize allay item pickups under item-pickup flag
|
||||
* Categorize dragon egg interaction (teleporting) as building
|
||||
* Ignore most NPC-based actions for Player events
|
||||
* Optimize handling of tamed animals where the owner was offline (Paper only)
|
||||
* Optimize additional InventoryHolder accesses (Paper only)
|
||||
* Fix an exception that occurred when plugins created portals with non-player entities
|
||||
* Fix possible error when using Paper's entity origin API
|
||||
* Update bstats and squirrelid libs
|
||||
|
||||
## 7.0.7
|
||||
* Add rock-growth flag for budding amethyst and pointed dripstone.
|
||||
* Add /rg migrateheights command. See https://worldguard.enginehub.org/en/latest/regions/commands/#migrate-region-heights
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
Compiling
|
||||
=========
|
||||
|
||||
You can compile WorldGuard as long as you have some version of Java greater than or equal to 16 installed. Gradle will download JDK 16 specifically if needed,
|
||||
but it needs some version of Java to bootstrap from.
|
||||
|
||||
Note that if you have JRE 16 installed, Gradle will currently attempt to use that to compile, which will not work. It is easiest to uninstall JRE 16 and
|
||||
replace it with JDK 16.
|
||||
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.
|
||||
|
||||
The build process uses Gradle, which you do *not* need to download. WorldGuard is a multi-module project with three modules:
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ A Bukkit server implementation (such as [Paper](https://papermc.io)) and the [Wo
|
|||
Compiling
|
||||
---------
|
||||
|
||||
The project is written for Java 16 and our build process makes use of
|
||||
The project is written for Java 17 and our build process makes use of
|
||||
[Gradle](http://gradle.org).
|
||||
|
||||
Dependencies are automatically handled by Gradle.
|
||||
|
@ -40,8 +40,8 @@ Submissions must be licensed under the GNU Lesser General Public License v3.
|
|||
Links
|
||||
-----
|
||||
|
||||
* [Homepage](http://enginehub.org/worldguard)
|
||||
* [Homepage](https://enginehub.org/worldguard)
|
||||
* [Discord](https://discord.gg/enginehub)
|
||||
* [Issue tracker](https://github.com/EngineHub/WorldGuard/issues)
|
||||
* [Continuous integration](http://builds.enginehub.org) [![Build Status](https://ci.enginehub.org/app/rest/builds/buildType:bt11,branch:master/statusIcon.svg)](http://ci.enginehub.org/viewType.html?buildTypeId=bt11&guest=1)
|
||||
* [Continuous integration](https://builds.enginehub.org) [![Build Status](https://ci.enginehub.org/app/rest/builds/buildType:bt11,branch:master/statusIcon.svg)](http://ci.enginehub.org/viewType.html?buildTypeId=bt11&guest=1)
|
||||
* [End-user documentation](https://worldguard.enginehub.org/en/latest/)
|
||||
|
|
|
@ -11,7 +11,19 @@ repositories {
|
|||
dependencies {
|
||||
implementation(gradleApi())
|
||||
implementation("gradle.plugin.org.cadixdev.gradle:licenser:0.6.1")
|
||||
implementation("org.ajoberstar.grgit:grgit-gradle:4.1.0")
|
||||
implementation("com.github.jengelman.gradle.plugins:shadow:6.1.0")
|
||||
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.21.0")
|
||||
}
|
||||
implementation("org.ajoberstar.grgit:grgit-gradle:5.2.2")
|
||||
implementation("com.github.johnrengelman:shadow:8.1.1")
|
||||
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:5.2.0")
|
||||
constraints {
|
||||
val asmVersion = "[9.7,)"
|
||||
implementation("org.ow2.asm:asm:$asmVersion") {
|
||||
because("Need Java 21 support in shadow")
|
||||
}
|
||||
implementation("org.ow2.asm:asm-commons:$asmVersion") {
|
||||
because("Need Java 21 support in shadow")
|
||||
}
|
||||
implementation("org.vafer:jdependency:[2.10,)") {
|
||||
because("Need Java 21 support in shadow")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ fun Project.applyCommonConfiguration() {
|
|||
|
||||
plugins.withId("java") {
|
||||
the<JavaPluginExtension>().toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(16))
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,6 +1,6 @@
|
|||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.ExtraPropertiesExtension
|
||||
import org.gradle.api.plugins.JavaPluginConvention
|
||||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.api.tasks.SourceSetContainer
|
||||
import org.gradle.kotlin.dsl.getByType
|
||||
import org.gradle.kotlin.dsl.the
|
||||
|
@ -9,4 +9,4 @@ val Project.ext: ExtraPropertiesExtension
|
|||
get() = extensions.getByType()
|
||||
|
||||
val Project.sourceSets: SourceSetContainer
|
||||
get() = the<JavaPluginConvention>().sourceSets
|
||||
get() = the<JavaPluginExtension>().sourceSets
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.ExternalModuleDependency
|
||||
import org.gradle.api.artifacts.ModuleDependency
|
||||
import org.gradle.api.attributes.Bundling
|
||||
import org.gradle.api.attributes.Category
|
||||
|
@ -52,22 +53,22 @@ fun Project.applyLibrariesConfiguration() {
|
|||
}
|
||||
val altConfigFiles = { artifactType: String ->
|
||||
val deps = configurations["shade"].incoming.dependencies
|
||||
.filterIsInstance<ModuleDependency>()
|
||||
.map { it.copy() }
|
||||
.map { dependency ->
|
||||
dependency.artifact {
|
||||
name = dependency.name
|
||||
type = artifactType
|
||||
extension = "jar"
|
||||
classifier = artifactType
|
||||
}
|
||||
dependency
|
||||
.filterIsInstance<ModuleDependency>()
|
||||
.map { it.copy() }
|
||||
.map { dependency ->
|
||||
dependency.artifact {
|
||||
name = dependency.name
|
||||
type = artifactType
|
||||
extension = "jar"
|
||||
classifier = artifactType
|
||||
}
|
||||
dependency
|
||||
}
|
||||
|
||||
files(configurations.detachedConfiguration(*deps.toTypedArray())
|
||||
.resolvedConfiguration.lenientConfiguration.artifacts
|
||||
.filter { it.classifier == artifactType }
|
||||
.map { zipTree(it.file) })
|
||||
.resolvedConfiguration.lenientConfiguration.artifacts
|
||||
.filter { it.classifier == artifactType }
|
||||
.map { zipTree(it.file) })
|
||||
}
|
||||
tasks.register<Jar>("sourcesJar") {
|
||||
from({
|
||||
|
@ -161,11 +162,26 @@ fun Project.applyLibrariesConfiguration() {
|
|||
applyCommonArtifactoryConfig()
|
||||
}
|
||||
|
||||
// A horrible hack because `softwareComponentFactory` has to be gotten via plugin
|
||||
// gradle why
|
||||
internal open class LibsConfigPluginHack @Inject constructor(
|
||||
private val softwareComponentFactory: SoftwareComponentFactory
|
||||
private val softwareComponentFactory: SoftwareComponentFactory
|
||||
) : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
val libsComponents = softwareComponentFactory.adhoc("libs")
|
||||
project.components.add(libsComponents)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.constrainDependenciesToLibsCore() {
|
||||
evaluationDependsOn(":worldguard-libs:core")
|
||||
val coreDeps = project(":worldguard-libs:core").configurations["shade"].dependencies
|
||||
.filterIsInstance<ExternalModuleDependency>()
|
||||
dependencies.constraints {
|
||||
for (coreDep in coreDeps) {
|
||||
add("shade", "${coreDep.group}:${coreDep.name}:${coreDep.version}") {
|
||||
because("libs should align with libs:core")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,74 +1,27 @@
|
|||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.component.AdhocComponentWithVariants
|
||||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.api.plugins.quality.CheckstyleExtension
|
||||
import org.gradle.api.publish.PublishingExtension
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
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.named
|
||||
import org.gradle.kotlin.dsl.register
|
||||
import org.gradle.kotlin.dsl.withType
|
||||
import org.gradle.kotlin.dsl.the
|
||||
|
||||
fun Project.applyPlatformAndCoreConfiguration() {
|
||||
fun Project.applyPlatformAndCoreConfiguration(javaRelease: Int = 17) {
|
||||
applyCommonConfiguration()
|
||||
apply(plugin = "java")
|
||||
apply(plugin = "eclipse")
|
||||
apply(plugin = "idea")
|
||||
apply(plugin = "maven-publish")
|
||||
apply(plugin = "checkstyle")
|
||||
apply(plugin = "com.jfrog.artifactory")
|
||||
applyCommonJavaConfiguration(
|
||||
sourcesJar = true,
|
||||
javaRelease = javaRelease,
|
||||
banSlf4j = false
|
||||
)
|
||||
|
||||
ext["internalVersion"] = "$version+${rootProject.ext["gitCommitHash"]}"
|
||||
|
||||
configure<CheckstyleExtension> {
|
||||
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
|
||||
toolVersion = "8.34"
|
||||
}
|
||||
|
||||
tasks.withType<Test>().configureEach {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
"compileOnly"("com.google.code.findbugs:jsr305:3.0.2")
|
||||
"testCompileOnly"("com.google.code.findbugs:jsr305:3.0.2")
|
||||
"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 as StandardJavadocDocletOptions).apply {
|
||||
addStringOption("Xdoclint:none", "-quiet")
|
||||
tags(
|
||||
"apiNote:a:API Note:",
|
||||
"implSpec:a:Implementation Requirements:",
|
||||
"implNote:a:Implementation Note:"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
the<JavaPluginExtension>().withJavadocJar()
|
||||
|
||||
if (name == "worldguard-core" || name == "worldguard-bukkit") {
|
||||
the<JavaPluginExtension>().withSourcesJar()
|
||||
}
|
||||
|
||||
tasks.named("check").configure {
|
||||
dependsOn("checkstyleMain", "checkstyleTest")
|
||||
}
|
||||
|
||||
configure<PublishingExtension> {
|
||||
publications {
|
||||
register<MavenPublication>("maven") {
|
||||
|
@ -105,8 +58,10 @@ fun Project.applyShadowConfiguration() {
|
|||
exclude("GradleStart**")
|
||||
exclude(".cache")
|
||||
exclude("LICENSE*")
|
||||
exclude("META-INF/maven/**")
|
||||
}
|
||||
val javaComponent = components["java"] as AdhocComponentWithVariants
|
||||
// I don't think we want this published (it's the shadow jar)
|
||||
javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) {
|
||||
skip()
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
object Versions {
|
||||
// const val PISTON = "0.4.3"
|
||||
// const val AUTO_VALUE = "1.6.5"
|
||||
const val WORLDEDIT = "7.2.7"
|
||||
const val JUNIT = "5.7.0"
|
||||
const val SQUIRRELID = "0.3.0"
|
||||
const val GUAVA = "31.0.1-jre"
|
||||
const val MOCKITO = "3.7.7"
|
||||
// const val PISTON = "0.4.3"
|
||||
// const val AUTO_VALUE = "1.6.5"
|
||||
const val WORLDEDIT = "7.3.0"
|
||||
const val JUNIT = "5.9.1"
|
||||
const val MOCKITO = "4.9.0"
|
||||
const val SQUIRRELID = "0.3.2"
|
||||
const val GUAVA = "31.1-jre"
|
||||
const val FINDBUGS = "3.0.2"
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<allow pkg="org.bstats.charts"/>
|
||||
<allow pkg="io.papermc.lib"/>
|
||||
<allow pkg="com.destroystokyo.paper"/>
|
||||
<allow pkg="co.aikar.timings.lib" />
|
||||
<allow pkg="io.papermc.paper"/>
|
||||
<allow pkg="org.spigotmc" />
|
||||
</subpackage>
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
group=com.sk89q.worldguard
|
||||
version=7.0.7
|
||||
version=7.1.0-SNAPSHOT
|
||||
|
|
Binary file not shown.
|
@ -1,5 +1,7 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
|
@ -80,13 +80,11 @@ do
|
|||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
@ -133,22 +131,29 @@ location of your Java installation."
|
|||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
|
@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
|
|||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
|
@ -205,6 +214,12 @@ set -- \
|
|||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
|
@ -25,7 +25,8 @@
|
|||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
|
@ -40,13 +41,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
|
@ -56,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
|
@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
|
|
@ -10,15 +10,12 @@ applyShadowConfiguration()
|
|||
repositories {
|
||||
maven {
|
||||
name = "paper"
|
||||
url = uri("https://papermc.io/repo/repository/maven-public/")
|
||||
url = uri("https://repo.papermc.io/repository/maven-public/")
|
||||
}
|
||||
maven {
|
||||
name = "bstats"
|
||||
url = uri("https://repo.codemc.org/repository/maven-public")
|
||||
}
|
||||
maven {
|
||||
name = "aikar-timings"
|
||||
url = uri("https://repo.aikar.co/nexus/content/groups/aikar/")
|
||||
// TODO: Remove this once paper updated to adventure release
|
||||
name = "adventure-snapshots"
|
||||
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,16 +25,15 @@ configurations {
|
|||
|
||||
dependencies {
|
||||
"api"(project(":worldguard-core"))
|
||||
"compileOnly"("io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT")
|
||||
"runtimeOnly"("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT") {
|
||||
"compileOnly"("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT")
|
||||
"runtimeOnly"("org.spigotmc:spigot-api:1.20.6-R0.1-SNAPSHOT") {
|
||||
exclude("junit", "junit")
|
||||
}
|
||||
"api"("com.sk89q.worldedit:worldedit-bukkit:${Versions.WORLDEDIT}") { isTransitive = false }
|
||||
"implementation"("com.google.guava:guava:${Versions.GUAVA}")
|
||||
"compileOnly"("com.sk89q:commandbook:2.3") { isTransitive = false }
|
||||
"shadeOnly"("io.papermc:paperlib:1.0.7")
|
||||
"shadeOnly"("org.bstats:bstats-bukkit:2.1.0")
|
||||
"shadeOnly"("co.aikar:minecraft-timings:1.0.4")
|
||||
"shadeOnly"("io.papermc:paperlib:1.0.8")
|
||||
"shadeOnly"("org.bstats:bstats-bukkit:3.0.1")
|
||||
}
|
||||
|
||||
tasks.named<Copy>("processResources") {
|
||||
|
|
|
@ -37,7 +37,6 @@ public class BukkitConfigurationManager extends YamlConfigurationManager {
|
|||
|
||||
private boolean hasCommandBookGodMode;
|
||||
boolean extraStats;
|
||||
boolean timedSessionHandlers;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
|
@ -57,7 +56,6 @@ public class BukkitConfigurationManager extends YamlConfigurationManager {
|
|||
public void load() {
|
||||
super.load();
|
||||
this.extraStats = getConfig().getBoolean("custom-metrics-charts", true);
|
||||
this.timedSessionHandlers = getConfig().getBoolean("extra-timings.session-handlers", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -244,7 +244,7 @@ public class BukkitWorldConfiguration extends YamlWorldConfiguration {
|
|||
disableDeathMessages = getBoolean("player-damage.disable-death-messages", false);
|
||||
|
||||
signChestProtection = getBoolean("chest-protection.enable", false);
|
||||
disableSignChestProtectionCheck = getBoolean("chest-protection.disable-off-check", false);
|
||||
disableSignChestProtectionCheck = getBoolean("chest-protection.disable-off-check", true);
|
||||
if (signChestProtection) {
|
||||
log.warning("Sign-based chest protection is deprecated for removal in a future version. See https://worldguard.enginehub.org/en/latest/chest-protection/ for details.");
|
||||
} else {
|
||||
|
@ -256,6 +256,8 @@ public class BukkitWorldConfiguration extends YamlWorldConfiguration {
|
|||
|
||||
disableCreatureTurtleEggTrampling = getBoolean("turtle-egg.disable-creature-trampling", false);
|
||||
disablePlayerTurtleEggTrampling = getBoolean("turtle-egg.disable-player-trampling", false);
|
||||
disableCreatureSnifferEggTrampling = getBoolean("sniffer-egg.disable-creature-trampling", false);
|
||||
disablePlayerSnifferEggTrampling = getBoolean("sniffer-egg.disable-player-trampling", false);
|
||||
|
||||
disallowedLightningBlocks = new HashSet<>(convertLegacyBlocks(getStringList("weather.prevent-lightning-strike-blocks", null)));
|
||||
preventLightningFire = getBoolean("weather.disable-lightning-strike-fire", false);
|
||||
|
@ -277,9 +279,11 @@ public class BukkitWorldConfiguration extends YamlWorldConfiguration {
|
|||
disableMyceliumSpread = getBoolean("dynamics.disable-mycelium-spread", false);
|
||||
disableVineGrowth = getBoolean("dynamics.disable-vine-growth", false);
|
||||
disableRockGrowth = getBoolean("dynamics.disable-rock-growth", false);
|
||||
disableSculkGrowth = getBoolean("dynamics.disable-sculk-growth", false);
|
||||
disableCropGrowth = getBoolean("dynamics.disable-crop-growth", false);
|
||||
disableSoilDehydration = getBoolean("dynamics.disable-soil-dehydration", false);
|
||||
disableCoralBlockFade = getBoolean("dynamics.disable-coral-block-fade", false);
|
||||
disableCopperBlockFade = getBoolean("dynamics.disable-copper-block-fade", false);
|
||||
allowedSnowFallOver = new HashSet<>(convertLegacyBlocks(getStringList("dynamics.snow-fall-blocks", null)));
|
||||
|
||||
useRegions = getBoolean("regions.enable", true);
|
||||
|
|
|
@ -34,6 +34,7 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
|||
import com.sk89q.worldguard.util.profile.resolver.PaperPlayerService;
|
||||
import com.sk89q.worldguard.bukkit.protection.events.flags.FlagContextCreateEvent;
|
||||
import com.sk89q.worldguard.bukkit.session.BukkitSessionManager;
|
||||
import com.sk89q.worldguard.bukkit.util.report.DatapackReport;
|
||||
import com.sk89q.worldguard.bukkit.util.report.PerformanceReport;
|
||||
import com.sk89q.worldguard.bukkit.util.report.PluginReport;
|
||||
import com.sk89q.worldguard.bukkit.util.report.SchedulerReport;
|
||||
|
@ -138,7 +139,6 @@ public class BukkitWorldGuardPlatform implements WorldGuardPlatform {
|
|||
sessionManager = new BukkitSessionManager();
|
||||
configuration = new BukkitConfigurationManager(WorldGuardPlugin.inst());
|
||||
configuration.load();
|
||||
sessionManager.setUsingTimings(configuration.timedSessionHandlers);
|
||||
regionContainer = new BukkitRegionContainer(WorldGuardPlugin.inst());
|
||||
regionContainer.initialize();
|
||||
debugHandler = new BukkitDebugHandler(WorldGuardPlugin.inst());
|
||||
|
@ -146,6 +146,7 @@ public class BukkitWorldGuardPlatform implements WorldGuardPlatform {
|
|||
|
||||
@Override
|
||||
public void unload() {
|
||||
sessionManager.shutdown();
|
||||
configuration.unload();
|
||||
regionContainer.shutdown();
|
||||
}
|
||||
|
@ -238,6 +239,7 @@ public class BukkitWorldGuardPlatform implements WorldGuardPlatform {
|
|||
report.add(new ServicesReport());
|
||||
report.add(new WorldReport());
|
||||
report.add(new PerformanceReport());
|
||||
if (PaperLib.isPaper()) report.add(new DatapackReport());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -264,7 +266,7 @@ public class BukkitWorldGuardPlatform implements WorldGuardPlatform {
|
|||
if (radius > 0) {
|
||||
BlockVector3 spawnLoc = BukkitAdapter.asBlockVector(bWorld.getSpawnLocation());
|
||||
return new ProtectedCuboidRegion("__spawn_protection__",
|
||||
spawnLoc.subtract(radius, 0, radius).withY(world.getMinimumPoint().getY()),
|
||||
spawnLoc.subtract(radius, 0, radius).withY(world.getMinimumPoint().y()),
|
||||
spawnLoc.add(radius, 0, radius).withY(world.getMaxY()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,10 +60,12 @@ import com.sk89q.worldguard.bukkit.listener.WorldGuardWorldListener;
|
|||
import com.sk89q.worldguard.bukkit.listener.WorldRulesListener;
|
||||
import com.sk89q.worldguard.bukkit.session.BukkitSessionManager;
|
||||
import com.sk89q.worldguard.bukkit.util.ClassSourceValidator;
|
||||
import com.sk89q.worldguard.bukkit.util.Entities;
|
||||
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;
|
||||
|
@ -158,11 +160,9 @@ public class WorldGuardPlugin extends JavaPlugin {
|
|||
reg.register(ToggleCommands.class);
|
||||
reg.register(ProtectionCommands.class);
|
||||
|
||||
getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
|
||||
if (!platform.getGlobalStateManager().hasCommandBookGodMode()) {
|
||||
reg.register(GeneralCommands.class);
|
||||
}
|
||||
}, 0L);
|
||||
if (!platform.getGlobalStateManager().hasCommandBookGodMode()) {
|
||||
reg.register(GeneralCommands.class);
|
||||
}
|
||||
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, sessionManager, BukkitSessionManager.RUN_DELAY, BukkitSessionManager.RUN_DELAY);
|
||||
|
||||
|
@ -213,6 +213,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
|
||||
|
@ -421,8 +422,9 @@ public class WorldGuardPlugin extends JavaPlugin {
|
|||
}
|
||||
|
||||
public Actor wrapCommandSender(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
return wrapPlayer((Player) sender);
|
||||
if (sender instanceof Player player) {
|
||||
if (Entities.isNPC(player)) return null;
|
||||
return wrapPlayer(player);
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -24,9 +24,12 @@ import com.google.common.collect.Sets;
|
|||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.internal.WGMetadata;
|
||||
import com.sk89q.worldguard.bukkit.util.Entities;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.AreaEffectCloud;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
@ -106,6 +109,12 @@ public final class Cause {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (object instanceof Tameable tameable && tameable.isTamed()) {
|
||||
// if they're tamed but also the root cause, the owner is offline
|
||||
// otherwise the owner will be the root cause (and known)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (object instanceof TNTPrimed || object instanceof Vehicle) {
|
||||
if (!PaperLib.isPaper()) {
|
||||
return false;
|
||||
|
@ -134,8 +143,8 @@ public final class Cause {
|
|||
@Nullable
|
||||
public Player getFirstPlayer() {
|
||||
for (Object object : causes) {
|
||||
if (object instanceof Player) {
|
||||
return (Player) object;
|
||||
if (object instanceof Player p && !Entities.isNPC(p)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,8 +154,8 @@ public final class Cause {
|
|||
@Nullable
|
||||
public Entity getFirstEntity() {
|
||||
for (Object object : causes) {
|
||||
if (object instanceof Entity) {
|
||||
return (Entity) object;
|
||||
if (object instanceof Entity e) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,8 +165,8 @@ public final class Cause {
|
|||
@Nullable
|
||||
public Entity getFirstNonPlayerEntity() {
|
||||
for (Object object : causes) {
|
||||
if (object instanceof Entity && !(object instanceof Player)) {
|
||||
return (Entity) object;
|
||||
if (object instanceof Entity e && (!(object instanceof Player) || Entities.isNPC(e))) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,8 +176,8 @@ public final class Cause {
|
|||
@Nullable
|
||||
public Block getFirstBlock() {
|
||||
for (Object object : causes) {
|
||||
if (object instanceof Block) {
|
||||
return (Block) object;
|
||||
if (object instanceof Block b) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,9 +308,24 @@ public final class Cause {
|
|||
} else if (o instanceof AreaEffectCloud) {
|
||||
indirect = true;
|
||||
addAll(((AreaEffectCloud) o).getSource());
|
||||
} else if (o instanceof Tameable) {
|
||||
} else if (o instanceof Tameable tameable) {
|
||||
indirect = true;
|
||||
addAll(((Tameable) o).getOwner());
|
||||
if (PaperLib.isPaper()) {
|
||||
UUID ownerId = tameable.getOwnerUniqueId();
|
||||
if (ownerId != null) {
|
||||
Player owner = Bukkit.getPlayer(ownerId);
|
||||
if (owner != null) {
|
||||
addAll(owner);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// this will cause offline player loads if the player is offline
|
||||
// too bad for spigot users
|
||||
AnimalTamer owner = tameable.getOwner();
|
||||
if (owner instanceof OfflinePlayer player) {
|
||||
addAll(player.getPlayer()); // player object if online, else null
|
||||
}
|
||||
}
|
||||
} else if (o instanceof Creature && ((Creature) o).getTarget() != null) {
|
||||
indirect = true;
|
||||
addAll(((Creature) o).getTarget());
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
|||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||
import com.sk89q.worldguard.bukkit.util.Entities;
|
||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
import com.sk89q.worldguard.domains.Association;
|
||||
import com.sk89q.worldguard.protection.association.DelayedRegionOverlapAssociation;
|
||||
|
@ -124,18 +125,18 @@ class AbstractListener implements Listener {
|
|||
|
||||
if (!cause.isKnown()) {
|
||||
return Associables.constant(Association.NON_MEMBER);
|
||||
} else if (rootCause instanceof Player) {
|
||||
return getPlugin().wrapPlayer((Player) rootCause);
|
||||
} else if (rootCause instanceof OfflinePlayer) {
|
||||
return getPlugin().wrapOfflinePlayer((OfflinePlayer) rootCause);
|
||||
} else if (rootCause instanceof Entity) {
|
||||
} else if (rootCause instanceof Player player && !Entities.isNPC(player)) {
|
||||
return getPlugin().wrapPlayer(player);
|
||||
} else if (rootCause instanceof OfflinePlayer offlinePlayer) {
|
||||
return getPlugin().wrapOfflinePlayer(offlinePlayer);
|
||||
} else if (rootCause instanceof Entity entity) {
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
final Entity entity = (Entity) rootCause;
|
||||
BukkitWorldConfiguration config = getWorldConfig(entity.getWorld());
|
||||
Location loc;
|
||||
if (PaperLib.isPaper() && config.usePaperEntityOrigin) {
|
||||
loc = entity.getOrigin();
|
||||
if (loc == null) {
|
||||
// Origin world may be null, and thus a Location with a null world created, which cannot be adapted to a WorldEdit location
|
||||
if (loc == null || loc.getWorld() == null) {
|
||||
loc = entity.getLocation();
|
||||
}
|
||||
} else {
|
||||
|
@ -143,9 +144,9 @@ class AbstractListener implements Listener {
|
|||
}
|
||||
return new DelayedRegionOverlapAssociation(query, BukkitAdapter.adapt(loc),
|
||||
config.useMaxPriorityAssociation);
|
||||
} else if (rootCause instanceof Block) {
|
||||
} else if (rootCause instanceof Block block) {
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
Location loc = ((Block) rootCause).getLocation();
|
||||
Location loc = block.getLocation();
|
||||
return new DelayedRegionOverlapAssociation(query, BukkitAdapter.adapt(loc),
|
||||
getWorldConfig(loc.getWorld()).useMaxPriorityAssociation);
|
||||
} else {
|
||||
|
|
|
@ -35,6 +35,10 @@ import org.bukkit.inventory.ItemStack;
|
|||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Handles blocked potions.
|
||||
|
@ -50,43 +54,50 @@ public class BlockedPotionsListener extends AbstractListener {
|
|||
super(plugin);
|
||||
}
|
||||
|
||||
private PotionEffectType getBlockedEffectByArrow(Arrow arrow, BukkitWorldConfiguration wcfg) {
|
||||
List<PotionEffect> effects = new ArrayList<>();
|
||||
PotionType potionType = arrow.getBasePotionType();
|
||||
if (potionType != null) {
|
||||
effects.addAll(potionType.getPotionEffects());
|
||||
}
|
||||
effects.addAll(arrow.getCustomEffects());
|
||||
for (PotionEffect potionEffect : effects) {
|
||||
if (wcfg.blockPotions.contains(potionEffect.getType())) {
|
||||
return potionEffect.getType();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onProjectile(DamageEntityEvent event) {
|
||||
if (event.getOriginalEvent() instanceof EntityDamageByEntityEvent) {
|
||||
EntityDamageByEntityEvent originalEvent = (EntityDamageByEntityEvent) event.getOriginalEvent();
|
||||
if (Entities.isPotionArrow(originalEvent.getDamager())) { // should take care of backcompat
|
||||
BukkitWorldConfiguration wcfg = getWorldConfig(event.getWorld());
|
||||
PotionEffectType blockedEffect = null;
|
||||
if (originalEvent.getDamager() instanceof SpectralArrow) {
|
||||
if (wcfg.blockPotions.contains(PotionEffectType.GLOWING)) {
|
||||
blockedEffect = PotionEffectType.GLOWING;
|
||||
}
|
||||
} else if (originalEvent.getDamager() instanceof Arrow) {
|
||||
Arrow tippedArrow = (Arrow) originalEvent.getDamager();
|
||||
PotionEffectType baseEffect = tippedArrow.getBasePotionData().getType().getEffectType();
|
||||
if (wcfg.blockPotions.contains(baseEffect)) {
|
||||
blockedEffect = baseEffect;
|
||||
} else {
|
||||
for (PotionEffect potionEffect : tippedArrow.getCustomEffects()) {
|
||||
if (wcfg.blockPotions.contains(potionEffect.getType())) {
|
||||
blockedEffect = potionEffect.getType();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (blockedEffect != null) {
|
||||
Player player = event.getCause().getFirstPlayer();
|
||||
if (player != null) {
|
||||
if (getPlugin().hasPermission(player, "worldguard.override.potions")) {
|
||||
return;
|
||||
}
|
||||
player.sendMessage(ChatColor.RED + "Sorry, arrows with "
|
||||
+ blockedEffect.getName() + " are presently disabled.");
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (!(event.getOriginalEvent() instanceof EntityDamageByEntityEvent originalEvent)) {
|
||||
return;
|
||||
}
|
||||
if (!Entities.isPotionArrow(originalEvent.getDamager())) {
|
||||
return;
|
||||
}
|
||||
|
||||
BukkitWorldConfiguration wcfg = getWorldConfig(event.getWorld());
|
||||
PotionEffectType blockedEffect = null;
|
||||
if (originalEvent.getDamager() instanceof SpectralArrow) {
|
||||
if (wcfg.blockPotions.contains(PotionEffectType.GLOWING)) {
|
||||
blockedEffect = PotionEffectType.GLOWING;
|
||||
}
|
||||
} else if (originalEvent.getDamager() instanceof Arrow arrow) {
|
||||
blockedEffect = getBlockedEffectByArrow(arrow, wcfg);
|
||||
}
|
||||
if (blockedEffect != null) {
|
||||
Player player = event.getCause().getFirstPlayer();
|
||||
if (player != null) {
|
||||
if (getPlugin().hasPermission(player, "worldguard.override.potions")) {
|
||||
return;
|
||||
}
|
||||
player.sendMessage(ChatColor.RED + "Sorry, arrows with "
|
||||
+ blockedEffect.getName() + " are presently disabled.");
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,25 +115,20 @@ public class BlockedPotionsListener extends AbstractListener {
|
|||
if (!wcfg.blockPotions.isEmpty()) {
|
||||
PotionEffectType blockedEffect = null;
|
||||
|
||||
PotionMeta meta;
|
||||
if (item.getItemMeta() instanceof PotionMeta) {
|
||||
meta = ((PotionMeta) item.getItemMeta());
|
||||
} else {
|
||||
return; // ok...?
|
||||
if (!(item.getItemMeta() instanceof PotionMeta meta)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the first blocked effect
|
||||
PotionEffectType baseEffect = meta.getBasePotionData().getType().getEffectType();
|
||||
if (wcfg.blockPotions.contains(baseEffect)) {
|
||||
blockedEffect = baseEffect;
|
||||
List<PotionEffect> effects = new ArrayList<>();
|
||||
if (meta.getBasePotionType() != null) {
|
||||
effects.addAll(meta.getBasePotionType().getPotionEffects());
|
||||
}
|
||||
|
||||
if (blockedEffect == null && meta.hasCustomEffects()) {
|
||||
for (PotionEffect effect : meta.getCustomEffects()) {
|
||||
if (wcfg.blockPotions.contains(effect.getType())) {
|
||||
blockedEffect = effect.getType();
|
||||
break;
|
||||
}
|
||||
effects.addAll(meta.getCustomEffects());
|
||||
for (PotionEffect potionEffect : effects) {
|
||||
if (wcfg.blockPotions.contains(potionEffect.getType())) {
|
||||
blockedEffect = potionEffect.getType();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,6 @@ package com.sk89q.worldguard.bukkit.listener;
|
|||
import static com.sk89q.worldguard.bukkit.cause.Cause.create;
|
||||
|
||||
import com.destroystokyo.paper.event.entity.EntityZapEvent;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||
import com.sk89q.worldguard.bukkit.event.DelegateEvent;
|
||||
|
@ -49,6 +47,7 @@ import com.sk89q.worldguard.bukkit.util.Materials;
|
|||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import io.papermc.paper.event.player.PlayerOpenSignEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
|
@ -115,6 +114,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
|||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityInteractEvent;
|
||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.event.entity.EntityTameEvent;
|
||||
import org.bukkit.event.entity.EntityUnleashEvent;
|
||||
import org.bukkit.event.entity.ExpBottleEvent;
|
||||
|
@ -142,12 +142,10 @@ import org.bukkit.event.vehicle.VehicleDamageEvent;
|
|||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
|
@ -165,17 +163,6 @@ public class EventAbstractionListener extends AbstractListener {
|
|||
private final EventDebounce<BlockPistonRetractKey> pistonRetractDebounce = EventDebounce.create(5000);
|
||||
private final EventDebounce<BlockPistonExtendKey> pistonExtendDebounce = EventDebounce.create(5000);
|
||||
|
||||
private static final boolean HAS_SNAPSHOT_INVHOLDER;
|
||||
static {
|
||||
boolean temp;
|
||||
try {
|
||||
Inventory.class.getMethod("getHolder", boolean.class);
|
||||
temp = true;
|
||||
} catch (NoSuchMethodException e) {
|
||||
temp = false;
|
||||
}
|
||||
HAS_SNAPSHOT_INVHOLDER = temp;
|
||||
}
|
||||
/**
|
||||
* Construct the listener.
|
||||
*
|
||||
|
@ -467,7 +454,9 @@ public class EventAbstractionListener extends AbstractListener {
|
|||
switch (event.getAction()) {
|
||||
case PHYSICAL:
|
||||
if (event.useInteractedBlock() != Result.DENY) {
|
||||
if (clicked.getType() == Material.FARMLAND || clicked.getType() == Material.TURTLE_EGG) {
|
||||
if (clicked.getType() == Material.FARMLAND ||
|
||||
clicked.getType() == Material.TURTLE_EGG ||
|
||||
clicked.getType() == Material.SNIFFER_EGG) {
|
||||
BreakBlockEvent breakDelagate = new BreakBlockEvent(event, cause, clicked);
|
||||
breakDelagate.setSilent(true);
|
||||
breakDelagate.getRelevantFlags().add(Flags.TRAMPLE_BLOCKS);
|
||||
|
@ -493,7 +482,7 @@ public class EventAbstractionListener extends AbstractListener {
|
|||
firedEvent.setSilent(true);
|
||||
}
|
||||
interactDebounce.debounce(clicked, event.getPlayer(), event, firedEvent);
|
||||
if (event.useInteractedBlock() == Result.DENY) {
|
||||
if (event.useInteractedBlock() == Result.DENY && !firedEvent.isSilent()) {
|
||||
playDenyEffect(player, clicked.getLocation().add(0, 1, 0));
|
||||
}
|
||||
}
|
||||
|
@ -613,9 +602,7 @@ public class EventAbstractionListener extends AbstractListener {
|
|||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onSignChange(SignChangeEvent event) {
|
||||
Events.fireToCancel(event, new UseBlockEvent(event, create(event.getPlayer()), event.getBlock()));
|
||||
|
||||
if (event.isCancelled()) {
|
||||
if (Events.fireToCancel(event, new PlaceBlockEvent(event, create(event.getPlayer()), event.getBlock()))) {
|
||||
playDenyEffect(event.getPlayer(), event.getBlock().getLocation().add(0.5, 0.5, 0.5));
|
||||
}
|
||||
}
|
||||
|
@ -933,6 +920,12 @@ public class EventAbstractionListener extends AbstractListener {
|
|||
pickupDebounce.debounce(event.getPlayer(), item, event, new DestroyEntityEvent(event, create(event.getPlayer()), event.getItem()));
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEntityPickupItem(EntityPickupItemEvent event) {
|
||||
Item item = event.getItem();
|
||||
pickupDebounce.debounce(event.getEntity(), item, event, new DestroyEntityEvent(event, create(event.getEntity()), event.getItem()));
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
Events.fireToCancel(event, new SpawnEntityEvent(event, create(event.getPlayer()), event.getItemDrop()));
|
||||
|
@ -963,12 +956,7 @@ public class EventAbstractionListener extends AbstractListener {
|
|||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onInventoryMoveItem(InventoryMoveItemEvent event) {
|
||||
InventoryHolder causeHolder;
|
||||
if (HAS_SNAPSHOT_INVHOLDER) {
|
||||
causeHolder = event.getInitiator().getHolder(false);
|
||||
} else {
|
||||
causeHolder = event.getInitiator().getHolder();
|
||||
}
|
||||
InventoryHolder causeHolder = PaperLib.getHolder(event.getInitiator(), false).getHolder();
|
||||
|
||||
WorldConfiguration wcfg = null;
|
||||
if (causeHolder instanceof Hopper
|
||||
|
@ -982,15 +970,8 @@ public class EventAbstractionListener extends AbstractListener {
|
|||
Entry entry;
|
||||
|
||||
if ((entry = moveItemDebounce.tryDebounce(event)) != null) {
|
||||
InventoryHolder sourceHolder;
|
||||
InventoryHolder targetHolder;
|
||||
/*if (HAS_SNAPSHOT_INVHOLDER) {
|
||||
sourceHolder = event.getSource().getHolder(false);
|
||||
targetHolder = event.getDestination().getHolder(false);
|
||||
} else {*/
|
||||
sourceHolder = event.getSource().getHolder();
|
||||
targetHolder = event.getDestination().getHolder();
|
||||
//}
|
||||
InventoryHolder sourceHolder = PaperLib.getHolder(event.getSource(), false).getHolder();
|
||||
InventoryHolder targetHolder = PaperLib.getHolder(event.getDestination(), false).getHolder();
|
||||
|
||||
Cause cause;
|
||||
|
||||
|
@ -1105,9 +1086,9 @@ public class EventAbstractionListener extends AbstractListener {
|
|||
public void onLingeringApply(AreaEffectCloudApplyEvent event) {
|
||||
AreaEffectCloud entity = event.getEntity();
|
||||
List<PotionEffect> effects = new ArrayList<>();
|
||||
PotionEffectType baseEffectType = entity.getBasePotionData().getType().getEffectType();
|
||||
if (baseEffectType != null) {
|
||||
effects.add(new PotionEffect(baseEffectType, 0, 0));
|
||||
List<PotionEffect> baseEffectTypes = entity.getBasePotionType() == null ? null : entity.getBasePotionType().getPotionEffects();
|
||||
if (baseEffectTypes != null) {
|
||||
effects.addAll(baseEffectTypes);
|
||||
}
|
||||
if (entity.hasCustomEffects()) {
|
||||
effects.addAll(entity.getCustomEffects());
|
||||
|
@ -1192,14 +1173,17 @@ public class EventAbstractionListener extends AbstractListener {
|
|||
|
||||
if (item != null && item.getType() == Material.END_CRYSTAL) { /*&& placed.getType() == Material.BEDROCK) {*/ // in vanilla you can only place them on bedrock but who knows what plugins will add
|
||||
// may be overprotective as a result, but better than being underprotective
|
||||
Events.fireToCancel(event, new SpawnEntityEvent(event, cause, placed.getLocation().add(0.5, 0, 0.5), EntityType.ENDER_CRYSTAL));
|
||||
Events.fireToCancel(event, new SpawnEntityEvent(event, cause, placed.getLocation().add(0.5, 0, 0.5), EntityType.END_CRYSTAL));
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle created spawn eggs
|
||||
if (item != null && Materials.isSpawnEgg(item.getType())) {
|
||||
Events.fireToCancel(event, new SpawnEntityEvent(event, cause, placed.getLocation().add(0.5, 0, 0.5), Materials.getEntitySpawnEgg(item.getType())));
|
||||
return;
|
||||
if (item != null) {
|
||||
EntityType possibleEntityType = Materials.getEntitySpawnEgg(item.getType());
|
||||
if (possibleEntityType != null) {
|
||||
Events.fireToCancel(event, new SpawnEntityEvent(event, cause, placed.getLocation().add(0.5, 0, 0.5), possibleEntityType));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// handle water/lava placement
|
||||
|
@ -1215,8 +1199,7 @@ public class EventAbstractionListener extends AbstractListener {
|
|||
return;
|
||||
}
|
||||
|
||||
if (holder instanceof Entity) {
|
||||
Entity entity = (Entity) holder;
|
||||
if (holder instanceof Entity entity) {
|
||||
Material mat = Materials.getRelatedMaterial((entity).getType());
|
||||
UseEntityEvent useEntityEvent = new UseEntityEvent(originalEvent, cause, entity);
|
||||
if (mat != null && hasInteractBypass((entity).getWorld(), mat)) {
|
||||
|
@ -1224,8 +1207,7 @@ public class EventAbstractionListener extends AbstractListener {
|
|||
}
|
||||
Events.fireToCancel(originalEvent, useEntityEvent);
|
||||
} else {
|
||||
if (holder instanceof BlockState) {
|
||||
final BlockState block = (BlockState) holder;
|
||||
if (holder instanceof BlockState block && block.isPlaced()) {
|
||||
final UseBlockEvent useBlockEvent = new UseBlockEvent(originalEvent, cause, block.getBlock());
|
||||
if (hasInteractBypass(block.getWorld(), block.getType())) {
|
||||
useBlockEvent.setAllowed(true);
|
||||
|
@ -1284,5 +1266,13 @@ public class EventAbstractionListener extends AbstractListener {
|
|||
public void onEntityTransform(EntityZapEvent event) {
|
||||
Events.fireToCancel(event, new DamageEntityEvent(event, create(event.getBolt()), event.getEntity()));
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onSignOpen(PlayerOpenSignEvent event) {
|
||||
if (event.getCause() == PlayerOpenSignEvent.Cause.INTERACT) {
|
||||
// other cases are handled by other events
|
||||
Events.fireToCancel(event, new UseBlockEvent(event, create(event.getPlayer()), event.getSign().getBlock()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package com.sk89q.worldguard.bukkit.listener;
|
|||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.util.Entities;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -57,9 +58,9 @@ 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 player = (Player) victim;
|
||||
if (victim instanceof Player player) {
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
|
||||
if (isInvincible(localPlayer)) {
|
||||
|
@ -87,9 +88,9 @@ 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 player = (Player) entity;
|
||||
if (entity instanceof Player player) {
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
|
||||
if (isInvincible(localPlayer)) {
|
||||
|
@ -100,8 +101,9 @@ public class InvincibilityListener extends AbstractListener {
|
|||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
if (Entities.isNPC(event.getEntity())) return;
|
||||
|
||||
if (event.getEntity() instanceof Player player) {
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
|
||||
if (event.getFoodLevel() < player.getFoodLevel() && isInvincible(localPlayer)) {
|
||||
|
|
|
@ -25,23 +25,21 @@ import com.sk89q.worldguard.WorldGuard;
|
|||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.session.MoveType;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.AbstractHorse;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityMountEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.spigotmc.event.entity.EntityMountEvent;
|
||||
|
||||
public class PlayerMoveListener extends AbstractListener {
|
||||
|
||||
|
@ -54,13 +52,10 @@ public class PlayerMoveListener extends AbstractListener {
|
|||
if (WorldGuard.getInstance().getPlatform().getGlobalStateManager().usePlayerMove) {
|
||||
PluginManager pm = getPlugin().getServer().getPluginManager();
|
||||
pm.registerEvents(this, getPlugin());
|
||||
if (PaperLib.isSpigot()) {
|
||||
pm.registerEvents(new EntityMountListener(), getPlugin());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
LocalPlayer player = getPlugin().wrapPlayer(event.getPlayer());
|
||||
|
||||
|
@ -99,7 +94,7 @@ public class PlayerMoveListener extends AbstractListener {
|
|||
moveType = MoveType.GLIDE;
|
||||
} else if (event.getPlayer().isSwimming()) {
|
||||
moveType = MoveType.SWIM;
|
||||
} else if (event.getPlayer().getVehicle() != null && event.getPlayer().getVehicle() instanceof Horse) {
|
||||
} else if (event.getPlayer().getVehicle() != null && event.getPlayer().getVehicle() instanceof AbstractHorse) {
|
||||
moveType = MoveType.RIDE;
|
||||
}
|
||||
com.sk89q.worldedit.util.Location weLocation = session.testMoveTo(localPlayer, BukkitAdapter.adapt(to), moveType);
|
||||
|
@ -148,18 +143,18 @@ public class PlayerMoveListener extends AbstractListener {
|
|||
if (loc != null) {
|
||||
player.teleport(BukkitAdapter.adapt(loc));
|
||||
}
|
||||
|
||||
session.uninitialize(localPlayer);
|
||||
}
|
||||
|
||||
private class EntityMountListener implements Listener {
|
||||
@EventHandler
|
||||
public void onEntityMount(EntityMountEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof Player) {
|
||||
LocalPlayer player = getPlugin().wrapPlayer((Player) entity);
|
||||
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(player);
|
||||
if (null != session.testMoveTo(player, BukkitAdapter.adapt(event.getMount().getLocation()), MoveType.EMBARK, true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@EventHandler
|
||||
public void onEntityMount(EntityMountEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof Player) {
|
||||
LocalPlayer player = getPlugin().wrapPlayer((Player) entity);
|
||||
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(player);
|
||||
if (null != session.testMoveTo(player, BukkitAdapter.adapt(event.getMount().getLocation()), MoveType.EMBARK, true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.sk89q.worldguard.WorldGuard;
|
|||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.event.block.BreakBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.block.PlaceBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.util.Entities;
|
||||
import com.sk89q.worldguard.bukkit.util.Materials;
|
||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||
|
@ -68,7 +69,7 @@ public class RegionFlagsListener extends AbstractListener {
|
|||
}
|
||||
}
|
||||
|
||||
if (event.getCause().find(EntityType.SNOWMAN) != null) {
|
||||
if (event.getCause().find(EntityType.SNOW_GOLEM) != null) {
|
||||
event.filter(testState(query, Flags.SNOWMAN_TRAILS), false);
|
||||
}
|
||||
|
||||
|
@ -99,7 +100,7 @@ public class RegionFlagsListener extends AbstractListener {
|
|||
event.filter(testState(query, Flags.ENDERDRAGON_BLOCK_DAMAGE), config.explosionFlagCancellation);
|
||||
}
|
||||
|
||||
if (event.getCause().find(EntityType.ENDER_CRYSTAL) != null) { // EnderCrystal
|
||||
if (event.getCause().find(EntityType.END_CRYSTAL) != null) { // EnderCrystal
|
||||
event.filter(testState(query, Flags.OTHER_EXPLOSION), config.explosionFlagCancellation);
|
||||
}
|
||||
|
||||
|
@ -118,24 +119,24 @@ 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;
|
||||
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
|
||||
if (entity instanceof Player && event.getCause() == DamageCause.FALL) {
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer((Player) entity);
|
||||
if (event.getCause() == DamageCause.FALL) {
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
if (!query.testState(BukkitAdapter.adapt(entity.getLocation()), localPlayer, Flags.FALL_DAMAGE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (entity instanceof Player && event.getCause() == DamageCause.FLY_INTO_WALL) {
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer((Player) entity);
|
||||
if (!query.testState(BukkitAdapter.adapt(entity.getLocation()), localPlayer, Flags.FALL_DAMAGE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (event.getCause() == DamageCause.FLY_INTO_WALL) {
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
if (!query.testState(BukkitAdapter.adapt(entity.getLocation()), localPlayer, Flags.FALL_DAMAGE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -218,7 +218,7 @@ public class RegionProtectionListener extends AbstractListener {
|
|||
String what;
|
||||
|
||||
/* TNT */
|
||||
if (event.getCause().find(EntityType.PRIMED_TNT, EntityType.MINECART_TNT) != null) {
|
||||
if (event.getCause().find(EntityType.TNT, EntityType.TNT_MINECART) != null) {
|
||||
canBreak = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.BLOCK_BREAK, Flags.TNT));
|
||||
what = "use dynamite";
|
||||
|
||||
|
@ -522,8 +522,7 @@ public class RegionProtectionListener extends AbstractListener {
|
|||
if (!isRegionSupportEnabled(vehicle.getWorld())) return; // Region support disabled
|
||||
Entity exited = event.getExited();
|
||||
|
||||
if (vehicle instanceof Tameable && exited instanceof Player) {
|
||||
Player player = (Player) exited;
|
||||
if (vehicle instanceof Tameable && exited instanceof Player player && !Entities.isNPC(player)) {
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
if (!isWhitelisted(Cause.create(player), vehicle.getWorld(), false)) {
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
|
|
|
@ -470,7 +470,6 @@ public class WorldGuardBlockListener extends AbstractListener {
|
|||
public void onBlockForm(BlockFormEvent event) {
|
||||
ConfigurationManager cfg = getConfig();
|
||||
|
||||
|
||||
if (cfg.activityHaltToggle) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
@ -521,6 +520,18 @@ public class WorldGuardBlockListener extends AbstractListener {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Materials.isUnwaxedCopper(event.getBlock().getType())) {
|
||||
if (wcfg.disableCopperBlockFade) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.COPPER_FADE))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -588,7 +599,7 @@ public class WorldGuardBlockListener extends AbstractListener {
|
|||
}
|
||||
}
|
||||
|
||||
if (newType == Material.BUDDING_AMETHYST || newType == Material.POINTED_DRIPSTONE) {
|
||||
if (Materials.isAmethystGrowth(newType) || newType == Material.POINTED_DRIPSTONE) {
|
||||
if (wcfg.disableRockGrowth) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
@ -601,6 +612,19 @@ public class WorldGuardBlockListener extends AbstractListener {
|
|||
}
|
||||
}
|
||||
|
||||
if (Materials.isSculkGrowth(newType)) {
|
||||
if (wcfg.disableSculkGrowth) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.SCULK_GROWTH))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
handleGrow(event, event.getBlock().getLocation(), newType);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,13 +25,17 @@ import com.sk89q.worldguard.LocalPlayer;
|
|||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||
import com.sk89q.worldguard.bukkit.util.Entities;
|
||||
import com.sk89q.worldguard.bukkit.util.InteropUtils;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.FailedLoadRegionSet;
|
||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
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;
|
||||
|
@ -116,6 +120,10 @@ public class WorldGuardEntityListener extends AbstractListener {
|
|||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (block.getType() == Material.SNIFFER_EGG && wcfg.disableCreatureSnifferEggTrampling) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
|
@ -138,8 +146,7 @@ public class WorldGuardEntityListener extends AbstractListener {
|
|||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (defender instanceof Player) {
|
||||
Player player = (Player) defender;
|
||||
} else if (defender instanceof Player player && !Entities.isNPC(defender)) {
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
|
||||
if (wcfg.disableLavaDamage && type == DamageCause.LAVA) {
|
||||
|
@ -227,8 +234,7 @@ public class WorldGuardEntityListener extends AbstractListener {
|
|||
}
|
||||
}
|
||||
|
||||
if (defender instanceof Player) {
|
||||
Player player = (Player) defender;
|
||||
if (defender instanceof Player player && !Entities.isNPC(defender)) {
|
||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
|
||||
if (wcfg.disableLightningDamage && event.getCause() == DamageCause.LIGHTNING) {
|
||||
|
@ -289,8 +295,7 @@ public class WorldGuardEntityListener extends AbstractListener {
|
|||
}
|
||||
|
||||
WorldConfiguration wcfg = getWorldConfig(defender.getWorld());
|
||||
if (defender instanceof Player) {
|
||||
Player player = (Player) defender;
|
||||
if (defender instanceof Player player && !Entities.isNPC(defender)) {
|
||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
|
||||
|
||||
|
@ -363,8 +368,7 @@ public class WorldGuardEntityListener extends AbstractListener {
|
|||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (defender instanceof Player) {
|
||||
Player player = (Player) defender;
|
||||
} else if (defender instanceof Player player && !Entities.isNPC(defender)) {
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
|
||||
if (type == DamageCause.WITHER) {
|
||||
|
@ -582,8 +586,8 @@ public class WorldGuardEntityListener extends AbstractListener {
|
|||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (event.getEntityType() == EntityType.PRIMED_TNT
|
||||
|| event.getEntityType() == EntityType.MINECART_TNT) {
|
||||
} else if (event.getEntityType() == EntityType.TNT
|
||||
|| event.getEntityType() == EntityType.TNT_MINECART) {
|
||||
if (wcfg.blockTNTExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
@ -603,7 +607,7 @@ public class WorldGuardEntityListener extends AbstractListener {
|
|||
WorldConfiguration wcfg = getWorldConfig(event.getEntity().getWorld());
|
||||
|
||||
// allow spawning of creatures from plugins
|
||||
if (!wcfg.blockPluginSpawning && event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM) {
|
||||
if (!wcfg.blockPluginSpawning && Entities.isPluginSpawning(event.getSpawnReason())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -657,35 +661,46 @@ public class WorldGuardEntityListener extends AbstractListener {
|
|||
public void onCreatePortal(PortalCreateEvent event) {
|
||||
WorldConfiguration wcfg = getWorldConfig(event.getWorld());
|
||||
|
||||
if (wcfg.regionNetherPortalProtection
|
||||
if (wcfg.useRegions && wcfg.regionNetherPortalProtection
|
||||
&& event.getReason() == PortalCreateEvent.CreateReason.NETHER_PAIR
|
||||
&& !event.getBlocks().isEmpty()) {
|
||||
final com.sk89q.worldedit.world.World world = BukkitAdapter.adapt(event.getWorld());
|
||||
final RegionManager regionManager = WorldGuard.getInstance().getPlatform().getRegionContainer()
|
||||
.get(world);
|
||||
if (regionManager == null) return;
|
||||
LocalPlayer associable = null;
|
||||
if (event.getEntity() instanceof Player) {
|
||||
associable = getPlugin().wrapPlayer(((Player) event.getEntity()));
|
||||
if (WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(associable, world)) {
|
||||
final Cause cause = Cause.create(event.getEntity());
|
||||
LocalPlayer localPlayer = null;
|
||||
if (cause.getRootCause() instanceof Player player) {
|
||||
if (wcfg.fakePlayerBuildOverride && InteropUtils.isFakePlayer(player)) {
|
||||
return;
|
||||
}
|
||||
localPlayer = getPlugin().wrapPlayer(player);
|
||||
if (WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, world)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
BlockVector3 min = null;
|
||||
BlockVector3 max = null;
|
||||
for (BlockState block : event.getBlocks()) {
|
||||
BlockVector3 loc = BlockVector3.at(block.getX(), block.getY(), block.getZ());
|
||||
min = min == null ? loc : loc.getMinimum(min);
|
||||
max = max == null ? loc : loc.getMaximum(max);
|
||||
final RegionManager regionManager = WorldGuard.getInstance().getPlatform().getRegionContainer()
|
||||
.get(world);
|
||||
ApplicableRegionSet regions;
|
||||
if (regionManager == null) {
|
||||
regions = FailedLoadRegionSet.getInstance();
|
||||
} else {
|
||||
BlockVector3 min = null;
|
||||
BlockVector3 max = null;
|
||||
for (BlockState block : event.getBlocks()) {
|
||||
BlockVector3 loc = BlockVector3.at(block.getX(), block.getY(), block.getZ());
|
||||
min = min == null ? loc : loc.getMinimum(min);
|
||||
max = max == null ? loc : loc.getMaximum(max);
|
||||
}
|
||||
ProtectedCuboidRegion target = new ProtectedCuboidRegion("__portal_check", true, min, max);
|
||||
regions = regionManager.getApplicableRegions(target);
|
||||
}
|
||||
ProtectedCuboidRegion target = new ProtectedCuboidRegion("__portal_check", true, min, max);
|
||||
final ApplicableRegionSet regions = regionManager.getApplicableRegions(target);
|
||||
if (!regions.testState(associable, Flags.BUILD, Flags.BLOCK_PLACE)) {
|
||||
if (associable != null) {
|
||||
final RegionAssociable associable = createRegionAssociable(cause);
|
||||
final State buildState = StateFlag.denyToNone(regions.queryState(associable, Flags.BUILD));
|
||||
if (!StateFlag.test(buildState, regions.queryState(associable, Flags.BLOCK_BREAK))
|
||||
|| !StateFlag.test(buildState, regions.queryState(associable, Flags.BLOCK_PLACE))) {
|
||||
if (localPlayer != null && !cause.isIndirect()) {
|
||||
// NB there is no way to cancel the teleport without PTA (since PlayerPortal doesn't have block info)
|
||||
// removing PTA was a mistake
|
||||
String message = regions.queryValue(associable, Flags.DENY_MESSAGE);
|
||||
RegionProtectionListener.formatAndSendDenyMessage("create portals", associable, message);
|
||||
String message = regions.queryValue(localPlayer, Flags.DENY_MESSAGE);
|
||||
RegionProtectionListener.formatAndSendDenyMessage("create portals", localPlayer, message);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -745,10 +760,10 @@ public class WorldGuardEntityListener extends AbstractListener {
|
|||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions && ent instanceof Player
|
||||
if (wcfg.useRegions && ent instanceof Player player && !Entities.isNPC(ent)
|
||||
&& !WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().testState(
|
||||
BukkitAdapter.adapt(ent.getLocation()),
|
||||
WorldGuardPlugin.inst().wrapPlayer((Player) ent),
|
||||
WorldGuardPlugin.inst().wrapPlayer(player),
|
||||
Flags.HEALTH_REGEN)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -758,10 +773,11 @@ public class WorldGuardEntityListener extends AbstractListener {
|
|||
public void onFoodChange(FoodLevelChangeEvent event) {
|
||||
if (event.getItem() != null) return;
|
||||
HumanEntity ent = event.getEntity();
|
||||
if (!(ent instanceof Player)) return;
|
||||
if (Entities.isNPC(ent)) return;
|
||||
if (!(ent instanceof Player bukkitPlayer)) return;
|
||||
if (event.getFoodLevel() > ent.getFoodLevel()) return;
|
||||
|
||||
LocalPlayer player = WorldGuardPlugin.inst().wrapPlayer((Player) ent);
|
||||
LocalPlayer player = WorldGuardPlugin.inst().wrapPlayer(bukkitPlayer);
|
||||
WorldConfiguration wcfg = getWorldConfig(ent.getWorld());
|
||||
|
||||
if (wcfg.useRegions
|
||||
|
|
|
@ -258,13 +258,11 @@ public class WorldGuardPlayerListener extends AbstractListener {
|
|||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
//Block placedIn = block.getRelative(event.getBlockFace());
|
||||
ApplicableRegionSet set =
|
||||
WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(block.getLocation()));
|
||||
//ApplicableRegionSet placedInSet = plugin.getRegionContainer().createQuery().getApplicableRegions(placedIn.getLocation());
|
||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
|
||||
if (item != null && item.getType().getKey().toString().equals(wcfg.regionWand) && getPlugin().hasPermission(player, "worldguard.region.wand")) {
|
||||
ApplicableRegionSet set = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.getApplicableRegions(BukkitAdapter.adapt(block.getLocation()), RegionQuery.QueryOption.SORT);
|
||||
if (set.size() > 0) {
|
||||
player.sendMessage(ChatColor.YELLOW + "Can you build? " + (set.testState(localPlayer, Flags.BUILD) ? "Yes" : "No"));
|
||||
|
||||
|
@ -309,11 +307,16 @@ public class WorldGuardPlayerListener extends AbstractListener {
|
|||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (type == Material.SNIFFER_EGG && wcfg.disablePlayerSnifferEggTrampling) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (com.sk89q.worldguard.bukkit.util.Entities.isNPC(player)) return;
|
||||
WorldConfiguration wcfg = getWorldConfig(player.getWorld());
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
|
@ -348,6 +351,7 @@ public class WorldGuardPlayerListener extends AbstractListener {
|
|||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (com.sk89q.worldguard.bukkit.util.Entities.isNPC(player)) return;
|
||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
ConfigurationManager cfg = getConfig();
|
||||
WorldConfiguration wcfg = getWorldConfig(player.getWorld());
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.sk89q.worldedit.util.Location;
|
|||
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.config.WorldConfiguration;
|
||||
import com.sk89q.worldguard.session.MoveType;
|
||||
import com.sk89q.worldguard.util.Locations;
|
||||
|
@ -59,6 +60,7 @@ public class WorldGuardVehicleListener extends AbstractListener {
|
|||
// Did we move a block?
|
||||
if (Locations.isDifferentBlock(BukkitAdapter.adapt(event.getFrom()), BukkitAdapter.adapt(event.getTo()))) {
|
||||
for (Player player : playerPassengers) {
|
||||
if (Entities.isNPC(player)) continue;
|
||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
Location lastValid;
|
||||
if ((lastValid = WorldGuard.getInstance().getPlatform().getSessionManager().get(localPlayer)
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package com.sk89q.worldguard.bukkit.listener.debounce.legacy;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.listener.debounce.legacy.InventoryMoveItemEventDebounce.Key;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
@ -44,18 +45,18 @@ public class InventoryMoveItemEventDebounce extends AbstractEventDebounce<Key> {
|
|||
private final Object target;
|
||||
|
||||
public Key(InventoryMoveItemEvent event) {
|
||||
cause = transform(event.getInitiator().getHolder());
|
||||
source = transform(event.getSource().getHolder());
|
||||
target = transform(event.getDestination().getHolder());
|
||||
cause = transform(PaperLib.getHolder(event.getInitiator(), false).getHolder());
|
||||
source = transform(PaperLib.getHolder(event.getSource(), false).getHolder());
|
||||
target = transform(PaperLib.getHolder(event.getDestination(), false).getHolder());
|
||||
}
|
||||
|
||||
private Object transform(InventoryHolder holder) {
|
||||
if (holder instanceof BlockState) {
|
||||
return new BlockMaterialKey(((BlockState) holder).getBlock());
|
||||
} else if (holder instanceof DoubleChest) {
|
||||
InventoryHolder left = ((DoubleChest) holder).getLeftSide();
|
||||
if (left instanceof Chest) {
|
||||
return new BlockMaterialKey(((Chest) left).getBlock());
|
||||
if (holder instanceof BlockState blockState) {
|
||||
return new BlockMaterialKey(blockState);
|
||||
} else if (holder instanceof DoubleChest doubleChest) {
|
||||
InventoryHolder left = PaperLib.isPaper() ? doubleChest.getLeftSide(false) : doubleChest.getLeftSide();
|
||||
if (left instanceof Chest chest) {
|
||||
return new BlockMaterialKey(chest);
|
||||
} else {
|
||||
return holder;
|
||||
}
|
||||
|
@ -94,8 +95,8 @@ public class InventoryMoveItemEventDebounce extends AbstractEventDebounce<Key> {
|
|||
private final Block block;
|
||||
private final Material material;
|
||||
|
||||
private BlockMaterialKey(Block block) {
|
||||
this.block = block;
|
||||
private BlockMaterialKey(BlockState block) {
|
||||
this.block = block.getBlock();
|
||||
material = block.getType();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@ import com.sk89q.worldguard.WorldGuard;
|
|||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.event.player.ProcessPlayerEvent;
|
||||
import com.sk89q.worldguard.bukkit.util.Entities;
|
||||
import com.sk89q.worldguard.session.AbstractSessionManager;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import com.sk89q.worldguard.session.handler.Handler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -41,13 +41,6 @@ import java.util.Collection;
|
|||
*/
|
||||
public class BukkitSessionManager extends AbstractSessionManager implements Runnable, Listener {
|
||||
|
||||
private boolean useTimings;
|
||||
|
||||
@Override
|
||||
protected Handler.Factory<? extends Handler> wrapForRegistration(Handler.Factory<? extends Handler> factory) {
|
||||
return useTimings ? new TimedHandlerFactory(factory) : factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-initialize handlers and clear "last position," "last state," etc.
|
||||
* information for all players.
|
||||
|
@ -81,9 +74,9 @@ public class BukkitSessionManager extends AbstractSessionManager implements Runn
|
|||
|
||||
@Override
|
||||
public boolean hasBypass(LocalPlayer player, World world) {
|
||||
if (player instanceof BukkitPlayer) {
|
||||
if (((BukkitPlayer) player).getPlayer().hasMetadata("NPC")
|
||||
&& WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(world).fakePlayerBuildOverride) {
|
||||
if (player instanceof BukkitPlayer bukkitPlayer) {
|
||||
if (Entities.isNPC(bukkitPlayer.getPlayer())
|
||||
&& WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(world).fakePlayerBuildOverride) {
|
||||
return true;
|
||||
}
|
||||
if (!((BukkitPlayer) player).getPlayer().isOnline()) {
|
||||
|
@ -93,11 +86,10 @@ public class BukkitSessionManager extends AbstractSessionManager implements Runn
|
|||
return super.hasBypass(player, world);
|
||||
}
|
||||
|
||||
public boolean isUsingTimings() {
|
||||
return useTimings;
|
||||
}
|
||||
|
||||
public void setUsingTimings(boolean useTimings) {
|
||||
this.useTimings = useTimings;
|
||||
public void shutdown() {
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
get(localPlayer).uninitialize(localPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,132 +0,0 @@
|
|||
/*
|
||||
* 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.session;
|
||||
|
||||
import co.aikar.timings.lib.MCTiming;
|
||||
import co.aikar.timings.lib.TimingManager;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.session.MoveType;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import com.sk89q.worldguard.session.handler.Handler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.security.CodeSource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
class TimedHandlerFactory extends Handler.Factory<Handler> {
|
||||
|
||||
private static final TimingManager TIMINGS = TimingManager.of(WorldGuardPlugin.inst());
|
||||
private static final MCTiming UNKNOWN_SOURCE = TIMINGS.of("Third-Party Session Handlers");
|
||||
private static final Map<CodeSource, TimingManager> PLUGIN_SOURCES = new HashMap<>();
|
||||
|
||||
private final Handler.Factory<?> factory;
|
||||
private final MCTiming timing;
|
||||
|
||||
TimedHandlerFactory(Handler.Factory<?> factory) {
|
||||
this.factory = factory;
|
||||
this.timing = makeTiming();
|
||||
}
|
||||
|
||||
private MCTiming makeTiming() {
|
||||
CodeSource codeSource = factory.getClass().getProtectionDomain().getCodeSource();
|
||||
TimingManager owner = PLUGIN_SOURCES.computeIfAbsent(codeSource, source -> {
|
||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
CodeSource pluginSource = plugin.getClass().getProtectionDomain().getCodeSource();
|
||||
if (Objects.equals(pluginSource, source)) {
|
||||
return TimingManager.of(plugin);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
String handlerName = factory.getClass().getEnclosingClass().getSimpleName();
|
||||
return owner == null
|
||||
? TIMINGS.of(handlerName, UNKNOWN_SOURCE)
|
||||
: owner.of(handlerName, owner.of("Session Handlers"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Handler create(Session session) {
|
||||
return new TimedHandler(factory.create(session), session, timing);
|
||||
}
|
||||
|
||||
static class TimedHandler extends Handler {
|
||||
private final Handler handler;
|
||||
private final MCTiming timing;
|
||||
|
||||
TimedHandler(Handler innerHandler, Session session, MCTiming timing) {
|
||||
super(session);
|
||||
this.handler = innerHandler;
|
||||
this.timing = timing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(LocalPlayer player, Location current, ApplicableRegionSet set) {
|
||||
try (MCTiming ignored = timing.startTiming()) {
|
||||
handler.initialize(player, current, set);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testMoveTo(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, MoveType moveType) {
|
||||
try (MCTiming ignored = timing.startTiming()) {
|
||||
return handler.testMoveTo(player, from, to, toSet, moveType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCrossBoundary(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType) {
|
||||
try (MCTiming ignored = timing.startTiming()) {
|
||||
return handler.onCrossBoundary(player, from, to, toSet, entered, exited, moveType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(LocalPlayer player, ApplicableRegionSet set) {
|
||||
try (MCTiming ignored = timing.startTiming()) {
|
||||
handler.tick(player, set);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public StateFlag.State getInvincibility(LocalPlayer player) {
|
||||
try (MCTiming ignored = timing.startTiming()) {
|
||||
return handler.getInvincibility(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Handler getWrappedHandler() {
|
||||
return handler;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -47,14 +47,17 @@ public class ClassSourceValidator {
|
|||
|
||||
private static final String SEPARATOR_LINE = Strings.repeat("*", 46);
|
||||
private static final Method loadClass;
|
||||
private static Class<?> pluginClassLoaderClass;
|
||||
|
||||
static {
|
||||
Method tmp;
|
||||
try {
|
||||
tmp = PluginClassLoader.class.getDeclaredMethod("loadClass0",
|
||||
pluginClassLoaderClass = Class.forName("org.bukkit.plugin.java.PluginClassLoader", false,
|
||||
Bukkit.class.getClassLoader());
|
||||
tmp = pluginClassLoaderClass.getDeclaredMethod("loadClass0",
|
||||
String.class, boolean.class, boolean.class, boolean.class);
|
||||
tmp.setAccessible(true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
} catch (NoSuchMethodException | ClassNotFoundException e) {
|
||||
tmp = null;
|
||||
}
|
||||
loadClass = tmp;
|
||||
|
@ -95,7 +98,7 @@ public class ClassSourceValidator {
|
|||
continue;
|
||||
}
|
||||
ClassLoader targetLoader = target.getClass().getClassLoader();
|
||||
if (!(targetLoader instanceof PluginClassLoader)) {
|
||||
if (!(pluginClassLoaderClass.isAssignableFrom(targetLoader.getClass()))) {
|
||||
continue;
|
||||
}
|
||||
for (Class<?> testClass : classes) {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package com.sk89q.worldguard.bukkit.util;
|
||||
|
||||
import org.bukkit.entity.Allay;
|
||||
import org.bukkit.entity.Ambient;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Arrow;
|
||||
|
@ -43,6 +44,7 @@ import org.bukkit.entity.TNTPrimed;
|
|||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
|
@ -101,8 +103,20 @@ public final class Entities {
|
|||
* @return true if the type is a vehicle type
|
||||
*/
|
||||
public static boolean isVehicle(EntityType type) {
|
||||
return type == EntityType.BOAT
|
||||
|| isMinecart(type);
|
||||
return isBoat(type) || isMinecart(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether the given entity type is a Boat type.
|
||||
*
|
||||
* @param type the type
|
||||
* @return true if the type is a Boat type
|
||||
*/
|
||||
public static boolean isBoat(EntityType type) {
|
||||
return switch(type) {
|
||||
case BOAT, CHEST_BOAT -> true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,13 +126,11 @@ public final class Entities {
|
|||
* @return true if the type is a Minecart type
|
||||
*/
|
||||
public static boolean isMinecart(EntityType type) {
|
||||
return type == EntityType.MINECART
|
||||
|| type == EntityType.MINECART_CHEST
|
||||
|| type == EntityType.MINECART_COMMAND
|
||||
|| type == EntityType.MINECART_FURNACE
|
||||
|| type == EntityType.MINECART_HOPPER
|
||||
|| type == EntityType.MINECART_MOB_SPAWNER
|
||||
|| type == EntityType.MINECART_TNT;
|
||||
return switch(type) {
|
||||
case MINECART, CHEST_MINECART, COMMAND_BLOCK_MINECART, FURNACE_MINECART,
|
||||
HOPPER_MINECART, SPAWNER_MINECART, TNT_MINECART -> true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -208,6 +220,7 @@ public final class Entities {
|
|||
return entity instanceof Hanging
|
||||
|| entity instanceof ArmorStand
|
||||
|| entity instanceof EnderCrystal
|
||||
|| entity instanceof Allay
|
||||
|| entity instanceof Minecart && entity instanceof InventoryHolder;
|
||||
}
|
||||
|
||||
|
@ -218,4 +231,18 @@ public final class Entities {
|
|||
public static boolean isAoECloud(EntityType type) {
|
||||
return type == EntityType.AREA_EFFECT_CLOUD;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the spawn reason should be considered as a "plugin spawning".
|
||||
* This is true for custom creations or the summon command.
|
||||
*
|
||||
* @param spawnReason the reason
|
||||
* @return true if considerd plugin spawning
|
||||
*/
|
||||
public static boolean isPluginSpawning(CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
return switch (spawnReason) {
|
||||
case CUSTOM, COMMAND -> true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public final class InteropUtils {
|
|||
UUID uuid = player.getUniqueId();
|
||||
String name = player.getName();
|
||||
|
||||
if (player.hasMetadata("NPC")) {
|
||||
if (Entities.isNPC(player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,28 +52,33 @@ public final class Materials {
|
|||
private static final Map<Material, Integer> MATERIAL_FLAGS = new EnumMap<>(Material.class);
|
||||
private static final Set<PotionEffectType> DAMAGE_EFFECTS = new HashSet<>();
|
||||
|
||||
private static void putMaterialTag(Tag<Material> tag, Integer value) {
|
||||
if (tag == null) return;
|
||||
tag.getValues().forEach(mat -> MATERIAL_FLAGS.put(mat, value));
|
||||
}
|
||||
|
||||
static {
|
||||
ENTITY_ITEMS.put(EntityType.PAINTING, Material.PAINTING);
|
||||
ENTITY_ITEMS.put(EntityType.ARROW, Material.ARROW);
|
||||
ENTITY_ITEMS.put(EntityType.SNOWBALL, Material.SNOWBALL);
|
||||
ENTITY_ITEMS.put(EntityType.FIREBALL, Material.FIRE_CHARGE);
|
||||
ENTITY_ITEMS.put(EntityType.ENDER_PEARL, Material.ENDER_PEARL);
|
||||
ENTITY_ITEMS.put(EntityType.THROWN_EXP_BOTTLE, Material.EXPERIENCE_BOTTLE);
|
||||
ENTITY_ITEMS.put(EntityType.EXPERIENCE_BOTTLE, Material.EXPERIENCE_BOTTLE);
|
||||
ENTITY_ITEMS.put(EntityType.ITEM_FRAME, Material.ITEM_FRAME);
|
||||
ENTITY_ITEMS.put(EntityType.GLOW_ITEM_FRAME, Material.GLOW_ITEM_FRAME);
|
||||
ENTITY_ITEMS.put(EntityType.PRIMED_TNT, Material.TNT);
|
||||
ENTITY_ITEMS.put(EntityType.FIREWORK, Material.FIREWORK_ROCKET);
|
||||
ENTITY_ITEMS.put(EntityType.MINECART_COMMAND, Material.COMMAND_BLOCK_MINECART);
|
||||
ENTITY_ITEMS.put(EntityType.TNT, Material.TNT);
|
||||
ENTITY_ITEMS.put(EntityType.FIREWORK_ROCKET, Material.FIREWORK_ROCKET);
|
||||
ENTITY_ITEMS.put(EntityType.COMMAND_BLOCK_MINECART, Material.COMMAND_BLOCK_MINECART);
|
||||
ENTITY_ITEMS.put(EntityType.BOAT, Material.OAK_BOAT);
|
||||
ENTITY_ITEMS.put(EntityType.MINECART, Material.MINECART);
|
||||
ENTITY_ITEMS.put(EntityType.MINECART_CHEST, Material.CHEST_MINECART);
|
||||
ENTITY_ITEMS.put(EntityType.MINECART_FURNACE, Material.FURNACE_MINECART);
|
||||
ENTITY_ITEMS.put(EntityType.MINECART_TNT, Material.TNT_MINECART);
|
||||
ENTITY_ITEMS.put(EntityType.MINECART_HOPPER, Material.HOPPER_MINECART);
|
||||
ENTITY_ITEMS.put(EntityType.SPLASH_POTION, Material.POTION);
|
||||
ENTITY_ITEMS.put(EntityType.CHEST_MINECART, Material.CHEST_MINECART);
|
||||
ENTITY_ITEMS.put(EntityType.FURNACE_MINECART, Material.FURNACE_MINECART);
|
||||
ENTITY_ITEMS.put(EntityType.TNT_MINECART, Material.TNT_MINECART);
|
||||
ENTITY_ITEMS.put(EntityType.HOPPER_MINECART, Material.HOPPER_MINECART);
|
||||
ENTITY_ITEMS.put(EntityType.POTION, Material.POTION);
|
||||
ENTITY_ITEMS.put(EntityType.EGG, Material.EGG);
|
||||
ENTITY_ITEMS.put(EntityType.ARMOR_STAND, Material.ARMOR_STAND);
|
||||
ENTITY_ITEMS.put(EntityType.ENDER_CRYSTAL, Material.END_CRYSTAL);
|
||||
ENTITY_ITEMS.put(EntityType.END_CRYSTAL, Material.END_CRYSTAL);
|
||||
|
||||
MATERIAL_FLAGS.put(Material.AIR, 0);
|
||||
MATERIAL_FLAGS.put(Material.STONE, 0);
|
||||
|
@ -95,7 +100,7 @@ public final class Materials {
|
|||
MATERIAL_FLAGS.put(Material.DETECTOR_RAIL, 0);
|
||||
MATERIAL_FLAGS.put(Material.STICKY_PISTON, 0);
|
||||
MATERIAL_FLAGS.put(Material.COBWEB, 0);
|
||||
MATERIAL_FLAGS.put(Material.GRASS, 0);
|
||||
MATERIAL_FLAGS.put(Material.SHORT_GRASS, 0);
|
||||
MATERIAL_FLAGS.put(Material.DEAD_BUSH, 0);
|
||||
MATERIAL_FLAGS.put(Material.PISTON, 0);
|
||||
MATERIAL_FLAGS.put(Material.PISTON_HEAD, 0);
|
||||
|
@ -110,7 +115,7 @@ public final class Materials {
|
|||
MATERIAL_FLAGS.put(Material.IRON_BLOCK, 0);
|
||||
MATERIAL_FLAGS.put(Material.BRICK, 0);
|
||||
MATERIAL_FLAGS.put(Material.TNT, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.BOOKSHELF, 0);
|
||||
MATERIAL_FLAGS.put(Material.BOOKSHELF, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.MOSSY_COBBLESTONE, 0);
|
||||
MATERIAL_FLAGS.put(Material.OBSIDIAN, 0);
|
||||
MATERIAL_FLAGS.put(Material.TORCH, 0);
|
||||
|
@ -636,7 +641,7 @@ public final class Materials {
|
|||
MATERIAL_FLAGS.put(Material.PUFFERFISH_BUCKET, 0);
|
||||
MATERIAL_FLAGS.put(Material.SALMON, 0);
|
||||
MATERIAL_FLAGS.put(Material.SALMON_BUCKET, 0);
|
||||
MATERIAL_FLAGS.put(Material.SCUTE, 0);
|
||||
MATERIAL_FLAGS.put(Material.TURTLE_SCUTE, 0);
|
||||
MATERIAL_FLAGS.put(Material.SPLASH_POTION, 0);
|
||||
MATERIAL_FLAGS.put(Material.TURTLE_HELMET, 0);
|
||||
MATERIAL_FLAGS.put(Material.TRIDENT, 0);
|
||||
|
@ -794,111 +799,91 @@ public final class Materials {
|
|||
MATERIAL_FLAGS.put(Material.HANGING_ROOTS, 0);
|
||||
MATERIAL_FLAGS.put(Material.POINTED_DRIPSTONE, 0);
|
||||
|
||||
// 1.19
|
||||
MATERIAL_FLAGS.put(Material.MUD, 0);
|
||||
MATERIAL_FLAGS.put(Material.MANGROVE_ROOTS, 0);
|
||||
MATERIAL_FLAGS.put(Material.MUDDY_MANGROVE_ROOTS, 0);
|
||||
MATERIAL_FLAGS.put(Material.PACKED_MUD, 0);
|
||||
MATERIAL_FLAGS.put(Material.MUD_BRICKS, 0);
|
||||
MATERIAL_FLAGS.put(Material.SCULK, 0);
|
||||
MATERIAL_FLAGS.put(Material.SCULK_VEIN, 0);
|
||||
MATERIAL_FLAGS.put(Material.SCULK_CATALYST, 0);
|
||||
MATERIAL_FLAGS.put(Material.SCULK_SHRIEKER, 0);
|
||||
MATERIAL_FLAGS.put(Material.TADPOLE_BUCKET, 0);
|
||||
MATERIAL_FLAGS.put(Material.RECOVERY_COMPASS, 0);
|
||||
MATERIAL_FLAGS.put(Material.DISC_FRAGMENT_5, 0);
|
||||
MATERIAL_FLAGS.put(Material.GOAT_HORN, 0);
|
||||
MATERIAL_FLAGS.put(Material.OCHRE_FROGLIGHT, 0);
|
||||
MATERIAL_FLAGS.put(Material.VERDANT_FROGLIGHT, 0);
|
||||
MATERIAL_FLAGS.put(Material.PEARLESCENT_FROGLIGHT, 0);
|
||||
MATERIAL_FLAGS.put(Material.FROGSPAWN, 0);
|
||||
MATERIAL_FLAGS.put(Material.ECHO_SHARD, 0);
|
||||
MATERIAL_FLAGS.put(Material.REINFORCED_DEEPSLATE, 0);
|
||||
|
||||
MATERIAL_FLAGS.put(Material.BAMBOO_MOSAIC, 0);
|
||||
MATERIAL_FLAGS.put(Material.BAMBOO_BLOCK, 0);
|
||||
MATERIAL_FLAGS.put(Material.STRIPPED_BAMBOO_BLOCK, 0);
|
||||
MATERIAL_FLAGS.put(Material.SUSPICIOUS_SAND, 0);
|
||||
MATERIAL_FLAGS.put(Material.SUSPICIOUS_GRAVEL, 0);
|
||||
MATERIAL_FLAGS.put(Material.PITCHER_PLANT, 0);
|
||||
MATERIAL_FLAGS.put(Material.CHISELED_BOOKSHELF, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.DECORATED_POT, MODIFIED_ON_RIGHT);
|
||||
MATERIAL_FLAGS.put(Material.BRUSH, 0);
|
||||
MATERIAL_FLAGS.put(Material.SNIFFER_EGG, 0);
|
||||
MATERIAL_FLAGS.put(Material.CALIBRATED_SCULK_SENSOR, 0);
|
||||
MATERIAL_FLAGS.put(Material.PIGLIN_HEAD, 0);
|
||||
MATERIAL_FLAGS.put(Material.PIGLIN_WALL_HEAD, 0);
|
||||
MATERIAL_FLAGS.put(Material.TORCHFLOWER_SEEDS, 0);
|
||||
MATERIAL_FLAGS.put(Material.TORCHFLOWER_CROP, 0);
|
||||
MATERIAL_FLAGS.put(Material.PITCHER_CROP, 0);
|
||||
MATERIAL_FLAGS.put(Material.PINK_PETALS, 0);
|
||||
MATERIAL_FLAGS.put(Material.PITCHER_POD, 0);
|
||||
MATERIAL_FLAGS.put(Material.NETHERITE_UPGRADE_SMITHING_TEMPLATE, 0);
|
||||
|
||||
MATERIAL_FLAGS.put(Material.ARMADILLO_SCUTE, 0);
|
||||
MATERIAL_FLAGS.put(Material.WOLF_ARMOR, 0);
|
||||
|
||||
// Generated via tag
|
||||
for (Material woodenDoor : Tag.WOODEN_DOORS.getValues()) {
|
||||
MATERIAL_FLAGS.put(woodenDoor, MODIFIED_ON_RIGHT);
|
||||
}
|
||||
for (Material woodenTrapdoor : Tag.WOODEN_TRAPDOORS.getValues()) {
|
||||
MATERIAL_FLAGS.put(woodenTrapdoor, MODIFIED_ON_RIGHT);
|
||||
}
|
||||
for (Material shulkerBox : Tag.SHULKER_BOXES.getValues()) {
|
||||
MATERIAL_FLAGS.put(shulkerBox, MODIFIED_ON_RIGHT);
|
||||
}
|
||||
for (Material boat : Tag.ITEMS_BOATS.getValues()) {
|
||||
MATERIAL_FLAGS.put(boat, 0);
|
||||
}
|
||||
for (Material banner : Tag.BANNERS.getValues()) {
|
||||
MATERIAL_FLAGS.put(banner, 0);
|
||||
}
|
||||
for (Material slab : Tag.SLABS.getValues()) {
|
||||
MATERIAL_FLAGS.put(slab, 0);
|
||||
}
|
||||
for (Material plank : Tag.PLANKS.getValues()) {
|
||||
MATERIAL_FLAGS.put(plank, 0);
|
||||
}
|
||||
for (Material carpet : Tag.CARPETS.getValues()) {
|
||||
MATERIAL_FLAGS.put(carpet, 0);
|
||||
}
|
||||
for (Material sapling : Tag.SAPLINGS.getValues()) {
|
||||
MATERIAL_FLAGS.put(sapling, 0);
|
||||
}
|
||||
for (Material log : Tag.LOGS.getValues()) {
|
||||
MATERIAL_FLAGS.put(log, 0);
|
||||
}
|
||||
for (Material leaves : Tag.LEAVES.getValues()) {
|
||||
MATERIAL_FLAGS.put(leaves, 0);
|
||||
}
|
||||
for (Material stair : Tag.STAIRS.getValues()) {
|
||||
MATERIAL_FLAGS.put(stair, 0);
|
||||
}
|
||||
for (Material wool : Tag.WOOL.getValues()) {
|
||||
MATERIAL_FLAGS.put(wool, 0);
|
||||
}
|
||||
for (Material plate : Tag.WOODEN_PRESSURE_PLATES.getValues()) {
|
||||
MATERIAL_FLAGS.put(plate, 0);
|
||||
}
|
||||
for (Material button : Tag.BUTTONS.getValues()) {
|
||||
MATERIAL_FLAGS.put(button, MODIFIED_ON_RIGHT);
|
||||
}
|
||||
for (Material pot : Tag.FLOWER_POTS.getValues()) {
|
||||
MATERIAL_FLAGS.put(pot, MODIFIED_ON_RIGHT);
|
||||
}
|
||||
for (Material wall : Tag.WALLS.getValues()) {
|
||||
MATERIAL_FLAGS.put(wall, 0);
|
||||
}
|
||||
for (Material sign : Tag.SIGNS.getValues()) {
|
||||
MATERIAL_FLAGS.put(sign, 0);
|
||||
}
|
||||
for (Material flower : Tag.SMALL_FLOWERS.getValues()) {
|
||||
MATERIAL_FLAGS.put(flower, 0);
|
||||
}
|
||||
for (Material bed : Tag.BEDS.getValues()) {
|
||||
MATERIAL_FLAGS.put(bed, MODIFIED_ON_RIGHT);
|
||||
}
|
||||
for (Material musicDisc : Tag.ITEMS_MUSIC_DISCS.getValues()) {
|
||||
MATERIAL_FLAGS.put(musicDisc, 0);
|
||||
}
|
||||
for (Material bannerPat : Tag.ITEMS_BANNERS.getValues()) {
|
||||
MATERIAL_FLAGS.put(bannerPat, 0);
|
||||
}
|
||||
for (Material fenceGate : Tag.FENCE_GATES.getValues()) {
|
||||
MATERIAL_FLAGS.put(fenceGate, MODIFIED_ON_RIGHT);
|
||||
}
|
||||
for (Material fence : Tag.FENCES.getValues()) {
|
||||
MATERIAL_FLAGS.put(fence, 0);
|
||||
} for (Material coalOre : Tag.COAL_ORES.getValues()) {
|
||||
MATERIAL_FLAGS.put(coalOre, 0);
|
||||
}
|
||||
for (Material ironOre : Tag.IRON_ORES.getValues()) {
|
||||
MATERIAL_FLAGS.put(ironOre, 0);
|
||||
}
|
||||
for (Material goldOre : Tag.GOLD_ORES.getValues()) {
|
||||
MATERIAL_FLAGS.put(goldOre, 0);
|
||||
}
|
||||
for (Material diamondOre : Tag.DIAMOND_ORES.getValues()) {
|
||||
MATERIAL_FLAGS.put(diamondOre, 0);
|
||||
}
|
||||
for (Material redstoneOre : Tag.REDSTONE_ORES.getValues()) {
|
||||
MATERIAL_FLAGS.put(redstoneOre, 0);
|
||||
}
|
||||
for (Material copperOre : Tag.COPPER_ORES.getValues()) {
|
||||
MATERIAL_FLAGS.put(copperOre, 0);
|
||||
}
|
||||
for (Material emeraldOre : Tag.EMERALD_ORES.getValues()) {
|
||||
MATERIAL_FLAGS.put(emeraldOre, 0);
|
||||
}
|
||||
for (Material lapisOre : Tag.LAPIS_ORES.getValues()) {
|
||||
MATERIAL_FLAGS.put(lapisOre, 0);
|
||||
}
|
||||
for (Material candle : Tag.CANDLES.getValues()) {
|
||||
MATERIAL_FLAGS.put(candle, MODIFIED_ON_RIGHT);
|
||||
}
|
||||
for (Material candleCakes : Tag.CANDLE_CAKES.getValues()) {
|
||||
MATERIAL_FLAGS.put(candleCakes, MODIFIED_ON_RIGHT);
|
||||
}
|
||||
for (Material cauldron : Tag.CAULDRONS.getValues()) {
|
||||
MATERIAL_FLAGS.put(cauldron, MODIFIED_ON_RIGHT);
|
||||
}
|
||||
putMaterialTag(Tag.WOODEN_DOORS, MODIFIED_ON_RIGHT);
|
||||
putMaterialTag(Tag.WOODEN_TRAPDOORS, MODIFIED_ON_RIGHT);
|
||||
putMaterialTag(Tag.SHULKER_BOXES, MODIFIED_ON_RIGHT);
|
||||
putMaterialTag(Tag.ITEMS_BOATS, 0);
|
||||
putMaterialTag(Tag.BANNERS, 0);
|
||||
putMaterialTag(Tag.SLABS, 0);
|
||||
putMaterialTag(Tag.PLANKS, 0);
|
||||
putMaterialTag(Tag.WOOL_CARPETS, 0);
|
||||
putMaterialTag(Tag.SAPLINGS, 0);
|
||||
putMaterialTag(Tag.LOGS, 0);
|
||||
putMaterialTag(Tag.LEAVES, 0);
|
||||
putMaterialTag(Tag.STAIRS, 0);
|
||||
putMaterialTag(Tag.WOOL, 0);
|
||||
putMaterialTag(Tag.WOODEN_PRESSURE_PLATES, 0);
|
||||
putMaterialTag(Tag.BUTTONS, MODIFIED_ON_RIGHT);
|
||||
putMaterialTag(Tag.FLOWER_POTS, MODIFIED_ON_RIGHT);
|
||||
putMaterialTag(Tag.WALLS, 0);
|
||||
putMaterialTag(Tag.ALL_SIGNS, 0);
|
||||
putMaterialTag(Tag.SMALL_FLOWERS, 0);
|
||||
putMaterialTag(Tag.BEDS, MODIFIED_ON_RIGHT);
|
||||
putMaterialTag(Tag.ITEMS_MUSIC_DISCS, 0);
|
||||
putMaterialTag(Tag.ITEMS_BANNERS, 0);
|
||||
putMaterialTag(Tag.FENCE_GATES, MODIFIED_ON_RIGHT);
|
||||
putMaterialTag(Tag.FENCES, 0);
|
||||
|
||||
putMaterialTag(Tag.COAL_ORES, 0);
|
||||
putMaterialTag(Tag.IRON_ORES, 0);
|
||||
putMaterialTag(Tag.GOLD_ORES, 0);
|
||||
putMaterialTag(Tag.DIAMOND_ORES, 0);
|
||||
putMaterialTag(Tag.REDSTONE_ORES, 0);
|
||||
putMaterialTag(Tag.COPPER_ORES, 0);
|
||||
putMaterialTag(Tag.EMERALD_ORES, 0);
|
||||
putMaterialTag(Tag.LAPIS_ORES, 0);
|
||||
putMaterialTag(Tag.CANDLES, MODIFIED_ON_RIGHT);
|
||||
putMaterialTag(Tag.CANDLE_CAKES, MODIFIED_ON_RIGHT);
|
||||
putMaterialTag(Tag.CAULDRONS, MODIFIED_ON_RIGHT);
|
||||
|
||||
// 1.20
|
||||
putMaterialTag(Tag.ITEMS_TRIM_TEMPLATES, 0);
|
||||
putMaterialTag(Tag.ITEMS_DECORATED_POT_SHERDS, 0);
|
||||
|
||||
Stream.concat(Stream.concat(
|
||||
Tag.CORAL_BLOCKS.getValues().stream(),
|
||||
|
@ -913,7 +898,6 @@ public final class Materials {
|
|||
|
||||
// Check for missing items/blocks
|
||||
for (Material material : Material.values()) {
|
||||
//noinspection deprecation
|
||||
if (material.isLegacy()) continue;
|
||||
// Add spawn eggs
|
||||
if (isSpawnEgg(material)) {
|
||||
|
@ -925,14 +909,14 @@ public final class Materials {
|
|||
}
|
||||
|
||||
// DAMAGE_EFFECTS.add(PotionEffectType.SPEED);
|
||||
DAMAGE_EFFECTS.add(PotionEffectType.SLOW);
|
||||
DAMAGE_EFFECTS.add(PotionEffectType.SLOWNESS);
|
||||
// DAMAGE_EFFECTS.add(PotionEffectType.FAST_DIGGING);
|
||||
DAMAGE_EFFECTS.add(PotionEffectType.SLOW_DIGGING);
|
||||
DAMAGE_EFFECTS.add(PotionEffectType.MINING_FATIGUE);
|
||||
// DAMAGE_EFFECTS.add(PotionEffectType.INCREASE_DAMAGE);
|
||||
// DAMAGE_EFFECTS.add(PotionEffectType.HEAL);
|
||||
DAMAGE_EFFECTS.add(PotionEffectType.HARM);
|
||||
DAMAGE_EFFECTS.add(PotionEffectType.INSTANT_DAMAGE);
|
||||
// DAMAGE_EFFECTS.add(PotionEffectType.JUMP);
|
||||
DAMAGE_EFFECTS.add(PotionEffectType.CONFUSION);
|
||||
DAMAGE_EFFECTS.add(PotionEffectType.NAUSEA);
|
||||
// DAMAGE_EFFECTS.add(PotionEffectType.REGENERATION);
|
||||
// DAMAGE_EFFECTS.add(PotionEffectType.DAMAGE_RESISTANCE);
|
||||
// DAMAGE_EFFECTS.add(PotionEffectType.FIRE_RESISTANCE);
|
||||
|
@ -956,6 +940,7 @@ public final class Materials {
|
|||
// DAMAGE_EFFECTS.add(PotionEffectType.DOLPHINS_GRACE);
|
||||
DAMAGE_EFFECTS.add(PotionEffectType.BAD_OMEN);
|
||||
// DAMAGE_EFFECTS.add(PotionEffectType.HERO_OF_THE_VILLAGE);
|
||||
DAMAGE_EFFECTS.add(PotionEffectType.DARKNESS);
|
||||
}
|
||||
|
||||
private Materials() {
|
||||
|
@ -997,13 +982,11 @@ public final class Materials {
|
|||
* @return the block material
|
||||
*/
|
||||
public static Material getBucketBlockMaterial(Material type) {
|
||||
switch (type) {
|
||||
case LAVA_BUCKET:
|
||||
return Material.LAVA;
|
||||
case WATER_BUCKET:
|
||||
default:
|
||||
return Material.WATER;
|
||||
}
|
||||
return switch (type) {
|
||||
case LAVA_BUCKET -> Material.LAVA;
|
||||
case WATER_BUCKET -> Material.WATER;
|
||||
default -> Material.WATER;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1143,220 +1126,97 @@ public final class Materials {
|
|||
|| material == Material.BARREL
|
||||
|| material == Material.BLAST_FURNACE
|
||||
|| material == Material.SMOKER
|
||||
|| material == Material.CHISELED_BOOKSHELF
|
||||
|| Tag.ITEMS_CHEST_BOATS.isTagged(material)
|
||||
|| Tag.SHULKER_BOXES.isTagged(material);
|
||||
}
|
||||
|
||||
public static boolean isSpawnEgg(Material material) {
|
||||
switch (material) {
|
||||
case AXOLOTL_SPAWN_EGG:
|
||||
case BAT_SPAWN_EGG:
|
||||
case BEE_SPAWN_EGG:
|
||||
case BLAZE_SPAWN_EGG:
|
||||
case CAT_SPAWN_EGG:
|
||||
case CAVE_SPIDER_SPAWN_EGG:
|
||||
case CHICKEN_SPAWN_EGG:
|
||||
case COD_SPAWN_EGG:
|
||||
case COW_SPAWN_EGG:
|
||||
case CREEPER_SPAWN_EGG:
|
||||
case DOLPHIN_SPAWN_EGG:
|
||||
case DONKEY_SPAWN_EGG:
|
||||
case DROWNED_SPAWN_EGG:
|
||||
case ELDER_GUARDIAN_SPAWN_EGG:
|
||||
case ENDERMAN_SPAWN_EGG:
|
||||
case ENDERMITE_SPAWN_EGG:
|
||||
case EVOKER_SPAWN_EGG:
|
||||
case FOX_SPAWN_EGG:
|
||||
case GHAST_SPAWN_EGG:
|
||||
case GLOW_SQUID_SPAWN_EGG:
|
||||
case GOAT_SPAWN_EGG:
|
||||
case GUARDIAN_SPAWN_EGG:
|
||||
case HOGLIN_SPAWN_EGG:
|
||||
case HORSE_SPAWN_EGG:
|
||||
case HUSK_SPAWN_EGG:
|
||||
case LLAMA_SPAWN_EGG:
|
||||
case MAGMA_CUBE_SPAWN_EGG:
|
||||
case MOOSHROOM_SPAWN_EGG:
|
||||
case MULE_SPAWN_EGG:
|
||||
case OCELOT_SPAWN_EGG:
|
||||
case PANDA_SPAWN_EGG:
|
||||
case PARROT_SPAWN_EGG:
|
||||
case PHANTOM_SPAWN_EGG:
|
||||
case PIGLIN_BRUTE_SPAWN_EGG:
|
||||
case PIGLIN_SPAWN_EGG:
|
||||
case PIG_SPAWN_EGG:
|
||||
case PILLAGER_SPAWN_EGG:
|
||||
case POLAR_BEAR_SPAWN_EGG:
|
||||
case PUFFERFISH_SPAWN_EGG:
|
||||
case RABBIT_SPAWN_EGG:
|
||||
case RAVAGER_SPAWN_EGG:
|
||||
case SALMON_SPAWN_EGG:
|
||||
case SHEEP_SPAWN_EGG:
|
||||
case SHULKER_SPAWN_EGG:
|
||||
case SILVERFISH_SPAWN_EGG:
|
||||
case SKELETON_HORSE_SPAWN_EGG:
|
||||
case SKELETON_SPAWN_EGG:
|
||||
case SLIME_SPAWN_EGG:
|
||||
case SPIDER_SPAWN_EGG:
|
||||
case SQUID_SPAWN_EGG:
|
||||
case STRAY_SPAWN_EGG:
|
||||
case STRIDER_SPAWN_EGG:
|
||||
case TRADER_LLAMA_SPAWN_EGG:
|
||||
case TROPICAL_FISH_SPAWN_EGG:
|
||||
case TURTLE_SPAWN_EGG:
|
||||
case VEX_SPAWN_EGG:
|
||||
case VILLAGER_SPAWN_EGG:
|
||||
case VINDICATOR_SPAWN_EGG:
|
||||
case WANDERING_TRADER_SPAWN_EGG:
|
||||
case WITCH_SPAWN_EGG:
|
||||
case WITHER_SKELETON_SPAWN_EGG:
|
||||
case WOLF_SPAWN_EGG:
|
||||
case ZOGLIN_SPAWN_EGG:
|
||||
case ZOMBIE_HORSE_SPAWN_EGG:
|
||||
case ZOMBIFIED_PIGLIN_SPAWN_EGG:
|
||||
case ZOMBIE_SPAWN_EGG:
|
||||
case ZOMBIE_VILLAGER_SPAWN_EGG:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return getEntitySpawnEgg(material) != null;
|
||||
}
|
||||
|
||||
public static EntityType getEntitySpawnEgg(Material material) {
|
||||
switch (material) {
|
||||
case AXOLOTL_SPAWN_EGG:
|
||||
return EntityType.AXOLOTL;
|
||||
case SPIDER_SPAWN_EGG:
|
||||
return EntityType.SPIDER;
|
||||
case BAT_SPAWN_EGG:
|
||||
return EntityType.BAT;
|
||||
case BEE_SPAWN_EGG:
|
||||
return EntityType.BEE;
|
||||
case BLAZE_SPAWN_EGG:
|
||||
return EntityType.BLAZE;
|
||||
case CAT_SPAWN_EGG:
|
||||
return EntityType.CAT;
|
||||
case CAVE_SPIDER_SPAWN_EGG:
|
||||
return EntityType.CAVE_SPIDER;
|
||||
case CHICKEN_SPAWN_EGG:
|
||||
return EntityType.CHICKEN;
|
||||
case COD_SPAWN_EGG:
|
||||
return EntityType.COD;
|
||||
case COW_SPAWN_EGG:
|
||||
return EntityType.COW;
|
||||
case CREEPER_SPAWN_EGG:
|
||||
return EntityType.CREEPER;
|
||||
case DOLPHIN_SPAWN_EGG:
|
||||
return EntityType.DOLPHIN;
|
||||
case DONKEY_SPAWN_EGG:
|
||||
return EntityType.DONKEY;
|
||||
case DROWNED_SPAWN_EGG:
|
||||
return EntityType.DROWNED;
|
||||
case ELDER_GUARDIAN_SPAWN_EGG:
|
||||
return EntityType.ELDER_GUARDIAN;
|
||||
case ENDERMAN_SPAWN_EGG:
|
||||
return EntityType.ENDERMAN;
|
||||
case ENDERMITE_SPAWN_EGG:
|
||||
return EntityType.ENDERMITE;
|
||||
case EVOKER_SPAWN_EGG:
|
||||
return EntityType.EVOKER;
|
||||
case FOX_SPAWN_EGG:
|
||||
return EntityType.FOX;
|
||||
case GHAST_SPAWN_EGG:
|
||||
return EntityType.GHAST;
|
||||
case GLOW_SQUID_SPAWN_EGG:
|
||||
return EntityType.GLOW_SQUID;
|
||||
case GOAT_SPAWN_EGG:
|
||||
return EntityType.GOAT;
|
||||
case GUARDIAN_SPAWN_EGG:
|
||||
return EntityType.GUARDIAN;
|
||||
case HOGLIN_SPAWN_EGG:
|
||||
return EntityType.HOGLIN;
|
||||
case HORSE_SPAWN_EGG:
|
||||
return EntityType.HORSE;
|
||||
case HUSK_SPAWN_EGG:
|
||||
return EntityType.HUSK;
|
||||
case LLAMA_SPAWN_EGG:
|
||||
return EntityType.LLAMA;
|
||||
case MAGMA_CUBE_SPAWN_EGG:
|
||||
return EntityType.MAGMA_CUBE;
|
||||
case MOOSHROOM_SPAWN_EGG:
|
||||
return EntityType.MUSHROOM_COW;
|
||||
case MULE_SPAWN_EGG:
|
||||
return EntityType.MULE;
|
||||
case OCELOT_SPAWN_EGG:
|
||||
return EntityType.OCELOT;
|
||||
case PANDA_SPAWN_EGG:
|
||||
return EntityType.PANDA;
|
||||
case PARROT_SPAWN_EGG:
|
||||
return EntityType.PARROT;
|
||||
case PHANTOM_SPAWN_EGG:
|
||||
return EntityType.PHANTOM;
|
||||
case PIGLIN_BRUTE_SPAWN_EGG:
|
||||
return EntityType.PIGLIN_BRUTE;
|
||||
case PIGLIN_SPAWN_EGG:
|
||||
return EntityType.PIGLIN;
|
||||
case PILLAGER_SPAWN_EGG:
|
||||
return EntityType.PILLAGER;
|
||||
case POLAR_BEAR_SPAWN_EGG:
|
||||
return EntityType.POLAR_BEAR;
|
||||
case PUFFERFISH_SPAWN_EGG:
|
||||
return EntityType.PUFFERFISH;
|
||||
case RABBIT_SPAWN_EGG:
|
||||
return EntityType.RABBIT;
|
||||
case RAVAGER_SPAWN_EGG:
|
||||
return EntityType.RAVAGER;
|
||||
case SALMON_SPAWN_EGG:
|
||||
return EntityType.SALMON;
|
||||
case SHEEP_SPAWN_EGG:
|
||||
return EntityType.SHEEP;
|
||||
case SHULKER_SPAWN_EGG:
|
||||
return EntityType.SHULKER;
|
||||
case SILVERFISH_SPAWN_EGG:
|
||||
return EntityType.SILVERFISH;
|
||||
case SKELETON_HORSE_SPAWN_EGG:
|
||||
return EntityType.SKELETON_HORSE;
|
||||
case SKELETON_SPAWN_EGG:
|
||||
return EntityType.SKELETON;
|
||||
case SLIME_SPAWN_EGG:
|
||||
return EntityType.SLIME;
|
||||
case SQUID_SPAWN_EGG:
|
||||
return EntityType.SQUID;
|
||||
case STRAY_SPAWN_EGG:
|
||||
return EntityType.STRAY;
|
||||
case STRIDER_SPAWN_EGG:
|
||||
return EntityType.STRIDER;
|
||||
case TRADER_LLAMA_SPAWN_EGG:
|
||||
return EntityType.TRADER_LLAMA;
|
||||
case TROPICAL_FISH_SPAWN_EGG:
|
||||
return EntityType.TROPICAL_FISH;
|
||||
case TURTLE_SPAWN_EGG:
|
||||
return EntityType.TURTLE;
|
||||
case VEX_SPAWN_EGG:
|
||||
return EntityType.VEX;
|
||||
case VILLAGER_SPAWN_EGG:
|
||||
return EntityType.VILLAGER;
|
||||
case VINDICATOR_SPAWN_EGG:
|
||||
return EntityType.VINDICATOR;
|
||||
case WANDERING_TRADER_SPAWN_EGG:
|
||||
return EntityType.WANDERING_TRADER;
|
||||
case WITCH_SPAWN_EGG:
|
||||
return EntityType.WITCH;
|
||||
case WITHER_SKELETON_SPAWN_EGG:
|
||||
return EntityType.WITHER_SKELETON;
|
||||
case WOLF_SPAWN_EGG:
|
||||
return EntityType.WOLF;
|
||||
case ZOMBIE_HORSE_SPAWN_EGG:
|
||||
return EntityType.ZOMBIE_HORSE;
|
||||
case ZOMBIFIED_PIGLIN_SPAWN_EGG:
|
||||
return EntityType.ZOMBIFIED_PIGLIN;
|
||||
case ZOMBIE_SPAWN_EGG:
|
||||
return EntityType.ZOMBIE;
|
||||
case ZOMBIE_VILLAGER_SPAWN_EGG:
|
||||
return EntityType.ZOMBIE_VILLAGER;
|
||||
case PIG_SPAWN_EGG:
|
||||
default: // Uhh
|
||||
return EntityType.PIG;
|
||||
}
|
||||
return switch (material) {
|
||||
case ALLAY_SPAWN_EGG -> EntityType.ALLAY;
|
||||
case ARMADILLO_SPAWN_EGG -> EntityType.ARMADILLO;
|
||||
case AXOLOTL_SPAWN_EGG -> EntityType.AXOLOTL;
|
||||
case SPIDER_SPAWN_EGG -> EntityType.SPIDER;
|
||||
case BAT_SPAWN_EGG -> EntityType.BAT;
|
||||
case BEE_SPAWN_EGG -> EntityType.BEE;
|
||||
case BLAZE_SPAWN_EGG -> EntityType.BLAZE;
|
||||
case CAT_SPAWN_EGG -> EntityType.CAT;
|
||||
case CAMEL_SPAWN_EGG -> EntityType.CAMEL;
|
||||
case CAVE_SPIDER_SPAWN_EGG -> EntityType.CAVE_SPIDER;
|
||||
case CHICKEN_SPAWN_EGG -> EntityType.CHICKEN;
|
||||
case COD_SPAWN_EGG -> EntityType.COD;
|
||||
case COW_SPAWN_EGG -> EntityType.COW;
|
||||
case CREEPER_SPAWN_EGG -> EntityType.CREEPER;
|
||||
case DOLPHIN_SPAWN_EGG -> EntityType.DOLPHIN;
|
||||
case DONKEY_SPAWN_EGG -> EntityType.DONKEY;
|
||||
case DROWNED_SPAWN_EGG -> EntityType.DROWNED;
|
||||
case ELDER_GUARDIAN_SPAWN_EGG -> EntityType.ELDER_GUARDIAN;
|
||||
case ENDER_DRAGON_SPAWN_EGG -> EntityType.ENDER_DRAGON;
|
||||
case ENDERMAN_SPAWN_EGG -> EntityType.ENDERMAN;
|
||||
case ENDERMITE_SPAWN_EGG -> EntityType.ENDERMITE;
|
||||
case EVOKER_SPAWN_EGG -> EntityType.EVOKER;
|
||||
case FOX_SPAWN_EGG -> EntityType.FOX;
|
||||
case FROG_SPAWN_EGG -> EntityType.FROG;
|
||||
case GHAST_SPAWN_EGG -> EntityType.GHAST;
|
||||
case GLOW_SQUID_SPAWN_EGG -> EntityType.GLOW_SQUID;
|
||||
case GOAT_SPAWN_EGG -> EntityType.GOAT;
|
||||
case GUARDIAN_SPAWN_EGG -> EntityType.GUARDIAN;
|
||||
case HOGLIN_SPAWN_EGG -> EntityType.HOGLIN;
|
||||
case HORSE_SPAWN_EGG -> EntityType.HORSE;
|
||||
case HUSK_SPAWN_EGG -> EntityType.HUSK;
|
||||
case IRON_GOLEM_SPAWN_EGG -> EntityType.IRON_GOLEM;
|
||||
case LLAMA_SPAWN_EGG -> EntityType.LLAMA;
|
||||
case MAGMA_CUBE_SPAWN_EGG -> EntityType.MAGMA_CUBE;
|
||||
case MOOSHROOM_SPAWN_EGG -> EntityType.MOOSHROOM;
|
||||
case MULE_SPAWN_EGG -> EntityType.MULE;
|
||||
case OCELOT_SPAWN_EGG -> EntityType.OCELOT;
|
||||
case PANDA_SPAWN_EGG -> EntityType.PANDA;
|
||||
case PARROT_SPAWN_EGG -> EntityType.PARROT;
|
||||
case PHANTOM_SPAWN_EGG -> EntityType.PHANTOM;
|
||||
case PIGLIN_BRUTE_SPAWN_EGG -> EntityType.PIGLIN_BRUTE;
|
||||
case PIGLIN_SPAWN_EGG -> EntityType.PIGLIN;
|
||||
case PILLAGER_SPAWN_EGG -> EntityType.PILLAGER;
|
||||
case POLAR_BEAR_SPAWN_EGG -> EntityType.POLAR_BEAR;
|
||||
case PUFFERFISH_SPAWN_EGG -> EntityType.PUFFERFISH;
|
||||
case RABBIT_SPAWN_EGG -> EntityType.RABBIT;
|
||||
case RAVAGER_SPAWN_EGG -> EntityType.RAVAGER;
|
||||
case SALMON_SPAWN_EGG -> EntityType.SALMON;
|
||||
case SHEEP_SPAWN_EGG -> EntityType.SHEEP;
|
||||
case SHULKER_SPAWN_EGG -> EntityType.SHULKER;
|
||||
case SILVERFISH_SPAWN_EGG -> EntityType.SILVERFISH;
|
||||
case SKELETON_HORSE_SPAWN_EGG -> EntityType.SKELETON_HORSE;
|
||||
case SKELETON_SPAWN_EGG -> EntityType.SKELETON;
|
||||
case SLIME_SPAWN_EGG -> EntityType.SLIME;
|
||||
case SNIFFER_SPAWN_EGG -> EntityType.SNIFFER;
|
||||
case SNOW_GOLEM_SPAWN_EGG -> EntityType.SNOW_GOLEM;
|
||||
case SQUID_SPAWN_EGG -> EntityType.SQUID;
|
||||
case STRAY_SPAWN_EGG -> EntityType.STRAY;
|
||||
case STRIDER_SPAWN_EGG -> EntityType.STRIDER;
|
||||
case TADPOLE_SPAWN_EGG -> EntityType.TADPOLE;
|
||||
case TRADER_LLAMA_SPAWN_EGG -> EntityType.TRADER_LLAMA;
|
||||
case TROPICAL_FISH_SPAWN_EGG -> EntityType.TROPICAL_FISH;
|
||||
case TURTLE_SPAWN_EGG -> EntityType.TURTLE;
|
||||
case VEX_SPAWN_EGG -> EntityType.VEX;
|
||||
case VILLAGER_SPAWN_EGG -> EntityType.VILLAGER;
|
||||
case VINDICATOR_SPAWN_EGG -> EntityType.VINDICATOR;
|
||||
case WANDERING_TRADER_SPAWN_EGG -> EntityType.WANDERING_TRADER;
|
||||
case WARDEN_SPAWN_EGG -> EntityType.WARDEN;
|
||||
case WITCH_SPAWN_EGG -> EntityType.WITCH;
|
||||
case WITHER_SPAWN_EGG -> EntityType.WITHER;
|
||||
case WITHER_SKELETON_SPAWN_EGG -> EntityType.WITHER_SKELETON;
|
||||
case WOLF_SPAWN_EGG -> EntityType.WOLF;
|
||||
case ZOGLIN_SPAWN_EGG -> EntityType.ZOGLIN;
|
||||
case ZOMBIE_HORSE_SPAWN_EGG -> EntityType.ZOMBIE_HORSE;
|
||||
case ZOMBIFIED_PIGLIN_SPAWN_EGG -> EntityType.ZOMBIFIED_PIGLIN;
|
||||
case ZOMBIE_SPAWN_EGG -> EntityType.ZOMBIE;
|
||||
case ZOMBIE_VILLAGER_SPAWN_EGG -> EntityType.ZOMBIE_VILLAGER;
|
||||
case PIG_SPAWN_EGG -> EntityType.PIG;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean isBed(Material material) {
|
||||
|
@ -1380,26 +1240,14 @@ public final class Materials {
|
|||
* @return true if the material is a crop
|
||||
*/
|
||||
public static boolean isCrop(Material type) {
|
||||
switch (type) {
|
||||
case WHEAT:
|
||||
case CARROTS:
|
||||
case POTATOES:
|
||||
case BEETROOTS:
|
||||
case MELON_STEM:
|
||||
case PUMPKIN_STEM:
|
||||
case PUMPKIN:
|
||||
case MELON:
|
||||
case CACTUS:
|
||||
case SUGAR_CANE:
|
||||
case BAMBOO:
|
||||
case BAMBOO_SAPLING:
|
||||
case SWEET_BERRY_BUSH:
|
||||
case NETHER_WART:
|
||||
case CAVE_VINES:
|
||||
case CAVE_VINES_PLANT:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (Tag.CROPS.isTagged(type)) return true;
|
||||
// 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 ->
|
||||
true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1434,18 +1282,11 @@ public final class Materials {
|
|||
|| Tag.PRESSURE_PLATES.isTagged(material)) {
|
||||
return true;
|
||||
}
|
||||
switch (material) {
|
||||
case LEVER:
|
||||
case LECTERN:
|
||||
case ENCHANTING_TABLE:
|
||||
case BELL:
|
||||
case LOOM:
|
||||
case CARTOGRAPHY_TABLE:
|
||||
case STONECUTTER:
|
||||
case GRINDSTONE:
|
||||
return true;
|
||||
default: return false;
|
||||
}
|
||||
return switch (material) {
|
||||
case LEVER, LECTERN, ENCHANTING_TABLE, BELL, LOOM,
|
||||
CARTOGRAPHY_TABLE, STONECUTTER, GRINDSTONE -> true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1492,9 +1333,11 @@ public final class Materials {
|
|||
return type == Material.REPEATER
|
||||
|| type == Material.COMPARATOR
|
||||
|| type == Material.CAKE
|
||||
|| type == Material.DRAGON_EGG
|
||||
|| Tag.FLOWER_POTS.isTagged(type)
|
||||
|| Tag.CANDLES.isTagged(type)
|
||||
|| Tag.CANDLE_CAKES.isTagged(type);
|
||||
|| Tag.CANDLE_CAKES.isTagged(type)
|
||||
|| Tag.ALL_SIGNS.isTagged(type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1524,37 +1367,17 @@ public final class Materials {
|
|||
* @return true if equippable armor
|
||||
*/
|
||||
public static boolean isArmor(Material type) {
|
||||
switch (type) {
|
||||
case LEATHER_HELMET:
|
||||
case LEATHER_CHESTPLATE:
|
||||
case LEATHER_LEGGINGS:
|
||||
case LEATHER_BOOTS:
|
||||
case CHAINMAIL_HELMET:
|
||||
case CHAINMAIL_CHESTPLATE:
|
||||
case CHAINMAIL_LEGGINGS:
|
||||
case CHAINMAIL_BOOTS:
|
||||
case IRON_HELMET:
|
||||
case IRON_CHESTPLATE:
|
||||
case IRON_LEGGINGS:
|
||||
case IRON_BOOTS:
|
||||
case DIAMOND_HELMET:
|
||||
case DIAMOND_CHESTPLATE:
|
||||
case DIAMOND_LEGGINGS:
|
||||
case DIAMOND_BOOTS:
|
||||
case GOLDEN_HELMET:
|
||||
case GOLDEN_CHESTPLATE:
|
||||
case GOLDEN_LEGGINGS:
|
||||
case GOLDEN_BOOTS:
|
||||
case NETHERITE_HELMET:
|
||||
case NETHERITE_CHESTPLATE:
|
||||
case NETHERITE_LEGGINGS:
|
||||
case NETHERITE_BOOTS:
|
||||
case TURTLE_HELMET:
|
||||
case ELYTRA:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return switch (type) {
|
||||
case LEATHER_HELMET, LEATHER_CHESTPLATE, LEATHER_LEGGINGS, LEATHER_BOOTS,
|
||||
CHAINMAIL_HELMET, CHAINMAIL_CHESTPLATE, CHAINMAIL_LEGGINGS, CHAINMAIL_BOOTS,
|
||||
IRON_HELMET, IRON_CHESTPLATE, IRON_LEGGINGS, IRON_BOOTS,
|
||||
DIAMOND_HELMET, DIAMOND_CHESTPLATE, DIAMOND_LEGGINGS, DIAMOND_BOOTS,
|
||||
GOLDEN_HELMET, GOLDEN_CHESTPLATE, GOLDEN_LEGGINGS, GOLDEN_BOOTS,
|
||||
NETHERITE_HELMET, NETHERITE_CHESTPLATE, NETHERITE_LEGGINGS, NETHERITE_BOOTS,
|
||||
TURTLE_HELMET, ELYTRA ->
|
||||
true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1575,64 +1398,40 @@ public final class Materials {
|
|||
case GOLDEN_HOE:
|
||||
case DIAMOND_HOE:
|
||||
case NETHERITE_HOE:
|
||||
switch (targetMaterial) {
|
||||
case GRASS_BLOCK:
|
||||
case DIRT:
|
||||
case DIRT_PATH:
|
||||
case ROOTED_DIRT:
|
||||
// case COARSE_DIRT: // already handled by the server...
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return switch (targetMaterial) {
|
||||
case GRASS_BLOCK, DIRT, DIRT_PATH, ROOTED_DIRT ->
|
||||
true;
|
||||
default -> false;
|
||||
};
|
||||
case WOODEN_AXE:
|
||||
case STONE_AXE:
|
||||
case IRON_AXE:
|
||||
case GOLDEN_AXE:
|
||||
case DIAMOND_AXE:
|
||||
case NETHERITE_AXE:
|
||||
if (isWaxedCopper(targetMaterial))
|
||||
return true;
|
||||
switch (targetMaterial) {
|
||||
case OAK_LOG:
|
||||
case DARK_OAK_LOG:
|
||||
case ACACIA_LOG:
|
||||
case BIRCH_LOG:
|
||||
case SPRUCE_LOG:
|
||||
case JUNGLE_LOG:
|
||||
case OAK_WOOD:
|
||||
case DARK_OAK_WOOD:
|
||||
case ACACIA_WOOD:
|
||||
case BIRCH_WOOD:
|
||||
case SPRUCE_WOOD:
|
||||
case JUNGLE_WOOD:
|
||||
case CRIMSON_STEM:
|
||||
case WARPED_STEM:
|
||||
case CRIMSON_HYPHAE:
|
||||
case WARPED_HYPHAE:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (isWaxedCopper(targetMaterial)) return true;
|
||||
if (Tag.LOGS.isTagged(targetMaterial)) return true;
|
||||
return switch (targetMaterial) {
|
||||
case OAK_WOOD, DARK_OAK_WOOD, ACACIA_WOOD, BIRCH_WOOD, SPRUCE_WOOD, PUMPKIN, BAMBOO_BLOCK,
|
||||
JUNGLE_WOOD, CRIMSON_STEM, WARPED_STEM, CRIMSON_HYPHAE, WARPED_HYPHAE ->
|
||||
true;
|
||||
default -> false;
|
||||
};
|
||||
case WOODEN_SHOVEL:
|
||||
case STONE_SHOVEL:
|
||||
case IRON_SHOVEL:
|
||||
case GOLDEN_SHOVEL:
|
||||
case DIAMOND_SHOVEL:
|
||||
case NETHERITE_SHOVEL:
|
||||
switch (targetMaterial) {
|
||||
case GRASS_BLOCK:
|
||||
case CAMPFIRE:
|
||||
case SOUL_CAMPFIRE:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return switch (targetMaterial) {
|
||||
case GRASS_BLOCK, CAMPFIRE, SOUL_CAMPFIRE -> true;
|
||||
default -> false;
|
||||
};
|
||||
case SHEARS:
|
||||
switch (targetMaterial) {
|
||||
case PUMPKIN:
|
||||
case BEE_NEST:
|
||||
case BEEHIVE:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return switch (targetMaterial) {
|
||||
case PUMPKIN, BEE_NEST, BEEHIVE -> true;
|
||||
default -> false;
|
||||
};
|
||||
case BLACK_DYE:
|
||||
case BLUE_DYE:
|
||||
case BROWN_DYE:
|
||||
|
@ -1651,9 +1450,14 @@ public final class Materials {
|
|||
case YELLOW_DYE:
|
||||
case GLOW_INK_SAC:
|
||||
case INK_SAC:
|
||||
return Tag.SIGNS.isTagged(targetMaterial);
|
||||
return Tag.ALL_SIGNS.isTagged(targetMaterial);
|
||||
case HONEYCOMB:
|
||||
return isUnwaxedCopper(targetMaterial);
|
||||
return isUnwaxedCopper(targetMaterial) || Tag.ALL_SIGNS.isTagged(targetMaterial);
|
||||
case BRUSH:
|
||||
return switch (targetMaterial) {
|
||||
case SUSPICIOUS_GRAVEL, SUSPICIOUS_SAND -> true;
|
||||
default -> false;
|
||||
};
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -1664,48 +1468,37 @@ public final class Materials {
|
|||
}
|
||||
|
||||
public static boolean isWaxedCopper(Material type) {
|
||||
switch (type) {
|
||||
case WAXED_COPPER_BLOCK:
|
||||
case WAXED_EXPOSED_COPPER:
|
||||
case WAXED_WEATHERED_COPPER:
|
||||
case WAXED_OXIDIZED_COPPER:
|
||||
case WAXED_CUT_COPPER:
|
||||
case WAXED_EXPOSED_CUT_COPPER:
|
||||
case WAXED_WEATHERED_CUT_COPPER:
|
||||
case WAXED_OXIDIZED_CUT_COPPER:
|
||||
case WAXED_CUT_COPPER_STAIRS:
|
||||
case WAXED_EXPOSED_CUT_COPPER_STAIRS:
|
||||
case WAXED_WEATHERED_CUT_COPPER_STAIRS:
|
||||
case WAXED_OXIDIZED_CUT_COPPER_STAIRS:
|
||||
case WAXED_CUT_COPPER_SLAB:
|
||||
case WAXED_EXPOSED_CUT_COPPER_SLAB:
|
||||
case WAXED_WEATHERED_CUT_COPPER_SLAB:
|
||||
case WAXED_OXIDIZED_CUT_COPPER_SLAB:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return switch (type) {
|
||||
case WAXED_COPPER_BLOCK, WAXED_EXPOSED_COPPER, WAXED_WEATHERED_COPPER, WAXED_OXIDIZED_COPPER,
|
||||
WAXED_CUT_COPPER, WAXED_EXPOSED_CUT_COPPER, WAXED_WEATHERED_CUT_COPPER,
|
||||
WAXED_OXIDIZED_CUT_COPPER, WAXED_CUT_COPPER_STAIRS, WAXED_EXPOSED_CUT_COPPER_STAIRS,
|
||||
WAXED_WEATHERED_CUT_COPPER_STAIRS, WAXED_OXIDIZED_CUT_COPPER_STAIRS, WAXED_CUT_COPPER_SLAB,
|
||||
WAXED_EXPOSED_CUT_COPPER_SLAB, WAXED_WEATHERED_CUT_COPPER_SLAB, WAXED_OXIDIZED_CUT_COPPER_SLAB ->
|
||||
true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean isUnwaxedCopper(Material type) {
|
||||
switch (type) {
|
||||
case COPPER_BLOCK:
|
||||
case EXPOSED_COPPER:
|
||||
case WEATHERED_COPPER:
|
||||
case OXIDIZED_COPPER:
|
||||
case CUT_COPPER:
|
||||
case EXPOSED_CUT_COPPER:
|
||||
case WEATHERED_CUT_COPPER:
|
||||
case OXIDIZED_CUT_COPPER:
|
||||
case CUT_COPPER_STAIRS:
|
||||
case EXPOSED_CUT_COPPER_STAIRS:
|
||||
case WEATHERED_CUT_COPPER_STAIRS:
|
||||
case OXIDIZED_CUT_COPPER_STAIRS:
|
||||
case CUT_COPPER_SLAB:
|
||||
case EXPOSED_CUT_COPPER_SLAB:
|
||||
case WEATHERED_CUT_COPPER_SLAB:
|
||||
case OXIDIZED_CUT_COPPER_SLAB:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return switch (type) {
|
||||
case COPPER_BLOCK, EXPOSED_COPPER, WEATHERED_COPPER, OXIDIZED_COPPER, CUT_COPPER,
|
||||
EXPOSED_CUT_COPPER, WEATHERED_CUT_COPPER, OXIDIZED_CUT_COPPER, CUT_COPPER_STAIRS,
|
||||
EXPOSED_CUT_COPPER_STAIRS, WEATHERED_CUT_COPPER_STAIRS, OXIDIZED_CUT_COPPER_STAIRS,
|
||||
CUT_COPPER_SLAB, EXPOSED_CUT_COPPER_SLAB, WEATHERED_CUT_COPPER_SLAB, OXIDIZED_CUT_COPPER_SLAB ->
|
||||
true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean isAmethystGrowth(Material mat) {
|
||||
return mat == Material.BUDDING_AMETHYST
|
||||
|| mat == Material.AMETHYST_CLUSTER
|
||||
|| mat == Material.LARGE_AMETHYST_BUD
|
||||
|| mat == Material.MEDIUM_AMETHYST_BUD
|
||||
|| mat == Material.SMALL_AMETHYST_BUD;
|
||||
}
|
||||
|
||||
public static boolean isSculkGrowth(Material mat) {
|
||||
return mat == Material.SCULK || mat == Material.SCULK_VEIN;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* 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.report;
|
||||
|
||||
import com.sk89q.worldedit.util.report.DataReport;
|
||||
import io.papermc.paper.datapack.Datapack;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* A report for current datapacks with some information. Only available on Paper
|
||||
*/
|
||||
public class DatapackReport extends DataReport {
|
||||
public DatapackReport() {
|
||||
super("DataPacks");
|
||||
|
||||
Collection<Datapack> packs = Bukkit.getDatapackManager().getPacks();
|
||||
|
||||
append("Datapack Count", packs.size());
|
||||
append("Datapack Enabled Count", Bukkit.getDatapackManager().getEnabledPacks().size());
|
||||
|
||||
for (Datapack pack : packs) {
|
||||
DataReport report = new DataReport("DataPack: " + pack.getName());
|
||||
report.append("Enabled?", pack.isEnabled());
|
||||
report.append("Name", pack.getName());
|
||||
report.append("Compatibility", pack.getCompatibility().name());
|
||||
append(report.getTitle(), report);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@
|
|||
package com.sk89q.worldguard.bukkit.util.report;
|
||||
|
||||
import com.sk89q.worldedit.util.report.DataReport;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
@ -33,9 +34,18 @@ public class ServerReport extends DataReport {
|
|||
append("Bukkit Version", server.getBukkitVersion());
|
||||
append("Implementation", server.getName() + " " + server.getVersion());
|
||||
append("Player Count", "%d/%d", Bukkit.getOnlinePlayers().size(), server.getMaxPlayers());
|
||||
|
||||
append("Server Class Source", server.getClass().getProtectionDomain().getCodeSource().getLocation());
|
||||
|
||||
DataReport onlineMode = new DataReport("Online Mode");
|
||||
onlineMode.append("enabled?", server.getOnlineMode());
|
||||
if (PaperLib.isSpigot()) {
|
||||
onlineMode.append("BungeeCord support?", Bukkit.spigot().getConfig().getBoolean("settings.bungeecord", false));
|
||||
}
|
||||
if (PaperLib.isPaper()) {
|
||||
onlineMode.append("Velocity support?", Bukkit.spigot().getPaperConfig().getBoolean("proxies.velocity.enabled", false));
|
||||
}
|
||||
append(onlineMode.getTitle(), onlineMode);
|
||||
|
||||
DataReport spawning = new DataReport("Spawning");
|
||||
spawning.append("Ambient Spawn Limit", server.getAmbientSpawnLimit());
|
||||
spawning.append("Animal Spawn Limit", server.getAnimalSpawnLimit());
|
||||
|
|
|
@ -3,4 +3,4 @@ main: com.sk89q.worldguard.bukkit.WorldGuardPlugin
|
|||
version: "${internalVersion}"
|
||||
depend: [WorldEdit]
|
||||
softdepend: [CommandBook]
|
||||
api-version: 1.17
|
||||
api-version: "1.20"
|
||||
|
|
|
@ -8,11 +8,11 @@ dependencies {
|
|||
"api"(project(":worldguard-libs:core"))
|
||||
"api"("com.sk89q.worldedit:worldedit-core:${Versions.WORLDEDIT}")
|
||||
"implementation"("org.flywaydb:flyway-core:3.0")
|
||||
"implementation"("org.yaml:snakeyaml:1.29")
|
||||
"implementation"("org.yaml:snakeyaml:2.0")
|
||||
"implementation"("com.google.guava:guava:${Versions.GUAVA}")
|
||||
|
||||
"compileOnly"("com.google.code.findbugs:jsr305:1.3.9")
|
||||
"testImplementation"("org.hamcrest:hamcrest-library:1.2.1")
|
||||
"compileOnly"("com.google.code.findbugs:jsr305:${Versions.FINDBUGS}")
|
||||
"testImplementation"("org.hamcrest:hamcrest-library:2.2")
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -95,9 +95,9 @@ public class DatabaseHandler implements LoggerHandler {
|
|||
stmt.setString(1, eventType.name());
|
||||
stmt.setString(2, worldName);
|
||||
stmt.setString(3, player != null ? player.getName() : "");
|
||||
stmt.setInt(4, pos.getBlockX());
|
||||
stmt.setInt(5, pos.getBlockY());
|
||||
stmt.setInt(6, pos.getBlockZ());
|
||||
stmt.setInt(4, pos.x());
|
||||
stmt.setInt(5, pos.y());
|
||||
stmt.setInt(6, pos.z());
|
||||
stmt.setString(7, item);
|
||||
stmt.setInt(8, (int)(System.currentTimeMillis() / 1000));
|
||||
stmt.setString(9, comment);
|
||||
|
|
|
@ -221,7 +221,7 @@ public class FileHandler implements LoggerHandler {
|
|||
* @return The position's coordinates in human-readable form
|
||||
*/
|
||||
private String getCoordinates(BlockVector3 pos) {
|
||||
return "@" + pos.getBlockX() + "," + pos.getBlockY() + "," + pos.getBlockZ();
|
||||
return "@" + pos.x() + "," + pos.y() + "," + pos.z();
|
||||
}
|
||||
|
||||
private void logEvent(BlacklistEvent event, String text, Target target, BlockVector3 pos, String comment) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -378,7 +378,7 @@ class FlagHelperBox extends PaginationBox {
|
|||
if (currVal == null) {
|
||||
currVal = getInheritedValue(region, flag);
|
||||
}
|
||||
String display = currVal == null ? regName : currVal.getId();
|
||||
String display = currVal == null ? regName : currVal.id();
|
||||
appendValueText(builder, flag, display, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -160,7 +160,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 +214,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)
|
||||
|
@ -330,17 +330,9 @@ public final class RegionCommands extends RegionCommandsBase {
|
|||
}
|
||||
}
|
||||
|
||||
RegionAdder task = new RegionAdder(manager, region);
|
||||
task.setLocatorPolicy(UserLocatorPolicy.UUID_ONLY);
|
||||
task.setOwnersInput(new String[]{player.getName()});
|
||||
|
||||
final String description = String.format("Claiming region '%s'", id);
|
||||
AsyncCommandBuilder.wrap(task, sender)
|
||||
.registerWithSupervisor(WorldGuard.getInstance().getSupervisor(), description)
|
||||
.sendMessageAfterDelay("(Please wait... " + description + ")")
|
||||
.onSuccess(TextComponent.of(String.format("A new region has been claimed named '%s'.", id)), null)
|
||||
.onFailure("Failed to claim region", WorldGuard.getInstance().getExceptionConverter())
|
||||
.buildAndExec(WorldGuard.getInstance().getExecutorService());
|
||||
region.getOwners().addPlayer(player);
|
||||
manager.addRegion(region);
|
||||
player.print(TextComponent.of(String.format("A new region has been claimed named '%s'.", id)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -595,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());
|
||||
}
|
||||
|
||||
|
@ -606,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());
|
||||
}
|
||||
|
||||
|
@ -1200,7 +1192,7 @@ public final class RegionCommands extends RegionCommandsBase {
|
|||
// TODO: Add some method to create a safe teleport location.
|
||||
// The method AbstractPlayerActor$findFreePoisition(Location loc) is no good way for this.
|
||||
// It doesn't return the found location and it can't be checked if the location is inside the region.
|
||||
throw new CommandException("Center teleport is only availible in Spectator gamemode.");
|
||||
throw new CommandException("Center teleport is only available in Spectator gamemode.");
|
||||
}
|
||||
} else {
|
||||
teleportLocation = FlagValueCalculator.getEffectiveFlagOf(existing, Flags.TELE_LOC, player);
|
||||
|
|
|
@ -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;
|
||||
|
@ -308,8 +305,8 @@ class RegionCommandsBase {
|
|||
// Detect the type of region from WorldEdit
|
||||
if (selection instanceof Polygonal2DRegion) {
|
||||
Polygonal2DRegion polySel = (Polygonal2DRegion) selection;
|
||||
int minY = polySel.getMinimumPoint().getBlockY();
|
||||
int maxY = polySel.getMaximumPoint().getBlockY();
|
||||
int minY = polySel.getMinimumPoint().y();
|
||||
int maxY = polySel.getMaximumPoint().y();
|
||||
return new ProtectedPolygonalRegion(id, polySel.getPoints(), minY, maxY);
|
||||
} else if (selection instanceof CuboidRegion) {
|
||||
BlockVector3 min = selection.getMinimumPoint();
|
||||
|
@ -348,7 +345,7 @@ class RegionCommandsBase {
|
|||
if (region instanceof GlobalProtectedRegion) {
|
||||
return;
|
||||
}
|
||||
int height = region.getMaximumPoint().getBlockY() - region.getMinimumPoint().getBlockY();
|
||||
int height = region.getMaximumPoint().y() - region.getMinimumPoint().y();
|
||||
if (height <= 2) {
|
||||
sender.printDebug("(Warning: The height of the region was " + (height + 1) + " block(s).)");
|
||||
}
|
||||
|
@ -418,9 +415,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);
|
||||
}
|
||||
|
|
|
@ -139,6 +139,8 @@ public abstract class WorldConfiguration {
|
|||
public boolean disablePlayerCropTrampling;
|
||||
public boolean disableCreatureTurtleEggTrampling;
|
||||
public boolean disablePlayerTurtleEggTrampling;
|
||||
public boolean disableCreatureSnifferEggTrampling;
|
||||
public boolean disablePlayerSnifferEggTrampling;
|
||||
public boolean preventLightningFire;
|
||||
public Set<String> disallowedLightningBlocks;
|
||||
public boolean disableThunder;
|
||||
|
@ -159,11 +161,13 @@ public abstract class WorldConfiguration {
|
|||
public boolean disableMyceliumSpread;
|
||||
public boolean disableVineGrowth;
|
||||
public boolean disableRockGrowth;
|
||||
public boolean disableSculkGrowth;
|
||||
public boolean disableCropGrowth;
|
||||
public boolean disableEndermanGriefing;
|
||||
public boolean disableSnowmanTrails;
|
||||
public boolean disableSoilDehydration;
|
||||
public boolean disableCoralBlockFade;
|
||||
public boolean disableCopperBlockFade;
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -409,15 +488,18 @@ public class DefaultDomain implements Domain, ChangeTracked {
|
|||
final TextComponent.Builder builder = TextComponent.builder("");
|
||||
final Iterator<TextComponent> profiles = profileMap.keySet().stream().sorted().map(name -> {
|
||||
final UUID uuid = profileMap.get(name);
|
||||
final TextComponent component = TextComponent.of(name, TextColor.YELLOW)
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, uuid == null
|
||||
? TextComponent.of("Name only", TextColor.GRAY)
|
||||
: TextComponent.of("Last known name of uuid: ", TextColor.GRAY)
|
||||
.append(TextComponent.of(uuid.toString(), TextColor.WHITE))));
|
||||
if (uuid == null) {
|
||||
return component;
|
||||
return TextComponent.of(name, TextColor.YELLOW)
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Name only", TextColor.GRAY)
|
||||
.append(TextComponent.newline()).append(TextComponent.of("Click to copy"))))
|
||||
.clickEvent(ClickEvent.of(ClickEvent.Action.COPY_TO_CLIPBOARD, name));
|
||||
} else {
|
||||
return TextComponent.of(name, TextColor.YELLOW)
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Last known name of uuid: ", TextColor.GRAY)
|
||||
.append(TextComponent.of(uuid.toString(), TextColor.WHITE))
|
||||
.append(TextComponent.newline()).append(TextComponent.of("Click to copy"))))
|
||||
.clickEvent(ClickEvent.of(ClickEvent.Action.COPY_TO_CLIPBOARD, uuid.toString()));
|
||||
}
|
||||
return component.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, uuid.toString()));
|
||||
}).iterator();
|
||||
while (profiles.hasNext()) {
|
||||
builder.append(profiles.next());
|
||||
|
@ -428,30 +510,50 @@ public class DefaultDomain implements Domain, ChangeTracked {
|
|||
|
||||
if (!uuids.isEmpty()) {
|
||||
builder.append(TextComponent.of(uuids.size() + " unknown uuid" + (uuids.size() == 1 ? "" : "s"), TextColor.GRAY)
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of(String.join("\n", uuids))
|
||||
.append(TextComponent.newline().append(TextComponent.of("Click to select")))))
|
||||
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, String.join(",", uuids))));
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Unable to resolve the name for:", TextColor.GRAY)
|
||||
.append(TextComponent.newline())
|
||||
.append(TextComponent.of(String.join("\n", uuids), TextColor.WHITE))
|
||||
.append(TextComponent.newline().append(TextComponent.of("Click to copy")))))
|
||||
.clickEvent(ClickEvent.of(ClickEvent.Action.COPY_TO_CLIPBOARD, String.join(",", uuids))));
|
||||
}
|
||||
|
||||
|
||||
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 +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -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)) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -57,6 +57,6 @@ public class EntityTypeFlag extends Flag<EntityType> {
|
|||
|
||||
@Override
|
||||
public Object marshal(EntityType o) {
|
||||
return o.getId();
|
||||
return o.id();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -121,9 +121,11 @@ public final class Flags {
|
|||
public static final StateFlag MYCELIUM_SPREAD = register(new StateFlag("mycelium-spread", true));
|
||||
public static final StateFlag VINE_GROWTH = register(new StateFlag("vine-growth", true));
|
||||
public static final StateFlag ROCK_GROWTH = register(new StateFlag("rock-growth", true));
|
||||
public static final StateFlag SCULK_GROWTH = register (new StateFlag("sculk-growth", true));
|
||||
public static final StateFlag CROP_GROWTH = register(new StateFlag("crop-growth", true));
|
||||
public static final StateFlag SOIL_DRY = register(new StateFlag("soil-dry", true));
|
||||
public static final StateFlag CORAL_FADE = register(new StateFlag("coral-fade", true));
|
||||
public static final StateFlag COPPER_FADE = register(new StateFlag("copper-fade", true));
|
||||
public static final StateFlag WATER_FLOW = register(new StateFlag("water-flow", true));
|
||||
public static final StateFlag LAVA_FLOW = register(new StateFlag("lava-flow", true));
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -57,6 +57,6 @@ public class GameModeTypeFlag extends Flag<GameMode> {
|
|||
|
||||
@Override
|
||||
public Object marshal(GameMode o) {
|
||||
return o.getId();
|
||||
return o.id();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
@ -137,9 +137,9 @@ public class LocationFlag extends Flag<Location> {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
vec.put("x", position.getX());
|
||||
vec.put("y", position.getY());
|
||||
vec.put("z", position.getZ());
|
||||
vec.put("x", position.x());
|
||||
vec.put("y", position.y());
|
||||
vec.put("z", position.z());
|
||||
vec.put("yaw", o.getYaw());
|
||||
vec.put("pitch", o.getPitch());
|
||||
return vec;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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() {
|
||||
|
@ -61,6 +61,6 @@ public class RegistryFlag<T extends Keyed> extends Flag<T> {
|
|||
|
||||
@Override
|
||||
public Object marshal(T o) {
|
||||
return o.getId();
|
||||
return o.id();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,9 +82,9 @@ public class VectorFlag extends Flag<Vector3> {
|
|||
@Override
|
||||
public Object marshal(Vector3 o) {
|
||||
Map<String, Object> vec = new HashMap<>();
|
||||
vec.put("x", o.getX());
|
||||
vec.put("y", o.getY());
|
||||
vec.put("z", o.getZ());
|
||||
vec.put("x", o.x());
|
||||
vec.put("y", o.y());
|
||||
vec.put("z", o.z());
|
||||
return vec;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -57,6 +57,6 @@ public class WeatherTypeFlag extends Flag<WeatherType> {
|
|||
|
||||
@Override
|
||||
public Object marshal(WeatherType o) {
|
||||
return o.getId();
|
||||
return o.id();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -93,10 +93,10 @@ public class ChunkHashTable implements ConcurrentRegionIndex {
|
|||
private ChunkState get(BlockVector2 position, boolean create) {
|
||||
ChunkState state;
|
||||
synchronized (lock) {
|
||||
state = states.get(position.getBlockX(), position.getBlockZ());
|
||||
state = states.get(position.x(), position.z());
|
||||
if (state == null && create) {
|
||||
state = new ChunkState(position);
|
||||
states.put(position.getBlockX(), position.getBlockZ(), state);
|
||||
states.put(position.x(), position.z(), state);
|
||||
executor.submit(new EnumerateRegions(position));
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ public class ChunkHashTable implements ConcurrentRegionIndex {
|
|||
for (ChunkState state : previousStates.values()) {
|
||||
BlockVector2 position = state.getPosition();
|
||||
positions.add(position);
|
||||
states.put(position.getBlockX(), position.getBlockZ(), new ChunkState(position));
|
||||
states.put(position.x(), position.z(), new ChunkState(position));
|
||||
}
|
||||
|
||||
if (!positions.isEmpty()) {
|
||||
|
@ -179,9 +179,9 @@ public class ChunkHashTable implements ConcurrentRegionIndex {
|
|||
public void forget(BlockVector2 chunkPosition) {
|
||||
checkNotNull(chunkPosition);
|
||||
synchronized (lock) {
|
||||
states.remove(chunkPosition.getBlockX(), chunkPosition.getBlockZ());
|
||||
states.remove(chunkPosition.x(), chunkPosition.z());
|
||||
ChunkState state = lastState;
|
||||
if (state != null && state.getPosition().getBlockX() == chunkPosition.getBlockX() && state.getPosition().getBlockZ() == chunkPosition.getBlockZ()) {
|
||||
if (state != null && state.getPosition().x() == chunkPosition.x() && state.getPosition().z() == chunkPosition.z()) {
|
||||
lastState = null;
|
||||
}
|
||||
}
|
||||
|
@ -238,10 +238,10 @@ public class ChunkHashTable implements ConcurrentRegionIndex {
|
|||
checkNotNull(consumer);
|
||||
|
||||
ChunkState state = lastState;
|
||||
int chunkX = position.getBlockX() >> 4;
|
||||
int chunkZ = position.getBlockZ() >> 4;
|
||||
int chunkX = position.x() >> 4;
|
||||
int chunkZ = position.z() >> 4;
|
||||
|
||||
if (state == null || state.getPosition().getBlockX() != chunkX || state.getPosition().getBlockZ() != chunkZ) {
|
||||
if (state == null || state.getPosition().x() != chunkX || state.getPosition().z() != chunkZ) {
|
||||
state = get(BlockVector2.at(chunkX, chunkZ), false);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public class PriorityRTreeIndex extends HashMapIndex {
|
|||
@Override
|
||||
public void applyContaining(BlockVector3 position, Predicate<ProtectedRegion> consumer) {
|
||||
Set<ProtectedRegion> seen = new HashSet<>();
|
||||
MBR pointMBR = new SimpleMBR(position.getX(), position.getX(), position.getY(), position.getY(), position.getZ(), position.getZ());
|
||||
MBR pointMBR = new SimpleMBR(position.x(), position.x(), position.y(), position.y(), position.z(), position.z());
|
||||
|
||||
for (ProtectedRegion region : tree.find(pointMBR)) {
|
||||
if (region.contains(position) && !seen.contains(region)) {
|
||||
|
@ -87,7 +87,7 @@ public class PriorityRTreeIndex extends HashMapIndex {
|
|||
BlockVector3 max = region.getMaximumPoint().ceil();
|
||||
|
||||
Set<ProtectedRegion> candidates = new HashSet<>();
|
||||
MBR pointMBR = new SimpleMBR(min.getX(), max.getX(), min.getY(), max.getY(), min.getZ(), max.getZ());
|
||||
MBR pointMBR = new SimpleMBR(min.x(), max.x(), min.y(), max.y(), min.z(), max.z());
|
||||
|
||||
for (ProtectedRegion found : tree.find(pointMBR)) {
|
||||
candidates.add(found);
|
||||
|
|
|
@ -84,8 +84,8 @@ public class WorldHeightMigration extends AbstractMigration {
|
|||
if (min == 0 && max == 255) return;
|
||||
}
|
||||
for (ProtectedRegion region : regions) {
|
||||
if (region.getMinimumPoint().getBlockY() <= 0
|
||||
&& region.getMaximumPoint().getBlockY() >= 255) {
|
||||
if (region.getMinimumPoint().y() <= 0
|
||||
&& region.getMaximumPoint().y() >= 255) {
|
||||
expand(region, min, max);
|
||||
changed++;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -41,6 +43,7 @@ import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
|
|||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.DumperOptions.FlowStyle;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||
import org.yaml.snakeyaml.parser.ParserException;
|
||||
|
@ -89,7 +92,7 @@ public class YamlRegionFile implements RegionDatabase {
|
|||
options.setIndent(4);
|
||||
options.setDefaultFlowStyle(FlowStyle.AUTO);
|
||||
|
||||
ERROR_DUMP_YAML = new Yaml(new SafeConstructor(), new Representer(), options);
|
||||
ERROR_DUMP_YAML = new Yaml(new SafeConstructor(new LoaderOptions()), new Representer(new DumperOptions()), options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -213,14 +216,14 @@ public class YamlRegionFile implements RegionDatabase {
|
|||
} else if (region instanceof ProtectedPolygonalRegion) {
|
||||
ProtectedPolygonalRegion poly = (ProtectedPolygonalRegion) region;
|
||||
node.setProperty("type", "poly2d");
|
||||
node.setProperty("min-y", poly.getMinimumPoint().getBlockY());
|
||||
node.setProperty("max-y", poly.getMaximumPoint().getBlockY());
|
||||
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.getBlockX());
|
||||
data.put("z", point.getBlockZ());
|
||||
data.put("x", point.x());
|
||||
data.put("z", point.z());
|
||||
points.add(data);
|
||||
}
|
||||
|
||||
|
@ -284,6 +287,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;
|
||||
}
|
||||
|
||||
|
@ -304,6 +313,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;
|
||||
}
|
||||
|
||||
|
@ -322,7 +339,7 @@ public class YamlRegionFile implements RegionDatabase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a YAML processer instance.
|
||||
* Create a YAML processor instance.
|
||||
*
|
||||
* @param file the file
|
||||
* @return a processor instance
|
||||
|
@ -336,7 +353,7 @@ public class YamlRegionFile implements RegionDatabase {
|
|||
* Dump the given object as YAML for debugging purposes.
|
||||
*
|
||||
* @param object the object
|
||||
* @return the YAML string or an error string if dumping fals
|
||||
* @return the YAML string or an error string if dumping fails
|
||||
*/
|
||||
private static String toYamlOutput(Object object) {
|
||||
try {
|
||||
|
|
|
@ -113,12 +113,12 @@ class RegionInserter {
|
|||
BlockVector3 max = region.getMaximumPoint();
|
||||
|
||||
stmt.setString(1, region.getId());
|
||||
stmt.setInt(2, min.getBlockZ());
|
||||
stmt.setInt(3, min.getBlockY());
|
||||
stmt.setInt(4, min.getBlockX());
|
||||
stmt.setInt(5, max.getBlockZ());
|
||||
stmt.setInt(6, max.getBlockY());
|
||||
stmt.setInt(7, max.getBlockX());
|
||||
stmt.setInt(2, min.z());
|
||||
stmt.setInt(3, min.y());
|
||||
stmt.setInt(4, min.x());
|
||||
stmt.setInt(5, max.z());
|
||||
stmt.setInt(6, max.y());
|
||||
stmt.setInt(7, max.x());
|
||||
stmt.addBatch();
|
||||
}
|
||||
|
||||
|
@ -141,8 +141,8 @@ class RegionInserter {
|
|||
for (List<ProtectedPolygonalRegion> partition : Lists.partition(polygons, StatementBatch.MAX_BATCH_SIZE)) {
|
||||
for (ProtectedPolygonalRegion region : partition) {
|
||||
stmt.setString(1, region.getId());
|
||||
stmt.setInt(2, region.getMaximumPoint().getBlockY());
|
||||
stmt.setInt(3, region.getMinimumPoint().getBlockY());
|
||||
stmt.setInt(2, region.getMaximumPoint().y());
|
||||
stmt.setInt(3, region.getMinimumPoint().y());
|
||||
stmt.addBatch();
|
||||
}
|
||||
|
||||
|
@ -167,8 +167,8 @@ class RegionInserter {
|
|||
for (ProtectedPolygonalRegion region : polygons) {
|
||||
for (BlockVector2 point : region.getPoints()) {
|
||||
stmt.setString(1, region.getId());
|
||||
stmt.setInt(2, point.getBlockZ());
|
||||
stmt.setInt(3, point.getBlockX());
|
||||
stmt.setInt(2, point.z());
|
||||
stmt.setInt(3, point.x());
|
||||
batch.addBatch();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import com.sk89q.worldguard.util.io.Closer;
|
|||
import com.sk89q.worldguard.util.sql.DataSourceConfig;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.DumperOptions.FlowStyle;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||
import org.yaml.snakeyaml.representer.Representer;
|
||||
|
@ -191,11 +192,11 @@ class SQLRegionDatabase implements RegionDatabase {
|
|||
DumperOptions options = new DumperOptions();
|
||||
options.setIndent(2);
|
||||
options.setDefaultFlowStyle(FlowStyle.FLOW);
|
||||
Representer representer = new Representer();
|
||||
Representer representer = new Representer(options);
|
||||
representer.setDefaultFlowStyle(FlowStyle.FLOW);
|
||||
|
||||
// We have to use this in order to properly save non-string values
|
||||
return new Yaml(new SafeConstructor(), new Representer(), options);
|
||||
return new Yaml(new SafeConstructor(new LoaderOptions()), representer, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -69,7 +69,7 @@ public class GlobalProtectedRegion extends ProtectedRegion {
|
|||
public List<BlockVector2> getPoints() {
|
||||
// This doesn't make sense
|
||||
List<BlockVector2> pts = new ArrayList<>();
|
||||
pts.add(BlockVector2.at(min.getBlockX(), min.getBlockZ()));
|
||||
pts.add(BlockVector2.at(min.x(), min.z()));
|
||||
return pts;
|
||||
}
|
||||
|
||||
|
|
|
@ -113,10 +113,10 @@ public class ProtectedCuboidRegion extends ProtectedRegion {
|
|||
@Override
|
||||
public List<BlockVector2> getPoints() {
|
||||
List<BlockVector2> pts = new ArrayList<>();
|
||||
int x1 = min.getBlockX();
|
||||
int x2 = max.getBlockX();
|
||||
int z1 = min.getBlockZ();
|
||||
int z2 = max.getBlockZ();
|
||||
int x1 = min.x();
|
||||
int x2 = max.x();
|
||||
int z1 = min.z();
|
||||
int z2 = max.z();
|
||||
|
||||
pts.add(BlockVector2.at(x1, z1));
|
||||
pts.add(BlockVector2.at(x2, z1));
|
||||
|
@ -128,12 +128,12 @@ public class ProtectedCuboidRegion extends ProtectedRegion {
|
|||
|
||||
@Override
|
||||
public boolean contains(BlockVector3 pt) {
|
||||
final double x = pt.getX();
|
||||
final double y = pt.getY();
|
||||
final double z = pt.getZ();
|
||||
return x >= min.getBlockX() && x < max.getBlockX() + 1
|
||||
&& y >= min.getBlockY() && y < max.getBlockY() + 1
|
||||
&& z >= min.getBlockZ() && z < max.getBlockZ() + 1;
|
||||
final double x = pt.x();
|
||||
final double y = pt.y();
|
||||
final double z = pt.z();
|
||||
return x >= min.x() && x < max.x() + 1
|
||||
&& y >= min.y() && y < max.y() + 1
|
||||
&& z >= min.z() && z < max.z() + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -143,10 +143,10 @@ public class ProtectedCuboidRegion extends ProtectedRegion {
|
|||
|
||||
@Override
|
||||
Area toArea() {
|
||||
int x = getMinimumPoint().getBlockX();
|
||||
int z = getMinimumPoint().getBlockZ();
|
||||
int width = getMaximumPoint().getBlockX() - x + 1;
|
||||
int height = getMaximumPoint().getBlockZ() - z + 1;
|
||||
int x = getMinimumPoint().x();
|
||||
int z = getMinimumPoint().z();
|
||||
int width = getMaximumPoint().x() - x + 1;
|
||||
int height = getMaximumPoint().z() - z + 1;
|
||||
return new Area(new Rectangle(x, z, width, height));
|
||||
}
|
||||
|
||||
|
@ -161,9 +161,9 @@ public class ProtectedCuboidRegion extends ProtectedRegion {
|
|||
|
||||
@Override
|
||||
public int volume() {
|
||||
int xLength = max.getBlockX() - min.getBlockX() + 1;
|
||||
int yLength = max.getBlockY() - min.getBlockY() + 1;
|
||||
int zLength = max.getBlockZ() - min.getBlockZ() + 1;
|
||||
int xLength = max.x() - min.x() + 1;
|
||||
int yLength = max.y() - min.y() + 1;
|
||||
int zLength = max.z() - min.z() + 1;
|
||||
|
||||
try {
|
||||
long v = MathUtils.checkedMultiply(xLength, yLength);
|
||||
|
|
|
@ -65,8 +65,8 @@ public class ProtectedPolygonalRegion extends ProtectedRegion {
|
|||
ImmutableList<BlockVector2> immutablePoints = ImmutableList.copyOf(points);
|
||||
setMinMaxPoints(immutablePoints, minY, maxY);
|
||||
this.points = immutablePoints;
|
||||
this.minY = min.getBlockY();
|
||||
this.maxY = max.getBlockY();
|
||||
this.minY = min.y();
|
||||
this.maxY = max.y();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,7 +82,7 @@ public class ProtectedPolygonalRegion extends ProtectedRegion {
|
|||
List<BlockVector3> points = new ArrayList<>();
|
||||
int y = minY;
|
||||
for (BlockVector2 point2D : points2D) {
|
||||
points.add(BlockVector3.at(point2D.getBlockX(), y, point2D.getBlockZ()));
|
||||
points.add(BlockVector3.at(point2D.x(), y, point2D.z()));
|
||||
y = maxY;
|
||||
}
|
||||
setMinMaxPoints(points);
|
||||
|
@ -102,15 +102,15 @@ public class ProtectedPolygonalRegion extends ProtectedRegion {
|
|||
public boolean contains(BlockVector3 position) {
|
||||
checkNotNull(position);
|
||||
|
||||
int targetX = position.getBlockX(); // Width
|
||||
int targetY = position.getBlockY(); // Height
|
||||
int targetZ = position.getBlockZ(); // Depth
|
||||
int targetX = position.x(); // Width
|
||||
int targetY = position.y(); // Height
|
||||
int targetZ = position.z(); // Depth
|
||||
|
||||
if (targetY < minY || targetY > maxY) {
|
||||
return false;
|
||||
}
|
||||
//Quick and dirty check.
|
||||
if (targetX < min.getBlockX() || targetX > max.getBlockX() || targetZ < min.getBlockZ() || targetZ > max.getBlockZ()) {
|
||||
if (targetX < min.x() || targetX > max.x() || targetZ < min.z() || targetZ > max.z()) {
|
||||
return false;
|
||||
}
|
||||
boolean inside = false;
|
||||
|
@ -122,12 +122,12 @@ public class ProtectedPolygonalRegion extends ProtectedRegion {
|
|||
long crossproduct;
|
||||
int i;
|
||||
|
||||
xOld = points.get(npoints - 1).getBlockX();
|
||||
zOld = points.get(npoints - 1).getBlockZ();
|
||||
xOld = points.get(npoints - 1).x();
|
||||
zOld = points.get(npoints - 1).z();
|
||||
|
||||
for (i = 0; i < npoints; i++) {
|
||||
xNew = points.get(i).getBlockX();
|
||||
zNew = points.get(i).getBlockZ();
|
||||
xNew = points.get(i).x();
|
||||
zNew = points.get(i).z();
|
||||
//Check for corner
|
||||
if (xNew == targetX && zNew == targetZ) {
|
||||
return true;
|
||||
|
@ -173,8 +173,8 @@ public class ProtectedPolygonalRegion extends ProtectedRegion {
|
|||
|
||||
int i = 0;
|
||||
for (BlockVector2 point : points) {
|
||||
xCoords[i] = point.getBlockX();
|
||||
yCoords[i] = point.getBlockZ();
|
||||
xCoords[i] = point.x();
|
||||
yCoords[i] = point.z();
|
||||
i++;
|
||||
}
|
||||
|
||||
|
|
|
@ -92,17 +92,17 @@ public abstract class ProtectedRegion implements ChangeTracked, Comparable<Prote
|
|||
* @param points the points to set with at least one entry
|
||||
*/
|
||||
protected void setMinMaxPoints(List<BlockVector3> points) {
|
||||
int minX = points.get(0).getBlockX();
|
||||
int minY = points.get(0).getBlockY();
|
||||
int minZ = points.get(0).getBlockZ();
|
||||
int minX = points.get(0).x();
|
||||
int minY = points.get(0).y();
|
||||
int minZ = points.get(0).z();
|
||||
int maxX = minX;
|
||||
int maxY = minY;
|
||||
int maxZ = minZ;
|
||||
|
||||
for (BlockVector3 v : points) {
|
||||
int x = v.getBlockX();
|
||||
int y = v.getBlockY();
|
||||
int z = v.getBlockZ();
|
||||
int x = v.x();
|
||||
int y = v.y();
|
||||
int z = v.z();
|
||||
|
||||
if (x < minX) minX = x;
|
||||
if (y < minY) minY = y;
|
||||
|
@ -514,7 +514,7 @@ public abstract class ProtectedRegion implements ChangeTracked, Comparable<Prote
|
|||
*/
|
||||
public boolean contains(BlockVector2 position) {
|
||||
checkNotNull(position);
|
||||
return contains(BlockVector3.at(position.getBlockX(), min.getBlockY(), position.getBlockZ()));
|
||||
return contains(BlockVector3.at(position.x(), min.y(), position.z()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -607,16 +607,16 @@ public abstract class ProtectedRegion implements ChangeTracked, Comparable<Prote
|
|||
BlockVector3 rMaxPoint = region.getMaximumPoint();
|
||||
BlockVector3 min = getMinimumPoint();
|
||||
|
||||
if (rMaxPoint.getBlockX() < min.getBlockX()) return false;
|
||||
if (rMaxPoint.getBlockY() < min.getBlockY()) return false;
|
||||
if (rMaxPoint.getBlockZ() < min.getBlockZ()) return false;
|
||||
if (rMaxPoint.x() < min.x()) return false;
|
||||
if (rMaxPoint.y() < min.y()) return false;
|
||||
if (rMaxPoint.z() < min.z()) return false;
|
||||
|
||||
BlockVector3 rMinPoint = region.getMinimumPoint();
|
||||
BlockVector3 max = getMaximumPoint();
|
||||
|
||||
if (rMinPoint.getBlockX() > max.getBlockX()) return false;
|
||||
if (rMinPoint.getBlockY() > max.getBlockY()) return false;
|
||||
if (rMinPoint.getBlockZ() > max.getBlockZ()) return false;
|
||||
if (rMinPoint.x() > max.x()) return false;
|
||||
if (rMinPoint.y() > max.y()) return false;
|
||||
if (rMinPoint.z() > max.z()) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -636,16 +636,16 @@ public abstract class ProtectedRegion implements ChangeTracked, Comparable<Prote
|
|||
for (BlockVector2 aPts2 : pts2) {
|
||||
|
||||
Line2D line1 = new Line2D.Double(
|
||||
lastPt1.getBlockX(),
|
||||
lastPt1.getBlockZ(),
|
||||
aPts1.getBlockX(),
|
||||
aPts1.getBlockZ());
|
||||
lastPt1.x(),
|
||||
lastPt1.z(),
|
||||
aPts1.x(),
|
||||
aPts1.z());
|
||||
|
||||
if (line1.intersectsLine(
|
||||
lastPt2.getBlockX(),
|
||||
lastPt2.getBlockZ(),
|
||||
aPts2.getBlockX(),
|
||||
aPts2.getBlockZ())) {
|
||||
lastPt2.x(),
|
||||
lastPt2.z(),
|
||||
aPts2.x(),
|
||||
aPts2.z())) {
|
||||
return true;
|
||||
}
|
||||
lastPt2 = aPts2;
|
||||
|
|
|
@ -30,27 +30,21 @@ public class ProtectedRegionMBRConverter implements MBRConverter<ProtectedRegion
|
|||
|
||||
@Override
|
||||
public double getMax(int dimension, ProtectedRegion region) {
|
||||
switch (dimension) {
|
||||
case 0:
|
||||
return region.getMaximumPoint().getBlockX();
|
||||
case 1:
|
||||
return region.getMaximumPoint().getBlockY();
|
||||
case 2:
|
||||
return region.getMaximumPoint().getBlockZ();
|
||||
}
|
||||
return 0;
|
||||
return switch (dimension) {
|
||||
case 0 -> region.getMaximumPoint().x();
|
||||
case 1 -> region.getMaximumPoint().y();
|
||||
case 2 -> region.getMaximumPoint().z();
|
||||
default -> 0;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMin(int dimension, ProtectedRegion region) {
|
||||
switch (dimension) {
|
||||
case 0:
|
||||
return region.getMinimumPoint().getBlockX();
|
||||
case 1:
|
||||
return region.getMinimumPoint().getBlockY();
|
||||
case 2:
|
||||
return region.getMinimumPoint().getBlockZ();
|
||||
}
|
||||
return 0;
|
||||
return switch (dimension) {
|
||||
case 0 -> region.getMinimumPoint().x();
|
||||
case 1 -> region.getMinimumPoint().y();
|
||||
case 2 -> region.getMinimumPoint().z();
|
||||
default -> 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue