├── .github ├── FUNDING.yml └── ISSUE_TEMPLATE │ ├── config.yml │ └── feature_request.yml ├── gradle.properties ├── worldguard-logo.png ├── worldguard-libs ├── bukkit │ └── build.gradle.kts ├── build.gradle.kts └── core │ └── build.gradle.kts ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .travis.yml ├── settings.gradle.kts ├── worldguard-bukkit ├── src │ └── main │ │ ├── resources │ │ ├── plugin.yml │ │ ├── defaults │ │ │ ├── config_world.yml │ │ │ └── config.yml │ │ └── migrations │ │ │ └── region │ │ │ └── mysql │ │ │ └── V2__Bug_fix_and_UUID.sql │ │ └── java │ │ └── com │ │ └── sk89q │ │ └── worldguard │ │ └── bukkit │ │ ├── event │ │ ├── Handleable.java │ │ ├── debug │ │ │ ├── CancelLogging.java │ │ │ ├── LoggingBlockBreakEvent.java │ │ │ ├── LoggingEntityDamageByEntityEvent.java │ │ │ ├── CancelLogger.java │ │ │ └── LoggingBlockPlaceEvent.java │ │ ├── BulkEvent.java │ │ ├── player │ │ │ └── ProcessPlayerEvent.java │ │ └── entity │ │ │ ├── UseEntityEvent.java │ │ │ ├── DamageEntityEvent.java │ │ │ └── DestroyEntityEvent.java │ │ ├── util │ │ └── report │ │ │ ├── ServicesReport.java │ │ │ └── DatapackReport.java │ │ ├── listener │ │ ├── WorldGuardServerListener.java │ │ └── debounce │ │ │ ├── BlockPistonRetractKey.java │ │ │ └── BlockPistonExtendKey.java │ │ ├── protection │ │ └── events │ │ │ └── flags │ │ │ └── FlagContextCreateEvent.java │ │ └── chest │ │ └── BukkitSignChestProtection.java └── contrib │ └── blacklist_table.sql ├── .gitignore ├── config └── checkstyle │ ├── suppressions.xml │ └── import-control.xml ├── worldguard-core ├── build.gradle.kts └── src │ ├── main │ └── java │ │ └── com │ │ └── sk89q │ │ └── worldguard │ │ ├── internal │ │ ├── PermissionModel.java │ │ ├── permission │ │ │ └── AbstractPermissionModel.java │ │ └── platform │ │ │ └── DebugHandler.java │ │ ├── domains │ │ ├── Association.java │ │ └── registry │ │ │ ├── DomainConflictException.java │ │ │ ├── DomainFactory.java │ │ │ └── InvalidDomainFormatException.java │ │ ├── blacklist │ │ ├── action │ │ │ ├── ActionResult.java │ │ │ ├── Action.java │ │ │ ├── RepeatGuardedAction.java │ │ │ ├── DenyAction.java │ │ │ ├── AllowAction.java │ │ │ ├── LogAction.java │ │ │ ├── NotifyAction.java │ │ │ ├── KickAction.java │ │ │ ├── BanAction.java │ │ │ └── TellAction.java │ │ ├── target │ │ │ ├── TargetMatcherParseException.java │ │ │ ├── Target.java │ │ │ ├── ItemTarget.java │ │ │ ├── BlockTarget.java │ │ │ ├── TargetMatcher.java │ │ │ ├── BlockMatcher.java │ │ │ ├── ItemMatcher.java │ │ │ ├── ItemBlockMatcher.java │ │ │ └── TargetMatcherParser.java │ │ ├── logger │ │ │ ├── LoggerHandler.java │ │ │ └── ConsoleHandler.java │ │ ├── TrackedEvent.java │ │ └── event │ │ │ ├── ItemUseBlacklistEvent.java │ │ │ ├── ItemDropBlacklistEvent.java │ │ │ ├── ItemEquipBlacklistEvent.java │ │ │ ├── BlockBreakBlacklistEvent.java │ │ │ ├── BlockPlaceBlacklistEvent.java │ │ │ ├── ItemAcquireBlacklistEvent.java │ │ │ ├── BlockInteractBlacklistEvent.java │ │ │ ├── BlockBlacklistEvent.java │ │ │ ├── ItemBlacklistEvent.java │ │ │ ├── EventType.java │ │ │ ├── ItemDestroyWithBlacklistEvent.java │ │ │ └── BlockDispenseBlacklistEvent.java │ │ ├── util │ │ ├── collect │ │ │ ├── EntryBase.java │ │ │ ├── LongHash.java │ │ │ └── LongHashTable.java │ │ ├── profiler │ │ │ ├── ThreadIdFilter.java │ │ │ ├── ThreadNameFilter.java │ │ │ └── StackTraceNode.java │ │ ├── ChangeTracked.java │ │ ├── formatting │ │ │ └── component │ │ │ │ ├── Notify.java │ │ │ │ └── BlacklistNotify.java │ │ ├── Locations.java │ │ ├── report │ │ │ └── RegionReport.java │ │ └── Entities.java │ │ ├── protection │ │ ├── managers │ │ │ ├── storage │ │ │ │ ├── DriverType.java │ │ │ │ ├── StorageException.java │ │ │ │ ├── DifferenceSaveException.java │ │ │ │ ├── sql │ │ │ │ │ ├── StatementBatch.java │ │ │ │ │ └── DomainTableCache.java │ │ │ │ └── MemoryRegionDatabase.java │ │ │ ├── index │ │ │ │ ├── AbstractRegionIndex.java │ │ │ │ └── ConcurrentRegionIndex.java │ │ │ ├── migration │ │ │ │ ├── Migration.java │ │ │ │ └── MigrationException.java │ │ │ └── RemovalStrategy.java │ │ ├── flags │ │ │ ├── registry │ │ │ │ ├── FlagConflictException.java │ │ │ │ └── UnknownFlag.java │ │ │ ├── InvalidFlagFormatException.java │ │ │ ├── InvalidFlagFormat.java │ │ │ ├── BuildFlag.java │ │ │ ├── DoubleFlag.java │ │ │ ├── IntegerFlag.java │ │ │ ├── CommandStringFlag.java │ │ │ ├── NumberFlag.java │ │ │ ├── RegionGroup.java │ │ │ └── UUIDFlag.java │ │ ├── util │ │ │ └── UnresolvedNamesException.java │ │ ├── association │ │ │ ├── ConstantAssociation.java │ │ │ ├── RegionAssociable.java │ │ │ └── RegionOverlapAssociation.java │ │ ├── regions │ │ │ ├── RegionType.java │ │ │ └── ProtectedRegionMBRConverter.java │ │ ├── DelayedRegionOverlapAssociation.java │ │ └── AbstractRegionSet.java │ │ ├── session │ │ ├── MoveType.java │ │ ├── WorldPlayerTuple.java │ │ └── handler │ │ │ └── WaterBreathing.java │ │ └── commands │ │ ├── task │ │ ├── RegionManagerLoader.java │ │ └── RegionManagerSaver.java │ │ └── ProtectionCommands.java │ └── test │ └── java │ └── com │ └── sk89q │ └── worldguard │ ├── protection │ ├── HashMapIndexTest.java │ ├── HashMapIndexPriorityTest.java │ ├── PriorityRTreeIndexTest.java │ ├── HashMapIndexRegionOverlapTest.java │ ├── PriorityRTreeRegionOverlapTest.java │ ├── PriorityRTreeRegionPriorityTest.java │ └── PriorityRTreeRegionEntryExitTest.java │ └── domains │ └── CustomUUIDDomain.java ├── HEADER.txt ├── .gitattributes └── COMPILING.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: enginehub 2 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | group=com.sk89q.worldguard 2 | version=7.1.0-SNAPSHOT 3 | -------------------------------------------------------------------------------- /worldguard-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firestarter/worldguard/master/worldguard-logo.png -------------------------------------------------------------------------------- /worldguard-libs/bukkit/build.gradle.kts: -------------------------------------------------------------------------------- 1 | applyLibrariesConfiguration() 2 | constrainDependenciesToLibsCore() -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firestarter/worldguard/master/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /worldguard-libs/build.gradle.kts: -------------------------------------------------------------------------------- 1 | tasks.register("build") { 2 | dependsOn(subprojects.map { it.tasks.named("build") }) 3 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | dist: trusty 3 | jdk: 4 | - oraclejdk11 5 | notifications: 6 | email: false 7 | before_install: chmod +x gradlew 8 | script: ./gradlew build -S 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: EngineHub Discord 4 | url: https://discord.gg/EngineHub 5 | about: Please ask and answer questions here. 6 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "worldguard" 2 | 3 | include("worldguard-libs") 4 | include("worldguard-libs:core") 5 | include("worldguard-core") 6 | //include("worldguard-libs:bukkit") 7 | include("worldguard-bukkit") 8 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: WorldGuard 2 | main: com.sk89q.worldguard.bukkit.WorldGuardPlugin 3 | version: "${internalVersion}" 4 | depend: [WorldEdit] 5 | softdepend: [CommandBook] 6 | api-version: "1.20" 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .project 3 | .settings/ 4 | target/ 5 | 6 | .DS_Store 7 | 8 | **/*.iml 9 | **/.idea 10 | 11 | bin/ 12 | dependency-reduced-pom.xml 13 | *-private.sh 14 | 15 | .gradle/ 16 | **/build/ 17 | out/ 18 | 19 | scripts/ 20 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip 4 | networkTimeout=10000 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /config/checkstyle/suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /worldguard-libs/core/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar 2 | 3 | applyLibrariesConfiguration() 4 | 5 | dependencies { 6 | "shade"("org.enginehub:squirrelid:${Versions.SQUIRRELID}") 7 | "shade"("org.khelekore:prtree:1.5.0") 8 | } 9 | 10 | tasks.named("jar") { 11 | dependencies { 12 | relocate("org.enginehub.squirrelid", "com.sk89q.worldguard.util.profile") { 13 | include(dependency("org.enginehub:squirrelid")) 14 | } 15 | 16 | include(dependency("org.khelekore:prtree")) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /worldguard-core/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `java-library` 3 | } 4 | 5 | applyPlatformAndCoreConfiguration() 6 | 7 | dependencies { 8 | "api"(project(":worldguard-libs:core")) 9 | "api"("com.sk89q.worldedit:worldedit-core:${Versions.WORLDEDIT}") 10 | "implementation"("org.flywaydb:flyway-core:3.0") 11 | "implementation"("org.yaml:snakeyaml:2.0") 12 | "implementation"("com.google.guava:guava:${Versions.GUAVA}") 13 | 14 | "compileOnly"("com.google.code.findbugs:jsr305:${Versions.FINDBUGS}") 15 | "testImplementation"("org.hamcrest:hamcrest-library:2.2") 16 | } 17 | 18 | tasks.withType().configureEach { 19 | dependsOn(":worldguard-libs:build") 20 | } -------------------------------------------------------------------------------- /HEADER.txt: -------------------------------------------------------------------------------- 1 | WorldGuard, a suite of tools for Minecraft 2 | Copyright (C) sk89q 3 | Copyright (C) WorldGuard team and contributors 4 | 5 | This program is free software: you can redistribute it and/or modify it 6 | under the terms of the GNU Lesser General Public License as published by the 7 | Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 13 | for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with this program. If not, see . 17 | -------------------------------------------------------------------------------- /worldguard-bukkit/contrib/blacklist_table.sql: -------------------------------------------------------------------------------- 1 | -- Blacklist table for MySQL. 2 | -- You must still configure WorldGuard to use your database. 3 | -- If you do not plan on using a database for logging blacklist events, 4 | -- you do not need to do anything with this file. 5 | 6 | CREATE TABLE `blacklist_events` ( 7 | `id` int(11) NOT NULL AUTO_INCREMENT, 8 | `event` varchar(25) NOT NULL, 9 | `world` varchar(32) NOT NULL, 10 | `player` varchar(16) NOT NULL, 11 | `x` int(11) NOT NULL, 12 | `y` int(11) NOT NULL, 13 | `z` int(11) NOT NULL, 14 | `item` int(11) NOT NULL, 15 | `time` int(11) NOT NULL, 16 | `comment` varchar(255) NULL, 17 | PRIMARY KEY (`id`) 18 | ); 19 | 20 | -- Required update if you have an older version of the table: 21 | 22 | ALTER TABLE `blacklist_events` ADD `comment` VARCHAR( 255 ) NULL 23 | 24 | ALTER TABLE `blacklist_events` ADD `world` VARCHAR( 32 ) NOT NULL -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | # Force Batch files to CRLF 3 | *.bat eol=crlf -text 4 | 5 | # Java sources 6 | *.java text diff=java 7 | *.kt text diff=java 8 | *.gradle text diff=java 9 | *.gradle.kts text diff=java 10 | 11 | # These files are text and should be normalized (Convert crlf => lf) 12 | *.css text diff=css 13 | *.df text 14 | *.htm text diff=html 15 | *.html text diff=html 16 | *.js text 17 | *.jsp text 18 | *.jspf text 19 | *.jspx text 20 | *.properties text 21 | *.tld text 22 | *.tag text 23 | *.tagx text 24 | *.xml text 25 | 26 | # These files are binary and should be left untouched 27 | # (binary is a macro for -text -diff) 28 | *.class binary 29 | *.dll binary 30 | *.ear binary 31 | *.jar binary 32 | *.so binary 33 | *.war binary 34 | *.jks binary 35 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/resources/defaults/config_world.yml: -------------------------------------------------------------------------------- 1 | # 2 | # WorldGuard's configuration file. 3 | # 4 | # This is the a per-world configuration file. It only affects one 5 | # corresponding world. 6 | # 7 | # About editing this file: 8 | # - DO NOT USE TABS. You MUST use spaces or Bukkit will complain. If 9 | # you use an editor like Notepad++ (recommended for Windows users), you 10 | # must configure it to "replace tabs with spaces." In Notepad++, this can 11 | # be changed in Settings > Preferences > Language Menu. 12 | # - Don't get rid of the indents. They are indented so some entries are 13 | # in categories (like "enforce-single-session" is in the "protection" 14 | # category. 15 | # - If you want to check the format of this file before putting it 16 | # into WorldGuard, paste it into http://yaml-online-parser.appspot.com/ 17 | # and see if it gives "ERROR:". 18 | # - Lines starting with # are comments and so they are ignored. 19 | # 20 | 21 | # -- This should be automatically replaced by the plugin in-game -- -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/resources/migrations/region/mysql/V2__Bug_fix_and_UUID.sql: -------------------------------------------------------------------------------- 1 | -- Fix WORLDGUARD-3117 2 | -- Otherwise, you can't be both an owner and a member of a region 3 | 4 | ALTER TABLE `${tablePrefix}region_players` 5 | DROP PRIMARY KEY, 6 | ADD PRIMARY KEY (`region_id`, `world_id`, `user_id`, `owner`); 7 | 8 | ALTER TABLE `${tablePrefix}region_groups` 9 | DROP PRIMARY KEY, 10 | ADD PRIMARY KEY (`region_id`, `world_id`, `group_id`, `owner`); 11 | 12 | -- Fix WORLDGUARD-3030 13 | -- Adds UUID support 14 | 15 | ALTER TABLE `${tablePrefix}user` 16 | ALTER `name` DROP DEFAULT; 17 | 18 | ALTER TABLE `${tablePrefix}user` 19 | CHANGE COLUMN `name` `name` VARCHAR(64) NULL COLLATE 'utf8_bin' AFTER `id`, 20 | ADD COLUMN `uuid` CHAR(36) NULL AFTER `name`, 21 | ADD UNIQUE INDEX `uuid` (`uuid`); 22 | 23 | -- Strings with differing numbers of trailing spaces are equal in MySQL 24 | -- The domains have been updated to trim strings 25 | 26 | UPDATE `${tablePrefix}user` SET `name` = TRIM(`name`); 27 | UPDATE `${tablePrefix}group` SET `name` = TRIM(`name`); -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/internal/PermissionModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.internal; 21 | 22 | public interface PermissionModel { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/resources/defaults/config.yml: -------------------------------------------------------------------------------- 1 | # 2 | # WorldGuard's configuration file 3 | # 4 | # About editing this file: 5 | # - DO NOT USE TABS. You MUST use spaces or Bukkit will complain. If 6 | # you use an editor like Notepad++ (recommended for Windows users), you 7 | # must configure it to "replace tabs with spaces." In Notepad++, this can 8 | # be changed in Settings > Preferences > Language Menu. 9 | # - Don't get rid of the indents. They are indented so some entries are 10 | # in categories (like "enforce-single-session" is in the "protection" 11 | # category. 12 | # - If you want to check the format of this file before putting it 13 | # into WorldGuard, paste it into http://yaml-online-parser.appspot.com/ 14 | # and see if it gives "ERROR:". 15 | # - Lines starting with # are commentsand so they are ignored. 16 | # 17 | # WARNING: 18 | # Remember to check the compatibility spreadsheet for WorldGuard to see 19 | # if any features are currently broken in your version of Bukkit. 20 | # 21 | 22 | # -- This should be automatically replaced by the plugin in-game -- -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: Feature request 2 | description: Suggest an idea for WorldGuard 3 | labels: ['type:feature-request', 'status:pending'] 4 | 5 | body: 6 | - type: textarea 7 | attributes: 8 | label: The Problem 9 | description: > 10 | What is making your WorldGuard experience sub-optimal? This should be something that 11 | cannot be easily solved by existing WorldGuard features. 12 | placeholder: It's hard to ... ; I'm unable to ... 13 | validations: 14 | required: true 15 | 16 | - type: textarea 17 | attributes: 18 | label: A Solution 19 | description: What is your proposed solution to the above problem? 20 | validations: 21 | required: true 22 | 23 | - type: textarea 24 | attributes: 25 | label: Alternatives 26 | description: | 27 | Alternative solutions or workarounds to the problem. 28 | You should also describe why these are not preferable to the given solution. 29 | validations: 30 | required: false 31 | 32 | - type: textarea 33 | attributes: 34 | label: Anything Else? 35 | description: Add any additional context you can provide below. 36 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/domains/Association.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.domains; 21 | 22 | /** 23 | * Indicates the level of membership. 24 | */ 25 | public enum Association { 26 | 27 | OWNER, 28 | MEMBER, 29 | NON_MEMBER 30 | 31 | } 32 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/action/ActionResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.action; 21 | 22 | public enum ActionResult { 23 | 24 | INHERIT, 25 | DENY, 26 | ALLOW, 27 | DENY_OVERRIDE, 28 | ALLOW_OVERRIDE 29 | 30 | } 31 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/util/collect/EntryBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.util.collect; 21 | 22 | public class EntryBase { 23 | 24 | protected long key; 25 | 26 | public EntryBase(long key) { 27 | this.key = key; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/managers/storage/DriverType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.managers.storage; 21 | 22 | /** 23 | * An enumeration of supported drivers. 24 | */ 25 | public enum DriverType { 26 | 27 | YAML, 28 | MYSQL 29 | 30 | } 31 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/event/Handleable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.bukkit.event; 21 | 22 | import org.bukkit.event.Event.Result; 23 | 24 | public interface Handleable { 25 | 26 | Result getResult(); 27 | 28 | void setResult(Result result); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/domains/registry/DomainConflictException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.domains.registry; 21 | 22 | public class DomainConflictException extends RuntimeException { 23 | public DomainConflictException(String message) { 24 | super(message); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/domains/registry/DomainFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | 21 | package com.sk89q.worldguard.domains.registry; 22 | 23 | import com.sk89q.worldguard.domains.CustomDomain; 24 | 25 | @FunctionalInterface 26 | public interface DomainFactory { 27 | T create(String name); 28 | } 29 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/managers/index/AbstractRegionIndex.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.managers.index; 21 | 22 | /** 23 | * An abstract implementation of a region index to make implementations easier. 24 | */ 25 | abstract class AbstractRegionIndex implements RegionIndex { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/registry/FlagConflictException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.flags.registry; 21 | 22 | public class FlagConflictException extends RuntimeException { 23 | 24 | public FlagConflictException(String message) { 25 | super(message); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/action/Action.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.action; 21 | 22 | import com.sk89q.worldguard.blacklist.event.BlacklistEvent; 23 | 24 | public interface Action { 25 | 26 | ActionResult apply(BlacklistEvent event, boolean silent, boolean repeating, boolean forceRepeat); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/domains/registry/InvalidDomainFormatException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.domains.registry; 21 | 22 | public class InvalidDomainFormatException extends Exception { 23 | private static final long serialVersionUID = 8101615074524004172L; 24 | 25 | public InvalidDomainFormatException(String msg) { 26 | super(msg); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/InvalidFlagFormatException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.flags; 21 | 22 | public class InvalidFlagFormatException extends InvalidFlagFormat { 23 | private static final long serialVersionUID = 8101615074524004172L; 24 | 25 | public InvalidFlagFormatException(String msg) { 26 | super(msg); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /config/checkstyle/import-control.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/target/TargetMatcherParseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.target; 21 | 22 | import static com.google.common.base.Preconditions.checkNotNull; 23 | 24 | public class TargetMatcherParseException extends Exception { 25 | 26 | public TargetMatcherParseException(String message) { 27 | super(checkNotNull(message)); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/event/debug/CancelLogging.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.bukkit.event.debug; 21 | 22 | import org.bukkit.event.Cancellable; 23 | 24 | import java.util.List; 25 | 26 | public interface CancelLogging extends Cancellable { 27 | 28 | /** 29 | * Get an immutable list of cancels. 30 | * 31 | * @return An immutable list 32 | */ 33 | List getCancels(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/managers/migration/Migration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.managers.migration; 21 | 22 | /** 23 | * An object that migrates region data. 24 | */ 25 | public interface Migration { 26 | 27 | /** 28 | * Execute the migration. 29 | * 30 | * @throws MigrationException thrown if the migration fails 31 | */ 32 | void migrate() throws MigrationException; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/InvalidFlagFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.flags; 21 | 22 | /** 23 | * @deprecated replaced by {@link InvalidFlagFormatException}. Will be removed in WorldGuard 8 24 | */ 25 | @Deprecated(forRemoval = true) 26 | public class InvalidFlagFormat extends Exception { 27 | 28 | private static final long serialVersionUID = 8101615074524004172L; 29 | 30 | public InvalidFlagFormat(String msg) { 31 | super(msg); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/target/Target.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.target; 21 | 22 | /** 23 | * A target is something that can have events attached to it. 24 | */ 25 | public interface Target { 26 | 27 | /** 28 | * Get the type ID. 29 | * 30 | * @return the type ID 31 | */ 32 | String getTypeId(); 33 | 34 | /** 35 | * Get a friendly name to be printed. 36 | * 37 | * @return a friendly name 38 | */ 39 | String getFriendlyName(); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/util/profiler/ThreadIdFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.util.profiler; 21 | 22 | import java.lang.management.ThreadInfo; 23 | import java.util.function.Predicate; 24 | 25 | public class ThreadIdFilter implements Predicate { 26 | 27 | private final long id; 28 | 29 | public ThreadIdFilter(long id) { 30 | this.id = id; 31 | } 32 | 33 | @Override 34 | public boolean test(ThreadInfo threadInfo) { 35 | return threadInfo.getThreadId() == id; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/managers/index/ConcurrentRegionIndex.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.managers.index; 21 | 22 | import java.util.concurrent.ConcurrentMap; 23 | 24 | /** 25 | * An implementation of a region index that supports concurrent access. 26 | * 27 | *

The mechanics of concurrent access should be similar to that of 28 | * {@link ConcurrentMap}. Spatial queries can lag behind changes on the data 29 | * for brief periods of time.

30 | */ 31 | public interface ConcurrentRegionIndex extends RegionIndex { 32 | } 33 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/target/ItemTarget.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.target; 21 | 22 | import com.sk89q.worldedit.world.item.ItemType; 23 | 24 | public class ItemTarget implements Target { 25 | 26 | private ItemType type; 27 | 28 | public ItemTarget(ItemType type) { 29 | this.type = type; 30 | } 31 | 32 | @Override 33 | public String getTypeId() { 34 | return type.getId(); 35 | } 36 | 37 | @Override 38 | public String getFriendlyName() { 39 | return type.getName(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/target/BlockTarget.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.target; 21 | 22 | import com.sk89q.worldedit.world.block.BlockType; 23 | 24 | public class BlockTarget implements Target { 25 | 26 | private BlockType type; 27 | 28 | public BlockTarget(BlockType type) { 29 | this.type = type; 30 | } 31 | 32 | @Override 33 | public String getTypeId() { 34 | return type.getId(); 35 | } 36 | 37 | @Override 38 | public String getFriendlyName() { 39 | return type.getName(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/event/BulkEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.bukkit.event; 21 | 22 | import org.bukkit.event.Event.Result; 23 | 24 | /** 25 | * A bulk event contains several affected objects in a list. 26 | */ 27 | public interface BulkEvent { 28 | 29 | /** 30 | * Get the actual result. 31 | * 32 | *

By default, bulk events will set the result to DENY if the number of 33 | * affected objects drops to zero. This method returns the true result.

34 | * 35 | * @return the explicit result 36 | */ 37 | Result getExplicitResult(); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/util/ChangeTracked.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.util; 21 | 22 | /** 23 | * An object that keeps track of a dirty flag that is set to true when changes 24 | * are made to this object. 25 | */ 26 | public interface ChangeTracked { 27 | 28 | /** 29 | * Tests whether changes have been made. 30 | * 31 | * @return true if changes have been made 32 | */ 33 | boolean isDirty(); 34 | 35 | /** 36 | * Set whether changes have been made. 37 | * 38 | * @param dirty a new dirty state 39 | */ 40 | void setDirty(boolean dirty); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/target/TargetMatcher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.target; 21 | 22 | /** 23 | * Matches a {@link Target}. 24 | */ 25 | public interface TargetMatcher { 26 | 27 | /** 28 | * Get the matched type ID, which is merely used for indexing. 29 | * 30 | * @return the type ID 31 | */ 32 | String getMatchedTypeId(); 33 | 34 | /** 35 | * Return whether the given target is matched by this matcher. 36 | * 37 | * @param target the target 38 | * @return true if matched 39 | */ 40 | boolean test(Target target); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/logger/LoggerHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.logger; 21 | 22 | import com.sk89q.worldguard.blacklist.event.BlacklistEvent; 23 | 24 | /** 25 | * Interface for loggers for the blacklist. 26 | */ 27 | public interface LoggerHandler { 28 | 29 | /** 30 | * Log an event. 31 | * 32 | * @param event The event 33 | * @param comment The comment to log with the event 34 | */ 35 | public void logEvent(BlacklistEvent event, String comment); 36 | 37 | /** 38 | * Close the logger. 39 | */ 40 | public void close(); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /worldguard-core/src/test/java/com/sk89q/worldguard/protection/HashMapIndexTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection; 21 | 22 | import com.sk89q.worldguard.protection.managers.RegionManager; 23 | import com.sk89q.worldguard.protection.managers.index.HashMapIndex; 24 | import com.sk89q.worldguard.protection.managers.storage.MemoryRegionDatabase; 25 | 26 | public class HashMapIndexTest extends RegionOverlapTest { 27 | 28 | @Override 29 | protected RegionManager createRegionManager() throws Exception { 30 | return new RegionManager(new MemoryRegionDatabase(), new HashMapIndex.Factory(), getFlagRegistry()); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/target/BlockMatcher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.target; 21 | 22 | import com.sk89q.worldedit.world.block.BlockType; 23 | 24 | public class BlockMatcher implements TargetMatcher { 25 | 26 | private final BlockType type; 27 | 28 | public BlockMatcher(BlockType type) { 29 | this.type = type; 30 | } 31 | 32 | @Override 33 | public String getMatchedTypeId() { 34 | return this.type.getId(); 35 | } 36 | 37 | @Override 38 | public boolean test(Target target) { 39 | return target.getTypeId().equals(getMatchedTypeId()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/target/ItemMatcher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.target; 21 | 22 | import com.sk89q.worldedit.world.item.ItemType; 23 | 24 | public class ItemMatcher implements TargetMatcher { 25 | 26 | private final ItemType type; 27 | 28 | public ItemMatcher(ItemType type) { 29 | this.type = type; 30 | } 31 | 32 | @Override 33 | public String getMatchedTypeId() { 34 | return this.type.getId(); 35 | } 36 | 37 | @Override 38 | public boolean test(Target target) { 39 | return target.getTypeId().equals(getMatchedTypeId()); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/managers/RemovalStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.managers; 21 | 22 | import com.sk89q.worldguard.protection.managers.index.RegionIndex; 23 | 24 | /** 25 | * Determines the strategy regarding child regions when regions are 26 | * removed from a {@link RegionIndex}. 27 | */ 28 | public enum RemovalStrategy { 29 | 30 | /** 31 | * Unset the parent in children regions. 32 | */ 33 | UNSET_PARENT_IN_CHILDREN, 34 | 35 | /** 36 | * Remove any children under the removed regions. This includes sub-children, etc. 37 | */ 38 | REMOVE_CHILDREN 39 | 40 | } 41 | -------------------------------------------------------------------------------- /worldguard-core/src/test/java/com/sk89q/worldguard/protection/HashMapIndexPriorityTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection; 21 | 22 | import com.sk89q.worldguard.protection.managers.index.HashMapIndex; 23 | import com.sk89q.worldguard.protection.managers.RegionManager; 24 | import com.sk89q.worldguard.protection.managers.storage.MemoryRegionDatabase; 25 | 26 | public class HashMapIndexPriorityTest extends RegionPriorityTest { 27 | 28 | @Override 29 | protected RegionManager createRegionManager() throws Exception { 30 | return new RegionManager(new MemoryRegionDatabase(), new HashMapIndex.Factory(), getFlagRegistry()); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/target/ItemBlockMatcher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.target; 21 | 22 | import com.sk89q.worldedit.world.block.BlockType; 23 | 24 | public class ItemBlockMatcher implements TargetMatcher { 25 | 26 | private final BlockType type; 27 | 28 | public ItemBlockMatcher(BlockType type) { 29 | this.type = type; 30 | } 31 | 32 | @Override 33 | public String getMatchedTypeId() { 34 | return this.type.getId(); 35 | } 36 | 37 | @Override 38 | public boolean test(Target target) { 39 | return target.getTypeId().equals(getMatchedTypeId()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/util/UnresolvedNamesException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.util; 21 | 22 | /** 23 | * Thrown when there are unresolved names. 24 | */ 25 | public class UnresolvedNamesException extends Exception { 26 | 27 | public UnresolvedNamesException() { 28 | } 29 | 30 | public UnresolvedNamesException(String message) { 31 | super(message); 32 | } 33 | 34 | public UnresolvedNamesException(String message, Throwable cause) { 35 | super(message, cause); 36 | } 37 | 38 | public UnresolvedNamesException(Throwable cause) { 39 | super(cause); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /worldguard-core/src/test/java/com/sk89q/worldguard/protection/PriorityRTreeIndexTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection; 21 | 22 | import com.sk89q.worldguard.protection.managers.RegionManager; 23 | import com.sk89q.worldguard.protection.managers.index.PriorityRTreeIndex; 24 | import com.sk89q.worldguard.protection.managers.storage.MemoryRegionDatabase; 25 | 26 | public class PriorityRTreeIndexTest extends RegionOverlapTest { 27 | 28 | @Override 29 | protected RegionManager createRegionManager() throws Exception { 30 | return new RegionManager(new MemoryRegionDatabase(), new PriorityRTreeIndex.Factory(), getFlagRegistry()); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /worldguard-core/src/test/java/com/sk89q/worldguard/protection/HashMapIndexRegionOverlapTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection; 21 | 22 | import com.sk89q.worldguard.protection.managers.index.HashMapIndex; 23 | import com.sk89q.worldguard.protection.managers.RegionManager; 24 | import com.sk89q.worldguard.protection.managers.storage.MemoryRegionDatabase; 25 | 26 | public class HashMapIndexRegionOverlapTest extends RegionOverlapTest { 27 | 28 | @Override 29 | protected RegionManager createRegionManager() throws Exception { 30 | return new RegionManager(new MemoryRegionDatabase(), new HashMapIndex.Factory(), getFlagRegistry()); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/managers/storage/StorageException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.managers.storage; 21 | 22 | /** 23 | * Exceptions related to region stores inherit from this exception. 24 | */ 25 | public class StorageException extends Exception { 26 | 27 | public StorageException() { 28 | } 29 | 30 | public StorageException(String message) { 31 | super(message); 32 | } 33 | 34 | public StorageException(String message, Throwable cause) { 35 | super(message, cause); 36 | } 37 | 38 | public StorageException(Throwable cause) { 39 | super(cause); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/managers/migration/MigrationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.managers.migration; 21 | 22 | /** 23 | * Thrown when a migration fails. 24 | */ 25 | public class MigrationException extends Exception { 26 | 27 | public MigrationException() { 28 | super(); 29 | } 30 | 31 | public MigrationException(String message) { 32 | super(message); 33 | } 34 | 35 | public MigrationException(String message, Throwable cause) { 36 | super(message, cause); 37 | } 38 | 39 | public MigrationException(Throwable cause) { 40 | super(cause); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /worldguard-core/src/test/java/com/sk89q/worldguard/protection/PriorityRTreeRegionOverlapTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection; 21 | 22 | import com.sk89q.worldguard.protection.managers.index.PriorityRTreeIndex; 23 | import com.sk89q.worldguard.protection.managers.RegionManager; 24 | import com.sk89q.worldguard.protection.managers.storage.MemoryRegionDatabase; 25 | 26 | public class PriorityRTreeRegionOverlapTest extends RegionOverlapTest { 27 | 28 | @Override 29 | protected RegionManager createRegionManager() throws Exception { 30 | return new RegionManager(new MemoryRegionDatabase(), new PriorityRTreeIndex.Factory(), getFlagRegistry()); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /worldguard-core/src/test/java/com/sk89q/worldguard/protection/PriorityRTreeRegionPriorityTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection; 21 | 22 | import com.sk89q.worldguard.protection.managers.index.PriorityRTreeIndex; 23 | import com.sk89q.worldguard.protection.managers.RegionManager; 24 | import com.sk89q.worldguard.protection.managers.storage.MemoryRegionDatabase; 25 | 26 | public class PriorityRTreeRegionPriorityTest extends RegionPriorityTest { 27 | 28 | @Override 29 | protected RegionManager createRegionManager() throws Exception { 30 | return new RegionManager(new MemoryRegionDatabase(), new PriorityRTreeIndex.Factory(), getFlagRegistry()); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /worldguard-core/src/test/java/com/sk89q/worldguard/protection/PriorityRTreeRegionEntryExitTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection; 21 | 22 | import com.sk89q.worldguard.protection.managers.index.PriorityRTreeIndex; 23 | import com.sk89q.worldguard.protection.managers.RegionManager; 24 | import com.sk89q.worldguard.protection.managers.storage.MemoryRegionDatabase; 25 | 26 | public class PriorityRTreeRegionEntryExitTest extends RegionEntryExitTest { 27 | 28 | @Override 29 | protected RegionManager createRegionManager() throws Exception { 30 | return new RegionManager(new MemoryRegionDatabase(), new PriorityRTreeIndex.Factory(), getFlagRegistry()); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/association/ConstantAssociation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.association; 21 | 22 | import com.sk89q.worldguard.domains.Association; 23 | import com.sk89q.worldguard.protection.regions.ProtectedRegion; 24 | 25 | import java.util.List; 26 | 27 | class ConstantAssociation implements RegionAssociable { 28 | 29 | private final Association association; 30 | 31 | ConstantAssociation(Association association) { 32 | this.association = association; 33 | } 34 | 35 | @Override 36 | public Association getAssociation(List regions) { 37 | return association; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/managers/storage/DifferenceSaveException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.managers.storage; 21 | 22 | /** 23 | * Thrown when a partial save is not supported. 24 | */ 25 | public class DifferenceSaveException extends StorageException { 26 | 27 | public DifferenceSaveException() { 28 | } 29 | 30 | public DifferenceSaveException(String message) { 31 | super(message); 32 | } 33 | 34 | public DifferenceSaveException(String message, Throwable cause) { 35 | super(message, cause); 36 | } 37 | 38 | public DifferenceSaveException(Throwable cause) { 39 | super(cause); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/util/formatting/component/Notify.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.util.formatting.component; 21 | 22 | import com.sk89q.worldedit.util.formatting.component.TextComponentProducer; 23 | import com.sk89q.worldedit.util.formatting.text.TextComponent; 24 | import com.sk89q.worldedit.util.formatting.text.format.TextColor; 25 | 26 | public class Notify extends TextComponentProducer { 27 | 28 | public Notify(String cause, String description) { 29 | append(TextComponent.of("WG: ", TextColor.GRAY)); 30 | append(TextComponent.of(cause, TextColor.LIGHT_PURPLE)); 31 | append(TextComponent.of(description, TextColor.GOLD)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/action/RepeatGuardedAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.action; 21 | 22 | import com.sk89q.worldguard.blacklist.event.BlacklistEvent; 23 | 24 | public abstract class RepeatGuardedAction implements Action { 25 | 26 | @Override 27 | public final ActionResult apply(BlacklistEvent event, boolean silent, boolean repeating, boolean forceRepeat) { 28 | if (!repeating || forceRepeat) { 29 | return applyNonRepeated(event, silent); 30 | } 31 | 32 | return ActionResult.INHERIT; 33 | } 34 | 35 | protected abstract ActionResult applyNonRepeated(BlacklistEvent event, boolean silent); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/association/RegionAssociable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.association; 21 | 22 | import com.sk89q.worldguard.domains.Association; 23 | import com.sk89q.worldguard.protection.regions.ProtectedRegion; 24 | 25 | import java.util.List; 26 | 27 | /** 28 | * An object that can have membership in a region. 29 | */ 30 | public interface RegionAssociable { 31 | 32 | /** 33 | * Get the highest association level for the input regions. 34 | * 35 | * @param regions a list of regions 36 | * @return the highest membership level 37 | */ 38 | Association getAssociation(List regions); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/util/profiler/ThreadNameFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.util.profiler; 21 | 22 | import java.lang.management.ThreadInfo; 23 | import java.util.function.Predicate; 24 | 25 | import static com.google.common.base.Preconditions.checkNotNull; 26 | 27 | public class ThreadNameFilter implements Predicate { 28 | 29 | private final String name; 30 | 31 | public ThreadNameFilter(String name) { 32 | checkNotNull(name, "name"); 33 | this.name = name; 34 | } 35 | 36 | @Override 37 | public boolean test(ThreadInfo threadInfo) { 38 | return threadInfo.getThreadName().equalsIgnoreCase(name); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/util/Locations.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.util; 21 | 22 | import com.sk89q.worldedit.util.Location; 23 | 24 | public final class Locations { 25 | 26 | private Locations() { 27 | } 28 | 29 | /** 30 | * Tests whether two different locations are in two different blocks. 31 | * 32 | * @param a The first location 33 | * @param b The second location 34 | * @return Whether the two locations are two different blocks 35 | */ 36 | public static boolean isDifferentBlock(Location a, Location b) { 37 | return a.getBlockX() != b.getBlockX() || a.getBlockY() != b.getBlockY() || a.getBlockZ() != b.getBlockZ(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/util/formatting/component/BlacklistNotify.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.util.formatting.component; 21 | 22 | import com.sk89q.worldedit.util.formatting.text.TextComponent; 23 | import com.sk89q.worldedit.util.formatting.text.format.TextColor; 24 | import com.sk89q.worldguard.blacklist.event.BlacklistEvent; 25 | 26 | public class BlacklistNotify extends Notify { 27 | 28 | public BlacklistNotify(BlacklistEvent event, String comment) { 29 | super(event.getCauseName(), " (" + event.getDescription() + ") "); 30 | append(TextComponent.of(event.getTarget().getFriendlyName() + (comment != null ? " (" + comment + ")" : "") + ".", TextColor.WHITE)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/action/DenyAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.action; 21 | 22 | import com.sk89q.worldguard.blacklist.event.BlacklistEvent; 23 | 24 | public final class DenyAction implements Action { 25 | 26 | private static final DenyAction INSTANCE = new DenyAction(); 27 | 28 | private DenyAction() { 29 | } 30 | 31 | @Override 32 | public ActionResult apply(BlacklistEvent event, boolean silent, boolean repeating, boolean forceRepeat) { 33 | if (silent) { 34 | return ActionResult.DENY_OVERRIDE; 35 | } 36 | 37 | return ActionResult.DENY; 38 | } 39 | 40 | public static DenyAction getInstance() { 41 | return INSTANCE; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/action/AllowAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.action; 21 | 22 | import com.sk89q.worldguard.blacklist.event.BlacklistEvent; 23 | 24 | public final class AllowAction implements Action { 25 | 26 | private static final AllowAction INSTANCE = new AllowAction(); 27 | 28 | private AllowAction() { 29 | } 30 | 31 | @Override 32 | public ActionResult apply(BlacklistEvent event, boolean silent, boolean repeating, boolean forceRepeat) { 33 | if (silent) { 34 | return ActionResult.ALLOW_OVERRIDE; 35 | } 36 | 37 | return ActionResult.ALLOW; 38 | } 39 | 40 | public static AllowAction getInstance() { 41 | return INSTANCE; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/regions/RegionType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.regions; 21 | 22 | /** 23 | * An enum of supported region types. 24 | */ 25 | public enum RegionType { 26 | 27 | // Do not change the names 28 | CUBOID("cuboid"), 29 | POLYGON("poly2d"), 30 | GLOBAL("global"); 31 | 32 | private final String name; 33 | 34 | /** 35 | * Create a new instance. 36 | * 37 | * @param name the region name 38 | */ 39 | RegionType(String name) { 40 | this.name = name; 41 | } 42 | 43 | /** 44 | * Get the name of the region. 45 | * 46 | * @return the name of the region 47 | */ 48 | public String getName() { 49 | return name; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /COMPILING.md: -------------------------------------------------------------------------------- 1 | Compiling 2 | ========= 3 | 4 | You can compile WorldGuard as long as you have some version of Java greater than or equal to 17 installed. Gradle will download JDK 17 specifically if needed, 5 | but it needs some version of Java to bootstrap from. 6 | 7 | Note that if you have JRE 17 installed, Gradle will currently attempt to use that to compile, which will not work. It is easiest to uninstall JRE 16 and 8 | replace it with JDK 17. 9 | 10 | The build process uses Gradle, which you do *not* need to download. WorldGuard is a multi-module project with three modules: 11 | 12 | * `worldguard-core` contains the WorldGuard API 13 | * `worldguard-bukkit` is the Bukkit plugin 14 | * `worldguard-libs` contains library relocations 15 | 16 | ## To compile... 17 | 18 | ### On Windows 19 | 20 | 1. **Shift** + **right click** the folder with WorldGuard's files and click "Open PowerShell window here". 21 | 2. `gradlew build` 22 | 23 | ### On Linux, BSD, or Mac OS X 24 | 25 | 1. In your terminal, navigate to the folder with WorldGuard's files (`cd /folder/of/worldguard/files`) 26 | 2. `./gradlew build` 27 | 28 | ## Then you will find... 29 | 30 | You will find: 31 | 32 | * The core WorldGuard API in **worldguard-core/build/libs** 33 | * WorldGuard for Bukkit in **worldguard-bukkit/build/libs** 34 | 35 | If you want to use WorldGuard, use the `-dist` version. 36 | 37 | (The -dist version includes WorldGuard + necessary libraries.) 38 | 39 | ## Other commands 40 | 41 | * `gradlew idea` will generate an [IntelliJ IDEA](http://www.jetbrains.com/idea/) module for each folder. 42 | * `gradlew eclipse` will generate an [Eclipse](https://www.eclipse.org/downloads/) project for each folder. 43 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/util/profiler/StackTraceNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.util.profiler; 21 | 22 | public class StackTraceNode extends StackNode { 23 | 24 | private final String className; 25 | private final String methodName; 26 | 27 | public StackTraceNode(String className, String methodName) { 28 | super(className + "." + methodName + "()"); 29 | this.className = className; 30 | this.methodName = methodName; 31 | } 32 | 33 | public String getClassName() { 34 | return className; 35 | } 36 | 37 | public String getMethodName() { 38 | return methodName; 39 | } 40 | 41 | @Override 42 | public int compareTo(StackNode o) { 43 | return Long.compare(o.getTotalTime(), getTotalTime()); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/BuildFlag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.flags; 21 | 22 | /** 23 | * A special implementation of the {@link StateFlag} for 24 | * {@link Flags#BUILD}. 25 | */ 26 | class BuildFlag extends StateFlag { 27 | 28 | public BuildFlag(String name, boolean def) { 29 | super(name, def); 30 | } 31 | 32 | @Override 33 | public boolean implicitlySetWithMembership() { 34 | return true; 35 | } 36 | 37 | @Override 38 | public boolean usesMembershipAsDefault() { 39 | return true; 40 | } 41 | 42 | @Override 43 | public boolean preventsAllowOnGlobal() { 44 | return true; 45 | } 46 | 47 | @Override 48 | public boolean requiresSubject() { 49 | return true; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/util/collect/LongHash.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.util.collect; 21 | 22 | public abstract class LongHash { 23 | 24 | public static long toLong(int msw, int lsw) { 25 | return ((long) msw << 32) + lsw - Integer.MIN_VALUE; 26 | } 27 | 28 | public static int msw(long l) { 29 | return (int) (l >> 32); 30 | } 31 | 32 | public static int lsw(long l) { 33 | return (int) (l & 0xFFFFFFFF) + Integer.MIN_VALUE; 34 | } 35 | 36 | public boolean containsKey(int msw, int lsw) { 37 | return containsKey(toLong(msw, lsw)); 38 | } 39 | 40 | public void remove(int msw, int lsw) { 41 | remove(toLong(msw, lsw)); 42 | } 43 | 44 | public abstract boolean containsKey(long key); 45 | 46 | public abstract void remove(long key); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/util/report/ServicesReport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.bukkit.util.report; 21 | 22 | import com.sk89q.worldedit.util.report.DataReport; 23 | import org.bukkit.Bukkit; 24 | import org.bukkit.plugin.ServicesManager; 25 | 26 | import java.util.Collection; 27 | 28 | public class ServicesReport extends DataReport { 29 | 30 | public ServicesReport() { 31 | super("Services"); 32 | 33 | ServicesManager manager = Bukkit.getServer().getServicesManager(); 34 | Collection> services = manager.getKnownServices(); 35 | 36 | for (Class service : services) { 37 | Object provider = manager.load(service); 38 | if (provider != null) { 39 | append(service.getName(), provider); 40 | } 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/internal/permission/AbstractPermissionModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.internal.permission; 21 | 22 | import com.sk89q.worldedit.extension.platform.Actor; 23 | import com.sk89q.worldguard.internal.PermissionModel; 24 | 25 | import static com.google.common.base.Preconditions.checkNotNull; 26 | 27 | public abstract class AbstractPermissionModel implements PermissionModel { 28 | 29 | private final Actor sender; 30 | 31 | protected AbstractPermissionModel(Actor sender) { 32 | checkNotNull(sender); 33 | this.sender = sender; 34 | } 35 | 36 | public Actor getSender() { 37 | return sender; 38 | } 39 | 40 | protected boolean hasPluginPermission(String permission) { 41 | return getSender().hasPermission("worldguard." + permission); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/internal/platform/DebugHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.internal.platform; 21 | 22 | import com.sk89q.minecraft.util.commands.CommandException; 23 | import com.sk89q.worldedit.extension.platform.Actor; 24 | import com.sk89q.worldguard.LocalPlayer; 25 | 26 | public interface DebugHandler { 27 | 28 | void testBreak(Actor sender, LocalPlayer target, boolean fromTarget, boolean stackTraceMode) throws CommandException; 29 | 30 | void testPlace(Actor sender, LocalPlayer target, boolean fromTarget, boolean stackTraceMode) throws CommandException; 31 | 32 | void testInteract(Actor sender, LocalPlayer target, boolean fromTarget, boolean stackTraceMode) throws CommandException; 33 | 34 | void testDamage(Actor sender, LocalPlayer target, boolean fromTarget, boolean stackTraceMode) throws CommandException; 35 | } 36 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/TrackedEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist; 21 | 22 | import com.sk89q.worldguard.blacklist.event.BlacklistEvent; 23 | 24 | import javax.annotation.Nullable; 25 | 26 | class TrackedEvent { 27 | 28 | @Nullable 29 | private BlacklistEvent lastEvent; 30 | private long time = 0; 31 | 32 | public boolean matches(BlacklistEvent other) { 33 | if (lastEvent == null) { 34 | return false; 35 | } 36 | long now = System.currentTimeMillis(); 37 | return other.getEventType() == lastEvent.getEventType() && time > now - 3000; 38 | } 39 | 40 | public void resetTimer() { 41 | time = System.currentTimeMillis(); 42 | } 43 | 44 | public void setLastEvent(@Nullable BlacklistEvent lastEvent) { 45 | this.lastEvent = lastEvent; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/logger/ConsoleHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.logger; 21 | 22 | import com.sk89q.worldguard.blacklist.event.BlacklistEvent; 23 | 24 | import java.util.logging.Level; 25 | import java.util.logging.Logger; 26 | 27 | public class ConsoleHandler implements LoggerHandler { 28 | 29 | private String worldName; 30 | private final Logger logger; 31 | 32 | public ConsoleHandler(String worldName, Logger logger) { 33 | this.worldName = worldName; 34 | this.logger = logger; 35 | } 36 | 37 | @Override 38 | public void logEvent(BlacklistEvent event, String comment) { 39 | logger.log(Level.INFO, "[" + worldName + "] " + event.getLoggerMessage() + 40 | (comment != null ? " (" + comment + ")" : "")); 41 | } 42 | 43 | @Override 44 | public void close() { 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/event/debug/LoggingBlockBreakEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.bukkit.event.debug; 21 | 22 | import org.bukkit.block.Block; 23 | import org.bukkit.entity.Player; 24 | import org.bukkit.event.block.BlockBreakEvent; 25 | 26 | import java.util.List; 27 | 28 | public class LoggingBlockBreakEvent extends BlockBreakEvent implements CancelLogging { 29 | 30 | private final CancelLogger logger = new CancelLogger(); 31 | 32 | public LoggingBlockBreakEvent(Block block, Player player) { 33 | super(block, player); 34 | } 35 | 36 | public List getCancels() { 37 | return logger.getCancels(); 38 | } 39 | 40 | @Override 41 | public void setCancelled(boolean cancel) { 42 | this.logger.log(isCancelled(), cancel, new Exception().getStackTrace()); 43 | super.setCancelled(cancel); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/util/report/RegionReport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.util.report; 21 | 22 | import com.sk89q.worldedit.util.report.DataReport; 23 | import com.sk89q.worldguard.protection.regions.ProtectedRegion; 24 | 25 | /** 26 | * Reports on a region. 27 | */ 28 | public class RegionReport extends DataReport { 29 | 30 | public RegionReport(ProtectedRegion region) { 31 | super("Region: " + region.getId()); 32 | 33 | append("Type", region.getType()); 34 | append("Priority", region.getPriority()); 35 | append("Parent", region.getParent() == null ? "" : region.getParent().getId()); 36 | append("Owners", region.getOwners()); 37 | append("Members", region.getMembers()); 38 | append("Flags", region.getFlags()); 39 | append("Bounds", region.getMinimumPoint() + " -> " + region.getMaximumPoint()); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/session/MoveType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.session; 21 | 22 | /** 23 | * Types of movements. 24 | * 25 | *

Used with Session#testMoveTo(Location, MoveType).

26 | */ 27 | public enum MoveType { 28 | 29 | RESPAWN(false, true), 30 | EMBARK(true, false), 31 | MOVE(true, false), 32 | GLIDE(true, false), 33 | SWIM(true, false), 34 | TELEPORT(true, true), 35 | RIDE(true, false), 36 | OTHER_NON_CANCELLABLE(false, false), 37 | OTHER_CANCELLABLE(true, false); 38 | 39 | private final boolean cancellable; 40 | private final boolean teleport; 41 | 42 | MoveType(boolean cancellable, boolean teleport) { 43 | this.cancellable = cancellable; 44 | this.teleport = teleport; 45 | } 46 | 47 | public boolean isCancellable() { 48 | return cancellable; 49 | } 50 | 51 | public boolean isTeleport() { 52 | return teleport; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/event/debug/LoggingEntityDamageByEntityEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.bukkit.event.debug; 21 | 22 | import org.bukkit.entity.Entity; 23 | import org.bukkit.event.entity.EntityDamageByEntityEvent; 24 | 25 | import java.util.List; 26 | 27 | public class LoggingEntityDamageByEntityEvent extends EntityDamageByEntityEvent implements CancelLogging { 28 | 29 | private final CancelLogger logger = new CancelLogger(); 30 | 31 | public LoggingEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, double damage) { 32 | super(damager, damagee, cause, damage); 33 | } 34 | 35 | public List getCancels() { 36 | return logger.getCancels(); 37 | } 38 | 39 | @Override 40 | public void setCancelled(boolean cancel) { 41 | this.logger.log(isCancelled(), cancel, new Exception().getStackTrace()); 42 | super.setCancelled(cancel); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/registry/UnknownFlag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.flags.registry; 21 | 22 | import com.sk89q.worldguard.protection.flags.Flag; 23 | import com.sk89q.worldguard.protection.flags.FlagContext; 24 | import com.sk89q.worldguard.protection.flags.InvalidFlagFormatException; 25 | 26 | import javax.annotation.Nullable; 27 | 28 | public class UnknownFlag extends Flag { 29 | 30 | public UnknownFlag(String name) { 31 | super(name); 32 | } 33 | 34 | @Override 35 | public Object parseInput(FlagContext context) throws InvalidFlagFormatException { 36 | throw new InvalidFlagFormatException("The plugin that registered this flag is not currently installed"); 37 | } 38 | 39 | @Override 40 | public Object unmarshal(@Nullable Object o) { 41 | return o; 42 | } 43 | 44 | @Override 45 | public Object marshal(Object o) { 46 | return o; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/DoubleFlag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.flags; 21 | 22 | /** 23 | * Stores doubles. 24 | */ 25 | public class DoubleFlag extends NumberFlag { 26 | 27 | public DoubleFlag(String name, RegionGroup defaultGroup) { 28 | super(name, defaultGroup); 29 | } 30 | 31 | public DoubleFlag(String name) { 32 | super(name); 33 | } 34 | 35 | @Override 36 | public Double parseInput(FlagContext context) throws InvalidFlagFormatException { 37 | return context.getUserInputAsDouble(); 38 | } 39 | 40 | @Override 41 | public Double unmarshal(Object o) { 42 | if (o instanceof Double) { 43 | return (Double) o; 44 | } else if (o instanceof Number) { 45 | return ((Number) o).doubleValue(); 46 | } else { 47 | return null; 48 | } 49 | } 50 | 51 | @Override 52 | public Object marshal(Double o) { 53 | return o; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/IntegerFlag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.flags; 21 | 22 | /** 23 | * Stores an integer. 24 | */ 25 | public class IntegerFlag extends NumberFlag { 26 | 27 | public IntegerFlag(String name, RegionGroup defaultGroup) { 28 | super(name, defaultGroup); 29 | } 30 | 31 | public IntegerFlag(String name) { 32 | super(name); 33 | } 34 | 35 | @Override 36 | public Integer parseInput(FlagContext context) throws InvalidFlagFormatException { 37 | return context.getUserInputAsInt(); 38 | } 39 | 40 | @Override 41 | public Integer unmarshal(Object o) { 42 | if (o instanceof Integer) { 43 | return (Integer) o; 44 | } else if (o instanceof Number) { 45 | return ((Number) o).intValue(); 46 | } else { 47 | return null; 48 | } 49 | } 50 | 51 | @Override 52 | public Object marshal(Integer o) { 53 | return o; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/managers/storage/sql/StatementBatch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.managers.storage.sql; 21 | 22 | import java.sql.PreparedStatement; 23 | import java.sql.SQLException; 24 | 25 | class StatementBatch { 26 | 27 | public static final int MAX_BATCH_SIZE = 100; 28 | 29 | private final PreparedStatement stmt; 30 | private final int batchSize; 31 | private int count = 0; 32 | 33 | StatementBatch(PreparedStatement stmt, int batchSize) { 34 | this.stmt = stmt; 35 | this.batchSize = batchSize; 36 | } 37 | 38 | public void addBatch() throws SQLException { 39 | stmt.addBatch(); 40 | count++; 41 | if (count > batchSize) { 42 | stmt.executeBatch(); 43 | count = 0; 44 | } 45 | } 46 | 47 | public void executeRemaining() throws SQLException { 48 | if (count > 0) { 49 | count = 0; 50 | stmt.executeBatch(); 51 | } 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/event/ItemUseBlacklistEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.event; 21 | 22 | import com.sk89q.worldedit.math.BlockVector3; 23 | import com.sk89q.worldguard.LocalPlayer; 24 | import com.sk89q.worldguard.blacklist.target.Target; 25 | 26 | import javax.annotation.Nullable; 27 | 28 | public final class ItemUseBlacklistEvent extends ItemBlacklistEvent { 29 | 30 | /** 31 | * Construct the object. 32 | * 33 | * @param player The player associated with this event 34 | * @param position The position the event occurred at 35 | * @param target The target of the event 36 | */ 37 | public ItemUseBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) { 38 | super(player, position, target); 39 | } 40 | 41 | @Override 42 | public String getDescription() { 43 | return "use"; 44 | } 45 | 46 | @Override 47 | public EventType getEventType() { 48 | return EventType.USE; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/event/ItemDropBlacklistEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.event; 21 | 22 | import com.sk89q.worldedit.math.BlockVector3; 23 | import com.sk89q.worldguard.LocalPlayer; 24 | import com.sk89q.worldguard.blacklist.target.Target; 25 | 26 | import javax.annotation.Nullable; 27 | 28 | public final class ItemDropBlacklistEvent extends ItemBlacklistEvent { 29 | 30 | /** 31 | * Construct the object. 32 | * 33 | * @param player The player associated with this event 34 | * @param position The position the event occurred at 35 | * @param target The target of the event 36 | */ 37 | public ItemDropBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) { 38 | super(player, position, target); 39 | } 40 | 41 | @Override 42 | public String getDescription() { 43 | return "drop"; 44 | } 45 | 46 | @Override 47 | public EventType getEventType() { 48 | return EventType.DROP; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/event/ItemEquipBlacklistEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.event; 21 | 22 | import com.sk89q.worldedit.math.BlockVector3; 23 | import com.sk89q.worldguard.LocalPlayer; 24 | import com.sk89q.worldguard.blacklist.target.Target; 25 | 26 | import javax.annotation.Nullable; 27 | 28 | public final class ItemEquipBlacklistEvent extends ItemBlacklistEvent { 29 | 30 | /** 31 | * Construct the object. 32 | * 33 | * @param player The player associated with this event 34 | * @param position The position the event occurred at 35 | * @param target The target of the event 36 | */ 37 | public ItemEquipBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) { 38 | super(player, position, target); 39 | } 40 | 41 | @Override 42 | public String getDescription() { 43 | return "equip"; 44 | } 45 | 46 | @Override 47 | public EventType getEventType() { 48 | return EventType.EQUIP; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/event/BlockBreakBlacklistEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.event; 21 | 22 | import com.sk89q.worldedit.math.BlockVector3; 23 | import com.sk89q.worldguard.LocalPlayer; 24 | import com.sk89q.worldguard.blacklist.target.Target; 25 | 26 | import javax.annotation.Nullable; 27 | 28 | public final class BlockBreakBlacklistEvent extends BlockBlacklistEvent { 29 | 30 | /** 31 | * Construct the object. 32 | * 33 | * @param player The player associated with this event 34 | * @param position The position the event occurred at 35 | * @param target The target of the event 36 | */ 37 | public BlockBreakBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) { 38 | super(player, position, target); 39 | } 40 | 41 | @Override 42 | public String getDescription() { 43 | return "break"; 44 | } 45 | 46 | @Override 47 | public EventType getEventType() { 48 | return EventType.BREAK; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/event/BlockPlaceBlacklistEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.event; 21 | 22 | import com.sk89q.worldedit.math.BlockVector3; 23 | import com.sk89q.worldguard.LocalPlayer; 24 | import com.sk89q.worldguard.blacklist.target.Target; 25 | 26 | import javax.annotation.Nullable; 27 | 28 | public final class BlockPlaceBlacklistEvent extends BlockBlacklistEvent { 29 | 30 | /** 31 | * Construct the object. 32 | * 33 | * @param player The player associated with this event 34 | * @param position The position the event occurred at 35 | * @param target The target of the event 36 | */ 37 | public BlockPlaceBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) { 38 | super(player, position, target); 39 | } 40 | 41 | @Override 42 | public String getDescription() { 43 | return "place"; 44 | } 45 | 46 | @Override 47 | public EventType getEventType() { 48 | return EventType.PLACE; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/event/debug/CancelLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.bukkit.event.debug; 21 | 22 | import com.google.common.collect.ImmutableList; 23 | 24 | import java.util.ArrayList; 25 | import java.util.List; 26 | 27 | /** 28 | * Logs attempts at cancellation. 29 | */ 30 | public class CancelLogger { 31 | 32 | private List entries = new ArrayList<>(); 33 | 34 | /** 35 | * Log a call. 36 | * 37 | * @param before The cancellation flag before the call 38 | * @param after The cancellation flag after the call 39 | * @param stackTrace The stack trace 40 | */ 41 | public void log(boolean before, boolean after, StackTraceElement[] stackTrace) { 42 | entries.add(new CancelAttempt(before, after, stackTrace)); 43 | } 44 | 45 | /** 46 | * Get an immutable list of cancels. 47 | * 48 | * @return An immutable list 49 | */ 50 | public List getCancels() { 51 | return ImmutableList.copyOf(entries); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/event/ItemAcquireBlacklistEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.event; 21 | 22 | import com.sk89q.worldedit.math.BlockVector3; 23 | import com.sk89q.worldguard.LocalPlayer; 24 | import com.sk89q.worldguard.blacklist.target.Target; 25 | 26 | import javax.annotation.Nullable; 27 | 28 | public final class ItemAcquireBlacklistEvent extends ItemBlacklistEvent { 29 | 30 | /** 31 | * Construct the object. 32 | * 33 | * @param player The player associated with this event 34 | * @param position The position the event occurred at 35 | * @param target The target of the event 36 | */ 37 | public ItemAcquireBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) { 38 | super(player, position, target); 39 | } 40 | 41 | @Override 42 | public String getDescription() { 43 | return "acquire"; 44 | } 45 | 46 | @Override 47 | public EventType getEventType() { 48 | return EventType.ACQUIRE; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/WorldGuardServerListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.bukkit.listener; 21 | 22 | import com.sk89q.worldguard.bukkit.WorldGuardPlugin; 23 | import org.bukkit.event.EventHandler; 24 | import org.bukkit.event.server.PluginDisableEvent; 25 | import org.bukkit.event.server.PluginEnableEvent; 26 | 27 | public class WorldGuardServerListener extends AbstractListener { 28 | 29 | public WorldGuardServerListener(WorldGuardPlugin plugin) { 30 | super(plugin); 31 | } 32 | 33 | @EventHandler 34 | public void onPluginEnable(PluginEnableEvent event) { 35 | if (event.getPlugin().getDescription().getName().equalsIgnoreCase("CommandBook")) { 36 | getConfig().updateCommandBookGodMode(); 37 | } 38 | } 39 | 40 | @EventHandler 41 | public void onPluginDisable(PluginDisableEvent event) { 42 | if (event.getPlugin().getDescription().getName().equalsIgnoreCase("CommandBook")) { 43 | getConfig().updateCommandBookGodMode(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/event/BlockInteractBlacklistEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.event; 21 | 22 | import com.sk89q.worldedit.math.BlockVector3; 23 | import com.sk89q.worldguard.LocalPlayer; 24 | import com.sk89q.worldguard.blacklist.target.Target; 25 | 26 | import javax.annotation.Nullable; 27 | 28 | public final class BlockInteractBlacklistEvent extends BlockBlacklistEvent { 29 | 30 | /** 31 | * Construct the object. 32 | * 33 | * @param player The player associated with this event 34 | * @param position The position the event occurred at 35 | * @param target The target of the event 36 | */ 37 | public BlockInteractBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) { 38 | super(player, position, target); 39 | } 40 | 41 | @Override 42 | public String getDescription() { 43 | return "interact with"; 44 | } 45 | 46 | @Override 47 | public EventType getEventType() { 48 | return EventType.INTERACT; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/util/Entities.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.util; 21 | 22 | import com.sk89q.worldedit.entity.Entity; 23 | import com.sk89q.worldedit.entity.metadata.EntityProperties; 24 | 25 | public class Entities { 26 | 27 | private Entities() { 28 | } 29 | 30 | /** 31 | * Returns whether an entity should be removed for the halt activity mode. 32 | * 33 | * @param entity The entity 34 | * @return true if it's to be removed 35 | */ 36 | public static boolean isIntensiveEntity(Entity entity) { 37 | EntityProperties properties = entity.getFacet(EntityProperties.class); 38 | return properties != null 39 | && (properties.isItem() 40 | || properties.isTNT() 41 | || properties.isExperienceOrb() 42 | || properties.isFallingBlock() 43 | || (properties.isLiving() 44 | && !(properties.isTamed()) 45 | && !(properties.isPlayerDerived()) 46 | && !properties.isArmorStand())); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/action/LogAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.action; 21 | 22 | import com.sk89q.worldguard.blacklist.Blacklist; 23 | import com.sk89q.worldguard.blacklist.BlacklistEntry; 24 | import com.sk89q.worldguard.blacklist.event.BlacklistEvent; 25 | 26 | import static com.google.common.base.Preconditions.checkNotNull; 27 | 28 | public class LogAction extends RepeatGuardedAction { 29 | 30 | private final Blacklist blacklist; 31 | private final BlacklistEntry entry; 32 | 33 | public LogAction(Blacklist blacklist, BlacklistEntry entry) { 34 | checkNotNull(blacklist); 35 | checkNotNull(entry); 36 | this.blacklist = blacklist; 37 | this.entry = entry; 38 | } 39 | 40 | @Override 41 | protected ActionResult applyNonRepeated(BlacklistEvent event, boolean silent) { 42 | if (silent) { 43 | return ActionResult.INHERIT; 44 | } 45 | 46 | blacklist.getLogger().logEvent(event, entry.getComment()); 47 | 48 | return ActionResult.INHERIT; 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/action/NotifyAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.action; 21 | 22 | import com.sk89q.worldguard.blacklist.Blacklist; 23 | import com.sk89q.worldguard.blacklist.BlacklistEntry; 24 | import com.sk89q.worldguard.blacklist.event.BlacklistEvent; 25 | 26 | import static com.google.common.base.Preconditions.checkNotNull; 27 | 28 | public class NotifyAction extends RepeatGuardedAction { 29 | 30 | private final Blacklist blacklist; 31 | private final BlacklistEntry entry; 32 | 33 | public NotifyAction(Blacklist blacklist, BlacklistEntry entry) { 34 | checkNotNull(blacklist); 35 | checkNotNull(entry); 36 | this.blacklist = blacklist; 37 | this.entry = entry; 38 | } 39 | 40 | @Override 41 | protected ActionResult applyNonRepeated(BlacklistEvent event, boolean silent) { 42 | if (silent) { 43 | return ActionResult.INHERIT; 44 | } 45 | 46 | blacklist.notify(event, entry.getComment()); 47 | 48 | return ActionResult.INHERIT; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/event/BlockBlacklistEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.event; 21 | 22 | import com.sk89q.worldedit.math.BlockVector3; 23 | import com.sk89q.worldguard.LocalPlayer; 24 | import com.sk89q.worldguard.blacklist.target.Target; 25 | 26 | import javax.annotation.Nullable; 27 | 28 | abstract class BlockBlacklistEvent extends AbstractBlacklistEvent { 29 | 30 | /** 31 | * Construct the object. 32 | * 33 | * @param player The player associated with this event 34 | * @param position The position the event occurred at 35 | * @param target The target of the event 36 | */ 37 | BlockBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) { 38 | super(player, position, target); 39 | } 40 | 41 | @Override 42 | public String getLoggerMessage() { 43 | return getPlayerName() + " tried to " + getDescription() + " " + getTarget().getFriendlyName(); 44 | } 45 | 46 | @Override 47 | public BlockVector3 getLoggedPosition() { 48 | return getPosition(); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/CommandStringFlag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.flags; 21 | 22 | /** 23 | * Stores a command/ 24 | */ 25 | public class CommandStringFlag extends Flag { 26 | 27 | public CommandStringFlag(String name, RegionGroup defaultGroup) { 28 | super(name, defaultGroup); 29 | } 30 | 31 | public CommandStringFlag(String name) { 32 | super(name); 33 | } 34 | 35 | @Override 36 | public String parseInput(FlagContext context) throws InvalidFlagFormatException { 37 | String input = context.getUserInput(); 38 | input = input.trim(); 39 | if (!input.startsWith("/")) { 40 | input = "/" + input; 41 | } 42 | return input.toLowerCase(); 43 | } 44 | 45 | @Override 46 | public String unmarshal(Object o) { 47 | if (o instanceof String) { 48 | return (String) o; 49 | } else { 50 | return null; 51 | } 52 | } 53 | 54 | @Override 55 | public Object marshal(String o) { 56 | return o; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/DelayedRegionOverlapAssociation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection; 21 | 22 | import com.sk89q.worldedit.util.Location; 23 | import com.sk89q.worldguard.protection.regions.RegionQuery; 24 | 25 | import java.util.List; 26 | 27 | /** 28 | * Determines that the association to a region is {@code OWNER} if the input 29 | * region is in a set of source regions. 30 | * 31 | *

This class only performs a spatial query if its 32 | * {@link #getAssociation(List)} method is called.

33 | * 34 | * @deprecated Use {@link com.sk89q.worldguard.protection.association.DelayedRegionOverlapAssociation} instead. This class is mis-packaged. 35 | */ 36 | @Deprecated 37 | public class DelayedRegionOverlapAssociation extends com.sk89q.worldguard.protection.association.DelayedRegionOverlapAssociation { 38 | /** 39 | * Create a new instance. 40 | * @param query the query 41 | * @param location the location 42 | */ 43 | public DelayedRegionOverlapAssociation(RegionQuery query, Location location) { 44 | super(query, location, false); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/commands/task/RegionManagerLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.commands.task; 21 | 22 | import com.sk89q.worldguard.protection.managers.RegionManager; 23 | import com.sk89q.worldguard.protection.managers.storage.StorageException; 24 | 25 | import java.util.Arrays; 26 | import java.util.Collection; 27 | import java.util.concurrent.Callable; 28 | 29 | import static com.google.common.base.Preconditions.checkNotNull; 30 | 31 | public class RegionManagerLoader implements Callable> { 32 | 33 | private final Collection managers; 34 | 35 | public RegionManagerLoader(Collection managers) { 36 | checkNotNull(managers); 37 | this.managers = managers; 38 | } 39 | 40 | public RegionManagerLoader(RegionManager... manager) { 41 | this(Arrays.asList(manager)); 42 | } 43 | 44 | @Override 45 | public Collection call() throws StorageException { 46 | for (RegionManager manager : managers) { 47 | manager.load(); 48 | } 49 | 50 | return managers; 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/commands/task/RegionManagerSaver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.commands.task; 21 | 22 | import com.sk89q.worldguard.protection.managers.RegionManager; 23 | import com.sk89q.worldguard.protection.managers.storage.StorageException; 24 | 25 | import java.util.Arrays; 26 | import java.util.Collection; 27 | import java.util.concurrent.Callable; 28 | 29 | import static com.google.common.base.Preconditions.checkNotNull; 30 | 31 | public class RegionManagerSaver implements Callable> { 32 | 33 | private final Collection managers; 34 | 35 | public RegionManagerSaver(Collection managers) { 36 | checkNotNull(managers); 37 | this.managers = managers; 38 | } 39 | 40 | public RegionManagerSaver(RegionManager... manager) { 41 | this(Arrays.asList(manager)); 42 | } 43 | 44 | @Override 45 | public Collection call() throws StorageException { 46 | for (RegionManager manager : managers) { 47 | manager.save(); 48 | } 49 | 50 | return managers; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/AbstractRegionSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection; 21 | 22 | import static com.sk89q.worldguard.protection.flags.StateFlag.test; 23 | 24 | import com.sk89q.worldguard.protection.association.RegionAssociable; 25 | import com.sk89q.worldguard.protection.flags.StateFlag; 26 | import com.sk89q.worldguard.protection.flags.StateFlag.State; 27 | 28 | import javax.annotation.Nullable; 29 | 30 | public abstract class AbstractRegionSet implements ApplicableRegionSet { 31 | 32 | @Override 33 | public boolean testState(@Nullable RegionAssociable subject, StateFlag... flags) { 34 | return test(queryState(subject, flags)); 35 | } 36 | 37 | @Nullable 38 | @Override 39 | public State queryState(@Nullable RegionAssociable subject, StateFlag... flags) { 40 | State value = null; 41 | 42 | for (StateFlag flag : flags) { 43 | value = StateFlag.combine(value, queryValue(subject, flag)); 44 | if (value == State.DENY) { 45 | break; 46 | } 47 | } 48 | 49 | return value; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/target/TargetMatcherParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.target; 21 | 22 | import com.sk89q.worldedit.world.block.BlockType; 23 | import com.sk89q.worldedit.world.block.BlockTypes; 24 | import com.sk89q.worldedit.world.item.ItemType; 25 | import com.sk89q.worldedit.world.item.ItemTypes; 26 | 27 | public class TargetMatcherParser { 28 | 29 | public TargetMatcher fromInput(String input) throws TargetMatcherParseException { 30 | input = input.toLowerCase().trim(); 31 | BlockType blockType = BlockTypes.get(input); 32 | if (blockType != null) { 33 | if (blockType.hasItemType()) { 34 | return new ItemBlockMatcher(blockType); 35 | } else { 36 | return new BlockMatcher(blockType); 37 | } 38 | } else { 39 | ItemType itemType = ItemTypes.get(input); 40 | if (itemType == null) { 41 | throw new TargetMatcherParseException("Unknown block or item name: " + input); 42 | } 43 | return new ItemMatcher(itemType); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/event/debug/LoggingBlockPlaceEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.bukkit.event.debug; 21 | 22 | import org.bukkit.block.Block; 23 | import org.bukkit.block.BlockState; 24 | import org.bukkit.entity.Player; 25 | import org.bukkit.event.block.BlockPlaceEvent; 26 | import org.bukkit.inventory.ItemStack; 27 | 28 | import java.util.List; 29 | 30 | public class LoggingBlockPlaceEvent extends BlockPlaceEvent implements CancelLogging { 31 | 32 | private final CancelLogger logger = new CancelLogger(); 33 | 34 | public LoggingBlockPlaceEvent(Block placedBlock, BlockState replacedBlockState, Block placedAgainst, ItemStack itemInHand, Player thePlayer, boolean canBuild) { 35 | super(placedBlock, replacedBlockState, placedAgainst, itemInHand, thePlayer, canBuild); 36 | } 37 | 38 | public List getCancels() { 39 | return logger.getCancels(); 40 | } 41 | 42 | @Override 43 | public void setCancelled(boolean cancel) { 44 | this.logger.log(isCancelled(), cancel, new Exception().getStackTrace()); 45 | super.setCancelled(cancel); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/debounce/BlockPistonRetractKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.bukkit.listener.debounce; 21 | 22 | import org.bukkit.block.Block; 23 | import org.bukkit.event.block.BlockPistonRetractEvent; 24 | 25 | public class BlockPistonRetractKey { 26 | 27 | private final Block piston; 28 | private final Block retract; 29 | 30 | public BlockPistonRetractKey(BlockPistonRetractEvent event) { 31 | piston = event.getBlock(); 32 | retract = event.getRetractLocation().getBlock(); 33 | } 34 | 35 | @Override 36 | public boolean equals(Object o) { 37 | if (this == o) return true; 38 | if (o == null || getClass() != o.getClass()) return false; 39 | 40 | BlockPistonRetractKey that = (BlockPistonRetractKey) o; 41 | 42 | if (!piston.equals(that.piston)) return false; 43 | if (!retract.equals(that.retract)) return false; 44 | 45 | return true; 46 | } 47 | 48 | @Override 49 | public int hashCode() { 50 | int result = piston.hashCode(); 51 | result = 31 * result + retract.hashCode(); 52 | return result; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/util/report/DatapackReport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.bukkit.util.report; 21 | 22 | import com.sk89q.worldedit.util.report.DataReport; 23 | import io.papermc.paper.datapack.Datapack; 24 | import org.bukkit.Bukkit; 25 | 26 | import java.util.Collection; 27 | 28 | /** 29 | * A report for current datapacks with some information. Only available on Paper 30 | */ 31 | public class DatapackReport extends DataReport { 32 | public DatapackReport() { 33 | super("DataPacks"); 34 | 35 | Collection packs = Bukkit.getDatapackManager().getPacks(); 36 | 37 | append("Datapack Count", packs.size()); 38 | append("Datapack Enabled Count", Bukkit.getDatapackManager().getEnabledPacks().size()); 39 | 40 | for (Datapack pack : packs) { 41 | DataReport report = new DataReport("DataPack: " + pack.getName()); 42 | report.append("Enabled?", pack.isEnabled()); 43 | report.append("Name", pack.getName()); 44 | report.append("Compatibility", pack.getCompatibility().name()); 45 | append(report.getTitle(), report); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/event/ItemBlacklistEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.event; 21 | 22 | import com.sk89q.worldedit.math.BlockVector3; 23 | import com.sk89q.worldguard.LocalPlayer; 24 | import com.sk89q.worldguard.blacklist.target.Target; 25 | 26 | import javax.annotation.Nullable; 27 | 28 | abstract class ItemBlacklistEvent extends AbstractBlacklistEvent { 29 | 30 | /** 31 | * Construct the object. 32 | * 33 | * @param player The player associated with this event 34 | * @param position The position the event occurred at 35 | * @param target The target of the event 36 | */ 37 | ItemBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) { 38 | super(player, position, target); 39 | } 40 | 41 | @Override 42 | public String getLoggerMessage() { 43 | return getPlayerName() + " tried to " + getDescription() + " " + getTarget().getFriendlyName(); 44 | } 45 | 46 | @Override 47 | public BlockVector3 getLoggedPosition() { 48 | return getPlayer() != null ? getPlayer().getLocation().toVector().toBlockPoint() : getPosition(); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/commands/ProtectionCommands.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.commands; 21 | 22 | import com.sk89q.minecraft.util.commands.Command; 23 | import com.sk89q.minecraft.util.commands.CommandContext; 24 | import com.sk89q.minecraft.util.commands.NestedCommand; 25 | import com.sk89q.worldedit.extension.platform.Actor; 26 | import com.sk89q.worldguard.WorldGuard; 27 | import com.sk89q.worldguard.commands.region.MemberCommands; 28 | import com.sk89q.worldguard.commands.region.RegionCommands; 29 | 30 | public class ProtectionCommands { 31 | @SuppressWarnings("unused") 32 | private final WorldGuard worldGuard; 33 | 34 | public ProtectionCommands(WorldGuard worldGuard) { 35 | this.worldGuard = worldGuard; 36 | } 37 | 38 | @Command(aliases = {"region", "regions", "rg"}, desc = "Region management commands") 39 | @NestedCommand({RegionCommands.class, MemberCommands.class}) 40 | public void region(CommandContext args, Actor sender) {} 41 | 42 | @Command(aliases = {"worldguard", "wg"}, desc = "WorldGuard commands") 43 | @NestedCommand({WorldGuardCommands.class}) 44 | public void worldGuard(CommandContext args, Actor sender) {} 45 | } 46 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/event/EventType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.event; 21 | 22 | public enum EventType { 23 | 24 | BREAK(BlockBreakBlacklistEvent.class, "on-break"), 25 | PLACE(BlockPlaceBlacklistEvent.class, "on-place"), 26 | INTERACT(BlockInteractBlacklistEvent.class, "on-interact"), 27 | DISPENSE(BlockDispenseBlacklistEvent.class, "on-dispense"), 28 | DESTROY_WITH(ItemDestroyWithBlacklistEvent.class, "on-destroy-with"), 29 | ACQUIRE(ItemAcquireBlacklistEvent.class, "on-acquire"), 30 | EQUIP(ItemEquipBlacklistEvent.class, "on-equip"), 31 | DROP(ItemDropBlacklistEvent.class, "on-drop"), 32 | USE(ItemUseBlacklistEvent.class, "on-use"); 33 | 34 | private final Class eventClass; 35 | private final String ruleName; 36 | 37 | EventType(Class eventClass, String ruleName) { 38 | this.eventClass = eventClass; 39 | this.ruleName = ruleName; 40 | } 41 | 42 | public Class getEventClass() { 43 | return eventClass; 44 | } 45 | 46 | public String getRuleName() { 47 | return ruleName; 48 | } 49 | 50 | } -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/session/WorldPlayerTuple.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.session; 21 | 22 | import com.sk89q.worldedit.world.World; 23 | import com.sk89q.worldguard.LocalPlayer; 24 | 25 | public class WorldPlayerTuple { 26 | 27 | private final World world; 28 | private final LocalPlayer player; 29 | 30 | public WorldPlayerTuple(World world, LocalPlayer player) { 31 | this.world = world; 32 | this.player = player; 33 | } 34 | 35 | @Override 36 | public boolean equals(Object o) { 37 | if (this == o) return true; 38 | if (o == null || getClass() != o.getClass()) return false; 39 | 40 | WorldPlayerTuple that = (WorldPlayerTuple) o; 41 | 42 | if (!player.equals(that.player)) return false; 43 | if (!world.equals(that.world)) return false; 44 | 45 | return true; 46 | } 47 | 48 | public LocalPlayer getPlayer() { 49 | return player; 50 | } 51 | 52 | public World getWorld() { 53 | return world; 54 | } 55 | 56 | @Override 57 | public int hashCode() { 58 | int result = world.hashCode(); 59 | result = 31 * result + player.hashCode(); 60 | return result; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/event/ItemDestroyWithBlacklistEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.event; 21 | 22 | import com.sk89q.worldedit.math.BlockVector3; 23 | import com.sk89q.worldguard.LocalPlayer; 24 | import com.sk89q.worldguard.blacklist.target.Target; 25 | 26 | import javax.annotation.Nullable; 27 | 28 | public final class ItemDestroyWithBlacklistEvent extends ItemBlacklistEvent { 29 | 30 | /** 31 | * Construct the object. 32 | * 33 | * @param player The player associated with this event 34 | * @param position The position the event occurred at 35 | * @param target The target of the event 36 | */ 37 | public ItemDestroyWithBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) { 38 | super(player, position, target); 39 | } 40 | 41 | @Override 42 | public String getDescription() { 43 | return "destroy with"; 44 | } 45 | 46 | @Override 47 | public EventType getEventType() { 48 | return EventType.DESTROY_WITH; 49 | } 50 | 51 | @Override 52 | public BlockVector3 getLoggedPosition() { 53 | // Use the block position instead 54 | return getPosition(); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/event/BlockDispenseBlacklistEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.event; 21 | 22 | import com.sk89q.worldedit.math.BlockVector3; 23 | import com.sk89q.worldguard.LocalPlayer; 24 | import com.sk89q.worldguard.blacklist.target.Target; 25 | 26 | import javax.annotation.Nullable; 27 | 28 | public final class BlockDispenseBlacklistEvent extends BlockBlacklistEvent { 29 | 30 | /** 31 | * Construct the object. 32 | * 33 | * @param player The player associated with this event 34 | * @param position The position the event occurred at 35 | * @param target The target of the event 36 | */ 37 | public BlockDispenseBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) { 38 | super(player, position, target); 39 | } 40 | 41 | @Override 42 | public String getDescription() { 43 | return "dispense"; 44 | } 45 | 46 | @Override 47 | public String getLoggerMessage() { 48 | return getPosition() + " tried to " + getDescription() + " " + getTarget().getFriendlyName(); 49 | } 50 | 51 | @Override 52 | public EventType getEventType() { 53 | return EventType.DISPENSE; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /worldguard-core/src/test/java/com/sk89q/worldguard/domains/CustomUUIDDomain.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.domains; 21 | 22 | import com.sk89q.worldguard.domains.registry.CustomDomainContext; 23 | import com.sk89q.worldguard.domains.registry.InvalidDomainFormatException; 24 | 25 | import java.util.Objects; 26 | import java.util.UUID; 27 | 28 | public class CustomUUIDDomain extends CustomDomain { 29 | private UUID test; 30 | 31 | public CustomUUIDDomain(String name, UUID test) { 32 | super(name); 33 | this.test = test; 34 | } 35 | 36 | @Override 37 | public void parseInput(CustomDomainContext context) throws InvalidDomainFormatException { 38 | throw new InvalidDomainFormatException("not supported"); 39 | } 40 | 41 | @Override 42 | public void unmarshal(Object o) { 43 | } 44 | 45 | @Override 46 | public Object marshal() { 47 | return null; 48 | } 49 | 50 | @Override 51 | public boolean contains(UUID uniqueId) { 52 | return Objects.equals(test, uniqueId); 53 | } 54 | 55 | @Override 56 | public boolean contains(String playerName) { 57 | return false; 58 | } 59 | 60 | @Override 61 | public void clear() { 62 | test = null; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/regions/ProtectedRegionMBRConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.regions; 21 | 22 | import org.khelekore.prtree.MBRConverter; 23 | 24 | public class ProtectedRegionMBRConverter implements MBRConverter { 25 | 26 | @Override 27 | public int getDimensions() { 28 | return 3; 29 | } 30 | 31 | @Override 32 | public double getMax(int dimension, ProtectedRegion region) { 33 | switch (dimension) { 34 | case 0: 35 | return region.getMaximumPoint().getBlockX(); 36 | case 1: 37 | return region.getMaximumPoint().getBlockY(); 38 | case 2: 39 | return region.getMaximumPoint().getBlockZ(); 40 | } 41 | return 0; 42 | } 43 | 44 | @Override 45 | public double getMin(int dimension, ProtectedRegion region) { 46 | switch (dimension) { 47 | case 0: 48 | return region.getMinimumPoint().getBlockX(); 49 | case 1: 50 | return region.getMinimumPoint().getBlockY(); 51 | case 2: 52 | return region.getMinimumPoint().getBlockZ(); 53 | } 54 | return 0; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/debounce/BlockPistonExtendKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.bukkit.listener.debounce; 21 | 22 | import org.bukkit.block.Block; 23 | import org.bukkit.event.block.BlockPistonExtendEvent; 24 | 25 | import java.util.List; 26 | 27 | public class BlockPistonExtendKey { 28 | 29 | private final Block piston; 30 | private final List blocks; 31 | private final int blocksHashCode; 32 | 33 | public BlockPistonExtendKey(BlockPistonExtendEvent event) { 34 | piston = event.getBlock(); 35 | blocks = event.getBlocks(); 36 | blocksHashCode = blocks.hashCode(); 37 | } 38 | 39 | @Override 40 | public boolean equals(Object o) { 41 | if (this == o) return true; 42 | if (o == null || getClass() != o.getClass()) return false; 43 | 44 | BlockPistonExtendKey that = (BlockPistonExtendKey) o; 45 | 46 | if (!blocks.equals(that.blocks)) return false; 47 | if (!piston.equals(that.piston)) return false; 48 | 49 | return true; 50 | } 51 | 52 | @Override 53 | public int hashCode() { 54 | int result = piston.hashCode(); 55 | result = 31 * result + blocksHashCode; 56 | return result; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/event/player/ProcessPlayerEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.bukkit.event.player; 21 | 22 | import org.bukkit.entity.Player; 23 | import org.bukkit.event.Event; 24 | import org.bukkit.event.HandlerList; 25 | 26 | import static com.google.common.base.Preconditions.checkNotNull; 27 | 28 | /** 29 | * This event is an internal event. We do not recommend handling or throwing 30 | * this event or its subclasses as the interface is highly subject to change. 31 | * 32 | *

Posted when a player has to be processed, either because a world has been 33 | * loaded, the server has started, or WorldGuard has been reloaded.

34 | */ 35 | public class ProcessPlayerEvent extends Event { 36 | 37 | private static final HandlerList handlers = new HandlerList(); 38 | 39 | private final Player player; 40 | 41 | public ProcessPlayerEvent(Player player) { 42 | checkNotNull(player); 43 | this.player = player; 44 | } 45 | 46 | public Player getPlayer() { 47 | return player; 48 | } 49 | 50 | @Override 51 | public HandlerList getHandlers() { 52 | return handlers; 53 | } 54 | 55 | public static HandlerList getHandlerList() { 56 | return handlers; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/action/KickAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.action; 21 | 22 | import com.sk89q.worldguard.blacklist.BlacklistEntry; 23 | import com.sk89q.worldguard.blacklist.event.BlacklistEvent; 24 | 25 | import static com.google.common.base.Preconditions.checkNotNull; 26 | 27 | public class KickAction implements Action { 28 | 29 | private final BlacklistEntry entry; 30 | 31 | public KickAction(BlacklistEntry entry) { 32 | checkNotNull(entry); 33 | this.entry = entry; 34 | } 35 | 36 | @Override 37 | public ActionResult apply(BlacklistEvent event, boolean silent, boolean repeating, boolean forceRepeat) { 38 | if (silent) { 39 | return ActionResult.INHERIT; 40 | } 41 | 42 | if (event.getPlayer() != null) { 43 | String message = entry.getMessage(); 44 | 45 | if (message != null) { 46 | event.getPlayer().kick(String.format(message, event.getTarget().getFriendlyName())); 47 | } else { 48 | event.getPlayer().kick("You can't " + event.getDescription() + " " + event.getTarget().getFriendlyName()); 49 | } 50 | } 51 | 52 | return ActionResult.INHERIT; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/protection/events/flags/FlagContextCreateEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.bukkit.protection.events.flags; 21 | 22 | import com.sk89q.worldguard.protection.flags.FlagContext.FlagContextBuilder; 23 | import org.bukkit.event.Event; 24 | import org.bukkit.event.HandlerList; 25 | 26 | public class FlagContextCreateEvent extends Event { 27 | 28 | private FlagContextBuilder builder; 29 | 30 | public FlagContextCreateEvent(FlagContextBuilder builder) { 31 | this.builder = builder; 32 | } 33 | 34 | /** 35 | * Add an object to the flag context with the given key. Keys must be unique. 36 | * 37 | * @param key a unique string to identify the object 38 | * @param value the object to store in the context 39 | * @return true if added successfully, false if the key was already used 40 | */ 41 | public boolean addObject(String key, Object value) { 42 | return builder.tryAddToMap(key, value); 43 | } 44 | 45 | private static final HandlerList handlers = new HandlerList(); 46 | 47 | @Override 48 | public HandlerList getHandlers() { 49 | return handlers; 50 | } 51 | 52 | public static HandlerList getHandlerList() { 53 | return handlers; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/action/BanAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.action; 21 | 22 | import com.sk89q.worldguard.blacklist.BlacklistEntry; 23 | import com.sk89q.worldguard.blacklist.event.BlacklistEvent; 24 | 25 | import static com.google.common.base.Preconditions.checkNotNull; 26 | 27 | public class BanAction implements Action { 28 | 29 | private final BlacklistEntry entry; 30 | 31 | public BanAction(BlacklistEntry entry) { 32 | checkNotNull(entry); 33 | this.entry = entry; 34 | } 35 | 36 | @Override 37 | public ActionResult apply(BlacklistEvent event, boolean silent, boolean repeating, boolean forceRepeat) { 38 | if (silent) { 39 | return ActionResult.INHERIT; 40 | } 41 | 42 | if (event.getPlayer() != null) { 43 | String message = entry.getMessage(); 44 | 45 | if (message != null) { 46 | event.getPlayer().ban("Banned: " + String.format(message, event.getTarget().getFriendlyName())); 47 | } else { 48 | event.getPlayer().ban("Banned: You can't " + event.getDescription() + " " + event.getTarget().getFriendlyName()); 49 | } 50 | } 51 | 52 | return ActionResult.INHERIT; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/association/RegionOverlapAssociation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.association; 21 | 22 | import com.sk89q.worldguard.protection.regions.ProtectedRegion; 23 | 24 | import javax.annotation.Nonnull; 25 | import java.util.Set; 26 | 27 | /** 28 | * Determines that the association to a region is {@code OWNER} if the input 29 | * region is in a set of source regions. 30 | */ 31 | public class RegionOverlapAssociation extends AbstractRegionOverlapAssociation { 32 | 33 | /** 34 | * Create a new instance. 35 | * 36 | * @param source set of regions that input regions must be contained within 37 | */ 38 | public RegionOverlapAssociation(@Nonnull Set source) { 39 | this(source, false); 40 | } 41 | 42 | /** 43 | * Create a new instance. 44 | * 45 | * @param source set of regions that input regions must be contained within 46 | * @param useMaxPriorityAssociation whether to use the max priority from regions to determine association 47 | */ 48 | public RegionOverlapAssociation(@Nonnull Set source, boolean useMaxPriorityAssociation) { 49 | super(source, useMaxPriorityAssociation); 50 | calcMaxPriority(); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/NumberFlag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.flags; 21 | 22 | import static com.google.common.base.Preconditions.checkNotNull; 23 | 24 | import com.google.common.annotations.Beta; 25 | 26 | /** 27 | * Stores an Number. 28 | */ 29 | public abstract class NumberFlag extends Flag { 30 | 31 | private static final Number[] EMPTY_NUMBER_ARRAY = new Number[0]; 32 | private Number[] suggestions = EMPTY_NUMBER_ARRAY; 33 | 34 | protected NumberFlag(String name, RegionGroup defaultGroup) { 35 | super(name, defaultGroup); 36 | } 37 | 38 | protected NumberFlag(String name) { 39 | super(name); 40 | } 41 | 42 | /** 43 | * Not recommended for public use. Will likely be moved when migrating to piston for commands. 44 | * @param values suggested values 45 | */ 46 | @Beta 47 | public void setSuggestedValues(Number[] values) { 48 | this.suggestions = checkNotNull(values); 49 | } 50 | 51 | /** 52 | * Not recommended for public use. Will likely be moved when migrating to piston for commands. 53 | * @return suggested values 54 | */ 55 | @Beta 56 | public Number[] getSuggestedValues() { 57 | return suggestions; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/managers/storage/sql/DomainTableCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.managers.storage.sql; 21 | 22 | import com.sk89q.worldguard.protection.managers.storage.sql.TableCache.GroupNameCache; 23 | import com.sk89q.worldguard.protection.managers.storage.sql.TableCache.UserNameCache; 24 | import com.sk89q.worldguard.protection.managers.storage.sql.TableCache.UserUuidCache; 25 | import com.sk89q.worldguard.util.sql.DataSourceConfig; 26 | 27 | import java.sql.Connection; 28 | 29 | class DomainTableCache { 30 | 31 | private final UserNameCache userNameCache; 32 | private final UserUuidCache userUuidCache; 33 | private final GroupNameCache groupNameCache; 34 | 35 | DomainTableCache(DataSourceConfig config, Connection conn) { 36 | userNameCache = new UserNameCache(config, conn); 37 | userUuidCache = new UserUuidCache(config, conn); 38 | groupNameCache = new GroupNameCache(config, conn); 39 | } 40 | 41 | public UserNameCache getUserNameCache() { 42 | return userNameCache; 43 | } 44 | 45 | public UserUuidCache getUserUuidCache() { 46 | return userUuidCache; 47 | } 48 | 49 | public GroupNameCache getGroupNameCache() { 50 | return groupNameCache; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/util/collect/LongHashTable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.util.collect; 21 | 22 | import java.util.ArrayList; 23 | 24 | public class LongHashTable extends LongBaseHashTable { 25 | 26 | public void put(int msw, int lsw, V value) { 27 | put(toLong(msw, lsw), value); 28 | } 29 | 30 | public V get(int msw, int lsw) { 31 | return get(toLong(msw, lsw)); 32 | } 33 | 34 | public synchronized void put(long key, V value) { 35 | put(new Entry(key, value)); 36 | } 37 | 38 | @SuppressWarnings("unchecked") 39 | public synchronized V get(long key) { 40 | Entry entry = ((Entry) getEntry(key)); 41 | return entry != null ? entry.value : null; 42 | } 43 | 44 | @SuppressWarnings("unchecked") 45 | public synchronized ArrayList values() { 46 | ArrayList ret = new ArrayList<>(); 47 | 48 | ArrayList entries = entries(); 49 | 50 | for (EntryBase entry : entries) { 51 | ret.add(((Entry) entry).value); 52 | } 53 | return ret; 54 | } 55 | 56 | private class Entry extends EntryBase { 57 | V value; 58 | 59 | Entry(long k, V v) { 60 | super(k); 61 | this.value = v; 62 | } 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/session/handler/WaterBreathing.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.session.handler; 21 | 22 | import com.sk89q.worldguard.LocalPlayer; 23 | import com.sk89q.worldguard.session.Session; 24 | 25 | public class WaterBreathing extends Handler { 26 | 27 | public static final Factory FACTORY = new Factory(); 28 | public static class Factory extends Handler.Factory { 29 | @Override 30 | public WaterBreathing create(Session session) { 31 | return new WaterBreathing(session); 32 | } 33 | } 34 | 35 | public boolean waterBreathing; 36 | 37 | public WaterBreathing(Session session) { 38 | super(session); 39 | } 40 | 41 | public boolean hasWaterBreathing() { 42 | return waterBreathing; 43 | } 44 | 45 | public void setWaterBreathing(boolean waterBreathing) { 46 | this.waterBreathing = waterBreathing; 47 | } 48 | 49 | public static boolean set(LocalPlayer player, Session session, boolean value) { 50 | WaterBreathing waterBreathing = session.getHandler(WaterBreathing.class); 51 | if (waterBreathing != null) { 52 | waterBreathing.setWaterBreathing(value); 53 | return true; 54 | } else{ 55 | return false; 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/event/entity/UseEntityEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.bukkit.event.entity; 21 | 22 | import com.sk89q.worldguard.bukkit.cause.Cause; 23 | import org.bukkit.entity.Entity; 24 | import org.bukkit.event.Event; 25 | import org.bukkit.event.HandlerList; 26 | 27 | import javax.annotation.Nonnull; 28 | import javax.annotation.Nullable; 29 | 30 | import static com.google.common.base.Preconditions.checkNotNull; 31 | 32 | /** 33 | * This event is an internal event. We do not recommend handling or throwing 34 | * this event or its subclasses as the interface is highly subject to change. 35 | * 36 | *

Thrown when an entity is used.

37 | */ 38 | public class UseEntityEvent extends AbstractEntityEvent { 39 | 40 | private static final HandlerList handlers = new HandlerList(); 41 | 42 | public UseEntityEvent(@Nullable Event originalEvent, Cause cause, Entity target) { 43 | super(originalEvent, cause, checkNotNull(target)); 44 | } 45 | 46 | @Override 47 | @Nonnull 48 | public Entity getEntity() { 49 | return super.getEntity(); 50 | } 51 | 52 | @Override 53 | public HandlerList getHandlers() { 54 | return handlers; 55 | } 56 | 57 | public static HandlerList getHandlerList() { 58 | return handlers; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/event/entity/DamageEntityEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.bukkit.event.entity; 21 | 22 | import com.sk89q.worldguard.bukkit.cause.Cause; 23 | import org.bukkit.entity.Entity; 24 | import org.bukkit.event.Event; 25 | import org.bukkit.event.HandlerList; 26 | 27 | import javax.annotation.Nonnull; 28 | import javax.annotation.Nullable; 29 | 30 | import static com.google.common.base.Preconditions.checkNotNull; 31 | 32 | /** 33 | * This event is an internal event. We do not recommend handling or throwing 34 | * this event or its subclasses as the interface is highly subject to change. 35 | * 36 | *

Thrown when an entity is damaged.

37 | */ 38 | public class DamageEntityEvent extends AbstractEntityEvent { 39 | 40 | private static final HandlerList handlers = new HandlerList(); 41 | 42 | public DamageEntityEvent(@Nullable Event originalEvent, Cause cause, Entity target) { 43 | super(originalEvent, cause, checkNotNull(target)); 44 | } 45 | 46 | @Override 47 | @Nonnull 48 | public Entity getEntity() { 49 | return super.getEntity(); 50 | } 51 | 52 | @Override 53 | public HandlerList getHandlers() { 54 | return handlers; 55 | } 56 | 57 | public static HandlerList getHandlerList() { 58 | return handlers; 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/event/entity/DestroyEntityEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.bukkit.event.entity; 21 | 22 | import com.sk89q.worldguard.bukkit.cause.Cause; 23 | import org.bukkit.entity.Entity; 24 | import org.bukkit.event.Event; 25 | import org.bukkit.event.HandlerList; 26 | 27 | import javax.annotation.Nonnull; 28 | import javax.annotation.Nullable; 29 | 30 | import static com.google.common.base.Preconditions.checkNotNull; 31 | 32 | /** 33 | * This event is an internal event. We do not recommend handling or throwing 34 | * this event or its subclasses as the interface is highly subject to change. 35 | * 36 | *

Thrown when an entity is removed.

37 | */ 38 | public class DestroyEntityEvent extends AbstractEntityEvent { 39 | 40 | private static final HandlerList handlers = new HandlerList(); 41 | 42 | public DestroyEntityEvent(@Nullable Event originalEvent, Cause cause, Entity target) { 43 | super(originalEvent, cause, checkNotNull(target)); 44 | } 45 | 46 | @Override 47 | @Nonnull 48 | public Entity getEntity() { 49 | return super.getEntity(); 50 | } 51 | 52 | @Override 53 | public HandlerList getHandlers() { 54 | return handlers; 55 | } 56 | 57 | public static HandlerList getHandlerList() { 58 | return handlers; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/RegionGroup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.flags; 21 | 22 | import com.sk89q.worldguard.domains.Association; 23 | 24 | import java.util.Arrays; 25 | import java.util.EnumSet; 26 | import java.util.Set; 27 | 28 | import static com.google.common.base.Preconditions.checkNotNull; 29 | 30 | /** 31 | * A grouping of region membership types. 32 | */ 33 | public enum RegionGroup { 34 | 35 | MEMBERS(Association.MEMBER, Association.OWNER), 36 | OWNERS(Association.OWNER), 37 | NON_MEMBERS(Association.NON_MEMBER), 38 | NON_OWNERS(Association.MEMBER, Association.NON_MEMBER), 39 | ALL(Association.OWNER, Association.MEMBER, Association.NON_MEMBER), 40 | NONE(); 41 | 42 | private final Set contained; 43 | 44 | RegionGroup(Association... association) { 45 | this.contained = association.length > 0 ? EnumSet.copyOf(Arrays.asList(association)) : EnumSet.noneOf(Association.class); 46 | } 47 | 48 | /** 49 | * Test whether this group contains the given membership status. 50 | * 51 | * @param association membership status 52 | * @return true if contained 53 | */ 54 | public boolean contains(Association association) { 55 | checkNotNull(association); 56 | return contained.contains(association); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/action/TellAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.blacklist.action; 21 | 22 | import com.sk89q.worldguard.blacklist.BlacklistEntry; 23 | import com.sk89q.worldguard.blacklist.event.BlacklistEvent; 24 | 25 | import static com.google.common.base.Preconditions.checkNotNull; 26 | 27 | public class TellAction extends RepeatGuardedAction { 28 | 29 | private final BlacklistEntry entry; 30 | 31 | public TellAction(BlacklistEntry entry) { 32 | checkNotNull(entry); 33 | this.entry = entry; 34 | } 35 | 36 | @Override 37 | protected ActionResult applyNonRepeated(BlacklistEvent event, boolean silent) { 38 | if (silent) { 39 | return ActionResult.INHERIT; 40 | } 41 | 42 | String message = entry.getMessage(); 43 | 44 | if (event.getPlayer() != null) { 45 | if (message != null) { 46 | message = message.replaceAll("(?!<\\\\)\\\\n", "\n").replaceAll("\\\\\\\\n", "\\n"); 47 | event.getPlayer().print(String.format(message, event.getTarget().getFriendlyName())); 48 | } else { 49 | event.getPlayer().printError("You're not allowed to " + event.getDescription() + " " + event.getTarget().getFriendlyName() + "."); 50 | } 51 | } 52 | 53 | return ActionResult.INHERIT; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/managers/storage/MemoryRegionDatabase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.managers.storage; 21 | 22 | import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; 23 | import com.sk89q.worldguard.protection.managers.RegionDifference; 24 | import com.sk89q.worldguard.protection.regions.ProtectedRegion; 25 | 26 | import java.util.Collections; 27 | import java.util.HashSet; 28 | import java.util.Set; 29 | 30 | /** 31 | * A region database that saves the memory to an in-memory {@link HashSet}. 32 | * 33 | *

This implementation is thread-safe. Difference saves 34 | * are not supported.

35 | */ 36 | public class MemoryRegionDatabase implements RegionDatabase { 37 | 38 | private Set regions = Collections.emptySet(); 39 | 40 | @Override 41 | public String getName() { 42 | return "MEMORY"; 43 | } 44 | 45 | @Override 46 | public Set loadAll(FlagRegistry flagRegistry) { 47 | return regions; 48 | } 49 | 50 | @Override 51 | public void saveAll(Set regions) { 52 | this.regions = Collections.unmodifiableSet(new HashSet<>(regions)); 53 | } 54 | 55 | @Override 56 | public void saveChanges(RegionDifference difference) throws DifferenceSaveException { 57 | throw new DifferenceSaveException(); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/UUIDFlag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.protection.flags; 21 | 22 | import javax.annotation.Nullable; 23 | import java.util.UUID; 24 | 25 | public class UUIDFlag extends Flag { 26 | 27 | public UUIDFlag(String name, @Nullable RegionGroup defaultGroup) { 28 | super(name, defaultGroup); 29 | } 30 | 31 | public UUIDFlag(String name) { 32 | super(name); 33 | } 34 | 35 | @Override 36 | public UUID parseInput(FlagContext context) throws InvalidFlagFormatException { 37 | String input = context.getUserInput(); 38 | if ("self".equalsIgnoreCase(input)) { 39 | return context.getSender().getUniqueId(); 40 | } 41 | try { 42 | return UUID.fromString(input); 43 | } catch (IllegalArgumentException e) { 44 | throw new InvalidFlagFormatException("Not a valid uuid: " + input); 45 | } 46 | } 47 | 48 | @Override 49 | public UUID unmarshal(@Nullable Object o) { 50 | if (!(o instanceof String)) { 51 | return null; 52 | } 53 | try { 54 | return UUID.fromString((String)o); 55 | } catch (IllegalArgumentException e) { 56 | return null; 57 | } 58 | } 59 | 60 | @Override 61 | public Object marshal(UUID o) { 62 | return o.toString(); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/chest/BukkitSignChestProtection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * WorldGuard, a suite of tools for Minecraft 3 | * Copyright (C) sk89q 4 | * Copyright (C) WorldGuard team and contributors 5 | * 6 | * This program is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 | * for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | package com.sk89q.worldguard.bukkit.chest; 21 | 22 | import com.sk89q.worldedit.bukkit.BukkitAdapter; 23 | import com.sk89q.worldedit.util.Location; 24 | import com.sk89q.worldguard.LocalPlayer; 25 | import com.sk89q.worldguard.chest.SignChestProtection; 26 | import org.bukkit.block.BlockState; 27 | import org.bukkit.block.Sign; 28 | 29 | public class BukkitSignChestProtection extends SignChestProtection { 30 | 31 | private Boolean isProtectedSign(Sign sign, LocalPlayer player) { 32 | if (sign.getLine(0).equalsIgnoreCase("[Lock]")) { 33 | if (player == null) { // No player, no access 34 | return true; 35 | } 36 | 37 | String name = player.getName(); 38 | return !name.equalsIgnoreCase(sign.getLine(1).trim()) 39 | && !name.equalsIgnoreCase(sign.getLine(2).trim()) 40 | && !name.equalsIgnoreCase(sign.getLine(3).trim()); 41 | } 42 | 43 | return null; 44 | } 45 | 46 | @Override 47 | public Boolean isProtectedSign(Location block, LocalPlayer player) { 48 | BlockState state = BukkitAdapter.adapt(block).getBlock().getState(); 49 | if (!(state instanceof Sign)) { 50 | return null; 51 | } 52 | return isProtectedSign((Sign) state, player); 53 | } 54 | } 55 | --------------------------------------------------------------------------------