Compare commits
126 Commits
Author | SHA1 | Date |
---|---|---|
Preva1l | d2edaceae7 | |
Intelli | ca59ff25df | |
Intelli | cfb53f766e | |
lukyn76 | e7c5078035 | |
Intelli | 5242973fe8 | |
Intelli | e99a4a86d0 | |
Intelli | 48b1fe22d3 | |
Intelli | 29225a4a59 | |
Intelli | e6557ab5f3 | |
Intelli | 5859958ec2 | |
Intelli | 5bc28b3e05 | |
Intelli | b41e40acc0 | |
Intelli | 5a49ef8447 | |
Telesphoreo | 42af5dc7a1 | |
Intelli | dbb44ab5b9 | |
Intelli | d18a023e73 | |
Intelli | 377a6f55b9 | |
Intelli | e61b8a4d9b | |
Intelli | 3b9d8726d9 | |
Intelli | 48d2030766 | |
Intelli | 86ace6c326 | |
Intelli | 346b4b8b20 | |
Intelli | 704f0aaf9b | |
Intelli | 4daaf6cc02 | |
Intelli | 5426e69fb8 | |
Intelli | 6023c21ba9 | |
Intelli | 3e3496ad12 | |
Intelli | f3c631bbf5 | |
Intelli | d8ad48beb8 | |
Intelli | 053f7d5c7d | |
Nahuel Dolores | a4c37da8ee | |
Intelli | b1598a022a | |
Intelli | 32688c55cf | |
Intelli | a239b51ed1 | |
Intelli | af1d4402eb | |
Intelli | f7fea2b298 | |
Intelli | 15e8cd5b88 | |
Intelli | c91f460e42 | |
Intelli | 7424037795 | |
Intelli | ba6a55fff6 | |
Intelli | 1c57ba52aa | |
Intelli | 4308d4afca | |
Intelli | 7c61a33571 | |
Intelli | 172c6440db | |
Intelli | d8a669ed6c | |
Intelli | 66b77ee75a | |
Intelli | 488392cdbc | |
Intelli | b48dcec589 | |
Intelli | e49913bc09 | |
Intelli | d944c2bd89 | |
Intelli | f76b0d45bd | |
Intelli | 9f3196dc97 | |
Intelli | 69c163468f | |
Intelli | 34421b64f7 | |
Intelli | 0edf160f43 | |
Intelli | 45d4642086 | |
Take-John | af35a98b1d | |
Take-John | 950cf9460b | |
Intelli | 1b6d2ec667 | |
Intelli | d7910262be | |
Intelli | 8459181f77 | |
Intelli | 58f4a76d75 | |
Intelli | a46deeb6ba | |
Jeff P | 7fd50a0507 | |
Intelli | 9e1d5af97d | |
ianiiaannn | 4cce566e37 | |
Intelli | 703c36f356 | |
Intelli | 1dd293c5a4 | |
Radiant | 1331b8d0c5 | |
violetc | 2476aa2ea8 | |
Keno Medenbach | 6045799fea | |
Intelli | 342fadd0f6 | |
Intelli | e81c84671c | |
Intelli | e501046073 | |
Intelli | c6a0f20fff | |
Intelli | 05aebe7544 | |
Intelli | 36ad62007f | |
Intelli | bdde2d36be | |
Intelli | f32a3e7c5e | |
Intelli | c7cf035564 | |
Intelli | d4997cca60 | |
Intelli | 355eea1cf9 | |
Intelli | d7b76135c8 | |
Intelli | 1a06e6a6bf | |
Intelli | e7a6f21d88 | |
Intelli | 5973206bb3 | |
Intelli | 1e007c98a4 | |
Intelli | df9b478be7 | |
Intelli | 054beb700b | |
Intelli | 47a000a57f | |
Intelli | cde18dc529 | |
asdanjer | d200616fe1 | |
Intelli | e0d65453b6 | |
Intelli | d414db1c0b | |
Intelli | b0469924a7 | |
Intelli | 4e43a42662 | |
Intelli | 7e97e12969 | |
Intelli | d7d53bf9e2 | |
Intelli | b9309482cf | |
Intelli | 410eba5559 | |
ByteExceptionM | 814ae4d9d5 | |
Intelli | d64ec8d911 | |
Intelli | 5d90f25211 | |
Intelli | 7825f61e45 | |
Intelli | 7e49c95832 | |
Intelli | 4b9e69c40f | |
Sofiane H. Djerbi | f2934fd876 | |
Intelli | f706bcf38e | |
Intelli | fe6023450c | |
Intelli | ace870b930 | |
Intelli | 7170e29452 | |
Intelli | 29345e2fb1 | |
Amir | a22db638fa | |
Intelli | de3c326203 | |
Intelli | acb71a83a2 | |
Intelli | 3ffed30b1e | |
Intelli | 5d6fd60d40 | |
Intelli | 20710a00de | |
Intelli | 5eabee6504 | |
Intelli | 97eb0d777b | |
Intelli | 61847f2f8d | |
Intelli | 12f2000085 | |
Intelli | 66e32c02bf | |
Intelli | 9da1343f7f | |
Intelli | 272ecae858 | |
Intelli | 3db2159292 |
|
@ -10,7 +10,7 @@ Please note we have a code of conduct, please follow it in all your interactions
|
|||
- For consistency, please only use spaces for indentation.
|
||||
- Use descriptiveCamelCase for variable/method names. Names containing underscore or abbreviations should be changed.
|
||||
- Restrict changes in a commit to a single event or section of code (e.g. refactor BlockBreakEvent and BlockPlaceEvent in separate commits)
|
||||
- Attempt to keep the amount of code modified in a single commit small and readable.
|
||||
- Attempt to keep the amount of code modified in a single pull request small and readable.
|
||||
- Please utilize [SonarLint](https://www.sonarlint.org) in your IDE. Contributions are automatically analyzed.
|
||||
- When adding new functionality, please also be sure to update the documentation as well.
|
||||
- Use common sense. If you have a suggestion for a contribution guideline, post it on Discord.
|
||||
|
@ -148,4 +148,4 @@ at [https://www.contributor-covenant.org/translations][translations].
|
|||
[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
|
||||
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||
[FAQ]: https://www.contributor-covenant.org/faq
|
||||
[translations]: https://www.contributor-covenant.org/translations
|
||||
[translations]: https://www.contributor-covenant.org/translations
|
||||
|
|
|
@ -11,14 +11,14 @@ CoreProtect
|
|||
|
||||
CoreProtect is a blazing fast data logging and anti-griefing tool for Minecraft servers.
|
||||
|
||||
For a detailed description of the plugin, please visit [spigotmc.org/resources/coreprotect.8631](https://www.spigotmc.org/resources/coreprotect.8631/).
|
||||
For a detailed description of the plugin, please visit [coreprotect.net](https://coreprotect.net).
|
||||
|
||||
| Quick Links | |
|
||||
| --- | --- |
|
||||
| CoreProtect Discord: | [discord.gg/b4DZ4jy](https://discord.gg/b4DZ4jy) |
|
||||
| CoreProtect Patreon: | [patreon.com/coreprotect](https://www.patreon.com/coreprotect) |
|
||||
| CoreProtect Documentation: | [docs.coreprotect.net](https://docs.coreprotect.net) |
|
||||
| Downloads for MC 1.14 - 1.18: | [spigotmc.org/resources/coreprotect.8631](https://www.spigotmc.org/resources/coreprotect.8631/) |
|
||||
| Downloads for MC 1.14 - 1.20: | [coreprotect.net/latest](https://coreprotect.net/latest/) |
|
||||
| Downloads for MC 1.8 - 1.12: | [coreprotect.net/legacy](https://coreprotect.net/legacy/) |
|
||||
|
||||
bStats
|
||||
|
@ -41,7 +41,7 @@ Maven
|
|||
<dependency>
|
||||
<groupId>net.coreprotect</groupId>
|
||||
<artifactId>coreprotect</artifactId>
|
||||
<version>21.0</version>
|
||||
<version>22.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
```
|
||||
|
|
24
build.gradle
24
build.gradle
|
@ -2,16 +2,16 @@ import org.apache.tools.ant.filters.ReplaceTokens
|
|||
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'com.github.johnrengelman.shadow' version '7.1.2'
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
||||
id 'com.palantir.git-version' version '0.13.0'
|
||||
}
|
||||
|
||||
group = 'net.coreprotect'
|
||||
String projectVersion = '21.3'
|
||||
String projectVersion = '22.4'
|
||||
String projectBranch = ''
|
||||
version = projectVersion // `version` might be modified, we don't always want that (e.g. plugin.yml)
|
||||
description = 'Provides block protection for your server.'
|
||||
sourceCompatibility = '17'
|
||||
sourceCompatibility = '21'
|
||||
|
||||
if (System.getenv("BUILD_NUMBER") != null) {
|
||||
// Being built in Jenkins, append Build ID
|
||||
|
@ -23,20 +23,18 @@ if (System.getenv("BUILD_NUMBER") != null) {
|
|||
logger.info("Building version $version")
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
maven { url = 'https://hub.spigotmc.org/nexus/content/groups/public/' }
|
||||
maven { url = 'https://papermc.io/repo/repository/maven-public/' }
|
||||
maven { url = 'https://repo.papermc.io/repository/maven-public/' }
|
||||
maven { url = 'https://repo.codemc.org/repository/maven-public/' }
|
||||
maven { url = 'https://maven.enginehub.org/repo/' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly('com.sk89q.worldedit:worldedit-bukkit:7.0.0-SNAPSHOT') {
|
||||
exclude group: 'org.bukkit'
|
||||
}
|
||||
compileOnly 'io.papermc.paper:paper-api:1.19-R0.1-SNAPSHOT'
|
||||
implementation(platform("com.intellectualsites.bom:bom-newest:1.44")) // Ref: https://github.com/IntellectualSites/bom
|
||||
compileOnly("com.fastasyncworldedit:FastAsyncWorldEdit-Core")
|
||||
compileOnly("com.fastasyncworldedit:FastAsyncWorldEdit-Bukkit")
|
||||
compileOnly 'io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT'
|
||||
implementation 'org.bstats:bstats-bukkit-lite:1.8'
|
||||
implementation 'com.zaxxer:HikariCP:4.0.3'
|
||||
implementation 'com.zaxxer:HikariCP:5.0.1'
|
||||
}
|
||||
|
||||
jar {
|
||||
|
@ -52,6 +50,10 @@ shadowJar {
|
|||
// #toString because #getGroup technically returns an Object
|
||||
relocate('org.bstats', project.group.toString())
|
||||
relocate('com.zaxxer', project.group.toString())
|
||||
exclude(dependency('com.google.code.gson:.*'))
|
||||
exclude(dependency('org.intellij:.*'))
|
||||
exclude(dependency('org.jetbrains:.*'))
|
||||
exclude(dependency('org.slf4j:.*'))
|
||||
}
|
||||
archiveClassifier.set(null)
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ The CoreProtect API enables you to log your own block changes, perform lookups,
|
|||
|
||||
| API Details | |
|
||||
| --- | --- |
|
||||
| **API Version:** | 9 |
|
||||
| **Plugin Version:** | v21.0+ |
|
||||
| **API Version:** | 10 |
|
||||
| **Plugin Version:** | v22.4+ |
|
||||
| **Maven:** | [maven.playpro.com](https://maven.playpro.com) |
|
||||
|
||||
*Documentation for the API version 9 can be found [here](/api/version/v9/).*
|
||||
*Documentation for the API version 10 can be found [here](/api/version/v10/).*
|
|
@ -0,0 +1,526 @@
|
|||
# API Version 10
|
||||
|
||||
The CoreProtect API enables you to log your own block changes, perform lookups, rollbacks, restores, and more.
|
||||
|
||||
| API Details | |
|
||||
| --- | --- |
|
||||
| **API Version:** | 10 |
|
||||
| **Plugin Version:** | v22.4+ |
|
||||
| **Maven:** | [maven.playpro.com](https://maven.playpro.com) |
|
||||
|
||||
---
|
||||
|
||||
## Upgrading from API v9
|
||||
|
||||
The changes from the previous API version are as follows:
|
||||
|
||||
- The following methods have been added:
|
||||
```java
|
||||
logPlacement(String user, BlockState blockState)
|
||||
|
||||
logRemoval(String user, BlockState blockState)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Getting Started
|
||||
|
||||
Ensure you're using CoreProtect 22.4 or higher. Add it as an external jar to your plugin in your IDE.
|
||||
Alternatively, if using Maven, you can add it via the repository [https://maven.playpro.com](https://maven.playpro.com) (net.coreprotect, 22.4).
|
||||
|
||||
The first thing you need to do is get access to CoreProtect. You can do this by using code similar to the following:
|
||||
|
||||
```java
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.CoreProtectAPI;
|
||||
|
||||
private CoreProtectAPI getCoreProtect() {
|
||||
Plugin plugin = getServer().getPluginManager().getPlugin("CoreProtect");
|
||||
|
||||
// Check that CoreProtect is loaded
|
||||
if (plugin == null || !(plugin instanceof CoreProtect)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check that the API is enabled
|
||||
CoreProtectAPI CoreProtect = ((CoreProtect) plugin).getAPI();
|
||||
if (CoreProtect.isEnabled() == false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check that a compatible version of the API is loaded
|
||||
if (CoreProtect.APIVersion() < 10) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return CoreProtect;
|
||||
}
|
||||
```
|
||||
|
||||
With this code, you can then access the API with a call like the following:
|
||||
|
||||
```java
|
||||
CoreProtectAPI api = getCoreProtect();
|
||||
if (api != null){ // Ensure we have access to the API
|
||||
api.testAPI(); // Will print out "[CoreProtect] API test successful." in the console.
|
||||
}
|
||||
```
|
||||
|
||||
Yay, you're now using the CoreProtect API!
|
||||
|
||||
---
|
||||
|
||||
## API Overview
|
||||
|
||||
### Available Methods
|
||||
|
||||
```java
|
||||
boolean isEnabled()
|
||||
|
||||
void testAPI()
|
||||
|
||||
List<String[]> performLookup(int time, List<String> restrict_users, List<String> exclude_users, List<Object> restrict_blocks, List<Object> exclude_blocks, List<Integer> action_list, int radius, Location radius_location)
|
||||
|
||||
List<String[]> performRollback(int time, List<String> restrict_users, List<String> exclude_users, List<Object> restrict_blocks, List<Object> exclude_blocks, List<Integer> action_list, int radius, Location radius_location)
|
||||
|
||||
List<String[]> performRestore(int time, List<String> restrict_users, List<String> exclude_users, List<Object> restrict_blocks, List<Object> exclude_blocks, List<Integer> action_list, int radius, Location radius_location)
|
||||
|
||||
List<String[]> blockLookup(Block block, int time)
|
||||
|
||||
List<String[]> sessionLookup(String user, int time)
|
||||
|
||||
List<String[]> queueLookup(Block block)
|
||||
|
||||
ParseResult parseResult(String[] result)
|
||||
|
||||
boolean logChat(Player player, String message)
|
||||
|
||||
boolean logCommand(Player player, String command)
|
||||
|
||||
boolean logPlacement(String user, BlockState blockState)
|
||||
|
||||
boolean logPlacement(String user, Location location, Material type, BlockData blockData)
|
||||
|
||||
boolean logRemoval(String user, BlockState blockState)
|
||||
|
||||
boolean logRemoval(String user, Location location, Material type, BlockData blockData)
|
||||
|
||||
boolean logContainerTransaction(String user, Location location)
|
||||
|
||||
boolean logInteraction(String user, Location location)
|
||||
|
||||
boolean hasPlaced(String user, Block block, int time, int offset)
|
||||
|
||||
boolean hasRemoved(String user, Block block, int time, int offset)
|
||||
|
||||
void performPurge(int time)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Available Events
|
||||
|
||||
*The following events are emitted by CoreProtect.*
|
||||
|
||||
#### CoreProtectPreLogEvent
|
||||
|
||||
Fired when a CoreProtect logger is about to log an action. Cancellable.
|
||||
|
||||
| Property | Description | Mutable |
|
||||
| --- | --- | --- |
|
||||
| User | The name of the user under which this action will be logged. | Yes |
|
||||
| Cancelled | If cancelled, the action won't be logged to the database. | Yes |
|
||||
|
||||
---
|
||||
|
||||
### Method Usage
|
||||
|
||||
*Detailed method information is listed below.*
|
||||
|
||||
#### `isEnabled()`
|
||||
|
||||
Calling this will return true if the server has the CoreProtect API enabled, and false if it does not.
|
||||
|
||||
---
|
||||
|
||||
#### `testAPI()`
|
||||
|
||||
Running this will print out "[CoreProtect] API Test Successful." in the server console.
|
||||
|
||||
---
|
||||
|
||||
#### `performLookup(int time, List<String> restrict_users, List<String> exclude_users, List<Object> restrict_blocks, List<Object> exclude_blocks, List<Integer> action_list, int radius, Location radius_location)`
|
||||
|
||||
This will perform a lookup.
|
||||
|
||||
* **time:** Specify the amount of time to search back. "5" would return results from the last 5 seconds.
|
||||
* **restrict_users:** Specify any usernames to perform the lookup on. Can be set to "null" if both a radius and a location are specified.
|
||||
* **exclude_users:** Specify any usernames to exclude from the lookup. Can be set to "null".
|
||||
* **restrict_blocks:** Specify a list of EntityType's or Material's to restrict the search to. Can be set to "null".
|
||||
* **exclude_blocks:** Specify a list of EntityType's or Material's to exclude from the search. Can be set to "null".
|
||||
* **action_list:** Specify a list of action types to restrict the search to. Can be set to "null"
|
||||
* **radius:** Specify a radius to restrict the search to. A location must be specified if using this. Set to "0" to disable.
|
||||
* **radius_location:** Specify a location to search around. Can be set to "null" if no radius is specified, and a user is specified.
|
||||
|
||||
---
|
||||
|
||||
#### `performRollback(int time, List<String> restrict_users, List<String> exclude_users, List<Object> restrict_blocks, List<Object> exclude_blocks, List<Integer> action_list, int radius, Location radius_location)`
|
||||
|
||||
This will perform a rollback. Method must be called async.
|
||||
|
||||
* **time:** Specify the amount of time to rollback. "5" would return results from the last 5 seconds.
|
||||
* **restrict_users:** Specify any usernames to perform the rollback on. Can be set to "null" if both a radius and a location are specified.
|
||||
* **exclude_users:** Specify any usernames to exclude from the rollback. Can be set to "null".
|
||||
* **restrict_blocks:** Specify a list of EntityType's or Material's to restrict the rollback to. Can be set to "null".
|
||||
* **exclude_blocks:** Specify a list of EntityType's or Material's to exclude from the rollback. Can be set to "null".
|
||||
* **action_list:** Specify a list of action types to restrict the rollback to. Can be set to "null"
|
||||
* **radius:** Specify a radius to restrict the rollback to. A location must be specified if using this. Set to "0" to disable.
|
||||
* **radius_location:** Specify a location to rollback around. Can be set to "null" if no radius is specified, and a user is specified.
|
||||
|
||||
---
|
||||
|
||||
#### `performRestore(int time, List<String> restrict_users, List<String> exclude_users, List<Object> restrict_blocks, List<Object> exclude_blocks, List<Integer> action_list, int radius, Location radius_location)`
|
||||
|
||||
This will perform a restore.
|
||||
|
||||
* **time:** Specify the amount of time to restore. "5" would return results from the last 5 seconds.
|
||||
* **restrict_users:** Specify any usernames to perform the restore on. Can be set to "null" if both a radius and a location are specified.
|
||||
* **exclude_users:** Specify any usernames to exclude from the restore. Can be set to "null".
|
||||
* **restrict_blocks:** Specify a list of EntityType's or Material's to restrict the restore to. Can be set to "null".
|
||||
* **exclude_blocks:** Specify a list of EntityType's or Material's to exclude from the restore. Can be set to "null".
|
||||
* **action_list:** Specify a list of action types to restrict the restore to. Can be set to "null"
|
||||
* **radius:** Specify a radius to restrict the restore to. A location must be specified if using this. Set to "0" to disable.
|
||||
* **radius_location:** Specify a location to restore around. Can be set to "null" if no radius is specified, and a user is specified.
|
||||
|
||||
---
|
||||
|
||||
#### `blockLookup(Block block, int time)`
|
||||
|
||||
This will perform a full lookup on a single block.
|
||||
|
||||
* **block:** The block to perform the lookup on.
|
||||
* **time:** Specify the amount of time to lookup. "5" would return results from the last 5 seconds.
|
||||
|
||||
---
|
||||
|
||||
#### `queueLookup(Block block)`
|
||||
|
||||
This will search the consumer queue for changes on a block not yet saved in the database.
|
||||
|
||||
* **block:** The block to perform the lookup on.
|
||||
|
||||
---
|
||||
|
||||
#### `sessionLookup(String user, int time)`
|
||||
|
||||
This will perform a session lookup on a single player.
|
||||
|
||||
* **user:** The username to perform the lookup on.
|
||||
* **time:** Specify the amount of time to lookup. "5" would return results from the last 5 seconds.
|
||||
|
||||
---
|
||||
|
||||
#### `ParseResult parseResult(String[] result)`
|
||||
|
||||
This will parse results from a lookup. You'll then be able to view the following:
|
||||
|
||||
* **getX():** Get the X coordinate of the block.
|
||||
* **getY():** Get the Y coordinate of the block.
|
||||
* **getZ():** Get the Z coordinate of the block.
|
||||
* **getType():** Get the Material of the block.
|
||||
* **getBlockData():** Get the BlockData of the block.
|
||||
* **getPlayer():** Get the username as a string.
|
||||
* **getTimestamp():** Get the time of the action.
|
||||
* **getActionId():** Get the action ID. (0=removed, 1=placed, 2=interaction)
|
||||
* **getActionString():** Get the action as a string. (Removal, Placement, Interaction)
|
||||
* **isRolledBack():** If the block is currently rolled back or not.
|
||||
* **worldName():** The name of the world the block is located in.
|
||||
|
||||
---
|
||||
|
||||
#### `logPlacement(String user, BlockState blockState)`
|
||||
|
||||
This will log a block as being placed. *(Thread safe)*
|
||||
|
||||
* **user:** Specify the username to log as having placed the block.
|
||||
* **blockState:** Specify the BlockState of the block you're logging.
|
||||
|
||||
---
|
||||
|
||||
#### `logPlacement(String user, Location location, Material type, BlockData blockData)`
|
||||
|
||||
This will log a block as being placed.
|
||||
|
||||
* **user:** Specify the username to log as having placed the block.
|
||||
* **location:** Specify the location of the block you're logging.
|
||||
* **type:** Specify the Material of the block you're logging.
|
||||
* **blockData:** Specify the BlockData of the block you're logging. Can be set to "null".
|
||||
|
||||
---
|
||||
|
||||
#### `logRemoval(String user, BlockState blockState)`
|
||||
|
||||
This will log a block as being removed/broken. *(Thread safe)*
|
||||
|
||||
* **user:** Specify the username to log as having removed the block.
|
||||
* **blockState:** Specify the BlockState of the block you're logging.
|
||||
|
||||
---
|
||||
|
||||
#### `logRemoval(String user, Location location, Material type, BlockData blockData)`
|
||||
|
||||
This will log a block as being removed/broken, and will log the block's inventory (if applicable).
|
||||
|
||||
* **user:** Specify the username to log as having removed the block.
|
||||
* **location:** Specify the location of the block you're logging.
|
||||
* **type:** Specify the Material of the block you're logging.
|
||||
* **blockData:** Specify the BlockData of the block you're logging. Can be set to "null".
|
||||
|
||||
---
|
||||
|
||||
#### `logContainerTransaction(String user, Location location)`
|
||||
|
||||
This will log any transactions made to a block's inventory immediately after calling the method.
|
||||
|
||||
* **user:** Specify the username to log as having added/removed the items.
|
||||
* **location:** Specify the location of the block inventory you're logging.
|
||||
|
||||
---
|
||||
|
||||
#### `logInteraction(String user, Location location)`
|
||||
|
||||
This will log a block as having been interacted with.
|
||||
|
||||
* **user:** Specify the username to log as having caused the interaction.
|
||||
* **location:** Specify the location of the interaction you're logging.
|
||||
|
||||
---
|
||||
|
||||
#### `hasPlaced(String user, Block block, int time, int offset)`
|
||||
|
||||
This will return true if a user has already placed a block at the location within the specified time limit.
|
||||
|
||||
* **user:** The username you're checking to see if they've placed a block already.
|
||||
* **block:** The block you're checking.
|
||||
* **time:** How far back to check. "5" would only check through the last 5 seconds of logged blocks.
|
||||
* **offset:** A time offset. "2" would ignore the last 2 seconds of most recently ignored data. (0 = no offset)
|
||||
|
||||
---
|
||||
|
||||
#### `hasRemoved(String user, Block block, int time, int offset)`
|
||||
|
||||
This will return true if a user has already removed a block at the location within the specified time limit.
|
||||
|
||||
* **user:** The username you're checking to see if they've removed a block already.
|
||||
* **block:** The block you're checking.
|
||||
* **time:** How far back to check. "5" would only check through the last 5 seconds of logged blocks.
|
||||
* **offset:** A time offset. "2" would ignore the last 2 seconds of most recently ignored data. (0 = no offset)
|
||||
|
||||
---
|
||||
|
||||
#### `performPurge(int time)`
|
||||
|
||||
This will perform a purge on the CoreProtect database.
|
||||
|
||||
* **time:** Purge any data earlier than this. "120" would purge any data older than 120 seconds (2 minutes).
|
||||
|
||||
---
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
- Get the last 60 seconds of block data for the user "Notch".
|
||||
```java
|
||||
CoreProtectAPI CoreProtect = getCoreProtect();
|
||||
if (CoreProtect != null){ // Ensure we have access to the API
|
||||
List<String[]> lookup = CoreProtect.performLookup(60, Arrays.asList("Notch"), null, null, null, null, 0, null);
|
||||
if (lookup != null){
|
||||
for (String[] result : lookup){
|
||||
ParseResult parseResult = CoreProtect.parseResult(result);
|
||||
int x = parseResult.getX();
|
||||
int y = parseResult.getY();
|
||||
int z = parseResult.getZ();
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
- Get the last 60 seconds of block data for the user "Notch", excluding dirt and grass blocks.
|
||||
```java
|
||||
CoreProtectAPI CoreProtect = getCoreProtect();
|
||||
if (CoreProtect != null){ // Ensure we have access to the API
|
||||
List<Object> exclude = Arrays.asList(Material.DIRT, Material.GRASS);
|
||||
List<String[]> lookup = CoreProtect.performLookup(60, Arrays.asList("Notch"), null, null, exclude, null, 0, null);
|
||||
if (lookup != null){
|
||||
for (String[] value : lookup){
|
||||
ParseResult result = CoreProtect.parseResult(value);
|
||||
int x = result.getX();
|
||||
int y = result.getY();
|
||||
int z = result.getZ();
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
- Get the last 60 seconds of block data within 5 blocks of a location.
|
||||
```java
|
||||
CoreProtectAPI CoreProtect = getCoreProtect();
|
||||
if (CoreProtect != null){ // Ensure we have access to the API
|
||||
List<String[]> lookup = CoreProtect.performLookup(60, null, null, null, null, null, 5, location);
|
||||
if (lookup != null){
|
||||
for (String[] value : lookup){
|
||||
ParseResult result = CoreProtect.parseResult(value);
|
||||
int x = result.getX();
|
||||
int y = result.getY();
|
||||
int z = result.getZ();
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
- Rollbacks / restores use the same code structure as the above examples. For example:
|
||||
```java
|
||||
class BasicThread implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
CoreProtectAPI CoreProtect = getCoreProtect();
|
||||
if (CoreProtect != null){ // Ensure we have access to the API
|
||||
List<String[]> lookup = CoreProtect.performRollback(60, Arrays.asList("Notch"), null, null, null, null, 0, null);
|
||||
if (lookup != null){
|
||||
for (String[] value : lookup){
|
||||
ParseResult result = CoreProtect.parseResult(value);
|
||||
int x = result.getX();
|
||||
int y = result.getY();
|
||||
int z = result.getZ();
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Runnable runnable = new BasicThread();
|
||||
Thread thread = new Thread(runnable);
|
||||
thread.start();
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
- Check if the user "Notch" has already placed a block at a location within the last 60 seconds.
|
||||
```java
|
||||
CoreProtectAPI CoreProtect = getCoreProtect();
|
||||
if (CoreProtect != null){ // Ensure we have access to the API
|
||||
boolean hasPlaced = CoreProtect.hasPlaced("Notch", block, 60, 0);
|
||||
|
||||
// Search queue for pending changes
|
||||
if (!hasPlaced){
|
||||
List<String[]> lookup = CoreProtect.queueLookup(block);
|
||||
for (String[] result : lookup){
|
||||
ParseResult parseResult = CoreProtect.parseResult(result);
|
||||
if (parseResult.getActionId()==1 && parseResult.getPlayer().equals("Notch")){
|
||||
hasPlaced = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
- Get the last 60 seconds of block data for a specific block.
|
||||
```java
|
||||
CoreProtectAPI CoreProtect = getCoreProtect();
|
||||
if (CoreProtect != null){ // Ensure we have access to the API
|
||||
List<String[]> lookup = CoreProtect.blockLookup(block, 60);
|
||||
if (lookup != null){
|
||||
for (String[] result : lookup){
|
||||
ParseResult parseResult = CoreProtect.parseResult(result);
|
||||
int x = parseResult.getX();
|
||||
int y = parseResult.getY();
|
||||
int z = parseResult.getZ();
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
- Get the last 1 day of session data for the user "Notch".
|
||||
```java
|
||||
CoreProtectAPI CoreProtect = getCoreProtect();
|
||||
if (CoreProtect != null){ // Ensure we have access to the API
|
||||
List<String[]> lookup = CoreProtect.sessionLookup("Notch", (24 * 60 * 60));
|
||||
if (lookup != null){
|
||||
for (String[] result : lookup){
|
||||
ParseResult parseResult = CoreProtect.parseResult(result);
|
||||
int x = parseResult.getX();
|
||||
int y = parseResult.getY();
|
||||
int z = parseResult.getZ();
|
||||
int action = parseResult.getActionId(); // 0 = logout, 1 = login
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
- Log the placement of a block at a location by the user "Notch".
|
||||
```java
|
||||
CoreProtectAPI CoreProtect = getCoreProtect();
|
||||
if (CoreProtect != null){ // Ensure we have access to the API
|
||||
boolean success = CoreProtect.logPlacement("Notch", block.getLocation(), block.getType(), block.getData());
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
- Log adding/remove items in a chest (or some other block inventory).
|
||||
```java
|
||||
CoreProtectAPI CoreProtect = getCoreProtect();
|
||||
if (CoreProtect != null){ // Ensure we have access to the API
|
||||
boolean success = CoreProtect.logContainerTransaction("Notch", inventory.getLocation());
|
||||
// modify your container contents immediately after (e.g. [i]inventory.addItem(itemStack);[/i])
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
- Perform a multi-threaded placement check to see if the user "Notch" has already placed a block at a location within the last 60 seconds. This ignores the most recent 1 second of logged data, to account for the fact that that new block data may have already been logged, depending on your code.
|
||||
```java
|
||||
final Block block = null; //Should be an actual block
|
||||
class BasicThread implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
CoreProtectAPI CoreProtect = getCoreProtect();
|
||||
if (CoreProtect != null){ // Ensure we have access to the API
|
||||
boolean hasPlaced = CoreProtect.hasPlaced("Notch", block, 60, 1);
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Runnable runnable = new BasicThread();
|
||||
Thread thread = new Thread(runnable);
|
||||
thread.start();
|
||||
```
|
||||
|
||||
---
|
|
@ -203,7 +203,7 @@ This will parse results from a lookup. You'll then be able to view the following
|
|||
* **getZ():** Get the Z coordinate of the block.
|
||||
* **getType():** Get the Material of the block.
|
||||
* **getBlockData():** Get the BlockData of the block.
|
||||
* **getPlayer():** Get the username as a string..
|
||||
* **getPlayer():** Get the username as a string.
|
||||
* **getTimestamp():** Get the time of the action.
|
||||
* **getActionId():** Get the action ID. (0=removed, 1=placed, 2=interaction)
|
||||
* **getActionString():** Get the action as a string. (Removal, Placement, Interaction)
|
||||
|
@ -296,7 +296,7 @@ if (CoreProtect!=null){ //Ensure we have access to the API
|
|||
int x = parseResult.getX();
|
||||
int y = parseResult.getY();
|
||||
int z = parseResult.getZ();
|
||||
//...
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ if (CoreProtect!=null){ //Ensure we have access to the API
|
|||
int x = result.getX();
|
||||
int y = result.getY();
|
||||
int z = result.getZ();
|
||||
//...
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ if (CoreProtect!=null){ //Ensure we have access to the API
|
|||
int x = result.getX();
|
||||
int y = result.getY();
|
||||
int z = result.getZ();
|
||||
//...
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ public void run() {
|
|||
int x = result.getX();
|
||||
int y = result.getY();
|
||||
int z = result.getZ();
|
||||
//...
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ if (CoreProtect!=null){ //Ensure we have access to the API
|
|||
int x = parseResult.getX();
|
||||
int y = parseResult.getY();
|
||||
int z = parseResult.getZ();
|
||||
//...
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -203,7 +203,7 @@ This will parse results from a lookup. You'll then be able to view the following
|
|||
* **getZ():** Get the Z coordinate of the block.
|
||||
* **getType():** Get the Material of the block.
|
||||
* **getBlockData():** Get the BlockData of the block.
|
||||
* **getPlayer():** Get the username as a string..
|
||||
* **getPlayer():** Get the username as a string.
|
||||
* **getTimestamp():** Get the time of the action.
|
||||
* **getActionId():** Get the action ID. (0=removed, 1=placed, 2=interaction)
|
||||
* **getActionString():** Get the action as a string. (Removal, Placement, Interaction)
|
||||
|
@ -296,7 +296,7 @@ if (CoreProtect!=null){ //Ensure we have access to the API
|
|||
int x = parseResult.getX();
|
||||
int y = parseResult.getY();
|
||||
int z = parseResult.getZ();
|
||||
//...
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ if (CoreProtect!=null){ //Ensure we have access to the API
|
|||
int x = result.getX();
|
||||
int y = result.getY();
|
||||
int z = result.getZ();
|
||||
//...
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ if (CoreProtect!=null){ //Ensure we have access to the API
|
|||
int x = result.getX();
|
||||
int y = result.getY();
|
||||
int z = result.getZ();
|
||||
//...
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ public void run() {
|
|||
int x = result.getX();
|
||||
int y = result.getY();
|
||||
int z = result.getZ();
|
||||
//...
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ if (CoreProtect!=null){ //Ensure we have access to the API
|
|||
int x = parseResult.getX();
|
||||
int y = parseResult.getY();
|
||||
int z = parseResult.getZ();
|
||||
//...
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,11 +120,12 @@ void performPurge(int time)
|
|||
|
||||
#### CoreProtectPreLogEvent
|
||||
|
||||
Fired when a CoreProtect logger is about to log an action. Not cancellable.
|
||||
Fired when a CoreProtect logger is about to log an action. Cancellable.
|
||||
|
||||
| Property | Description | Mutable |
|
||||
| --- | --- | --- |
|
||||
| User | The name of the user under which this action will be logged. | Yes |
|
||||
| Cancelled | If cancelled, the action won't be logged to the database. | Yes |
|
||||
|
||||
---
|
||||
|
||||
|
@ -224,7 +225,7 @@ This will parse results from a lookup. You'll then be able to view the following
|
|||
* **getZ():** Get the Z coordinate of the block.
|
||||
* **getType():** Get the Material of the block.
|
||||
* **getBlockData():** Get the BlockData of the block.
|
||||
* **getPlayer():** Get the username as a string..
|
||||
* **getPlayer():** Get the username as a string.
|
||||
* **getTimestamp():** Get the time of the action.
|
||||
* **getActionId():** Get the action ID. (0=removed, 1=placed, 2=interaction)
|
||||
* **getActionString():** Get the action as a string. (Removal, Placement, Interaction)
|
||||
|
@ -317,7 +318,7 @@ if (CoreProtect != null){ // Ensure we have access to the API
|
|||
int x = parseResult.getX();
|
||||
int y = parseResult.getY();
|
||||
int z = parseResult.getZ();
|
||||
//...
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -337,7 +338,7 @@ if (CoreProtect != null){ // Ensure we have access to the API
|
|||
int x = result.getX();
|
||||
int y = result.getY();
|
||||
int z = result.getZ();
|
||||
//...
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -356,7 +357,7 @@ if (CoreProtect != null){ // Ensure we have access to the API
|
|||
int x = result.getX();
|
||||
int y = result.getY();
|
||||
int z = result.getZ();
|
||||
//...
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -379,7 +380,7 @@ public void run() {
|
|||
int x = result.getX();
|
||||
int y = result.getY();
|
||||
int z = result.getZ();
|
||||
//...
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -429,7 +430,7 @@ if (CoreProtect != null){ // Ensure we have access to the API
|
|||
int x = parseResult.getX();
|
||||
int y = parseResult.getY();
|
||||
int z = parseResult.getZ();
|
||||
//...
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -449,7 +450,7 @@ if (CoreProtect != null){ // Ensure we have access to the API
|
|||
int y = parseResult.getY();
|
||||
int z = parseResult.getZ();
|
||||
int action = parseResult.getActionId(); // 0 = logout, 1 = login
|
||||
//...
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ Purge old block data. Useful for freeing up space on your HDD if you don't need
|
|||
|
||||
| Command | Parameters |
|
||||
| --- | --- |
|
||||
| /co purge | `t:<time> r:<world>` |
|
||||
| /co purge | `t:<time> r:<world> i:<include>` |
|
||||
|
||||
For example, `/co purge t:30d` will delete all data older than one month, and only keep the last 30 days of data.
|
||||
|
||||
|
@ -101,8 +101,12 @@ For example, `/co purge t:30d` will delete all data older than one month, and on
|
|||
> If used from the console, only data older than 24 hours can be purged.
|
||||
|
||||
**Purging Worlds**
|
||||
You can also optionally specify a world in CoreProtect v19+.
|
||||
For example, `/co purge t:30d r:#world_nether` will delete all data older than one month in the Nether, without deleting data in any other worlds.
|
||||
You can optionally specify a world in CoreProtect v19+.
|
||||
For example, `/co purge t:30d r:#world_nether` will delete all data older than one month in the Nether, without removing data in any other worlds.
|
||||
|
||||
**Purging Blocks**
|
||||
You can optionally specify block types in CoreProtect v23+.
|
||||
For example, `/co purge t:30d i:stone,dirt` will delete all stone and dirt data older than one month, without removing other block data.
|
||||
|
||||
**MySQL Optimization**
|
||||
In CoreProtect v2.15+, adding "#optimize" to the end of the command (e.g. `/co purge t:30d #optimize`) will also optimize your tables and reclaim disk space.
|
||||
|
@ -133,6 +137,7 @@ ___
|
|||
|
||||
* Example: `u:Notch`
|
||||
* Example: `u:Notch,Intelli`
|
||||
* Example: `u:#fire,#tnt,#creeper,#explosion`
|
||||
|
||||
---
|
||||
|
||||
|
@ -276,4 +281,4 @@ Lookup commands are generally the same as rollback commands. The primary differe
|
|||
* `/co lookup u:Notch a:username`
|
||||
*(lookup previous usernames used by Notch)*
|
||||
|
||||
___
|
||||
___
|
||||
|
|
|
@ -18,15 +18,18 @@ Secondary configuration files override the value specified in config.yml. If you
|
|||
|
||||
## Disabling Logging
|
||||
|
||||
To disable logging for specific users or commands, simply do the following:
|
||||
To disable logging for specific users, blocks or commands, simply do the following:
|
||||
|
||||
1. In the CoreProtect plugin directory, create a file named `blacklist.txt`.
|
||||
2. Enter the names of the users (or commands) you'd like to disable logging for (each username on a new line).
|
||||
3. Either restart your server, or type "/co reload" in-game.
|
||||
|
||||
This can be used to disable logging for non-player users, such as "#tnt". For example, if you'd like to disable logging for the user "Notch", TNT explosions, and the "/help" command, the blacklist.txt file would look like this:
|
||||
This can be used to disable logging for non-player users, such as "#creeper". For example, if you'd like to disable logging for the user "Notch", TNT explosions, stone blocks, and the "/help" command, the blacklist.txt file would look like this:
|
||||
```text
|
||||
Notch
|
||||
#tnt
|
||||
/help
|
||||
```
|
||||
minecraft:stone
|
||||
```
|
||||
|
||||
*Please note that to disable logging for blocks, CoreProtect v23+ is required, and you must include the namespace. For example, to disable logging for dirt, you must add it as "minecraft:dirt".*
|
|
@ -22,7 +22,7 @@ Log your own block changes, perform lookups, rollbacks, restores, and more.
|
|||
A list of plugins and tools that are compatible with CoreProtect.
|
||||
|
||||
[**Per-World Configuration Files**](/config/#per-world-configuration)
|
||||
Log your own block changes, perform lookups, rollbacks, restores, and more.
|
||||
Modify the logging settings for a specific world on your server.
|
||||
|
||||
[**Disable Logging for Specific Users or Commands**](/config/#disabling-logging)
|
||||
Log your own block changes, perform lookups, rollbacks, restores, and more.
|
||||
[**Disable Logging With a Blacklist**](/config/#disabling-logging)
|
||||
Disable logging for specific users, blocks or commands.
|
||||
|
|
|
@ -24,7 +24,7 @@ DATABASE_LOCKED_4: "Desactivando el bloqueo en la base de datos resultaría en u
|
|||
DATABASE_UNREACHABLE: "No se pudo alcanzar la base de datos. Descartando datos y apagando."
|
||||
DEVELOPMENT_BRANCH: "Rama de desarrollo detectada, saltando scripts de parche."
|
||||
DIRT_BLOCK: "Se ha colocado un bloque de tierra debajo de tí."
|
||||
DISABLE_SUCCESS: "¡Se ha desactivado extosamente {0}!"
|
||||
DISABLE_SUCCESS: "¡Se ha desactivado exitosamente {0}!"
|
||||
ENABLE_FAILED: "Imposible de iniciar {0}."
|
||||
ENABLE_SUCCESS: "¡{0} ha sido exitosamente activado!"
|
||||
ENJOY_COREPROTECT: "¿Disfrutando {0}? ¡Ingrese a nuestro Discord!"
|
||||
|
@ -198,4 +198,4 @@ USING_SQLITE: "Usando SQLite para el guardado de información."
|
|||
VALID_DONATION_KEY: "Clave de donación válida."
|
||||
VERSION_NOTICE: "Versión {0} está disponible."
|
||||
VERSION_REQUIRED: "{0} {1} o súperior es requerida."
|
||||
WORLD_NOT_FOUND: "Mundo \"{0}\" inexistente."
|
||||
WORLD_NOT_FOUND: "Mundo \"{0}\" inexistente."
|
||||
|
|
186
lang/zh-tw.yml
186
lang/zh-tw.yml
|
@ -1,8 +1,8 @@
|
|||
# CoreProtect Language File (zh-TW)
|
||||
# Translators: whitebear13579, Flandre_tw
|
||||
# Translators: whitebear13579, flandretw, ianiiaannn
|
||||
|
||||
ACTION_NOT_SUPPORTED: "此指令不支援該操作。"
|
||||
AMOUNT_BLOCK: "{0} 個{方塊|方塊}"
|
||||
ACTION_NOT_SUPPORTED: "此指令不支援該行為。"
|
||||
AMOUNT_BLOCK: "{0} 格{方塊|方塊}"
|
||||
AMOUNT_CHUNK: "{0} 個{區塊|區塊}"
|
||||
AMOUNT_ENTITY: "{0} 個{實體|實體}"
|
||||
AMOUNT_ITEM: "{0} 個{物品|物品}"
|
||||
|
@ -10,52 +10,52 @@ API_TEST: "API 測試成功。"
|
|||
CACHE_ERROR: "警告: 驗證快取 {0} 時出現錯誤。"
|
||||
CACHE_RELOAD: "正在強制從資料庫中重新載入{鏡像|世界}快取。"
|
||||
CHECK_CONFIG: "請檢查 config.yml 檔案。"
|
||||
COMMAND_CONSOLE: "請從控制台運行命令。"
|
||||
COMMAND_NOT_FOUND: "未知的指令 \"{0}\"。"
|
||||
COMMAND_CONSOLE: "請從控制台執行此指令。"
|
||||
COMMAND_NOT_FOUND: "未知的指令「{0}」。"
|
||||
COMMAND_THROTTLED: "請稍後再試。"
|
||||
CONSUMER_ERROR: "消費者隊列處理已經 {暫停|繼續}."
|
||||
CONSUMER_TOGGLED: "消費者隊列處理已 {暫停|繼續}."
|
||||
CONTAINER_HEADER: "儲存容器變更記錄。"
|
||||
CONSUMER_ERROR: "消費者隊列處理已經{暫停|繼續}."
|
||||
CONSUMER_TOGGLED: "消費者隊列處理已{暫停|繼續}."
|
||||
CONTAINER_HEADER: "儲存容器變更紀錄。"
|
||||
DATABASE_BUSY: "資料庫繁忙,請稍後再試。"
|
||||
DATABASE_INDEX_ERROR: "無法驗證資料庫索引。"
|
||||
DATABASE_LOCKED_1: "資料庫已被鎖定,請等待 15 秒後再試……"
|
||||
DATABASE_LOCKED_1: "資料庫已被鎖定,請稍後 15 秒後再試……"
|
||||
DATABASE_LOCKED_2: "資料庫正在使用,請稍後再試一次。"
|
||||
DATABASE_LOCKED_3: "若要關閉資料庫鎖定功能,請設定 \"database-lock: false\"。"
|
||||
DATABASE_LOCKED_4: "關閉資料庫鎖定功能,可能導致資料損壞。"
|
||||
DATABASE_UNREACHABLE: "資料庫無法存取,正在拋棄資料並關閉。"
|
||||
DEVELOPMENT_BRANCH: "檢測到正在使用開發分支的版本,已跳過使用補丁腳本。"
|
||||
DATABASE_LOCKED_3: "若要停用資料庫鎖定功能,請設定「database-lock: false」。"
|
||||
DATABASE_LOCKED_4: "停用資料庫鎖定功能可能導致資料毀損。"
|
||||
DATABASE_UNREACHABLE: "資料庫無法存取,正在拋棄資料並停用。"
|
||||
DEVELOPMENT_BRANCH: "檢測到正在使用開發分支的版本,已跳過資料庫版本更新。"
|
||||
DIRT_BLOCK: "已在你的下方放置了泥土。"
|
||||
DISABLE_SUCCESS: "執行成功 ! 關閉 {0} !"
|
||||
DISABLE_SUCCESS: "執行成功!已停用 {0}!"
|
||||
ENABLE_FAILED: "無法啟用 {0}。"
|
||||
ENABLE_SUCCESS: "已經成功啟用 {0} !"
|
||||
ENJOY_COREPROTECT: "喜歡 {0} 嗎 ? 加入我們的 Discord !"
|
||||
ENABLE_SUCCESS: "已經成功啟用 {0}!"
|
||||
ENJOY_COREPROTECT: "喜歡 {0} 嗎?加入我們的 Discord!"
|
||||
FINISHING_CONVERSION: "正在完成資料轉換,請稍候……"
|
||||
FINISHING_LOGGING: "正在完成資料記錄,請稍候……"
|
||||
FIRST_VERSION: "初始化資料庫: {0}"
|
||||
FINISHING_LOGGING: "正在完成紀錄檔處理,請稍候……"
|
||||
FIRST_VERSION: "資料庫初始化版本: {0}"
|
||||
GLOBAL_LOOKUP: "請勿指定範圍來進行全面的搜尋。"
|
||||
GLOBAL_ROLLBACK: "使用 \"{0}\" 來進行全面的{回滾|恢復}。"
|
||||
HELP_ACTION_1: "將搜尋限制為某個行為。"
|
||||
GLOBAL_ROLLBACK: "使用「{0}」來進行全面的{回滾|恢復}。"
|
||||
HELP_ACTION_1: "僅過濾某個行為。"
|
||||
HELP_ACTION_2: "範例: [a:block], [a:+block], [a:-block] [a:click], [a:container], [a:inventory], [a:item], [a:kill], [a:chat], [a:command], [a:sign], [a:session], [a:username]"
|
||||
HELP_COMMAND: "顯示該指令的更多資訊。"
|
||||
HELP_EXCLUDE_1: "排除方塊/玩家"
|
||||
HELP_EXCLUDE_2: "範例: [e:stone], [e:Notch], [e:stone,Notch]"
|
||||
HELP_HEADER: "{0} 說明"
|
||||
HELP_INCLUDE_1: "包括指定的方塊/實體"
|
||||
HELP_INCLUDE_1: "僅過濾指定的方塊/實體"
|
||||
HELP_INCLUDE_2: "範例: [i:stone], [i:zombie], [i:stone,wood,bedrock]"
|
||||
HELP_INSPECT_1: "當檢查器啟用後,你可以執行以下操作:"
|
||||
HELP_INSPECT_2: "對你欲查詢的方塊點擊左鍵,可以查看方塊放置記錄。"
|
||||
HELP_INSPECT_3: "對你欲查詢的方塊點擊右鍵,可以查看相鄰方塊破壞記錄。"
|
||||
HELP_INSPECT_4: "對你欲查詢的位置放置方塊,可以查看放置位置破壞記錄。"
|
||||
HELP_INSPECT_5: "對你欲查詢的液體中放置方塊,可以查看液體變更記錄。"
|
||||
HELP_INSPECT_6: "對你欲查詢的門、儲物箱等方塊點擊右鍵,可以查看使用記錄。"
|
||||
HELP_INSPECT_7: "小提醒: 你可以使用 \"/co i\" 來加快搜尋的速度。"
|
||||
HELP_INSPECT_COMMAND: "開啟或關閉檢查器。"
|
||||
HELP_INSPECT_2: "對你欲查詢的方塊點擊左鍵,可以查看方塊放置紀錄。"
|
||||
HELP_INSPECT_3: "對你欲查詢的方塊點擊右鍵,可以查看相鄰方塊破壞紀錄。"
|
||||
HELP_INSPECT_4: "對你欲查詢的位置放置方塊,可以查看放置位置破壞紀錄。"
|
||||
HELP_INSPECT_5: "對你欲查詢的液體中放置方塊,可以查看液體變更紀錄。"
|
||||
HELP_INSPECT_6: "對你欲查詢的門、儲物箱等方塊點擊右鍵,可以查看使用紀錄。"
|
||||
HELP_INSPECT_7: "小提醒: 你可以使用「/co i」來快速啟用或停用檢查器。"
|
||||
HELP_INSPECT_COMMAND: "啟用或停用檢查器。"
|
||||
HELP_LIST: "顯示所有指令列表。"
|
||||
HELP_LOOKUP_1: "指令捷徑"
|
||||
HELP_LOOKUP_2: "在使用檢查器檢查後以便查看日誌。"
|
||||
HELP_LOOKUP_COMMAND: "進階查詢方塊的資料。"
|
||||
HELP_NO_INFO: "未找到 \"{0}\" 的相關指令資訊。"
|
||||
HELP_PARAMETER: "若需查看相關詳細參數資訊,請查閱 \"{0}\"。"
|
||||
HELP_LOOKUP_COMMAND: "進階查詢方塊資料。"
|
||||
HELP_NO_INFO: "未找到「{0}」的相關指令資訊。"
|
||||
HELP_PARAMETER: "若需查看相關詳細參數資訊,請查閱「{0}」。"
|
||||
HELP_PARAMS_1: "執行{查詢|回滾|恢復}。"
|
||||
HELP_PARAMS_2: "指定需要{查詢|回滾|恢復}的玩家。"
|
||||
HELP_PARAMS_3: "指定需要{查詢|回滾|恢復}的時間範圍。"
|
||||
|
@ -63,12 +63,12 @@ HELP_PARAMS_4: "指定限制{查詢|回滾|恢復}的範圍。"
|
|||
HELP_PARAMS_5: "將{查詢|回滾|恢復}限制在某個行為。"
|
||||
HELP_PARAMS_6: "在{查詢|回滾|恢復}中指定特定的實體/方塊。"
|
||||
HELP_PARAMS_7: "從{查詢|回滾|恢復}中排除特定的方塊/玩家。"
|
||||
HELP_PURGE_1: "刪除了指定時間範圍的資料。"
|
||||
HELP_PURGE_2: "舉例來說,\"{0}\" 將會刪除超過一個月的所有方塊資料,只保留最近 30 天的資料。"
|
||||
HELP_PURGE_COMMAND: "刪除舊的方塊資料。"
|
||||
HELP_PURGE_1: "清除指定時間範圍內的資料。"
|
||||
HELP_PURGE_2: "舉例來說,「{0}」將會清除超過一個月的所有資料,只保留最近 30 天的資料。"
|
||||
HELP_PURGE_COMMAND: "清除舊資料。"
|
||||
HELP_RADIUS_1: "指定半徑範圍。"
|
||||
HELP_RADIUS_2: "範例: [r:10] (僅會更改你周圍的 10 格方塊)"
|
||||
HELP_RELOAD_COMMAND: "重新載入配置檔案。"
|
||||
HELP_RADIUS_2: "範例: [r:10](僅會更改你周圍的 10 格方塊)"
|
||||
HELP_RELOAD_COMMAND: "重新載入設定檔。"
|
||||
HELP_RESTORE_COMMAND: "恢復方塊資料。"
|
||||
HELP_ROLLBACK_COMMAND: "回滾方塊資料。"
|
||||
HELP_STATUS: "查看插件狀態與版本資訊。"
|
||||
|
@ -78,106 +78,106 @@ HELP_TIME_1: "指定搜尋的時間範圍。"
|
|||
HELP_TIME_2: "範例: [t:2w,5d,7h,2m,10s], [t:5d2h], [t:2.50h]"
|
||||
HELP_USER_1: "指定要搜尋的玩家。"
|
||||
HELP_USER_2: "範例: [u:Notch], [u:Notch,#enderman]"
|
||||
INCOMPATIBLE_ACTION: "\"{0}\" 不能用於此操作。"
|
||||
INSPECTOR_ERROR: "已{開啟|關閉}檢查器了。"
|
||||
INSPECTOR_TOGGLED: "已{開啟|關閉}檢查器。"
|
||||
INTEGRATION_ERROR: "無法{初始化|關閉} {0} 日誌記錄。"
|
||||
INTEGRATION_SUCCESS: "{0} 成功記錄{初始化|關閉}。"
|
||||
INTEGRATION_VERSION: "發現 {0} 版本無效。"
|
||||
INCOMPATIBLE_ACTION: "「{0}」不能用於此行為。"
|
||||
INSPECTOR_ERROR: "檢查器已經{啟用|停用}了。"
|
||||
INSPECTOR_TOGGLED: "已{啟用|停用}檢查器。"
|
||||
INTEGRATION_ERROR: "無法{初始化|停用}{0}紀錄檔。"
|
||||
INTEGRATION_SUCCESS: "{0} 紀錄檔已成功{初始化|停用}。"
|
||||
INTEGRATION_VERSION: "{0} 的版本無效。"
|
||||
INTERACTIONS_HEADER: "玩家互動"
|
||||
INVALID_ACTION: "這不是有效的行為。"
|
||||
INVALID_BRANCH_1: "插件版本無效 (未設定分支)。"
|
||||
INVALID_BRANCH_2: "若要繼續行為,請將你的項目分之設定為 \"development\"。"
|
||||
INVALID_BRANCH_3: "執行開發中的插件可能會導致資料損毀。"
|
||||
INVALID_CONTAINER: "請先檢查有效的容器。"
|
||||
INVALID_DONATION_KEY: "無效的捐贈金鑰。"
|
||||
INVALID_INCLUDE: "\"{0}\" 是無效的方塊/實體名稱。"
|
||||
INVALID_INCLUDE_COMBO: "這是無效的方塊/實體組合。"
|
||||
INVALID_RADIUS: "請輸入有效的範圍。"
|
||||
INVALID_SELECTION: "未找到選擇 {0} 的內容。"
|
||||
INVALID_USERNAME: "\"{0}\" 是無效的玩家名稱。"
|
||||
INVALID_WORLD: "請指定有效的世界。"
|
||||
INVALID_ACTION: "此並非有效的行為。"
|
||||
INVALID_BRANCH_1: "插件版本無效(未設定分支)。"
|
||||
INVALID_BRANCH_2: "若要繼續,請將分支設定為「development」。"
|
||||
INVALID_BRANCH_3: "執行開發中的插件版本可能會導致資料損毀。"
|
||||
INVALID_CONTAINER: "此並非有效的容器。"
|
||||
INVALID_DONATION_KEY: "無效的贊助金鑰。"
|
||||
INVALID_INCLUDE: "「{0}」為無效的方塊/實體名稱。"
|
||||
INVALID_INCLUDE_COMBO: "此為無效的方塊/實體組合。"
|
||||
INVALID_RADIUS: "此並非有效的範圍。"
|
||||
INVALID_SELECTION: "「{0}」為無效的選擇範圍。"
|
||||
INVALID_USERNAME: "「{0}」為無效的使用者名稱。"
|
||||
INVALID_WORLD: "此並非有效的世界。"
|
||||
LATEST_VERSION: "最新版本: {0}"
|
||||
LINK_DISCORD: "Discord: {0}"
|
||||
LINK_DOWNLOAD: "下載: {0}"
|
||||
LINK_PATREON: "Patreon: {0}"
|
||||
LINK_WIKI_BLOCK: "方塊名稱: {0}"
|
||||
LINK_WIKI_ENTITY: "實體名稱: {0}"
|
||||
LOGGING_ITEMS: "還剩 {0} 項要進行記錄,請稍候……"
|
||||
LOGGING_TIME_LIMIT: "已達到記錄的時間上限,正在刪除資料並關閉……"
|
||||
LOGGING_ITEMS: "還剩 {0} 項要進行紀錄,請稍候……"
|
||||
LOGGING_TIME_LIMIT: "已達到紀錄的時間上限,正在捨棄資料並停用……"
|
||||
LOOKUP_BLOCK: "{0} {放置|破壞} {1}。"
|
||||
LOOKUP_CONTAINER: "{0} {新增|刪除} {1} {2}。"
|
||||
LOOKUP_HEADER: "{0} 搜尋結果。"
|
||||
LOOKUP_CONTAINER: "{0} {存入|取出} {1} {2}。"
|
||||
LOOKUP_HEADER: "{0} 條搜尋結果。"
|
||||
LOOKUP_INTERACTION: "{0} {點擊|殺死} {1}。"
|
||||
LOOKUP_ITEM: "{0} {撿起|拋棄} {1} {2}。"
|
||||
LOOKUP_LOGIN: "{0} 已登{入|出}。"
|
||||
LOOKUP_PAGE: "第 {0} 頁"
|
||||
LOOKUP_PROJECTILE: "{0} {扔|射} {1} {2}."
|
||||
LOOKUP_ROWS_FOUND: "已找到 {0} {行|行}。"
|
||||
LOOKUP_ROWS_FOUND: "已找到 {0} {條|條}。"
|
||||
LOOKUP_SEARCHING: "正在搜尋,請稍候……"
|
||||
LOOKUP_STORAGE: "{0} {存|取} {1} {2}。"
|
||||
LOOKUP_STORAGE: "{0} {存入|取出} {1} {2}。"
|
||||
LOOKUP_TIME: "{0} 前"
|
||||
LOOKUP_USERNAME: "{0} 以 {1} 的身分登入。"
|
||||
MAXIMUM_RADIUS: "最大 {查詢|回滾|恢復} 的範圍為 {0}。"
|
||||
MISSING_ACTION_USER: "若要使用此操作,請指定玩家。"
|
||||
LOOKUP_USERNAME: "{0} 已改變使用者名稱為 {1}。"
|
||||
MAXIMUM_RADIUS: "最大{查詢|回滾|恢復}的範圍為 {0}。"
|
||||
MISSING_ACTION_USER: "若要使用此行為,請指定玩家。"
|
||||
MISSING_LOOKUP_TIME: "請指定{查詢|回滾|恢復}的時間範圍。"
|
||||
MISSING_LOOKUP_USER: "請指定搜尋的玩家或是{方塊|範圍}。"
|
||||
MISSING_PARAMETERS: "請使用 \"{0}\"。"
|
||||
MISSING_PARAMETERS: "請使用「{0}」。"
|
||||
MISSING_ROLLBACK_RADIUS: "你沒有指定{回滾|恢復}的範圍。"
|
||||
MISSING_ROLLBACK_USER: "你沒有指定{回滾|恢復}的玩家。"
|
||||
MYSQL_UNAVAILABLE: "無法連線到 MySQL 伺服器。"
|
||||
NO_DATA: "找不到 {0} §f的資料。"
|
||||
NO_DATA_LOCATION: "找不到這個位置的{資料|交易|互動|訊息}。"
|
||||
NO_DATA: "未找到 {0} §f的資料。"
|
||||
NO_DATA_LOCATION: "未找到此位置的{資料|交易|互動|訊息}。"
|
||||
NO_PERMISSION: "你沒有使用該操作的權限。"
|
||||
NO_RESULTS: "未找到相關結果。"
|
||||
NO_RESULTS_PAGE: "未找到該頁面相關的{結果|資料}。"
|
||||
NO_ROLLBACK: "未找到{待處理|上一個}回滾/恢復。"
|
||||
PATCH_INTERRUPTED: "更新已中斷 ! 將會在下次重新啟動時再次嘗試。"
|
||||
PATCH_INTERRUPTED: "更新已中斷!將會在下次啟動時再次嘗試。"
|
||||
PATCH_OUTDATED_1: "無法更新早於 {0} 的資料庫。"
|
||||
PATCH_OUTDATED_2: "請使用受到支援的 CoreProtect 版本。"
|
||||
PATCH_PROCESSING: "正在處理新資訊,請稍候……"
|
||||
PATCH_SKIP_UPDATE: "已在 {0} 上跳過{列表|索引}的{更新|建立|刪除}。"
|
||||
PATCH_SKIP_UPDATE: "已在 {0} 上跳過{資料表|索引}的{更新|建立|清除}。"
|
||||
PATCH_STARTED: "正在執行 {0} 更新,請稍候……"
|
||||
PATCH_SUCCESS: "已成功升級到 {0}。"
|
||||
PATCH_UPGRADING: "正在進行資料庫升級,請稍候……"
|
||||
PLEASE_SELECT: "請選擇: \"{0}\" 或是 \"{1}\"。"
|
||||
PATCH_SUCCESS: "資料庫已成功更新到 {0}。"
|
||||
PATCH_UPGRADING: "正在進行資料庫更新,請稍候……"
|
||||
PLEASE_SELECT: "請選擇:「{0}」或是「{1}」。"
|
||||
PREVIEW_CANCELLED: "預覽已取消。"
|
||||
PREVIEW_CANCELLING: "正在取消預覽……"
|
||||
PREVIEW_IN_GAME: "你只能在遊戲中預覽回滾。"
|
||||
PREVIEW_TRANSACTION: "您無法預覽 {集裝箱|庫存} 交易。"
|
||||
PREVIEW_TRANSACTION: "您無法預覽{集裝箱|庫存}交易。"
|
||||
PURGE_ABORTED: "清除失敗,你的資料可能已損毀。"
|
||||
PURGE_ERROR: "無法處理 {0} 條資料 !"
|
||||
PURGE_ERROR: "無法處理 {0} 筆資料!"
|
||||
PURGE_FAILED: "清除失敗,請稍後再試。"
|
||||
PURGE_IN_PROGRESS: "正在執行清除作業,請稍後再試。"
|
||||
PURGE_MINIMUM_TIME: "你只能清除早於 {0} {天|小時}的資料。"
|
||||
PURGE_NOTICE_1: "請注意,此操作可能需要一些時間。"
|
||||
PURGE_NOTICE_2: "在完成此程序前請不要重新啟動伺服器。"
|
||||
PURGE_OPTIMIZING: "正在最佳化資料庫,請稍候……"
|
||||
PURGE_PROCESSING: "正在處理 {0} 資料……"
|
||||
PURGE_REPAIRING: "正在嘗試修復此問題,這可能需要一些時間。"
|
||||
PURGE_ROWS: "已刪除 {0} {行|行}資料。"
|
||||
PURGE_STARTED: "資料刪除開始於 \"{0}\"。"
|
||||
PURGE_PROCESSING: "正在清除 {0} 筆資料……"
|
||||
PURGE_REPAIRING: "正在嘗試修復問題,這可能需要一些時間。"
|
||||
PURGE_ROWS: "已清除 {0} {筆|筆}資料。"
|
||||
PURGE_STARTED: "資料清除開始於「{0}」。"
|
||||
PURGE_SUCCESS: "成功清除資料。"
|
||||
RELOAD_STARTED: "正在重新載入配置檔案 - 請稍候……"
|
||||
RELOAD_SUCCESS: "成功重新載入配置檔案。"
|
||||
ROLLBACK_ABORTED: "已中止回滾/恢復。"
|
||||
RELOAD_STARTED: "正在重新載入設定檔——請稍候……"
|
||||
RELOAD_SUCCESS: "成功重新載入設定檔。"
|
||||
ROLLBACK_ABORTED: "已中斷回滾/恢復。"
|
||||
ROLLBACK_CHUNKS_FOUND: "找到 {0} 個{區塊|區塊}需要修改。"
|
||||
ROLLBACK_CHUNKS_MODIFIED: "已修改 {0}/{1}個{區塊|區塊}。"
|
||||
ROLLBACK_COMPLETED: "已完成 \"{0}\" 的{回滾|恢復|預覽}。"
|
||||
ROLLBACK_EXCLUDED_USERS: "已排除{玩家|玩家}: \"{0}\"。"
|
||||
ROLLBACK_INCLUDE: "{包括|不包括}{方塊|實體|目標}{類型|類型}: \"{0}\"。"
|
||||
ROLLBACK_COMPLETED: "已完成「{0}」的{回滾|恢復|預覽}。"
|
||||
ROLLBACK_EXCLUDED_USERS: "已排除{玩家|玩家}「{0}」。"
|
||||
ROLLBACK_INCLUDE: "{包括|不包括}{方塊|實體|目標}{類型|類型}「{0}」。"
|
||||
ROLLBACK_IN_PROGRESS: "已在進行回滾/恢復。"
|
||||
ROLLBACK_LENGTH: "花費時間: {0} {秒|秒}。"
|
||||
ROLLBACK_MODIFIED: "{已修改|正在修改} {0}。"
|
||||
ROLLBACK_RADIUS: "範圍: {0} {方塊|方塊}。"
|
||||
ROLLBACK_SELECTION: "範圍設定為 \"{0}\"。"
|
||||
ROLLBACK_STARTED: "{回滾|恢復|預覽}開始於 \"{0}\"。"
|
||||
ROLLBACK_RADIUS: "範圍: {0} 格{方塊|方塊}。"
|
||||
ROLLBACK_SELECTION: "選擇範圍為「{0}」。"
|
||||
ROLLBACK_STARTED: "{回滾|恢復|預覽}開始於「{0}」。"
|
||||
ROLLBACK_TIME: "時間範圍: {0}。"
|
||||
ROLLBACK_WORLD_ACTION: "限制{世界|互動} \"{0}\"。"
|
||||
ROLLBACK_WORLD_ACTION: "限制{世界|行為}「{0}」。"
|
||||
SIGN_HEADER: "簽名訊息"
|
||||
STATUS_CONSUMER: "玩家: {0} 個{物品|物品}已在隊列中。"
|
||||
STATUS_CONSUMER: "消費者隊列: {0} 筆{資料|資料}在隊列中。"
|
||||
STATUS_DATABASE: "資料庫: 使用 {0}。"
|
||||
STATUS_INTEGRATION: "{0}: 整合{開啟|關閉}。"
|
||||
STATUS_INTEGRATION: "{0}: 整合{啟用|停用}。"
|
||||
STATUS_LICENSE: "憑證: {0}"
|
||||
STATUS_VERSION: "版本: {0}"
|
||||
TELEPORTED: "傳送到 {0}。"
|
||||
|
@ -192,11 +192,11 @@ UPDATE_ERROR: "檢查更新時發生錯誤。"
|
|||
UPDATE_HEADER: "{0} 更新"
|
||||
UPDATE_NOTICE: "通知: {0} 現已推出。"
|
||||
UPGRADE_IN_PROGRESS: "正在進行更新,請稍後再試。"
|
||||
USER_NOT_FOUND: "找不到玩家 \"{0}\"。"
|
||||
USER_OFFLINE: "用戶 \"{0}\"不在線。"
|
||||
USER_NOT_FOUND: "未找到玩家「{0}」。"
|
||||
USER_OFFLINE: "用戶「{0}」不在線上。"
|
||||
USING_MYSQL: "使用 MySQL 進行資料儲存。"
|
||||
USING_SQLITE: "使用 SQLite 進行資料儲存。"
|
||||
VALID_DONATION_KEY: "有效的贈品金鑰"
|
||||
VALID_DONATION_KEY: "有效的贊助金鑰"
|
||||
VERSION_NOTICE: "版本 {0} 現已推出。"
|
||||
VERSION_REQUIRED: "{0} 需要使用 {1} 或更高版本。"
|
||||
WORLD_NOT_FOUND: "世界: \"{0}\" 不存在。"
|
||||
WORLD_NOT_FOUND: "世界「{0}」不存在。"
|
46
pom.xml
46
pom.xml
|
@ -2,7 +2,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.coreprotect</groupId>
|
||||
<artifactId>CoreProtect</artifactId>
|
||||
<version>21.3</version>
|
||||
<version>22.4</version>
|
||||
<properties>
|
||||
<project.branch></project.branch>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -51,6 +51,14 @@
|
|||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<artifactSet>
|
||||
<excludes>
|
||||
<exclude>com.google.code.gson:*</exclude>
|
||||
<exclude>org.intellij:*</exclude>
|
||||
<exclude>org.jetbrains:*</exclude>
|
||||
<exclude>org.slf4j:*</exclude>
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
|
@ -74,19 +82,27 @@
|
|||
</repository>
|
||||
<repository>
|
||||
<id>paper-repo</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>codemc-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>enginehub-repo</id>
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.intellectualsites.bom</groupId>
|
||||
<artifactId>bom-newest</artifactId> <!-- Ref: https://github.com/IntellectualSites/bom -->
|
||||
<version>1.44</version>
|
||||
<scope>import</scope>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<!--
|
||||
paper-api: io.papermc.paper
|
||||
paper-api (<= 1.16): com.destroystokyo.paper
|
||||
spigot-api: org.spigotmc
|
||||
bukkit: org.bukkit
|
||||
|
@ -94,7 +110,7 @@
|
|||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.19-R0.1-SNAPSHOT</version>
|
||||
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -104,21 +120,25 @@
|
|||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-bukkit</artifactId>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
<groupId>com.fastasyncworldedit</groupId>
|
||||
<artifactId>FastAsyncWorldEdit-Core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fastasyncworldedit</groupId>
|
||||
<artifactId>FastAsyncWorldEdit-Bukkit</artifactId>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<artifactId>FastAsyncWorldEdit-Core</artifactId>
|
||||
<groupId>*</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>4.0.3</version>
|
||||
<version>5.0.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,9 +1,13 @@
|
|||
package net.coreprotect;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bstats.bukkit.MetricsLite;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
@ -21,8 +25,10 @@ import net.coreprotect.listener.player.PlayerQuitListener;
|
|||
import net.coreprotect.paper.PaperAdapter;
|
||||
import net.coreprotect.thread.CacheHandler;
|
||||
import net.coreprotect.thread.NetworkHandler;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Teleport;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public final class CoreProtect extends JavaPlugin {
|
||||
|
@ -94,7 +100,7 @@ public final class CoreProtect extends JavaPlugin {
|
|||
Chat.console(Phrase.build(Phrase.LINK_DISCORD, "www.coreprotect.net/discord/"));
|
||||
Chat.console("--------------------");
|
||||
|
||||
getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
|
||||
Scheduler.scheduleSyncDelayedTask(this, () -> {
|
||||
try {
|
||||
Thread networkHandler = new Thread(new NetworkHandler(true, true));
|
||||
networkHandler.start();
|
||||
|
@ -167,6 +173,15 @@ public final class CoreProtect extends JavaPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
if (!ConfigHandler.isFolia) {
|
||||
Iterator<Entry<Location, BlockData>> iterator = Teleport.revertBlocks.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Entry<Location, BlockData> entry = iterator.next();
|
||||
entry.getKey().getBlock().setBlockData(entry.getValue());
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
ConfigHandler.serverRunning = false;
|
||||
long shutdownTime = System.currentTimeMillis();
|
||||
long alertTime = shutdownTime + (10 * 1000);
|
||||
|
|
|
@ -25,7 +25,7 @@ import net.coreprotect.config.Config;
|
|||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.database.Database;
|
||||
import net.coreprotect.database.Lookup;
|
||||
import net.coreprotect.database.Rollback;
|
||||
import net.coreprotect.database.rollback.Rollback;
|
||||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.listener.player.InventoryChangeListener;
|
||||
import net.coreprotect.utility.Chat;
|
||||
|
@ -168,7 +168,7 @@ public class CoreProtectAPI extends Queue {
|
|||
}
|
||||
|
||||
public int APIVersion() {
|
||||
return 9;
|
||||
return 10;
|
||||
}
|
||||
|
||||
public List<String[]> blockLookup(Block block, int time) {
|
||||
|
@ -191,8 +191,8 @@ public class CoreProtectAPI extends Queue {
|
|||
boolean match = false;
|
||||
|
||||
if (Config.getGlobal().API_ENABLED) {
|
||||
long timestamp = System.currentTimeMillis() / 1000L;
|
||||
long offsetTime = timestamp - offset;
|
||||
long timestamp = System.currentTimeMillis();
|
||||
long offsetTime = timestamp - offset * 1000L;
|
||||
List<String[]> check = blockLookup(block, time);
|
||||
|
||||
for (String[] value : check) {
|
||||
|
@ -212,8 +212,8 @@ public class CoreProtectAPI extends Queue {
|
|||
boolean match = false;
|
||||
|
||||
if (Config.getGlobal().API_ENABLED) {
|
||||
long timestamp = System.currentTimeMillis() / 1000L;
|
||||
long offsetTime = timestamp - offset;
|
||||
long timestamp = System.currentTimeMillis();
|
||||
long offsetTime = timestamp - offset * 1000L;
|
||||
List<String[]> check = blockLookup(block, time);
|
||||
|
||||
for (String[] value : check) {
|
||||
|
@ -282,6 +282,19 @@ public class CoreProtectAPI extends Queue {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean logPlacement(String user, BlockState blockState) {
|
||||
if (!Config.getGlobal().API_ENABLED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (blockState == null || user == null || user.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Queue.queueBlockPlace(user, blockState, blockState.getType(), null, blockState.getType(), -1, 0, blockState.getBlockData().getAsString());
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean logPlacement(String user, Location location, Material type, BlockData blockData) {
|
||||
if (Config.getGlobal().API_ENABLED) {
|
||||
if (user != null && location != null) {
|
||||
|
@ -316,6 +329,19 @@ public class CoreProtectAPI extends Queue {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean logRemoval(String user, BlockState blockState) {
|
||||
if (!Config.getGlobal().API_ENABLED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (blockState == null || user == null || user.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Queue.queueBlockBreak(user, blockState, blockState.getType(), blockState.getBlockData().getAsString(), 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean logRemoval(String user, Location location, Material type, BlockData blockData) {
|
||||
if (Config.getGlobal().API_ENABLED) {
|
||||
if (user != null && location != null) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.coreprotect.api;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
@ -49,7 +50,9 @@ public class QueueLookup extends Queue {
|
|||
Map<Integer, Object> consumerObject = Consumer.consumerObjects.get(currentConsumer);
|
||||
|
||||
Location oldLocation = block.getLocation();
|
||||
for (Object[] data : consumerData) {
|
||||
ListIterator<Object[]> iterator = consumerData.listIterator();
|
||||
while (iterator.hasNext()) {
|
||||
Object[] data = iterator.next();
|
||||
int id = (int) data[0];
|
||||
int action = (int) data[1];
|
||||
if (action != Process.BLOCK_BREAK && action != Process.BLOCK_PLACE) {
|
||||
|
|
|
@ -3,20 +3,30 @@ package net.coreprotect.bukkit;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Directional;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.MerchantRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionData;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
@ -31,15 +41,14 @@ public class BukkitAdapter implements BukkitInterface {
|
|||
public static final int BUKKIT_V1_17 = 17;
|
||||
public static final int BUKKIT_V1_18 = 18;
|
||||
public static final int BUKKIT_V1_19 = 19;
|
||||
public static final int BUKKIT_V1_20 = 20;
|
||||
|
||||
public static void loadAdapter() {
|
||||
switch (ConfigHandler.SERVER_VERSION) {
|
||||
case BUKKIT_V1_13:
|
||||
case BUKKIT_V1_14:
|
||||
BukkitAdapter.ADAPTER = new BukkitAdapter();
|
||||
break;
|
||||
case BUKKIT_V1_15:
|
||||
BukkitAdapter.ADAPTER = new Bukkit_v1_15();
|
||||
BukkitAdapter.ADAPTER = new BukkitAdapter();
|
||||
break;
|
||||
case BUKKIT_V1_16:
|
||||
BukkitAdapter.ADAPTER = new Bukkit_v1_16();
|
||||
|
@ -51,8 +60,12 @@ public class BukkitAdapter implements BukkitInterface {
|
|||
BukkitAdapter.ADAPTER = new Bukkit_v1_18();
|
||||
break;
|
||||
case BUKKIT_V1_19:
|
||||
default:
|
||||
BukkitAdapter.ADAPTER = new Bukkit_v1_19();
|
||||
break;
|
||||
case BUKKIT_V1_20:
|
||||
default:
|
||||
BukkitAdapter.ADAPTER = new Bukkit_v1_20();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,11 +113,6 @@ public class BukkitAdapter implements BukkitInterface {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSignChange(Player player, Sign sign) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinHeight(World world) {
|
||||
return 0;
|
||||
|
@ -136,13 +144,13 @@ public class BukkitAdapter implements BukkitInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlowing(Sign sign) {
|
||||
public boolean isGlowing(Sign sign, boolean isFront) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGlowing(Sign sign, boolean set) {
|
||||
return;
|
||||
public boolean isWaxed(Sign sign) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -155,4 +163,125 @@ public class BukkitAdapter implements BukkitInterface {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGlowing(Sign sign, boolean isFront, boolean isGlowing) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(Sign sign, boolean isFront, int color) {
|
||||
if (!isFront) {
|
||||
return;
|
||||
}
|
||||
|
||||
sign.setColor(DyeColor.getByColor(Color.fromRGB(color)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWaxed(Sign sign, boolean isWaxed) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor(Sign sign, boolean isFront) {
|
||||
if (isFront) {
|
||||
return sign.getColor().getColor().asRGB();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getPlantSeeds(Material material) {
|
||||
switch (material) {
|
||||
case WHEAT:
|
||||
material = Material.WHEAT_SEEDS;
|
||||
break;
|
||||
case PUMPKIN_STEM:
|
||||
material = Material.PUMPKIN_SEEDS;
|
||||
break;
|
||||
case MELON_STEM:
|
||||
material = Material.MELON_SEEDS;
|
||||
break;
|
||||
case BEETROOTS:
|
||||
material = Material.BEETROOT_SEEDS;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
return material;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDecoratedPot(Material material) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuspiciousBlock(Material material) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSign(Material material) {
|
||||
return Tag.SIGNS.isTagged(material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChiseledBookshelf(Material material) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBookshelfBook(Material material) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getChiseledBookshelfBook(BlockState blockState, PlayerInteractEvent event) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLine(Sign sign, int line) {
|
||||
if (line < 4) {
|
||||
return sign.getLine(line);
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLine(Sign sign, int line, String string) {
|
||||
if (string == null) {
|
||||
string = "";
|
||||
}
|
||||
|
||||
if (line < 4) {
|
||||
sign.setLine(line, string);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSignFront(SignChangeEvent event) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getArrowMeta(Arrow arrow, ItemStack itemStack) {
|
||||
PotionData data = arrow.getBasePotionData();
|
||||
if (data.getType() != PotionType.UNCRAFTABLE) {
|
||||
itemStack = new ItemStack(Material.TIPPED_ARROW);
|
||||
PotionMeta meta = (PotionMeta) itemStack.getItemMeta();
|
||||
meta.setBasePotionData(data);
|
||||
for (PotionEffect effect : arrow.getCustomEffects()) {
|
||||
meta.addCustomEffect(effect, false);
|
||||
}
|
||||
itemStack.setItemMeta(meta);
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,12 +6,15 @@ import java.util.Map;
|
|||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.MerchantRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
@ -44,16 +47,44 @@ public interface BukkitInterface {
|
|||
|
||||
public boolean isItemFrame(Material material);
|
||||
|
||||
public boolean isGlowing(Sign sign);
|
||||
public boolean isGlowing(Sign sign, boolean isFront);
|
||||
|
||||
public boolean isInvisible(Material material);
|
||||
|
||||
public boolean isWaxed(Sign sign);
|
||||
|
||||
public int getMinHeight(World world);
|
||||
|
||||
public int getLegacyBlockId(Material material);
|
||||
|
||||
public void sendSignChange(Player player, Sign sign);
|
||||
public void setGlowing(Sign sign, boolean isFront, boolean isGlowing);
|
||||
|
||||
public void setGlowing(Sign sign, boolean b);
|
||||
public void setColor(Sign sign, boolean isFront, int color);
|
||||
|
||||
public void setWaxed(Sign sign, boolean isWaxed);
|
||||
|
||||
public int getColor(Sign sign, boolean isFront);
|
||||
|
||||
public Material getPlantSeeds(Material material);
|
||||
|
||||
public boolean isDecoratedPot(Material material);
|
||||
|
||||
public boolean isSuspiciousBlock(Material material);
|
||||
|
||||
public boolean isSign(Material material);
|
||||
|
||||
public boolean isChiseledBookshelf(Material material);
|
||||
|
||||
public boolean isBookshelfBook(Material material);
|
||||
|
||||
public ItemStack getChiseledBookshelfBook(BlockState blockState, PlayerInteractEvent event);
|
||||
|
||||
public String getLine(Sign sign, int line);
|
||||
|
||||
public void setLine(Sign sign, int line, String string);
|
||||
|
||||
public boolean isSignFront(SignChangeEvent event);
|
||||
|
||||
public ItemStack getArrowMeta(Arrow arrow, ItemStack itemStack);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,105 +0,0 @@
|
|||
package net.coreprotect.bukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Bee;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SuspiciousStewMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
public class Bukkit_v1_15 extends BukkitAdapter implements BukkitInterface {
|
||||
|
||||
@Override
|
||||
public boolean getEntityMeta(LivingEntity entity, List<Object> info) {
|
||||
if (entity instanceof Bee) {
|
||||
Bee bee = (Bee) entity;
|
||||
info.add(bee.getAnger());
|
||||
info.add(bee.hasNectar());
|
||||
info.add(bee.hasStung());
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setEntityMeta(Entity entity, Object value, int count) {
|
||||
if (entity instanceof Bee) {
|
||||
Bee bee = (Bee) entity;
|
||||
if (count == 0) {
|
||||
int set = (int) value;
|
||||
bee.setAnger(set);
|
||||
}
|
||||
else if (count == 1) {
|
||||
boolean set = (Boolean) value;
|
||||
bee.setHasNectar(set);
|
||||
}
|
||||
else if (count == 2) {
|
||||
boolean set = (Boolean) value;
|
||||
bee.setHasStung(set);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getItemMeta(ItemMeta itemMeta, List<Map<String, Object>> list, List<List<Map<String, Object>>> metadata, int slot) {
|
||||
if (itemMeta instanceof SuspiciousStewMeta) {
|
||||
SuspiciousStewMeta meta = (SuspiciousStewMeta) itemMeta;
|
||||
SuspiciousStewMeta subMeta = meta.clone();
|
||||
meta.clearCustomEffects();
|
||||
list.add(meta.serialize());
|
||||
metadata.add(list);
|
||||
|
||||
if (subMeta.hasCustomEffects()) {
|
||||
for (PotionEffect effect : subMeta.getCustomEffects()) {
|
||||
list = new ArrayList<>();
|
||||
list.add(effect.serialize());
|
||||
metadata.add(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setItemMeta(Material rowType, ItemStack itemstack, List<Map<String, Object>> map) {
|
||||
if ((rowType == Material.SUSPICIOUS_STEW)) {
|
||||
for (Map<String, Object> suspiciousStewData : map) {
|
||||
SuspiciousStewMeta meta = (SuspiciousStewMeta) itemstack.getItemMeta();
|
||||
PotionEffect effect = new PotionEffect(suspiciousStewData);
|
||||
meta.addCustomEffect(effect, true);
|
||||
itemstack.setItemMeta(meta);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSignChange(Player player, Sign sign) {
|
||||
player.sendSignChange(sign.getLocation(), sign.getLines(), sign.getColor());
|
||||
}
|
||||
|
||||
}
|
|
@ -17,10 +17,10 @@ import org.bukkit.entity.Zoglin;
|
|||
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
|
||||
public class Bukkit_v1_16 extends Bukkit_v1_15 implements BukkitInterface {
|
||||
public class Bukkit_v1_16 extends BukkitAdapter implements BukkitInterface {
|
||||
|
||||
public Bukkit_v1_16() {
|
||||
BlockGroup.TRACK_TOP = new HashSet<>(Arrays.asList(Material.TORCH, Material.REDSTONE_TORCH, Material.BAMBOO, Material.BAMBOO_SAPLING, Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SWEET_BERRY_BUSH, Material.SCAFFOLDING, Material.OAK_SAPLING, Material.SPRUCE_SAPLING, Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.GRASS, Material.FERN, Material.DEAD_BUSH, Material.DANDELION, Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.REDSTONE_WIRE, Material.WHEAT, Material.ACACIA_SIGN, Material.BIRCH_SIGN, Material.DARK_OAK_SIGN, Material.JUNGLE_SIGN, Material.OAK_SIGN, Material.SPRUCE_SIGN, Material.WHITE_BANNER, Material.ORANGE_BANNER, Material.MAGENTA_BANNER, Material.LIGHT_BLUE_BANNER, Material.YELLOW_BANNER, Material.LIME_BANNER, Material.PINK_BANNER, Material.GRAY_BANNER, Material.LIGHT_GRAY_BANNER, Material.CYAN_BANNER, Material.PURPLE_BANNER, Material.BLUE_BANNER, Material.BROWN_BANNER, Material.GREEN_BANNER, Material.RED_BANNER, Material.BLACK_BANNER, Material.RAIL, Material.IRON_DOOR, Material.SNOW, Material.CACTUS, Material.SUGAR_CANE, Material.REPEATER, Material.PUMPKIN_STEM, Material.MELON_STEM, Material.CARROT, Material.POTATO, Material.COMPARATOR, Material.ACTIVATOR_RAIL, Material.SUNFLOWER, Material.LILAC, Material.TALL_GRASS, Material.LARGE_FERN, Material.ROSE_BUSH, Material.PEONY, Material.NETHER_WART, Material.CHORUS_PLANT, Material.CHORUS_FLOWER, Material.KELP, Material.SOUL_TORCH, Material.TWISTING_VINES, Material.CRIMSON_FUNGUS, Material.WARPED_FUNGUS, Material.CRIMSON_ROOTS, Material.WARPED_ROOTS, Material.NETHER_SPROUTS, Material.CRIMSON_SIGN, Material.WARPED_SIGN));
|
||||
BlockGroup.TRACK_TOP = new HashSet<>(Arrays.asList(Material.TORCH, Material.REDSTONE_TORCH, Material.BAMBOO, Material.BAMBOO_SAPLING, Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SWEET_BERRY_BUSH, Material.SCAFFOLDING, Material.OAK_SAPLING, Material.SPRUCE_SAPLING, Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.FERN, Material.DEAD_BUSH, Material.DANDELION, Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.REDSTONE_WIRE, Material.WHEAT, Material.ACACIA_SIGN, Material.BIRCH_SIGN, Material.DARK_OAK_SIGN, Material.JUNGLE_SIGN, Material.OAK_SIGN, Material.SPRUCE_SIGN, Material.WHITE_BANNER, Material.ORANGE_BANNER, Material.MAGENTA_BANNER, Material.LIGHT_BLUE_BANNER, Material.YELLOW_BANNER, Material.LIME_BANNER, Material.PINK_BANNER, Material.GRAY_BANNER, Material.LIGHT_GRAY_BANNER, Material.CYAN_BANNER, Material.PURPLE_BANNER, Material.BLUE_BANNER, Material.BROWN_BANNER, Material.GREEN_BANNER, Material.RED_BANNER, Material.BLACK_BANNER, Material.RAIL, Material.IRON_DOOR, Material.SNOW, Material.CACTUS, Material.SUGAR_CANE, Material.REPEATER, Material.PUMPKIN_STEM, Material.MELON_STEM, Material.CARROT, Material.POTATO, Material.COMPARATOR, Material.ACTIVATOR_RAIL, Material.SUNFLOWER, Material.LILAC, Material.TALL_GRASS, Material.LARGE_FERN, Material.ROSE_BUSH, Material.PEONY, Material.NETHER_WART, Material.CHORUS_PLANT, Material.CHORUS_FLOWER, Material.KELP, Material.SOUL_TORCH, Material.TWISTING_VINES, Material.CRIMSON_FUNGUS, Material.WARPED_FUNGUS, Material.CRIMSON_ROOTS, Material.WARPED_ROOTS, Material.NETHER_SPROUTS, Material.CRIMSON_SIGN, Material.WARPED_SIGN));
|
||||
BlockGroup.TRACK_BOTTOM = new HashSet<>(Arrays.asList(Material.WEEPING_VINES));
|
||||
BlockGroup.TRACK_SIDE = new HashSet<>(Arrays.asList(Material.WALL_TORCH, Material.REDSTONE_WALL_TORCH, Material.RAIL, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.ACTIVATOR_RAIL, Material.WHITE_BED, Material.ORANGE_BED, Material.MAGENTA_BED, Material.LIGHT_BLUE_BED, Material.YELLOW_BED, Material.LIME_BED, Material.PINK_BED, Material.GRAY_BED, Material.LIGHT_GRAY_BED, Material.CYAN_BED, Material.PURPLE_BED, Material.BLUE_BED, Material.BROWN_BED, Material.GREEN_BED, Material.RED_BED, Material.BLACK_BED, Material.LADDER, Material.ACACIA_WALL_SIGN, Material.BIRCH_WALL_SIGN, Material.DARK_OAK_WALL_SIGN, Material.JUNGLE_WALL_SIGN, Material.OAK_WALL_SIGN, Material.SPRUCE_WALL_SIGN, Material.VINE, Material.COCOA, Material.TRIPWIRE_HOOK, Material.WHITE_WALL_BANNER, Material.ORANGE_WALL_BANNER, Material.MAGENTA_WALL_BANNER, Material.LIGHT_BLUE_WALL_BANNER, Material.YELLOW_WALL_BANNER, Material.LIME_WALL_BANNER, Material.PINK_WALL_BANNER, Material.GRAY_WALL_BANNER, Material.LIGHT_GRAY_WALL_BANNER, Material.CYAN_WALL_BANNER, Material.PURPLE_WALL_BANNER, Material.BLUE_WALL_BANNER, Material.BROWN_WALL_BANNER, Material.GREEN_WALL_BANNER, Material.RED_WALL_BANNER, Material.BLACK_WALL_BANNER, Material.SOUL_WALL_TORCH, Material.CRIMSON_WALL_SIGN, Material.WARPED_WALL_SIGN));
|
||||
BlockGroup.DOORS = new HashSet<>(Arrays.asList(Material.OAK_DOOR, Material.SPRUCE_DOOR, Material.BIRCH_DOOR, Material.JUNGLE_DOOR, Material.ACACIA_DOOR, Material.DARK_OAK_DOOR, Material.CRIMSON_DOOR, Material.WARPED_DOOR));
|
||||
|
@ -34,7 +34,7 @@ public class Bukkit_v1_16 extends Bukkit_v1_15 implements BukkitInterface {
|
|||
BlockGroup.INTERACT_BLOCKS = new HashSet<>(Arrays.asList(Material.SPRUCE_FENCE_GATE, Material.BIRCH_FENCE_GATE, Material.JUNGLE_FENCE_GATE, Material.DARK_OAK_FENCE_GATE, Material.ACACIA_FENCE_GATE, Material.DISPENSER, Material.NOTE_BLOCK, Material.CHEST, Material.FURNACE, Material.LEVER, Material.REPEATER, Material.ACACIA_TRAPDOOR, Material.BIRCH_TRAPDOOR, Material.DARK_OAK_TRAPDOOR, Material.JUNGLE_TRAPDOOR, Material.SPRUCE_TRAPDOOR, Material.OAK_TRAPDOOR, Material.OAK_FENCE_GATE, Material.BREWING_STAND, Material.ANVIL, Material.CHIPPED_ANVIL, Material.DAMAGED_ANVIL, Material.ENDER_CHEST, Material.TRAPPED_CHEST, Material.COMPARATOR, Material.HOPPER, Material.DROPPER, Material.SHULKER_BOX, Material.BLACK_SHULKER_BOX, Material.BLUE_SHULKER_BOX, Material.BROWN_SHULKER_BOX, Material.CYAN_SHULKER_BOX, Material.GRAY_SHULKER_BOX, Material.GREEN_SHULKER_BOX, Material.LIGHT_BLUE_SHULKER_BOX, Material.LIME_SHULKER_BOX, Material.MAGENTA_SHULKER_BOX, Material.ORANGE_SHULKER_BOX, Material.PINK_SHULKER_BOX, Material.PURPLE_SHULKER_BOX, Material.RED_SHULKER_BOX, Material.LIGHT_GRAY_SHULKER_BOX, Material.WHITE_SHULKER_BOX, Material.YELLOW_SHULKER_BOX, Material.BARREL, Material.BLAST_FURNACE, Material.GRINDSTONE, Material.LOOM, Material.SMOKER, Material.CRAFTING_TABLE, Material.CARTOGRAPHY_TABLE, Material.ENCHANTING_TABLE, Material.SMITHING_TABLE, Material.STONECUTTER, Material.CRIMSON_FENCE_GATE, Material.WARPED_FENCE_GATE, Material.CRIMSON_TRAPDOOR, Material.WARPED_TRAPDOOR));
|
||||
BlockGroup.SAFE_INTERACT_BLOCKS = new HashSet<>(Arrays.asList(Material.LEVER, Material.ACACIA_TRAPDOOR, Material.BIRCH_TRAPDOOR, Material.DARK_OAK_TRAPDOOR, Material.JUNGLE_TRAPDOOR, Material.SPRUCE_TRAPDOOR, Material.OAK_TRAPDOOR, Material.OAK_FENCE_GATE, Material.SPRUCE_FENCE_GATE, Material.BIRCH_FENCE_GATE, Material.JUNGLE_FENCE_GATE, Material.DARK_OAK_FENCE_GATE, Material.ACACIA_FENCE_GATE, Material.CRIMSON_FENCE_GATE, Material.WARPED_FENCE_GATE, Material.CRIMSON_TRAPDOOR, Material.WARPED_TRAPDOOR));
|
||||
BlockGroup.UPDATE_STATE = new HashSet<>(Arrays.asList(Material.TORCH, Material.WALL_TORCH, Material.REDSTONE_WIRE, Material.RAIL, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.FURNACE, Material.BLAST_FURNACE, Material.SMOKER, Material.LEVER, Material.REDSTONE_TORCH, Material.REDSTONE_WALL_TORCH, Material.GLOWSTONE, Material.JACK_O_LANTERN, Material.REPEATER, Material.REDSTONE_LAMP, Material.BEACON, Material.COMPARATOR, Material.DAYLIGHT_DETECTOR, Material.REDSTONE_BLOCK, Material.HOPPER, Material.CHEST, Material.TRAPPED_CHEST, Material.ACTIVATOR_RAIL, Material.SOUL_TORCH, Material.SOUL_WALL_TORCH, Material.SHROOMLIGHT, Material.RESPAWN_ANCHOR, Material.CRYING_OBSIDIAN, Material.TARGET));
|
||||
BlockGroup.NON_ATTACHABLE = new HashSet<>(Arrays.asList(Material.AIR, Material.CAVE_AIR, Material.BARRIER, Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SWEET_BERRY_BUSH, Material.OAK_SAPLING, Material.SPRUCE_SAPLING, Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING, Material.WATER, Material.LAVA, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.GRASS, Material.FERN, Material.DEAD_BUSH, Material.DANDELION, Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.TORCH, Material.WALL_TORCH, Material.REDSTONE_WIRE, Material.LADDER, Material.RAIL, Material.LEVER, Material.REDSTONE_TORCH, Material.REDSTONE_WALL_TORCH, Material.SNOW, Material.SUGAR_CANE, Material.NETHER_PORTAL, Material.REPEATER, Material.KELP, Material.CHORUS_FLOWER, Material.CHORUS_PLANT, Material.SOUL_TORCH, Material.SOUL_WALL_TORCH));
|
||||
BlockGroup.NON_ATTACHABLE = new HashSet<>(Arrays.asList(Material.AIR, Material.CAVE_AIR, Material.BARRIER, Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SWEET_BERRY_BUSH, Material.OAK_SAPLING, Material.SPRUCE_SAPLING, Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING, Material.WATER, Material.LAVA, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.FERN, Material.DEAD_BUSH, Material.DANDELION, Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.TORCH, Material.WALL_TORCH, Material.REDSTONE_WIRE, Material.LADDER, Material.RAIL, Material.LEVER, Material.REDSTONE_TORCH, Material.REDSTONE_WALL_TORCH, Material.SNOW, Material.SUGAR_CANE, Material.NETHER_PORTAL, Material.REPEATER, Material.KELP, Material.CHORUS_FLOWER, Material.CHORUS_PLANT, Material.SOUL_TORCH, Material.SOUL_WALL_TORCH));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,14 +31,14 @@ public class Bukkit_v1_17 extends Bukkit_v1_16 implements BukkitInterface {
|
|||
|
||||
public Bukkit_v1_17() {
|
||||
BlockGroup.TRACK_ANY = new HashSet<>(Arrays.asList(Material.PISTON_HEAD, Material.LEVER, Material.BELL, Material.SMALL_AMETHYST_BUD, Material.MEDIUM_AMETHYST_BUD, Material.LARGE_AMETHYST_BUD, Material.AMETHYST_CLUSTER, Material.GLOW_LICHEN));
|
||||
BlockGroup.TRACK_TOP = new HashSet<>(Arrays.asList(Material.TORCH, Material.REDSTONE_TORCH, Material.BAMBOO, Material.BAMBOO_SAPLING, Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SWEET_BERRY_BUSH, Material.SCAFFOLDING, Material.OAK_SAPLING, Material.SPRUCE_SAPLING, Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.GRASS, Material.FERN, Material.DEAD_BUSH, Material.DANDELION, Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.REDSTONE_WIRE, Material.WHEAT, Material.ACACIA_SIGN, Material.BIRCH_SIGN, Material.DARK_OAK_SIGN, Material.JUNGLE_SIGN, Material.OAK_SIGN, Material.SPRUCE_SIGN, Material.WHITE_BANNER, Material.ORANGE_BANNER, Material.MAGENTA_BANNER, Material.LIGHT_BLUE_BANNER, Material.YELLOW_BANNER, Material.LIME_BANNER, Material.PINK_BANNER, Material.GRAY_BANNER, Material.LIGHT_GRAY_BANNER, Material.CYAN_BANNER, Material.PURPLE_BANNER, Material.BLUE_BANNER, Material.BROWN_BANNER, Material.GREEN_BANNER, Material.RED_BANNER, Material.BLACK_BANNER, Material.RAIL, Material.IRON_DOOR, Material.SNOW, Material.CACTUS, Material.SUGAR_CANE, Material.REPEATER, Material.PUMPKIN_STEM, Material.MELON_STEM, Material.CARROT, Material.POTATO, Material.COMPARATOR, Material.ACTIVATOR_RAIL, Material.SUNFLOWER, Material.LILAC, Material.TALL_GRASS, Material.LARGE_FERN, Material.ROSE_BUSH, Material.PEONY, Material.NETHER_WART, Material.CHORUS_PLANT, Material.CHORUS_FLOWER, Material.KELP, Material.SOUL_TORCH, Material.TWISTING_VINES, Material.CRIMSON_FUNGUS, Material.WARPED_FUNGUS, Material.CRIMSON_ROOTS, Material.WARPED_ROOTS, Material.NETHER_SPROUTS, Material.CRIMSON_SIGN, Material.WARPED_SIGN, Material.AZALEA, Material.FLOWERING_AZALEA, Material.SMALL_DRIPLEAF, Material.BIG_DRIPLEAF));
|
||||
BlockGroup.TRACK_TOP = new HashSet<>(Arrays.asList(Material.TORCH, Material.REDSTONE_TORCH, Material.BAMBOO, Material.BAMBOO_SAPLING, Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SWEET_BERRY_BUSH, Material.SCAFFOLDING, Material.OAK_SAPLING, Material.SPRUCE_SAPLING, Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.FERN, Material.DEAD_BUSH, Material.DANDELION, Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.REDSTONE_WIRE, Material.WHEAT, Material.ACACIA_SIGN, Material.BIRCH_SIGN, Material.DARK_OAK_SIGN, Material.JUNGLE_SIGN, Material.OAK_SIGN, Material.SPRUCE_SIGN, Material.WHITE_BANNER, Material.ORANGE_BANNER, Material.MAGENTA_BANNER, Material.LIGHT_BLUE_BANNER, Material.YELLOW_BANNER, Material.LIME_BANNER, Material.PINK_BANNER, Material.GRAY_BANNER, Material.LIGHT_GRAY_BANNER, Material.CYAN_BANNER, Material.PURPLE_BANNER, Material.BLUE_BANNER, Material.BROWN_BANNER, Material.GREEN_BANNER, Material.RED_BANNER, Material.BLACK_BANNER, Material.RAIL, Material.IRON_DOOR, Material.SNOW, Material.CACTUS, Material.SUGAR_CANE, Material.REPEATER, Material.PUMPKIN_STEM, Material.MELON_STEM, Material.CARROT, Material.POTATO, Material.COMPARATOR, Material.ACTIVATOR_RAIL, Material.SUNFLOWER, Material.LILAC, Material.TALL_GRASS, Material.LARGE_FERN, Material.ROSE_BUSH, Material.PEONY, Material.NETHER_WART, Material.CHORUS_PLANT, Material.CHORUS_FLOWER, Material.KELP, Material.SOUL_TORCH, Material.TWISTING_VINES, Material.CRIMSON_FUNGUS, Material.WARPED_FUNGUS, Material.CRIMSON_ROOTS, Material.WARPED_ROOTS, Material.NETHER_SPROUTS, Material.CRIMSON_SIGN, Material.WARPED_SIGN, Material.AZALEA, Material.FLOWERING_AZALEA, Material.SMALL_DRIPLEAF, Material.BIG_DRIPLEAF));
|
||||
BlockGroup.TRACK_TOP_BOTTOM = new HashSet<>(Arrays.asList(Material.POINTED_DRIPSTONE, Material.BIG_DRIPLEAF_STEM));
|
||||
BlockGroup.TRACK_BOTTOM = new HashSet<>(Arrays.asList(Material.WEEPING_VINES, Material.CAVE_VINES, Material.CAVE_VINES_PLANT, Material.HANGING_ROOTS));
|
||||
BlockGroup.VINES = new HashSet<>(Arrays.asList(Material.VINE, Material.WEEPING_VINES, Material.TWISTING_VINES, Material.CAVE_VINES));
|
||||
BlockGroup.CANDLES = new HashSet<>(Arrays.asList(Material.CANDLE, Material.BLACK_CANDLE, Material.BLUE_CANDLE, Material.BROWN_CANDLE, Material.CYAN_CANDLE, Material.GRAY_CANDLE, Material.GREEN_CANDLE, Material.LIGHT_BLUE_CANDLE, Material.LIGHT_GRAY_CANDLE, Material.LIME_CANDLE, Material.MAGENTA_CANDLE, Material.ORANGE_CANDLE, Material.PINK_CANDLE, Material.PURPLE_CANDLE, Material.RED_CANDLE, Material.WHITE_CANDLE, Material.YELLOW_CANDLE, Material.CANDLE_CAKE, Material.BLACK_CANDLE_CAKE, Material.BLUE_CANDLE_CAKE, Material.BROWN_CANDLE_CAKE, Material.CYAN_CANDLE_CAKE, Material.GRAY_CANDLE_CAKE, Material.GREEN_CANDLE_CAKE, Material.LIGHT_BLUE_CANDLE_CAKE, Material.LIGHT_GRAY_CANDLE_CAKE, Material.LIME_CANDLE_CAKE, Material.MAGENTA_CANDLE_CAKE, Material.ORANGE_CANDLE_CAKE, Material.PINK_CANDLE_CAKE, Material.PURPLE_CANDLE_CAKE, Material.RED_CANDLE_CAKE, Material.WHITE_CANDLE_CAKE, Material.YELLOW_CANDLE_CAKE));
|
||||
BlockGroup.AMETHYST = new HashSet<>(Arrays.asList(Material.SMALL_AMETHYST_BUD, Material.MEDIUM_AMETHYST_BUD, Material.LARGE_AMETHYST_BUD, Material.AMETHYST_CLUSTER));
|
||||
BlockGroup.UPDATE_STATE = new HashSet<>(Arrays.asList(Material.TORCH, Material.WALL_TORCH, Material.REDSTONE_WIRE, Material.RAIL, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.FURNACE, Material.BLAST_FURNACE, Material.SMOKER, Material.LEVER, Material.REDSTONE_TORCH, Material.REDSTONE_WALL_TORCH, Material.GLOWSTONE, Material.JACK_O_LANTERN, Material.REPEATER, Material.REDSTONE_LAMP, Material.BEACON, Material.COMPARATOR, Material.DAYLIGHT_DETECTOR, Material.REDSTONE_BLOCK, Material.HOPPER, Material.CHEST, Material.TRAPPED_CHEST, Material.ACTIVATOR_RAIL, Material.SOUL_TORCH, Material.SOUL_WALL_TORCH, Material.SHROOMLIGHT, Material.RESPAWN_ANCHOR, Material.CRYING_OBSIDIAN, Material.TARGET, Material.SMALL_AMETHYST_BUD, Material.MEDIUM_AMETHYST_BUD, Material.LARGE_AMETHYST_BUD, Material.AMETHYST_CLUSTER, Material.CAVE_VINES, Material.CAVE_VINES_PLANT, Material.GLOW_LICHEN, Material.LIGHT, Material.LAVA_CAULDRON));
|
||||
BlockGroup.NON_ATTACHABLE = new HashSet<>(Arrays.asList(Material.AIR, Material.CAVE_AIR, Material.BARRIER, Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SWEET_BERRY_BUSH, Material.OAK_SAPLING, Material.SPRUCE_SAPLING, Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING, Material.WATER, Material.LAVA, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.GRASS, Material.FERN, Material.DEAD_BUSH, Material.DANDELION, Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.TORCH, Material.WALL_TORCH, Material.REDSTONE_WIRE, Material.LADDER, Material.RAIL, Material.LEVER, Material.REDSTONE_TORCH, Material.REDSTONE_WALL_TORCH, Material.SNOW, Material.SUGAR_CANE, Material.NETHER_PORTAL, Material.REPEATER, Material.KELP, Material.CHORUS_FLOWER, Material.CHORUS_PLANT, Material.SOUL_TORCH, Material.SOUL_WALL_TORCH, Material.LIGHT, Material.SMALL_DRIPLEAF, Material.BIG_DRIPLEAF, Material.BIG_DRIPLEAF_STEM, Material.GLOW_LICHEN, Material.HANGING_ROOTS));
|
||||
BlockGroup.NON_ATTACHABLE = new HashSet<>(Arrays.asList(Material.AIR, Material.CAVE_AIR, Material.BARRIER, Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SWEET_BERRY_BUSH, Material.OAK_SAPLING, Material.SPRUCE_SAPLING, Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING, Material.WATER, Material.LAVA, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.FERN, Material.DEAD_BUSH, Material.DANDELION, Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.TORCH, Material.WALL_TORCH, Material.REDSTONE_WIRE, Material.LADDER, Material.RAIL, Material.LEVER, Material.REDSTONE_TORCH, Material.REDSTONE_WALL_TORCH, Material.SNOW, Material.SUGAR_CANE, Material.NETHER_PORTAL, Material.REPEATER, Material.KELP, Material.CHORUS_FLOWER, Material.CHORUS_PLANT, Material.SOUL_TORCH, Material.SOUL_WALL_TORCH, Material.LIGHT, Material.SMALL_DRIPLEAF, Material.BIG_DRIPLEAF, Material.BIG_DRIPLEAF_STEM, Material.GLOW_LICHEN, Material.HANGING_ROOTS));
|
||||
BlockGroup.VERTICAL_TOP_BOTTOM = new HashSet<>(Arrays.asList(Material.BIG_DRIPLEAF_STEM));
|
||||
}
|
||||
|
||||
|
@ -218,13 +218,21 @@ public class Bukkit_v1_17 extends Bukkit_v1_16 implements BukkitInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlowing(Sign sign) {
|
||||
public boolean isGlowing(Sign sign, boolean isFront) {
|
||||
if (!isFront) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return sign.isGlowingText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGlowing(Sign sign, boolean set) {
|
||||
sign.setGlowingText(set);
|
||||
public void setGlowing(Sign sign, boolean isFront, boolean isGlowing) {
|
||||
if (!isFront) {
|
||||
return;
|
||||
}
|
||||
|
||||
sign.setGlowingText(isGlowing);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,14 +16,14 @@ import net.coreprotect.model.BlockGroup;
|
|||
public class Bukkit_v1_19 extends Bukkit_v1_18 implements BukkitInterface {
|
||||
|
||||
public Bukkit_v1_19() {
|
||||
BlockGroup.TRACK_TOP = new HashSet<>(Arrays.asList(Material.TORCH, Material.REDSTONE_TORCH, Material.BAMBOO, Material.BAMBOO_SAPLING, Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SWEET_BERRY_BUSH, Material.SCAFFOLDING, Material.OAK_SAPLING, Material.SPRUCE_SAPLING, Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING, Material.MANGROVE_PROPAGULE, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.GRASS, Material.FERN, Material.DEAD_BUSH, Material.DANDELION, Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.REDSTONE_WIRE, Material.WHEAT, Material.MANGROVE_SIGN, Material.ACACIA_SIGN, Material.BIRCH_SIGN, Material.DARK_OAK_SIGN, Material.JUNGLE_SIGN, Material.OAK_SIGN, Material.SPRUCE_SIGN, Material.WHITE_BANNER, Material.ORANGE_BANNER, Material.MAGENTA_BANNER, Material.LIGHT_BLUE_BANNER, Material.YELLOW_BANNER, Material.LIME_BANNER, Material.PINK_BANNER, Material.GRAY_BANNER, Material.LIGHT_GRAY_BANNER, Material.CYAN_BANNER, Material.PURPLE_BANNER, Material.BLUE_BANNER, Material.BROWN_BANNER, Material.GREEN_BANNER, Material.RED_BANNER, Material.BLACK_BANNER, Material.RAIL, Material.IRON_DOOR, Material.SNOW, Material.CACTUS, Material.SUGAR_CANE, Material.REPEATER, Material.PUMPKIN_STEM, Material.MELON_STEM, Material.CARROT, Material.POTATO, Material.COMPARATOR, Material.ACTIVATOR_RAIL, Material.SUNFLOWER, Material.LILAC, Material.TALL_GRASS, Material.LARGE_FERN, Material.ROSE_BUSH, Material.PEONY, Material.NETHER_WART, Material.CHORUS_PLANT, Material.CHORUS_FLOWER, Material.KELP, Material.SOUL_TORCH, Material.TWISTING_VINES, Material.CRIMSON_FUNGUS, Material.WARPED_FUNGUS, Material.CRIMSON_ROOTS, Material.WARPED_ROOTS, Material.NETHER_SPROUTS, Material.CRIMSON_SIGN, Material.WARPED_SIGN, Material.AZALEA, Material.FLOWERING_AZALEA, Material.SMALL_DRIPLEAF, Material.BIG_DRIPLEAF));
|
||||
BlockGroup.TRACK_TOP = new HashSet<>(Arrays.asList(Material.TORCH, Material.REDSTONE_TORCH, Material.BAMBOO, Material.BAMBOO_SAPLING, Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SWEET_BERRY_BUSH, Material.SCAFFOLDING, Material.OAK_SAPLING, Material.SPRUCE_SAPLING, Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING, Material.MANGROVE_PROPAGULE, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.FERN, Material.DEAD_BUSH, Material.DANDELION, Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.REDSTONE_WIRE, Material.WHEAT, Material.MANGROVE_SIGN, Material.ACACIA_SIGN, Material.BIRCH_SIGN, Material.DARK_OAK_SIGN, Material.JUNGLE_SIGN, Material.OAK_SIGN, Material.SPRUCE_SIGN, Material.WHITE_BANNER, Material.ORANGE_BANNER, Material.MAGENTA_BANNER, Material.LIGHT_BLUE_BANNER, Material.YELLOW_BANNER, Material.LIME_BANNER, Material.PINK_BANNER, Material.GRAY_BANNER, Material.LIGHT_GRAY_BANNER, Material.CYAN_BANNER, Material.PURPLE_BANNER, Material.BLUE_BANNER, Material.BROWN_BANNER, Material.GREEN_BANNER, Material.RED_BANNER, Material.BLACK_BANNER, Material.RAIL, Material.IRON_DOOR, Material.SNOW, Material.CACTUS, Material.SUGAR_CANE, Material.REPEATER, Material.PUMPKIN_STEM, Material.MELON_STEM, Material.CARROT, Material.POTATO, Material.COMPARATOR, Material.ACTIVATOR_RAIL, Material.SUNFLOWER, Material.LILAC, Material.TALL_GRASS, Material.LARGE_FERN, Material.ROSE_BUSH, Material.PEONY, Material.NETHER_WART, Material.CHORUS_PLANT, Material.CHORUS_FLOWER, Material.KELP, Material.SOUL_TORCH, Material.TWISTING_VINES, Material.CRIMSON_FUNGUS, Material.WARPED_FUNGUS, Material.CRIMSON_ROOTS, Material.WARPED_ROOTS, Material.NETHER_SPROUTS, Material.CRIMSON_SIGN, Material.WARPED_SIGN, Material.AZALEA, Material.FLOWERING_AZALEA, Material.SMALL_DRIPLEAF, Material.BIG_DRIPLEAF));
|
||||
BlockGroup.TRACK_SIDE = new HashSet<>(Arrays.asList(Material.WALL_TORCH, Material.REDSTONE_WALL_TORCH, Material.RAIL, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.ACTIVATOR_RAIL, Material.WHITE_BED, Material.ORANGE_BED, Material.MAGENTA_BED, Material.LIGHT_BLUE_BED, Material.YELLOW_BED, Material.LIME_BED, Material.PINK_BED, Material.GRAY_BED, Material.LIGHT_GRAY_BED, Material.CYAN_BED, Material.PURPLE_BED, Material.BLUE_BED, Material.BROWN_BED, Material.GREEN_BED, Material.RED_BED, Material.BLACK_BED, Material.LADDER, Material.MANGROVE_WALL_SIGN, Material.ACACIA_WALL_SIGN, Material.BIRCH_WALL_SIGN, Material.DARK_OAK_WALL_SIGN, Material.JUNGLE_WALL_SIGN, Material.OAK_WALL_SIGN, Material.SPRUCE_WALL_SIGN, Material.VINE, Material.COCOA, Material.TRIPWIRE_HOOK, Material.WHITE_WALL_BANNER, Material.ORANGE_WALL_BANNER, Material.MAGENTA_WALL_BANNER, Material.LIGHT_BLUE_WALL_BANNER, Material.YELLOW_WALL_BANNER, Material.LIME_WALL_BANNER, Material.PINK_WALL_BANNER, Material.GRAY_WALL_BANNER, Material.LIGHT_GRAY_WALL_BANNER, Material.CYAN_WALL_BANNER, Material.PURPLE_WALL_BANNER, Material.BLUE_WALL_BANNER, Material.BROWN_WALL_BANNER, Material.GREEN_WALL_BANNER, Material.RED_WALL_BANNER, Material.BLACK_WALL_BANNER, Material.SOUL_WALL_TORCH, Material.CRIMSON_WALL_SIGN, Material.WARPED_WALL_SIGN));
|
||||
BlockGroup.DOORS = new HashSet<>(Arrays.asList(Material.OAK_DOOR, Material.SPRUCE_DOOR, Material.BIRCH_DOOR, Material.JUNGLE_DOOR, Material.MANGROVE_DOOR, Material.ACACIA_DOOR, Material.DARK_OAK_DOOR, Material.CRIMSON_DOOR, Material.WARPED_DOOR));
|
||||
BlockGroup.BUTTONS = new HashSet<>(Arrays.asList(Material.STONE_BUTTON, Material.OAK_BUTTON, Material.MANGROVE_BUTTON, Material.ACACIA_BUTTON, Material.BIRCH_BUTTON, Material.DARK_OAK_BUTTON, Material.JUNGLE_BUTTON, Material.SPRUCE_BUTTON, Material.POLISHED_BLACKSTONE_BUTTON, Material.CRIMSON_BUTTON, Material.WARPED_BUTTON));
|
||||
BlockGroup.PRESSURE_PLATES = new HashSet<>(Arrays.asList(Material.STONE_PRESSURE_PLATE, Material.MANGROVE_PRESSURE_PLATE, Material.ACACIA_PRESSURE_PLATE, Material.BIRCH_PRESSURE_PLATE, Material.DARK_OAK_PRESSURE_PLATE, Material.HEAVY_WEIGHTED_PRESSURE_PLATE, Material.JUNGLE_PRESSURE_PLATE, Material.LIGHT_WEIGHTED_PRESSURE_PLATE, Material.OAK_PRESSURE_PLATE, Material.SPRUCE_PRESSURE_PLATE, Material.CRIMSON_PRESSURE_PLATE, Material.WARPED_PRESSURE_PLATE, Material.POLISHED_BLACKSTONE_PRESSURE_PLATE));
|
||||
BlockGroup.INTERACT_BLOCKS = new HashSet<>(Arrays.asList(Material.SPRUCE_FENCE_GATE, Material.BIRCH_FENCE_GATE, Material.JUNGLE_FENCE_GATE, Material.DARK_OAK_FENCE_GATE, Material.MANGROVE_FENCE_GATE, Material.ACACIA_FENCE_GATE, Material.DISPENSER, Material.NOTE_BLOCK, Material.CHEST, Material.FURNACE, Material.LEVER, Material.REPEATER, Material.MANGROVE_TRAPDOOR, Material.ACACIA_TRAPDOOR, Material.BIRCH_TRAPDOOR, Material.DARK_OAK_TRAPDOOR, Material.JUNGLE_TRAPDOOR, Material.SPRUCE_TRAPDOOR, Material.OAK_TRAPDOOR, Material.OAK_FENCE_GATE, Material.BREWING_STAND, Material.ANVIL, Material.CHIPPED_ANVIL, Material.DAMAGED_ANVIL, Material.ENDER_CHEST, Material.TRAPPED_CHEST, Material.COMPARATOR, Material.HOPPER, Material.DROPPER, Material.SHULKER_BOX, Material.BLACK_SHULKER_BOX, Material.BLUE_SHULKER_BOX, Material.BROWN_SHULKER_BOX, Material.CYAN_SHULKER_BOX, Material.GRAY_SHULKER_BOX, Material.GREEN_SHULKER_BOX, Material.LIGHT_BLUE_SHULKER_BOX, Material.LIME_SHULKER_BOX, Material.MAGENTA_SHULKER_BOX, Material.ORANGE_SHULKER_BOX, Material.PINK_SHULKER_BOX, Material.PURPLE_SHULKER_BOX, Material.RED_SHULKER_BOX, Material.LIGHT_GRAY_SHULKER_BOX, Material.WHITE_SHULKER_BOX, Material.YELLOW_SHULKER_BOX, Material.BARREL, Material.BLAST_FURNACE, Material.GRINDSTONE, Material.LOOM, Material.SMOKER, Material.CRAFTING_TABLE, Material.CARTOGRAPHY_TABLE, Material.ENCHANTING_TABLE, Material.SMITHING_TABLE, Material.STONECUTTER, Material.CRIMSON_FENCE_GATE, Material.WARPED_FENCE_GATE, Material.CRIMSON_TRAPDOOR, Material.WARPED_TRAPDOOR));
|
||||
BlockGroup.SAFE_INTERACT_BLOCKS = new HashSet<>(Arrays.asList(Material.LEVER, Material.MANGROVE_TRAPDOOR, Material.ACACIA_TRAPDOOR, Material.BIRCH_TRAPDOOR, Material.DARK_OAK_TRAPDOOR, Material.JUNGLE_TRAPDOOR, Material.SPRUCE_TRAPDOOR, Material.OAK_TRAPDOOR, Material.OAK_FENCE_GATE, Material.SPRUCE_FENCE_GATE, Material.BIRCH_FENCE_GATE, Material.JUNGLE_FENCE_GATE, Material.DARK_OAK_FENCE_GATE, Material.MANGROVE_FENCE_GATE, Material.ACACIA_FENCE_GATE, Material.CRIMSON_FENCE_GATE, Material.WARPED_FENCE_GATE, Material.CRIMSON_TRAPDOOR, Material.WARPED_TRAPDOOR));
|
||||
BlockGroup.NON_ATTACHABLE = new HashSet<>(Arrays.asList(Material.AIR, Material.CAVE_AIR, Material.BARRIER, Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SWEET_BERRY_BUSH, Material.OAK_SAPLING, Material.SPRUCE_SAPLING, Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING, Material.MANGROVE_PROPAGULE, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING, Material.WATER, Material.LAVA, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.GRASS, Material.FERN, Material.DEAD_BUSH, Material.DANDELION, Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.TORCH, Material.WALL_TORCH, Material.REDSTONE_WIRE, Material.LADDER, Material.RAIL, Material.LEVER, Material.REDSTONE_TORCH, Material.REDSTONE_WALL_TORCH, Material.SNOW, Material.SUGAR_CANE, Material.NETHER_PORTAL, Material.REPEATER, Material.KELP, Material.CHORUS_FLOWER, Material.CHORUS_PLANT, Material.SOUL_TORCH, Material.SOUL_WALL_TORCH, Material.LIGHT, Material.SMALL_DRIPLEAF, Material.BIG_DRIPLEAF, Material.BIG_DRIPLEAF_STEM, Material.GLOW_LICHEN, Material.HANGING_ROOTS));
|
||||
BlockGroup.NON_ATTACHABLE = new HashSet<>(Arrays.asList(Material.AIR, Material.CAVE_AIR, Material.BARRIER, Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SWEET_BERRY_BUSH, Material.OAK_SAPLING, Material.SPRUCE_SAPLING, Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING, Material.MANGROVE_PROPAGULE, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING, Material.WATER, Material.LAVA, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.FERN, Material.DEAD_BUSH, Material.DANDELION, Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.TORCH, Material.WALL_TORCH, Material.REDSTONE_WIRE, Material.LADDER, Material.RAIL, Material.LEVER, Material.REDSTONE_TORCH, Material.REDSTONE_WALL_TORCH, Material.SNOW, Material.SUGAR_CANE, Material.NETHER_PORTAL, Material.REPEATER, Material.KELP, Material.CHORUS_FLOWER, Material.CHORUS_PLANT, Material.SOUL_TORCH, Material.SOUL_WALL_TORCH, Material.LIGHT, Material.SMALL_DRIPLEAF, Material.BIG_DRIPLEAF, Material.BIG_DRIPLEAF_STEM, Material.GLOW_LICHEN, Material.HANGING_ROOTS));
|
||||
BlockGroup.SCULK = new HashSet<>(Arrays.asList(Material.SCULK, Material.SCULK_VEIN, Material.SCULK_SENSOR, Material.SCULK_SHRIEKER));
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,294 @@
|
|||
package net.coreprotect.bukkit;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.ChiseledBookshelf;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.sign.Side;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
|
||||
public class Bukkit_v1_20 extends Bukkit_v1_19 implements BukkitInterface {
|
||||
|
||||
private Boolean hasClickedPosition = null;
|
||||
private Boolean hasBasePotionType = null;
|
||||
|
||||
public Bukkit_v1_20() {
|
||||
BlockGroup.CONTAINERS = new HashSet<>(Arrays.asList(Material.JUKEBOX, Material.DISPENSER, Material.CHEST, Material.FURNACE, Material.BREWING_STAND, Material.TRAPPED_CHEST, Material.HOPPER, Material.DROPPER, Material.ARMOR_STAND, Material.ITEM_FRAME, Material.SHULKER_BOX, Material.BLACK_SHULKER_BOX, Material.BLUE_SHULKER_BOX, Material.BROWN_SHULKER_BOX, Material.CYAN_SHULKER_BOX, Material.GRAY_SHULKER_BOX, Material.GREEN_SHULKER_BOX, Material.LIGHT_BLUE_SHULKER_BOX, Material.LIME_SHULKER_BOX, Material.MAGENTA_SHULKER_BOX, Material.ORANGE_SHULKER_BOX, Material.PINK_SHULKER_BOX, Material.PURPLE_SHULKER_BOX, Material.RED_SHULKER_BOX, Material.LIGHT_GRAY_SHULKER_BOX, Material.WHITE_SHULKER_BOX, Material.YELLOW_SHULKER_BOX, Material.BARREL, Material.BLAST_FURNACE, Material.SMOKER, Material.LECTERN, Material.CHISELED_BOOKSHELF, Material.DECORATED_POT));
|
||||
BlockGroup.UPDATE_STATE = new HashSet<>(Arrays.asList(Material.TORCH, Material.WALL_TORCH, Material.REDSTONE_WIRE, Material.RAIL, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.FURNACE, Material.BLAST_FURNACE, Material.SMOKER, Material.LEVER, Material.REDSTONE_TORCH, Material.REDSTONE_WALL_TORCH, Material.GLOWSTONE, Material.JACK_O_LANTERN, Material.REPEATER, Material.REDSTONE_LAMP, Material.BEACON, Material.COMPARATOR, Material.DAYLIGHT_DETECTOR, Material.REDSTONE_BLOCK, Material.HOPPER, Material.CHEST, Material.TRAPPED_CHEST, Material.ACTIVATOR_RAIL, Material.SOUL_TORCH, Material.SOUL_WALL_TORCH, Material.SHROOMLIGHT, Material.RESPAWN_ANCHOR, Material.CRYING_OBSIDIAN, Material.TARGET, Material.SMALL_AMETHYST_BUD, Material.MEDIUM_AMETHYST_BUD, Material.LARGE_AMETHYST_BUD, Material.AMETHYST_CLUSTER, Material.CAVE_VINES, Material.CAVE_VINES_PLANT, Material.GLOW_LICHEN, Material.LIGHT, Material.LAVA_CAULDRON, Material.CHISELED_BOOKSHELF));
|
||||
|
||||
BlockGroup.BUTTONS.clear();
|
||||
BlockGroup.BUTTONS.addAll(Tag.BUTTONS.getValues());
|
||||
BlockGroup.PRESSURE_PLATES.clear();
|
||||
BlockGroup.PRESSURE_PLATES.addAll(Tag.PRESSURE_PLATES.getValues());
|
||||
|
||||
for (Material value : Tag.DOORS.getValues()) {
|
||||
if (!BlockGroup.DOORS.contains(value)) {
|
||||
BlockGroup.DOORS.add(value);
|
||||
}
|
||||
}
|
||||
for (Material value : Tag.FENCE_GATES.getValues()) {
|
||||
if (!BlockGroup.INTERACT_BLOCKS.contains(value)) {
|
||||
BlockGroup.INTERACT_BLOCKS.add(value);
|
||||
}
|
||||
if (!BlockGroup.SAFE_INTERACT_BLOCKS.contains(value)) {
|
||||
BlockGroup.SAFE_INTERACT_BLOCKS.add(value);
|
||||
}
|
||||
}
|
||||
for (Material value : Tag.WOODEN_TRAPDOORS.getValues()) {
|
||||
if (!BlockGroup.INTERACT_BLOCKS.contains(value)) {
|
||||
BlockGroup.INTERACT_BLOCKS.add(value);
|
||||
}
|
||||
if (!BlockGroup.SAFE_INTERACT_BLOCKS.contains(value)) {
|
||||
BlockGroup.SAFE_INTERACT_BLOCKS.add(value);
|
||||
}
|
||||
}
|
||||
for (Material value : Tag.CEILING_HANGING_SIGNS.getValues()) {
|
||||
if (!BlockGroup.TRACK_BOTTOM.contains(value)) {
|
||||
BlockGroup.TRACK_BOTTOM.add(value);
|
||||
}
|
||||
}
|
||||
for (Material value : Tag.WALL_SIGNS.getValues()) {
|
||||
if (!BlockGroup.TRACK_SIDE.contains(value)) {
|
||||
BlockGroup.TRACK_SIDE.add(value);
|
||||
}
|
||||
}
|
||||
for (Material value : Tag.SAPLINGS.getValues()) {
|
||||
if (!BlockGroup.TRACK_TOP.contains(value)) {
|
||||
BlockGroup.TRACK_TOP.add(value);
|
||||
}
|
||||
if (!BlockGroup.NON_ATTACHABLE.contains(value)) {
|
||||
BlockGroup.NON_ATTACHABLE.add(value);
|
||||
}
|
||||
}
|
||||
for (Material value : Tag.FLOWERS.getValues()) {
|
||||
if (!BlockGroup.TRACK_TOP.contains(value)) {
|
||||
BlockGroup.TRACK_TOP.add(value);
|
||||
}
|
||||
if (!BlockGroup.NON_ATTACHABLE.contains(value)) {
|
||||
BlockGroup.NON_ATTACHABLE.add(value);
|
||||
}
|
||||
}
|
||||
for (Material value : Tag.SIGNS.getValues()) {
|
||||
if (!Tag.WALL_SIGNS.isTagged(value) && !BlockGroup.TRACK_TOP.contains(value)) {
|
||||
BlockGroup.TRACK_TOP.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGlowing(Sign sign, boolean isFront, boolean isGlowing) {
|
||||
if (isFront) {
|
||||
sign.getSide(Side.FRONT).setGlowingText(isGlowing);
|
||||
}
|
||||
else {
|
||||
sign.getSide(Side.BACK).setGlowingText(isGlowing);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parseLegacyName(String name) {
|
||||
switch (name) {
|
||||
case "GRASS_PATH":
|
||||
name = "DIRT_PATH";
|
||||
break;
|
||||
case "GRASS":
|
||||
name = "SHORT_GRASS";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// fallback until this method is moved up into v1_21
|
||||
if (name.equals("SHORT_GRASS") && Material.getMaterial(name) == null) {
|
||||
name = "GRASS";
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(Sign sign, boolean isFront, int color) {
|
||||
if (isFront) {
|
||||
sign.getSide(Side.FRONT).setColor(DyeColor.getByColor(Color.fromRGB(color)));
|
||||
}
|
||||
else {
|
||||
sign.getSide(Side.BACK).setColor(DyeColor.getByColor(Color.fromRGB(color)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWaxed(Sign sign, boolean isWaxed) {
|
||||
sign.setWaxed(isWaxed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor(Sign sign, boolean isFront) {
|
||||
if (isFront) {
|
||||
return sign.getSide(Side.FRONT).getColor().getColor().asRGB();
|
||||
}
|
||||
else {
|
||||
return sign.getSide(Side.BACK).getColor().getColor().asRGB();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlowing(Sign sign, boolean isFront) {
|
||||
if (isFront) {
|
||||
return sign.getSide(Side.FRONT).isGlowingText();
|
||||
}
|
||||
else {
|
||||
return sign.getSide(Side.BACK).isGlowingText();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWaxed(Sign sign) {
|
||||
return sign.isWaxed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getPlantSeeds(Material material) {
|
||||
switch (material) {
|
||||
case WHEAT:
|
||||
material = Material.WHEAT_SEEDS;
|
||||
break;
|
||||
case PUMPKIN_STEM:
|
||||
material = Material.PUMPKIN_SEEDS;
|
||||
break;
|
||||
case MELON_STEM:
|
||||
material = Material.MELON_SEEDS;
|
||||
break;
|
||||
case BEETROOTS:
|
||||
material = Material.BEETROOT_SEEDS;
|
||||
break;
|
||||
case TORCHFLOWER_CROP:
|
||||
material = Material.TORCHFLOWER_SEEDS;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
return material;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDecoratedPot(Material material) {
|
||||
return material == Material.DECORATED_POT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuspiciousBlock(Material material) {
|
||||
return material == Material.SUSPICIOUS_GRAVEL || material == Material.SUSPICIOUS_SAND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSign(Material material) {
|
||||
return Tag.ALL_SIGNS.isTagged(material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChiseledBookshelf(Material material) {
|
||||
return material == Material.CHISELED_BOOKSHELF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBookshelfBook(Material material) {
|
||||
return Tag.ITEMS_BOOKSHELF_BOOKS.isTagged(material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getChiseledBookshelfBook(BlockState blockState, PlayerInteractEvent event) {
|
||||
try {
|
||||
if (hasClickedPosition == null) {
|
||||
hasClickedPosition = true;
|
||||
PlayerInteractEvent.class.getMethod("getClickedPosition"); // Bukkit 1.20.1+
|
||||
}
|
||||
else if (Boolean.FALSE.equals(hasClickedPosition)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ChiseledBookshelf chiseledBookshelf = (ChiseledBookshelf) blockState;
|
||||
ItemStack book = chiseledBookshelf.getInventory().getItem(chiseledBookshelf.getSlot(event.getClickedPosition()));
|
||||
return book == null ? new ItemStack(Material.AIR) : book;
|
||||
}
|
||||
catch (Exception e) {
|
||||
hasClickedPosition = false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLine(Sign sign, int line) {
|
||||
if (line < 4) {
|
||||
return sign.getSide(Side.FRONT).getLine(line);
|
||||
}
|
||||
else {
|
||||
return sign.getSide(Side.BACK).getLine(line - 4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLine(Sign sign, int line, String string) {
|
||||
if (string == null) {
|
||||
string = "";
|
||||
}
|
||||
|
||||
if (line < 4) {
|
||||
sign.getSide(Side.FRONT).setLine(line, string);
|
||||
}
|
||||
else {
|
||||
sign.getSide(Side.BACK).setLine(line - 4, string);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSignFront(SignChangeEvent event) {
|
||||
return event.getSide().equals(Side.FRONT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getArrowMeta(Arrow arrow, ItemStack itemStack) {
|
||||
try {
|
||||
if (hasBasePotionType == null) {
|
||||
hasBasePotionType = true;
|
||||
Arrow.class.getMethod("getBasePotionType"); // Bukkit 1.20.2+
|
||||
}
|
||||
else if (Boolean.FALSE.equals(hasBasePotionType)) {
|
||||
return super.getArrowMeta(arrow, itemStack);
|
||||
}
|
||||
|
||||
PotionType potionType = arrow.getBasePotionType();
|
||||
Color color = arrow.getColor();
|
||||
if (potionType != null || color != null) {
|
||||
itemStack = new ItemStack(Material.TIPPED_ARROW);
|
||||
PotionMeta meta = (PotionMeta) itemStack.getItemMeta();
|
||||
meta.setBasePotionType(potionType);
|
||||
meta.setColor(color);
|
||||
for (PotionEffect effect : arrow.getCustomEffects()) {
|
||||
meta.addCustomEffect(effect, false);
|
||||
}
|
||||
itemStack.setItemMeta(meta);
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
catch (Exception e) {
|
||||
hasBasePotionType = false;
|
||||
return super.getArrowMeta(arrow, itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -7,6 +7,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
@ -34,7 +35,6 @@ import net.coreprotect.utility.Util;
|
|||
public class CommandHandler implements CommandExecutor {
|
||||
private static CommandHandler instance;
|
||||
private static ConcurrentHashMap<String, Boolean> versionAlert = new ConcurrentHashMap<>();
|
||||
protected static Set<Material> naturalBlocks = BlockGroup.NATURAL_BLOCKS;
|
||||
|
||||
public static CommandHandler getInstance() {
|
||||
if (instance == null) {
|
||||
|
@ -277,12 +277,7 @@ public class CommandHandler implements CommandExecutor {
|
|||
if (argument.contains(",")) {
|
||||
String[] i2 = argument.split(",");
|
||||
for (String i3 : i2) {
|
||||
if (i3.equals("#natural")) {
|
||||
for (Material block : naturalBlocks) {
|
||||
excluded.put(block, false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!checkTags(i3, excluded)) {
|
||||
Material i3_material = Util.getType(i3);
|
||||
if (i3_material != null && (i3_material.isBlock() || argAction.contains(4))) {
|
||||
excluded.put(i3_material, false);
|
||||
|
@ -306,12 +301,7 @@ public class CommandHandler implements CommandExecutor {
|
|||
}
|
||||
}
|
||||
else {
|
||||
if (argument.equals("#natural")) {
|
||||
for (Material block : naturalBlocks) {
|
||||
excluded.put(block, false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!checkTags(argument, excluded)) {
|
||||
Material iMaterial = Util.getType(argument);
|
||||
if (iMaterial != null && (iMaterial.isBlock() || argAction.contains(4))) {
|
||||
excluded.put(iMaterial, false);
|
||||
|
@ -359,7 +349,7 @@ public class CommandHandler implements CommandExecutor {
|
|||
String[] i2 = argument.split(",");
|
||||
for (String i3 : i2) {
|
||||
boolean isBlock = false;
|
||||
if (i3.equals("#natural")) {
|
||||
if (checkTags(i3)) {
|
||||
isBlock = true;
|
||||
}
|
||||
else {
|
||||
|
@ -387,7 +377,7 @@ public class CommandHandler implements CommandExecutor {
|
|||
}
|
||||
else {
|
||||
boolean isBlock = false;
|
||||
if (argument.equals("#natural")) {
|
||||
if (checkTags(argument)) {
|
||||
isBlock = true;
|
||||
}
|
||||
else {
|
||||
|
@ -630,10 +620,7 @@ public class CommandHandler implements CommandExecutor {
|
|||
if (argument.contains(",")) {
|
||||
String[] i2 = argument.split(",");
|
||||
for (String i3 : i2) {
|
||||
if (i3.equals("#natural")) {
|
||||
restricted.addAll(naturalBlocks);
|
||||
}
|
||||
else {
|
||||
if (!checkTags(argument, restricted)) {
|
||||
Material i3_material = Util.getType(i3);
|
||||
if (i3_material != null && (i3_material.isBlock() || argAction.contains(4))) {
|
||||
restricted.add(i3_material);
|
||||
|
@ -662,10 +649,7 @@ public class CommandHandler implements CommandExecutor {
|
|||
}
|
||||
}
|
||||
else {
|
||||
if (argument.equals("#natural")) {
|
||||
restricted.addAll(naturalBlocks);
|
||||
}
|
||||
else {
|
||||
if (!checkTags(argument, restricted)) {
|
||||
Material material = Util.getType(argument);
|
||||
if (material != null && (material.isBlock() || argAction.contains(4))) {
|
||||
restricted.add(material);
|
||||
|
@ -1137,6 +1121,52 @@ public class CommandHandler implements CommandExecutor {
|
|||
return worldName;
|
||||
}
|
||||
|
||||
protected static Map<String, Set<Material>> getTags() {
|
||||
Map<String, Set<Material>> tagMap = new HashMap<>();
|
||||
tagMap.put("#button", BlockGroup.BUTTONS);
|
||||
tagMap.put("#container", BlockGroup.CONTAINERS);
|
||||
tagMap.put("#door", BlockGroup.DOORS);
|
||||
tagMap.put("#natural", BlockGroup.NATURAL_BLOCKS);
|
||||
tagMap.put("#pressure_plate", BlockGroup.PRESSURE_PLATES);
|
||||
tagMap.put("#shulker_box", BlockGroup.SHULKER_BOXES);
|
||||
return tagMap;
|
||||
}
|
||||
|
||||
protected static boolean checkTags(String argument) {
|
||||
return getTags().containsKey(argument);
|
||||
}
|
||||
|
||||
protected static boolean checkTags(String argument, Map<Object, Boolean> list) {
|
||||
for (Entry<String, Set<Material>> entry : getTags().entrySet()) {
|
||||
String tag = entry.getKey();
|
||||
Set<Material> materials = entry.getValue();
|
||||
|
||||
if (argument.equals(tag)) {
|
||||
for (Material block : materials) {
|
||||
list.put(block, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected static boolean checkTags(String argument, List<Object> list) {
|
||||
for (Entry<String, Set<Material>> entry : getTags().entrySet()) {
|
||||
String tag = entry.getKey();
|
||||
Set<Material> materials = entry.getValue();
|
||||
|
||||
if (argument.equals(tag)) {
|
||||
list.addAll(materials);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void validUserCheck(List<String> users, String user) {
|
||||
List<String> badUsers = Arrays.asList("n", "noisy", "v", "verbose", "#v", "#verbose", "#silent", "#preview", "#preview_cancel", "#count", "#sum");
|
||||
String check = user.replaceAll("[\\s'\"]", "");
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.coreprotect.command;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.Connection;
|
||||
import java.sql.Statement;
|
||||
import java.text.NumberFormat;
|
||||
|
@ -356,14 +357,9 @@ public class LookupCommand {
|
|||
ConfigHandler.lookupThrottle.put(player2.getName(), new Object[] { true, System.currentTimeMillis() });
|
||||
if (connection != null) {
|
||||
Statement statement = connection.createStatement();
|
||||
String blockdata = ChestTransactionLookup.performLookup(command.getName(), statement, location, player2, p2, finalLimit, false);
|
||||
if (blockdata.contains("\n")) {
|
||||
for (String b : blockdata.split("\n")) {
|
||||
Chat.sendComponent(player2, b);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Chat.sendComponent(player2, blockdata);
|
||||
List<String> blockData = ChestTransactionLookup.performLookup(command.getName(), statement, location, player2, p2, finalLimit, false);
|
||||
for (String data : blockData) {
|
||||
Chat.sendComponent(player2, data);
|
||||
}
|
||||
statement.close();
|
||||
}
|
||||
|
@ -906,7 +902,7 @@ public class LookupCommand {
|
|||
for (String[] data : lookupList) {
|
||||
String time = data[0];
|
||||
String dplayer = data[1];
|
||||
String dtype = data[5];
|
||||
int dtype = Integer.parseInt(data[5]);
|
||||
int ddata = Integer.parseInt(data[6]);
|
||||
int daction = Integer.parseInt(data[7]);
|
||||
int amount = Integer.parseInt(data[10]);
|
||||
|
@ -916,8 +912,10 @@ public class LookupCommand {
|
|||
int z = Integer.parseInt(data[4]);
|
||||
String rbd = ((Integer.parseInt(data[8]) == 2 || Integer.parseInt(data[8]) == 3) ? Color.STRIKETHROUGH : "");
|
||||
String timeago = Util.getTimeSince(Integer.parseInt(time), unixtimestamp, true);
|
||||
Material blockType = Util.itemFilter(Util.getType(Integer.parseInt(dtype)), (Integer.parseInt(data[13]) == 0));
|
||||
Material blockType = Util.itemFilter(Util.getType(dtype), (Integer.parseInt(data[13]) == 0));
|
||||
String dname = Util.nameFilter(blockType.name().toLowerCase(Locale.ROOT), ddata);
|
||||
byte[] metadata = data[11] == null ? null : data[11].getBytes(StandardCharsets.ISO_8859_1);
|
||||
String tooltip = Util.getEnchantments(metadata, dtype, amount);
|
||||
|
||||
String selector = Selector.FIRST;
|
||||
String tag = Color.WHITE + "-";
|
||||
|
@ -946,7 +944,7 @@ public class LookupCommand {
|
|||
tag = (daction == 0 ? Color.GREEN + "+" : Color.RED + "-");
|
||||
}
|
||||
|
||||
Chat.sendComponent(player2, timeago + " " + tag + " " + Phrase.build(Phrase.LOOKUP_CONTAINER, Color.DARK_AQUA + rbd + dplayer + Color.WHITE + rbd, "x" + amount, Color.DARK_AQUA + rbd + dname + Color.WHITE, selector));
|
||||
Chat.sendComponent(player2, timeago + " " + tag + " " + Phrase.build(Phrase.LOOKUP_CONTAINER, Color.DARK_AQUA + rbd + dplayer + Color.WHITE + rbd, "x" + amount, Util.createTooltip(Color.DARK_AQUA + rbd + dname, tooltip) + Color.WHITE, selector));
|
||||
PluginChannelListener.getInstance().sendData(player2, Integer.parseInt(time), Phrase.LOOKUP_CONTAINER, selector, dplayer, dname, amount, x, y, z, wid, rbd, true, tag.contains("+"));
|
||||
}
|
||||
}
|
||||
|
@ -963,7 +961,7 @@ public class LookupCommand {
|
|||
int x = Integer.parseInt(data[2]);
|
||||
int y = Integer.parseInt(data[3]);
|
||||
int z = Integer.parseInt(data[4]);
|
||||
String dtype = data[5];
|
||||
int dtype = Integer.parseInt(data[5]);
|
||||
int ddata = Integer.parseInt(data[6]);
|
||||
int daction = Integer.parseInt(data[7]);
|
||||
int wid = Integer.parseInt(data[9]);
|
||||
|
@ -983,8 +981,7 @@ public class LookupCommand {
|
|||
String dname = "";
|
||||
boolean isPlayer = false;
|
||||
if (daction == 3 && !finalArgAction.contains(11) && amount == -1) {
|
||||
int dTypeInt = Integer.parseInt(dtype);
|
||||
if (dTypeInt == 0) {
|
||||
if (dtype == 0) {
|
||||
if (ConfigHandler.playerIdCacheReversed.get(ddata) == null) {
|
||||
UserStatement.loadName(connection, ddata);
|
||||
}
|
||||
|
@ -992,11 +989,11 @@ public class LookupCommand {
|
|||
isPlayer = true;
|
||||
}
|
||||
else {
|
||||
dname = Util.getEntityType(dTypeInt).name();
|
||||
dname = Util.getEntityType(dtype).name();
|
||||
}
|
||||
}
|
||||
else {
|
||||
dname = Util.getType(Integer.parseInt(dtype)).name().toLowerCase(Locale.ROOT);
|
||||
dname = Util.getType(dtype).name().toLowerCase(Locale.ROOT);
|
||||
dname = Util.nameFilter(dname, ddata);
|
||||
}
|
||||
if (dname.length() > 0 && !isPlayer) {
|
||||
|
@ -1015,6 +1012,9 @@ public class LookupCommand {
|
|||
String selector = Selector.FIRST;
|
||||
String action = "a:block";
|
||||
if (finalArgAction.contains(4) || finalArgAction.contains(5) || finalArgAction.contains(11) || amount > -1) {
|
||||
byte[] metadata = data[11] == null ? null : data[11].getBytes(StandardCharsets.ISO_8859_1);
|
||||
String tooltip = Util.getEnchantments(metadata, dtype, amount);
|
||||
|
||||
if (daction == 2 || daction == 3) {
|
||||
phrase = Phrase.LOOKUP_ITEM; // {picked up|dropped}
|
||||
selector = (daction != 2 ? Selector.FIRST : Selector.SECOND);
|
||||
|
@ -1040,7 +1040,7 @@ public class LookupCommand {
|
|||
action = "a:container";
|
||||
}
|
||||
|
||||
Chat.sendComponent(player2, timeago + " " + tag + " " + Phrase.build(phrase, Color.DARK_AQUA + rbd + dplayer + Color.WHITE + rbd, "x" + amount, Color.DARK_AQUA + rbd + dname + Color.WHITE, selector));
|
||||
Chat.sendComponent(player2, timeago + " " + tag + " " + Phrase.build(phrase, Color.DARK_AQUA + rbd + dplayer + Color.WHITE + rbd, "x" + amount, Util.createTooltip(Color.DARK_AQUA + rbd + dname, tooltip) + Color.WHITE, selector));
|
||||
PluginChannelListener.getInstance().sendData(player2, Integer.parseInt(time), phrase, selector, dplayer, dname, (tag.contains("+") ? 1 : -1), x, y, z, wid, rbd, action.contains("container"), tag.contains("+"));
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -8,11 +8,16 @@ import java.sql.ResultSetMetaData;
|
|||
import java.text.NumberFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.consumer.Consumer;
|
||||
|
@ -31,13 +36,20 @@ public class PurgeCommand extends Consumer {
|
|||
int resultc = args.length;
|
||||
Location location = CommandHandler.parseLocation(player, args);
|
||||
final Integer[] argRadius = CommandHandler.parseRadius(args, player, location);
|
||||
final List<Integer> argAction = CommandHandler.parseAction(args);
|
||||
final List<Object> argBlocks = CommandHandler.parseRestricted(player, args, argAction);
|
||||
final Map<Object, Boolean> argExclude = CommandHandler.parseExcluded(player, args, argAction);
|
||||
final List<String> argExcludeUsers = CommandHandler.parseExcludedUsers(player, args);
|
||||
final long[] argTime = CommandHandler.parseTime(args);
|
||||
final int argWid = CommandHandler.parseWorld(args, false, false);
|
||||
final List<Integer> argAction = CommandHandler.parseAction(args);
|
||||
final List<Integer> supportedActions = Arrays.asList();
|
||||
long startTime = argTime[1] > 0 ? argTime[0] : 0;
|
||||
long endTime = argTime[1] > 0 ? argTime[1] : argTime[0];
|
||||
|
||||
if (argBlocks == null || argExclude == null || argExcludeUsers == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ConfigHandler.converterRunning) {
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
||||
return;
|
||||
|
@ -67,6 +79,14 @@ public class PurgeCommand extends Consumer {
|
|||
Chat.sendMessage(player, new ChatMessage(Phrase.build(Phrase.WORLD_NOT_FOUND, worldName)).build());
|
||||
return;
|
||||
}
|
||||
if (player instanceof Player && endTime < 2592000) {
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_MINIMUM_TIME, "30", Selector.FIRST)); // 30 days
|
||||
return;
|
||||
}
|
||||
else if (endTime < 86400) {
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_MINIMUM_TIME, "24", Selector.SECOND)); // 24 hours
|
||||
return;
|
||||
}
|
||||
for (int action : argAction) {
|
||||
if (!supportedActions.contains(action)) {
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ACTION_NOT_SUPPORTED));
|
||||
|
@ -74,12 +94,70 @@ public class PurgeCommand extends Consumer {
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (player instanceof Player && endTime < 2592000) {
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_MINIMUM_TIME, "30", Selector.FIRST)); // 30 days
|
||||
return;
|
||||
|
||||
StringBuilder restrict = new StringBuilder();
|
||||
String includeBlock = "";
|
||||
String includeEntity = "";
|
||||
boolean hasBlock = false;
|
||||
boolean item = false;
|
||||
boolean entity = false;
|
||||
int restrictCount = 0;
|
||||
|
||||
if (argBlocks.size() > 0) {
|
||||
StringBuilder includeListMaterial = new StringBuilder();
|
||||
StringBuilder includeListEntity = new StringBuilder();
|
||||
|
||||
for (Object restrictTarget : argBlocks) {
|
||||
String targetName = "";
|
||||
|
||||
if (restrictTarget instanceof Material) {
|
||||
targetName = ((Material) restrictTarget).name();
|
||||
if (includeListMaterial.length() == 0) {
|
||||
includeListMaterial = includeListMaterial.append(Util.getBlockId(targetName, false));
|
||||
}
|
||||
else {
|
||||
includeListMaterial.append(",").append(Util.getBlockId(targetName, false));
|
||||
}
|
||||
|
||||
/* Include legacy IDs */
|
||||
int legacyId = BukkitAdapter.ADAPTER.getLegacyBlockId((Material) restrictTarget);
|
||||
if (legacyId > 0) {
|
||||
includeListMaterial.append(",").append(legacyId);
|
||||
}
|
||||
|
||||
targetName = ((Material) restrictTarget).name().toLowerCase(Locale.ROOT);
|
||||
item = (!item ? !(((Material) restrictTarget).isBlock()) : item);
|
||||
hasBlock = true;
|
||||
}
|
||||
else if (restrictTarget instanceof EntityType) {
|
||||
targetName = ((EntityType) restrictTarget).name();
|
||||
if (includeListEntity.length() == 0) {
|
||||
includeListEntity = includeListEntity.append(Util.getEntityId(targetName, false));
|
||||
}
|
||||
else {
|
||||
includeListEntity.append(",").append(Util.getEntityId(targetName, false));
|
||||
}
|
||||
|
||||
targetName = ((EntityType) restrictTarget).name().toLowerCase(Locale.ROOT);
|
||||
entity = true;
|
||||
}
|
||||
|
||||
if (restrictCount == 0) {
|
||||
restrict = restrict.append("" + targetName + "");
|
||||
}
|
||||
else {
|
||||
restrict.append(", ").append(targetName);
|
||||
}
|
||||
|
||||
restrictCount++;
|
||||
}
|
||||
|
||||
includeBlock = includeListMaterial.toString();
|
||||
includeEntity = includeListEntity.toString();
|
||||
}
|
||||
else if (endTime < 86400) {
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_MINIMUM_TIME, "24", Selector.SECOND)); // 24 hours
|
||||
|
||||
if (entity) {
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ACTION_NOT_SUPPORTED));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -90,7 +168,12 @@ public class PurgeCommand extends Consumer {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final StringBuilder restrictTargets = restrict;
|
||||
final String includeBlockFinal = includeBlock;
|
||||
final boolean optimize = optimizeCheck;
|
||||
final boolean hasBlockRestriction = hasBlock;
|
||||
final int restrictCountFinal = restrictCount;
|
||||
|
||||
class BasicThread implements Runnable {
|
||||
|
||||
|
@ -123,6 +206,11 @@ public class PurgeCommand extends Consumer {
|
|||
else {
|
||||
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_STARTED, "#global"));
|
||||
}
|
||||
|
||||
if (hasBlockRestriction) {
|
||||
Chat.sendGlobalMessage(player, Phrase.build(Phrase.ROLLBACK_INCLUDE, restrictTargets.toString(), Selector.FIRST, Selector.FIRST, (restrictCountFinal == 1 ? Selector.FIRST : Selector.SECOND))); // include
|
||||
}
|
||||
|
||||
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_NOTICE_1));
|
||||
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_NOTICE_2));
|
||||
|
||||
|
@ -172,6 +260,7 @@ public class PurgeCommand extends Consumer {
|
|||
|
||||
List<String> purgeTables = Arrays.asList("sign", "container", "item", "skull", "session", "chat", "command", "entity", "block");
|
||||
List<String> worldTables = Arrays.asList("sign", "container", "item", "session", "chat", "command", "block");
|
||||
List<String> restrictTables = Arrays.asList("block");
|
||||
List<String> excludeTables = Arrays.asList("database_lock"); // don't insert data into these tables
|
||||
for (String table : ConfigHandler.databaseTables) {
|
||||
String tableName = table.replaceAll("_", " ");
|
||||
|
@ -198,11 +287,16 @@ public class PurgeCommand extends Consumer {
|
|||
try {
|
||||
String timeLimit = "";
|
||||
if (purgeTables.contains(table)) {
|
||||
String blockRestriction = "";
|
||||
if (hasBlockRestriction && restrictTables.contains(table)) {
|
||||
blockRestriction = "type IN(" + includeBlockFinal + ") AND ";
|
||||
}
|
||||
|
||||
if (argWid > 0 && worldTables.contains(table)) {
|
||||
timeLimit = " WHERE (wid = '" + argWid + "' AND (time >= '" + timeEnd + "' OR time < '" + timeStart + "')) OR wid != '" + argWid + "'";
|
||||
timeLimit = " WHERE (" + blockRestriction + "wid = '" + argWid + "' AND (time >= '" + timeEnd + "' OR time < '" + timeStart + "')) OR (" + blockRestriction + "wid != '" + argWid + "')";
|
||||
}
|
||||
else if (argWid == 0) {
|
||||
timeLimit = " WHERE (time >= '" + timeEnd + "' OR time < '" + timeStart + "')";
|
||||
timeLimit = " WHERE " + blockRestriction + "(time >= '" + timeEnd + "' OR time < '" + timeStart + "')";
|
||||
}
|
||||
}
|
||||
query = "INSERT INTO " + purgePrefix + table + " SELECT " + columns + " FROM " + ConfigHandler.prefix + table + timeLimit;
|
||||
|
@ -256,6 +350,14 @@ public class PurgeCommand extends Consumer {
|
|||
try {
|
||||
boolean purge = purgeTables.contains(table);
|
||||
|
||||
String blockRestriction = "";
|
||||
if (hasBlockRestriction && restrictTables.contains(table)) {
|
||||
blockRestriction = "type IN(" + includeBlockFinal + ") AND ";
|
||||
}
|
||||
else if (hasBlockRestriction) {
|
||||
purge = false;
|
||||
}
|
||||
|
||||
String worldRestriction = "";
|
||||
if (argWid > 0 && worldTables.contains(table)) {
|
||||
worldRestriction = " AND wid = '" + argWid + "'";
|
||||
|
@ -265,7 +367,7 @@ public class PurgeCommand extends Consumer {
|
|||
}
|
||||
|
||||
if (purge) {
|
||||
query = "DELETE FROM " + purgePrefix + table + " WHERE time < '" + timeEnd + "' AND time >= '" + timeStart + "'" + worldRestriction;
|
||||
query = "DELETE FROM " + purgePrefix + table + " WHERE " + blockRestriction + "time < '" + timeEnd + "' AND time >= '" + timeStart + "'" + worldRestriction;
|
||||
preparedStmt = connection.prepareStatement(query);
|
||||
preparedStmt.execute();
|
||||
preparedStmt.close();
|
||||
|
@ -315,6 +417,14 @@ public class PurgeCommand extends Consumer {
|
|||
try {
|
||||
boolean purge = purgeTables.contains(table);
|
||||
|
||||
String blockRestriction = "";
|
||||
if (hasBlockRestriction && restrictTables.contains(table)) {
|
||||
blockRestriction = "type IN(" + includeBlockFinal + ") AND ";
|
||||
}
|
||||
else if (hasBlockRestriction) {
|
||||
purge = false;
|
||||
}
|
||||
|
||||
String worldRestriction = "";
|
||||
if (argWid > 0 && worldTables.contains(table)) {
|
||||
worldRestriction = " AND wid = '" + argWid + "'";
|
||||
|
@ -324,7 +434,7 @@ public class PurgeCommand extends Consumer {
|
|||
}
|
||||
|
||||
if (purge) {
|
||||
query = "DELETE FROM " + ConfigHandler.prefix + table + " WHERE time < '" + timeEnd + "' AND time >= '" + timeStart + "'" + worldRestriction;
|
||||
query = "DELETE FROM " + ConfigHandler.prefix + table + " WHERE " + blockRestriction + "time < '" + timeEnd + "' AND time >= '" + timeStart + "'" + worldRestriction;
|
||||
preparedStmt = connection.prepareStatement(query);
|
||||
preparedStmt.execute();
|
||||
removed = removed + preparedStmt.getUpdateCount();
|
||||
|
|
|
@ -23,8 +23,8 @@ import net.coreprotect.config.Config;
|
|||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.ContainerRollback;
|
||||
import net.coreprotect.database.Database;
|
||||
import net.coreprotect.database.Rollback;
|
||||
import net.coreprotect.database.lookup.PlayerLookup;
|
||||
import net.coreprotect.database.rollback.Rollback;
|
||||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.language.Selector;
|
||||
import net.coreprotect.utility.Chat;
|
||||
|
|
|
@ -301,7 +301,7 @@ public class TabHandler implements TabCompleter {
|
|||
|
||||
if (materials == null) {
|
||||
List<Material> addList = Arrays.asList(Material.ARMOR_STAND);
|
||||
List<Material> excludeList = Arrays.asList(Material.GRASS);
|
||||
List<Material> excludeList = Arrays.asList();
|
||||
Set<String> materialList = new HashSet<>();
|
||||
|
||||
Material[] materialValues = Material.values();
|
||||
|
@ -317,6 +317,11 @@ public class TabHandler implements TabCompleter {
|
|||
materialList.add(add.name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
// add custom tags
|
||||
for (String tag : CommandHandler.getTags().keySet()) {
|
||||
materialList.add(tag);
|
||||
}
|
||||
|
||||
materials = new ArrayList<>(materialList);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,10 @@ import org.bukkit.World;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.ChatMessage;
|
||||
import net.coreprotect.utility.Color;
|
||||
|
@ -99,12 +101,14 @@ public class TeleportCommand {
|
|||
|
||||
int chunkX = location.getBlockX() >> 4;
|
||||
int chunkZ = location.getBlockZ() >> 4;
|
||||
if (location.getWorld().isChunkLoaded(chunkX, chunkZ) == false) {
|
||||
location.getWorld().getChunkAt(location);
|
||||
}
|
||||
Scheduler.runTask(CoreProtect.getInstance(), () -> {
|
||||
if (!location.getWorld().isChunkLoaded(chunkX, chunkZ)) {
|
||||
location.getWorld().getChunkAt(location);
|
||||
}
|
||||
|
||||
// Teleport the player to a safe location
|
||||
Teleport.performSafeTeleport(((Player) player), location, true);
|
||||
// Teleport the player to a safe location
|
||||
Teleport.performSafeTeleport(((Player) player), location, true);
|
||||
}, location);
|
||||
|
||||
ConfigHandler.teleportThrottle.put(player.getName(), new Object[] { false, System.currentTimeMillis() });
|
||||
}
|
||||
|
|
|
@ -20,13 +20,13 @@ import org.bukkit.World;
|
|||
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.language.Language;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
|
||||
public class Config extends Language {
|
||||
|
||||
private static final Map<String, String[]> HEADERS = new HashMap<>();
|
||||
private static final Map<String, String> DEFAULT_VALUES = new LinkedHashMap<>();
|
||||
private static final Map<String, Config> CONFIG_BY_WORLD_NAME = new HashMap<>();
|
||||
private static final WeakHashMap<World, Config> CONFIG_BY_WORLD = new WeakHashMap<>();
|
||||
private static final String DEFAULT_FILE_HEADER = "# CoreProtect Config";
|
||||
public static final String LINE_SEPARATOR = "\n";
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class Config extends Language {
|
|||
public String MYSQL_USERNAME;
|
||||
public String MYSQL_PASSWORD;
|
||||
public String LANGUAGE;
|
||||
public boolean ENABLE_AWE;
|
||||
public boolean ENABLE_SSL;
|
||||
public boolean DISABLE_WAL;
|
||||
public boolean HOVER_EVENTS;
|
||||
public boolean DATABASE_LOCK;
|
||||
|
@ -85,8 +85,10 @@ public class Config extends Language {
|
|||
public boolean PLAYER_MESSAGES;
|
||||
public boolean PLAYER_COMMANDS;
|
||||
public boolean PLAYER_SESSIONS;
|
||||
public boolean UNKNOWN_LOGGING;
|
||||
public boolean USERNAME_CHANGES;
|
||||
public boolean WORLDEDIT;
|
||||
public int MAXIMUM_POOL_SIZE;
|
||||
public int MYSQL_PORT;
|
||||
public int DEFAULT_RADIUS;
|
||||
public int MAX_RADIUS;
|
||||
|
@ -165,7 +167,7 @@ public class Config extends Language {
|
|||
HEADERS.put("sign-text", new String[] { "# Logs text on signs. If disabled, signs will be blank when rolled back." });
|
||||
HEADERS.put("buckets", new String[] { "# Logs lava and water sources placed/removed by players who are using buckets." });
|
||||
HEADERS.put("leaf-decay", new String[] { "# Logs natural tree leaf decay." });
|
||||
HEADERS.put("tree-growth", new String[] { "# Logs tree growth. Trees are linked to the player who planted the sappling." });
|
||||
HEADERS.put("tree-growth", new String[] { "# Logs tree growth. Trees are linked to the player who planted the sapling." });
|
||||
HEADERS.put("mushroom-growth", new String[] { "# Logs mushroom growth." });
|
||||
HEADERS.put("vine-growth", new String[] { "# Logs natural vine growth." });
|
||||
HEADERS.put("sculk-spread", new String[] { "# Logs the spread of sculk blocks from sculk catalysts." });
|
||||
|
@ -186,7 +188,7 @@ public class Config extends Language {
|
|||
}
|
||||
|
||||
private void readValues() {
|
||||
this.ENABLE_AWE = this.getBoolean("enable-awe", false);
|
||||
this.ENABLE_SSL = this.getBoolean("enable-ssl", false);
|
||||
this.DISABLE_WAL = this.getBoolean("disable-wal", false);
|
||||
this.HOVER_EVENTS = this.getBoolean("hover-events", true);
|
||||
this.DATABASE_LOCK = this.getBoolean("database-lock", true);
|
||||
|
@ -194,6 +196,8 @@ public class Config extends Language {
|
|||
this.HOPPER_FILTER_META = this.getBoolean("hopper-filter-meta", false);
|
||||
this.EXCLUDE_TNT = this.getBoolean("exclude-tnt", false);
|
||||
this.NETWORK_DEBUG = this.getBoolean("network-debug", false);
|
||||
this.UNKNOWN_LOGGING = this.getBoolean("unknown-logging", false);
|
||||
this.MAXIMUM_POOL_SIZE = this.getInt("maximum-pool-size", 10);
|
||||
this.DONATION_KEY = this.getString("donation-key");
|
||||
this.MYSQL = this.getBoolean("use-mysql");
|
||||
this.PREFIX = this.getString("table-prefix");
|
||||
|
@ -255,10 +259,14 @@ public class Config extends Language {
|
|||
|
||||
// returns a world specific config if it exists, otherwise the global config
|
||||
public static Config getConfig(final World world) {
|
||||
Config ret = CONFIG_BY_WORLD.get(world);
|
||||
return getConfig(world.getName());
|
||||
}
|
||||
|
||||
public static Config getConfig(final String worldName) {
|
||||
Config ret = CONFIG_BY_WORLD_NAME.get(worldName);
|
||||
if (ret == null) {
|
||||
ret = CONFIG_BY_WORLD_NAME.getOrDefault(world.getName(), GLOBAL);
|
||||
CONFIG_BY_WORLD.put(world, ret);
|
||||
ret = CONFIG_BY_WORLD_NAME.getOrDefault(worldName, GLOBAL);
|
||||
CONFIG_BY_WORLD_NAME.put(worldName, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -310,7 +318,7 @@ public class Config extends Language {
|
|||
|
||||
configured = configured.replaceAll("[^0-9]", "");
|
||||
|
||||
return configured.isEmpty() ? 0 : Integer.parseInt(configured);
|
||||
return configured.isEmpty() ? dfl : Integer.parseInt(configured);
|
||||
}
|
||||
|
||||
private String getString(final String key) {
|
||||
|
@ -383,7 +391,7 @@ public class Config extends Language {
|
|||
// for now this solution is good enough to ensure we only modify on the main thread
|
||||
final CompletableFuture<Void> complete = new CompletableFuture<>();
|
||||
|
||||
Bukkit.getScheduler().runTask(CoreProtect.getInstance(), () -> {
|
||||
Scheduler.runTask(CoreProtect.getInstance(), () -> {
|
||||
try {
|
||||
parseConfig(data);
|
||||
}
|
||||
|
@ -402,7 +410,6 @@ public class Config extends Language {
|
|||
}
|
||||
|
||||
CONFIG_BY_WORLD_NAME.clear();
|
||||
CONFIG_BY_WORLD.clear();
|
||||
|
||||
// we need to load global first since it is used for config defaults
|
||||
final byte[] defaultData = data.get("config");
|
||||
|
|
|
@ -43,7 +43,7 @@ public class ConfigHandler extends Queue {
|
|||
public static final String EDITION_BRANCH = Util.getBranch();
|
||||
public static final String EDITION_NAME = Util.getPluginName();
|
||||
public static final String JAVA_VERSION = "11.0";
|
||||
public static final String SPIGOT_VERSION = "1.14";
|
||||
public static final String SPIGOT_VERSION = "1.15";
|
||||
public static String path = "plugins/CoreProtect/";
|
||||
public static String sqlite = "database.db";
|
||||
public static String host = "127.0.0.1";
|
||||
|
@ -52,9 +52,12 @@ public class ConfigHandler extends Queue {
|
|||
public static String username = "root";
|
||||
public static String password = "";
|
||||
public static String prefix = "co_";
|
||||
public static int maximumPoolSize = 10;
|
||||
|
||||
public static HikariDataSource hikariDataSource = null;
|
||||
public static final boolean isSpigot = Util.isSpigot();
|
||||
public static final boolean isPaper = Util.isPaper();
|
||||
public static final boolean isFolia = Util.isFolia();
|
||||
public static volatile boolean serverRunning = false;
|
||||
public static volatile boolean converterRunning = false;
|
||||
public static volatile boolean purgeRunning = false;
|
||||
|
@ -98,6 +101,7 @@ public class ConfigHandler extends Queue {
|
|||
public static ConcurrentHashMap<String, List<ItemStack>> itemsSell = new ConcurrentHashMap<>();
|
||||
public static ConcurrentHashMap<String, List<ItemStack>> itemsBuy = new ConcurrentHashMap<>();
|
||||
public static ConcurrentHashMap<String, Object[]> hopperAbort = new ConcurrentHashMap<>();
|
||||
public static ConcurrentHashMap<String, Object[]> hopperSuccess = new ConcurrentHashMap<>();
|
||||
public static Map<String, List<ItemStack[]>> forceContainer = syncMap();
|
||||
public static Map<String, Integer> lookupType = syncMap();
|
||||
public static Map<String, Object[]> lookupThrottle = syncMap();
|
||||
|
@ -118,7 +122,7 @@ public class ConfigHandler extends Queue {
|
|||
public static Map<Integer, String> playerIdCacheReversed = syncMap();
|
||||
public static Map<String, List<Object>> lastRollback = syncMap();
|
||||
public static Map<String, Boolean> activeRollbacks = syncMap();
|
||||
public static Map<String, Object[]> entityBlockMapper = syncMap();
|
||||
public static Map<String, Object[]> entityBlockMapper = new ConcurrentHashMap<>();
|
||||
public static ConcurrentHashMap<Long, Long> populatedChunks = new ConcurrentHashMap<>();
|
||||
public static ConcurrentHashMap<String, String> language = new ConcurrentHashMap<>();
|
||||
public static List<String> databaseTables = new ArrayList<>();
|
||||
|
@ -173,6 +177,7 @@ public class ConfigHandler extends Queue {
|
|||
ConfigHandler.database = Config.getGlobal().MYSQL_DATABASE;
|
||||
ConfigHandler.username = Config.getGlobal().MYSQL_USERNAME;
|
||||
ConfigHandler.password = Config.getGlobal().MYSQL_PASSWORD;
|
||||
ConfigHandler.maximumPoolSize = Config.getGlobal().MAXIMUM_POOL_SIZE;
|
||||
ConfigHandler.prefix = Config.getGlobal().PREFIX;
|
||||
|
||||
ConfigHandler.loadBlacklist(); // Load the blacklist file if it exists.
|
||||
|
@ -229,8 +234,8 @@ public class ConfigHandler extends Queue {
|
|||
config.setJdbcUrl("jdbc:mysql://" + ConfigHandler.host + ":" + ConfigHandler.port + "/" + ConfigHandler.database);
|
||||
config.setUsername(ConfigHandler.username);
|
||||
config.setPassword(ConfigHandler.password);
|
||||
config.setMaxLifetime(300000);
|
||||
config.setKeepaliveTime(60000);
|
||||
config.setMaximumPoolSize(ConfigHandler.maximumPoolSize);
|
||||
config.setMaxLifetime(60000);
|
||||
config.addDataSourceProperty("characterEncoding", "UTF-8");
|
||||
config.addDataSourceProperty("connectionTimeout", "10000");
|
||||
/* https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration */
|
||||
|
@ -245,7 +250,7 @@ public class ConfigHandler extends Queue {
|
|||
config.addDataSourceProperty("maintainTimeStats", "false");
|
||||
/* Disable SSL to suppress the unverified server identity warning */
|
||||
config.addDataSourceProperty("allowPublicKeyRetrieval", "true");
|
||||
config.addDataSourceProperty("useSSL", "false");
|
||||
config.addDataSourceProperty("useSSL", Config.getGlobal().ENABLE_SSL);
|
||||
|
||||
ConfigHandler.hikariDataSource = new HikariDataSource(config);
|
||||
}
|
||||
|
@ -414,7 +419,10 @@ public class ConfigHandler extends Queue {
|
|||
|
||||
ConfigHandler.loadConfig(); // Load (or create) the configuration file.
|
||||
ConfigHandler.loadDatabase(); // Initialize MySQL and create tables if necessary.
|
||||
ListenerHandler.registerNetworking(); // Register channels for networking API
|
||||
|
||||
if (startup) {
|
||||
ListenerHandler.registerNetworking(); // Register channels for networking API
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -24,6 +24,7 @@ import net.coreprotect.config.ConfigHandler;
|
|||
import net.coreprotect.consumer.process.Process;
|
||||
import net.coreprotect.listener.block.BlockUtil;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class Queue {
|
||||
|
@ -85,7 +86,7 @@ public class Queue {
|
|||
}
|
||||
|
||||
protected static void queueBlockBreakValidate(final String user, final Block block, final BlockState blockState, final Material type, final String blockData, final int extraData, int ticks) {
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CoreProtect.getInstance(), () -> {
|
||||
Scheduler.scheduleSyncDelayedTask(CoreProtect.getInstance(), () -> {
|
||||
try {
|
||||
if (!block.getType().equals(type)) {
|
||||
queueBlockBreak(user, blockState, type, blockData, null, extraData, 0);
|
||||
|
@ -94,7 +95,7 @@ public class Queue {
|
|||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, ticks);
|
||||
}, block.getLocation(), ticks);
|
||||
}
|
||||
|
||||
protected static void queueBlockBreak(String user, BlockState block, Material type, String blockData, Material breakType, int extraData, int blockNumber) {
|
||||
|
@ -178,18 +179,18 @@ public class Queue {
|
|||
}
|
||||
|
||||
protected static void queueBlockPlaceDelayed(final String user, final Location placed, final Material type, final String blockData, final BlockState replaced, int ticks) {
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CoreProtect.getInstance(), () -> {
|
||||
Scheduler.scheduleSyncDelayedTask(CoreProtect.getInstance(), () -> {
|
||||
try {
|
||||
queueBlockPlace(user, placed.getBlock().getState(), type, replaced, null, -1, 0, blockData);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, ticks);
|
||||
}, placed, ticks);
|
||||
}
|
||||
|
||||
protected static void queueBlockPlaceValidate(final String user, final BlockState blockLocation, final Block block, final BlockState blockReplaced, final Material forceT, final int forceD, final int forceData, final String blockData, int ticks) {
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CoreProtect.getInstance(), () -> {
|
||||
Scheduler.scheduleSyncDelayedTask(CoreProtect.getInstance(), () -> {
|
||||
try {
|
||||
Material blockType = block.getType();
|
||||
if (blockType.equals(forceT)) {
|
||||
|
@ -204,11 +205,11 @@ public class Queue {
|
|||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, ticks);
|
||||
}, blockLocation.getLocation(), ticks);
|
||||
}
|
||||
|
||||
protected static void queueBlockGravityValidate(final String user, final Location location, final Block block, final Material blockType, int ticks) {
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CoreProtect.getInstance(), () -> {
|
||||
Scheduler.scheduleSyncDelayedTask(CoreProtect.getInstance(), () -> {
|
||||
try {
|
||||
Block placementBlock = BlockUtil.gravityScan(location, blockType, user);
|
||||
if (!block.equals(placementBlock)) {
|
||||
|
@ -218,7 +219,7 @@ public class Queue {
|
|||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, ticks);
|
||||
}, location, ticks);
|
||||
}
|
||||
|
||||
protected static void queueContainerBreak(String user, Location location, Material type, ItemStack[] oldInventory) {
|
||||
|
@ -351,7 +352,7 @@ public class Queue {
|
|||
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, location);
|
||||
}
|
||||
|
||||
protected static void queueSignText(String user, Location location, int action, int color, boolean glowing, String line1, String line2, String line3, String line4, int offset) {
|
||||
protected static void queueSignText(String user, Location location, int action, int color, int colorSecondary, boolean frontGlowing, boolean backGlowing, boolean isWaxed, boolean isFront, String line1, String line2, String line3, String line4, String line5, String line6, String line7, String line8, int offset) {
|
||||
/*
|
||||
if (line1.length() == 0 && line2.length() == 0 && line3.length() == 0 && line4.length() == 0) {
|
||||
return;
|
||||
|
@ -360,7 +361,7 @@ public class Queue {
|
|||
int currentConsumer = Consumer.currentConsumer;
|
||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||
addConsumer(currentConsumer, new Object[] { consumerId, Process.SIGN_TEXT, null, color, null, action, offset, null });
|
||||
Consumer.consumerSigns.get(currentConsumer).put(consumerId, new Object[] { (glowing == true ? 1 : 0), line1, line2, line3, line4 });
|
||||
Consumer.consumerSigns.get(currentConsumer).put(consumerId, new Object[] { colorSecondary, Util.getSignData(frontGlowing, backGlowing), isWaxed, isFront, line1, line2, line3, line4, line5, line6, line7, line8 });
|
||||
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, location);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
package net.coreprotect.consumer.process;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
|
@ -41,6 +47,42 @@ class ContainerTransactionProcess {
|
|||
ConfigHandler.transactingChest.remove(transactingChestId);
|
||||
}
|
||||
}
|
||||
else if (loggingChestId.startsWith("#hopper")) {
|
||||
List<Object> transactingChest = ConfigHandler.transactingChest.get(transactingChestId);
|
||||
if (force_size == 0 && ConfigHandler.oldContainer.getOrDefault(loggingChestId, Collections.synchronizedList(new ArrayList<>())).size() == 1 && transactingChest != null && transactingChest.isEmpty()) {
|
||||
int loopCount = ConfigHandler.loggingChest.getOrDefault(loggingChestId, 0);
|
||||
int maxInventorySize = (99 * 54);
|
||||
try {
|
||||
Inventory checkInventory = (Inventory) inventory;
|
||||
maxInventorySize = checkInventory.getSize() * checkInventory.getMaxStackSize();
|
||||
}
|
||||
catch (Exception e) {
|
||||
// use default of 5,346
|
||||
}
|
||||
|
||||
if (loopCount > maxInventorySize) {
|
||||
ItemStack[] destinationContents = null;
|
||||
ItemStack movedItem = null;
|
||||
|
||||
String hopperPush = "#hopper-push." + location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ();
|
||||
Object[] hopperPushData = ConfigHandler.hopperSuccess.remove(hopperPush);
|
||||
if (hopperPushData != null) {
|
||||
destinationContents = (ItemStack[]) hopperPushData[0];
|
||||
movedItem = (ItemStack) hopperPushData[1];
|
||||
}
|
||||
|
||||
if (destinationContents != null) {
|
||||
Set<ItemStack> movedItems = new HashSet<>();
|
||||
Object[] lastAbort = ConfigHandler.hopperAbort.get(hopperPush);
|
||||
if (lastAbort != null && Arrays.equals(destinationContents, (ItemStack[]) lastAbort[1])) {
|
||||
((Set<?>) lastAbort[0]).forEach(itemStack -> movedItems.add((ItemStack) itemStack));
|
||||
}
|
||||
movedItems.add(movedItem);
|
||||
ConfigHandler.hopperAbort.put(hopperPush, new Object[] { movedItems, destinationContents });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
inventories.remove(id);
|
||||
}
|
||||
|
|
|
@ -83,6 +83,14 @@ public class Process {
|
|||
int consumerDataSize = consumerData.size();
|
||||
currentConsumerSize = consumerDataSize;
|
||||
|
||||
if (currentConsumerSize == 0) { // No data, skip processing
|
||||
updateLockTable(statement, (lastRun ? 0 : 1));
|
||||
statement.close();
|
||||
Consumer.consumer_id.put(processId, new Integer[] { 0, 0 });
|
||||
Consumer.isPaused = false;
|
||||
return;
|
||||
}
|
||||
|
||||
Database.beginTransaction(statement);
|
||||
// Scan through usernames, ensure everything is loaded in memory.
|
||||
for (Entry<Integer, String[]> entry : users.entrySet()) {
|
||||
|
@ -225,6 +233,7 @@ public class Process {
|
|||
consumerData.remove(index);
|
||||
}
|
||||
currentConsumerSize = 0;
|
||||
Consumer.consumer_id.put(processId, new Integer[] { 0, 0 });
|
||||
Consumer.isPaused = false;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class SignTextProcess {
|
|||
Map<Integer, Object[]> signs = Consumer.consumerSigns.get(processId);
|
||||
if (signs.get(id) != null) {
|
||||
Object[] SIGN_DATA = signs.get(id);
|
||||
SignTextLogger.log(preparedStmt, batchCount, user, location, action, color, (Integer) SIGN_DATA[0], (String) SIGN_DATA[1], (String) SIGN_DATA[2], (String) SIGN_DATA[3], (String) SIGN_DATA[4], forceData);
|
||||
SignTextLogger.log(preparedStmt, batchCount, user, location, action, color, (Integer) SIGN_DATA[0], (Integer) SIGN_DATA[1], (Boolean) SIGN_DATA[2], (Boolean) SIGN_DATA[3], (String) SIGN_DATA[4], (String) SIGN_DATA[5], (String) SIGN_DATA[6], (String) SIGN_DATA[7], (String) SIGN_DATA[8], (String) SIGN_DATA[9], (String) SIGN_DATA[10], (String) SIGN_DATA[11], forceData);
|
||||
signs.remove(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@ class SignUpdateProcess {
|
|||
int userid = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
|
||||
String query = "";
|
||||
if (action == 0) {
|
||||
query = "SELECT color, data, line_1, line_2, line_3, line_4 FROM " + ConfigHandler.prefix + "sign WHERE user='" + userid + "' AND wid='" + wid + "' AND x='" + x + "' AND z='" + z + "' AND y='" + y + "' AND time < '" + time + "' ORDER BY rowid DESC LIMIT 0, 1";
|
||||
query = "SELECT color, color_secondary, data, waxed, face, line_1, line_2, line_3, line_4, line_5, line_6, line_7, line_8 FROM " + ConfigHandler.prefix + "sign WHERE user='" + userid + "' AND wid='" + wid + "' AND x='" + x + "' AND z='" + z + "' AND y='" + y + "' AND time < '" + time + "' ORDER BY rowid DESC LIMIT 0, 1";
|
||||
}
|
||||
else {
|
||||
query = "SELECT color, data, line_1, line_2, line_3, line_4 FROM " + ConfigHandler.prefix + "sign WHERE user='" + userid + "' AND wid='" + wid + "' AND x='" + x + "' AND z='" + z + "' AND y='" + y + "' AND time >= '" + time + "' ORDER BY rowid ASC LIMIT 0, 1";
|
||||
query = "SELECT color, color_secondary, data, waxed, face, line_1, line_2, line_3, line_4, line_5, line_6, line_7, line_8 FROM " + ConfigHandler.prefix + "sign WHERE user='" + userid + "' AND wid='" + wid + "' AND x='" + x + "' AND z='" + z + "' AND y='" + y + "' AND time >= '" + time + "' ORDER BY rowid ASC LIMIT 0, 1";
|
||||
}
|
||||
SignStatement.getData(statement, block, query);
|
||||
Util.updateBlock(block);
|
||||
|
|
|
@ -21,7 +21,10 @@ class StructureGrowthProcess {
|
|||
Map<Integer, List<BlockState>> blockLists = Consumer.consumerBlockList.get(processId);
|
||||
if (blockLists.get(id) != null) {
|
||||
List<BlockState> blockStates = blockLists.get(id);
|
||||
String resultData = Lookup.whoPlaced(statement, block);
|
||||
String resultData = Lookup.whoPlacedCache(block);
|
||||
if (resultData.isEmpty()) {
|
||||
resultData = Lookup.whoPlaced(statement, block);
|
||||
}
|
||||
if (resultData.length() > 0) {
|
||||
user = resultData;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
@ -22,12 +21,15 @@ import net.coreprotect.CoreProtect;
|
|||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.consumer.process.Process;
|
||||
import net.coreprotect.database.rollback.Rollback;
|
||||
import net.coreprotect.database.rollback.RollbackComplete;
|
||||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class ContainerRollback extends Queue {
|
||||
public class ContainerRollback extends Rollback {
|
||||
|
||||
public static void performContainerRollbackRestore(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, String timeString, List<Object> restrictList, Map<Object, Boolean> excludeList, List<String> excludeUserList, List<Integer> actionList, final Location location, Integer[] radius, long startTime, long endTime, boolean restrictWorld, boolean lookup, boolean verbose, final int rollbackType) {
|
||||
try {
|
||||
|
@ -46,9 +48,9 @@ public class ContainerRollback extends Queue {
|
|||
Queue.queueRollbackUpdate(userString, location, lookupList, Process.CONTAINER_ROLLBACK_UPDATE, rollbackType); // Perform update transaction in consumer
|
||||
|
||||
final String finalUserString = userString;
|
||||
ConfigHandler.rollbackHash.put(userString, new int[] { 0, 0, 0, 0 });
|
||||
ConfigHandler.rollbackHash.put(userString, new int[] { 0, 0, 0, 0, 0 });
|
||||
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CoreProtect.getInstance(), new Runnable() {
|
||||
Scheduler.scheduleSyncDelayedTask(CoreProtect.getInstance(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
|
@ -140,13 +142,13 @@ public class ContainerRollback extends Queue {
|
|||
}
|
||||
matchingFrames.clear();
|
||||
|
||||
ConfigHandler.rollbackHash.put(finalUserString, new int[] { itemCount, modifyCount, entityCount, 1 });
|
||||
ConfigHandler.rollbackHash.put(finalUserString, new int[] { itemCount, modifyCount, entityCount, 1, 1 });
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
}, location, 0);
|
||||
|
||||
int[] rollbackHashData = ConfigHandler.rollbackHash.get(finalUserString);
|
||||
int next = rollbackHashData[3];
|
||||
|
@ -176,7 +178,7 @@ public class ContainerRollback extends Queue {
|
|||
int itemCount = 0;
|
||||
int entityCount = 0;
|
||||
|
||||
Rollback.finishRollbackRestore(user, location, checkUsers, restrictList, excludeList, excludeUserList, actionList, timeString, file, totalSeconds, itemCount, blockCount, entityCount, rollbackType, radius, verbose, restrictWorld, 0);
|
||||
RollbackComplete.output(user, location, checkUsers, restrictList, excludeList, excludeUserList, actionList, timeString, file, totalSeconds, itemCount, blockCount, entityCount, rollbackType, radius, verbose, restrictWorld, 0);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
|
|
@ -106,6 +106,10 @@ public class Database extends Queue {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean hasReturningKeys() {
|
||||
return (!Config.getGlobal().MYSQL && ConfigHandler.SERVER_VERSION >= 20);
|
||||
}
|
||||
|
||||
public static void containerBreakCheck(String user, Material type, Object container, ItemStack[] contents, Location location) {
|
||||
if (BlockGroup.CONTAINERS.contains(type) && !BlockGroup.SHULKER_BOXES.contains(type)) {
|
||||
if (Config.getConfig(location.getWorld()).ITEM_TRANSACTIONS) {
|
||||
|
@ -215,7 +219,7 @@ public class Database extends Queue {
|
|||
public static PreparedStatement prepareStatement(Connection connection, int type, boolean keys) {
|
||||
PreparedStatement preparedStatement = null;
|
||||
try {
|
||||
String signInsert = "INSERT INTO " + ConfigHandler.prefix + "sign (time, user, wid, x, y, z, action, color, data, line_1, line_2, line_3, line_4) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
String signInsert = "INSERT INTO " + ConfigHandler.prefix + "sign (time, user, wid, x, y, z, action, color, color_secondary, data, waxed, face, line_1, line_2, line_3, line_4, line_5, line_6, line_7, line_8) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
String blockInsert = "INSERT INTO " + ConfigHandler.prefix + "block (time, user, wid, x, y, z, type, data, meta, blockdata, action, rolled_back) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
String skullInsert = "INSERT INTO " + ConfigHandler.prefix + "skull (time, owner) VALUES (?, ?)";
|
||||
String containerInsert = "INSERT INTO " + ConfigHandler.prefix + "container (time, user, wid, x, y, z, type, data, amount, metadata, action, rolled_back) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
|
@ -286,7 +290,12 @@ public class Database extends Queue {
|
|||
PreparedStatement preparedStatement = null;
|
||||
try {
|
||||
if (keys) {
|
||||
preparedStatement = connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
|
||||
if (hasReturningKeys()) {
|
||||
preparedStatement = connection.prepareStatement(query + " RETURNING rowid");
|
||||
}
|
||||
else {
|
||||
preparedStatement = connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
|
||||
}
|
||||
}
|
||||
else {
|
||||
preparedStatement = connection.prepareStatement(query);
|
||||
|
@ -362,8 +371,8 @@ public class Database extends Queue {
|
|||
index = ", INDEX(wid,x,z,time), INDEX(action,time), INDEX(user,time), INDEX(time)";
|
||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "session(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int, user int, wid int, x int, y int (3), z int, action tinyint" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
||||
index = ", INDEX(wid,x,z,time), INDEX(user,time), INDEX(time)";
|
||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "sign(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int, user int, wid int, x int, y int, z int, action tinyint, color int, data tinyint, line_1 varchar(100), line_2 varchar(100), line_3 varchar(100), line_4 varchar(100)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "skull(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, owner varchar(64)) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "sign(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int, user int, wid int, x int, y int, z int, action tinyint, color int, color_secondary int, data tinyint, waxed tinyint, face tinyint, line_1 varchar(100), line_2 varchar(100), line_3 varchar(100), line_4 varchar(100), line_5 varchar(100), line_6 varchar(100), line_7 varchar(100), line_8 varchar(100)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "skull(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, owner varchar(255)) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
||||
index = ", INDEX(user), INDEX(uuid)";
|
||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "user(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int,user varchar(100),uuid varchar(64)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
||||
index = ", INDEX(uuid,user)";
|
||||
|
@ -450,7 +459,7 @@ public class Database extends Queue {
|
|||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "session (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, action INTEGER);");
|
||||
}
|
||||
if (!tableData.contains(prefix + "sign")) {
|
||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "sign (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, action INTEGER, color INTEGER, data INTEGER, line_1 TEXT, line_2 TEXT, line_3 TEXT, line_4 TEXT);");
|
||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "sign (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, action INTEGER, color INTEGER, color_secondary INTEGER, data INTEGER, waxed INTEGER, face INTEGER, line_1 TEXT, line_2 TEXT, line_3 TEXT, line_4 TEXT, line_5 TEXT, line_6 TEXT, line_7 TEXT, line_8 TEXT);");
|
||||
}
|
||||
if (!tableData.contains(prefix + "skull")) {
|
||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "skull (id INTEGER PRIMARY KEY ASC, time INTEGER, owner TEXT);");
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.coreprotect.database;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
|
@ -28,7 +29,7 @@ import net.coreprotect.utility.Util;
|
|||
|
||||
public class Lookup extends Queue {
|
||||
|
||||
static List<String[]> convertRawLookup(Statement statement, List<Object[]> list) {
|
||||
protected static List<String[]> convertRawLookup(Statement statement, List<Object[]> list) {
|
||||
List<String[]> newList = new ArrayList<>();
|
||||
|
||||
if (list == null) {
|
||||
|
@ -55,7 +56,7 @@ public class Lookup extends Queue {
|
|||
results[newId] = (String) map[i];
|
||||
}
|
||||
}
|
||||
else if (i == 13 && map[i] instanceof Byte[]) {
|
||||
else if (i == 13 && map[i] instanceof byte[]) {
|
||||
results[newId] = Util.byteDataToString((byte[]) map[i], (int) map[6]);
|
||||
}
|
||||
else if (i > 0) { // skip rowid
|
||||
|
@ -65,6 +66,9 @@ public class Lookup extends Queue {
|
|||
else if (map[i] instanceof String) {
|
||||
results[newId] = (String) map[i];
|
||||
}
|
||||
else if (map[i] instanceof byte[]) {
|
||||
results[newId] = new String((byte[]) map[i], StandardCharsets.ISO_8859_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
@ -118,7 +122,7 @@ public class Lookup extends Queue {
|
|||
return newList;
|
||||
}
|
||||
|
||||
static List<Object[]> performLookupRaw(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, Map<Object, Boolean> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, Long[] rowData, long startTime, long endTime, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup) {
|
||||
protected static List<Object[]> performLookupRaw(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, Map<Object, Boolean> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, Long[] rowData, long startTime, long endTime, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup) {
|
||||
List<Object[]> list = new ArrayList<>();
|
||||
List<Integer> invalidRollbackActions = new ArrayList<>();
|
||||
invalidRollbackActions.add(2);
|
||||
|
@ -187,36 +191,65 @@ public class Lookup extends Queue {
|
|||
int resultX = results.getInt("x");
|
||||
int resultY = results.getInt("y");
|
||||
int resultZ = results.getInt("z");
|
||||
boolean isFront = results.getInt("face") == 0;
|
||||
String line1 = results.getString("line_1");
|
||||
String line2 = results.getString("line_2");
|
||||
String line3 = results.getString("line_3");
|
||||
String line4 = results.getString("line_4");
|
||||
String line5 = results.getString("line_5");
|
||||
String line6 = results.getString("line_6");
|
||||
String line7 = results.getString("line_7");
|
||||
String line8 = results.getString("line_8");
|
||||
|
||||
StringBuilder message = new StringBuilder();
|
||||
if (line1 != null && line1.length() > 0) {
|
||||
if (isFront && line1 != null && line1.length() > 0) {
|
||||
message.append(line1);
|
||||
if (!line1.endsWith(" ")) {
|
||||
message.append(" ");
|
||||
}
|
||||
}
|
||||
if (line2 != null && line2.length() > 0) {
|
||||
if (isFront && line2 != null && line2.length() > 0) {
|
||||
message.append(line2);
|
||||
if (!line2.endsWith(" ")) {
|
||||
message.append(" ");
|
||||
}
|
||||
}
|
||||
if (line3 != null && line3.length() > 0) {
|
||||
if (isFront && line3 != null && line3.length() > 0) {
|
||||
message.append(line3);
|
||||
if (!line3.endsWith(" ")) {
|
||||
message.append(" ");
|
||||
}
|
||||
}
|
||||
if (line4 != null && line4.length() > 0) {
|
||||
if (isFront && line4 != null && line4.length() > 0) {
|
||||
message.append(line4);
|
||||
if (!line4.endsWith(" ")) {
|
||||
message.append(" ");
|
||||
}
|
||||
}
|
||||
if (!isFront && line5 != null && line5.length() > 0) {
|
||||
message.append(line5);
|
||||
if (!line5.endsWith(" ")) {
|
||||
message.append(" ");
|
||||
}
|
||||
}
|
||||
if (!isFront && line6 != null && line6.length() > 0) {
|
||||
message.append(line6);
|
||||
if (!line6.endsWith(" ")) {
|
||||
message.append(" ");
|
||||
}
|
||||
}
|
||||
if (!isFront && line7 != null && line7.length() > 0) {
|
||||
message.append(line7);
|
||||
if (!line7.endsWith(" ")) {
|
||||
message.append(" ");
|
||||
}
|
||||
}
|
||||
if (!isFront && line8 != null && line8.length() > 0) {
|
||||
message.append(line8);
|
||||
if (!line8.endsWith(" ")) {
|
||||
message.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
Object[] dataArray = new Object[] { resultId, resultTime, resultUserId, resultWorldId, resultX, resultY, resultZ, message.toString() };
|
||||
list.add(dataArray);
|
||||
|
@ -592,7 +625,7 @@ public class Lookup extends Queue {
|
|||
}
|
||||
|
||||
if (actionList.contains(10)) {
|
||||
queryBlock = queryBlock + " action = '1' AND (LENGTH(line_1) > 0 OR LENGTH(line_2) > 0 OR LENGTH(line_3) > 0 OR LENGTH(line_4) > 0) AND";
|
||||
queryBlock = queryBlock + " action = '1' AND (LENGTH(line_1) > 0 OR LENGTH(line_2) > 0 OR LENGTH(line_3) > 0 OR LENGTH(line_4) > 0 OR LENGTH(line_5) > 0 OR LENGTH(line_6) > 0 OR LENGTH(line_7) > 0 OR LENGTH(line_8) > 0) AND";
|
||||
}
|
||||
|
||||
if (queryBlock.length() > 0) {
|
||||
|
@ -645,7 +678,7 @@ public class Lookup extends Queue {
|
|||
}
|
||||
else if (actionList.contains(10)) {
|
||||
queryTable = "sign";
|
||||
rows = "rowid as id,time,user,wid,x,y,z,line_1,line_2,line_3,line_4";
|
||||
rows = "rowid as id,time,user,wid,x,y,z,face,line_1,line_2,line_3,line_4,line_5,line_6,line_7,line_8";
|
||||
}
|
||||
else if (actionList.contains(11)) {
|
||||
queryTable = "item";
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -9,6 +9,7 @@ import org.bukkit.Material;
|
|||
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.statement.BlockStatement;
|
||||
import net.coreprotect.database.statement.UserStatement;
|
||||
|
@ -36,8 +37,13 @@ public class BlockBreakLogger {
|
|||
return;
|
||||
}
|
||||
|
||||
if (ConfigHandler.blacklist.get(checkType.getKey().toString()) != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!user.startsWith("#")) {
|
||||
CacheHandler.spreadCache.remove(location);
|
||||
String cacheId = location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ() + "." + Util.getWorldId(location.getWorld().getName());
|
||||
CacheHandler.spreadCache.remove(cacheId);
|
||||
}
|
||||
|
||||
if (checkType == Material.LECTERN) {
|
||||
|
@ -48,7 +54,9 @@ public class BlockBreakLogger {
|
|||
}
|
||||
|
||||
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||
if (Config.getGlobal().API_ENABLED) {
|
||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||
int wid = Util.getWorldId(location.getWorld().getName());
|
||||
|
@ -57,6 +65,11 @@ public class BlockBreakLogger {
|
|||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
CacheHandler.breakCache.put("" + x + "." + y + "." + z + "." + wid + "", new Object[] { time, event.getUser(), type });
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, type, data, meta, blockData, 0, 0);
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.bukkit.block.BlockState;
|
|||
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.statement.BlockStatement;
|
||||
import net.coreprotect.database.statement.UserStatement;
|
||||
|
@ -54,6 +55,10 @@ public class BlockPlaceLogger {
|
|||
return;
|
||||
}
|
||||
|
||||
if (ConfigHandler.blacklist.get(type.getKey().toString()) != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
int z = block.getZ();
|
||||
|
@ -79,7 +84,9 @@ public class BlockPlaceLogger {
|
|||
}
|
||||
|
||||
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||
if (Config.getGlobal().API_ENABLED) {
|
||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||
int wid = Util.getWorldId(block.getWorld().getName());
|
||||
|
@ -89,8 +96,11 @@ public class BlockPlaceLogger {
|
|||
CacheHandler.lookupCache.put("" + x + "." + y + "." + z + "." + wid + "", new Object[] { time, event.getUser(), type });
|
||||
}
|
||||
|
||||
int internalType = Util.getBlockId(type.name(), true);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int internalType = Util.getBlockId(type.name(), true);
|
||||
if (replacedType > 0 && Util.getType(replacedType) != Material.AIR && Util.getType(replacedType) != Material.CAVE_AIR) {
|
||||
BlockStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, replacedType, replacedData, null, replaceBlockData, 0, 0);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Locale;
|
|||
import org.bukkit.Location;
|
||||
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.statement.CommandStatement;
|
||||
import net.coreprotect.database.statement.UserStatement;
|
||||
|
@ -28,7 +29,13 @@ public class CommandLogger {
|
|||
}
|
||||
|
||||
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||
if (Config.getGlobal().API_ENABLED) {
|
||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||
int wid = Util.getWorldId(location.getWorld().getName());
|
||||
|
|
|
@ -9,12 +9,12 @@ import java.util.Map;
|
|||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.database.statement.ContainerStatement;
|
||||
|
@ -34,16 +34,12 @@ public class ContainerLogger extends Queue {
|
|||
ItemStack[] contents = null;
|
||||
String faceData = null;
|
||||
|
||||
if (type == Material.ARMOR_STAND) {
|
||||
EntityEquipment equipment = (EntityEquipment) container;
|
||||
if (equipment != null) {
|
||||
contents = Util.getArmorStandContents(equipment);
|
||||
}
|
||||
if (type == Material.ITEM_FRAME) {
|
||||
contents = (ItemStack[]) ((Object[]) container)[1];
|
||||
faceData = ((BlockFace) ((Object[]) container)[2]).name();
|
||||
}
|
||||
else if (type == Material.ITEM_FRAME) {
|
||||
ItemFrame itemFrame = (ItemFrame) container;
|
||||
contents = Util.getItemFrameItem(itemFrame);
|
||||
faceData = itemFrame.getFacing().name();
|
||||
else if (type == Material.JUKEBOX || type == Material.ARMOR_STAND) {
|
||||
contents = (ItemStack[]) ((Object[]) container)[1];
|
||||
}
|
||||
else {
|
||||
Inventory inventory = (Inventory) container;
|
||||
|
@ -61,6 +57,9 @@ public class ContainerLogger extends Queue {
|
|||
ItemStack[] oi1 = oldList.get(0);
|
||||
ItemStack[] oldInventory = Util.getContainerState(oi1);
|
||||
ItemStack[] newInventory = Util.getContainerState(contents);
|
||||
if (oldInventory == null || newInventory == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<ItemStack[]> forceList = ConfigHandler.forceContainer.get(loggingContainerId);
|
||||
if (forceList != null) {
|
||||
|
@ -162,18 +161,25 @@ public class ContainerLogger extends Queue {
|
|||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
||||
return;
|
||||
}
|
||||
boolean success = false;
|
||||
int slot = 0;
|
||||
for (ItemStack item : items) {
|
||||
if (item != null) {
|
||||
if (item.getAmount() > 0 && !Util.isAir(item.getType())) {
|
||||
// Object[] metadata = new Object[] { slot, item.getItemMeta() };
|
||||
List<List<Map<String, Object>>> metadata = ItemMetaHandler.seralize(item, type, faceData, slot);
|
||||
List<List<Map<String, Object>>> metadata = ItemMetaHandler.serialize(item, type, faceData, slot);
|
||||
if (metadata.size() == 0) {
|
||||
metadata = null;
|
||||
}
|
||||
|
||||
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||
if (Config.getGlobal().API_ENABLED) {
|
||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||
int wid = Util.getWorldId(location.getWorld().getName());
|
||||
|
@ -185,10 +191,17 @@ public class ContainerLogger extends Queue {
|
|||
int data = 0;
|
||||
int amount = item.getAmount();
|
||||
ContainerStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, typeId, data, amount, metadata, action, 0);
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
slot++;
|
||||
}
|
||||
|
||||
if (success && user.equals("#hopper")) {
|
||||
String hopperPush = "#hopper-push." + location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ();
|
||||
ConfigHandler.hopperSuccess.remove(hopperPush);
|
||||
ConfigHandler.hopperAbort.remove(hopperPush);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -8,7 +8,9 @@ import java.util.Locale;
|
|||
import org.bukkit.block.BlockState;
|
||||
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.Database;
|
||||
import net.coreprotect.database.statement.BlockStatement;
|
||||
import net.coreprotect.database.statement.EntityStatement;
|
||||
import net.coreprotect.database.statement.UserStatement;
|
||||
|
@ -28,7 +30,13 @@ public class EntityKillLogger {
|
|||
}
|
||||
|
||||
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||
if (Config.getGlobal().API_ENABLED) {
|
||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||
int wid = Util.getWorldId(block.getWorld().getName());
|
||||
|
@ -36,11 +44,21 @@ public class EntityKillLogger {
|
|||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
int z = block.getZ();
|
||||
EntityStatement.insert(preparedStmt2, time, data);
|
||||
ResultSet keys = preparedStmt2.getGeneratedKeys();
|
||||
keys.next();
|
||||
int entity_key = keys.getInt(1);
|
||||
keys.close();
|
||||
int entity_key = 0;
|
||||
|
||||
ResultSet resultSet = EntityStatement.insert(preparedStmt2, time, data);
|
||||
if (Database.hasReturningKeys()) {
|
||||
resultSet.next();
|
||||
entity_key = resultSet.getInt(1);
|
||||
resultSet.close();
|
||||
}
|
||||
else {
|
||||
ResultSet keys = preparedStmt2.getGeneratedKeys();
|
||||
keys.next();
|
||||
entity_key = keys.getInt(1);
|
||||
keys.close();
|
||||
}
|
||||
|
||||
BlockStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, type, entity_key, null, null, 3, 0);
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.bukkit.Location;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.statement.ItemStatement;
|
||||
import net.coreprotect.database.statement.UserStatement;
|
||||
|
@ -119,13 +120,19 @@ public class ItemLogger {
|
|||
for (ItemStack item : items) {
|
||||
if (item != null && item.getAmount() > 0 && !Util.isAir(item.getType())) {
|
||||
// Object[] metadata = new Object[] { slot, item.getItemMeta() };
|
||||
List<List<Map<String, Object>>> data = ItemMetaHandler.seralize(item, null, null, 0);
|
||||
List<List<Map<String, Object>>> data = ItemMetaHandler.serialize(item, null, null, 0);
|
||||
if (data.size() == 0) {
|
||||
data = null;
|
||||
}
|
||||
|
||||
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||
if (Config.getGlobal().API_ENABLED) {
|
||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||
int wid = Util.getWorldId(location.getWorld().getName());
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.bukkit.Material;
|
|||
import org.bukkit.block.BlockState;
|
||||
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.statement.BlockStatement;
|
||||
import net.coreprotect.database.statement.UserStatement;
|
||||
|
@ -27,7 +28,13 @@ public class PlayerInteractLogger {
|
|||
}
|
||||
|
||||
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||
if (Config.getGlobal().API_ENABLED) {
|
||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||
int wid = Util.getWorldId(block.getWorld().getName());
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Locale;
|
|||
import org.bukkit.block.BlockState;
|
||||
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.statement.BlockStatement;
|
||||
import net.coreprotect.database.statement.UserStatement;
|
||||
|
@ -29,7 +30,13 @@ public class PlayerKillLogger {
|
|||
}
|
||||
|
||||
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||
if (Config.getGlobal().API_ENABLED) {
|
||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||
int playerId = ConfigHandler.playerIdCache.get(player.toLowerCase(Locale.ROOT));
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Locale;
|
|||
import org.bukkit.Location;
|
||||
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.statement.SignStatement;
|
||||
import net.coreprotect.database.statement.UserStatement;
|
||||
|
@ -18,14 +19,20 @@ public class SignTextLogger {
|
|||
throw new IllegalStateException("Database class");
|
||||
}
|
||||
|
||||
public static void log(PreparedStatement preparedStmt, int batchCount, String user, Location location, int action, int color, int data, String line1, String line2, String line3, String line4, int timeOffset) {
|
||||
public static void log(PreparedStatement preparedStmt, int batchCount, String user, Location location, int action, int color, int colorSecondary, int data, boolean isWaxed, boolean isFront, String line1, String line2, String line3, String line4, String line5, String line6, String line7, String line8, int timeOffset) {
|
||||
try {
|
||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||
if (Config.getGlobal().API_ENABLED) {
|
||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||
int wid = Util.getWorldId(location.getWorld().getName());
|
||||
|
@ -33,7 +40,21 @@ public class SignTextLogger {
|
|||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
SignStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, action, color, data, line1, line2, line3, line4);
|
||||
|
||||
if (line1.isEmpty() && line2.isEmpty() && line3.isEmpty() && line4.isEmpty()) {
|
||||
line1 = null;
|
||||
line2 = null;
|
||||
line3 = null;
|
||||
line4 = null;
|
||||
}
|
||||
if (line5.isEmpty() && line6.isEmpty() && line7.isEmpty() && line8.isEmpty()) {
|
||||
line5 = null;
|
||||
line6 = null;
|
||||
line7 = null;
|
||||
line8 = null;
|
||||
}
|
||||
|
||||
SignStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, action, color, colorSecondary, data, isWaxed ? 1 : 0, isFront ? 0 : 1, line1, line2, line3, line4, line5, line6, line7, line8);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -8,7 +8,9 @@ import org.bukkit.block.BlockState;
|
|||
import org.bukkit.block.Skull;
|
||||
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.Database;
|
||||
import net.coreprotect.database.statement.SkullStatement;
|
||||
import net.coreprotect.paper.PaperAdapter;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class SkullBreakLogger {
|
||||
|
@ -28,12 +30,19 @@ public class SkullBreakLogger {
|
|||
String skullOwner = "";
|
||||
int skullKey = 0;
|
||||
if (skull.hasOwner()) {
|
||||
skullOwner = skull.getOwningPlayer().getUniqueId().toString();
|
||||
SkullStatement.insert(preparedStmt2, time, skullOwner);
|
||||
ResultSet keys = preparedStmt2.getGeneratedKeys();
|
||||
keys.next();
|
||||
skullKey = keys.getInt(1);
|
||||
keys.close();
|
||||
skullOwner = PaperAdapter.ADAPTER.getSkullOwner(skull);
|
||||
ResultSet resultSet = SkullStatement.insert(preparedStmt2, time, skullOwner);
|
||||
if (Database.hasReturningKeys()) {
|
||||
resultSet.next();
|
||||
skullKey = resultSet.getInt(1);
|
||||
resultSet.close();
|
||||
}
|
||||
else {
|
||||
ResultSet keys = preparedStmt2.getGeneratedKeys();
|
||||
keys.next();
|
||||
skullKey = keys.getInt(1);
|
||||
keys.close();
|
||||
}
|
||||
}
|
||||
|
||||
BlockBreakLogger.log(preparedStmt, batchCount, user, block.getLocation(), type, skullKey, null, block.getBlockData().getAsString(), null);
|
||||
|
|
|
@ -9,7 +9,9 @@ import org.bukkit.block.BlockState;
|
|||
import org.bukkit.block.Skull;
|
||||
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.Database;
|
||||
import net.coreprotect.database.statement.SkullStatement;
|
||||
import net.coreprotect.paper.PaperAdapter;
|
||||
|
||||
public class SkullPlaceLogger {
|
||||
|
||||
|
@ -30,12 +32,19 @@ public class SkullPlaceLogger {
|
|||
Skull skull = (Skull) block;
|
||||
String skullOwner = "";
|
||||
if (skull.hasOwner()) {
|
||||
skullOwner = skull.getOwningPlayer().getUniqueId().toString();
|
||||
SkullStatement.insert(preparedStmt2, time, skullOwner);
|
||||
ResultSet keys = preparedStmt2.getGeneratedKeys();
|
||||
keys.next();
|
||||
skullKey = keys.getInt(1);
|
||||
keys.close();
|
||||
skullOwner = PaperAdapter.ADAPTER.getSkullOwner(skull);
|
||||
ResultSet resultSet = SkullStatement.insert(preparedStmt2, time, skullOwner);
|
||||
if (Database.hasReturningKeys()) {
|
||||
resultSet.next();
|
||||
skullKey = resultSet.getInt(1);
|
||||
resultSet.close();
|
||||
}
|
||||
else {
|
||||
ResultSet keys = preparedStmt2.getGeneratedKeys();
|
||||
keys.next();
|
||||
skullKey = keys.getInt(1);
|
||||
keys.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@ package net.coreprotect.database.lookup;
|
|||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
@ -18,8 +20,8 @@ import net.coreprotect.utility.Util;
|
|||
|
||||
public class ChestTransactionLookup {
|
||||
|
||||
public static String performLookup(String command, Statement statement, Location l, CommandSender commandSender, int page, int limit, boolean exact) {
|
||||
String result = "";
|
||||
public static List<String> performLookup(String command, Statement statement, Location l, CommandSender commandSender, int page, int limit, boolean exact) {
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
try {
|
||||
if (l == null) {
|
||||
|
@ -67,13 +69,11 @@ public class ChestTransactionLookup {
|
|||
|
||||
int totalPages = (int) Math.ceil(count / (limit + 0.0));
|
||||
|
||||
query = "SELECT time,user,action,type,data,amount,rolled_back FROM " + ConfigHandler.prefix + "container " + Util.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + x + "' OR x = '" + x2 + "') AND (z = '" + z + "' OR z = '" + z2 + "') AND y = '" + y + "' ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
||||
query = "SELECT time,user,action,type,data,amount,metadata,rolled_back FROM " + ConfigHandler.prefix + "container " + Util.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + x + "' OR x = '" + x2 + "') AND (z = '" + z + "' OR z = '" + z2 + "') AND y = '" + y + "' ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
||||
if (exact) {
|
||||
query = "SELECT time,user,action,type,data,amount,rolled_back FROM " + ConfigHandler.prefix + "container " + Util.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + l.getBlockX() + "') AND (z = '" + l.getBlockZ() + "') AND y = '" + y + "' ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
||||
query = "SELECT time,user,action,type,data,amount,metadata,rolled_back FROM " + ConfigHandler.prefix + "container " + Util.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + l.getBlockX() + "') AND (z = '" + l.getBlockZ() + "') AND y = '" + y + "' ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
||||
}
|
||||
results = statement.executeQuery(query);
|
||||
|
||||
StringBuilder resultBuilder = new StringBuilder();
|
||||
while (results.next()) {
|
||||
int resultUserId = results.getInt("user");
|
||||
int resultAction = results.getInt("action");
|
||||
|
@ -82,6 +82,8 @@ public class ChestTransactionLookup {
|
|||
long resultTime = results.getLong("time");
|
||||
int resultAmount = results.getInt("amount");
|
||||
int resultRolledBack = results.getInt("rolled_back");
|
||||
byte[] resultMetadata = results.getBytes("metadata");
|
||||
String tooltip = Util.getEnchantments(resultMetadata, resultType, resultAmount);
|
||||
|
||||
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
||||
UserStatement.loadName(statement.getConnection(), resultUserId);
|
||||
|
@ -91,7 +93,7 @@ public class ChestTransactionLookup {
|
|||
String timeAgo = Util.getTimeSince(resultTime, time, true);
|
||||
|
||||
if (!found) {
|
||||
resultBuilder = new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.CONTAINER_HEADER) + Color.WHITE + " ----- " + Util.getCoordinates(command, worldId, x, y, z, false, false) + "\n");
|
||||
result.add(new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.CONTAINER_HEADER) + Color.WHITE + " ----- " + Util.getCoordinates(command, worldId, x, y, z, false, false)).toString());
|
||||
}
|
||||
found = true;
|
||||
|
||||
|
@ -117,25 +119,23 @@ public class ChestTransactionLookup {
|
|||
target = target.split(":")[1];
|
||||
}
|
||||
|
||||
resultBuilder.append(timeAgo + " " + tag + " ").append(Phrase.build(Phrase.LOOKUP_CONTAINER, Color.DARK_AQUA + rbFormat + resultUser + Color.WHITE + rbFormat, "x" + resultAmount, Color.DARK_AQUA + rbFormat + target + Color.WHITE, selector)).append("\n");
|
||||
result.add(new StringBuilder(timeAgo + " " + tag + " " + Phrase.build(Phrase.LOOKUP_CONTAINER, Color.DARK_AQUA + rbFormat + resultUser + Color.WHITE + rbFormat, "x" + resultAmount, Util.createTooltip(Color.DARK_AQUA + rbFormat + target, tooltip) + Color.WHITE, selector)).toString());
|
||||
PluginChannelListener.getInstance().sendData(commandSender, resultTime, Phrase.LOOKUP_CONTAINER, selector, resultUser, target, resultAmount, x, y, z, worldId, rbFormat, true, tag.contains("+"));
|
||||
}
|
||||
result = resultBuilder.toString();
|
||||
results.close();
|
||||
|
||||
if (found) {
|
||||
if (count > limit) {
|
||||
String pageInfo = Color.WHITE + "-----\n";
|
||||
pageInfo = pageInfo + Util.getPageNavigation(command, page, totalPages) + "\n";
|
||||
result = result + pageInfo;
|
||||
result.add(Color.WHITE + "-----");
|
||||
result.add(Util.getPageNavigation(command, page, totalPages));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (rowMax > count && count > 0) {
|
||||
result = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_RESULTS_PAGE, Selector.SECOND);
|
||||
result.add(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_RESULTS_PAGE, Selector.SECOND));
|
||||
}
|
||||
else {
|
||||
result = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_DATA_LOCATION, Selector.SECOND);
|
||||
result.add(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_DATA_LOCATION, Selector.SECOND));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ import java.sql.ResultSet;
|
|||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -18,6 +20,8 @@ import net.coreprotect.utility.Util;
|
|||
|
||||
public class SignMessageLookup {
|
||||
|
||||
static Pattern pattern = Pattern.compile("§x(§[a-fA-F0-9]){6}");
|
||||
|
||||
public static List<String> performLookup(String command, Statement statement, Location l, CommandSender commandSender, int page, int limit) {
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
|
@ -51,7 +55,7 @@ public class SignMessageLookup {
|
|||
int rowMax = page * limit;
|
||||
int pageStart = rowMax - limit;
|
||||
|
||||
String query = "SELECT COUNT(*) as count from " + ConfigHandler.prefix + "sign " + Util.getWidIndex("sign") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND action = '1' AND (LENGTH(line_1) > 0 OR LENGTH(line_2) > 0 OR LENGTH(line_3) > 0 OR LENGTH(line_4) > 0) LIMIT 0, 1";
|
||||
String query = "SELECT COUNT(*) as count from " + ConfigHandler.prefix + "sign " + Util.getWidIndex("sign") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND action = '1' AND (LENGTH(line_1) > 0 OR LENGTH(line_2) > 0 OR LENGTH(line_3) > 0 OR LENGTH(line_4) > 0 OR LENGTH(line_5) > 0 OR LENGTH(line_6) > 0 OR LENGTH(line_7) > 0 OR LENGTH(line_8) > 0) LIMIT 0, 1";
|
||||
ResultSet results = statement.executeQuery(query);
|
||||
|
||||
while (results.next()) {
|
||||
|
@ -61,7 +65,7 @@ public class SignMessageLookup {
|
|||
|
||||
int totalPages = (int) Math.ceil(count / (limit + 0.0));
|
||||
|
||||
query = "SELECT time,user,line_1,line_2,line_3,line_4 FROM " + ConfigHandler.prefix + "sign " + Util.getWidIndex("sign") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND action = '1' AND (LENGTH(line_1) > 0 OR LENGTH(line_2) > 0 OR LENGTH(line_3) > 0 OR LENGTH(line_4) > 0) ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
||||
query = "SELECT time,user,face,line_1,line_2,line_3,line_4,line_5,line_6,line_7,line_8 FROM " + ConfigHandler.prefix + "sign " + Util.getWidIndex("sign") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND action = '1' AND (LENGTH(line_1) > 0 OR LENGTH(line_2) > 0 OR LENGTH(line_3) > 0 OR LENGTH(line_4) > 0 OR LENGTH(line_5) > 0 OR LENGTH(line_6) > 0 OR LENGTH(line_7) > 0 OR LENGTH(line_8) > 0) ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
||||
results = statement.executeQuery(query);
|
||||
|
||||
while (results.next()) {
|
||||
|
@ -71,32 +75,69 @@ public class SignMessageLookup {
|
|||
String line2 = results.getString("line_2");
|
||||
String line3 = results.getString("line_3");
|
||||
String line4 = results.getString("line_4");
|
||||
String line5 = results.getString("line_5");
|
||||
String line6 = results.getString("line_6");
|
||||
String line7 = results.getString("line_7");
|
||||
String line8 = results.getString("line_8");
|
||||
boolean isFront = results.getInt("face") == 0;
|
||||
|
||||
StringBuilder message = new StringBuilder();
|
||||
if (line1 != null && line1.length() > 0) {
|
||||
if (isFront && line1 != null && line1.length() > 0) {
|
||||
message.append(line1);
|
||||
if (!line1.endsWith(" ")) {
|
||||
message.append(" ");
|
||||
}
|
||||
}
|
||||
if (line2 != null && line2.length() > 0) {
|
||||
if (isFront && line2 != null && line2.length() > 0) {
|
||||
message.append(line2);
|
||||
if (!line2.endsWith(" ")) {
|
||||
message.append(" ");
|
||||
}
|
||||
}
|
||||
if (line3 != null && line3.length() > 0) {
|
||||
if (isFront && line3 != null && line3.length() > 0) {
|
||||
message.append(line3);
|
||||
if (!line3.endsWith(" ")) {
|
||||
message.append(" ");
|
||||
}
|
||||
}
|
||||
if (line4 != null && line4.length() > 0) {
|
||||
if (isFront && line4 != null && line4.length() > 0) {
|
||||
message.append(line4);
|
||||
if (!line4.endsWith(" ")) {
|
||||
message.append(" ");
|
||||
}
|
||||
}
|
||||
if (!isFront && line5 != null && line5.length() > 0) {
|
||||
message.append(line5);
|
||||
if (!line5.endsWith(" ")) {
|
||||
message.append(" ");
|
||||
}
|
||||
}
|
||||
if (!isFront && line6 != null && line6.length() > 0) {
|
||||
message.append(line6);
|
||||
if (!line6.endsWith(" ")) {
|
||||
message.append(" ");
|
||||
}
|
||||
}
|
||||
if (!isFront && line7 != null && line7.length() > 0) {
|
||||
message.append(line7);
|
||||
if (!line7.endsWith(" ")) {
|
||||
message.append(" ");
|
||||
}
|
||||
}
|
||||
if (!isFront && line8 != null && line8.length() > 0) {
|
||||
message.append(line8);
|
||||
if (!line8.endsWith(" ")) {
|
||||
message.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
String parsedMessage = message.toString();
|
||||
if (parsedMessage.contains("§x")) {
|
||||
for (Matcher matcher = pattern.matcher(parsedMessage); matcher.find(); matcher = pattern.matcher(parsedMessage)) {
|
||||
String color = parsedMessage.substring(matcher.start(), matcher.end());
|
||||
parsedMessage = parsedMessage.replace(color, "");
|
||||
}
|
||||
}
|
||||
|
||||
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
||||
UserStatement.loadName(statement.getConnection(), resultUserId);
|
||||
|
@ -109,7 +150,7 @@ public class SignMessageLookup {
|
|||
result.add(new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.SIGN_HEADER) + Color.WHITE + " ----- " + Util.getCoordinates(command, worldId, x, y, z, false, false) + "").toString());
|
||||
}
|
||||
found = true;
|
||||
result.add(timeAgo + Color.WHITE + " - " + Color.DARK_AQUA + resultUser + ": " + Color.WHITE + "\n" + message.toString() + Color.WHITE);
|
||||
result.add(timeAgo + Color.WHITE + " - " + Color.DARK_AQUA + resultUser + ": " + Color.WHITE + "\n" + parsedMessage + Color.WHITE);
|
||||
PluginChannelListener.getInstance().sendMessageData(commandSender, resultTime, resultUser, message.toString(), true, x, y, z, worldId);
|
||||
}
|
||||
results.close();
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,306 @@
|
|||
package net.coreprotect.database.rollback;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.language.Selector;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
|
||||
public class RollbackComplete {
|
||||
|
||||
public static void output(CommandSender user, Location location, List<String> checkUsers, List<Object> restrictList, Map<Object, Boolean> excludeList, List<String> excludeUserList, List<Integer> actionList, String timeString, Integer chunkCount, Double seconds, Integer itemCount, Integer blockCount, Integer entityCount, int rollbackType, Integer[] radius, boolean verbose, boolean restrictWorld, int preview) {
|
||||
try {
|
||||
if (preview == 2) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PREVIEW_CANCELLED));
|
||||
return;
|
||||
}
|
||||
|
||||
Chat.sendMessage(user, "-----");
|
||||
|
||||
StringBuilder usersBuilder = new StringBuilder();
|
||||
for (String value : checkUsers) {
|
||||
if (usersBuilder.length() == 0) {
|
||||
usersBuilder = usersBuilder.append("" + value + "");
|
||||
}
|
||||
else {
|
||||
usersBuilder.append(", ").append(value);
|
||||
}
|
||||
}
|
||||
String users = usersBuilder.toString();
|
||||
|
||||
if (users.equals("#global") && restrictWorld) {
|
||||
users = "#" + location.getWorld().getName();
|
||||
}
|
||||
|
||||
if (preview > 0) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_COMPLETED, users, Selector.THIRD)); // preview
|
||||
}
|
||||
else if (rollbackType == 0) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_COMPLETED, users, Selector.FIRST)); // rollback
|
||||
}
|
||||
else if (rollbackType == 1) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_COMPLETED, users, Selector.SECOND)); // restore
|
||||
}
|
||||
|
||||
if (preview == 1 || rollbackType == 0 || rollbackType == 1) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_TIME, timeString));
|
||||
}
|
||||
|
||||
if (radius != null) {
|
||||
int worldedit = radius[7];
|
||||
if (worldedit == 0) {
|
||||
Integer rollbackRadius = radius[0];
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_RADIUS, rollbackRadius.toString(), (rollbackRadius == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||
}
|
||||
else {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_SELECTION, "#worldedit"));
|
||||
}
|
||||
}
|
||||
|
||||
if (restrictWorld && radius == null) {
|
||||
if (location != null) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, location.getWorld().getName(), Selector.FIRST));
|
||||
}
|
||||
}
|
||||
|
||||
if (actionList.contains(4) && actionList.contains(11)) {
|
||||
if (actionList.contains(0)) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "+inventory", Selector.SECOND));
|
||||
}
|
||||
else if (actionList.contains(1)) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "-inventory", Selector.SECOND));
|
||||
}
|
||||
else {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "inventory", Selector.SECOND));
|
||||
}
|
||||
}
|
||||
else if (actionList.contains(4)) {
|
||||
if (actionList.contains(0)) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "-container", Selector.SECOND));
|
||||
}
|
||||
else if (actionList.contains(1)) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "+container", Selector.SECOND));
|
||||
}
|
||||
else {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "container", Selector.SECOND));
|
||||
}
|
||||
}
|
||||
else if (actionList.contains(0) && actionList.contains(1)) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "block", Selector.SECOND));
|
||||
}
|
||||
else if (actionList.contains(0)) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "-block", Selector.SECOND));
|
||||
}
|
||||
else if (actionList.contains(1)) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "+block", Selector.SECOND));
|
||||
}
|
||||
else if (actionList.contains(3)) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "kill", Selector.SECOND));
|
||||
}
|
||||
|
||||
if (restrictList.size() > 0) {
|
||||
StringBuilder restrictTargets = new StringBuilder();
|
||||
boolean material = false;
|
||||
boolean item = false;
|
||||
boolean entity = false;
|
||||
|
||||
int targetCount = 0;
|
||||
for (Object restrictTarget : restrictList) {
|
||||
String targetName = "";
|
||||
|
||||
if (restrictTarget instanceof Material) {
|
||||
targetName = ((Material) restrictTarget).name().toLowerCase(Locale.ROOT);
|
||||
item = (!item ? !(((Material) restrictTarget).isBlock()) : item);
|
||||
material = true;
|
||||
}
|
||||
else if (restrictTarget instanceof EntityType) {
|
||||
targetName = ((EntityType) restrictTarget).name().toLowerCase(Locale.ROOT);
|
||||
entity = true;
|
||||
}
|
||||
|
||||
if (targetCount == 0) {
|
||||
restrictTargets = restrictTargets.append("" + targetName + "");
|
||||
}
|
||||
else {
|
||||
restrictTargets.append(", ").append(targetName);
|
||||
}
|
||||
|
||||
targetCount++;
|
||||
}
|
||||
|
||||
String targetType = Selector.THIRD;
|
||||
if (material && !item && !entity) {
|
||||
targetType = Selector.FIRST;
|
||||
}
|
||||
else if (material && item && !entity) {
|
||||
targetType = Selector.THIRD;
|
||||
}
|
||||
else if (entity && !material) {
|
||||
targetType = Selector.SECOND;
|
||||
}
|
||||
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_INCLUDE, restrictTargets.toString(), Selector.FIRST, targetType, (targetCount == 1 ? Selector.FIRST : Selector.SECOND))); // include
|
||||
}
|
||||
|
||||
if (excludeList.size() > 0) {
|
||||
StringBuilder excludeTargets = new StringBuilder();
|
||||
boolean material = false;
|
||||
boolean item = false;
|
||||
boolean entity = false;
|
||||
|
||||
int excludeCount = 0;
|
||||
for (Map.Entry<Object, Boolean> entry : excludeList.entrySet()) {
|
||||
Object excludeTarget = entry.getKey();
|
||||
Boolean excludeTargetInternal = entry.getValue();
|
||||
|
||||
// don't display default block excludes
|
||||
if (Boolean.TRUE.equals(excludeTargetInternal)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// don't display that excluded water/fire/farmland in inventory rollbacks
|
||||
if (actionList.contains(4) && actionList.contains(11)) {
|
||||
if (excludeTarget.equals(Material.FIRE) || excludeTarget.equals(Material.WATER) || excludeTarget.equals(Material.FARMLAND)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
String targetName = "";
|
||||
if (excludeTarget instanceof Material) {
|
||||
targetName = ((Material) excludeTarget).name().toLowerCase(Locale.ROOT);
|
||||
item = (!item ? !(((Material) excludeTarget).isBlock()) : item);
|
||||
material = true;
|
||||
}
|
||||
else if (excludeTarget instanceof EntityType) {
|
||||
targetName = ((EntityType) excludeTarget).name().toLowerCase(Locale.ROOT);
|
||||
entity = true;
|
||||
}
|
||||
|
||||
if (excludeCount == 0) {
|
||||
excludeTargets = excludeTargets.append("" + targetName + "");
|
||||
}
|
||||
else {
|
||||
excludeTargets.append(", ").append(targetName);
|
||||
}
|
||||
|
||||
excludeCount++;
|
||||
}
|
||||
|
||||
String targetType = Selector.THIRD;
|
||||
if (material && !item && !entity) {
|
||||
targetType = Selector.FIRST;
|
||||
}
|
||||
else if (material && item && !entity) {
|
||||
targetType = Selector.THIRD;
|
||||
}
|
||||
else if (entity && !material) {
|
||||
targetType = Selector.SECOND;
|
||||
}
|
||||
|
||||
if (excludeCount > 0) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_INCLUDE, excludeTargets.toString(), Selector.SECOND, targetType, (excludeCount == 1 ? Selector.FIRST : Selector.SECOND))); // exclude
|
||||
}
|
||||
}
|
||||
|
||||
if (excludeUserList.size() > 0) {
|
||||
StringBuilder excludeUsers = new StringBuilder();
|
||||
|
||||
int excludeCount = 0;
|
||||
for (String excludeUser : excludeUserList) {
|
||||
// don't display that excluded #hopper in inventory rollbacks
|
||||
if (actionList.contains(4) && actionList.contains(11)) {
|
||||
if (excludeUser.equals("#hopper")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (excludeCount == 0) {
|
||||
excludeUsers = excludeUsers.append("" + excludeUser + "");
|
||||
}
|
||||
else {
|
||||
excludeUsers.append(", ").append(excludeUser);
|
||||
}
|
||||
|
||||
excludeCount++;
|
||||
}
|
||||
|
||||
if (excludeCount > 0) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_EXCLUDED_USERS, excludeUsers.toString(), (excludeCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder modifiedData = new StringBuilder();
|
||||
Integer modifyCount = 0;
|
||||
if (actionList.contains(5)) {
|
||||
modifiedData = modifiedData.append(Phrase.build(Phrase.AMOUNT_ITEM, NumberFormat.getInstance().format(blockCount), (blockCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||
modifyCount++;
|
||||
}
|
||||
else {
|
||||
if (itemCount > 0 || actionList.contains(4)) {
|
||||
modifiedData = modifiedData.append(Phrase.build(Phrase.AMOUNT_ITEM, NumberFormat.getInstance().format(itemCount), (itemCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||
modifyCount++;
|
||||
}
|
||||
|
||||
if (entityCount > 0) {
|
||||
if (modifyCount > 0) {
|
||||
modifiedData.append(", ");
|
||||
}
|
||||
modifiedData.append(Phrase.build(Phrase.AMOUNT_ENTITY, NumberFormat.getInstance().format(entityCount), (entityCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||
modifyCount++;
|
||||
}
|
||||
|
||||
if (blockCount > 0 || !actionList.contains(4) || preview > 0) {
|
||||
if (modifyCount > 0) {
|
||||
modifiedData.append(", ");
|
||||
}
|
||||
modifiedData.append(Phrase.build(Phrase.AMOUNT_BLOCK, NumberFormat.getInstance().format(blockCount), (blockCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||
modifyCount++;
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder modifiedDataVerbose = new StringBuilder();
|
||||
if (verbose && preview == 0 && !actionList.contains(11)) {
|
||||
if (chunkCount > -1 && modifyCount < 3) {
|
||||
if (modifyCount > 0) {
|
||||
modifiedData.append(", ");
|
||||
}
|
||||
modifiedData.append(Phrase.build(Phrase.AMOUNT_CHUNK, NumberFormat.getInstance().format(chunkCount), (chunkCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||
modifyCount++;
|
||||
}
|
||||
else if (chunkCount > 1) {
|
||||
modifiedDataVerbose.append(Phrase.build(Phrase.AMOUNT_CHUNK, NumberFormat.getInstance().format(chunkCount), (chunkCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||
}
|
||||
}
|
||||
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_MODIFIED, modifiedData.toString(), (preview == 0 ? Selector.FIRST : Selector.SECOND)));
|
||||
if (modifiedDataVerbose.length() > 0) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_MODIFIED, modifiedDataVerbose.toString(), (preview == 0 ? Selector.FIRST : Selector.SECOND)));
|
||||
}
|
||||
|
||||
if (preview == 0) {
|
||||
BigDecimal decimalSeconds = new BigDecimal(seconds).setScale(1, RoundingMode.HALF_EVEN);
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_LENGTH, decimalSeconds.stripTrailingZeros().toPlainString(), (decimalSeconds.doubleValue() == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||
}
|
||||
|
||||
Chat.sendMessage(user, "-----");
|
||||
if (preview > 0) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PLEASE_SELECT, "/co apply", "/co cancel"));
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,487 @@
|
|||
package net.coreprotect.database.rollback;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.FireworkEffect.Builder;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
import org.bukkit.block.Jukebox;
|
||||
import org.bukkit.block.ShulkerBox;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.meta.BannerMeta;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
import org.bukkit.inventory.meta.CrossbowMeta;
|
||||
import org.bukkit.inventory.meta.FireworkEffectMeta;
|
||||
import org.bukkit.inventory.meta.FireworkMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.MapMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.inventory.meta.SuspiciousStewMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.io.BukkitObjectInputStream;
|
||||
|
||||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.database.Lookup;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class RollbackUtil extends Lookup {
|
||||
|
||||
protected static int modifyContainerItems(Material type, Object container, int slot, ItemStack itemstack, int action) {
|
||||
int modifiedArmor = -1;
|
||||
try {
|
||||
ItemStack[] contents = null;
|
||||
|
||||
if (type != null && type.equals(Material.ARMOR_STAND)) {
|
||||
EntityEquipment equipment = (EntityEquipment) container;
|
||||
if (equipment != null) {
|
||||
if (action == 1) {
|
||||
itemstack.setAmount(1);
|
||||
}
|
||||
else {
|
||||
itemstack.setType(Material.AIR);
|
||||
itemstack.setAmount(0);
|
||||
}
|
||||
|
||||
if (slot < 4) {
|
||||
contents = equipment.getArmorContents();
|
||||
if (slot >= 0) {
|
||||
contents[slot] = itemstack;
|
||||
}
|
||||
equipment.setArmorContents(contents);
|
||||
}
|
||||
else {
|
||||
ArmorStand armorStand = (ArmorStand) equipment.getHolder();
|
||||
armorStand.setArms(true);
|
||||
switch (slot) {
|
||||
case 4:
|
||||
equipment.setItemInMainHand(itemstack);
|
||||
break;
|
||||
case 5:
|
||||
equipment.setItemInOffHand(itemstack);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (type != null && type.equals(Material.ITEM_FRAME)) {
|
||||
ItemFrame frame = (ItemFrame) container;
|
||||
if (frame != null) {
|
||||
if (action == 1) {
|
||||
itemstack.setAmount(1);
|
||||
}
|
||||
else {
|
||||
itemstack.setType(Material.AIR);
|
||||
itemstack.setAmount(0);
|
||||
}
|
||||
|
||||
frame.setItem(itemstack);
|
||||
}
|
||||
}
|
||||
else if (type != null && type.equals(Material.JUKEBOX)) {
|
||||
Jukebox jukebox = (Jukebox) container;
|
||||
if (jukebox != null) {
|
||||
if (action == 1 && Tag.ITEMS_MUSIC_DISCS.isTagged(itemstack.getType())) {
|
||||
itemstack.setAmount(1);
|
||||
}
|
||||
else {
|
||||
itemstack.setType(Material.AIR);
|
||||
itemstack.setAmount(0);
|
||||
}
|
||||
|
||||
jukebox.setRecord(itemstack);
|
||||
jukebox.update();
|
||||
}
|
||||
}
|
||||
else {
|
||||
Inventory inventory = (Inventory) container;
|
||||
if (inventory != null) {
|
||||
boolean isPlayerInventory = (inventory instanceof PlayerInventory);
|
||||
if (action == 1) {
|
||||
int count = 0;
|
||||
int amount = itemstack.getAmount();
|
||||
itemstack.setAmount(1);
|
||||
|
||||
while (count < amount) {
|
||||
boolean addedItem = false;
|
||||
if (isPlayerInventory) {
|
||||
int setArmor = Util.setPlayerArmor((PlayerInventory) inventory, itemstack);
|
||||
addedItem = (setArmor > -1);
|
||||
modifiedArmor = addedItem ? setArmor : modifiedArmor;
|
||||
}
|
||||
if (!addedItem) {
|
||||
if (BukkitAdapter.ADAPTER.isChiseledBookshelf(type)) {
|
||||
ItemStack[] inventoryContents = inventory.getStorageContents();
|
||||
int i = 0;
|
||||
for (ItemStack stack : inventoryContents) {
|
||||
if (stack == null) {
|
||||
inventoryContents[i] = itemstack;
|
||||
addedItem = true;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (addedItem) {
|
||||
inventory.setStorageContents(inventoryContents);
|
||||
}
|
||||
else {
|
||||
addedItem = (inventory.addItem(itemstack).size() == 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
addedItem = (inventory.addItem(itemstack).size() == 0);
|
||||
}
|
||||
}
|
||||
if (!addedItem && isPlayerInventory) {
|
||||
PlayerInventory playerInventory = (PlayerInventory) inventory;
|
||||
ItemStack offhand = playerInventory.getItemInOffHand();
|
||||
if (offhand == null || offhand.getType() == Material.AIR || (itemstack.isSimilar(offhand) && offhand.getAmount() < offhand.getMaxStackSize())) {
|
||||
ItemStack setOffhand = itemstack.clone();
|
||||
if (itemstack.isSimilar(offhand)) {
|
||||
setOffhand.setAmount(offhand.getAmount() + 1);
|
||||
}
|
||||
|
||||
playerInventory.setItemInOffHand(setOffhand);
|
||||
}
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
int removeAmount = itemstack.getAmount();
|
||||
ItemStack removeMatch = itemstack.clone();
|
||||
removeMatch.setAmount(1);
|
||||
|
||||
ItemStack[] inventoryContents = (isPlayerInventory ? inventory.getContents() : inventory.getStorageContents()).clone();
|
||||
for (int i = inventoryContents.length - 1; i >= 0; i--) {
|
||||
if (inventoryContents[i] != null) {
|
||||
ItemStack itemStack = inventoryContents[i].clone();
|
||||
int maxAmount = itemStack.getAmount();
|
||||
int currentAmount = maxAmount;
|
||||
itemStack.setAmount(1);
|
||||
|
||||
if (itemStack.toString().equals(removeMatch.toString())) {
|
||||
for (int scan = 0; scan < maxAmount; scan++) {
|
||||
if (removeAmount > 0) {
|
||||
currentAmount--;
|
||||
itemStack.setAmount(currentAmount);
|
||||
removeAmount--;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
itemStack.setAmount(maxAmount);
|
||||
}
|
||||
|
||||
if (itemStack.getAmount() == 0) {
|
||||
inventoryContents[i] = null;
|
||||
}
|
||||
else {
|
||||
inventoryContents[i] = itemStack;
|
||||
}
|
||||
}
|
||||
|
||||
if (removeAmount == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isPlayerInventory) {
|
||||
inventory.setContents(inventoryContents);
|
||||
}
|
||||
else {
|
||||
inventory.setStorageContents(inventoryContents);
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
while (count < removeAmount) {
|
||||
inventory.removeItem(removeMatch);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return modifiedArmor;
|
||||
}
|
||||
|
||||
public static void sortContainerItems(PlayerInventory inventory, List<Integer> modifiedArmorSlots) {
|
||||
try {
|
||||
ItemStack[] armorContents = inventory.getArmorContents();
|
||||
ItemStack[] storageContents = inventory.getStorageContents();
|
||||
|
||||
for (int armor = 0; armor < armorContents.length; armor++) {
|
||||
ItemStack armorItem = armorContents[armor];
|
||||
if (armorItem == null || !modifiedArmorSlots.contains(armor)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int storage = 0; storage < storageContents.length; storage++) {
|
||||
ItemStack storageItem = storageContents[storage];
|
||||
if (storageItem == null) {
|
||||
storageContents[storage] = armorItem;
|
||||
armorContents[armor] = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inventory.setArmorContents(armorContents);
|
||||
inventory.setStorageContents(storageContents);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildFireworkEffect(Builder effectBuilder, Material rowType, ItemStack itemstack) {
|
||||
try {
|
||||
FireworkEffect effect = effectBuilder.build();
|
||||
if ((rowType == Material.FIREWORK_ROCKET)) {
|
||||
FireworkMeta meta = (FireworkMeta) itemstack.getItemMeta();
|
||||
meta.addEffect(effect);
|
||||
itemstack.setItemMeta(meta);
|
||||
}
|
||||
else if ((rowType == Material.FIREWORK_STAR)) {
|
||||
FireworkEffectMeta meta = (FireworkEffectMeta) itemstack.getItemMeta();
|
||||
meta.setEffect(effect);
|
||||
itemstack.setItemMeta(meta);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Object[] populateItemStack(ItemStack itemstack, Object list) {
|
||||
int slot = 0;
|
||||
String faceData = "";
|
||||
|
||||
try {
|
||||
/*
|
||||
if (list instanceof Object[]) {
|
||||
slot = (int) ((Object[]) list)[0];
|
||||
ItemMeta itemMeta = (ItemMeta) ((Object[]) list)[1];
|
||||
itemstack.setItemMeta(itemMeta);
|
||||
return new Object[] { slot, itemstack };
|
||||
}
|
||||
*/
|
||||
|
||||
Material rowType = itemstack.getType();
|
||||
List<Object> metaList = (List<Object>) list;
|
||||
if (metaList.size() > 0 && !(metaList.get(0) instanceof List<?>)) {
|
||||
if (rowType.name().endsWith("_BANNER")) {
|
||||
BannerMeta meta = (BannerMeta) itemstack.getItemMeta();
|
||||
for (Object value : metaList) {
|
||||
if (value instanceof Map) {
|
||||
Pattern pattern = new Pattern((Map<String, Object>) value);
|
||||
meta.addPattern(pattern);
|
||||
}
|
||||
}
|
||||
itemstack.setItemMeta(meta);
|
||||
}
|
||||
else if (BlockGroup.SHULKER_BOXES.contains(rowType)) {
|
||||
BlockStateMeta meta = (BlockStateMeta) itemstack.getItemMeta();
|
||||
ShulkerBox shulkerBox = (ShulkerBox) meta.getBlockState();
|
||||
for (Object value : metaList) {
|
||||
ItemStack item = Util.unserializeItemStackLegacy(value);
|
||||
if (item != null) {
|
||||
shulkerBox.getInventory().addItem(item);
|
||||
}
|
||||
}
|
||||
meta.setBlockState(shulkerBox);
|
||||
itemstack.setItemMeta(meta);
|
||||
}
|
||||
|
||||
return new Object[] { slot, faceData, itemstack };
|
||||
}
|
||||
|
||||
int itemCount = 0;
|
||||
Builder effectBuilder = FireworkEffect.builder();
|
||||
for (List<Map<String, Object>> map : (List<List<Map<String, Object>>>) list) {
|
||||
if (map.size() == 0) {
|
||||
if (itemCount == 3 && (rowType == Material.FIREWORK_ROCKET || rowType == Material.FIREWORK_STAR)) {
|
||||
buildFireworkEffect(effectBuilder, rowType, itemstack);
|
||||
itemCount = 0;
|
||||
}
|
||||
|
||||
itemCount++;
|
||||
continue;
|
||||
}
|
||||
Map<String, Object> mapData = map.get(0);
|
||||
|
||||
if (mapData.get("slot") != null) {
|
||||
slot = (Integer) mapData.get("slot");
|
||||
}
|
||||
else if (mapData.get("facing") != null) {
|
||||
faceData = (String) mapData.get("facing");
|
||||
}
|
||||
else if (mapData.get("modifiers") != null) {
|
||||
ItemMeta itemMeta = itemstack.getItemMeta();
|
||||
if (itemMeta.hasAttributeModifiers()) {
|
||||
for (Map.Entry<Attribute, AttributeModifier> entry : itemMeta.getAttributeModifiers().entries()) {
|
||||
itemMeta.removeAttributeModifier(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
List<Object> modifiers = (List<Object>) mapData.get("modifiers");
|
||||
|
||||
for (Object item : modifiers) {
|
||||
Map<Attribute, Map<String, Object>> modifiersMap = (Map<Attribute, Map<String, Object>>) item;
|
||||
for (Map.Entry<Attribute, Map<String, Object>> entry : modifiersMap.entrySet()) {
|
||||
try {
|
||||
Attribute attribute = entry.getKey();
|
||||
AttributeModifier modifier = AttributeModifier.deserialize(entry.getValue());
|
||||
itemMeta.addAttributeModifier(attribute, modifier);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
// AttributeModifier already exists
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
itemstack.setItemMeta(itemMeta);
|
||||
}
|
||||
else if (itemCount == 0) {
|
||||
ItemMeta meta = Util.deserializeItemMeta(itemstack.getItemMeta().getClass(), map.get(0));
|
||||
itemstack.setItemMeta(meta);
|
||||
|
||||
if (map.size() > 1 && (rowType == Material.POTION)) {
|
||||
PotionMeta subMeta = (PotionMeta) itemstack.getItemMeta();
|
||||
org.bukkit.Color color = org.bukkit.Color.deserialize(map.get(1));
|
||||
subMeta.setColor(color);
|
||||
itemstack.setItemMeta(subMeta);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((rowType == Material.LEATHER_HORSE_ARMOR) || (rowType == Material.LEATHER_HELMET) || (rowType == Material.LEATHER_CHESTPLATE) || (rowType == Material.LEATHER_LEGGINGS) || (rowType == Material.LEATHER_BOOTS)) { // leather armor
|
||||
for (Map<String, Object> colorData : map) {
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) itemstack.getItemMeta();
|
||||
org.bukkit.Color color = org.bukkit.Color.deserialize(colorData);
|
||||
meta.setColor(color);
|
||||
itemstack.setItemMeta(meta);
|
||||
}
|
||||
}
|
||||
else if ((rowType == Material.POTION)) { // potion
|
||||
for (Map<String, Object> potionData : map) {
|
||||
PotionMeta meta = (PotionMeta) itemstack.getItemMeta();
|
||||
PotionEffect effect = new PotionEffect(potionData);
|
||||
meta.addCustomEffect(effect, true);
|
||||
itemstack.setItemMeta(meta);
|
||||
}
|
||||
}
|
||||
else if (rowType.name().endsWith("_BANNER")) {
|
||||
for (Map<String, Object> patternData : map) {
|
||||
BannerMeta meta = (BannerMeta) itemstack.getItemMeta();
|
||||
Pattern pattern = new Pattern(patternData);
|
||||
meta.addPattern(pattern);
|
||||
itemstack.setItemMeta(meta);
|
||||
}
|
||||
}
|
||||
else if ((rowType == Material.CROSSBOW)) {
|
||||
CrossbowMeta meta = (CrossbowMeta) itemstack.getItemMeta();
|
||||
for (Map<String, Object> itemData : map) {
|
||||
ItemStack crossbowItem = Util.unserializeItemStack(itemData);
|
||||
if (crossbowItem != null) {
|
||||
meta.addChargedProjectile(crossbowItem);
|
||||
}
|
||||
}
|
||||
itemstack.setItemMeta(meta);
|
||||
}
|
||||
else if (rowType == Material.MAP || rowType == Material.FILLED_MAP) {
|
||||
for (Map<String, Object> colorData : map) {
|
||||
MapMeta meta = (MapMeta) itemstack.getItemMeta();
|
||||
org.bukkit.Color color = org.bukkit.Color.deserialize(colorData);
|
||||
meta.setColor(color);
|
||||
itemstack.setItemMeta(meta);
|
||||
}
|
||||
}
|
||||
else if ((rowType == Material.FIREWORK_ROCKET) || (rowType == Material.FIREWORK_STAR)) {
|
||||
if (itemCount == 1) {
|
||||
effectBuilder = FireworkEffect.builder();
|
||||
for (Map<String, Object> fireworkData : map) {
|
||||
org.bukkit.FireworkEffect.Type type = (org.bukkit.FireworkEffect.Type) fireworkData.getOrDefault("type", org.bukkit.FireworkEffect.Type.BALL);
|
||||
boolean hasFlicker = (Boolean) fireworkData.get("flicker");
|
||||
boolean hasTrail = (Boolean) fireworkData.get("trail");
|
||||
effectBuilder.with(type);
|
||||
effectBuilder.flicker(hasFlicker);
|
||||
effectBuilder.trail(hasTrail);
|
||||
}
|
||||
}
|
||||
else if (itemCount == 2) {
|
||||
for (Map<String, Object> colorData : map) {
|
||||
org.bukkit.Color color = org.bukkit.Color.deserialize(colorData);
|
||||
effectBuilder.withColor(color);
|
||||
}
|
||||
}
|
||||
else if (itemCount == 3) {
|
||||
for (Map<String, Object> colorData : map) {
|
||||
org.bukkit.Color color = org.bukkit.Color.deserialize(colorData);
|
||||
effectBuilder.withFade(color);
|
||||
}
|
||||
buildFireworkEffect(effectBuilder, rowType, itemstack);
|
||||
itemCount = 0;
|
||||
}
|
||||
}
|
||||
else if ((rowType == Material.SUSPICIOUS_STEW)) {
|
||||
for (Map<String, Object> suspiciousStewData : map) {
|
||||
SuspiciousStewMeta meta = (SuspiciousStewMeta) itemstack.getItemMeta();
|
||||
PotionEffect effect = new PotionEffect(suspiciousStewData);
|
||||
meta.addCustomEffect(effect, true);
|
||||
itemstack.setItemMeta(meta);
|
||||
}
|
||||
}
|
||||
else {
|
||||
BukkitAdapter.ADAPTER.setItemMeta(rowType, itemstack, map);
|
||||
}
|
||||
}
|
||||
|
||||
itemCount++;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new Object[] { slot, faceData, itemstack };
|
||||
}
|
||||
|
||||
public static Object[] populateItemStack(ItemStack itemstack, byte[] metadata) {
|
||||
if (metadata != null) {
|
||||
try {
|
||||
ByteArrayInputStream metaByteStream = new ByteArrayInputStream(metadata);
|
||||
BukkitObjectInputStream metaObjectStream = new BukkitObjectInputStream(metaByteStream);
|
||||
Object metaList = metaObjectStream.readObject();
|
||||
metaObjectStream.close();
|
||||
metaByteStream.close();
|
||||
|
||||
return populateItemStack(itemstack, metaList);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return new Object[] { 0, "", itemstack };
|
||||
}
|
||||
|
||||
}
|
|
@ -12,13 +12,15 @@ import org.bukkit.block.BlockState;
|
|||
import org.bukkit.util.io.BukkitObjectInputStream;
|
||||
import org.bukkit.util.io.BukkitObjectOutputStream;
|
||||
|
||||
import net.coreprotect.database.Database;
|
||||
|
||||
public class EntityStatement {
|
||||
|
||||
private EntityStatement() {
|
||||
throw new IllegalStateException("Database class");
|
||||
}
|
||||
|
||||
public static void insert(PreparedStatement preparedStmt, int time, List<Object> data) {
|
||||
public static ResultSet insert(PreparedStatement preparedStmt, int time, List<Object> data) {
|
||||
try {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
BukkitObjectOutputStream oos = new BukkitObjectOutputStream(bos);
|
||||
|
@ -30,11 +32,18 @@ public class EntityStatement {
|
|||
byte[] byte_data = bos.toByteArray();
|
||||
preparedStmt.setInt(1, time);
|
||||
preparedStmt.setObject(2, byte_data);
|
||||
preparedStmt.executeUpdate();
|
||||
if (Database.hasReturningKeys()) {
|
||||
return preparedStmt.executeQuery();
|
||||
}
|
||||
else {
|
||||
preparedStmt.executeUpdate();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<Object> getData(Statement statement, BlockState block, String query) {
|
||||
|
|
|
@ -4,12 +4,11 @@ import java.sql.PreparedStatement;
|
|||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class SignStatement {
|
||||
|
||||
|
@ -17,7 +16,7 @@ public class SignStatement {
|
|||
throw new IllegalStateException("Database class");
|
||||
}
|
||||
|
||||
public static void insert(PreparedStatement preparedStmt, int batchCount, int time, int id, int wid, int x, int y, int z, int action, int color, int data, String line1, String line2, String line3, String line4) {
|
||||
public static void insert(PreparedStatement preparedStmt, int batchCount, int time, int id, int wid, int x, int y, int z, int action, int color, int colorSecondary, int data, int waxed, int face, String line1, String line2, String line3, String line4, String line5, String line6, String line7, String line8) {
|
||||
try {
|
||||
preparedStmt.setInt(1, time);
|
||||
preparedStmt.setInt(2, id);
|
||||
|
@ -27,11 +26,18 @@ public class SignStatement {
|
|||
preparedStmt.setInt(6, z);
|
||||
preparedStmt.setInt(7, action);
|
||||
preparedStmt.setInt(8, color);
|
||||
preparedStmt.setInt(9, data);
|
||||
preparedStmt.setString(10, line1);
|
||||
preparedStmt.setString(11, line2);
|
||||
preparedStmt.setString(12, line3);
|
||||
preparedStmt.setString(13, line4);
|
||||
preparedStmt.setInt(9, colorSecondary);
|
||||
preparedStmt.setInt(10, data);
|
||||
preparedStmt.setInt(11, waxed);
|
||||
preparedStmt.setInt(12, face);
|
||||
preparedStmt.setString(13, line1);
|
||||
preparedStmt.setString(14, line2);
|
||||
preparedStmt.setString(15, line3);
|
||||
preparedStmt.setString(16, line4);
|
||||
preparedStmt.setString(17, line5);
|
||||
preparedStmt.setString(18, line6);
|
||||
preparedStmt.setString(19, line7);
|
||||
preparedStmt.setString(20, line8);
|
||||
preparedStmt.addBatch();
|
||||
|
||||
if (batchCount > 0 && batchCount % 1000 == 0) {
|
||||
|
@ -54,24 +60,39 @@ public class SignStatement {
|
|||
|
||||
while (resultSet.next()) {
|
||||
int color = resultSet.getInt("color");
|
||||
int colorSecondary = resultSet.getInt("color_secondary");
|
||||
int data = resultSet.getInt("data");
|
||||
boolean isWaxed = resultSet.getInt("waxed") == 1;
|
||||
// boolean isFront = resultSet.getInt("face") == 0;
|
||||
String line1 = resultSet.getString("line_1");
|
||||
String line2 = resultSet.getString("line_2");
|
||||
String line3 = resultSet.getString("line_3");
|
||||
String line4 = resultSet.getString("line_4");
|
||||
String line5 = resultSet.getString("line_5");
|
||||
String line6 = resultSet.getString("line_6");
|
||||
String line7 = resultSet.getString("line_7");
|
||||
String line8 = resultSet.getString("line_8");
|
||||
|
||||
if (color > 0) {
|
||||
sign.setColor(DyeColor.getByColor(Color.fromRGB(color)));
|
||||
BukkitAdapter.ADAPTER.setColor(sign, true, color);
|
||||
}
|
||||
if (colorSecondary > 0) {
|
||||
BukkitAdapter.ADAPTER.setColor(sign, false, colorSecondary);
|
||||
}
|
||||
|
||||
if (data > 0) {
|
||||
BukkitAdapter.ADAPTER.setGlowing(sign, (data == 1 ? true : false));
|
||||
}
|
||||
|
||||
sign.setLine(0, line1);
|
||||
sign.setLine(1, line2);
|
||||
sign.setLine(2, line3);
|
||||
sign.setLine(3, line4);
|
||||
boolean frontGlowing = Util.isSideGlowing(true, data);
|
||||
boolean backGlowing = Util.isSideGlowing(false, data);
|
||||
BukkitAdapter.ADAPTER.setGlowing(sign, true, frontGlowing);
|
||||
BukkitAdapter.ADAPTER.setGlowing(sign, false, backGlowing);
|
||||
BukkitAdapter.ADAPTER.setLine(sign, 0, line1);
|
||||
BukkitAdapter.ADAPTER.setLine(sign, 1, line2);
|
||||
BukkitAdapter.ADAPTER.setLine(sign, 2, line3);
|
||||
BukkitAdapter.ADAPTER.setLine(sign, 3, line4);
|
||||
BukkitAdapter.ADAPTER.setLine(sign, 4, line5);
|
||||
BukkitAdapter.ADAPTER.setLine(sign, 5, line6);
|
||||
BukkitAdapter.ADAPTER.setLine(sign, 6, line7);
|
||||
BukkitAdapter.ADAPTER.setLine(sign, 7, line8);
|
||||
BukkitAdapter.ADAPTER.setWaxed(sign, isWaxed);
|
||||
}
|
||||
|
||||
resultSet.close();
|
||||
|
|
|
@ -9,21 +9,31 @@ import org.bukkit.Bukkit;
|
|||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Skull;
|
||||
|
||||
import net.coreprotect.database.Database;
|
||||
import net.coreprotect.paper.PaperAdapter;
|
||||
|
||||
public class SkullStatement {
|
||||
|
||||
private SkullStatement() {
|
||||
throw new IllegalStateException("Database class");
|
||||
}
|
||||
|
||||
public static void insert(PreparedStatement preparedStmt, int time, String owner) {
|
||||
public static ResultSet insert(PreparedStatement preparedStmt, int time, String owner) {
|
||||
try {
|
||||
preparedStmt.setInt(1, time);
|
||||
preparedStmt.setString(2, owner);
|
||||
preparedStmt.executeUpdate();
|
||||
if (Database.hasReturningKeys()) {
|
||||
return preparedStmt.executeQuery();
|
||||
}
|
||||
else {
|
||||
preparedStmt.executeUpdate();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void getData(Statement statement, BlockState block, String query) {
|
||||
|
@ -37,9 +47,12 @@ public class SkullStatement {
|
|||
|
||||
while (resultSet.next()) {
|
||||
String owner = resultSet.getString("owner");
|
||||
if (owner != null && owner.length() >= 32) {
|
||||
if (owner != null && owner.length() >= 32 && owner.contains("-")) {
|
||||
skull.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(owner)));
|
||||
}
|
||||
else if (owner != null && owner.length() > 1) {
|
||||
PaperAdapter.ADAPTER.setSkullOwner(skull, owner);
|
||||
}
|
||||
}
|
||||
|
||||
resultSet.close();
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Locale;
|
|||
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.Database;
|
||||
|
||||
public class UserStatement {
|
||||
|
||||
|
@ -21,14 +22,32 @@ public class UserStatement {
|
|||
|
||||
try {
|
||||
int unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||
PreparedStatement preparedStmt = connection.prepareStatement("INSERT INTO " + ConfigHandler.prefix + "user (time, user) VALUES (?, ?)", Statement.RETURN_GENERATED_KEYS);
|
||||
|
||||
PreparedStatement preparedStmt = null;
|
||||
if (Database.hasReturningKeys()) {
|
||||
preparedStmt = connection.prepareStatement("INSERT INTO " + ConfigHandler.prefix + "user (time, user) VALUES (?, ?) RETURNING rowid");
|
||||
}
|
||||
else {
|
||||
preparedStmt = connection.prepareStatement("INSERT INTO " + ConfigHandler.prefix + "user (time, user) VALUES (?, ?)", Statement.RETURN_GENERATED_KEYS);
|
||||
}
|
||||
|
||||
preparedStmt.setInt(1, unixtimestamp);
|
||||
preparedStmt.setString(2, user);
|
||||
preparedStmt.executeUpdate();
|
||||
ResultSet keys = preparedStmt.getGeneratedKeys();
|
||||
keys.next();
|
||||
id = keys.getInt(1);
|
||||
keys.close();
|
||||
|
||||
if (Database.hasReturningKeys()) {
|
||||
ResultSet resultSet = preparedStmt.executeQuery();
|
||||
resultSet.next();
|
||||
id = resultSet.getInt(1);
|
||||
resultSet.close();
|
||||
}
|
||||
else {
|
||||
preparedStmt.executeUpdate();
|
||||
ResultSet keys = preparedStmt.getGeneratedKeys();
|
||||
keys.next();
|
||||
id = keys.getInt(1);
|
||||
keys.close();
|
||||
}
|
||||
|
||||
preparedStmt.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package net.coreprotect.event;
|
||||
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class CoreProtectPreLogEvent extends Event {
|
||||
public class CoreProtectPreLogEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled = false;
|
||||
private String user;
|
||||
|
||||
public CoreProtectPreLogEvent(String user) {
|
||||
|
@ -17,6 +19,16 @@ public class CoreProtectPreLogEvent extends Event {
|
|||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
public void setUser(String newUser) {
|
||||
if (newUser == null || newUser.isEmpty()) {
|
||||
throw new IllegalArgumentException("Invalid user");
|
||||
|
|
|
@ -52,7 +52,7 @@ public class Language {
|
|||
phrases.put(Phrase.DATABASE_LOCKED_4, "Disabling database locking can result in data corruption.");
|
||||
phrases.put(Phrase.DATABASE_UNREACHABLE, "Database is unreachable. Discarding data and shutting down.");
|
||||
phrases.put(Phrase.DEVELOPMENT_BRANCH, "Development branch detected, skipping patch scripts.");
|
||||
phrases.put(Phrase.DIRT_BLOCK, "Placed a dirt block under you.");
|
||||
phrases.put(Phrase.DIRT_BLOCK, "Placed a temporary safety block under you.");
|
||||
phrases.put(Phrase.DISABLE_SUCCESS, "Success! Disabled {0}");
|
||||
phrases.put(Phrase.ENABLE_FAILED, "{0} was unable to start.");
|
||||
phrases.put(Phrase.ENABLE_SUCCESS, "{0} has been successfully enabled!");
|
||||
|
|
|
@ -216,7 +216,8 @@ public enum Phrase {
|
|||
|
||||
final private static Set<Phrase> HEADERS = new HashSet<>(Arrays.asList(Phrase.CONTAINER_HEADER, Phrase.HELP_HEADER, Phrase.INTERACTIONS_HEADER, Phrase.LOOKUP_HEADER, Phrase.SIGN_HEADER, Phrase.UPDATE_HEADER));
|
||||
final private static Set<String> COLORS = new HashSet<>(Arrays.asList(Color.WHITE, Color.DARK_AQUA));
|
||||
final private static String split = ":";
|
||||
final private static String SPLIT = ":";
|
||||
final private static String FULL_WIDTH_SPLIT = ":";
|
||||
|
||||
public String getPhrase() {
|
||||
return Language.getPhrase(this);
|
||||
|
@ -265,7 +266,8 @@ public enum Phrase {
|
|||
}
|
||||
|
||||
if (color.length() > 0) {
|
||||
output = output.replaceFirst(split, split + color);
|
||||
output = output.replaceFirst(SPLIT, SPLIT + color);
|
||||
output = output.replaceFirst(FULL_WIDTH_SPLIT, FULL_WIDTH_SPLIT + color);
|
||||
output = ChatMessage.parseQuotes(output, color);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import net.coreprotect.listener.block.BlockIgniteListener;
|
|||
import net.coreprotect.listener.block.BlockPistonListener;
|
||||
import net.coreprotect.listener.block.BlockPlaceListener;
|
||||
import net.coreprotect.listener.block.BlockSpreadListener;
|
||||
import net.coreprotect.listener.block.CampfireStartListener;
|
||||
import net.coreprotect.listener.channel.PluginChannelHandshakeListener;
|
||||
import net.coreprotect.listener.channel.PluginChannelListener;
|
||||
import net.coreprotect.listener.entity.CreatureSpawnListener;
|
||||
|
@ -44,6 +45,7 @@ import net.coreprotect.listener.player.PlayerInteractEntityListener;
|
|||
import net.coreprotect.listener.player.PlayerInteractListener;
|
||||
import net.coreprotect.listener.player.PlayerItemBreakListener;
|
||||
import net.coreprotect.listener.player.PlayerJoinListener;
|
||||
import net.coreprotect.listener.player.PlayerPickupArrowListener;
|
||||
import net.coreprotect.listener.player.PlayerQuitListener;
|
||||
import net.coreprotect.listener.player.PlayerTakeLecternBookListener;
|
||||
import net.coreprotect.listener.player.ProjectileLaunchListener;
|
||||
|
@ -52,6 +54,7 @@ import net.coreprotect.listener.world.ChunkPopulateListener;
|
|||
import net.coreprotect.listener.world.LeavesDecayListener;
|
||||
import net.coreprotect.listener.world.PortalCreateListener;
|
||||
import net.coreprotect.listener.world.StructureGrowListener;
|
||||
import net.coreprotect.paper.listener.BlockPreDispenseListener;
|
||||
import net.coreprotect.paper.listener.PaperChatListener;
|
||||
|
||||
public final class ListenerHandler {
|
||||
|
@ -60,6 +63,15 @@ public final class ListenerHandler {
|
|||
|
||||
PluginManager pluginManager = plugin.getServer().getPluginManager();
|
||||
|
||||
// Paper Listeners / Fallbacks (Block Listeners)
|
||||
try {
|
||||
Class.forName("io.papermc.paper.event.block.BlockPreDispenseEvent"); // Paper 1.16+
|
||||
pluginManager.registerEvents(new BlockPreDispenseListener(), plugin);
|
||||
}
|
||||
catch (Exception e) {
|
||||
BlockPreDispenseListener.useBlockPreDispenseEvent = false;
|
||||
}
|
||||
|
||||
// Block Listeners
|
||||
pluginManager.registerEvents(new BlockBreakListener(), plugin);
|
||||
pluginManager.registerEvents(new BlockBurnListener(), plugin);
|
||||
|
@ -73,6 +85,13 @@ public final class ListenerHandler {
|
|||
pluginManager.registerEvents(new BlockPistonListener(), plugin);
|
||||
pluginManager.registerEvents(new BlockPlaceListener(), plugin);
|
||||
pluginManager.registerEvents(new BlockSpreadListener(), plugin);
|
||||
try {
|
||||
Class.forName("org.bukkit.event.block.CampfireStartEvent"); // Bukkit 1.20+
|
||||
pluginManager.registerEvents(new CampfireStartListener(), plugin);
|
||||
}
|
||||
catch (Exception e) {
|
||||
CampfireStartListener.useCampfireStartEvent = false;
|
||||
}
|
||||
|
||||
// Entity Listeners
|
||||
pluginManager.registerEvents(new CreatureSpawnListener(), plugin);
|
||||
|
@ -88,6 +107,15 @@ public final class ListenerHandler {
|
|||
pluginManager.registerEvents(new HangingBreakListener(), plugin);
|
||||
pluginManager.registerEvents(new HangingBreakByEntityListener(), plugin);
|
||||
|
||||
// Paper Listeners / Fallbacks (Player Listeners)
|
||||
try {
|
||||
Class.forName("net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer"); // Paper 1.16+
|
||||
pluginManager.registerEvents(new PaperChatListener(), plugin);
|
||||
}
|
||||
catch (Exception e) {
|
||||
pluginManager.registerEvents(new PlayerChatListener(), plugin);
|
||||
}
|
||||
|
||||
// Player Listeners
|
||||
pluginManager.registerEvents(new ArmorStandManipulateListener(), plugin);
|
||||
pluginManager.registerEvents(new CraftItemListener(), plugin);
|
||||
|
@ -115,15 +143,6 @@ public final class ListenerHandler {
|
|||
pluginManager.registerEvents(new PortalCreateListener(), plugin);
|
||||
pluginManager.registerEvents(new StructureGrowListener(), plugin);
|
||||
|
||||
// Paper Listeners / Fallbacks
|
||||
try {
|
||||
Class.forName("net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer");
|
||||
pluginManager.registerEvents(new PaperChatListener(), plugin);
|
||||
}
|
||||
catch (Exception e) {
|
||||
pluginManager.registerEvents(new PlayerChatListener(), plugin);
|
||||
}
|
||||
|
||||
// Plugin channel events
|
||||
pluginManager.registerEvents(new PluginChannelListener(), plugin);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import java.util.Locale;
|
|||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Banner;
|
||||
import org.bukkit.block.Block;
|
||||
|
@ -38,6 +37,7 @@ import net.coreprotect.config.Config;
|
|||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.database.Database;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.paper.PaperAdapter;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public final class BlockBreakListener extends Queue implements Listener {
|
||||
|
@ -125,7 +125,7 @@ public final class BlockBreakListener extends Queue implements Listener {
|
|||
Block scanBlock = world.getBlockAt(scanLocation);
|
||||
Material scanType = scanBlock.getType();
|
||||
if (scanMin == 5) {
|
||||
if (scanType.hasGravity()) {
|
||||
if (scanType.hasGravity() || BukkitAdapter.ADAPTER.isSuspiciousBlock(scanType)) {
|
||||
if (Config.getConfig(world).BLOCK_MOVEMENT) {
|
||||
// log the top-most sand/gravel block as being removed
|
||||
int scanY = y + 2;
|
||||
|
@ -133,7 +133,7 @@ public final class BlockBreakListener extends Queue implements Listener {
|
|||
while (!topFound) {
|
||||
Block topBlock = world.getBlockAt(x, scanY, z);
|
||||
Material topMaterial = topBlock.getType();
|
||||
if (!topMaterial.hasGravity()) {
|
||||
if (!topMaterial.hasGravity() && !BukkitAdapter.ADAPTER.isSuspiciousBlock(topMaterial)) {
|
||||
scanLocation = new Location(world, x, (scanY - 1), z);
|
||||
topFound = true;
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ public final class BlockBreakListener extends Queue implements Listener {
|
|||
}
|
||||
}
|
||||
else if (scanMin == 5) {
|
||||
if (scanType.hasGravity()) {
|
||||
if (scanType.hasGravity() || BukkitAdapter.ADAPTER.isSuspiciousBlock(scanType)) {
|
||||
log = true;
|
||||
}
|
||||
}
|
||||
|
@ -273,18 +273,28 @@ public final class BlockBreakListener extends Queue implements Listener {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (log && Tag.SIGNS.isTagged(blockType)) {
|
||||
if (log && BukkitAdapter.ADAPTER.isSign(blockType)) {
|
||||
if (Config.getConfig(world).SIGN_TEXT) {
|
||||
try {
|
||||
Location location = blockState.getLocation();
|
||||
Sign sign = (Sign) blockLog.getState();
|
||||
String line1 = sign.getLine(0);
|
||||
String line2 = sign.getLine(1);
|
||||
String line3 = sign.getLine(2);
|
||||
String line4 = sign.getLine(3);
|
||||
int color = sign.getColor().getColor().asRGB();
|
||||
boolean isGlowing = BukkitAdapter.ADAPTER.isGlowing(sign);
|
||||
Queue.queueSignText(user, location, 0, color, isGlowing, line1, line2, line3, line4, 5);
|
||||
String line1 = PaperAdapter.ADAPTER.getLine(sign, 0);
|
||||
String line2 = PaperAdapter.ADAPTER.getLine(sign, 1);
|
||||
String line3 = PaperAdapter.ADAPTER.getLine(sign, 2);
|
||||
String line4 = PaperAdapter.ADAPTER.getLine(sign, 3);
|
||||
String line5 = PaperAdapter.ADAPTER.getLine(sign, 4);
|
||||
String line6 = PaperAdapter.ADAPTER.getLine(sign, 5);
|
||||
String line7 = PaperAdapter.ADAPTER.getLine(sign, 6);
|
||||
String line8 = PaperAdapter.ADAPTER.getLine(sign, 7);
|
||||
|
||||
boolean isFront = true;
|
||||
int color = BukkitAdapter.ADAPTER.getColor(sign, isFront);
|
||||
int colorSecondary = BukkitAdapter.ADAPTER.getColor(sign, !isFront);
|
||||
boolean frontGlowing = BukkitAdapter.ADAPTER.isGlowing(sign, isFront);
|
||||
boolean backGlowing = BukkitAdapter.ADAPTER.isGlowing(sign, !isFront);
|
||||
boolean isWaxed = BukkitAdapter.ADAPTER.isWaxed(sign);
|
||||
|
||||
Queue.queueSignText(user, location, 0, color, colorSecondary, frontGlowing, backGlowing, isWaxed, isFront, line1, line2, line3, line4, line5, line6, line7, line8, 5);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -315,7 +325,10 @@ public final class BlockBreakListener extends Queue implements Listener {
|
|||
}
|
||||
|
||||
for (Block placementBlock : placementMap) {
|
||||
queueBlockPlace(user, block.getState(), placementBlock.getType(), null, null, -1, 0, placementBlock.getBlockData().getAsString());
|
||||
Material placementType = placementBlock.getType();
|
||||
if (placementType.hasGravity()) {
|
||||
queueBlockPlace(user, block.getState(), placementType, null, null, -1, 0, placementBlock.getBlockData().getAsString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import net.coreprotect.config.Config;
|
|||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.listener.player.InventoryChangeListener;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.paper.listener.BlockPreDispenseListener;
|
||||
import net.coreprotect.thread.CacheHandler;
|
||||
|
||||
public final class BlockDispenseListener extends Queue implements Listener {
|
||||
|
@ -48,20 +49,22 @@ public final class BlockDispenseListener extends Queue implements Listener {
|
|||
boolean dispenseSuccess = !event.getVelocity().equals(new Vector()); // true if velocity is set
|
||||
boolean dispenseRelative = newBlock.getLocation().equals(velocityLocation); // true if velocity location matches relative location
|
||||
|
||||
if (dispenseRelative || material.equals(Material.FLINT_AND_STEEL) || material.equals(Material.SHEARS)) {
|
||||
forceItem = false;
|
||||
}
|
||||
if (!BlockPreDispenseListener.useBlockPreDispenseEvent || (!BlockPreDispenseListener.useForDroppers && block.getType() == Material.DROPPER)) {
|
||||
if (dispenseRelative || material.equals(Material.FLINT_AND_STEEL) || material.equals(Material.SHEARS)) {
|
||||
forceItem = false;
|
||||
}
|
||||
|
||||
if (block.getType() == Material.DROPPER) {
|
||||
forceItem = true; // droppers always drop items
|
||||
}
|
||||
if (block.getType() == Material.DROPPER) {
|
||||
forceItem = true; // droppers always drop items
|
||||
}
|
||||
|
||||
ItemStack[] inventory = ((InventoryHolder) block.getState()).getInventory().getStorageContents();
|
||||
if (forceItem) {
|
||||
inventory = Arrays.copyOf(inventory, inventory.length + 1);
|
||||
inventory[inventory.length - 1] = item;
|
||||
ItemStack[] inventory = ((InventoryHolder) block.getState()).getInventory().getStorageContents();
|
||||
if (forceItem) {
|
||||
inventory = Arrays.copyOf(inventory, inventory.length + 1);
|
||||
inventory[inventory.length - 1] = item;
|
||||
}
|
||||
InventoryChangeListener.inventoryTransaction(user, block.getLocation(), inventory);
|
||||
}
|
||||
InventoryChangeListener.inventoryTransaction(user, block.getLocation(), inventory);
|
||||
|
||||
if (material.equals(Material.WATER_BUCKET)) {
|
||||
type = Material.WATER;
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package net.coreprotect.listener.block;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
@ -26,6 +25,7 @@ import net.coreprotect.config.Config;
|
|||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.database.Database;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.paper.PaperAdapter;
|
||||
|
||||
public final class BlockExplodeListener extends Queue implements Listener {
|
||||
|
||||
|
@ -37,9 +37,7 @@ public final class BlockExplodeListener extends Queue implements Listener {
|
|||
}
|
||||
|
||||
if (Config.getConfig(world).NATURAL_BREAK) {
|
||||
Iterator<Map.Entry<Location, Block>> it = new HashMap<>(blockMap).entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<Location, Block> data = it.next();
|
||||
for (Entry<Location, Block> data : new HashMap<>(blockMap).entrySet()) {
|
||||
Block block = data.getValue();
|
||||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
|
@ -114,17 +112,27 @@ public final class BlockExplodeListener extends Queue implements Listener {
|
|||
Block block = entry.getValue();
|
||||
Material blockType = block.getType();
|
||||
BlockState blockState = block.getState();
|
||||
if (Tag.SIGNS.isTagged(blockType) && Config.getConfig(world).SIGN_TEXT) {
|
||||
if (BukkitAdapter.ADAPTER.isSign(blockType) && Config.getConfig(world).SIGN_TEXT) {
|
||||
try {
|
||||
Location location = blockState.getLocation();
|
||||
Sign sign = (Sign) blockState;
|
||||
String line1 = sign.getLine(0);
|
||||
String line2 = sign.getLine(1);
|
||||
String line3 = sign.getLine(2);
|
||||
String line4 = sign.getLine(3);
|
||||
int color = sign.getColor().getColor().asRGB();
|
||||
boolean isGlowing = BukkitAdapter.ADAPTER.isGlowing(sign);
|
||||
Queue.queueSignText(user, location, 0, color, isGlowing, line1, line2, line3, line4, 5);
|
||||
String line1 = PaperAdapter.ADAPTER.getLine(sign, 0);
|
||||
String line2 = PaperAdapter.ADAPTER.getLine(sign, 1);
|
||||
String line3 = PaperAdapter.ADAPTER.getLine(sign, 2);
|
||||
String line4 = PaperAdapter.ADAPTER.getLine(sign, 3);
|
||||
String line5 = PaperAdapter.ADAPTER.getLine(sign, 4);
|
||||
String line6 = PaperAdapter.ADAPTER.getLine(sign, 5);
|
||||
String line7 = PaperAdapter.ADAPTER.getLine(sign, 6);
|
||||
String line8 = PaperAdapter.ADAPTER.getLine(sign, 7);
|
||||
|
||||
boolean isFront = true;
|
||||
int color = BukkitAdapter.ADAPTER.getColor(sign, isFront);
|
||||
int colorSecondary = BukkitAdapter.ADAPTER.getColor(sign, !isFront);
|
||||
boolean frontGlowing = BukkitAdapter.ADAPTER.isGlowing(sign, isFront);
|
||||
boolean backGlowing = BukkitAdapter.ADAPTER.isGlowing(sign, !isFront);
|
||||
boolean isWaxed = BukkitAdapter.ADAPTER.isWaxed(sign);
|
||||
|
||||
Queue.queueSignText(user, location, 0, color, colorSecondary, frontGlowing, backGlowing, isWaxed, isFront, line1, line2, line3, line4, line5, line6, line7, line8, 5);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -148,7 +156,7 @@ public final class BlockExplodeListener extends Queue implements Listener {
|
|||
user = "#tnt";
|
||||
}
|
||||
else if (user.contains("end_crystal")) {
|
||||
user = "#endercrystal";
|
||||
user = "#ender_crystal";
|
||||
}
|
||||
if (!user.startsWith("#")) {
|
||||
user = "#explosion";
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
package net.coreprotect.listener.block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockFertilizeEvent;
|
||||
|
||||
|
@ -17,7 +20,7 @@ import net.coreprotect.thread.CacheHandler;
|
|||
|
||||
public final class BlockFertilizeListener extends Queue implements Listener {
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
protected void onBlockFertilize(BlockFertilizeEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
|
@ -30,7 +33,14 @@ public final class BlockFertilizeListener extends Queue implements Listener {
|
|||
|
||||
Location location = block.getLocation();
|
||||
List<BlockState> blocks = event.getBlocks();
|
||||
if (blocks.size() == 1 && blocks.get(0).getLocation().equals(location) && Tag.SAPLINGS.isTagged(block.getType())) {
|
||||
|
||||
if (Tag.SAPLINGS.isTagged(block.getType()) && (!Config.getConfig(location.getWorld()).TREE_GROWTH || (blocks.size() == 1 && blocks.get(0).getLocation().equals(location)))) {
|
||||
return;
|
||||
}
|
||||
if (block.getType().name().toLowerCase(Locale.ROOT).contains("mushroom") && (!Config.getConfig(location.getWorld()).MUSHROOM_GROWTH || (blocks.size() == 1 && blocks.get(0).getLocation().equals(location)))) {
|
||||
return;
|
||||
}
|
||||
if (block.getType() == Material.AIR && blocks.size() > 1 && Tag.LOGS.isTagged(blocks.get(1).getType()) && !Config.getConfig(location.getWorld()).TREE_GROWTH) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,10 +20,11 @@ public final class BlockFormListener extends Queue implements Listener {
|
|||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
protected void onBlockForm(BlockFormEvent event) {
|
||||
// random form, snow/ice
|
||||
World world = event.getBlock().getWorld();
|
||||
Block block = event.getBlock();
|
||||
World world = block.getWorld();
|
||||
BlockState newState = event.getNewState();
|
||||
if (Config.getConfig(world).LIQUID_TRACKING && (newState.getType().equals(Material.OBSIDIAN) || newState.getType().equals(Material.COBBLESTONE) || event.getBlock().getType().name().endsWith("_CONCRETE_POWDER"))) {
|
||||
Block block = event.getBlock();
|
||||
boolean log = false;
|
||||
if (Config.getConfig(world).LIQUID_TRACKING && (newState.getType().equals(Material.OBSIDIAN) || newState.getType().equals(Material.COBBLESTONE) || block.getType().name().endsWith("_CONCRETE_POWDER"))) {
|
||||
String player = Lookup.whoPlacedCache(block);
|
||||
int wid = Util.getWorldId(world.getName());
|
||||
if (!(player.length() > 0)) {
|
||||
|
@ -58,7 +59,7 @@ public final class BlockFormListener extends Queue implements Listener {
|
|||
}
|
||||
}
|
||||
if (player.length() > 0) {
|
||||
boolean log = true;
|
||||
log = true;
|
||||
/*
|
||||
if (newState.getType().equals(Material.COBBLESTONE)) {
|
||||
log = false;
|
||||
|
@ -78,6 +79,9 @@ public final class BlockFormListener extends Queue implements Listener {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!log && Config.getConfig(world).UNKNOWN_LOGGING && Lookup.whoPlacedCache(block).length() == 0) {
|
||||
Queue.queueBlockPlace("#unknown", block.getLocation().getBlock().getState(), block.getType(), block.getState(), newState.getType(), -1, 0, newState.getBlockData().getAsString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -75,10 +75,10 @@ public final class BlockFromToListener extends Queue implements Listener {
|
|||
}
|
||||
|
||||
if (f.startsWith("#")) {
|
||||
Location location = toBlock.getLocation();
|
||||
String cacheId = toBlock.getX() + "." + toBlock.getY() + "." + toBlock.getZ() + "." + Util.getWorldId(toBlock.getWorld().getName());
|
||||
int timestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||
Object[] cacheData = CacheHandler.spreadCache.get(location);
|
||||
CacheHandler.spreadCache.put(location, new Object[] { timestamp, type });
|
||||
Object[] cacheData = CacheHandler.spreadCache.get(cacheId);
|
||||
CacheHandler.spreadCache.put(cacheId, new Object[] { timestamp, type });
|
||||
if (toBlockState == null && cacheData != null && ((Material) cacheData[1]) == type) {
|
||||
return;
|
||||
}
|
||||
|
@ -87,6 +87,39 @@ public final class BlockFromToListener extends Queue implements Listener {
|
|||
CacheHandler.lookupCache.put("" + x + "." + y + "." + z + "." + wid + "", new Object[] { unixtimestamp, f, type });
|
||||
Queue.queueBlockPlace(f, toBlock.getState(), block.getType(), toBlockState, type, -1, 0, blockData.getAsString());
|
||||
}
|
||||
else if (type.equals(Material.DRAGON_EGG)) {
|
||||
Location location = block.getLocation();
|
||||
int worldId = Util.getWorldId(location.getWorld().getName());
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
String coordinates = x + "." + y + "." + z + "." + worldId + "." + type.name();
|
||||
String user = "#entity";
|
||||
|
||||
Object[] data = CacheHandler.interactCache.get(coordinates);
|
||||
if (data != null && data[1] == Material.DRAGON_EGG) {
|
||||
long newTime = System.currentTimeMillis();
|
||||
long oldTime = (long) data[0];
|
||||
|
||||
if ((newTime - oldTime) < 20) { // 50ms = 1 tick
|
||||
user = (String) data[2];
|
||||
}
|
||||
CacheHandler.interactCache.remove(coordinates);
|
||||
}
|
||||
|
||||
if (Config.getConfig(block.getWorld()).BLOCK_BREAK) {
|
||||
Queue.queueBlockBreak(user, block.getState(), block.getType(), block.getBlockData().getAsString(), 0);
|
||||
}
|
||||
if (Config.getConfig(block.getWorld()).BLOCK_PLACE) {
|
||||
Block toBlock = event.getToBlock();
|
||||
BlockState toBlockState = toBlock.getState();
|
||||
if (Config.getConfig(world).BLOCK_MOVEMENT) {
|
||||
toBlockState = BlockUtil.gravityScan(toBlock.getLocation(), type, user).getState();
|
||||
}
|
||||
|
||||
Queue.queueBlockPlace(user, toBlockState, block.getType(), toBlockState, type, -1, 0, blockData.getAsString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.util.Locale;
|
|||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
@ -28,6 +27,7 @@ import net.coreprotect.config.Config;
|
|||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.listener.player.InventoryChangeListener;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.paper.PaperAdapter;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public final class BlockPlaceListener extends Queue implements Listener {
|
||||
|
@ -106,19 +106,29 @@ public final class BlockPlaceListener extends Queue implements Listener {
|
|||
|
||||
Queue.queueBlockPlace(player.getName(), blockState, blockPlaced.getType(), blockReplaced, forceType, forceData, 0, bBlockData);
|
||||
|
||||
if (Tag.SIGNS.isTagged(blockType)) {
|
||||
if (BukkitAdapter.ADAPTER.isSign(blockType)) {
|
||||
if (Config.getConfig(world).SIGN_TEXT) {
|
||||
try {
|
||||
Location location = blockState.getLocation();
|
||||
Sign sign = (Sign) blockState;
|
||||
String line1 = sign.getLine(0);
|
||||
String line2 = sign.getLine(1);
|
||||
String line3 = sign.getLine(2);
|
||||
String line4 = sign.getLine(3);
|
||||
int color = sign.getColor().getColor().asRGB();
|
||||
boolean isGlowing = BukkitAdapter.ADAPTER.isGlowing(sign);
|
||||
if (line1.length() > 0 || line2.length() > 0 || line3.length() > 0 || line4.length() > 0) {
|
||||
Queue.queueSignText(player.getName(), location, 1, color, isGlowing, line1, line2, line3, line4, 0);
|
||||
String line1 = PaperAdapter.ADAPTER.getLine(sign, 0);
|
||||
String line2 = PaperAdapter.ADAPTER.getLine(sign, 1);
|
||||
String line3 = PaperAdapter.ADAPTER.getLine(sign, 2);
|
||||
String line4 = PaperAdapter.ADAPTER.getLine(sign, 3);
|
||||
String line5 = PaperAdapter.ADAPTER.getLine(sign, 4);
|
||||
String line6 = PaperAdapter.ADAPTER.getLine(sign, 5);
|
||||
String line7 = PaperAdapter.ADAPTER.getLine(sign, 6);
|
||||
String line8 = PaperAdapter.ADAPTER.getLine(sign, 7);
|
||||
|
||||
boolean isFront = true;
|
||||
int color = BukkitAdapter.ADAPTER.getColor(sign, isFront);
|
||||
int colorSecondary = BukkitAdapter.ADAPTER.getColor(sign, !isFront);
|
||||
boolean frontGlowing = BukkitAdapter.ADAPTER.isGlowing(sign, isFront);
|
||||
boolean backGlowing = BukkitAdapter.ADAPTER.isGlowing(sign, !isFront);
|
||||
boolean isWaxed = BukkitAdapter.ADAPTER.isWaxed(sign);
|
||||
|
||||
if (line1.length() > 0 || line2.length() > 0 || line3.length() > 0 || line4.length() > 0 || line5.length() > 0 || line6.length() > 0 || line7.length() > 0 || line8.length() > 0) {
|
||||
Queue.queueSignText(player.getName(), location, 1, color, colorSecondary, frontGlowing, backGlowing, isWaxed, isFront, line1, line2, line3, line4, line5, line6, line7, line8, 0);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.coreprotect.config.Config;
|
|||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.thread.CacheHandler;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public final class BlockSpreadListener extends Queue implements Listener {
|
||||
|
||||
|
@ -81,10 +82,11 @@ public final class BlockSpreadListener extends Queue implements Listener {
|
|||
}
|
||||
|
||||
private boolean checkCacheData(Block block, Material type) {
|
||||
String cacheId = block.getX() + "." + block.getY() + "." + block.getZ() + "." + Util.getWorldId(block.getWorld().getName());
|
||||
Location location = block.getLocation();
|
||||
int timestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||
Object[] cacheData = CacheHandler.spreadCache.get(location);
|
||||
CacheHandler.spreadCache.put(location, new Object[] { timestamp, type });
|
||||
Object[] cacheData = CacheHandler.spreadCache.get(cacheId);
|
||||
CacheHandler.spreadCache.put(cacheId, new Object[] { timestamp, type });
|
||||
if (cacheData != null && ((Material) cacheData[1]) == type) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package net.coreprotect.listener.block;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.CampfireStartEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.listener.player.PlayerDropItemListener;
|
||||
import net.coreprotect.thread.CacheHandler;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public final class CampfireStartListener extends Queue implements Listener {
|
||||
|
||||
public static boolean useCampfireStartEvent = true;
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
protected void onCampfireStart(CampfireStartEvent event) {
|
||||
Block block = event.getBlock();
|
||||
Location location = block.getLocation();
|
||||
int worldId = Util.getWorldId(location.getWorld().getName());
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
String coordinates = x + "." + y + "." + z + "." + worldId + "." + block.getType().name();
|
||||
String user = "#entity";
|
||||
|
||||
Object[] data = CacheHandler.interactCache.get(coordinates);
|
||||
if (data != null && data[1].equals(event.getSource())) {
|
||||
long newTime = System.currentTimeMillis();
|
||||
long oldTime = (long) data[0];
|
||||
if ((newTime - oldTime) < 20) { // 50ms = 1 tick
|
||||
user = (String) data[2];
|
||||
}
|
||||
CacheHandler.interactCache.remove(coordinates);
|
||||
}
|
||||
|
||||
if (user.equals("#entity")) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack itemStack = event.getSource().clone();
|
||||
itemStack.setAmount(1);
|
||||
PlayerDropItemListener.playerDropItem(event.getBlock().getLocation(), user, itemStack);
|
||||
}
|
||||
|
||||
}
|
|
@ -40,9 +40,9 @@ public final class CreatureSpawnListener extends Queue implements Listener {
|
|||
Map.Entry<String, Object[]> pair = it.next();
|
||||
String name = pair.getKey();
|
||||
Object[] data = pair.getValue();
|
||||
if ((data[0].equals(key) || data[1].equals(key)) && Util.getEntityMaterial(event.getEntityType()) == ((ItemStack) data[2]).getType()) {
|
||||
if ((data[1].equals(key) || data[2].equals(key)) && Util.getEntityMaterial(event.getEntityType()) == ((ItemStack) data[3]).getType()) {
|
||||
Block gravityLocation = BlockUtil.gravityScan(location, Material.ARMOR_STAND, name);
|
||||
Queue.queueBlockPlace(name, gravityLocation.getState(), location.getBlock().getType(), location.getBlock().getState(), ((ItemStack) data[2]).getType(), (int) event.getEntity().getLocation().getYaw(), 1, null);
|
||||
Queue.queueBlockPlace(name, gravityLocation.getState(), location.getBlock().getType(), location.getBlock().getState(), ((ItemStack) data[3]).getType(), (int) event.getEntity().getLocation().getYaw(), 1, null);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
|
@ -45,7 +46,9 @@ public final class EntityDamageByBlockListener extends Queue implements Listener
|
|||
if (entity instanceof ItemFrame && Config.getConfig(entity.getWorld()).ITEM_TRANSACTIONS) {
|
||||
ItemFrame frame = (ItemFrame) entity;
|
||||
if (frame.getItem().getType() != Material.AIR) {
|
||||
PlayerInteractEntityListener.queueFrameTransaction(user, frame, false);
|
||||
ItemStack[] oldState = new ItemStack[] { frame.getItem().clone() };
|
||||
ItemStack[] newState = new ItemStack[] { new ItemStack(Material.AIR) };
|
||||
PlayerInteractEntityListener.queueContainerSpecifiedItems(user, Material.ITEM_FRAME, new Object[] { oldState, newState, frame.getFacing() }, frame.getLocation(), false);
|
||||
}
|
||||
}
|
||||
else if (entity instanceof ArmorStand && Config.getConfig(entity.getWorld()).BLOCK_BREAK) {
|
||||
|
|
|
@ -2,7 +2,6 @@ package net.coreprotect.listener.entity;
|
|||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
@ -35,6 +34,7 @@ import net.coreprotect.config.ConfigHandler;
|
|||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.database.Database;
|
||||
import net.coreprotect.listener.player.PlayerInteractEntityListener;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public final class EntityDamageByEntityListener extends Queue implements Listener {
|
||||
|
@ -113,7 +113,9 @@ public final class EntityDamageByEntityListener extends Queue implements Listene
|
|||
if (entity instanceof ItemFrame && Config.getConfig(entityLocation.getWorld()).ITEM_TRANSACTIONS) {
|
||||
ItemFrame frame = (ItemFrame) entity;
|
||||
if (frame.getItem().getType() != Material.AIR) {
|
||||
PlayerInteractEntityListener.queueFrameTransaction(user, frame, logDrops);
|
||||
ItemStack[] oldState = new ItemStack[] { frame.getItem().clone() };
|
||||
ItemStack[] newState = new ItemStack[] { new ItemStack(Material.AIR) };
|
||||
PlayerInteractEntityListener.queueContainerSpecifiedItems(user, Material.ITEM_FRAME, new Object[] { oldState, newState, frame.getFacing() }, frame.getLocation(), logDrops);
|
||||
}
|
||||
}
|
||||
else if (entity instanceof EnderCrystal && Config.getConfig(entity.getWorld()).BLOCK_BREAK) {
|
||||
|
@ -125,13 +127,13 @@ public final class EntityDamageByEntityListener extends Queue implements Listene
|
|||
if (Config.getConfig(entityLocation.getWorld()).ITEM_TRANSACTIONS) {
|
||||
String killer = user;
|
||||
ItemStack[] contents = Util.getContainerContents(Material.ARMOR_STAND, entity, block.getLocation());
|
||||
Bukkit.getScheduler().runTask(CoreProtect.getInstance(), () -> {
|
||||
Scheduler.runTask(CoreProtect.getInstance(), () -> {
|
||||
if (entity != null && entity.isDead()) {
|
||||
entityLocation.setY(entityLocation.getY() + 0.99);
|
||||
Database.containerBreakCheck(killer, Material.ARMOR_STAND, entity, contents, block.getLocation());
|
||||
Queue.queueBlockBreak(killer, block.getState(), Material.ARMOR_STAND, null, (int) entityLocation.getYaw());
|
||||
}
|
||||
});
|
||||
}, entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.coreprotect.listener.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
@ -20,6 +21,7 @@ import org.bukkit.entity.AbstractHorse;
|
|||
import org.bukkit.entity.AbstractVillager;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Bee;
|
||||
import org.bukkit.entity.Cat;
|
||||
import org.bukkit.entity.ChestedHorse;
|
||||
import org.bukkit.entity.Creeper;
|
||||
|
@ -66,6 +68,7 @@ import net.coreprotect.CoreProtect;
|
|||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.serialize.ItemMetaHandler;
|
||||
|
||||
public final class EntityDeathListener extends Queue implements Listener {
|
||||
|
@ -95,13 +98,13 @@ public final class EntityDeathListener extends Queue implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(CoreProtect.getInstance(), () -> {
|
||||
for (LivingEntity entity : entityList) {
|
||||
for (LivingEntity entity : entityList) {
|
||||
Scheduler.runTask(CoreProtect.getInstance(), () -> {
|
||||
if (entity != null && entity.isDead()) {
|
||||
logEntityDeath(entity, "#command");
|
||||
}
|
||||
}
|
||||
});
|
||||
}, entity);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void logEntityDeath(LivingEntity entity, String e) {
|
||||
|
@ -119,8 +122,11 @@ public final class EntityDeathListener extends Queue implements Listener {
|
|||
e = isCommand ? "#command" : "";
|
||||
}
|
||||
|
||||
List<DamageCause> validDamageCauses = Arrays.asList(DamageCause.SUICIDE, DamageCause.POISON, DamageCause.THORNS, DamageCause.MAGIC, DamageCause.WITHER);
|
||||
|
||||
boolean skip = true;
|
||||
if (!Config.getConfig(entity.getWorld()).SKIP_GENERIC_DATA || (!(entity instanceof Zombie) && !(entity instanceof Skeleton))) {
|
||||
EntityDamageEvent.DamageCause cause = damage.getCause();
|
||||
if (!Config.getConfig(entity.getWorld()).SKIP_GENERIC_DATA || (!(entity instanceof Zombie) && !(entity instanceof Skeleton)) || (validDamageCauses.contains(cause) || cause.name().equals("KILL"))) {
|
||||
skip = false;
|
||||
}
|
||||
|
||||
|
@ -169,7 +175,6 @@ public final class EntityDeathListener extends Queue implements Listener {
|
|||
}
|
||||
}
|
||||
else {
|
||||
EntityDamageEvent.DamageCause cause = damage.getCause();
|
||||
if (cause.equals(EntityDamageEvent.DamageCause.FIRE)) {
|
||||
e = "#fire";
|
||||
}
|
||||
|
@ -187,6 +192,12 @@ public final class EntityDeathListener extends Queue implements Listener {
|
|||
else if (cause.equals(EntityDamageEvent.DamageCause.MAGIC)) {
|
||||
e = "#magic";
|
||||
}
|
||||
else if (cause.equals(EntityDamageEvent.DamageCause.WITHER)) {
|
||||
e = "#wither_effect";
|
||||
}
|
||||
else if (!cause.name().contains("_")) {
|
||||
e = "#" + cause.name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
|
||||
if (entity instanceof ArmorStand) {
|
||||
|
@ -222,7 +233,7 @@ public final class EntityDeathListener extends Queue implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
if (e.startsWith("#wither")) {
|
||||
if (e.startsWith("#wither") && !e.equals("#wither_effect")) {
|
||||
e = "#wither";
|
||||
}
|
||||
|
||||
|
@ -366,7 +377,7 @@ public final class EntityDeathListener extends Queue implements Listener {
|
|||
List<Object> ingredients = new ArrayList<>();
|
||||
List<Object> itemMap = new ArrayList<>();
|
||||
ItemStack item = merchantRecipe.getResult().clone();
|
||||
List<List<Map<String, Object>>> metadata = ItemMetaHandler.seralize(item, item.getType(), null, 0);
|
||||
List<List<Map<String, Object>>> metadata = ItemMetaHandler.serialize(item, item.getType(), null, 0);
|
||||
item.setItemMeta(null);
|
||||
itemMap.add(item.serialize());
|
||||
itemMap.add(metadata);
|
||||
|
@ -378,7 +389,7 @@ public final class EntityDeathListener extends Queue implements Listener {
|
|||
for (ItemStack ingredient : merchantRecipe.getIngredients()) {
|
||||
itemMap = new ArrayList<>();
|
||||
item = ingredient.clone();
|
||||
metadata = ItemMetaHandler.seralize(item, item.getType(), null, 0);
|
||||
metadata = ItemMetaHandler.serialize(item, item.getType(), null, 0);
|
||||
item.setItemMeta(null);
|
||||
itemMap.add(item.serialize());
|
||||
itemMap.add(metadata);
|
||||
|
@ -496,6 +507,12 @@ public final class EntityDeathListener extends Queue implements Listener {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (entity instanceof Bee) {
|
||||
Bee bee = (Bee) entity;
|
||||
info.add(bee.getAnger());
|
||||
info.add(bee.hasNectar());
|
||||
info.add(bee.hasStung());
|
||||
}
|
||||
else {
|
||||
BukkitAdapter.ADAPTER.getEntityMeta(entity, info);
|
||||
}
|
||||
|
@ -519,6 +536,16 @@ public final class EntityDeathListener extends Queue implements Listener {
|
|||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
/*
|
||||
System.out.println("ENTITY DEATH - " + event.getEntity().getName());
|
||||
if (event.getEntity().getKiller() != null) {
|
||||
System.out.println("^ (killer): " + event.getEntity().getKiller().getName());
|
||||
}
|
||||
else if (event.getEntity().getLastDamageCause() != null) {
|
||||
System.out.println("^ (damage cause): " + event.getEntity().getLastDamageCause().getEntity().getName());
|
||||
}
|
||||
*/
|
||||
|
||||
LivingEntity entity = event.getEntity();
|
||||
if (entity == null) {
|
||||
return;
|
||||
|
|
|
@ -46,7 +46,7 @@ public final class EntityExplodeListener extends Queue implements Listener {
|
|||
user = "#wither";
|
||||
}
|
||||
else if (entity instanceof EnderCrystal) {
|
||||
user = "#endercrystal";
|
||||
user = "#ender_crystal";
|
||||
}
|
||||
|
||||
boolean log = false;
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.config.Config;
|
||||
|
@ -133,7 +134,9 @@ public final class HangingBreakByEntityListener extends Queue implements Listene
|
|||
|
||||
if (!event.isCancelled() && Config.getConfig(entity.getWorld()).ITEM_TRANSACTIONS && !inspecting) {
|
||||
if (itemframe.getItem().getType() != Material.AIR) {
|
||||
PlayerInteractEntityListener.queueFrameTransaction(culprit, itemframe, logDrops);
|
||||
ItemStack[] oldState = new ItemStack[] { itemframe.getItem().clone() };
|
||||
ItemStack[] newState = new ItemStack[] { new ItemStack(Material.AIR) };
|
||||
PlayerInteractEntityListener.queueContainerSpecifiedItems(culprit, Material.ITEM_FRAME, new Object[] { oldState, newState, itemframe.getFacing() }, itemframe.getLocation(), logDrops);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.config.Config;
|
||||
|
@ -61,7 +62,9 @@ public final class HangingBreakListener extends Queue implements Listener {
|
|||
|
||||
if (!event.isCancelled() && Config.getConfig(entity.getWorld()).ITEM_TRANSACTIONS) {
|
||||
if (itemframe.getItem().getType() != Material.AIR) {
|
||||
PlayerInteractEntityListener.queueFrameTransaction(causeName, itemframe, logDrops);
|
||||
ItemStack[] oldState = new ItemStack[] { itemframe.getItem().clone() };
|
||||
ItemStack[] newState = new ItemStack[] { new ItemStack(Material.AIR) };
|
||||
PlayerInteractEntityListener.queueContainerSpecifiedItems(causeName, Material.ITEM_FRAME, new Object[] { oldState, newState, itemframe.getFacing() }, itemframe.getLocation(), logDrops);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,7 @@ package net.coreprotect.listener.player;
|
|||
|
||||
import java.sql.Connection;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
@ -60,15 +57,9 @@ public final class ArmorStandManipulateListener extends Queue implements Listene
|
|||
try (Connection connection = Database.getConnection(true)) {
|
||||
if (connection != null) {
|
||||
Statement statement = connection.createStatement();
|
||||
String blockData = ChestTransactionLookup.performLookup(null, statement, location, finalPlayer, 1, 7, true);
|
||||
|
||||
if (blockData.contains("\n")) {
|
||||
for (String b : blockData.split("\n")) {
|
||||
Chat.sendComponent(finalPlayer, b);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Chat.sendComponent(finalPlayer, blockData);
|
||||
List<String> blockData = ChestTransactionLookup.performLookup(null, statement, location, finalPlayer, 1, 7, true);
|
||||
for (String data : blockData) {
|
||||
Chat.sendComponent(finalPlayer, data);
|
||||
}
|
||||
statement.close();
|
||||
}
|
||||
|
@ -93,7 +84,8 @@ public final class ArmorStandManipulateListener extends Queue implements Listene
|
|||
Player player = event.getPlayer();
|
||||
final ArmorStand armorStand = event.getRightClicked();
|
||||
EntityEquipment equipment = armorStand.getEquipment();
|
||||
ItemStack[] contents = Util.getArmorStandContents(equipment);
|
||||
ItemStack[] oldContents = Util.getArmorStandContents(equipment);
|
||||
ItemStack[] newContents = oldContents.clone();
|
||||
ItemStack item = event.getArmorStandItem();
|
||||
ItemStack playerItem = event.getPlayerItem();
|
||||
|
||||
|
@ -116,49 +108,45 @@ public final class ArmorStandManipulateListener extends Queue implements Listene
|
|||
return;
|
||||
}
|
||||
|
||||
if (item == null && playerItem == null) {
|
||||
int slot = 0;
|
||||
switch (event.getSlot()) {
|
||||
case LEGS:
|
||||
slot = 1;
|
||||
break;
|
||||
case CHEST:
|
||||
slot = 2;
|
||||
break;
|
||||
case HEAD:
|
||||
slot = 3;
|
||||
break;
|
||||
case HAND:
|
||||
slot = 4;
|
||||
break;
|
||||
case OFF_HAND:
|
||||
slot = 5;
|
||||
break;
|
||||
default:
|
||||
slot = 0;
|
||||
}
|
||||
// 0: BOOTS, 1: LEGGINGS, 2: CHESTPLATE, 3: HELMET, 4: MAINHAND, 5: OFFHAND
|
||||
|
||||
if (item.getType() == playerItem.getType()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
if (item!=null && playerItem==null){
|
||||
//player gets item
|
||||
}
|
||||
if (item==null && playerItem!=null){
|
||||
//players item placed on armor stands
|
||||
}
|
||||
if (item!=null && playerItem!=null){
|
||||
//items are swapped
|
||||
}
|
||||
*/
|
||||
|
||||
Material type = Material.ARMOR_STAND;
|
||||
Location standLocation = armorStand.getLocation();
|
||||
int x = standLocation.getBlockX();
|
||||
int y = standLocation.getBlockY();
|
||||
int z = standLocation.getBlockZ();
|
||||
|
||||
String transactingChestId = standLocation.getWorld().getUID().toString() + "." + x + "." + y + "." + z;
|
||||
String loggingChestId = player.getName().toLowerCase(Locale.ROOT) + "." + x + "." + y + "." + z;
|
||||
int chestId = Queue.getChestId(loggingChestId);
|
||||
if (chestId > 0) {
|
||||
if (ConfigHandler.forceContainer.get(loggingChestId) != null) {
|
||||
int force_size = ConfigHandler.forceContainer.get(loggingChestId).size();
|
||||
List<ItemStack[]> list = ConfigHandler.oldContainer.get(loggingChestId);
|
||||
|
||||
if (list.size() <= force_size) {
|
||||
list.add(Util.getContainerState(contents));
|
||||
ConfigHandler.oldContainer.put(loggingChestId, list);
|
||||
}
|
||||
}
|
||||
else if (item.getType() != Material.AIR && playerItem.getType() == Material.AIR) {
|
||||
oldContents[slot] = item.clone();
|
||||
newContents[slot] = new ItemStack(Material.AIR);
|
||||
PlayerInteractEntityListener.queueContainerSpecifiedItems(player.getName(), Material.ARMOR_STAND, new Object[] { oldContents, newContents }, armorStand.getLocation(), false);
|
||||
}
|
||||
else {
|
||||
List<ItemStack[]> list = new ArrayList<>();
|
||||
list.add(Util.getContainerState(contents));
|
||||
ConfigHandler.oldContainer.put(loggingChestId, list);
|
||||
else if (item.getType() == Material.AIR && playerItem.getType() != Material.AIR) {
|
||||
oldContents[slot] = new ItemStack(Material.AIR);
|
||||
newContents[slot] = playerItem.clone();
|
||||
PlayerInteractEntityListener.queueContainerSpecifiedItems(player.getName(), Material.ARMOR_STAND, new Object[] { oldContents, newContents }, armorStand.getLocation(), false);
|
||||
}
|
||||
else if (item.getType() != Material.AIR && playerItem.getType() != Material.AIR) {
|
||||
oldContents[slot] = item.clone();
|
||||
newContents[slot] = playerItem.clone();
|
||||
PlayerInteractEntityListener.queueContainerSpecifiedItems(player.getName(), Material.ARMOR_STAND, new Object[] { oldContents, newContents }, armorStand.getLocation(), false);
|
||||
}
|
||||
|
||||
ConfigHandler.transactingChest.computeIfAbsent(transactingChestId, k -> Collections.synchronizedList(new ArrayList<>()));
|
||||
Queue.queueContainerTransaction(player.getName(), standLocation, type, equipment, chestId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Locale;
|
|||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.event.Event.Result;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
@ -71,7 +71,7 @@ public final class CraftItemListener extends Queue implements Listener {
|
|||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
HumanEntity player = event.getWhoClicked();
|
||||
if (event.getClick() == ClickType.NUMBER_KEY && player.getInventory().getItem(event.getHotbarButton()) != null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package net.coreprotect.listener.player;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
@ -15,6 +14,7 @@ import org.bukkit.event.entity.FoodLevelChangeEvent;
|
|||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.thread.CacheHandler;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public final class FoodLevelChangeListener extends Queue implements Listener {
|
||||
|
@ -50,7 +50,7 @@ public final class FoodLevelChangeListener extends Queue implements Listener {
|
|||
}
|
||||
final Material oldBlockType = oldType;
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(CoreProtect.getInstance(), () -> {
|
||||
Scheduler.runTask(CoreProtect.getInstance(), () -> {
|
||||
try {
|
||||
Block newBlock = oldBlockState.getBlock();
|
||||
BlockState newBlockState = newBlock.getState();
|
||||
|
@ -66,7 +66,7 @@ public final class FoodLevelChangeListener extends Queue implements Listener {
|
|||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}, oldBlockState.getLocation());
|
||||
}
|
||||
|
||||
CacheHandler.interactCache.remove(coordinates);
|
||||
|
|
|
@ -5,10 +5,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.BrewerInventory;
|
||||
import org.bukkit.inventory.FurnaceInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -16,6 +13,7 @@ import org.bukkit.inventory.ItemStack;
|
|||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public final class HopperPullListener {
|
||||
|
@ -30,62 +28,20 @@ public final class HopperPullListener {
|
|||
}
|
||||
}
|
||||
|
||||
ItemStack[] containerState = null;
|
||||
if (!ConfigHandler.isPaper) {
|
||||
containerState = Util.getContainerState(sourceHolder.getInventory().getContents());
|
||||
}
|
||||
ItemStack[] sourceContainer = containerState;
|
||||
ItemStack[] destinationContainer = Util.getContainerState(destinationHolder.getInventory().getContents());
|
||||
ItemStack movedItem = item.clone();
|
||||
|
||||
final long taskStarted = InventoryChangeListener.tasksStarted.incrementAndGet();
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(CoreProtect.getInstance(), () -> {
|
||||
Scheduler.runTaskAsynchronously(CoreProtect.getInstance(), () -> {
|
||||
try {
|
||||
if (sourceHolder == null || destinationHolder == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean hopperTransactions = Config.getConfig(location.getWorld()).HOPPER_TRANSACTIONS;
|
||||
int itemHash = Util.getItemStackHashCode(item);
|
||||
boolean abort = false;
|
||||
|
||||
if (ConfigHandler.isPaper) {
|
||||
for (ItemStack itemStack : sourceHolder.getInventory().getContents()) {
|
||||
if (itemStack != null && Util.getItemStackHashCode(itemStack) == itemHash) {
|
||||
if (itemHash != Util.getItemStackHashCode(movedItem) || destinationHolder.getInventory().firstEmpty() == -1 || destinationHolder.getInventory() instanceof BrewerInventory || destinationHolder.getInventory() instanceof FurnaceInventory) {
|
||||
abort = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
for (ItemStack itemStack : sourceHolder.getInventory().getContents()) {
|
||||
if (itemStack != null && Util.getItemStackHashCode(itemStack) == itemHash) {
|
||||
abort = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (abort) {
|
||||
for (ItemStack itemStack : destinationHolder.getInventory().getContents()) {
|
||||
if (itemStack != null && Util.getItemStackHashCode(itemStack) == Util.getItemStackHashCode(movedItem)) {
|
||||
if (itemHash == Util.getItemStackHashCode(itemStack) && destinationHolder.getInventory().firstEmpty() > -1) {
|
||||
abort = false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
else {
|
||||
ItemStack[] sourceContents = sourceHolder.getInventory().getContents();
|
||||
boolean addedInventory = Util.addedContainer(sourceContainer, sourceContents);
|
||||
if (addedInventory) {
|
||||
abort = true;
|
||||
}
|
||||
boolean addedInventory = Util.canAddContainer(destinationContainer, movedItem, destinationHolder.getInventory().getMaxStackSize());
|
||||
if (!addedInventory) {
|
||||
abort = true;
|
||||
}
|
||||
|
||||
if (abort) {
|
||||
|
@ -104,6 +60,7 @@ public final class HopperPullListener {
|
|||
ConfigHandler.hopperAbort.remove(loggingChestId);
|
||||
}
|
||||
|
||||
boolean hopperTransactions = Config.getConfig(location.getWorld()).HOPPER_TRANSACTIONS;
|
||||
if (!hopperTransactions) {
|
||||
List<Object> list = ConfigHandler.transactingChest.get(location.getWorld().getUID().toString() + "." + location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ());
|
||||
if (list != null) {
|
||||
|
|
|
@ -5,10 +5,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.BrewerInventory;
|
||||
import org.bukkit.inventory.FurnaceInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -16,12 +13,18 @@ import org.bukkit.inventory.ItemStack;
|
|||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public final class HopperPushListener {
|
||||
|
||||
static void processHopperPush(Location location, InventoryHolder sourceHolder, InventoryHolder destinationHolder, ItemStack item) {
|
||||
String loggingChestId = "#hopper-push." + location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ();
|
||||
Location destinationLocation = destinationHolder.getInventory().getLocation();
|
||||
if (destinationLocation == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String loggingChestId = "#hopper-push." + destinationLocation.getBlockX() + "." + destinationLocation.getBlockY() + "." + destinationLocation.getBlockZ();
|
||||
Object[] lastAbort = ConfigHandler.hopperAbort.get(loggingChestId);
|
||||
if (lastAbort != null) {
|
||||
ItemStack[] destinationContents = destinationHolder.getInventory().getContents();
|
||||
|
@ -30,40 +33,20 @@ public final class HopperPushListener {
|
|||
}
|
||||
}
|
||||
|
||||
ItemStack[] containerState = null;
|
||||
if (!ConfigHandler.isPaper) {
|
||||
containerState = Util.getContainerState(destinationHolder.getInventory().getContents());
|
||||
}
|
||||
ItemStack[] destinationContainer = containerState;
|
||||
ItemStack[] destinationContainer = Util.getContainerState(destinationHolder.getInventory().getContents());
|
||||
ItemStack movedItem = item.clone();
|
||||
|
||||
final long taskStarted = InventoryChangeListener.tasksStarted.incrementAndGet();
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(CoreProtect.getInstance(), () -> {
|
||||
Scheduler.runTaskAsynchronously(CoreProtect.getInstance(), () -> {
|
||||
try {
|
||||
if (sourceHolder == null || destinationHolder == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int itemHash = Util.getItemStackHashCode(item);
|
||||
boolean abort = false;
|
||||
|
||||
if (ConfigHandler.isPaper) {
|
||||
for (ItemStack itemStack : sourceHolder.getInventory().getContents()) {
|
||||
if (itemStack != null && Util.getItemStackHashCode(itemStack) == itemHash) {
|
||||
if (itemHash != Util.getItemStackHashCode(movedItem) || destinationHolder.getInventory().firstEmpty() == -1 || destinationHolder.getInventory() instanceof BrewerInventory || destinationHolder.getInventory() instanceof FurnaceInventory) {
|
||||
abort = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
ItemStack[] destinationContents = destinationHolder.getInventory().getContents();
|
||||
boolean addedInventory = Util.addedContainer(destinationContainer, destinationContents);
|
||||
if (!addedInventory) {
|
||||
abort = true;
|
||||
}
|
||||
boolean addedInventory = Util.canAddContainer(destinationContainer, movedItem, destinationHolder.getInventory().getMaxStackSize());
|
||||
if (!addedInventory) {
|
||||
abort = true;
|
||||
}
|
||||
|
||||
if (abort) {
|
||||
|
@ -77,6 +60,9 @@ public final class HopperPushListener {
|
|||
ConfigHandler.hopperAbort.put(loggingChestId, new Object[] { movedItems, Util.getContainerState(destinationContents) });
|
||||
return;
|
||||
}
|
||||
else {
|
||||
ConfigHandler.hopperSuccess.put(loggingChestId, new Object[] { destinationContainer, movedItem });
|
||||
}
|
||||
|
||||
List<Object> list = ConfigHandler.transactingChest.get(location.getWorld().getUID().toString() + "." + location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ());
|
||||
if (list != null) {
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
@ -32,6 +31,7 @@ import net.coreprotect.config.ConfigHandler;
|
|||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.paper.PaperAdapter;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.Validate;
|
||||
|
||||
|
@ -203,7 +203,7 @@ public final class InventoryChangeListener extends Queue implements Listener {
|
|||
return false;
|
||||
}
|
||||
|
||||
private static void onInventoryInteractAsync(Player player, Inventory inventory, boolean enderChest) {
|
||||
static void onInventoryInteractAsync(Player player, Inventory inventory, boolean enderChest) {
|
||||
if (inventory == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ public final class InventoryChangeListener extends Queue implements Listener {
|
|||
ItemStack[] containerState = Util.getContainerState(inventory.getContents());
|
||||
|
||||
final long taskStarted = InventoryChangeListener.tasksStarted.incrementAndGet();
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(CoreProtect.getInstance(), () -> {
|
||||
Scheduler.runTaskAsynchronously(CoreProtect.getInstance(), () -> {
|
||||
try {
|
||||
Material containerType = (enderChest != true ? null : Material.ENDER_CHEST);
|
||||
InventoryChangeListener.checkTasks(taskStarted);
|
||||
|
@ -249,7 +249,13 @@ public final class InventoryChangeListener extends Queue implements Listener {
|
|||
boolean enderChest = false;
|
||||
if (inventoryAction != InventoryAction.MOVE_TO_OTHER_INVENTORY && inventoryAction != InventoryAction.COLLECT_TO_CURSOR && inventoryAction != InventoryAction.UNKNOWN) {
|
||||
// Perform this check to prevent triggering onInventoryInteractAsync when a user is just clicking items in their own inventory
|
||||
Inventory inventory = event.getView().getInventory(event.getRawSlot());
|
||||
Inventory inventory = null;
|
||||
try {
|
||||
inventory = event.getView().getInventory(event.getRawSlot());
|
||||
}
|
||||
catch (Exception e) {
|
||||
return;
|
||||
}
|
||||
if (inventory == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -311,7 +317,12 @@ public final class InventoryChangeListener extends Queue implements Listener {
|
|||
return;
|
||||
}
|
||||
|
||||
Location location = event.getSource().getLocation();
|
||||
Inventory sourceInventory = event.getSource();
|
||||
if (sourceInventory == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Location location = sourceInventory.getLocation();
|
||||
if (location == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -321,7 +332,7 @@ public final class InventoryChangeListener extends Queue implements Listener {
|
|||
return;
|
||||
}
|
||||
|
||||
InventoryHolder sourceHolder = PaperAdapter.ADAPTER.getHolder(event.getSource(), false);
|
||||
InventoryHolder sourceHolder = PaperAdapter.ADAPTER.getHolder(sourceInventory, false);
|
||||
if (sourceHolder == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import net.coreprotect.consumer.Queue;
|
|||
|
||||
public final class PlayerDropItemListener extends Queue implements Listener {
|
||||
|
||||
protected static void playerDropItem(Location location, String user, ItemStack itemStack) {
|
||||
public static void playerDropItem(Location location, String user, ItemStack itemStack) {
|
||||
if (!Config.getConfig(location.getWorld()).ITEM_DROPS || itemStack == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -38,14 +38,14 @@ public final class PlayerInteractEntityListener extends Queue implements Listene
|
|||
final Entity entity = event.getRightClicked(); // change item in ItemFrame, etc
|
||||
if (entity instanceof ItemFrame) {
|
||||
ItemFrame frame = (ItemFrame) entity;
|
||||
Material handType = Material.AIR;
|
||||
ItemStack handItem = new ItemStack(Material.AIR);
|
||||
ItemStack mainHand = player.getInventory().getItemInMainHand();
|
||||
ItemStack offHand = player.getInventory().getItemInOffHand();
|
||||
if (event.getHand().equals(EquipmentSlot.HAND) && mainHand.getType() != Material.AIR) {
|
||||
handType = mainHand.getType();
|
||||
handItem = mainHand;
|
||||
}
|
||||
else if (event.getHand().equals(EquipmentSlot.OFF_HAND) && offHand.getType() != Material.AIR) {
|
||||
handType = offHand.getType();
|
||||
handItem = offHand;
|
||||
}
|
||||
else if (event.getHand().equals(EquipmentSlot.OFF_HAND)) {
|
||||
return;
|
||||
|
@ -72,8 +72,13 @@ public final class PlayerInteractEntityListener extends Queue implements Listene
|
|||
return;
|
||||
}
|
||||
|
||||
if (frame.getItem().getType().equals(Material.AIR) && !handType.equals(Material.AIR)) {
|
||||
queueFrameTransaction(player.getName(), frame, false);
|
||||
if (frame.getItem().getType().equals(Material.AIR) && !handItem.getType().equals(Material.AIR)) { // add item to item frame
|
||||
ItemStack[] oldState = new ItemStack[] { new ItemStack(Material.AIR) };
|
||||
ItemStack[] newState = new ItemStack[] { handItem.clone() };
|
||||
if (newState[0].getAmount() > 1) {
|
||||
newState[0].setAmount(1); // never add more than 1 item to an item frame at once
|
||||
}
|
||||
queueContainerSpecifiedItems(player.getName(), Material.ITEM_FRAME, new Object[] { oldState, newState, frame.getFacing() }, frame.getLocation(), false);
|
||||
}
|
||||
}
|
||||
else if (!event.isCancelled() && entity instanceof Creature && entity.getType().name().equals("ALLAY")) {
|
||||
|
@ -108,15 +113,13 @@ public final class PlayerInteractEntityListener extends Queue implements Listene
|
|||
}
|
||||
}
|
||||
|
||||
public static void queueFrameTransaction(String user, ItemFrame frame, boolean logDrop) {
|
||||
ItemStack[] contents = Util.getItemFrameItem(frame);
|
||||
Material type = Material.ITEM_FRAME;
|
||||
Location frameLocation = frame.getLocation();
|
||||
int x = frameLocation.getBlockX();
|
||||
int y = frameLocation.getBlockY();
|
||||
int z = frameLocation.getBlockZ();
|
||||
public static void queueContainerSpecifiedItems(String user, Material type, Object container, Location location, boolean logDrop) {
|
||||
ItemStack[] contents = (ItemStack[]) ((Object[]) container)[0];
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
|
||||
String transactingChestId = frameLocation.getWorld().getUID().toString() + "." + x + "." + y + "." + z;
|
||||
String transactingChestId = location.getWorld().getUID().toString() + "." + x + "." + y + "." + z;
|
||||
String loggingChestId = user.toLowerCase(Locale.ROOT) + "." + x + "." + y + "." + z;
|
||||
int chestId = Queue.getChestId(loggingChestId);
|
||||
if (chestId > 0) {
|
||||
|
@ -137,15 +140,15 @@ public final class PlayerInteractEntityListener extends Queue implements Listene
|
|||
}
|
||||
|
||||
ConfigHandler.transactingChest.computeIfAbsent(transactingChestId, k -> Collections.synchronizedList(new ArrayList<>()));
|
||||
Queue.queueContainerTransaction(user, frameLocation, type, frame, chestId);
|
||||
Queue.queueContainerTransaction(user, location, type, container, chestId);
|
||||
|
||||
if (logDrop) {
|
||||
ItemStack dropItem = frame.getItem();
|
||||
ItemStack dropItem = contents[0];
|
||||
if (dropItem.getType() == Material.AIR) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerDropItemListener.playerDropItem(frame.getLocation(), user, dropItem);
|
||||
PlayerDropItemListener.playerDropItem(location, user, dropItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
@ -19,6 +17,7 @@ import org.bukkit.block.Block;
|
|||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.DoubleChest;
|
||||
import org.bukkit.block.Jukebox;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.data.Bisected;
|
||||
import org.bukkit.block.data.Bisected.Half;
|
||||
|
@ -37,6 +36,7 @@ import org.bukkit.event.EventPriority;
|
|||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.BlockInventoryHolder;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -52,8 +52,11 @@ import net.coreprotect.database.lookup.ChestTransactionLookup;
|
|||
import net.coreprotect.database.lookup.InteractionLookup;
|
||||
import net.coreprotect.database.lookup.SignMessageLookup;
|
||||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.listener.block.CampfireStartListener;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.paper.PaperAdapter;
|
||||
import net.coreprotect.thread.CacheHandler;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
@ -61,6 +64,7 @@ import net.coreprotect.utility.Util;
|
|||
public final class PlayerInteractListener extends Queue implements Listener {
|
||||
|
||||
public static ConcurrentHashMap<String, Object[]> lastInspectorEvent = new ConcurrentHashMap<>();
|
||||
public static ConcurrentHashMap<String, Object[]> suspiciousBlockEvent = new ConcurrentHashMap<>();
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
protected void onPlayerInspect(PlayerInteractEvent event) {
|
||||
|
@ -139,7 +143,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
if (blockFinal instanceof Sign && player.getGameMode() != GameMode.CREATIVE) {
|
||||
Thread.sleep(1500);
|
||||
Sign sign = (Sign) blockFinal;
|
||||
BukkitAdapter.ADAPTER.sendSignChange(player, sign);
|
||||
player.sendSignChange(sign.getLocation(), sign.getLines(), sign.getColor());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -186,7 +190,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
final Material type = block.getType();
|
||||
boolean isInteractBlock = BlockGroup.INTERACT_BLOCKS.contains(type);
|
||||
boolean isContainerBlock = BlockGroup.CONTAINERS.contains(type);
|
||||
boolean isSignBlock = Tag.SIGNS.isTagged(type);
|
||||
boolean isSignBlock = BukkitAdapter.ADAPTER.isSign(type);
|
||||
|
||||
if (isInteractBlock || isContainerBlock || isSignBlock) {
|
||||
final Block clickedBlock = event.getClickedBlock();
|
||||
|
@ -303,15 +307,9 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
try (Connection connection = Database.getConnection(true)) {
|
||||
if (connection != null) {
|
||||
Statement statement = connection.createStatement();
|
||||
String blockData = ChestTransactionLookup.performLookup(null, statement, finalLocation, player, 1, 7, false);
|
||||
|
||||
if (blockData.contains("\n")) {
|
||||
for (String splitData : blockData.split("\n")) {
|
||||
Chat.sendComponent(player, splitData);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Chat.sendComponent(player, blockData);
|
||||
List<String> blockData = ChestTransactionLookup.performLookup(null, statement, finalLocation, player, 1, 7, false);
|
||||
for (String data : blockData) {
|
||||
Chat.sendComponent(player, data);
|
||||
}
|
||||
|
||||
statement.close();
|
||||
|
@ -527,13 +525,20 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
/* Logging for players punching out fire blocks. */
|
||||
if (event.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
|
||||
World world = event.getClickedBlock().getWorld();
|
||||
if (event.useInteractedBlock() != Event.Result.DENY && Config.getConfig(world).BLOCK_BREAK) {
|
||||
Block relativeBlock = event.getClickedBlock().getRelative(event.getBlockFace());
|
||||
if (event.useInteractedBlock() != Event.Result.DENY) {
|
||||
Block block = event.getClickedBlock();
|
||||
if (block.getType() == Material.DRAGON_EGG) {
|
||||
clickedDragonEgg(event.getPlayer(), block);
|
||||
}
|
||||
|
||||
if (BlockGroup.FIRE.contains(relativeBlock.getType())) {
|
||||
Player player = event.getPlayer();
|
||||
Material type = relativeBlock.getType();
|
||||
Queue.queueBlockBreak(player.getName(), relativeBlock.getState(), type, relativeBlock.getBlockData().getAsString(), 0);
|
||||
if (Config.getConfig(world).BLOCK_BREAK) {
|
||||
Block relativeBlock = event.getClickedBlock().getRelative(event.getBlockFace());
|
||||
|
||||
if (BlockGroup.FIRE.contains(relativeBlock.getType())) {
|
||||
Player player = event.getPlayer();
|
||||
Material type = relativeBlock.getType();
|
||||
Queue.queueBlockBreak(player.getName(), relativeBlock.getState(), type, relativeBlock.getBlockData().getAsString(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -547,7 +552,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
if (event.useInteractedBlock() != Event.Result.DENY) {
|
||||
boolean isCake = false;
|
||||
|
||||
if (Tag.SIGNS.isTagged(type)) {
|
||||
if (BukkitAdapter.ADAPTER.isSign(type)) {
|
||||
// check if right clicked sign with dye
|
||||
Set<Material> dyeSet = EnumSet.of(Material.BLACK_DYE, Material.BLUE_DYE, Material.BROWN_DYE, Material.CYAN_DYE, Material.GRAY_DYE, Material.GREEN_DYE, Material.LIGHT_BLUE_DYE, Material.LIGHT_GRAY_DYE, Material.LIME_DYE, Material.MAGENTA_DYE, Material.ORANGE_DYE, Material.PINK_DYE, Material.PURPLE_DYE, Material.RED_DYE, Material.WHITE_DYE, Material.YELLOW_DYE);
|
||||
Material handType = null;
|
||||
|
@ -557,30 +562,47 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
handType = mainHand.getType();
|
||||
}
|
||||
|
||||
if (handType != null && (dyeSet.contains(handType) || handType.name().endsWith("INK_SAC")) && Config.getConfig(block.getWorld()).SIGN_TEXT) {
|
||||
if (handType != null && (dyeSet.contains(handType) || handType.name().endsWith("INK_SAC") || handType == Material.HONEYCOMB) && Config.getConfig(block.getWorld()).SIGN_TEXT) {
|
||||
BlockState blockState = block.getState();
|
||||
Sign sign = (Sign) blockState;
|
||||
String line1 = sign.getLine(0);
|
||||
String line2 = sign.getLine(1);
|
||||
String line3 = sign.getLine(2);
|
||||
String line4 = sign.getLine(3);
|
||||
int oldColor = sign.getColor().getColor().asRGB();
|
||||
int newColor = oldColor;
|
||||
boolean oldGlowing = BukkitAdapter.ADAPTER.isGlowing(sign);
|
||||
boolean newGlowing = oldGlowing;
|
||||
String line1 = PaperAdapter.ADAPTER.getLine(sign, 0);
|
||||
String line2 = PaperAdapter.ADAPTER.getLine(sign, 1);
|
||||
String line3 = PaperAdapter.ADAPTER.getLine(sign, 2);
|
||||
String line4 = PaperAdapter.ADAPTER.getLine(sign, 3);
|
||||
String line5 = PaperAdapter.ADAPTER.getLine(sign, 4);
|
||||
String line6 = PaperAdapter.ADAPTER.getLine(sign, 5);
|
||||
String line7 = PaperAdapter.ADAPTER.getLine(sign, 6);
|
||||
String line8 = PaperAdapter.ADAPTER.getLine(sign, 7);
|
||||
|
||||
if (dyeSet.contains(handType)) {
|
||||
newColor = (DyeColor.valueOf(handType.name().replaceFirst("_DYE", ""))).getColor().asRGB();
|
||||
}
|
||||
else {
|
||||
newGlowing = (handType != Material.INK_SAC);
|
||||
}
|
||||
boolean isFront = true;
|
||||
int oldColor = BukkitAdapter.ADAPTER.getColor(sign, isFront);
|
||||
int oldColorSecondary = BukkitAdapter.ADAPTER.getColor(sign, !isFront);
|
||||
boolean oldFrontGlowing = BukkitAdapter.ADAPTER.isGlowing(sign, isFront);
|
||||
boolean oldBackGlowing = BukkitAdapter.ADAPTER.isGlowing(sign, !isFront);
|
||||
boolean oldIsWaxed = BukkitAdapter.ADAPTER.isWaxed(sign);
|
||||
|
||||
if (oldGlowing != newGlowing || oldColor != newColor) {
|
||||
Location location = blockState.getLocation();
|
||||
Queue.queueSignText(player.getName(), location, 0, oldColor, oldGlowing, line1, line2, line3, line4, 1); // 1 second timeOffset
|
||||
Queue.queueBlockPlace(player.getName(), block.getState(), block.getType(), blockState, block.getType(), -1, 0, blockState.getBlockData().getAsString());
|
||||
Queue.queueSignText(player.getName(), location, 2, newColor, newGlowing, line1, line2, line3, line4, 0);
|
||||
if (!oldIsWaxed) {
|
||||
Scheduler.runTask(CoreProtect.getInstance(), () -> {
|
||||
BlockState newState = block.getState();
|
||||
if (newState instanceof Sign) {
|
||||
Sign newSign = (Sign) newState;
|
||||
int newColor = BukkitAdapter.ADAPTER.getColor(newSign, isFront);
|
||||
int newColorSecondary = BukkitAdapter.ADAPTER.getColor(newSign, !isFront);
|
||||
boolean newFrontGlowing = BukkitAdapter.ADAPTER.isGlowing(newSign, isFront);
|
||||
boolean newBackGlowing = BukkitAdapter.ADAPTER.isGlowing(newSign, !isFront);
|
||||
boolean newIsWaxed = BukkitAdapter.ADAPTER.isWaxed(newSign);
|
||||
|
||||
boolean modifyingFront = oldBackGlowing == newBackGlowing && oldColorSecondary == newColorSecondary;
|
||||
if (oldColor != newColor || oldColorSecondary != newColorSecondary || oldFrontGlowing != newFrontGlowing || oldBackGlowing != newBackGlowing || oldIsWaxed != newIsWaxed) {
|
||||
Location location = blockState.getLocation();
|
||||
Queue.queueSignText(player.getName(), location, 0, oldColor, oldColorSecondary, oldFrontGlowing, oldBackGlowing, oldIsWaxed, modifyingFront, line1, line2, line3, line4, line5, line6, line7, line8, 1); // 1 second timeOffset
|
||||
Queue.queueBlockPlace(player.getName(), blockState, block.getType(), blockState, block.getType(), -1, 0, blockState.getBlockData().getAsString());
|
||||
Queue.queueSignText(player.getName(), location, 2, newColor, newColorSecondary, newFrontGlowing, newBackGlowing, newIsWaxed, modifyingFront, line1, line2, line3, line4, line5, line6, line7, line8, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}, block.getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -620,9 +642,162 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
});
|
||||
*/
|
||||
}
|
||||
else if (CampfireStartListener.useCampfireStartEvent && (type == Material.CAMPFIRE || type == Material.SOUL_CAMPFIRE)) {
|
||||
ItemStack handItem = null;
|
||||
ItemStack mainHand = player.getInventory().getItemInMainHand();
|
||||
ItemStack offHand = player.getInventory().getItemInOffHand();
|
||||
|
||||
if (event.getHand().equals(EquipmentSlot.HAND) && mainHand != null && mainHand.getType() != Material.BUCKET) {
|
||||
handItem = mainHand;
|
||||
}
|
||||
else if (event.getHand().equals(EquipmentSlot.OFF_HAND) && offHand != null) {
|
||||
handItem = offHand;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getGameMode() != GameMode.CREATIVE) {
|
||||
Location location = block.getLocation();
|
||||
long time = System.currentTimeMillis();
|
||||
int wid = Util.getWorldId(location.getWorld().getName());
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
String coordinates = x + "." + y + "." + z + "." + wid + "." + type.name();
|
||||
CacheHandler.interactCache.put(coordinates, new Object[] { time, handItem, player.getName() });
|
||||
}
|
||||
}
|
||||
|
||||
isCake = type.name().endsWith(Material.CAKE.name());
|
||||
}
|
||||
else if (type == Material.JUKEBOX) {
|
||||
BlockState blockState = block.getState();
|
||||
if (blockState instanceof Jukebox) {
|
||||
Jukebox jukebox = (Jukebox) blockState;
|
||||
ItemStack jukeboxRecord = jukebox.isPlaying() ? jukebox.getRecord() : new ItemStack(Material.AIR);
|
||||
ItemStack oldItemState = jukeboxRecord.clone();
|
||||
ItemStack newItemState = new ItemStack(Material.AIR);
|
||||
|
||||
if (jukeboxRecord.getType() == Material.AIR) {
|
||||
ItemStack handItem = null;
|
||||
ItemStack mainHand = player.getInventory().getItemInMainHand();
|
||||
ItemStack offHand = player.getInventory().getItemInOffHand();
|
||||
|
||||
if (event.getHand().equals(EquipmentSlot.HAND) && mainHand != null && Tag.ITEMS_MUSIC_DISCS.isTagged(mainHand.getType())) {
|
||||
handItem = mainHand;
|
||||
}
|
||||
else if (event.getHand().equals(EquipmentSlot.OFF_HAND) && offHand != null && Tag.ITEMS_MUSIC_DISCS.isTagged(offHand.getType())) {
|
||||
handItem = offHand;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
oldItemState = new ItemStack(Material.AIR);
|
||||
newItemState = handItem.clone();
|
||||
}
|
||||
|
||||
if (!oldItemState.equals(newItemState)) {
|
||||
if (Config.getConfig(player.getWorld()).PLAYER_INTERACTIONS) {
|
||||
Queue.queuePlayerInteraction(player.getName(), blockState, type);
|
||||
}
|
||||
|
||||
if (Config.getConfig(block.getWorld()).ITEM_TRANSACTIONS) {
|
||||
boolean logDrops = player.getGameMode() != GameMode.CREATIVE;
|
||||
ItemStack[] oldState = new ItemStack[] { oldItemState };
|
||||
ItemStack[] newState = new ItemStack[] { newItemState };
|
||||
PlayerInteractEntityListener.queueContainerSpecifiedItems(player.getName(), Material.JUKEBOX, new Object[] { oldState, newState }, jukebox.getLocation(), logDrops);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (BukkitAdapter.ADAPTER.isChiseledBookshelf(type)) {
|
||||
BlockState blockState = block.getState();
|
||||
if (blockState instanceof BlockInventoryHolder) {
|
||||
ItemStack book = BukkitAdapter.ADAPTER.getChiseledBookshelfBook(blockState, event);
|
||||
if (book != null) {
|
||||
ItemStack oldItemState = book.clone();
|
||||
ItemStack newItemState = new ItemStack(Material.AIR);
|
||||
|
||||
if (book.getType() == Material.AIR) {
|
||||
ItemStack handItem = null;
|
||||
ItemStack mainHand = player.getInventory().getItemInMainHand();
|
||||
ItemStack offHand = player.getInventory().getItemInOffHand();
|
||||
|
||||
if (event.getHand().equals(EquipmentSlot.HAND) && mainHand != null && BukkitAdapter.ADAPTER.isBookshelfBook(mainHand.getType())) {
|
||||
handItem = mainHand;
|
||||
}
|
||||
else if (event.getHand().equals(EquipmentSlot.OFF_HAND) && offHand != null && BukkitAdapter.ADAPTER.isBookshelfBook(offHand.getType())) {
|
||||
handItem = offHand;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
oldItemState = new ItemStack(Material.AIR);
|
||||
newItemState = handItem.clone();
|
||||
}
|
||||
|
||||
if (!oldItemState.equals(newItemState)) {
|
||||
if (Config.getConfig(player.getWorld()).PLAYER_INTERACTIONS) {
|
||||
Queue.queuePlayerInteraction(player.getName(), blockState, type);
|
||||
}
|
||||
|
||||
InventoryChangeListener.inventoryTransaction(player.getName(), blockState.getLocation(), null);
|
||||
}
|
||||
}
|
||||
else { // fallback if unable to determine bookshelf slot
|
||||
InventoryChangeListener.inventoryTransaction(player.getName(), blockState.getLocation(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (BukkitAdapter.ADAPTER.isDecoratedPot(type)) {
|
||||
BlockState blockState = block.getState();
|
||||
InventoryChangeListener.inventoryTransaction(player.getName(), blockState.getLocation(), null);
|
||||
}
|
||||
else if (BukkitAdapter.ADAPTER.isSuspiciousBlock(type)) {
|
||||
ItemStack handItem = null;
|
||||
ItemStack mainHand = player.getInventory().getItemInMainHand();
|
||||
ItemStack offHand = player.getInventory().getItemInOffHand();
|
||||
if (event.getHand().equals(EquipmentSlot.HAND) && mainHand != null) {
|
||||
handItem = mainHand;
|
||||
}
|
||||
else if (event.getHand().equals(EquipmentSlot.OFF_HAND) && offHand != null) {
|
||||
handItem = offHand;
|
||||
}
|
||||
|
||||
if (handItem.getType() == Material.BRUSH) {
|
||||
BlockState blockState = block.getState();
|
||||
Location blockLocation = block.getLocation();
|
||||
Scheduler.scheduleSyncDelayedTask(CoreProtect.getInstance(), () -> {
|
||||
Material newType = block.getType();
|
||||
if (type == newType || (newType != Material.SAND && newType != Material.GRAVEL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
long systemTime = System.currentTimeMillis();
|
||||
boolean logChange = true;
|
||||
if (suspiciousBlockEvent.get(player.getName()) != null) {
|
||||
Object[] lastEvent = suspiciousBlockEvent.get(player.getName());
|
||||
long lastTime = (long) lastEvent[0];
|
||||
long timeSince = systemTime - lastTime;
|
||||
Location lastLocation = (Location) lastEvent[1];
|
||||
if (timeSince < 5000 && blockLocation.equals(lastLocation)) {
|
||||
logChange = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (logChange) {
|
||||
Queue.queueBlockPlace(player.getName(), blockState, newType, blockState, newType, -1, 0, null);
|
||||
suspiciousBlockEvent.put(player.getName(), new Object[] { systemTime, blockLocation });
|
||||
}
|
||||
}, blockLocation, 100);
|
||||
}
|
||||
}
|
||||
else if (type == Material.DRAGON_EGG) {
|
||||
clickedDragonEgg(player, block);
|
||||
}
|
||||
|
||||
if (isCake || type == Material.CAKE) {
|
||||
boolean placeCandle = false;
|
||||
|
@ -691,7 +866,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
if (!exists) {
|
||||
final Player playerFinal = player;
|
||||
final Location locationFinal = crystalLocation;
|
||||
Bukkit.getServer().getScheduler().runTask(CoreProtect.getInstance(), () -> {
|
||||
Scheduler.runTask(CoreProtect.getInstance(), () -> {
|
||||
try {
|
||||
boolean blockExists = false;
|
||||
int showingBottom = 0;
|
||||
|
@ -711,7 +886,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}, locationFinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -733,7 +908,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
|
||||
String relativeBlockKey = world.getName() + "-" + relativeBlockLocation.getBlockX() + "-" + relativeBlockLocation.getBlockY() + "-" + relativeBlockLocation.getBlockZ();
|
||||
String blockKey = world.getName() + "-" + blockLocation.getBlockX() + "-" + blockLocation.getBlockY() + "-" + blockLocation.getBlockZ();
|
||||
Object[] keys = new Object[] { relativeBlockKey, blockKey, handItem };
|
||||
Object[] keys = new Object[] { System.currentTimeMillis(), relativeBlockKey, blockKey, handItem };
|
||||
ConfigHandler.entityBlockMapper.put(player.getName(), keys);
|
||||
}
|
||||
}
|
||||
|
@ -762,4 +937,16 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void clickedDragonEgg(Player player, Block block) {
|
||||
Location location = block.getLocation();
|
||||
long time = System.currentTimeMillis();
|
||||
int wid = Util.getWorldId(location.getWorld().getName());
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
String coordinates = x + "." + y + "." + z + "." + wid + "." + Material.DRAGON_EGG.name();
|
||||
CacheHandler.interactCache.put(coordinates, new Object[] { time, Material.DRAGON_EGG, player.getName() });
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package net.coreprotect.listener;
|
||||
package net.coreprotect.listener.player;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.AbstractArrow;
|
||||
|
@ -8,11 +8,8 @@ import org.bukkit.event.EventPriority;
|
|||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerPickupArrowEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionData;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.listener.entity.EntityPickupItemListener;
|
||||
|
||||
|
@ -31,16 +28,7 @@ public final class PlayerPickupArrowListener extends Queue implements Listener {
|
|||
|
||||
if (arrow instanceof Arrow) {
|
||||
Arrow arrowEntity = (Arrow) arrow;
|
||||
PotionData data = arrowEntity.getBasePotionData();
|
||||
if (data.getType() != PotionType.UNCRAFTABLE) {
|
||||
itemStack = new ItemStack(Material.TIPPED_ARROW);
|
||||
PotionMeta meta = (PotionMeta) itemStack.getItemMeta();
|
||||
meta.setBasePotionData(data);
|
||||
for (PotionEffect effect : arrowEntity.getCustomEffects()) {
|
||||
meta.addCustomEffect(effect, false);
|
||||
}
|
||||
itemStack.setItemMeta(meta);
|
||||
}
|
||||
itemStack = BukkitAdapter.ADAPTER.getArrowMeta(arrowEntity, itemStack);
|
||||
}
|
||||
|
||||
return itemStack;
|
|
@ -24,7 +24,6 @@ import net.coreprotect.config.Config;
|
|||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.database.logger.ItemLogger;
|
||||
import net.coreprotect.listener.PlayerPickupArrowListener;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public final class ProjectileLaunchListener extends Queue implements Listener {
|
||||
|
@ -68,10 +67,10 @@ public final class ProjectileLaunchListener extends Queue implements Listener {
|
|||
Map.Entry<String, Object[]> pair = it.next();
|
||||
String name = pair.getKey();
|
||||
Object[] data = pair.getValue();
|
||||
ItemStack itemStack = (ItemStack) data[2];
|
||||
ItemStack itemStack = (ItemStack) data[3];
|
||||
Material entityMaterial = Util.getEntityMaterial(event.getEntityType());
|
||||
boolean isBow = BOWS.contains(itemStack.getType());
|
||||
if ((data[0].equals(key) || data[1].equals(key)) && (entityMaterial == itemStack.getType() || (itemStack.getType() == Material.LINGERING_POTION && entityMaterial == Material.SPLASH_POTION) || isBow)) {
|
||||
if ((data[1].equals(key) || data[2].equals(key)) && (entityMaterial == itemStack.getType() || (itemStack.getType() == Material.LINGERING_POTION && entityMaterial == Material.SPLASH_POTION) || isBow)) {
|
||||
boolean thrownItem = (itemStack.getType() != Material.FIREWORK_ROCKET && !isBow);
|
||||
if (isBow) {
|
||||
if (itemStack.getType() == Material.CROSSBOW) {
|
||||
|
|
|
@ -12,24 +12,85 @@ import org.bukkit.event.block.SignChangeEvent;
|
|||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.paper.PaperAdapter;
|
||||
|
||||
public final class SignChangeListener extends Queue implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
protected void onSignChange(SignChangeEvent event) {
|
||||
String player = event.getPlayer().getName();
|
||||
Block block = event.getBlock();
|
||||
if (event.isCancelled() || !Config.getConfig(block.getWorld()).SIGN_TEXT) {
|
||||
return;
|
||||
}
|
||||
|
||||
String player = event.getPlayer().getName();
|
||||
Location location = block.getLocation();
|
||||
BlockState blockState = block.getState();
|
||||
String line1 = event.getLine(0);
|
||||
String line2 = event.getLine(1);
|
||||
String line3 = event.getLine(2);
|
||||
String line4 = event.getLine(3);
|
||||
int color = (blockState instanceof Sign) ? ((Sign) blockState).getColor().getColor().asRGB() : 0;
|
||||
boolean isGlowing = (blockState instanceof Sign) ? BukkitAdapter.ADAPTER.isGlowing((Sign) blockState) : false;
|
||||
|
||||
if (!event.isCancelled() && Config.getConfig(block.getWorld()).SIGN_TEXT) {
|
||||
Queue.queueSignText(player, location, 1, color, isGlowing, line1, line2, line3, line4, 0);
|
||||
String edit1 = event.getLine(0);
|
||||
String edit2 = event.getLine(1);
|
||||
String edit3 = event.getLine(2);
|
||||
String edit4 = event.getLine(3);
|
||||
String line1 = "";
|
||||
String line2 = "";
|
||||
String line3 = "";
|
||||
String line4 = "";
|
||||
String line5 = "";
|
||||
String line6 = "";
|
||||
String line7 = "";
|
||||
String line8 = "";
|
||||
int color = 0;
|
||||
int colorSecondary = 0;
|
||||
boolean frontGlowing = false;
|
||||
boolean backGlowing = false;
|
||||
boolean isWaxed = false;
|
||||
boolean isFront = BukkitAdapter.ADAPTER.isSignFront(event);
|
||||
boolean existingText = false;
|
||||
|
||||
if (blockState instanceof Sign) {
|
||||
Sign sign = (Sign) blockState;
|
||||
line1 = PaperAdapter.ADAPTER.getLine(sign, 0);
|
||||
line2 = PaperAdapter.ADAPTER.getLine(sign, 1);
|
||||
line3 = PaperAdapter.ADAPTER.getLine(sign, 2);
|
||||
line4 = PaperAdapter.ADAPTER.getLine(sign, 3);
|
||||
line5 = PaperAdapter.ADAPTER.getLine(sign, 4);
|
||||
line6 = PaperAdapter.ADAPTER.getLine(sign, 5);
|
||||
line7 = PaperAdapter.ADAPTER.getLine(sign, 6);
|
||||
line8 = PaperAdapter.ADAPTER.getLine(sign, 7);
|
||||
color = BukkitAdapter.ADAPTER.getColor(sign, true);
|
||||
colorSecondary = BukkitAdapter.ADAPTER.getColor(sign, false);
|
||||
frontGlowing = BukkitAdapter.ADAPTER.isGlowing(sign, true);
|
||||
backGlowing = BukkitAdapter.ADAPTER.isGlowing(sign, false);
|
||||
isWaxed = BukkitAdapter.ADAPTER.isWaxed(sign);
|
||||
|
||||
if (isFront && line1.equals(edit1) && line2.equals(edit2) && line3.equals(edit3) && line4.equals(edit4)) {
|
||||
return;
|
||||
}
|
||||
else if (!isFront && line5.equals(edit1) && line6.equals(edit2) && line7.equals(edit3) && line8.equals(edit4)) {
|
||||
return;
|
||||
}
|
||||
else if (line1.length() > 0 || line2.length() > 0 || line3.length() > 0 || line4.length() > 0 || line5.length() > 0 || line6.length() > 0 || line7.length() > 0 || line8.length() > 0) {
|
||||
existingText = true;
|
||||
Queue.queueSignText(player, location, 0, color, colorSecondary, frontGlowing, backGlowing, isWaxed, isFront, line1, line2, line3, line4, line5, line6, line7, line8, 1);
|
||||
Queue.queueBlockPlace(player, blockState, block.getType(), blockState, block.getType(), -1, 0, blockState.getBlockData().getAsString());
|
||||
}
|
||||
}
|
||||
|
||||
if (isFront) {
|
||||
line1 = edit1;
|
||||
line2 = edit2;
|
||||
line3 = edit3;
|
||||
line4 = edit4;
|
||||
}
|
||||
else {
|
||||
line5 = edit1;
|
||||
line6 = edit2;
|
||||
line7 = edit3;
|
||||
line8 = edit4;
|
||||
}
|
||||
|
||||
if (existingText || line1.length() > 0 || line2.length() > 0 || line3.length() > 0 || line4.length() > 0 || line5.length() > 0 || line6.length() > 0 || line7.length() > 0 || line8.length() > 0) {
|
||||
Queue.queueSignText(player, location, 1, color, colorSecondary, frontGlowing, backGlowing, isWaxed, isFront, line1, line2, line3, line4, line5, line6, line7, line8, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,17 +7,15 @@ import java.util.Set;
|
|||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
|
||||
public final class BlockGroup {
|
||||
|
||||
public static Set<Material> TRACK_ANY = new HashSet<>(Arrays.asList(Material.PISTON_HEAD, Material.LEVER, Material.BELL));
|
||||
public static Set<Material> TRACK_TOP_BOTTOM = new HashSet<>(Arrays.asList());
|
||||
public static Set<Material> TRACK_TOP = new HashSet<>(Arrays.asList(Material.TORCH, Material.REDSTONE_TORCH, Material.BAMBOO, Material.BAMBOO_SAPLING, Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SWEET_BERRY_BUSH, Material.SCAFFOLDING, Material.OAK_SAPLING, Material.SPRUCE_SAPLING, Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.GRASS, Material.FERN, Material.DEAD_BUSH, Material.DANDELION, Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.REDSTONE_WIRE, Material.WHEAT, Material.ACACIA_SIGN, Material.BIRCH_SIGN, Material.DARK_OAK_SIGN, Material.JUNGLE_SIGN, Material.OAK_SIGN, Material.SPRUCE_SIGN, Material.WHITE_BANNER, Material.ORANGE_BANNER, Material.MAGENTA_BANNER, Material.LIGHT_BLUE_BANNER, Material.YELLOW_BANNER, Material.LIME_BANNER, Material.PINK_BANNER, Material.GRAY_BANNER, Material.LIGHT_GRAY_BANNER, Material.CYAN_BANNER, Material.PURPLE_BANNER, Material.BLUE_BANNER, Material.BROWN_BANNER, Material.GREEN_BANNER, Material.RED_BANNER, Material.BLACK_BANNER, Material.RAIL, Material.IRON_DOOR, Material.SNOW, Material.CACTUS, Material.SUGAR_CANE, Material.REPEATER, Material.PUMPKIN_STEM, Material.MELON_STEM, Material.CARROT, Material.POTATO, Material.COMPARATOR, Material.ACTIVATOR_RAIL, Material.SUNFLOWER, Material.LILAC, Material.TALL_GRASS, Material.LARGE_FERN, Material.ROSE_BUSH, Material.PEONY, Material.NETHER_WART, Material.CHORUS_PLANT, Material.CHORUS_FLOWER, Material.KELP));
|
||||
public static Set<Material> TRACK_TOP = new HashSet<>(Arrays.asList(Material.TORCH, Material.REDSTONE_TORCH, Material.BAMBOO, Material.BAMBOO_SAPLING, Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SWEET_BERRY_BUSH, Material.SCAFFOLDING, Material.OAK_SAPLING, Material.SPRUCE_SAPLING, Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.FERN, Material.DEAD_BUSH, Material.DANDELION, Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.REDSTONE_WIRE, Material.WHEAT, Material.ACACIA_SIGN, Material.BIRCH_SIGN, Material.DARK_OAK_SIGN, Material.JUNGLE_SIGN, Material.OAK_SIGN, Material.SPRUCE_SIGN, Material.WHITE_BANNER, Material.ORANGE_BANNER, Material.MAGENTA_BANNER, Material.LIGHT_BLUE_BANNER, Material.YELLOW_BANNER, Material.LIME_BANNER, Material.PINK_BANNER, Material.GRAY_BANNER, Material.LIGHT_GRAY_BANNER, Material.CYAN_BANNER, Material.PURPLE_BANNER, Material.BLUE_BANNER, Material.BROWN_BANNER, Material.GREEN_BANNER, Material.RED_BANNER, Material.BLACK_BANNER, Material.RAIL, Material.IRON_DOOR, Material.SNOW, Material.CACTUS, Material.SUGAR_CANE, Material.REPEATER, Material.PUMPKIN_STEM, Material.MELON_STEM, Material.CARROT, Material.POTATO, Material.COMPARATOR, Material.ACTIVATOR_RAIL, Material.SUNFLOWER, Material.LILAC, Material.TALL_GRASS, Material.LARGE_FERN, Material.ROSE_BUSH, Material.PEONY, Material.NETHER_WART, Material.CHORUS_PLANT, Material.CHORUS_FLOWER, Material.KELP));
|
||||
public static Set<Material> TRACK_BOTTOM = new HashSet<>(Arrays.asList());
|
||||
public static Set<Material> TRACK_SIDE = new HashSet<>(Arrays.asList(Material.WALL_TORCH, Material.REDSTONE_WALL_TORCH, Material.RAIL, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.ACTIVATOR_RAIL, Material.WHITE_BED, Material.ORANGE_BED, Material.MAGENTA_BED, Material.LIGHT_BLUE_BED, Material.YELLOW_BED, Material.LIME_BED, Material.PINK_BED, Material.GRAY_BED, Material.LIGHT_GRAY_BED, Material.CYAN_BED, Material.PURPLE_BED, Material.BLUE_BED, Material.BROWN_BED, Material.GREEN_BED, Material.RED_BED, Material.BLACK_BED, Material.LADDER, Material.ACACIA_WALL_SIGN, Material.BIRCH_WALL_SIGN, Material.DARK_OAK_WALL_SIGN, Material.JUNGLE_WALL_SIGN, Material.OAK_WALL_SIGN, Material.SPRUCE_WALL_SIGN, Material.VINE, Material.COCOA, Material.TRIPWIRE_HOOK, Material.WHITE_WALL_BANNER, Material.ORANGE_WALL_BANNER, Material.MAGENTA_WALL_BANNER, Material.LIGHT_BLUE_WALL_BANNER, Material.YELLOW_WALL_BANNER, Material.LIME_WALL_BANNER, Material.PINK_WALL_BANNER, Material.GRAY_WALL_BANNER, Material.LIGHT_GRAY_WALL_BANNER, Material.CYAN_WALL_BANNER, Material.PURPLE_WALL_BANNER, Material.BLUE_WALL_BANNER, Material.BROWN_WALL_BANNER, Material.GREEN_WALL_BANNER, Material.RED_WALL_BANNER, Material.BLACK_WALL_BANNER));
|
||||
public static Set<Material> SHULKER_BOXES = new HashSet<>(Arrays.asList(Material.SHULKER_BOX, Material.BLACK_SHULKER_BOX, Material.BLUE_SHULKER_BOX, Material.BROWN_SHULKER_BOX, Material.CYAN_SHULKER_BOX, Material.GRAY_SHULKER_BOX, Material.GREEN_SHULKER_BOX, Material.LIGHT_BLUE_SHULKER_BOX, Material.LIME_SHULKER_BOX, Material.MAGENTA_SHULKER_BOX, Material.ORANGE_SHULKER_BOX, Material.PINK_SHULKER_BOX, Material.PURPLE_SHULKER_BOX, Material.RED_SHULKER_BOX, Material.LIGHT_GRAY_SHULKER_BOX, Material.WHITE_SHULKER_BOX, Material.YELLOW_SHULKER_BOX));
|
||||
public static Set<Material> CONTAINERS = new HashSet<>(Arrays.asList(Material.DISPENSER, Material.CHEST, Material.FURNACE, Material.BREWING_STAND, Material.TRAPPED_CHEST, Material.HOPPER, Material.DROPPER, Material.ARMOR_STAND, Material.ITEM_FRAME, Material.SHULKER_BOX, Material.BLACK_SHULKER_BOX, Material.BLUE_SHULKER_BOX, Material.BROWN_SHULKER_BOX, Material.CYAN_SHULKER_BOX, Material.GRAY_SHULKER_BOX, Material.GREEN_SHULKER_BOX, Material.LIGHT_BLUE_SHULKER_BOX, Material.LIME_SHULKER_BOX, Material.MAGENTA_SHULKER_BOX, Material.ORANGE_SHULKER_BOX, Material.PINK_SHULKER_BOX, Material.PURPLE_SHULKER_BOX, Material.RED_SHULKER_BOX, Material.LIGHT_GRAY_SHULKER_BOX, Material.WHITE_SHULKER_BOX, Material.YELLOW_SHULKER_BOX, Material.BARREL, Material.BLAST_FURNACE, Material.SMOKER, Material.LECTERN));
|
||||
public static Set<Material> CONTAINERS = new HashSet<>(Arrays.asList(Material.JUKEBOX, Material.DISPENSER, Material.CHEST, Material.FURNACE, Material.BREWING_STAND, Material.TRAPPED_CHEST, Material.HOPPER, Material.DROPPER, Material.ARMOR_STAND, Material.ITEM_FRAME, Material.SHULKER_BOX, Material.BLACK_SHULKER_BOX, Material.BLUE_SHULKER_BOX, Material.BROWN_SHULKER_BOX, Material.CYAN_SHULKER_BOX, Material.GRAY_SHULKER_BOX, Material.GREEN_SHULKER_BOX, Material.LIGHT_BLUE_SHULKER_BOX, Material.LIME_SHULKER_BOX, Material.MAGENTA_SHULKER_BOX, Material.ORANGE_SHULKER_BOX, Material.PINK_SHULKER_BOX, Material.PURPLE_SHULKER_BOX, Material.RED_SHULKER_BOX, Material.LIGHT_GRAY_SHULKER_BOX, Material.WHITE_SHULKER_BOX, Material.YELLOW_SHULKER_BOX, Material.BARREL, Material.BLAST_FURNACE, Material.SMOKER, Material.LECTERN));
|
||||
public static Set<Material> DOORS = new HashSet<>(Arrays.asList(Material.OAK_DOOR, Material.SPRUCE_DOOR, Material.BIRCH_DOOR, Material.JUNGLE_DOOR, Material.ACACIA_DOOR, Material.DARK_OAK_DOOR));
|
||||
public static Set<Material> BUTTONS = new HashSet<>(Arrays.asList(Material.STONE_BUTTON, Material.OAK_BUTTON, Material.ACACIA_BUTTON, Material.BIRCH_BUTTON, Material.DARK_OAK_BUTTON, Material.JUNGLE_BUTTON, Material.SPRUCE_BUTTON));
|
||||
public static Set<Material> PRESSURE_PLATES = new HashSet<>(Arrays.asList(Material.STONE_PRESSURE_PLATE, Material.ACACIA_PRESSURE_PLATE, Material.BIRCH_PRESSURE_PLATE, Material.DARK_OAK_PRESSURE_PLATE, Material.HEAVY_WEIGHTED_PRESSURE_PLATE, Material.JUNGLE_PRESSURE_PLATE, Material.LIGHT_WEIGHTED_PRESSURE_PLATE, Material.OAK_PRESSURE_PLATE, Material.SPRUCE_PRESSURE_PLATE));
|
||||
|
@ -43,78 +41,85 @@ public final class BlockGroup {
|
|||
|
||||
// These are blocks that an item frame or painting can't be attached to.
|
||||
// Same as non_solid_entity_blocks? >>Perform testing<<
|
||||
public static Set<Material> NON_ATTACHABLE = new HashSet<>(Arrays.asList(Material.AIR, Material.CAVE_AIR, Material.BARRIER, Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SWEET_BERRY_BUSH, Material.OAK_SAPLING, Material.SPRUCE_SAPLING, Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING, Material.WATER, Material.LAVA, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.GRASS, Material.FERN, Material.DEAD_BUSH, Material.DANDELION, Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.TORCH, Material.WALL_TORCH, Material.REDSTONE_WIRE, Material.LADDER, Material.RAIL, Material.LEVER, Material.REDSTONE_TORCH, Material.REDSTONE_WALL_TORCH, Material.SNOW, Material.SUGAR_CANE, Material.NETHER_PORTAL, Material.REPEATER, Material.KELP, Material.CHORUS_FLOWER, Material.CHORUS_PLANT));
|
||||
public static Set<Material> NON_ATTACHABLE = new HashSet<>(Arrays.asList(Material.AIR, Material.CAVE_AIR, Material.BARRIER, Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SWEET_BERRY_BUSH, Material.OAK_SAPLING, Material.SPRUCE_SAPLING, Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING, Material.WATER, Material.LAVA, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.FERN, Material.DEAD_BUSH, Material.DANDELION, Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.TORCH, Material.WALL_TORCH, Material.REDSTONE_WIRE, Material.LADDER, Material.RAIL, Material.LEVER, Material.REDSTONE_TORCH, Material.REDSTONE_WALL_TORCH, Material.SNOW, Material.SUGAR_CANE, Material.NETHER_PORTAL, Material.REPEATER, Material.KELP, Material.CHORUS_FLOWER, Material.CHORUS_PLANT));
|
||||
|
||||
public static void initialize() {
|
||||
if (!ConfigHandler.serverRunning) {
|
||||
TRACK_ANY.addAll(BUTTONS);
|
||||
TRACK_TOP.addAll(DOORS);
|
||||
TRACK_TOP.addAll(PRESSURE_PLATES);
|
||||
TRACK_TOP.addAll(Tag.CARPETS.getValues());
|
||||
TRACK_TOP_BOTTOM.addAll(LANTERNS);
|
||||
LIGHTABLES.addAll(CANDLES);
|
||||
INTERACT_BLOCKS.addAll(DOORS);
|
||||
INTERACT_BLOCKS.addAll(BUTTONS);
|
||||
SAFE_INTERACT_BLOCKS.addAll(DOORS);
|
||||
SAFE_INTERACT_BLOCKS.addAll(BUTTONS);
|
||||
NON_ATTACHABLE.addAll(BUTTONS);
|
||||
NON_ATTACHABLE.addAll(CANDLES);
|
||||
NON_ATTACHABLE.addAll(FIRE);
|
||||
UPDATE_STATE.addAll(LIGHTABLES);
|
||||
UPDATE_STATE.addAll(LANTERNS);
|
||||
|
||||
/* add all blocks that support vertical scanning */
|
||||
VERTICAL.addAll(VERTICAL_TOP_BOTTOM);
|
||||
VERTICAL.addAll(VERTICAL_TOP);
|
||||
VERTICAL.addAll(VERTICAL_BOTTOM);
|
||||
|
||||
/* Natural block group */
|
||||
/* https://minecraft.fandom.com/wiki/Tag */
|
||||
NATURAL_BLOCKS.addAll(Tag.BAMBOO_PLANTABLE_ON.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.VALID_SPAWN.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.SAND.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.LOGS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.LEAVES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.ICE.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.UNDERWATER_BONEMEALS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.CORAL_BLOCKS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.ENDERMAN_HOLDABLE.getValues());
|
||||
NATURAL_BLOCKS.addAll(SOUL_BLOCKS);
|
||||
NATURAL_BLOCKS.addAll(VINES);
|
||||
|
||||
/*
|
||||
NATURAL_BLOCKS.addAll(Tag.BASE_STONE_OVERWORLD.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.BEACON_BASE_BLOCKS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.SOUL_FIRE_BASE_BLOCKS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.GEODE_INVALID_BLOCKS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.GUARDED_BY_PIGLINS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.INFINIBURN_END.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.INFINIBURN_NETHER.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.INFINIBURN_OVERWORLD.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.INSIDE_STEP_SOUND_BLOCKS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.DEEPSLATE_ORE_REPLACEABLES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.DIRT.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.STONE_ORE_REPLACEABLES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.COAL_ORES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.COPPER_ORES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.DIAMOND_ORES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.EMERALD_ORES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.GOLD_ORES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.IRON_ORES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.LAPIS_ORES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.REDSTONE_ORES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.FIRE.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.SNOW.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.BEEHIVES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.BEE_GROWABLES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.FLOWERS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.CROPS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.FEATURES_CANNOT_REPLACE.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.LUSH_GROUND_REPLACEABLE.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.MUSHROOM_GROW_BLOCK.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.NYLIUM.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.PORTALS.getValues());
|
||||
*/
|
||||
Material shortGrass = Material.getMaterial("SHORT_GRASS");
|
||||
if (shortGrass == null) {
|
||||
shortGrass = Material.getMaterial("GRASS");
|
||||
}
|
||||
if (shortGrass != null) {
|
||||
TRACK_TOP.add(shortGrass);
|
||||
NON_ATTACHABLE.add(shortGrass);
|
||||
}
|
||||
|
||||
TRACK_ANY.addAll(BUTTONS);
|
||||
TRACK_TOP.addAll(DOORS);
|
||||
TRACK_TOP.addAll(PRESSURE_PLATES);
|
||||
TRACK_TOP.addAll(Tag.CARPETS.getValues());
|
||||
TRACK_TOP_BOTTOM.addAll(LANTERNS);
|
||||
LIGHTABLES.addAll(CANDLES);
|
||||
INTERACT_BLOCKS.addAll(DOORS);
|
||||
INTERACT_BLOCKS.addAll(BUTTONS);
|
||||
SAFE_INTERACT_BLOCKS.addAll(DOORS);
|
||||
SAFE_INTERACT_BLOCKS.addAll(BUTTONS);
|
||||
NON_ATTACHABLE.addAll(BUTTONS);
|
||||
NON_ATTACHABLE.addAll(CANDLES);
|
||||
NON_ATTACHABLE.addAll(FIRE);
|
||||
UPDATE_STATE.addAll(LIGHTABLES);
|
||||
UPDATE_STATE.addAll(LANTERNS);
|
||||
|
||||
/* add all blocks that support vertical scanning */
|
||||
VERTICAL.addAll(VERTICAL_TOP_BOTTOM);
|
||||
VERTICAL.addAll(VERTICAL_TOP);
|
||||
VERTICAL.addAll(VERTICAL_BOTTOM);
|
||||
|
||||
/* Natural block group */
|
||||
/* https://minecraft.fandom.com/wiki/Tag */
|
||||
NATURAL_BLOCKS.addAll(Tag.BAMBOO_PLANTABLE_ON.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.VALID_SPAWN.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.SAND.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.LOGS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.LEAVES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.ICE.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.UNDERWATER_BONEMEALS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.CORAL_BLOCKS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.ENDERMAN_HOLDABLE.getValues());
|
||||
NATURAL_BLOCKS.addAll(SOUL_BLOCKS);
|
||||
NATURAL_BLOCKS.addAll(VINES);
|
||||
|
||||
/*
|
||||
NATURAL_BLOCKS.addAll(Tag.BASE_STONE_OVERWORLD.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.BEACON_BASE_BLOCKS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.SOUL_FIRE_BASE_BLOCKS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.GEODE_INVALID_BLOCKS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.GUARDED_BY_PIGLINS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.INFINIBURN_END.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.INFINIBURN_NETHER.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.INFINIBURN_OVERWORLD.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.INSIDE_STEP_SOUND_BLOCKS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.DEEPSLATE_ORE_REPLACEABLES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.DIRT.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.STONE_ORE_REPLACEABLES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.COAL_ORES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.COPPER_ORES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.DIAMOND_ORES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.EMERALD_ORES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.GOLD_ORES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.IRON_ORES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.LAPIS_ORES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.REDSTONE_ORES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.FIRE.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.SNOW.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.BEEHIVES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.BEE_GROWABLES.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.FLOWERS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.CROPS.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.FEATURES_CANNOT_REPLACE.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.LUSH_GROUND_REPLACEABLE.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.MUSHROOM_GROW_BLOCK.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.NYLIUM.getValues());
|
||||
NATURAL_BLOCKS.addAll(Tag.PORTALS.getValues());
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package net.coreprotect.paper;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
|
@ -18,6 +22,7 @@ public class PaperAdapter implements PaperInterface {
|
|||
public static final int PAPER_V1_17 = BukkitAdapter.BUKKIT_V1_17;
|
||||
public static final int PAPER_V1_18 = BukkitAdapter.BUKKIT_V1_18;
|
||||
public static final int PAPER_V1_19 = BukkitAdapter.BUKKIT_V1_19;
|
||||
public static final int PAPER_V1_20 = BukkitAdapter.BUKKIT_V1_20;
|
||||
|
||||
public static void loadAdapter() {
|
||||
int paperVersion = ConfigHandler.SERVER_VERSION;
|
||||
|
@ -27,19 +32,24 @@ public class PaperAdapter implements PaperInterface {
|
|||
|
||||
switch (paperVersion) {
|
||||
case PAPER_UNAVAILABLE:
|
||||
case PAPER_V1_13:
|
||||
case PAPER_V1_14:
|
||||
PaperAdapter.ADAPTER = new PaperAdapter();
|
||||
break;
|
||||
case PAPER_V1_13:
|
||||
case PAPER_V1_14:
|
||||
case PAPER_V1_15:
|
||||
PaperAdapter.ADAPTER = new PaperHandler();
|
||||
break;
|
||||
case PAPER_V1_16:
|
||||
PaperAdapter.ADAPTER = new Paper_v1_16();
|
||||
break;
|
||||
case PAPER_V1_17:
|
||||
case PAPER_V1_18:
|
||||
case PAPER_V1_19:
|
||||
PaperAdapter.ADAPTER = new Paper_v1_17();
|
||||
break;
|
||||
case PAPER_V1_20:
|
||||
default:
|
||||
PaperAdapter.ADAPTER = new Paper_v1_16();
|
||||
PaperAdapter.ADAPTER = new Paper_v1_20();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -54,4 +64,24 @@ public class PaperAdapter implements PaperInterface {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLine(Sign sign, int line) {
|
||||
return BukkitAdapter.ADAPTER.getLine(sign, line);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleportAsync(Entity entity, Location location) {
|
||||
entity.teleport(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSkullOwner(Skull skull) {
|
||||
return skull.getOwningPlayer().getUniqueId().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkullOwner(Skull skull, String owner) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package net.coreprotect.paper;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class PaperHandler extends PaperAdapter implements PaperInterface {
|
||||
|
||||
|
@ -9,4 +11,9 @@ public class PaperHandler extends PaperAdapter implements PaperInterface {
|
|||
return server.isStopping();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleportAsync(Entity entity, Location location) {
|
||||
entity.teleportAsync(location);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package net.coreprotect.paper;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
|
@ -10,4 +14,12 @@ public interface PaperInterface {
|
|||
|
||||
public boolean isStopping(Server server);
|
||||
|
||||
public String getLine(Sign sign, int line);
|
||||
|
||||
public void teleportAsync(Entity entity, Location location);
|
||||
|
||||
public String getSkullOwner(Skull skull);
|
||||
|
||||
public void setSkullOwner(Skull skull, String owner);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package net.coreprotect.paper;
|
||||
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public class Paper_v1_17 extends Paper_v1_16 implements PaperInterface {
|
||||
|
||||
@Override
|
||||
public String getLine(Sign sign, int line) {
|
||||
if (line >= 4) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// https://docs.adventure.kyori.net/serializer/
|
||||
return LegacyComponentSerializer.legacySection().serialize(sign.line(line));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package net.coreprotect.paper;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.block.sign.Side;
|
||||
|
||||
import net.coreprotect.config.Config;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public class Paper_v1_20 extends Paper_v1_17 implements PaperInterface {
|
||||
|
||||
@Override
|
||||
public String getLine(Sign sign, int line) {
|
||||
// https://docs.adventure.kyori.net/serializer/
|
||||
if (line < 4) {
|
||||
return LegacyComponentSerializer.legacySection().serialize(sign.getSide(Side.FRONT).line(line));
|
||||
}
|
||||
else {
|
||||
return LegacyComponentSerializer.legacySection().serialize(sign.getSide(Side.BACK).line(line - 4));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSkullOwner(Skull skull) {
|
||||
String owner = skull.getPlayerProfile().getName();
|
||||
if (Config.getGlobal().MYSQL) {
|
||||
if (owner.length() > 255 && skull.getPlayerProfile().getId() != null) {
|
||||
return skull.getPlayerProfile().getId().toString();
|
||||
}
|
||||
else if (owner.length() > 255) {
|
||||
return owner.substring(0, 255);
|
||||
}
|
||||
}
|
||||
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkullOwner(Skull skull, String owner) {
|
||||
skull.setPlayerProfile(Bukkit.createProfile(owner));
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue