37 Commits
Author SHA1 Message Date
Intelli d9f5411e87 CoreProtect v20.4 release 2022-01-04 19:26:11 -07:00
Intelli 19ed0162e5 Fixed MySQL purges not being gracefully interrupted on shutdown 2022-01-04 19:19:08 -07:00
Intelli 03bd19480e Fixed SQLite purges not successfully completing on some systems 2022-01-04 17:55:52 -07:00
Intelli 947c59882e Fixed MySQL connections not being released when performing a reload 2022-01-04 16:49:57 -07:00
Intelli 8ed4216c64 Fixed SQLException when MySQL driver isn't automatically detected (#117) 2022-01-04 16:32:30 -07:00
Intelli 64188f5a75 Fixed the top block of bamboo growth not being logged (#129) 2022-01-04 15:58:09 -07:00
Intelli 55fec1d092 Moved entity & teleport methods out of Util class 2022-01-04 15:20:01 -07:00
Intelli c1eecefa6f Fixed radius selections not supporting negative heights 2021-12-21 15:31:08 -07:00
Intelli 204d6c8d5f Added base Japanese language file 2021-12-20 15:24:49 -07:00
Intelli fffe75f1f4 CoreProtect v20.3 release 2021-12-18 11:35:55 -07:00
Intelli 3201a18b16 Fixed PoolInitializationException when initializing HikariCP 2021-12-17 17:00:06 -07:00
Intelli 085e410ab1 Fixed NoClassDefFoundError when using Paper 1.16 (#120) 2021-12-17 11:31:04 -07:00
Intelli 4f977d394c Minor description update to documentation 2021-12-17 11:25:05 -07:00
Intelli a4c21ec8f3 Added MC 1.18 to adapters 2021-12-17 11:24:29 -07:00
Intelli d7ee5257dd Changed additional timestamp values to long types 2021-12-16 18:08:56 -07:00
Intelli 08aeb5d5aa Updated GitHub workflow to use Java 17 2021-12-16 15:25:38 -07:00
Intelli c1a4323ce4 Added base Ukrainian language file (#119) 2021-12-16 15:10:34 -07:00
Intelli a5d063dced CoreProtect v20.2 release 2021-12-16 14:01:43 -07:00
Intelli f0779d288c Incremented API version to 8 2021-12-16 14:01:23 -07:00
Intelli 550c3038b8 Added support for Paper AsyncChatEvent (fixes #75) 2021-11-30 19:11:19 -07:00
Intelli d864bbe233 Replaced commons-lang with Guava 2021-11-22 15:39:57 -07:00
Jan Erik Petersen fc99c24a0a Add HikariCP connection pool for MySQL (#86)
* Add HikariCP connection pool for MySQL

* Make code more compatible with connection pooling

- Remove connection caching in Process/Consumer
- Use try-with-resources to make sure Connections always get closed, even in
  when an Exception occurs.

* Disable SSL for MySQL
2021-11-15 17:57:33 -07:00
Intelli 2d90f9cc08 Fixed moving pistons logged during explosions not rolling back correctly (#92) 2021-11-09 16:42:48 -07:00
dependabot[bot] ba0ad6c15c Bump mkdocs from 1.2.1 to 1.2.3 (#108)
Bumps [mkdocs](https://github.com/mkdocs/mkdocs) from 1.2.1 to 1.2.3.
- [Release notes](https://github.com/mkdocs/mkdocs/releases)
- [Commits](https://github.com/mkdocs/mkdocs/compare/1.2.1...1.2.3)

---
updated-dependencies:
- dependency-name: mkdocs
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-11-09 15:27:12 -07:00
Intelli 370558cec5 Fixed piston heads not being logged when the piston base is broken 2021-11-09 14:53:42 -07:00
Intelli 69184302c9 Fixed ClassCastException when logging chat and command messages 2021-11-04 13:59:48 -06:00
Intelli a61df070e6 Fixed InventoryMoveItemEvent still processing if both hopper & item transactions are disabled 2021-10-16 16:05:39 -06:00
Intelli 3742e018c4 Minor readability improvements in EntityDamageByBlockListener 2021-10-04 16:09:08 -06:00
Intelli 554e17df02 Use isAlive for monitoring consumer thread 2021-10-04 15:55:54 -06:00
Intelli bc39bc03d6 Fixed NullPointerException when logging player death item drops (fixes #71) 2021-08-22 14:25:26 -06:00
bermudalocketandIntelli da718de252 Make user mutable via CoreProtectPreLogEvent (#66)
* Make user mutable via CoreProtectPreLogEvent

* Cleanup & added missing toLowerCase in getId

* Docs: add Event category; add CoreProtectPreLogEvent

* Merged event documentation into API documentation

* Removed event.getUser() equality check

* Added IllegalArgumentException check within PreLogEvent

* Reverted docs/index.md

Co-authored-by: Intelli <contact@intelli.software>
2021-08-06 18:40:21 -06:00
Ghost_chu 39cd888440 Fixed sign message phrase in zh-cn.yml (#63)
It shouldn't translate to `Signature Message`, this commit fixed it to `Sign Message`
2021-08-03 13:07:25 -06:00
Intelli 697ad1b3ce Minor cleanup in adapters 2021-08-01 16:53:14 -06:00
Intelli 922e4478dc Improved hopper logging performance when using Paper
Disables snapshot creation when getting inventory holders
2021-08-01 16:42:07 -06:00
Intelli 2fd366389b Changed base dependency to Paper 2021-08-01 16:36:17 -06:00
Intelli 5e3a19f208 Added base Vietnamese language file 2021-07-27 18:45:52 -06:00
Intelli 37d49a0900 Added stale.yml configuration file 2021-07-27 15:10:14 -06:00
74 changed files with 2081 additions and 1235 deletions

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
daysUntilStale: 60
daysUntilClose: 7
exemptLabels:
- 'accepted'
- 'bug'
- 'suggestion'
- 'help wanted'
staleLabel: stale
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
closeComment: false
+3 -3
View File
@@ -13,11 +13,11 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 8
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt-hotspot'
java-version: '17'
distribution: 'temurin'
- name: Cache Maven packages
uses: actions/cache@v1
with:
+2 -2
View File
@@ -18,7 +18,7 @@ For a detailed description of the plugin, please visit [spigotmc.org/resources/c
| 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.17: | [spigotmc.org/resources/coreprotect.8631](https://www.spigotmc.org/resources/coreprotect.8631/) |
| Downloads for MC 1.14 - 1.18: | [spigotmc.org/resources/coreprotect.8631](https://www.spigotmc.org/resources/coreprotect.8631/) |
| 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>20.0</version>
<version>20.4</version>
<scope>provided</scope>
</dependency>
```
+4 -2
View File
@@ -7,7 +7,7 @@ plugins {
}
group = 'net.coreprotect'
String projectVersion = '20.1'
String projectVersion = '20.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.'
@@ -36,7 +36,8 @@ dependencies {
exclude group: 'org.bukkit'
}
compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT'
implementation 'org.bstats:bstats-bukkit-lite:1.7'
implementation 'org.bstats:bstats-bukkit-lite:1.8'
implementation 'com.zaxxer:HikariCP:4.0.3'
}
jar {
@@ -51,6 +52,7 @@ shadowJar {
dependencies {
// #toString because #getGroup technically returns an Object
relocate('org.bstats', project.group.toString())
relocate('com.zaxxer', project.group.toString())
}
archiveClassifier.set(null)
}
+37 -19
View File
@@ -4,8 +4,8 @@ The CoreProtect API enables you to log your own block changes, perform lookups,
| API Details | |
| --- | --- |
| **API Version:** | 7 |
| **Plugin Version:** | v20.0+ |
| **API Version:** | 8 |
| **Plugin Version:** | v20.2+ |
| **Maven:** | [maven.playpro.com](https://maven.playpro.com) |
*Documentation for the previous API version can be found [here](https://www.minerealm.com/community/viewtopic.php?f=32&t=16687).*
@@ -39,8 +39,8 @@ parseResult(String[] result).getTypeId()
## Getting Started
Ensure you're using CoreProtect 20.0 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, 20.0).
Ensure you're using CoreProtect 20.2 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, 20.2).
The first thing you need to do is get access to CoreProtect. You can do this by using code similar to the following:
@@ -122,21 +122,39 @@ boolean hasRemoved(String user, Block block, int time, int offset)
void performPurge(int time)
```
### Usage
---
`isEnabled()`
### Available Events
*The following events are emitted by CoreProtect.*
#### CoreProtectPreLogEvent
Fired when a CoreProtect logger is about to log an action. Not cancellable.
| Property | Description | Mutable |
| --- | --- | --- |
| User | The name of the user under which this action will be logged. | 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()`
#### `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)`
#### `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.
@@ -151,7 +169,7 @@ This will perform a lookup.
---
`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)`
#### `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.
@@ -166,7 +184,7 @@ This will perform a rollback. Method must be called async.
---
`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)`
#### `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.
@@ -181,7 +199,7 @@ This will perform a restore.
---
`blockLookup(Block block, int time)`
#### `blockLookup(Block block, int time)`
This will perform a full lookup on a single block.
@@ -190,7 +208,7 @@ This will perform a full lookup on a single block.
---
`ParseResult parseResult(String[] result)`
#### `ParseResult parseResult(String[] result)`
This will parse results from a lookup. You'll then be able to view the following:
@@ -208,7 +226,7 @@ This will parse results from a lookup. You'll then be able to view the following
---
`logPlacement(String user, Location location, Material type, BlockData blockData)`
#### `logPlacement(String user, Location location, Material type, BlockData blockData)`
This will log a block as being placed.
@@ -219,7 +237,7 @@ This will log a block as being placed.
---
`logRemoval(String user, Location location, Material type, BlockData blockData)`
#### `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).
@@ -230,7 +248,7 @@ This will log a block as being removed/broken, and will log the block's inventor
---
`logContainerTransaction(String user, Location location)`
#### `logContainerTransaction(String user, Location location)`
This will log any transactions made to a block's inventory immediately after calling the method.
@@ -239,7 +257,7 @@ This will log any transactions made to a block's inventory immediately after cal
---
`logInteraction(String user, Location location)`
#### `logInteraction(String user, Location location)`
This will log a block as having been interacted with.
@@ -248,7 +266,7 @@ This will log a block as having been interacted with.
---
`hasPlaced(String user, Block block, int time, int offset)`
#### `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.
@@ -259,7 +277,7 @@ This will return true if a user has already placed a block at the location withi
---
`hasRemoved(String user, Block block, int time, int 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.
@@ -270,7 +288,7 @@ This will return true if a user has already removed a block at the location with
---
`performPurge(int time)`
#### `performPurge(int time)`
This will perform a purge on the CoreProtect database.
+1 -2
View File
@@ -4,8 +4,7 @@ For more information about CoreProtect, visit [coreprotect.net](http://coreprote
## Getting Started
These documents are still a work in progress.
Please be sure to visit the following links for more information.
Please visit one of the following links for more information.
[**CoreProtect Commands**](/commands/)
A list of all commands that can be used within CoreProtect.
+197
View File
@@ -0,0 +1,197 @@
# CoreProtect Language File (ja)
ACTION_NOT_SUPPORTED: "そのアクションはサポートされていません。"
AMOUNT_BLOCK: "{0} {ブロック|ブロック}"
AMOUNT_CHUNK: "{0} {チャンク|チャンク}"
AMOUNT_ENTITY: "{0} {エンティティ|エンティティ}"
AMOUNT_ITEM: "{0} {item|items}"
API_TEST: "APIテストが成功しました。"
CACHE_ERROR: "警告:検証中にエラーが発生しました {0} キャッシュ。"
CACHE_RELOAD: "のリロードを強制する {マッピング|世界} データベースからのキャッシュ。"
CHECK_CONFIG: "config.ymlを確認してください"
COMMAND_NOT_FOUND: "指示 \"{0}\" 見つかりません。"
COMMAND_THROTTLED: "しばらく待ってから、もう一度お試しください。"
CONTAINER_HEADER: "コンテナトランザクション"
DATABASE_BUSY: "データベースがビジーです。後でもう一度やり直してください。"
DATABASE_INDEX_ERROR: "データベースインデックスを検証できません。"
DATABASE_LOCKED_1: "データベースがロックされています。最大15秒待機しています..."
DATABASE_LOCKED_2: "データベースはすでに使用されています。もう一度やり直してください。"
DATABASE_LOCKED_3: "データベースロックを無効にするには、「database-lock:false」を設定します。"
DATABASE_LOCKED_4: "データベースロックを無効にすると、データが破損する可能性があります。"
DATABASE_UNREACHABLE: "データベースにアクセスできません。データを破棄してシャットダウンします。"
DEVELOPMENT_BRANCH: "開発ブランチが検出され、パッチスクリプトをスキップしました。"
DIRT_BLOCK: "あなたの下にダートブロックを置きました。"
DISABLE_SUCCESS: "成功!無効 {0}"
ENABLE_FAILED: "{0} 開始できませんでした。"
ENABLE_SUCCESS: "{0} これで有効になります!"
ENJOY_COREPROTECT: "楽しみ {0}?私たちに参加する Discord!"
FINISHING_CONVERSION: "データ変換を終了します。お待ちください..."
FINISHING_LOGGING: "データロギングの終了。お待ちください..."
FIRST_VERSION: "初期DB:{0}"
GLOBAL_LOOKUP: "グローバルルックアップを実行するために半径を指定しないでください。"
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_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: "ヒント:「/coi」だけを使用できます。"
HELP_INSPECT_COMMAND: "ブロックインスペクターを切り替えます。"
HELP_LIST: "すべてのコマンドのリストを表示します。"
HELP_LOOKUP_1: "コマンドショートカット。"
HELP_LOOKUP_2: "追加のページを表示します。"
HELP_LOOKUP_COMMAND: "ルックアップブロックデータ。"
HELP_NO_INFO: "コマンドの情報 \"{0}\" 見つかりません。"
HELP_PARAMETER: "見てください \"{0}詳細なパラメータ情報については、「」を参照してください。"
HELP_PARAMS_1: "を実行します {ルックアップ|ロールバック|復元}。"
HELP_PARAMS_2: "ユーザーを指定して {ルックアップ|ロールバック|復元}。"
HELP_PARAMS_3: "時間を指定します {ルックアップ|ロールバック|復元}。"
HELP_PARAMS_4: "制限する {ルックアップ|ロールバック|復元} 半径に。"
HELP_PARAMS_5: "制限する {ルックアップ|ロールバック|復元} アクションに。"
HELP_PARAMS_6: "ブロック/エンティティをに含める {ルックアップ|ロールバック|復元}。"
HELP_PARAMS_7: "ブロック/ユーザーをから除外する {ルックアップ|ロールバック|復元}。"
HELP_PURGE_1: "古いデータを削除します。"
HELP_PURGE_2: "例えば、 \"{0}\" は、1か月より古いすべてのデータを削除し、過去30日間のデータのみを保持します。"
HELP_PURGE_COMMAND: "古いブロックデータを削除します。"
HELP_RADIUS_1: "半径領域を指定します。"
HELP_RADIUS_2: "例:[r:10] (変更は10ブロック以内でのみ行ってください)"
HELP_RELOAD_COMMAND: "構成ファイルを再ロードします。"
HELP_RESTORE_COMMAND: "ブロックデータを復元します。"
HELP_ROLLBACK_COMMAND: "ブロックデータをロールバックします。"
HELP_STATUS: "プラグインのステータスを表示します。"
HELP_STATUS_COMMAND: "プラグインのステータスを表示します。"
HELP_TELEPORT: "テレポート。"
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} バージョンが見つかりました。"
INTERACTIONS_HEADER: "プレイヤーの相互作用"
INVALID_ACTION: "それは有効なアクションではありません。"
INVALID_BRANCH_1: "プラグインのバージョンが無効です(ブランチが設定されていません)。"
INVALID_BRANCH_2: "続行するには、プロジェクトブランチを「開発」に設定します。"
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: "ロギングの制限時間に達しました。データを破棄してシャットダウンします。"
LOOKUP_BLOCK: "{0} {配置|壊れた} {1}。"
LOOKUP_CONTAINER: "{0} {追加|削除} {1} {2}。"
LOOKUP_HEADER: "{0} 結果"
LOOKUP_INTERACTION: "{0} {クリック|殺された} {1}。"
LOOKUP_ITEM: "{0} {拾った|落とした} {1} {2}。"
LOOKUP_LOGIN: "{0} ログに記録されます {in|out}。"
LOOKUP_PAGE: "ページ {0}"
LOOKUP_ROWS_FOUND: "{0} {行|行} 見つかった。"
LOOKUP_SEARCHING: "ルックアップ検索。お待ちください..."
LOOKUP_STORAGE: "{0} {預け入れ|撤回} {1} {2}。"
LOOKUP_TIME: "{0} 前に"
LOOKUP_USERNAME: "{0} としてログイン {1}。"
LOOKUP_VIEW_PAGE: "ページを表示するには、「{0}\" 。"
MAXIMUM_RADIUS: "最大 {ルックアップ|ロールバック|復元} 半径は {0}。"
MISSING_ACTION_USER: "そのアクションを使用するには、ユーザーを指定してください。"
MISSING_LOOKUP_TIME: "時間を指定してください {ルックアップ|ロールバック|復元}。"
MISSING_LOOKUP_USER: "ユーザーを指定するか、 {ブロック|半径}。"
MISSING_PARAMETERS: "使ってください \"{0}\" 。"
MISSING_ROLLBACK_RADIUS: "指定しませんでした {ロールバック|復元} 半径。"
MISSING_ROLLBACK_USER: "指定しませんでした {ロールバック|復元} ユーザー。"
MYSQL_UNAVAILABLE: "接続できません MySQL サーバ。"
NO_DATA: "でデータが見つかりません {0}。"
NO_DATA_LOCATION: "番号 {データ|トランザクション|相互作用|メッセージ} 見つかった。"
NO_PERMISSION: "あなたにはそれをする許可がありません。"
NO_RESULTS: "結果が見つかりません。"
NO_RESULTS_PAGE: "番号 {結果|データ} そのページで見つかりました。"
NO_ROLLBACK: "番号 {保留中|前へ} ロールバック/復元が見つかりました。"
PATCH_INTERRUPTED: "アップグレードが中断されました。再起動時に再試行します。"
PATCH_OUTDATED_1: "古いデータベースをアップグレードできません {0}。"
PATCH_OUTDATED_2: "サポートされているバージョンでアップグレードしてください CoreProtect。"
PATCH_PROCESSING: "新しいデータを処理しています。お待ちください..."
PATCH_SKIP_UPDATE: "スキップ {テーブル|インデックス} {更新|作成|削除} の上 {0}。"
PATCH_STARTED: "実行する {0} アップグレード。お待ちください..."
PATCH_SUCCESS: "正常にアップグレードされました {0}。"
PATCH_UPGRADING: "データベースのアップグレードが進行中です。お待ちください..."
PLEASE_SELECT: "選んでください: \"{0}\" また \"{1}\" 。"
PREVIEW_CANCELLED: "プレビューがキャンセルされました。"
PREVIEW_CANCELLING: "プレビューをキャンセルしています..."
PREVIEW_CONTAINER: "コンテナトランザクションをプレビューすることはできません。"
PREVIEW_IN_GAME: "ゲーム内でのみロールバックをプレビューできます。"
PURGE_ABORTED: "パージに失敗しました。データベースが破損している可能性があります。"
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_SUCCESS: "データのパージに成功しました。"
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_IN_PROGRESS: "ロールバック/復元はすでに進行中です。"
ROLLBACK_LENGTH: "所要時間:{0} {秒|秒}。"
ROLLBACK_MODIFIED: "{変更|変更} {0}。"
ROLLBACK_RADIUS: "半径:{0} {ブロック|ブロック}。"
ROLLBACK_SELECTION: "半径を「{0}\" 。"
ROLLBACK_STARTED: "{ロールバック|復元|プレビュー} 「で始まった{0}\" 。"
ROLLBACK_TIME: "時間範囲:{0}。"
ROLLBACK_WORLD_ACTION: "に制限 {世界|アクション} 「」{0}\" 。"
SIGN_HEADER: "メッセージに署名する"
STATUS_CONSUMER: "消費者: {0} {item|items} 順番待ち。"
STATUS_DATABASE: "データベース: 使用する {0}。"
STATUS_INTEGRATION: "{0}: 統合 {有効|無効}。"
STATUS_LICENSE: "ライセンス: {0}"
STATUS_VERSION: "バージョン: {0}"
TELEPORTED: "にテレポート {0}。"
TELEPORTED_SAFETY: "安全にテレポートしました。"
TELEPORT_PLAYERS: "テレポートコマンドはプレイヤーだけが使用できます。"
TIME_DAYS: "{0} {日|日}"
TIME_HOURS: "{0} {時間|時間}"
TIME_MINUTES: "{0} {分|分}"
TIME_SECONDS: "{0} {秒|秒}"
TIME_WEEKS: "{0} {週|週}"
UPDATE_ERROR: "更新の確認中にエラーが発生しました。"
UPDATE_HEADER: "{0} アップデート"
UPDATE_NOTICE: "知らせ:{0} 現在利用できます。"
UPGRADE_IN_PROGRESS: "アップグレードが進行中です。後でもう一度やり直してください。"
USER_NOT_FOUND: "ユーザー \"{0}\" 見つかりません。"
USING_MYSQL: "使用する MySQL データストレージ用。"
USING_SQLITE: "使用する SQLite データストレージ用。"
VALID_DONATION_KEY: "有効な寄付キー。"
VERSION_NOTICE: "バージョン {0} 現在利用できます。"
VERSION_REQUIRED: "{0} {1} 以上が必要です。"
WORLD_NOT_FOUND: "世界 \"{0}\" 見つかりません。"
+197
View File
@@ -0,0 +1,197 @@
# CoreProtect Language File (uk)
ACTION_NOT_SUPPORTED: "Ця дія не підтримується."
AMOUNT_BLOCK: "{0} {блок|блоки}"
AMOUNT_CHUNK: "{0} {шматок|шматки}"
AMOUNT_ENTITY: "{0} {сутність|сутності}"
AMOUNT_ITEM: "{0} {пункт|предмети}"
API_TEST: "Тест API успішний."
CACHE_ERROR: "УВАГА: Помилка під час перевірки {0} кеш."
CACHE_RELOAD: "Примусове перезавантаження {картографування|світу} кеші з бази даних."
CHECK_CONFIG: "Перевірте config.yml"
COMMAND_NOT_FOUND: "Команда \"{0}\" не знайдено."
COMMAND_THROTTLED: "Зачекайте хвилину і повторіть спробу."
CONTAINER_HEADER: "Контейнерні операції"
DATABASE_BUSY: "База даних зайнята. Будь-ласка спробуйте пізніше."
DATABASE_INDEX_ERROR: "Неможливо перевірити індекси бази даних."
DATABASE_LOCKED_1: "База даних заблокована. Очікування до 15 секунд..."
DATABASE_LOCKED_2: "База даних вже використовується. Будь ласка спробуйте ще раз."
DATABASE_LOCKED_3: "Щоб вимкнути блокування бази даних, встановіть \"database-lock: false\"."
DATABASE_LOCKED_4: "Вимкнення блокування бази даних може призвести до пошкодження даних."
DATABASE_UNREACHABLE: "База даних недоступна. Видалення даних та завершення роботи."
DEVELOPMENT_BRANCH: "Виявлено гілку розробки, пропущено сценарії виправлення."
DIRT_BLOCK: "Поклали під себе брудний блок."
DISABLE_SUCCESS: "Успіху! Інвалід {0}"
ENABLE_FAILED: "{0} не вдалося почати."
ENABLE_SUCCESS: "{0} тепер увімкнено!"
ENJOY_COREPROTECT: "Насолоджуйтесь {0}? Приєднуйтесь до наших Discord!"
FINISHING_CONVERSION: "Завершення перетворення даних. Будь ласка, зачекайте..."
FINISHING_LOGGING: "Завершення реєстрації даних. Будь ласка, зачекайте..."
FIRST_VERSION: "Початкова БД: {0}"
GLOBAL_LOOKUP: "Не вказуйте радіус для глобального пошуку."
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_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_LIST: "Відображає список усіх команд."
HELP_LOOKUP_1: "Ярлик команди."
HELP_LOOKUP_2: "Переглянути додаткові сторінки."
HELP_LOOKUP_COMMAND: "Перегляд даних блоку."
HELP_NO_INFO: "Інформація для команди \"{0}\" не знайдено."
HELP_PARAMETER: "Будь ласка, подивіться \"{0}\" для отримання детальної інформації про параметри."
HELP_PARAMS_1: "Виконайте {пошук|відкат|відновлення}."
HELP_PARAMS_2: "Вкажіть користувачів для {пошук|відкат|відновлення}."
HELP_PARAMS_3: "Вкажіть час до {пошук|відкат|відновлення}."
HELP_PARAMS_4: "Обмежте {пошук|відкат|відновлення} до радіусу."
HELP_PARAMS_5: "Обмежте {пошук|відкат|відновлення} до дії."
HELP_PARAMS_6: "Включити блоки/сутності до {пошук|відкат|відновлення}."
HELP_PARAMS_7: "Виключити блокування/користувачів із {пошук|відкат|відновлення}."
HELP_PURGE_1: "Видаліть старі дані."
HELP_PURGE_2: "Наприклад, \"{0}\" видалить усі дані старше одного місяця та збереже дані лише за останні 30 днів."
HELP_PURGE_COMMAND: "Видалити дані старого блоку."
HELP_RADIUS_1: "Вкажіть зону радіуса."
HELP_RADIUS_2: "Приклади: [r:10] (Вносити зміни лише в межах 10 блоків від вас)"
HELP_RELOAD_COMMAND: "Перезавантажує файл конфігурації."
HELP_RESTORE_COMMAND: "Відновлення даних блоку."
HELP_ROLLBACK_COMMAND: "Дані блоку відкату."
HELP_STATUS: "Переглянути стан плагіна."
HELP_STATUS_COMMAND: "Відображає стан плагіна."
HELP_TELEPORT: "Телепорт."
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} версія знайдена."
INTERACTIONS_HEADER: "Взаємодії гравців"
INVALID_ACTION: "Це не дійсна дія."
INVALID_BRANCH_1: "Недійсна версія плагіна (гілка не встановлена)."
INVALID_BRANCH_2: "Щоб продовжити, встановіть гілку проекту на \"розвиток\"."
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: "Досягнуто обмеження часу реєстрації. Видалення даних та завершення роботи."
LOOKUP_BLOCK: "{0} {розміщено|зламано} {1}."
LOOKUP_CONTAINER: "{0} {додано|видалено} {1} {2}."
LOOKUP_HEADER: "{0} Результати"
LOOKUP_INTERACTION: "{0} {натиснув|убитий} {1}."
LOOKUP_ITEM: "{0} {взяв|скинув} {1} {2}."
LOOKUP_LOGIN: "{0} зареєстрований {в|з ~ ~}."
LOOKUP_PAGE: "Сторінка {0}"
LOOKUP_ROWS_FOUND: "{0} {рядок|рядки} знайдено."
LOOKUP_SEARCHING: "Пошук під час пошуку. Будь ласка, зачекайте..."
LOOKUP_STORAGE: "{0} {здано на зберігання|вилучено} {1} {2}."
LOOKUP_TIME: "{0} тому"
LOOKUP_USERNAME: "{0} Ви увійшли як {1}."
LOOKUP_VIEW_PAGE: "Щоб переглянути сторінку, введіть \"{0}\"."
MAXIMUM_RADIUS: "Максимум {пошук|відкат|відновлення} радіус дорівнює {0}."
MISSING_ACTION_USER: "Щоб використати цю дію, вкажіть користувача."
MISSING_LOOKUP_TIME: "Будь ласка, вкажіть час до {пошук|відкат|відновлення}."
MISSING_LOOKUP_USER: "Будь ласка, вкажіть користувача або {блок|радіус}."
MISSING_PARAMETERS: "Будь ласка, використовуйте \"{0}\"."
MISSING_ROLLBACK_RADIUS: "Ви не вказали a {відкат|відновлення} радіус."
MISSING_ROLLBACK_USER: "Ви не вказали a {відкат|відновлення} користувача."
MYSQL_UNAVAILABLE: "Не вдається підключитися до MySQL сервер."
NO_DATA: "Дані не знайдені за адресою {0}."
NO_DATA_LOCATION: "Ні {дані|транзакції|взаємодії|повідомлення} знайдено."
NO_PERMISSION: "У вас немає дозволу на це."
NO_RESULTS: "Нічого не знайдено."
NO_RESULTS_PAGE: "Ні {результати|дані} знайдено для цієї сторінки."
NO_ROLLBACK: "Ні {в очікуванні|попередній} відкат/відновлення знайдено."
PATCH_INTERRUPTED: "Оновлення перервано. Спробую ще раз при перезавантаженні."
PATCH_OUTDATED_1: "Не вдається оновити бази даних старші {0}."
PATCH_OUTDATED_2: "Оновіть підтримувану версію CoreProtect."
PATCH_PROCESSING: "Обробка нових даних. Будь ласка, зачекайте..."
PATCH_SKIP_UPDATE: "Пропуск {таблиця|індекс} {оновлення|створення|видалення} на {0}."
PATCH_STARTED: "Виконання {0} оновлення. Будь ласка, зачекайте..."
PATCH_SUCCESS: "Успішно оновлено до {0}."
PATCH_UPGRADING: "Триває оновлення бази даних. Будь ласка, зачекайте..."
PLEASE_SELECT: "Виберіть будь ласка: \"{0}\" або \"{1}\"."
PREVIEW_CANCELLED: "Попередній перегляд скасовано."
PREVIEW_CANCELLING: "Скасування попереднього перегляду..."
PREVIEW_CONTAINER: "Ви не можете переглядати транзакційні контейнери."
PREVIEW_IN_GAME: "Попередній перегляд можна лише в грі."
PURGE_ABORTED: "Помилка очищення. Можливо, база даних пошкоджена."
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_SUCCESS: "Очищення даних успішно."
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_IN_PROGRESS: "Відкат/відновлення вже триває."
ROLLBACK_LENGTH: "Витрачений час: {0} {секунда|секунди}."
ROLLBACK_MODIFIED: "{Змінено|Змінюється} {0}."
ROLLBACK_RADIUS: "Радіус: {0} {блок|блоки}."
ROLLBACK_SELECTION: "Радіус встановлено на \"{0}\"."
ROLLBACK_STARTED: "{Відкат|Відновлення|Попередній перегляд} почав \"{0}\"."
ROLLBACK_TIME: "Часовий діапазон: {0}."
ROLLBACK_WORLD_ACTION: "Обмежено до {світ|дія} \"{0}\"."
SIGN_HEADER: "Підписуйте повідомлення"
STATUS_CONSUMER: "Споживач: {0} {пункт|предмети} в черзі."
STATUS_DATABASE: "База даних: Використання {0}."
STATUS_INTEGRATION: "{0}: Інтеграція {включено|вимкнено}."
STATUS_LICENSE: "Ліцензія: {0}"
STATUS_VERSION: "Версія: {0}"
TELEPORTED: "Телепортувався до {0}."
TELEPORTED_SAFETY: "Телепортував вас у безпечне місце."
TELEPORT_PLAYERS: "Команду телепорту можуть використовувати лише гравці."
TIME_DAYS: "{0} {день|дні}"
TIME_HOURS: "{0} {година|години}"
TIME_MINUTES: "{0} {хвилина|хвилини}"
TIME_SECONDS: "{0} {секунда|секунди}"
TIME_WEEKS: "{0} {тиждень|тиждень}"
UPDATE_ERROR: "Під час перевірки оновлень сталася помилка."
UPDATE_HEADER: "{0} Оновлення"
UPDATE_NOTICE: "Примітка: {0} тепер доступний."
UPGRADE_IN_PROGRESS: "Оновлення триває. Будь-ласка спробуйте пізніше."
USER_NOT_FOUND: "Користувач \"{0}\" не знайдено."
USING_MYSQL: "Використання MySQL для зберігання даних."
USING_SQLITE: "Використання SQLite для зберігання даних."
VALID_DONATION_KEY: "Дійсний ключ пожертви."
VERSION_NOTICE: "Версія {0} тепер доступний."
VERSION_REQUIRED: "{0} {1} або вище."
WORLD_NOT_FOUND: "Світ \"{0}\" не знайдено."
+197
View File
@@ -0,0 +1,197 @@
# CoreProtect Language File (vi)
ACTION_NOT_SUPPORTED: "Hành động đó không được hỗ trợ."
AMOUNT_BLOCK: "{0} {khối|khối}"
AMOUNT_CHUNK: "{0} {chunk|chunks}"
AMOUNT_ENTITY: "{0} {thực thể|thực thể}"
AMOUNT_ITEM: "{0} {item|item}"
API_TEST: "Kiểm tra API thành công."
CACHE_ERROR: "CẢNH BÁO: Lỗi khi xác thực {0} bộ nhớ đệm."
CACHE_RELOAD: "Buộc tải lại {lập bản đồ|thế giới} bộ nhớ đệm từ cơ sở dữ liệu."
CHECK_CONFIG: "Vui lòng kiểm tra config.yml"
COMMAND_NOT_FOUND: "Yêu cầu \"{0}\" không tìm thấy."
COMMAND_THROTTLED: "Vui lòng đợi trong giây lát và thử lại."
CONTAINER_HEADER: "Giao dịch vùng chứa"
DATABASE_BUSY: "Cơ sở dữ liệu bận rộn. Vui lòng thử lại sau."
DATABASE_INDEX_ERROR: "Không thể xác thực các chỉ mục cơ sở dữ liệu."
DATABASE_LOCKED_1: "Cơ sở dữ liệu bị khóa. Chờ tối đa 15 giây..."
DATABASE_LOCKED_2: "Cơ sở dữ liệu đã được sử dụng. Vui lòng thử lại."
DATABASE_LOCKED_3: "Để tắt khóa cơ sở dữ liệu, hãy đặt \"khóa cơ sở dữ liệu: false\"."
DATABASE_LOCKED_4: "Vô hiệu hóa khóa cơ sở dữ liệu có thể dẫn đến hỏng dữ liệu."
DATABASE_UNREACHABLE: "Cơ sở dữ liệu không thể truy cập được. Đang hủy bỏ dữ liệu và tắt."
DEVELOPMENT_BRANCH: "Đã phát hiện nhánh phát triển, bỏ qua các tập lệnh vá lỗi."
DIRT_BLOCK: "Đặt một khối bẩn dưới bạn."
DISABLE_SUCCESS: "Sự thành công! Tàn tật {0}"
ENABLE_FAILED: "{0} đã không thể bắt đầu."
ENABLE_SUCCESS: "{0} hiện đã được kích hoạt!"
ENJOY_COREPROTECT: "Vui thích {0}? Gia nhập với chúng tôi Discord!"
FINISHING_CONVERSION: "Kết thúc chuyển đổi dữ liệu. Vui lòng chờ..."
FINISHING_LOGGING: "Hoàn thành việc ghi dữ liệu. Vui lòng chờ..."
FIRST_VERSION: "DB ban đầu: {0}"
GLOBAL_LOOKUP: "Không chỉ định bán kính để thực hiện tra cứu toàn cục."
GLOBAL_ROLLBACK: "Sử dụng \"{0}\" để làm một toàn cầu {quay lại|khôi phục}"
HELP_ACTION_1: "Hạn chế tra cứu đối với một hành động."
HELP_ACTION_2: "Ví dụ: [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: "Hiển thị thông tin bổ sung."
HELP_EXCLUDE_1: "Loại trừ khối / người dùng."
HELP_EXCLUDE_2: "Ví dụ: [e:stone], [e:Notch], [e:stone,Notch]"
HELP_HEADER: "{0} Trợ giúp"
HELP_INCLUDE_1: "Bao gồm các khối / thực thể."
HELP_INCLUDE_2: "Ví dụ: [i:stone], [i:zombie], [i:stone,wood,bedrock]"
HELP_INSPECT_1: "Với trình kiểm tra được bật, bạn có thể:"
HELP_INSPECT_2: "Nhấp chuột trái để xem vị trí."
HELP_INSPECT_3: "Nhấp chuột phải để xem các lần xóa liền kề."
HELP_INSPECT_4: "Đặt một khối để xem việc loại bỏ."
HELP_INSPECT_5: "Đặt một khối vào chất lỏng để xem vị trí."
HELP_INSPECT_6: "Nhấp chuột phải để xem các giao dịch rương."
HELP_INSPECT_7: "Mẹo: Bạn chỉ có thể sử dụng \"/co i\"."
HELP_INSPECT_COMMAND: "Chuyển đổi trình kiểm tra khối."
HELP_LIST: "Hiển thị danh sách tất cả các lệnh."
HELP_LOOKUP_1: "Phím tắt lệnh."
HELP_LOOKUP_2: "Xem các trang bổ sung."
HELP_LOOKUP_COMMAND: "Dữ liệu khối tra cứu."
HELP_NO_INFO: "Thông tin cho lệnh \"{0}\" không tìm thấy."
HELP_PARAMETER: "Hãy xem \"{0}\" để biết thông tin chi tiết về thông số."
HELP_PARAMS_1: "Thực hiện {tra cứu|khôi phục|khôi phục}."
HELP_PARAMS_2: "Chỉ định người dùng {tra cứu|khôi phục|khôi phục}."
HELP_PARAMS_3: "Chỉ định thời gian để {tra cứu|khôi phục|khôi phục}."
HELP_PARAMS_4: "Hạn chế {tra cứu|khôi phục|khôi phục} đến một bán kính."
HELP_PARAMS_5: "Hạn chế {tra cứu|khôi phục|khôi phục} cho một hành động."
HELP_PARAMS_6: "Bao gồm các khối / thực thể trong {tra cứu|khôi phục|khôi phục}."
HELP_PARAMS_7: "Loại trừ các khối / người dùng khỏi {tra cứu|khôi phục|khôi phục}."
HELP_PURGE_1: "Xóa dữ liệu cũ."
HELP_PURGE_2: "Ví dụ, \"{0}\" sẽ xóa tất cả dữ liệu cũ hơn một tháng và chỉ giữ lại dữ liệu trong 30 ngày qua."
HELP_PURGE_COMMAND: "Xóa dữ liệu khối cũ."
HELP_RADIUS_1: "Chỉ định một khu vực bán kính."
HELP_RADIUS_2: "Ví dụ: [r:10] (Chỉ thực hiện các thay đổi trong vòng 10 khối nhà bạn)"
HELP_RELOAD_COMMAND: "Tải lại tệp cấu hình."
HELP_RESTORE_COMMAND: "Khôi phục dữ liệu khối."
HELP_ROLLBACK_COMMAND: "Dữ liệu khối khôi phục."
HELP_STATUS: "Xem trạng thái plugin."
HELP_STATUS_COMMAND: "Hiển thị trạng thái plugin."
HELP_TELEPORT: "Dịch chuyển."
HELP_TIME_1: "Chỉ định thời gian."
HELP_TIME_2: "Ví dụ: [t:2w,5d,7h,2m,10s], [t:5d2h], [t:2.50h]"
HELP_USER_1: "Chỉ định người dùng."
HELP_USER_2: "Ví dụ: [u:Notch], [u:Notch,#enderman]"
INCOMPATIBLE_ACTION: "\"{0}\" không thể được sử dụng với hành động đó."
INSPECTOR_ERROR: "Thanh tra đã {đã bật|đã tắt}."
INSPECTOR_TOGGLED: "Thanh tra ngay {đã bật|đã tắt}."
INTEGRATION_ERROR: "Không có khả năng {khởi tạo|vô hiệu hóa} {0} khai thác gỗ."
INTEGRATION_SUCCESS: "{0} ghi nhật ký thành công {khởi tạo|bị vô hiệu hóa}."
INTEGRATION_VERSION: "Không hợp lệ {0} phiên bản được tìm thấy."
INTERACTIONS_HEADER: "Tương tác của người chơi"
INVALID_ACTION: "Đó không phải là một hành động hợp lệ."
INVALID_BRANCH_1: "Phiên bản plugin không hợp lệ (chưa đặt nhánh)."
INVALID_BRANCH_2: "Để tiếp tục, hãy đặt nhánh dự án thành \"phát triển\"."
INVALID_BRANCH_3: "Chạy mã phát triển có thể dẫn đến hỏng dữ liệu."
INVALID_CONTAINER: "Vui lòng kiểm tra một thùng chứa hợp lệ trước."
INVALID_DONATION_KEY: "Khóa quyên góp không hợp lệ."
INVALID_INCLUDE: "\"{0}\" là một giá trị không hợp lệ."
INVALID_INCLUDE_COMBO: "Đó là sự kết hợp kiểu không hợp lệ."
INVALID_RADIUS: "Vui lòng nhập bán kính hợp lệ."
INVALID_SELECTION: "{0} lựa chọn không được tìm thấy."
INVALID_USERNAME: "\"{0}\" là tên người dùng không hợp lệ."
INVALID_WORLD: "Vui lòng chỉ định một thế giới hợp lệ."
LATEST_VERSION: "Phiên bản mới nhất: {0}"
LINK_DISCORD: "Discord: {0}"
LINK_DOWNLOAD: "Tải xuống: {0}"
LINK_PATREON: "Patreon: {0}"
LINK_WIKI_BLOCK: "Tên khối: {0}"
LINK_WIKI_ENTITY: "Tên thực thể: {0}"
LOGGING_ITEMS: "{0} mục còn lại để ghi. Vui lòng chờ..."
LOGGING_TIME_LIMIT: "Đã đạt đến giới hạn thời gian ghi nhật ký. Đang hủy bỏ dữ liệu và tắt."
LOOKUP_BLOCK: "{0} {đặt|đã phá vỡ} {1}."
LOOKUP_CONTAINER: "{0} {đã thêm|đã loại bỏ} {1} {2}."
LOOKUP_HEADER: "{0} Kết quả"
LOOKUP_INTERACTION: "{0} {đã nhấp vào|giết} {1}."
LOOKUP_ITEM: "{0} {nhặt lên|đánh rơi} {1} {2}."
LOOKUP_LOGIN: "{0} ghi nhật ký {vào|ra}."
LOOKUP_PAGE: "Trang {0}"
LOOKUP_ROWS_FOUND: "{0} {hàng|hàng} tìm."
LOOKUP_SEARCHING: "Tra cứu tìm kiếm. Vui lòng chờ..."
LOOKUP_STORAGE: "{0} {ký gửi|rút tiền} {1} {2}."
LOOKUP_TIME: "{0} trước kia"
LOOKUP_USERNAME: "{0} đăng nhập với tư cách {1}."
LOOKUP_VIEW_PAGE: "Để xem một trang, hãy nhập \"{0}\"."
MAXIMUM_RADIUS: "Giá trị lớn nhất {tra cứu|khôi phục|khôi phục} bán kính là {0}."
MISSING_ACTION_USER: "Để sử dụng hành động đó, vui lòng chỉ định người dùng."
MISSING_LOOKUP_TIME: "Vui lòng xác định thời gian để {tra cứu|khôi phục|khôi phục}."
MISSING_LOOKUP_USER: "Vui lòng chỉ định người dùng hoặc {khối|bán kính}."
MISSING_PARAMETERS: "Vui lòng sử dụng \"{0}\"."
MISSING_ROLLBACK_RADIUS: "Bạn đã không chỉ định một {khôi phục lại|khôi phục} bán kính."
MISSING_ROLLBACK_USER: "Bạn đã không chỉ định một {khôi phục lại|khôi phục} người sử dụng."
MYSQL_UNAVAILABLE: "Không thể kết nối MySQL người phục vụ."
NO_DATA: "Không tìm thấy dữ liệu tại {0}."
NO_DATA_LOCATION: "Không {dữ liệu|giao dịch|tương tác|tin nhắn} tìm."
NO_PERMISSION: "Bạn không có quyền để làm điều đó."
NO_RESULTS: "Không tìm thấy kết quả nào."
NO_RESULTS_PAGE: "Không {kết quả|dữ liệu} được tìm thấy cho trang đó."
NO_ROLLBACK: "Không {đang chờ xử lý|trước đó} khôi phục / khôi phục được tìm thấy."
PATCH_INTERRUPTED: "Nâng cấp bị gián đoạn. Sẽ thử lại khi khởi động lại."
PATCH_OUTDATED_1: "Không thể nâng cấp cơ sở dữ liệu cũ hơn {0}."
PATCH_OUTDATED_2: "Vui lòng nâng cấp bằng phiên bản được hỗ trợ của CoreProtect."
PATCH_PROCESSING: "Xử lý dữ liệu mới. Vui lòng chờ..."
PATCH_SKIP_UPDATE: "Bỏ qua {bảng|chỉ mục} {cập nhật|tạo|loại bỏ} trên {0}."
PATCH_STARTED: "Biểu diễn {0} nâng cấp. Vui lòng chờ..."
PATCH_SUCCESS: "Đã nâng cấp thành công lên {0}."
PATCH_UPGRADING: "Đang nâng cấp cơ sở dữ liệu. Vui lòng chờ..."
PLEASE_SELECT: "Xin hãy lựa chọn: \"{0}\" hoặc \"{1}\"."
PREVIEW_CANCELLED: "Đã hủy bản xem trước."
PREVIEW_CANCELLING: "Đang hủy bản xem trước..."
PREVIEW_CONTAINER: "Bạn không thể xem trước các giao dịch vùng chứa."
PREVIEW_IN_GAME: "Bạn chỉ có thể xem trước các lần quay lại trong trò chơi."
PURGE_ABORTED: "Thanh trừng không thành công. Cơ sở dữ liệu có thể bị hỏng."
PURGE_ERROR: "Không thể xử lý {0} dữ liệu!"
PURGE_FAILED: "Thanh trừng không thành công. Vui lòng thử lại sau."
PURGE_IN_PROGRESS: "Đang tiến hành thanh lọc. Vui lòng thử lại sau."
PURGE_MINIMUM_TIME: "Bạn chỉ có thể xóa dữ liệu cũ hơn {0} {ngày|giờ}."
PURGE_NOTICE_1: "Xin lưu ý rằng điều này có thể mất một thời gian."
PURGE_NOTICE_2: "Không khởi động lại máy chủ của bạn cho đến khi hoàn thành."
PURGE_OPTIMIZING: "Tối ưu hóa cơ sở dữ liệu. Vui lòng chờ..."
PURGE_PROCESSING: "Xử lý {0} dữ liệu..."
PURGE_REPAIRING: "Đang cố gắng sửa chữa. Điều này có thể mất một thời gian..."
PURGE_ROWS: "{0} {hàng|hàng} dữ liệu bị xóa."
PURGE_STARTED: "Quá trình thanh lọc dữ liệu bắt đầu vào \"{0}\"."
PURGE_SUCCESS: "Xóa dữ liệu thành công."
RELOAD_STARTED: "Đang tải lại cấu hình - vui lòng đợi."
RELOAD_SUCCESS: "Đã tải lại cấu hình thành công."
ROLLBACK_ABORTED: "Đã hủy bỏ khôi phục hoặc khôi phục."
ROLLBACK_CHUNKS_FOUND: "Tìm {0} {khối|khối} để sửa đổi."
ROLLBACK_CHUNKS_MODIFIED: "Đã sửa đổi {0}/{1} {chunk|chunks}."
ROLLBACK_COMPLETED: "{Quay lại|Khôi phục|Xem trước} hoàn thành cho \"{0}\"."
ROLLBACK_EXCLUDED_USERS: "Bị loại trừ {người dùng|người dùng}: \"{0}\"."
ROLLBACK_INCLUDE: "{Đã bao gồm|Đã loại trừ} {khối|thực thể|mục tiêu} {loại|loại}: \"{0}\"."
ROLLBACK_IN_PROGRESS: "Quá trình khôi phục / khôi phục đang được tiến hành."
ROLLBACK_LENGTH: "Mất thời gian: {0} {giây|giây}."
ROLLBACK_MODIFIED: "{Đã sửa đổi|Đang sửa đổi} {0}."
ROLLBACK_RADIUS: "Bán kính: {0} {khối|khối}."
ROLLBACK_SELECTION: "Bán kính được đặt thành \"{0}\"."
ROLLBACK_STARTED: "{Quay lại|Khôi phục|Xem trước} Bắt đầu vào \"{0}\"."
ROLLBACK_TIME: "Phạm vi thời gian: {0}."
ROLLBACK_WORLD_ACTION: "Bị hạn chế đối với {thế giới|hành động} \"{0}\"."
SIGN_HEADER: "Ký tin nhắn"
STATUS_CONSUMER: "Khách hàng: {0} {mặt hàng|mặt hàng} đợi."
STATUS_DATABASE: "Cơ sở dữ liệu: Sử dụng {0}."
STATUS_INTEGRATION: "{0}: Hội nhập {đã bật|đã tắt}."
STATUS_LICENSE: "Giấy phép: {0}"
STATUS_VERSION: "Phiên bản: {0}"
TELEPORTED: "Dịch chuyển đến {0}."
TELEPORTED_SAFETY: "Dịch chuyển bạn đến nơi an toàn."
TELEPORT_PLAYERS: "Lệnh dịch chuyển chỉ có thể được sử dụng bởi người chơi."
TIME_DAYS: "{0} {ngày|ngày}"
TIME_HOURS: "{0} {giờ|giờ}"
TIME_MINUTES: "{0} {phút|phút}"
TIME_SECONDS: "{0} {giây|giây}"
TIME_WEEKS: "{0} {tuần|tuần}"
UPDATE_ERROR: "Đã xảy ra lỗi khi kiểm tra các bản cập nhật."
UPDATE_HEADER: "{0} Cập nhật"
UPDATE_NOTICE: "Lưu ý: {0} hiện đã có sẵn."
UPGRADE_IN_PROGRESS: "Đang nâng cấp. Vui lòng thử lại sau."
USER_NOT_FOUND: "Người sử dụng \"{0}\" không tìm thấy."
USING_MYSQL: "Sử dụng MySQL để lưu trữ dữ liệu."
USING_SQLITE: "Sử dụng SQLite để lưu trữ dữ liệu."
VALID_DONATION_KEY: "Chìa khóa quyên góp hợp lệ."
VERSION_NOTICE: "Phiên bản {0} hiện đã có sẵn."
VERSION_REQUIRED: "{0} {1} hoặc cao hơn là bắt buộc."
WORLD_NOT_FOUND: "Thế giới \"{0}\" không tìm thấy."
+1 -1
View File
@@ -171,7 +171,7 @@ ROLLBACK_SELECTION: "半径设置为\"{0}\"。"
ROLLBACK_STARTED: "{回滚|恢复|预览}于 \"{0}\" 开始。"
ROLLBACK_TIME: "时间范围: {0}."
ROLLBACK_WORLD_ACTION: "限制{世界|动作}为 \"{0}\"。"
SIGN_HEADER: "签名消息"
SIGN_HEADER: "木牌消息"
STATUS_CONSUMER: "数据处理器: {0}个{数据|数据}待处理。"
STATUS_DATABASE: "数据库: 正在使用 {0}."
STATUS_INTEGRATION: "{0}: 合并{启用|禁用}."
+17 -17
View File
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.coreprotect</groupId>
<artifactId>CoreProtect</artifactId>
<version>20.1</version>
<version>20.4</version>
<properties>
<project.branch></project.branch>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -56,6 +56,10 @@
<pattern>org.bstats</pattern>
<shadedPattern>net.coreprotect</shadedPattern>
</relocation>
<relocation>
<pattern>com.zaxxer</pattern>
<shadedPattern>net.coreprotect</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
@@ -64,12 +68,6 @@
</plugins>
</build>
<repositories>
<!--
<repository>
<id>public</id>
<url>http://repo.mvdw-software.be/content/groups/public/</url>
</repository>
-->
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
@@ -88,20 +86,17 @@
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!--
paper-api (<= 1.16): com.destroystokyo.paper
spigot-api: org.spigotmc
bukkit: org.bukkit
-->
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
-->
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit-lite</artifactId>
@@ -120,5 +115,10 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>4.0.3</version>
</dependency>
</dependencies>
</project>
</project>
+1 -1
View File
@@ -1 +1 @@
mkdocs==1.2.1
mkdocs==1.2.3
@@ -13,6 +13,7 @@ import net.coreprotect.config.Config;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.consumer.Consumer;
import net.coreprotect.consumer.process.Process;
import net.coreprotect.database.Database;
import net.coreprotect.language.Language;
import net.coreprotect.language.Phrase;
import net.coreprotect.listener.ListenerHandler;
@@ -189,6 +190,7 @@ public final class CoreProtect extends JavaPlugin {
Thread.sleep(100);
}
Database.closeConnection();
Chat.console(Phrase.build(Phrase.DISABLE_SUCCESS, "CoreProtect v" + plugin.getDescription().getVersion()));
}
catch (Exception e) {
@@ -142,7 +142,7 @@ public class CoreProtectAPI extends Queue {
}
public int APIVersion() {
return 7;
return 8;
}
public List<String[]> blockLookup(Block block, int time) {
@@ -445,8 +445,7 @@ public class CoreProtectAPI extends Queue {
return null;
}
try {
Connection connection = Database.getConnection(false, 1000);
try (Connection connection = Database.getConnection(false, 1000)) {
if (connection != null) {
Statement statement = connection.createStatement();
boolean restrictWorld = false;
@@ -465,7 +464,7 @@ public class CoreProtectAPI extends Queue {
int xMax = location.getBlockX() + radius;
int zMin = location.getBlockZ() - radius;
int zMax = location.getBlockZ() + radius;
argRadius = new Integer[] { radius, xMin, xMax, -1, -1, zMin, zMax, 0 };
argRadius = new Integer[] { radius, xMin, xMax, null, null, zMin, zMax, 0 };
}
if (lookup == 1) {
@@ -488,7 +487,6 @@ public class CoreProtectAPI extends Queue {
}
statement.close();
connection.close();
}
}
catch (Exception e) {
@@ -22,25 +22,27 @@ import net.coreprotect.utility.Util;
public class BukkitAdapter implements BukkitInterface {
public static BukkitInterface ADAPTER;
public static final int BUKKIT_v1_13 = 13;
public static final int BUKKIT_v1_14 = 14;
public static final int BUKKIT_v1_15 = 15;
public static final int BUKKIT_v1_16 = 16;
public static final int BUKKIT_v1_17 = 17;
public static final int BUKKIT_V1_13 = 13;
public static final int BUKKIT_V1_14 = 14;
public static final int BUKKIT_V1_15 = 15;
public static final int BUKKIT_V1_16 = 16;
public static final int BUKKIT_V1_17 = 17;
public static final int BUKKIT_V1_18 = 18;
public static void loadAdapter() {
switch (ConfigHandler.SERVER_VERSION) {
case BUKKIT_v1_13:
case BUKKIT_v1_14:
case BUKKIT_V1_13:
case BUKKIT_V1_14:
BukkitAdapter.ADAPTER = new BukkitAdapter();
break;
case BUKKIT_v1_15:
case BUKKIT_V1_15:
BukkitAdapter.ADAPTER = new Bukkit_v1_15();
break;
case BUKKIT_v1_16:
case BUKKIT_V1_16:
BukkitAdapter.ADAPTER = new Bukkit_v1_16();
break;
case BUKKIT_v1_17:
case BUKKIT_V1_17:
case BUKKIT_V1_18:
default:
BukkitAdapter.ADAPTER = new Bukkit_v1_17();
break;
@@ -29,7 +29,7 @@ import net.coreprotect.utility.Util;
public class Bukkit_v1_17 extends Bukkit_v1_16 implements BukkitInterface {
public Bukkit_v1_17() {
BlockGroup.TRACK_ANY = new HashSet<>(Arrays.asList(Material.MOVING_PISTON, Material.LEVER, Material.BELL, Material.SMALL_AMETHYST_BUD, Material.MEDIUM_AMETHYST_BUD, Material.LARGE_AMETHYST_BUD, Material.AMETHYST_CLUSTER, Material.GLOW_LICHEN));
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_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));
@@ -11,14 +11,13 @@ import net.coreprotect.language.Phrase;
import net.coreprotect.language.Selector;
import net.coreprotect.utility.Chat;
import net.coreprotect.utility.Color;
import net.coreprotect.utility.Util;
public class ApplyCommand {
protected static void runCommand(CommandSender user, Command command, boolean permission, String[] args) {
try {
if (ConfigHandler.lastRollback.get(user.getName()) != null) {
List<Object> list = ConfigHandler.lastRollback.get(user.getName());
int time = (Integer) list.get(0);
long time = (Long) list.get(0);
args = (String[]) list.get(1);
Location location = (Location) list.get(2);
boolean valid = false;
@@ -11,14 +11,13 @@ import net.coreprotect.language.Phrase;
import net.coreprotect.language.Selector;
import net.coreprotect.utility.Chat;
import net.coreprotect.utility.Color;
import net.coreprotect.utility.Util;
public class CancelCommand {
protected static void runCommand(CommandSender user, Command command, boolean permission, String[] args) {
try {
if (ConfigHandler.lastRollback.get(user.getName()) != null) {
List<Object> list = ConfigHandler.lastRollback.get(user.getName());
int time = (Integer) list.get(0);
long time = (Long) list.get(0);
args = (String[]) list.get(1);
Location location = (Location) list.get(2);
boolean valid = false;
@@ -563,12 +563,12 @@ public class CommandHandler implements CommandExecutor {
rcount++;
}
if (location != null) {
int xmin = location.getBlockX() - r_x;
int xmax = location.getBlockX() + r_x;
int ymin = -1;
int ymax = -1;
int zmin = location.getBlockZ() - r_z;
int zmax = location.getBlockZ() + r_z;
Integer xmin = location.getBlockX() - r_x;
Integer xmax = location.getBlockX() + r_x;
Integer ymin = null;
Integer ymax = null;
Integer zmin = location.getBlockZ() - r_z;
Integer zmax = location.getBlockZ() + r_z;
if (r_y > -1) {
ymin = location.getBlockY() - r_y;
ymax = location.getBlockY() + r_y;
@@ -691,9 +691,9 @@ public class CommandHandler implements CommandExecutor {
return restricted;
}
protected static int parseTime(String[] inputArguments) {
protected static long parseTime(String[] inputArguments) {
String[] argumentArray = inputArguments.clone();
int time = 0;
long time = 0;
int count = 0;
int next = 0;
double w = 0;
@@ -754,7 +754,7 @@ public class CommandHandler implements CommandExecutor {
}
}
double rs = ((w * 7 * 24 * 60 * 60) + (d * 24 * 60 * 60) + (h * 60 * 60) + (m * 60) + s);
time = (int) rs;
time = (long) rs;
next = 0;
}
else {
@@ -763,6 +763,7 @@ public class CommandHandler implements CommandExecutor {
}
count++;
}
return time;
}
@@ -7,7 +7,6 @@ import net.coreprotect.language.Phrase;
import net.coreprotect.language.Selector;
import net.coreprotect.utility.Chat;
import net.coreprotect.utility.Color;
import net.coreprotect.utility.Util;
public class InspectCommand {
protected static void runCommand(CommandSender player, boolean permission, String[] args) {
@@ -7,7 +7,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -19,6 +18,8 @@ import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import com.google.common.base.Strings;
import net.coreprotect.config.Config;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.database.Database;
@@ -50,7 +51,7 @@ public class LookupCommand {
List<Object> argExclude = CommandHandler.parseExcluded(player, args, argAction);
List<String> argExcludeUsers = CommandHandler.parseExcludedUsers(player, args);
String ts = CommandHandler.parseTimeString(args);
int rbseconds = CommandHandler.parseTime(args);
long rbseconds = CommandHandler.parseTime(args);
int argWid = CommandHandler.parseWorld(args, true, true);
int parseRows = CommandHandler.parseRows(args);
boolean count = CommandHandler.parseCount(args);
@@ -324,9 +325,8 @@ public class LookupCommand {
class BasicThread implements Runnable {
@Override
public void run() {
try {
try (Connection connection = Database.getConnection(true)) {
ConfigHandler.lookupThrottle.put(player2.getName(), new Object[] { true, System.currentTimeMillis() });
Connection connection = Database.getConnection(true);
if (connection != null) {
Statement statement = connection.createStatement();
String blockdata = ChestTransactionLookup.performLookup(command.getName(), statement, location, player2, p2, finalLimit, false);
@@ -339,7 +339,6 @@ public class LookupCommand {
Chat.sendComponent(player2, blockdata);
}
statement.close();
connection.close();
}
else {
Chat.sendMessage(player2, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
@@ -422,9 +421,8 @@ public class LookupCommand {
class BasicThread implements Runnable {
@Override
public void run() {
try {
try (Connection connection = Database.getConnection(true)) {
ConfigHandler.lookupThrottle.put(player2.getName(), new Object[] { true, System.currentTimeMillis() });
Connection connection = Database.getConnection(true);
if (connection != null) {
Statement statement = connection.createStatement();
if (t == 8) {
@@ -461,7 +459,6 @@ public class LookupCommand {
}
}
statement.close();
connection.close();
}
else {
Chat.sendMessage(player2, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
@@ -557,7 +554,7 @@ public class LookupCommand {
c++;
}
int cs = -1;
long cs = -1;
int x = 0;
int y = 0;
int z = 0;
@@ -570,7 +567,7 @@ public class LookupCommand {
y = Integer.parseInt(data[1]);
z = Integer.parseInt(data[2]);
wid = Integer.parseInt(data[3]);
cs = Integer.parseInt(data[4]);
cs = Long.parseLong(data[4]);
// arg_radius = Integer.parseInt(data[5]);
argNoisy = Integer.parseInt(data[5]);
argExcluded = Integer.parseInt(data[6]);
@@ -643,7 +640,7 @@ public class LookupCommand {
}
final List<String> rollbackusers2 = rollbackusers;
int unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
long unixtimestamp = (System.currentTimeMillis() / 1000L);
if (cs == -1) {
if (rbseconds <= 0) {
cs = 0;
@@ -652,7 +649,7 @@ public class LookupCommand {
cs = unixtimestamp - rbseconds;
}
}
final int stime = cs;
final long stime = cs;
final Integer[] radius = argRadius;
try {
@@ -681,7 +678,7 @@ public class LookupCommand {
class BasicThread2 implements Runnable {
@Override
public void run() {
try {
try (Connection connection = Database.getConnection(true)) {
ConfigHandler.lookupThrottle.put(player2.getName(), new Object[] { true, System.currentTimeMillis() });
List<String> uuidList = new ArrayList<>();
@@ -699,7 +696,6 @@ public class LookupCommand {
ConfigHandler.lookupAlist.put(player2.getName(), finalArgAction);
ConfigHandler.lookupRadius.put(player2.getName(), radius);
Connection connection = Database.getConnection(true);
if (connection != null) {
Statement statement = connection.createStatement();
String baduser = "";
@@ -802,7 +798,7 @@ public class LookupCommand {
String timeago = Util.getTimeSince(Integer.parseInt(time), unixtimestamp, true);
double time_length = Util.getTimeSince(Integer.parseInt(time), unixtimestamp, false).replaceAll("[^0-9]", "").length() * 1.50;
int padding = (int) (time_length + 12.50);
String leftPadding = StringUtils.leftPad("", padding, ' ');
String leftPadding = Strings.padStart("", padding, ' ');
Chat.sendComponent(player2, timeago + " " + Color.WHITE + "- " + Color.DARK_AQUA + Phrase.build(Phrase.LOOKUP_LOGIN, Color.DARK_AQUA + dplayer + Color.WHITE, (action != 0 ? Selector.FIRST : Selector.SECOND)));
Chat.sendComponent(player2, Color.WHITE + leftPadding + Color.GREY + "^ " + Util.getCoordinates(command.getName(), wid, x, y, z, true, true) + "");
}
@@ -828,7 +824,7 @@ public class LookupCommand {
String timeago = Util.getTimeSince(Integer.parseInt(time), unixtimestamp, true);
double time_length = Util.getTimeSince(Integer.parseInt(time), unixtimestamp, false).replaceAll("[^0-9]", "").length() * 1.50;
int padding = (int) (time_length + 12.50);
String leftPadding = StringUtils.leftPad("", padding, ' ');
String leftPadding = Strings.padStart("", padding, ' ');
Chat.sendComponent(player2, timeago + " " + Color.WHITE + "- " + Color.DARK_AQUA + dplayer + ": " + Color.WHITE, message);
Chat.sendComponent(player2, Color.WHITE + leftPadding + Color.GREY + "^ " + Util.getCoordinates(command.getName(), wid, x, y, z, true, true) + "");
}
@@ -856,7 +852,7 @@ public class LookupCommand {
String timeago = Util.getTimeSince(Integer.parseInt(time), unixtimestamp, true);
double timeLength = Util.getTimeSince(Integer.parseInt(time), unixtimestamp, false).replaceAll("[^0-9]", "").length() * 1.50;
int padding = (int) (timeLength + 12.50);
String leftPadding = StringUtils.leftPad("", padding, ' ');
String leftPadding = Strings.padStart("", padding, ' ');
String dname = "";
boolean isPlayer = false;
@@ -950,7 +946,6 @@ public class LookupCommand {
Chat.sendMessage(player2, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.USER_NOT_FOUND, baduser));
}
statement.close();
connection.close();
}
else {
Chat.sendMessage(player2, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
@@ -31,7 +31,7 @@ public class PurgeCommand extends Consumer {
int resultc = args.length;
Location location = CommandHandler.parseLocation(player, args);
final Integer[] argRadius = CommandHandler.parseRadius(args, player, location);
final int seconds = CommandHandler.parseTime(args);
final long seconds = CommandHandler.parseTime(args);
final int argWid = CommandHandler.parseWorld(args, false, false);
final List<Integer> argAction = CommandHandler.parseAction(args);
final List<Integer> supportedActions = Arrays.asList();
@@ -95,8 +95,8 @@ public class PurgeCommand extends Consumer {
@Override
public void run() {
try {
int timestamp = (int) (System.currentTimeMillis() / 1000L);
int ptime = timestamp - seconds;
long timestamp = (System.currentTimeMillis() / 1000L);
long ptime = timestamp - seconds;
long removed = 0;
Connection connection = null;
@@ -329,6 +329,11 @@ public class PurgeCommand extends Consumer {
}
}
catch (Exception e) {
if (!ConfigHandler.serverRunning) {
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_FAILED));
return;
}
e.printStackTrace();
}
}
@@ -31,7 +31,7 @@ import net.coreprotect.utility.Color;
import net.coreprotect.utility.Util;
public class RollbackRestoreCommand {
protected static void runCommand(CommandSender player, Command command, boolean permission, String[] args, Location argLocation, int forceSeconds) {
protected static void runCommand(CommandSender player, Command command, boolean permission, String[] args, Location argLocation, long forceSeconds) {
Location lo = (argLocation != null ? argLocation : CommandHandler.parseLocation(player, args));
List<String> argUuids = new ArrayList<>();
List<String> argUsers = CommandHandler.parseUsers(args);
@@ -42,7 +42,7 @@ public class RollbackRestoreCommand {
List<Object> argExclude = CommandHandler.parseExcluded(player, args, argAction);
List<String> argExcludeUsers = CommandHandler.parseExcludedUsers(player, args);
String ts = CommandHandler.parseTimeString(args);
int rbSeconds = CommandHandler.parseTime(args);
long rbSeconds = CommandHandler.parseTime(args);
int argWid = CommandHandler.parseWorld(args, true, true);
boolean count = CommandHandler.parseCount(args);
boolean worldedit = CommandHandler.parseWorldEdit(args);
@@ -157,7 +157,7 @@ public class RollbackRestoreCommand {
int xmax = location.getBlockX() + DEFAULT_RADIUS;
int zmin = location.getBlockZ() - DEFAULT_RADIUS;
int zmax = location.getBlockZ() + DEFAULT_RADIUS;
argRadius = new Integer[] { DEFAULT_RADIUS, xmin, xmax, -1, -1, zmin, zmax, 0 };
argRadius = new Integer[] { DEFAULT_RADIUS, xmin, xmax, null, null, zmin, zmax, 0 };
}
// if (arg_radius==-2)arg_radius = -1;
@@ -284,12 +284,12 @@ public class RollbackRestoreCommand {
final List<String> rollbackusers2 = rollbackusers;
if (rbSeconds > 0) {
int unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
int seconds = unixtimestamp - rbSeconds;
long unixtimestamp = (System.currentTimeMillis() / 1000L);
long seconds = unixtimestamp - rbSeconds;
if (forceSeconds > 0) {
seconds = forceSeconds;
}
final int stime = seconds;
final long stime = seconds;
final Integer[] radius = argRadius;
try {
final CommandSender player2 = player;
@@ -310,11 +310,10 @@ public class RollbackRestoreCommand {
class BasicThread2 implements Runnable {
@Override
public void run() {
try {
try (Connection connection = Database.getConnection(false, 1000)) {
ConfigHandler.lookupThrottle.put(player.getName(), new Object[] { true, System.currentTimeMillis() });
int action = finalAction;
Location location = locationFinal;
Connection connection = Database.getConnection(false, 1000);
if (connection != null) {
Statement statement = connection.createStatement();
String baduser = "";
@@ -407,7 +406,6 @@ public class RollbackRestoreCommand {
Chat.sendMessage(player2, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.USER_NOT_FOUND, baduser));
}
statement.close();
connection.close();
}
else {
Chat.sendMessage(player2, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
@@ -11,6 +11,7 @@ import net.coreprotect.language.Phrase;
import net.coreprotect.utility.Chat;
import net.coreprotect.utility.ChatMessage;
import net.coreprotect.utility.Color;
import net.coreprotect.utility.Teleport;
import net.coreprotect.utility.Util;
public class TeleportCommand {
@@ -103,7 +104,7 @@ public class TeleportCommand {
}
// Teleport the player to a safe location
Util.performSafeTeleport(((Player) player), location, true);
Teleport.performSafeTeleport(((Player) player), location, true);
ConfigHandler.teleportThrottle.put(player.getName(), new Object[] { false, System.currentTimeMillis() });
}
@@ -11,14 +11,13 @@ import net.coreprotect.language.Phrase;
import net.coreprotect.language.Selector;
import net.coreprotect.utility.Chat;
import net.coreprotect.utility.Color;
import net.coreprotect.utility.Util;
public class UndoCommand {
protected static void runCommand(CommandSender user, Command command, boolean permission, String[] args) {
try {
if (ConfigHandler.lastRollback.get(user.getName()) != null) {
List<Object> list = ConfigHandler.lastRollback.get(user.getName());
int time = (Integer) list.get(0);
long time = (Long) list.get(0);
args = (String[]) list.get(1);
Location location = (Location) list.get(2);
for (String arg : args) {
@@ -21,13 +21,16 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import net.coreprotect.bukkit.BukkitAdapter;
import net.coreprotect.consumer.Consumer;
import net.coreprotect.consumer.Queue;
import net.coreprotect.database.Database;
import net.coreprotect.database.statement.UserStatement;
import net.coreprotect.language.Phrase;
import net.coreprotect.model.BlockGroup;
import net.coreprotect.paper.PaperAdapter;
import net.coreprotect.patch.Patch;
import net.coreprotect.spigot.SpigotAdapter;
import net.coreprotect.utility.Chat;
@@ -49,6 +52,7 @@ public class ConfigHandler extends Queue {
public static String username = "root";
public static String password = "";
public static String prefix = "co_";
public static HikariDataSource hikariDataSource = null;
public static final boolean isSpigot = Util.isSpigot();
public static final boolean isPaper = Util.isPaper();
public static volatile boolean serverRunning = false;
@@ -170,6 +174,9 @@ public class ConfigHandler extends Queue {
}
public static void loadDatabase() {
// close old pool when we reload the database, e.g. in purge command
Database.closeConnection();
if (!Config.getGlobal().MYSQL) {
try {
File tempFile = File.createTempFile("CoreProtect_" + System.currentTimeMillis(), ".tmp");
@@ -198,10 +205,38 @@ public class ConfigHandler extends Queue {
e.printStackTrace();
}
}
else {
HikariConfig config = new HikariConfig();
try {
Class.forName("com.mysql.cj.jdbc.Driver");
config.setDriverClassName("com.mysql.cj.jdbc.Driver");
}
catch (Exception e) {
config.setDriverClassName("com.mysql.jdbc.Driver");
}
if (ConfigHandler.serverRunning) {
Consumer.resetConnection = true;
config.setJdbcUrl("jdbc:mysql://" + ConfigHandler.host + ":" + ConfigHandler.port + "/" + ConfigHandler.database);
config.setUsername(ConfigHandler.username);
config.setPassword(ConfigHandler.password);
config.addDataSourceProperty("characterEncoding", "UTF-8");
config.addDataSourceProperty("connectionTimeout", "10000");
/* https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration */
/* https://cdn.oreillystatic.com/en/assets/1/event/21/Connector_J%20Performance%20Gems%20Presentation.pdf */
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
config.addDataSourceProperty("useServerPrepStmts", "true");
config.addDataSourceProperty("useLocalSessionState", "true");
config.addDataSourceProperty("rewriteBatchedStatements", "true");
config.addDataSourceProperty("cacheServerConfiguration", "true");
config.addDataSourceProperty("maintainTimeStats", "false");
/* Disable SSL to suppress the unverified server identity warning */
config.addDataSourceProperty("allowPublicKeyRetrieval", "true");
config.addDataSourceProperty("useSSL", "false");
ConfigHandler.hikariDataSource = new HikariDataSource(config);
}
Database.createDatabaseTables(ConfigHandler.prefix, false);
}
@@ -361,12 +396,18 @@ public class ConfigHandler extends Queue {
try {
BukkitAdapter.loadAdapter();
SpigotAdapter.loadAdapter();
PaperAdapter.loadAdapter();
BlockGroup.initialize();
ConfigHandler.loadConfig(); // Load (or create) the configuration file.
ConfigHandler.loadDatabase(); // Initialize MySQL and create tables if necessary.
Connection connection = Database.getConnection(true, 0);
}
catch (Exception e) {
e.printStackTrace();
}
try (Connection connection = Database.getConnection(true, 0)) {
Statement statement = connection.createStatement();
ConfigHandler.checkPlayers(connection);
@@ -394,7 +435,6 @@ public class ConfigHandler extends Queue {
}
statement.close();
connection.close();
return validVersion && databaseLock;
}
@@ -17,12 +17,11 @@ import net.coreprotect.consumer.process.Process;
public class Consumer extends Process implements Runnable, Thread.UncaughtExceptionHandler {
public static volatile boolean resetConnection = false;
private static Thread consumerThread = null;
public static volatile int currentConsumer = 0;
public static volatile boolean isPaused = false;
public static volatile boolean transacting = false;
public static volatile boolean interrupt = false;
private static volatile boolean running = false;
protected static volatile boolean pausedSuccess = false;
public static ConcurrentHashMap<Integer, ArrayList<Object[]>> consumer = new ConcurrentHashMap<>(4, 0.75f, 2);
@@ -96,19 +95,13 @@ public class Consumer extends Process implements Runnable, Thread.UncaughtExcept
}
public static boolean isRunning() {
return running;
return consumerThread != null && consumerThread.isAlive();
}
private static void pauseConsumer(int process_id) {
try {
while ((ConfigHandler.serverRunning || ConfigHandler.converterRunning) && (Consumer.isPaused || ConfigHandler.purgeRunning || Consumer.consumer_id.get(process_id)[1] == 1)) {
pausedSuccess = true;
if (Consumer.isPaused || ConfigHandler.purgeRunning) {
if (connection != null) {
connection.close();
connection = null;
}
}
Thread.sleep(100);
}
}
@@ -120,7 +113,6 @@ public class Consumer extends Process implements Runnable, Thread.UncaughtExcept
@Override
public void run() {
running = true;
boolean lastRun = false;
while (ConfigHandler.serverRunning || ConfigHandler.converterRunning || !lastRun) {
@@ -145,20 +137,17 @@ public class Consumer extends Process implements Runnable, Thread.UncaughtExcept
errorDelay();
}
}
running = false;
}
@Override
public void uncaughtException(Thread thread, Throwable e) {
running = false;
e.printStackTrace();
Bukkit.getPluginManager().disablePlugin(CoreProtect.getInstance());
}
public static void startConsumer() {
if (running == false) {
Thread consumerThread = new Thread(new Consumer());
if (!isRunning()) {
consumerThread = new Thread(new Consumer());
consumerThread.setUncaughtExceptionHandler(new Consumer());
consumerThread.start();
}
@@ -8,7 +8,7 @@ import org.bukkit.entity.EntityType;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.database.statement.EntityStatement;
import net.coreprotect.utility.Util;
import net.coreprotect.utility.entity.EntityUtil;
class EntitySpawnProcess {
@@ -18,7 +18,7 @@ class EntitySpawnProcess {
EntityType type = (EntityType) ((Object[]) object)[1];
String query = "SELECT data FROM " + ConfigHandler.prefix + "entity WHERE rowid='" + rowId + "' LIMIT 0, 1";
List<Object> data = EntityStatement.getData(statement, block, query);
Util.spawnEntity(block, type, data);
EntityUtil.spawnEntity(block, type, data);
}
}
}
@@ -2,14 +2,14 @@ package net.coreprotect.consumer.process;
import org.bukkit.block.BlockState;
import net.coreprotect.utility.Util;
import net.coreprotect.utility.entity.HangingUtil;
class HangingRemoveProcess {
static void process(Object object, int delay) {
if (object instanceof BlockState) {
BlockState block = (BlockState) object;
Util.removeHanging(block, delay);
HangingUtil.removeHanging(block, delay);
}
}
}
@@ -3,14 +3,14 @@ package net.coreprotect.consumer.process;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import net.coreprotect.utility.Util;
import net.coreprotect.utility.entity.HangingUtil;
class HangingSpawnProcess {
static void process(Object object, Material type, int data, int delay) {
if (object instanceof BlockState) {
BlockState block = (BlockState) object;
Util.spawnHanging(block, type, data, delay);
HangingUtil.spawnHanging(block, type, data, delay);
}
}
}
@@ -10,13 +10,18 @@ import net.coreprotect.database.logger.ChatLogger;
class PlayerChatProcess {
static void process(PreparedStatement preparedStmt, int batchCount, int processId, int id, Object[] object, String user) {
if (object[1] instanceof Location) {
static void process(PreparedStatement preparedStmt, int batchCount, int processId, int id, Object object, String user) {
if (!(object instanceof Object[])) {
return;
}
Object[] data = (Object[]) object;
if (data[1] instanceof Location) {
Map<Integer, String> strings = Consumer.consumerStrings.get(processId);
if (strings.get(id) != null) {
String message = strings.get(id);
Long timestamp = (Long) object[0];
Location location = (Location) object[1];
Long timestamp = (Long) data[0];
Location location = (Location) data[1];
ChatLogger.log(preparedStmt, batchCount, timestamp, location, user, message);
strings.remove(id);
}
@@ -10,13 +10,18 @@ import net.coreprotect.database.logger.CommandLogger;
class PlayerCommandProcess {
static void process(PreparedStatement preparedStmt, int batchCount, int processId, int id, Object[] object, String user) {
if (object[1] instanceof Location) {
static void process(PreparedStatement preparedStmt, int batchCount, int processId, int id, Object object, String user) {
if (!(object instanceof Object[])) {
return;
}
Object[] data = (Object[]) object;
if (data[1] instanceof Location) {
Map<Integer, String> strings = Consumer.consumerStrings.get(processId);
if (strings.get(id) != null) {
String message = strings.get(id);
Long timestamp = (Long) object[0];
Location location = (Location) object[1];
Long timestamp = (Long) data[0];
Location location = (Location) data[1];
CommandLogger.log(preparedStmt, batchCount, timestamp, location, user, message);
strings.remove(id);
}
@@ -45,36 +45,13 @@ public class Process {
public static final int BLOCKDATA_INSERT = 25;
public static final int ITEM_TRANSACTION = 26;
protected static Connection connection = null;
public static int lastLockUpdate = 0;
private static int lastConnection = 0;
private static volatile int currentConsumerSize = 0;
public static int getCurrentConsumerSize() {
return currentConsumerSize;
}
private static void validateConnection(boolean lastRun) {
try {
if (connection != null) {
int timeSinceLastConnection = ((int) (System.currentTimeMillis() / 1000L)) - lastConnection;
if ((!lastRun && timeSinceLastConnection > 900) || !connection.isValid(5) || Consumer.resetConnection) {
connection.close();
connection = null;
Consumer.resetConnection = false;
}
}
if (connection == null && ConfigHandler.serverRunning) {
connection = Database.getConnection(false, 500);
lastConnection = (int) (System.currentTimeMillis() / 1000L);
}
}
catch (Exception e) {
e.printStackTrace();
}
}
protected static void updateLockTable(Statement statement, int locked) {
try {
int unixTimestamp = (int) (System.currentTimeMillis() / 1000L);
@@ -90,9 +67,7 @@ public class Process {
}
protected static void processConsumer(int processId, boolean lastRun) {
try {
// Connection
validateConnection(lastRun);
try (Connection connection = Database.getConnection(false, 500)) {
if (connection == null) {
return;
}
@@ -195,10 +170,10 @@ public class Process {
SkullUpdateProcess.process(statement, object, forceData);
break;
case Process.PLAYER_CHAT:
PlayerChatProcess.process(preparedStmtChat, i, processId, id, (Object[]) object, user);
PlayerChatProcess.process(preparedStmtChat, i, processId, id, object, user);
break;
case Process.PLAYER_COMMAND:
PlayerCommandProcess.process(preparedStmtCommand, i, processId, id, (Object[]) object, user);
PlayerCommandProcess.process(preparedStmtCommand, i, processId, id, object, user);
break;
case Process.PLAYER_LOGIN:
PlayerLoginProcess.process(connection, preparedStmtSession, i, processId, id, object, blockData, replaceData, forceData, user);
@@ -243,7 +218,6 @@ public class Process {
for (int index = (i - 1); index >= 0; index--) {
consumerData.remove(index);
}
connection = null;
currentConsumerSize = 0;
Consumer.isPaused = false;
return;
@@ -288,11 +262,6 @@ public class Process {
users.clear();
consumerObject.clear();
consumerData.clear();
if (lastRun) {
connection.close();
connection = null;
}
}
catch (Exception e) {
e.printStackTrace();
@@ -24,7 +24,7 @@ import net.coreprotect.utility.Util;
public class ContainerRollback extends Queue {
public static void performContainerRollbackRestore(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, String timeString, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, final Location location, Integer[] radius, int checkTime, boolean restrictWorld, boolean lookup, boolean verbose, final int rollbackType) {
public static void performContainerRollbackRestore(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, String timeString, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, final Location location, Integer[] radius, long checkTime, boolean restrictWorld, boolean lookup, boolean verbose, final int rollbackType) {
try {
long startTime = System.currentTimeMillis();
@@ -138,15 +138,7 @@ public class Database extends Queue {
}
if (Config.getGlobal().MYSQL) {
try {
/* Using useServerPrepStmts, cachePrepStmts, and rewriteBatchedStatements per https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration */
String database = "jdbc:mysql://" + ConfigHandler.host + ":" + ConfigHandler.port + "/" + ConfigHandler.database + "?useUnicode=true&characterEncoding=utf-8&connectTimeout=10000&useSSL=false&allowPublicKeyRetrieval=true&useCursorFetch=true&useLocalSessionState=true&rewriteBatchedStatements=true&maintainTimeStats=false";
connection = DriverManager.getConnection(database, ConfigHandler.username, ConfigHandler.password);
/* Recommended implementation per https://dev.mysql.com/doc/refman/5.0/en/charset-applications.html & https://dev.mysql.com/doc/refman/5.0/en/charset-syntax.html */
Statement statement = connection.createStatement();
statement.executeUpdate("SET NAMES 'utf8mb4'"); // COLLATE 'utf8mb4mb4_general_ci'
statement.close();
connection = ConfigHandler.hikariDataSource.getConnection();
ConfigHandler.databaseReachable = true;
}
catch (Exception e) {
@@ -183,6 +175,18 @@ public class Database extends Queue {
return connection;
}
public static void closeConnection() {
try {
if (ConfigHandler.hikariDataSource != null) {
ConfigHandler.hikariDataSource.close();
ConfigHandler.hikariDataSource = null;
}
}
catch (Exception e) {
e.printStackTrace();
}
}
public static void performUpdate(Statement statement, long id, int action, int table) {
try {
int rolledBack = 1;
@@ -316,8 +320,7 @@ public class Database extends Queue {
if (Config.getGlobal().MYSQL) {
boolean success = false;
try {
Connection connection = Database.getConnection(true, true, true, 0);
try (Connection connection = Database.getConnection(true, true, true, 0)) {
if (connection != null) {
String index = "";
Statement statement = connection.createStatement();
@@ -357,7 +360,6 @@ public class Database extends Queue {
initializeTables(prefix, statement);
}
statement.close();
connection.close();
success = true;
}
}
@@ -369,8 +371,7 @@ public class Database extends Queue {
}
}
if (!Config.getGlobal().MYSQL) {
try {
Connection connection = Database.getConnection(true, 0);
try (Connection connection = Database.getConnection(true, 0)) {
Statement statement = connection.createStatement();
List<String> tableData = new ArrayList<>();
List<String> indexData = new ArrayList<>();
@@ -553,7 +554,6 @@ public class Database extends Queue {
initializeTables(prefix, statement);
}
statement.close();
connection.close();
}
catch (Exception e) {
e.printStackTrace();
@@ -75,7 +75,7 @@ public class Lookup extends Queue {
return newList;
}
public static int countLookupRows(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, int checkTime, boolean restrictWorld, boolean lookup) {
public static int countLookupRows(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, long checkTime, boolean restrictWorld, boolean lookup) {
int rows = 0;
try {
@@ -484,15 +484,15 @@ public class Lookup extends Queue {
}
if (radius != null) {
int xmin = radius[1];
int xmax = radius[2];
int ymin = radius[3];
int ymax = radius[4];
int zmin = radius[5];
int zmax = radius[6];
Integer xmin = radius[1];
Integer xmax = radius[2];
Integer ymin = radius[3];
Integer ymax = radius[4];
Integer zmin = radius[5];
Integer zmax = radius[6];
String queryY = "";
if (ymin > -1 && ymax > -1) {
if (ymin != null && ymax != null) {
queryY = " y >= '" + ymin + "' AND y <= '" + ymax + "' AND";
}
@@ -48,6 +48,7 @@ import org.bukkit.block.data.type.PistonHead;
import org.bukkit.block.data.type.RedstoneWire;
import org.bukkit.block.data.type.Snow;
import org.bukkit.block.data.type.Stairs;
import org.bukkit.block.data.type.TechnicalPiston;
import org.bukkit.block.data.type.TrapDoor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.ArmorStand;
@@ -83,6 +84,7 @@ import net.coreprotect.thread.CacheHandler;
import net.coreprotect.utility.Chat;
import net.coreprotect.utility.ChestTool;
import net.coreprotect.utility.Color;
import net.coreprotect.utility.Teleport;
import net.coreprotect.utility.Util;
public class Rollback extends Queue {
@@ -685,6 +687,12 @@ public class Rollback extends Queue {
pistonBlock.setBlockData(piston, false);
}
}
else if (rowType == Material.MOVING_PISTON && blockData instanceof TechnicalPiston && !(blockData instanceof PistonHead)) {
TechnicalPiston technicalPiston = (TechnicalPiston) blockData;
rowType = (technicalPiston.getType() == org.bukkit.block.data.type.TechnicalPiston.Type.STICKY ? Material.STICKY_PISTON : Material.PISTON);
blockData = rowType.createBlockData();
((Piston) blockData).setFacing(technicalPiston.getFacing());
}
if ((rowType == Material.AIR) && ((BukkitAdapter.ADAPTER.isItemFrame(oldTypeMaterial)) || (oldTypeMaterial == Material.PAINTING))) {
int delay = Util.getHangingDelay(hangingDelay, rowWorldId, rowX, rowY, rowZ);
@@ -1089,6 +1097,7 @@ public class Rollback extends Queue {
if (blockData instanceof MultipleFacing || BukkitAdapter.ADAPTER.isWall(blockData) || blockData instanceof Snow || blockData instanceof Stairs || blockData instanceof RedstoneWire || blockData instanceof Chest) {
physics = !(blockData instanceof Snow) || block.getY() <= BukkitAdapter.ADAPTER.getMinHeight(block.getWorld()) || (block.getWorld().getBlockAt(block.getX(), block.getY() - 1, block.getZ()).getType().equals(Material.GRASS_BLOCK));
}
Util.setTypeAndData(block, rowType, blockData, physics);
if (countBlock) {
blockCount1++;
@@ -1219,7 +1228,7 @@ public class Rollback extends Queue {
int chunkZ = playerLocation.getBlockZ() >> 4;
if (chunkX == finalChunkX && chunkZ == finalChunkZ) {
Util.performSafeTeleport(player, playerLocation, false);
Teleport.performSafeTeleport(player, playerLocation, false);
}
}
}
@@ -7,8 +7,11 @@ import java.util.Locale;
import org.bukkit.Location;
import org.bukkit.Material;
import net.coreprotect.CoreProtect;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.database.statement.BlockStatement;
import net.coreprotect.database.statement.UserStatement;
import net.coreprotect.event.CoreProtectPreLogEvent;
import net.coreprotect.thread.CacheHandler;
import net.coreprotect.utility.Util;
@@ -40,13 +43,16 @@ public class BlockBreakLogger {
blockData = blockData.replaceFirst("has_book=true", "has_book=false");
}
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
int wid = Util.getWorldId(location.getWorld().getName());
int time = (int) (System.currentTimeMillis() / 1000L);
int x = location.getBlockX();
int y = location.getBlockY();
int z = location.getBlockZ();
CacheHandler.breakCache.put("" + x + "." + y + "." + z + "." + wid + "", new Object[] { time, user, type });
int userId = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
CacheHandler.breakCache.put("" + x + "." + y + "." + z + "." + wid + "", new Object[] { time, event.getUser(), type });
BlockStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, type, data, meta, blockData, 0, 0);
}
catch (Exception e) {
@@ -12,9 +12,12 @@ import org.bukkit.block.data.type.Bed;
import org.bukkit.block.data.type.Door;
import org.bukkit.block.data.type.Door.Hinge;
import net.coreprotect.CoreProtect;
import net.coreprotect.bukkit.BukkitAdapter;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.database.statement.BlockStatement;
import net.coreprotect.database.statement.UserStatement;
import net.coreprotect.event.CoreProtectPreLogEvent;
import net.coreprotect.model.BlockGroup;
import net.coreprotect.thread.CacheHandler;
import net.coreprotect.utility.Util;
@@ -55,7 +58,11 @@ public class BlockPlaceLogger {
if (type.equals(Material.AIR) || type.equals(Material.CAVE_AIR)) {
return;
}
int userId = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
int wid = Util.getWorldId(block.getWorld().getName());
int time = (int) (System.currentTimeMillis() / 1000L);
int x = block.getX();
@@ -68,8 +75,8 @@ public class BlockPlaceLogger {
int doubledata = data;
int logdouble = 0;
if (user.length() > 0) {
CacheHandler.lookupCache.put("" + x + "." + y + "." + z + "." + wid + "", new Object[] { time, user, type });
if (event.getUser().length() > 0) {
CacheHandler.lookupCache.put("" + x + "." + y + "." + z + "." + wid + "", new Object[] { time, event.getUser(), type });
}
String doubleBlockData = null;
@@ -5,8 +5,11 @@ import java.util.Locale;
import org.bukkit.Location;
import net.coreprotect.CoreProtect;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.database.statement.CommandStatement;
import net.coreprotect.database.statement.UserStatement;
import net.coreprotect.event.CoreProtectPreLogEvent;
import net.coreprotect.utility.Util;
public class CommandLogger {
@@ -23,11 +26,15 @@ public class CommandLogger {
if (ConfigHandler.blacklist.get(((message + " ").split(" "))[0].toLowerCase(Locale.ROOT)) != null) {
return;
}
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
int wid = Util.getWorldId(location.getWorld().getName());
int x = location.getBlockX();
int y = location.getBlockY();
int z = location.getBlockZ();
int wid = Util.getWorldId(location.getWorld().getName());
int userId = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
CommandStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, message);
}
catch (Exception e) {
@@ -13,9 +13,12 @@ import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import net.coreprotect.CoreProtect;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.consumer.Queue;
import net.coreprotect.database.statement.ContainerStatement;
import net.coreprotect.database.statement.UserStatement;
import net.coreprotect.event.CoreProtectPreLogEvent;
import net.coreprotect.utility.Util;
import net.coreprotect.utility.serialize.ItemMetaHandler;
@@ -161,8 +164,11 @@ public class ContainerLogger extends Queue {
metadata = null;
}
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
int wid = Util.getWorldId(location.getWorld().getName());
int userid = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
int time = (int) (System.currentTimeMillis() / 1000L);
int x = location.getBlockX();
int y = location.getBlockY();
@@ -170,7 +176,7 @@ public class ContainerLogger extends Queue {
int typeId = Util.getBlockId(item.getType().name(), true);
int data = item.getDurability();
int amount = item.getAmount();
ContainerStatement.insert(preparedStmt, batchCount, time, userid, wid, x, y, z, typeId, data, amount, metadata, action, 0);
ContainerStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, typeId, data, amount, metadata, action, 0);
}
}
slot++;
@@ -7,9 +7,12 @@ import java.util.Locale;
import org.bukkit.block.BlockState;
import net.coreprotect.CoreProtect;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.database.statement.BlockStatement;
import net.coreprotect.database.statement.EntityStatement;
import net.coreprotect.database.statement.UserStatement;
import net.coreprotect.event.CoreProtectPreLogEvent;
import net.coreprotect.utility.Util;
public class EntityKillLogger {
@@ -23,18 +26,22 @@ public class EntityKillLogger {
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
return;
}
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
int wid = Util.getWorldId(block.getWorld().getName());
int time = (int) (System.currentTimeMillis() / 1000L);
int x = block.getX();
int y = block.getY();
int z = block.getZ();
int userid = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
EntityStatement.insert(preparedStmt2, time, data);
ResultSet keys = preparedStmt2.getGeneratedKeys();
keys.next();
int entity_key = keys.getInt(1);
keys.close();
BlockStatement.insert(preparedStmt, batchCount, time, userid, wid, x, y, z, type, entity_key, null, null, 3, 0);
BlockStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, type, entity_key, null, null, 3, 0);
}
catch (Exception e) {
e.printStackTrace();
@@ -9,8 +9,11 @@ import java.util.Map;
import org.bukkit.Location;
import org.bukkit.inventory.ItemStack;
import net.coreprotect.CoreProtect;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.database.statement.ItemStatement;
import net.coreprotect.database.statement.UserStatement;
import net.coreprotect.event.CoreProtectPreLogEvent;
import net.coreprotect.utility.Util;
import net.coreprotect.utility.serialize.ItemMetaHandler;
@@ -65,15 +68,18 @@ public class ItemLogger {
data = null;
}
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
int wid = Util.getWorldId(location.getWorld().getName());
int userid = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
int time = (int) (System.currentTimeMillis() / 1000L);
int x = location.getBlockX();
int y = location.getBlockY();
int z = location.getBlockZ();
int typeId = Util.getBlockId(item.getType().name(), true);
int amount = item.getAmount();
ItemStatement.insert(preparedStmt, batchCount, time, userid, wid, x, y, z, typeId, data, amount, action);
ItemStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, typeId, data, amount, action);
}
}
}
@@ -6,8 +6,11 @@ import java.util.Locale;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import net.coreprotect.CoreProtect;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.database.statement.BlockStatement;
import net.coreprotect.database.statement.UserStatement;
import net.coreprotect.event.CoreProtectPreLogEvent;
import net.coreprotect.utility.Util;
public class PlayerInteractLogger {
@@ -22,8 +25,12 @@ public class PlayerInteractLogger {
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null || Util.getType(type).equals(Material.AIR) || Util.getType(type).equals(Material.CAVE_AIR)) {
return;
}
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
int wid = Util.getWorldId(block.getWorld().getName());
int userId = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
int time = (int) (System.currentTimeMillis() / 1000L);
int x = block.getX();
int y = block.getY();
@@ -5,9 +5,11 @@ import java.util.Locale;
import org.bukkit.block.BlockState;
import net.coreprotect.CoreProtect;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.database.statement.BlockStatement;
import net.coreprotect.database.statement.UserStatement;
import net.coreprotect.event.CoreProtectPreLogEvent;
import net.coreprotect.utility.Util;
public class PlayerKillLogger {
@@ -21,16 +23,17 @@ public class PlayerKillLogger {
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
return;
}
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
int playerId = ConfigHandler.playerIdCache.get(player.toLowerCase(Locale.ROOT));
int wid = Util.getWorldId(block.getWorld().getName());
int time = (int) (System.currentTimeMillis() / 1000L);
int x = block.getX();
int y = block.getY();
int z = block.getZ();
int userId = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
if (ConfigHandler.playerIdCache.get(player.toLowerCase(Locale.ROOT)) == null) {
UserStatement.loadId(preparedStmt.getConnection(), player, null);
}
int playerId = ConfigHandler.playerIdCache.get(player.toLowerCase(Locale.ROOT));
BlockStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, 0, playerId, null, null, 3, 0);
}
catch (Exception e) {
@@ -5,8 +5,11 @@ import java.util.Locale;
import org.bukkit.Location;
import net.coreprotect.CoreProtect;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.database.statement.SignStatement;
import net.coreprotect.database.statement.UserStatement;
import net.coreprotect.event.CoreProtectPreLogEvent;
import net.coreprotect.utility.Util;
public class SignTextLogger {
@@ -20,7 +23,11 @@ public class SignTextLogger {
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
return;
}
int userId = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
int wid = Util.getWorldId(location.getWorld().getName());
int time = (int) (System.currentTimeMillis() / 1000L) - timeOffset;
int x = location.getBlockX();
@@ -12,7 +12,6 @@ import net.coreprotect.config.ConfigHandler;
import net.coreprotect.database.statement.UserStatement;
import net.coreprotect.language.Phrase;
import net.coreprotect.language.Selector;
import net.coreprotect.utility.Chat;
import net.coreprotect.utility.Color;
import net.coreprotect.utility.Util;
@@ -45,9 +44,9 @@ public class BlockLookup {
int x = block.getX();
int y = block.getY();
int z = block.getZ();
int time = (int) (System.currentTimeMillis() / 1000L);
long time = (System.currentTimeMillis() / 1000L);
int worldId = Util.getWorldId(block.getWorld().getName());
int checkTime = 0;
long checkTime = 0;
int count = 0;
int rowMax = page * limit;
int page_start = rowMax - limit;
@@ -75,7 +74,7 @@ public class BlockLookup {
int resultAction = results.getInt("action");
int resultType = results.getInt("type");
int resultData = results.getInt("data");
int resultTime = results.getInt("time");
long resultTime = results.getLong("time");
int resultRolledBack = results.getInt("rolled_back");
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
@@ -18,7 +18,7 @@ public class BlockLookupAPI {
public static List<String[]> performLookup(Block block, int offset) {
List<String[]> result = new ArrayList<>();
try {
try (Connection connection = Database.getConnection(false, 1000)) {
if (block == null) {
return result;
}
@@ -33,7 +33,6 @@ public class BlockLookupAPI {
checkTime = time - offset;
}
Connection connection = Database.getConnection(false, 1000);
if (connection == null) {
return result;
}
@@ -62,7 +61,6 @@ public class BlockLookupAPI {
}
results.close();
statement.close();
connection.close();
}
catch (Exception e) {
e.printStackTrace();
@@ -12,7 +12,6 @@ import net.coreprotect.config.ConfigHandler;
import net.coreprotect.database.statement.UserStatement;
import net.coreprotect.language.Phrase;
import net.coreprotect.language.Selector;
import net.coreprotect.utility.Chat;
import net.coreprotect.utility.Color;
import net.coreprotect.utility.Util;
@@ -48,7 +47,7 @@ public class ChestTransactionLookup {
int x2 = (int) Math.ceil(l.getX());
int y2 = (int) Math.ceil(l.getY());
int z2 = (int) Math.ceil(l.getZ());
int time = (int) (System.currentTimeMillis() / 1000L);
long time = (System.currentTimeMillis() / 1000L);
int worldId = Util.getWorldId(l.getWorld().getName());
int count = 0;
int rowMax = page * limit;
@@ -79,7 +78,7 @@ public class ChestTransactionLookup {
int resultAction = results.getInt("action");
int resultType = results.getInt("type");
int resultData = results.getInt("data");
int resultTime = results.getInt("time");
long resultTime = results.getLong("time");
int resultAmount = results.getInt("amount");
int resultRolledBack = results.getInt("rolled_back");
@@ -12,7 +12,6 @@ import net.coreprotect.config.ConfigHandler;
import net.coreprotect.database.statement.UserStatement;
import net.coreprotect.language.Phrase;
import net.coreprotect.language.Selector;
import net.coreprotect.utility.Chat;
import net.coreprotect.utility.Color;
import net.coreprotect.utility.Util;
@@ -73,7 +72,7 @@ public class InteractionLookup {
int resultAction = results.getInt("action");
int resultType = results.getInt("type");
int resultData = results.getInt("data");
int resultTime = results.getInt("time");
long resultTime = results.getLong("time");
int resultRolledBack = results.getInt("rolled_back");
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
@@ -44,7 +44,7 @@ public class SignMessageLookup {
int x = l.getBlockX();
int y = l.getBlockY();
int z = l.getBlockZ();
int time = (int) (System.currentTimeMillis() / 1000L);
long time = (System.currentTimeMillis() / 1000L);
int worldId = Util.getWorldId(l.getWorld().getName());
int count = 0;
int rowMax = page * limit;
@@ -64,7 +64,7 @@ public class SignMessageLookup {
results = statement.executeQuery(query);
while (results.next()) {
int resultTime = results.getInt("time");
long resultTime = results.getLong("time");
int resultUserId = results.getInt("user");
String line1 = results.getString("line_1");
String line2 = results.getString("line_2");
@@ -3,6 +3,7 @@ package net.coreprotect.database.statement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Locale;
@@ -36,6 +37,14 @@ public class UserStatement {
return id;
}
public static int getId(PreparedStatement preparedStatement, String user, boolean load) throws SQLException {
if (load && !ConfigHandler.playerIdCache.containsKey(user.toLowerCase(Locale.ROOT))) {
UserStatement.loadId(preparedStatement.getConnection(), user, null);
}
return ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
}
public static int loadId(Connection connection, String user, String uuid) {
// generate if doesn't exist
int id = -1;
@@ -0,0 +1,37 @@
package net.coreprotect.event;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class CoreProtectPreLogEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private String user;
public CoreProtectPreLogEvent(String user) {
super(true); // async
this.user = user;
}
public String getUser() {
return user;
}
public void setUser(String newUser) {
if (newUser == null || newUser.isEmpty()) {
throw new IllegalArgumentException("Invalid user");
}
this.user = newUser;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}
@@ -45,6 +45,7 @@ import net.coreprotect.listener.player.SignChangeListener;
import net.coreprotect.listener.world.LeavesDecayListener;
import net.coreprotect.listener.world.PortalCreateListener;
import net.coreprotect.listener.world.StructureGrowListener;
import net.coreprotect.paper.listener.PaperChatListener;
public final class ListenerHandler {
@@ -85,7 +86,6 @@ public final class ListenerHandler {
pluginManager.registerEvents(new ArmorStandManipulateListener(), plugin);
pluginManager.registerEvents(new PlayerBucketEmptyListener(), plugin);
pluginManager.registerEvents(new PlayerBucketFillListener(), plugin);
pluginManager.registerEvents(new PlayerChatListener(), plugin);
pluginManager.registerEvents(new PlayerCommandListener(), plugin);
pluginManager.registerEvents(new PlayerDeathListener(), plugin);
pluginManager.registerEvents(new PlayerDropItemListener(), plugin);
@@ -101,6 +101,16 @@ public final class ListenerHandler {
pluginManager.registerEvents(new StructureGrowListener(), plugin);
pluginManager.registerEvents(new LeavesDecayListener(), plugin);
pluginManager.registerEvents(new PortalCreateListener(), 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);
}
}
}
@@ -204,7 +204,7 @@ public final class BlockBreakListener extends Queue implements Listener {
}
}
if (!log) {
if (type.equals(Material.MOVING_PISTON)) {// broke a piston extension
if (type.equals(Material.PISTON_HEAD)) {// broke a piston extension
if (scanType.equals(Material.STICKY_PISTON) || scanType.equals(Material.PISTON)) { // adjacent piston
log = true;
}
@@ -218,7 +218,7 @@ public final class BlockBreakListener extends Queue implements Listener {
}
else {
// determine if side block is attached
if (scanType.equals(Material.MOVING_PISTON)) {
if (scanType.equals(Material.PISTON_HEAD)) {
if (!type.equals(Material.STICKY_PISTON) && !type.equals(Material.PISTON)) {
log = false;
}
@@ -9,6 +9,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockSpreadEvent;
import net.coreprotect.bukkit.BukkitAdapter;
import net.coreprotect.config.Config;
import net.coreprotect.consumer.Queue;
import net.coreprotect.model.BlockGroup;
@@ -59,7 +60,7 @@ public final class BlockSpreadListener extends Queue implements Listener {
Location below = sourceBlock.getLocation().clone();
below.setY(below.getY() - 2);
for (int i = 0; i < 2; i++) {
if (below.getY() >= 0) {
if (below.getY() >= BukkitAdapter.ADAPTER.getMinHeight(block.getWorld())) {
Block belowBlock = below.getBlock();
if (belowBlock.getType().equals(Material.BAMBOO)) {
Queue.queueBlockPlaceDelayed("#bamboo", belowBlock.getLocation(), belowBlock.getType(), null, belowBlock.getState(), 0);
@@ -69,8 +70,8 @@ public final class BlockSpreadListener extends Queue implements Listener {
}
below = null;
Queue.queueBlockPlaceDelayed("#bamboo", sourceBlock.getLocation(), sourceBlock.getType(), null, sourceBlock.getState(), 0);
Queue.queueBlockPlaceDelayed("#bamboo", block.getLocation(), block.getType(), null, block.getState(), 0);
Queue.queueBlockPlaceDelayed("#bamboo", sourceBlock.getLocation(), type, null, sourceBlock.getState(), 0);
Queue.queueBlockPlaceDelayed("#bamboo", block.getLocation(), type, null, block.getState(), 0);
}
}
}
@@ -23,37 +23,44 @@ public final class EntityDamageByBlockListener extends Queue implements Listener
@EventHandler(priority = EventPriority.MONITOR)
protected void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
Block damager = event.getDamager();
if (event.getEntity() instanceof ItemFrame || event.getEntity() instanceof ArmorStand || event.getEntity() instanceof EnderCrystal) {
if (damager != null && damager.getType() != Material.MAGMA_BLOCK) {
final Entity entity = event.getEntity();
Block block = entity.getLocation().getBlock();
String user = "#" + damager.getType().name().toLowerCase(Locale.ROOT);
if (user.contains("tnt")) {
user = "#tnt";
}
Entity entity = event.getEntity();
if (!(entity instanceof ItemFrame) && !(entity instanceof ArmorStand) && !(entity instanceof EnderCrystal)) {
return;
}
if (!event.isCancelled() && Config.getConfig(entity.getWorld()).BLOCK_BREAK) {
if (entity instanceof ItemFrame) {
Material frameType = BukkitAdapter.ADAPTER.getFrameType(entity);
ItemFrame frame = (ItemFrame) event.getEntity();
int data = 0;
if (frame.getItem() != null) {
data = Util.getBlockId(frame.getItem().getType());
}
Queue.queueBlockBreak(user, block.getState(), frameType, null, data);
Queue.queueBlockPlace(user, block.getState(), frameType, null, frameType, -1, 0, null);
}
else if (entity instanceof ArmorStand) {
Database.containerBreakCheck(user, Material.ARMOR_STAND, entity, null, block.getLocation());
Queue.queueBlockBreak(user, block.getState(), Material.ARMOR_STAND, null, (int) entity.getLocation().getYaw());
}
else if (entity instanceof EnderCrystal) {
EnderCrystal crystal = (EnderCrystal) event.getEntity();
Queue.queueBlockBreak(user, block.getState(), Material.END_CRYSTAL, null, crystal.isShowingBottom() ? 1 : 0);
}
}
Block damager = event.getDamager();
if (damager == null || damager.getType() == Material.MAGMA_BLOCK) {
return;
}
if (event.isCancelled() || !Config.getConfig(entity.getWorld()).BLOCK_BREAK) {
return;
}
Block block = entity.getLocation().getBlock();
String user = "#" + damager.getType().name().toLowerCase(Locale.ROOT);
if (user.contains("tnt")) {
user = "#tnt";
}
if (entity instanceof ItemFrame) {
Material frameType = BukkitAdapter.ADAPTER.getFrameType(entity);
ItemFrame frame = (ItemFrame) event.getEntity();
int data = 0;
if (frame.getItem() != null) {
data = Util.getBlockId(frame.getItem().getType());
}
Queue.queueBlockBreak(user, block.getState(), frameType, null, data);
Queue.queueBlockPlace(user, block.getState(), frameType, null, frameType, -1, 0, null);
}
else if (entity instanceof ArmorStand) {
Database.containerBreakCheck(user, Material.ARMOR_STAND, entity, null, block.getLocation());
Queue.queueBlockBreak(user, block.getState(), Material.ARMOR_STAND, null, (int) entity.getLocation().getYaw());
}
else if (entity instanceof EnderCrystal) {
EnderCrystal crystal = (EnderCrystal) event.getEntity();
Queue.queueBlockBreak(user, block.getState(), Material.END_CRYSTAL, null, crystal.isShowingBottom() ? 1 : 0);
}
}
@@ -33,8 +33,7 @@ public final class HangingBreakByEntityListener extends Queue implements Listene
class BasicThread implements Runnable {
@Override
public void run() {
try {
Connection connection = Database.getConnection(true);
try (Connection connection = Database.getConnection(true)) {
if (connection != null) {
Statement statement = connection.createStatement();
String blockData = BlockLookup.performLookup(null, statement, block, player, 0, 1, 7);
@@ -49,7 +48,6 @@ public final class HangingBreakByEntityListener extends Queue implements Listene
}
statement.close();
connection.close();
}
else {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
@@ -53,25 +53,24 @@ public final class ArmorStandManipulateListener extends Queue implements Listene
class BasicThread implements Runnable {
@Override
public void run() {
try {
if (ConfigHandler.converterRunning) {
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
if (ConfigHandler.converterRunning) {
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
return;
}
if (ConfigHandler.purgeRunning) {
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
return;
}
if (ConfigHandler.lookupThrottle.get(finalPlayer.getName()) != null) {
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(finalPlayer.getName());
if ((boolean) lookupThrottle[0] || ((System.currentTimeMillis() - (long) lookupThrottle[1])) < 100) {
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
return;
}
if (ConfigHandler.purgeRunning) {
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
return;
}
if (ConfigHandler.lookupThrottle.get(finalPlayer.getName()) != null) {
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(finalPlayer.getName());
if ((boolean) lookupThrottle[0] || ((System.currentTimeMillis() - (long) lookupThrottle[1])) < 100) {
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
return;
}
}
ConfigHandler.lookupThrottle.put(finalPlayer.getName(), new Object[] { true, System.currentTimeMillis() });
}
ConfigHandler.lookupThrottle.put(finalPlayer.getName(), new Object[] { true, System.currentTimeMillis() });
Connection connection = Database.getConnection(true);
try (Connection connection = Database.getConnection(true)) {
if (connection != null) {
Statement statement = connection.createStatement();
Location standLocation = armorStand.getLocation();
@@ -86,7 +85,6 @@ public final class ArmorStandManipulateListener extends Queue implements Listene
Chat.sendComponent(finalPlayer, blockData);
}
statement.close();
connection.close();
}
else {
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
@@ -31,6 +31,7 @@ import net.coreprotect.config.Config;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.consumer.Queue;
import net.coreprotect.model.BlockGroup;
import net.coreprotect.paper.PaperAdapter;
import net.coreprotect.utility.Util;
import net.coreprotect.utility.Validate;
@@ -315,17 +316,22 @@ public final class InventoryChangeListener extends Queue implements Listener {
return;
}
InventoryHolder sourceHolder = event.getSource().getHolder();
boolean hopperTransactions = Config.getConfig(location.getWorld()).HOPPER_TRANSACTIONS;
if (!hopperTransactions && !Config.getConfig(location.getWorld()).ITEM_TRANSACTIONS) {
return;
}
InventoryHolder sourceHolder = PaperAdapter.ADAPTER.getHolder(event.getSource(), false);
if (sourceHolder == null) {
return;
}
InventoryHolder destinationHolder = event.getDestination().getHolder();
InventoryHolder destinationHolder = PaperAdapter.ADAPTER.getHolder(event.getDestination(), false);
if (destinationHolder == null) {
return;
}
if (Config.getConfig(location.getWorld()).HOPPER_TRANSACTIONS) {
if (hopperTransactions) {
if (Validate.isHopper(destinationHolder) && (Validate.isContainer(sourceHolder) && !Validate.isHopper(sourceHolder))) {
HopperPullListener.processHopperPull(location, sourceHolder, destinationHolder, event.getItem());
}
@@ -20,6 +20,10 @@ import net.coreprotect.consumer.Queue;
public final class PlayerDropItemListener extends Queue implements Listener {
protected static void playerDropItem(Location location, Player player, ItemStack itemStack) {
if (itemStack == null) {
return;
}
String loggingItemId = player.getName().toLowerCase(Locale.ROOT) + "." + location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ();
int itemId = getItemId(loggingItemId);
@@ -41,10 +45,6 @@ public final class PlayerDropItemListener extends Queue implements Listener {
Player player = event.getPlayer();
ItemStack itemStack = item.getItemStack();
if (itemStack == null) {
return;
}
playerDropItem(location, player, itemStack);
}
@@ -87,24 +87,23 @@ public final class PlayerInteractListener extends Queue implements Listener {
class BasicThread implements Runnable {
@Override
public void run() {
try {
if (ConfigHandler.converterRunning) {
player.sendMessage(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
if (ConfigHandler.converterRunning) {
player.sendMessage(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
return;
}
if (ConfigHandler.purgeRunning) {
player.sendMessage(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
return;
}
if (ConfigHandler.lookupThrottle.get(player.getName()) != null) {
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(player.getName());
if ((boolean) lookupThrottle[0] || (System.currentTimeMillis() - (long) lookupThrottle[1]) < 100) {
player.sendMessage(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
return;
}
if (ConfigHandler.purgeRunning) {
player.sendMessage(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
return;
}
if (ConfigHandler.lookupThrottle.get(player.getName()) != null) {
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(player.getName());
if ((boolean) lookupThrottle[0] || (System.currentTimeMillis() - (long) lookupThrottle[1]) < 100) {
player.sendMessage(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
return;
}
}
}
Connection connection = Database.getConnection(true);
try (Connection connection = Database.getConnection(true)) {
if (connection != null) {
ConfigHandler.lookupThrottle.put(player.getName(), new Object[] { true, System.currentTimeMillis() });
Statement statement = connection.createStatement();
@@ -120,7 +119,6 @@ public final class PlayerInteractListener extends Queue implements Listener {
}
statement.close();
connection.close();
ConfigHandler.lookupThrottle.put(player.getName(), new Object[] { false, System.currentTimeMillis() });
if (blockFinal instanceof Sign && player.getGameMode() != GameMode.CREATIVE) {
@@ -185,28 +183,27 @@ public final class PlayerInteractListener extends Queue implements Listener {
class BasicThread implements Runnable {
@Override
public void run() {
try {
if (ConfigHandler.converterRunning) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
if (ConfigHandler.converterRunning) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
return;
}
if (ConfigHandler.purgeRunning) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
return;
}
if (ConfigHandler.lookupThrottle.get(player.getName()) != null) {
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(player.getName());
if ((boolean) lookupThrottle[0] || (System.currentTimeMillis() - (long) lookupThrottle[1]) < 100) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
return;
}
}
if (ConfigHandler.purgeRunning) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
return;
}
ConfigHandler.lookupThrottle.put(player.getName(), new Object[] { true, System.currentTimeMillis() });
if (ConfigHandler.lookupThrottle.get(player.getName()) != null) {
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(player.getName());
if ((boolean) lookupThrottle[0] || (System.currentTimeMillis() - (long) lookupThrottle[1]) < 100) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
return;
}
}
ConfigHandler.lookupThrottle.put(player.getName(), new Object[] { true, System.currentTimeMillis() });
Connection connection = Database.getConnection(true);
try (Connection connection = Database.getConnection(true)) {
if (connection != null) {
Statement statement = connection.createStatement();
List<String> signData = SignMessageLookup.performLookup(null, statement, location, player, 1, 7);
@@ -225,7 +222,6 @@ public final class PlayerInteractListener extends Queue implements Listener {
}
statement.close();
connection.close();
}
else {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
@@ -269,28 +265,27 @@ public final class PlayerInteractListener extends Queue implements Listener {
class BasicThread implements Runnable {
@Override
public void run() {
try {
if (ConfigHandler.converterRunning) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
return;
if (ConfigHandler.converterRunning) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
return;
}
if (ConfigHandler.purgeRunning) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
return;
}
if (ConfigHandler.lookupThrottle.get(player.getName()) != null) {
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(player.getName());
if ((boolean) lookupThrottle[0] || (System.currentTimeMillis() - (long) lookupThrottle[1]) < 100) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
return;
}
}
if (ConfigHandler.purgeRunning) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
return;
}
ConfigHandler.lookupThrottle.put(player.getName(), new Object[] { true, System.currentTimeMillis() });
if (ConfigHandler.lookupThrottle.get(player.getName()) != null) {
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(player.getName());
if ((boolean) lookupThrottle[0] || (System.currentTimeMillis() - (long) lookupThrottle[1]) < 100) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
return;
}
}
ConfigHandler.lookupThrottle.put(player.getName(), new Object[] { true, System.currentTimeMillis() });
Connection connection = Database.getConnection(true);
try (Connection connection = Database.getConnection(true)) {
if (connection != null) {
Statement statement = connection.createStatement();
String blockData = ChestTransactionLookup.performLookup(null, statement, finalLocation, player, 1, 7, false);
@@ -305,7 +300,6 @@ public final class PlayerInteractListener extends Queue implements Listener {
}
statement.close();
connection.close();
}
else {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
@@ -340,26 +334,25 @@ public final class PlayerInteractListener extends Queue implements Listener {
class BasicThread implements Runnable {
@Override
public void run() {
try {
if (ConfigHandler.converterRunning) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
if (ConfigHandler.converterRunning) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
return;
}
if (ConfigHandler.purgeRunning) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
return;
}
if (ConfigHandler.lookupThrottle.get(player.getName()) != null) {
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(player.getName());
if ((boolean) lookupThrottle[0] || (System.currentTimeMillis() - (long) lookupThrottle[1]) < 100) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
return;
}
if (ConfigHandler.purgeRunning) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
return;
}
if (ConfigHandler.lookupThrottle.get(player.getName()) != null) {
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(player.getName());
if ((boolean) lookupThrottle[0] || (System.currentTimeMillis() - (long) lookupThrottle[1]) < 100) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
return;
}
}
}
ConfigHandler.lookupThrottle.put(player.getName(), new Object[] { true, System.currentTimeMillis() });
ConfigHandler.lookupThrottle.put(player.getName(), new Object[] { true, System.currentTimeMillis() });
Connection connection = Database.getConnection(true);
try (Connection connection = Database.getConnection(true)) {
if (connection != null) {
Statement statement = connection.createStatement();
String blockData = InteractionLookup.performLookup(null, statement, finalInteractBlock, player, 0, 1, 7);
@@ -374,7 +367,6 @@ public final class PlayerInteractListener extends Queue implements Listener {
}
statement.close();
connection.close();
}
else {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
@@ -421,28 +413,27 @@ public final class PlayerInteractListener extends Queue implements Listener {
class BasicThread implements Runnable {
@Override
public void run() {
try {
if (ConfigHandler.converterRunning) {
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
if (ConfigHandler.converterRunning) {
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
return;
}
if (ConfigHandler.purgeRunning) {
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
return;
}
if (ConfigHandler.lookupThrottle.get(finalPlayer.getName()) != null) {
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(finalPlayer.getName());
if ((boolean) lookupThrottle[0] || (System.currentTimeMillis() - (long) lookupThrottle[1]) < 100) {
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
return;
}
}
if (ConfigHandler.purgeRunning) {
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
return;
}
ConfigHandler.lookupThrottle.put(finalPlayer.getName(), new Object[] { true, System.currentTimeMillis() });
if (ConfigHandler.lookupThrottle.get(finalPlayer.getName()) != null) {
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(finalPlayer.getName());
if ((boolean) lookupThrottle[0] || (System.currentTimeMillis() - (long) lookupThrottle[1]) < 100) {
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
return;
}
}
ConfigHandler.lookupThrottle.put(finalPlayer.getName(), new Object[] { true, System.currentTimeMillis() });
Connection connection = Database.getConnection(true);
try (Connection connection = Database.getConnection(true)) {
if (connection != null) {
Statement statement = connection.createStatement();
if (finalBlock.getType().equals(Material.AIR) || finalBlock.getType().equals(Material.CAVE_AIR)) {
@@ -470,7 +461,6 @@ public final class PlayerInteractListener extends Queue implements Listener {
}
statement.close();
connection.close();
}
else {
Chat.sendMessage(finalPlayer, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
@@ -11,7 +11,7 @@ import net.coreprotect.config.ConfigHandler;
public final class BlockGroup {
public static Set<Material> TRACK_ANY = new HashSet<>(Arrays.asList(Material.MOVING_PISTON, Material.LEVER, Material.BELL));
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_BOTTOM = new HashSet<>(Arrays.asList());
@@ -0,0 +1,49 @@
package net.coreprotect.paper;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import net.coreprotect.bukkit.BukkitAdapter;
import net.coreprotect.config.ConfigHandler;
public class PaperAdapter implements PaperInterface {
public static PaperInterface ADAPTER;
public static final int PAPER_UNAVAILABLE = 0;
public static final int PAPER_V1_13 = BukkitAdapter.BUKKIT_V1_13;
public static final int PAPER_V1_14 = BukkitAdapter.BUKKIT_V1_14;
public static final int PAPER_V1_15 = BukkitAdapter.BUKKIT_V1_15;
public static final int PAPER_V1_16 = BukkitAdapter.BUKKIT_V1_16;
public static final int PAPER_V1_17 = BukkitAdapter.BUKKIT_V1_17;
public static final int PAPER_V1_18 = BukkitAdapter.BUKKIT_V1_18;
public static void loadAdapter() {
int paperVersion = ConfigHandler.SERVER_VERSION;
if (!ConfigHandler.isPaper) {
paperVersion = PAPER_UNAVAILABLE;
}
switch (paperVersion) {
case PAPER_UNAVAILABLE:
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:
case PAPER_V1_17:
case PAPER_V1_18:
default:
PaperAdapter.ADAPTER = new Paper_v1_16();
break;
}
}
@Override
public InventoryHolder getHolder(Inventory holder, boolean useSnapshot) {
return holder.getHolder();
}
}
@@ -0,0 +1,5 @@
package net.coreprotect.paper;
public class PaperHandler extends PaperAdapter implements PaperInterface {
}
@@ -0,0 +1,10 @@
package net.coreprotect.paper;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
public interface PaperInterface {
public InventoryHolder getHolder(Inventory holder, boolean useSnapshot);
}
@@ -0,0 +1,13 @@
package net.coreprotect.paper;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
public class Paper_v1_16 extends PaperHandler implements PaperInterface {
@Override
public InventoryHolder getHolder(Inventory holder, boolean useSnapshot) {
return holder.getHolder(useSnapshot);
}
}
@@ -0,0 +1,28 @@
package net.coreprotect.paper.listener;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import io.papermc.paper.event.player.AsyncChatEvent;
import net.coreprotect.config.Config;
import net.coreprotect.consumer.Queue;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
public final class PaperChatListener extends Queue implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerChat(AsyncChatEvent event) {
String message = PlainTextComponentSerializer.plainText().serialize(event.message());
if (message.isEmpty()) {
return;
}
Player player = event.getPlayer();
if (!message.startsWith("/") && Config.getConfig(player.getWorld()).PLAYER_MESSAGES) {
long timestamp = System.currentTimeMillis() / 1000L;
Queue.queuePlayerChat(player, message, timestamp);
}
}
}
@@ -151,10 +151,9 @@ public class Patch {
int result = -1;
patching = true;
try {
try (Connection connection = Database.getConnection(true, 0)) {
boolean patched = false;
boolean allPatches = true;
Connection connection = Database.getConnection(true, 0);
Statement statement = connection.createStatement();
Integer[] newVersion = lastVersion;
@@ -221,7 +220,6 @@ public class Patch {
}
statement.close();
connection.close();
}
catch (Exception e) {
e.printStackTrace();
@@ -13,29 +13,31 @@ public class SpigotAdapter implements SpigotInterface {
public static SpigotInterface ADAPTER;
public static final int SPIGOT_UNAVAILABLE = 0;
public static final int SPIGOT_v1_13 = BukkitAdapter.BUKKIT_v1_13;
public static final int SPIGOT_v1_14 = BukkitAdapter.BUKKIT_v1_14;
public static final int SPIGOT_v1_15 = BukkitAdapter.BUKKIT_v1_15;
public static final int SPIGOT_v1_16 = BukkitAdapter.BUKKIT_v1_16;
public static final int SPIGOT_v1_17 = BukkitAdapter.BUKKIT_v1_17;
public static final int SPIGOT_V1_13 = BukkitAdapter.BUKKIT_V1_13;
public static final int SPIGOT_V1_14 = BukkitAdapter.BUKKIT_V1_14;
public static final int SPIGOT_V1_15 = BukkitAdapter.BUKKIT_V1_15;
public static final int SPIGOT_V1_16 = BukkitAdapter.BUKKIT_V1_16;
public static final int SPIGOT_V1_17 = BukkitAdapter.BUKKIT_V1_17;
public static final int SPIGOT_V1_18 = BukkitAdapter.BUKKIT_V1_18;
public static void loadAdapter() {
int SPIGOT_VERSION = ConfigHandler.SERVER_VERSION;
int spigotVersion = ConfigHandler.SERVER_VERSION;
if (!ConfigHandler.isSpigot) {
SPIGOT_VERSION = SPIGOT_UNAVAILABLE;
spigotVersion = SPIGOT_UNAVAILABLE;
}
switch (SPIGOT_VERSION) {
switch (spigotVersion) {
case SPIGOT_UNAVAILABLE:
SpigotAdapter.ADAPTER = new SpigotAdapter();
break;
case SPIGOT_v1_13:
case SPIGOT_v1_14:
case SPIGOT_v1_15:
case SPIGOT_V1_13:
case SPIGOT_V1_14:
case SPIGOT_V1_15:
SpigotAdapter.ADAPTER = new SpigotHandler();
break;
case SPIGOT_v1_16:
case SPIGOT_v1_17:
case SPIGOT_V1_16:
case SPIGOT_V1_17:
case SPIGOT_V1_18:
default:
SpigotAdapter.ADAPTER = new Spigot_v1_16();
break;
@@ -0,0 +1,105 @@
package net.coreprotect.utility;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import net.coreprotect.language.Phrase;
import net.coreprotect.model.BlockGroup;
public class Teleport {
private Teleport() {
throw new IllegalStateException("Utility class");
}
public static void performSafeTeleport(Player player, Location location, boolean enforceTeleport) {
try {
Set<Material> unsafeBlocks = new HashSet<>(Arrays.asList(Material.LAVA));
unsafeBlocks.addAll(BlockGroup.FIRE);
int worldHeight = location.getWorld().getMaxHeight();
int playerX = location.getBlockX();
int playerY = location.getBlockY();
int playerZ = location.getBlockZ();
int checkY = playerY - 1;
boolean safeBlock = false;
boolean placeSafe = false;
boolean alert = false;
while (!safeBlock) {
int above = checkY + 1;
if (above > worldHeight) {
above = worldHeight;
}
Block block1 = location.getWorld().getBlockAt(playerX, checkY, playerZ);
Block block2 = location.getWorld().getBlockAt(playerX, above, playerZ);
Material type1 = block1.getType();
Material type2 = block2.getType();
if (!Util.solidBlock(type1) && !Util.solidBlock(type2)) {
if (unsafeBlocks.contains(type1)) {
placeSafe = true;
}
else {
safeBlock = true;
if (placeSafe) {
int below = checkY - 1;
Block blockBelow = location.getWorld().getBlockAt(playerX, below, playerZ);
if (checkY < worldHeight && unsafeBlocks.contains(blockBelow.getType())) {
alert = true;
block1.setType(Material.DIRT);
checkY++;
}
}
}
}
if (checkY >= worldHeight || player.getGameMode() == GameMode.SPECTATOR) {
safeBlock = true;
if (checkY < worldHeight) {
checkY++;
}
}
if (safeBlock && (checkY > playerY || enforceTeleport)) {
if (checkY > worldHeight) {
checkY = worldHeight;
}
double oldY = location.getY();
location.setY(checkY);
player.teleport(location);
if (!enforceTeleport) {
// Only send a message if the player was moved by at least 1 block
if (location.getY() >= (oldY + 1.00)) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.TELEPORTED_SAFETY));
}
}
else {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.TELEPORTED, "x" + playerX + "/y" + checkY + "/z" + playerZ + "/" + location.getWorld().getName()));
}
if (alert) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + Color.ITALIC + "- " + Phrase.build(Phrase.DIRT_BLOCK));
}
}
checkY++;
}
}
catch (Exception e) {
e.printStackTrace();
}
}
}
+3 -828
View File
@@ -12,7 +12,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -22,19 +21,11 @@ import java.util.TreeSet;
import org.bukkit.Art;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.attribute.Attributable;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.block.Banner;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.Chest;
import org.bukkit.block.CommandBlock;
@@ -46,50 +37,14 @@ import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
import org.bukkit.configuration.serialization.DelegateDeserialization;
import org.bukkit.entity.AbstractHorse;
import org.bukkit.entity.AbstractVillager;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Cat;
import org.bukkit.entity.ChestedHorse;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Enderman;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fox;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Style;
import org.bukkit.entity.IronGolem;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Llama;
import org.bukkit.entity.MushroomCow;
import org.bukkit.entity.Painting;
import org.bukkit.entity.Panda;
import org.bukkit.entity.Panda.Gene;
import org.bukkit.entity.Parrot;
import org.bukkit.entity.Parrot.Variant;
import org.bukkit.entity.Phantom;
import org.bukkit.entity.Pig;
import org.bukkit.entity.Player;
import org.bukkit.entity.Raider;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Spellcaster;
import org.bukkit.entity.Spellcaster.Spell;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.TropicalFish;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Villager.Profession;
import org.bukkit.entity.Wolf;
import org.bukkit.entity.Zombie;
import org.bukkit.entity.ZombieVillager;
import org.bukkit.inventory.BlockInventoryHolder;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.MerchantRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.io.BukkitObjectOutputStream;
@@ -196,9 +151,9 @@ public class Util extends Queue {
return message.append(Color.WHITE + backArrow + Phrase.build(Phrase.LOOKUP_PAGE, page + "/" + totalPages) + nextArrow).toString();
}
public static String getTimeSince(int logTime, int currentTime, boolean component) {
public static String getTimeSince(long resultTime, long currentTime, boolean component) {
StringBuilder message = new StringBuilder();
double timeSince = currentTime - (logTime + 0.00);
double timeSince = currentTime - (resultTime + 0.00);
// minutes
timeSince = timeSince / 60;
@@ -221,7 +176,7 @@ public class Util extends Queue {
}
if (component) {
Date logDate = new Date(logTime * 1000L);
Date logDate = new Date(resultTime * 1000L);
String formattedTimestamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z").format(logDate);
return Chat.COMPONENT_TAG_OPEN + Chat.COMPONENT_POPUP + "|" + Color.GREY + formattedTimestamp + "|" + Color.GREY + message.toString() + Chat.COMPONENT_TAG_CLOSE;
@@ -569,84 +524,6 @@ public class Util extends Queue {
return artname;
}
public static int getBlockFace(BlockFace rotation) {
switch (rotation) {
case NORTH:
return 0;
case NORTH_NORTH_EAST:
return 1;
case NORTH_EAST:
return 2;
case EAST_NORTH_EAST:
return 3;
case EAST:
return 4;
case EAST_SOUTH_EAST:
return 5;
case SOUTH_EAST:
return 6;
case SOUTH_SOUTH_EAST:
return 7;
case SOUTH:
return 8;
case SOUTH_SOUTH_WEST:
return 9;
case SOUTH_WEST:
return 10;
case WEST_SOUTH_WEST:
return 11;
case WEST:
return 12;
case WEST_NORTH_WEST:
return 13;
case NORTH_WEST:
return 14;
case NORTH_NORTH_WEST:
return 15;
default:
throw new IllegalArgumentException("Invalid BlockFace rotation: " + rotation);
}
}
public static BlockFace getBlockFace(int rotation) {
switch (rotation) {
case 0:
return BlockFace.NORTH;
case 1:
return BlockFace.NORTH_NORTH_EAST;
case 2:
return BlockFace.NORTH_EAST;
case 3:
return BlockFace.EAST_NORTH_EAST;
case 4:
return BlockFace.EAST;
case 5:
return BlockFace.EAST_SOUTH_EAST;
case 6:
return BlockFace.SOUTH_EAST;
case 7:
return BlockFace.SOUTH_SOUTH_EAST;
case 8:
return BlockFace.SOUTH;
case 9:
return BlockFace.SOUTH_SOUTH_WEST;
case 10:
return BlockFace.SOUTH_WEST;
case 11:
return BlockFace.WEST_SOUTH_WEST;
case 12:
return BlockFace.WEST;
case 13:
return BlockFace.WEST_NORTH_WEST;
case 14:
return BlockFace.NORTH_WEST;
case 15:
return BlockFace.NORTH_NORTH_WEST;
default:
throw new AssertionError(rotation);
}
}
public static ItemStack[] getArmorStandContents(EntityEquipment equipment) {
ItemStack[] contents = new ItemStack[6];
if (equipment != null) {
@@ -1077,89 +954,6 @@ public class Util extends Queue {
Chat.sendComponent(consoleSender, Color.RESET + "[CoreProtect] " + string + Chat.COMPONENT_TAG_OPEN + Chat.COMPONENT_POPUP + "| | " + Chat.COMPONENT_TAG_CLOSE);
}
public static void performSafeTeleport(Player player, Location location, boolean enforceTeleport) {
try {
Set<Material> unsafeBlocks = new HashSet<>(Arrays.asList(Material.LAVA));
unsafeBlocks.addAll(BlockGroup.FIRE);
int worldHeight = location.getWorld().getMaxHeight();
int playerX = location.getBlockX();
int playerY = location.getBlockY();
int playerZ = location.getBlockZ();
int checkY = playerY - 1;
boolean safeBlock = false;
boolean placeSafe = false;
boolean alert = false;
while (!safeBlock) {
int above = checkY + 1;
if (above > worldHeight) {
above = worldHeight;
}
Block block1 = location.getWorld().getBlockAt(playerX, checkY, playerZ);
Block block2 = location.getWorld().getBlockAt(playerX, above, playerZ);
Material type1 = block1.getType();
Material type2 = block2.getType();
if (!Util.solidBlock(type1) && !Util.solidBlock(type2)) {
if (unsafeBlocks.contains(type1)) {
placeSafe = true;
}
else {
safeBlock = true;
if (placeSafe) {
int below = checkY - 1;
Block blockBelow = location.getWorld().getBlockAt(playerX, below, playerZ);
if (checkY < worldHeight && unsafeBlocks.contains(blockBelow.getType())) {
alert = true;
block1.setType(Material.DIRT);
checkY++;
}
}
}
}
if (checkY >= worldHeight || player.getGameMode() == GameMode.SPECTATOR) {
safeBlock = true;
if (checkY < worldHeight) {
checkY++;
}
}
if (safeBlock && (checkY > playerY || enforceTeleport)) {
if (checkY > worldHeight) {
checkY = worldHeight;
}
double oldY = location.getY();
location.setY(checkY);
player.teleport(location);
if (!enforceTeleport) {
// Only send a message if the player was moved by at least 1 block
if (location.getY() >= (oldY + 1.00)) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.TELEPORTED_SAFETY));
}
}
else {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.TELEPORTED, "x" + playerX + "/y" + checkY + "/z" + playerZ + "/" + location.getWorld().getName()));
}
if (alert) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + Color.ITALIC + "- " + Phrase.build(Phrase.DIRT_BLOCK));
}
}
checkY++;
}
}
catch (Exception e) {
e.printStackTrace();
}
}
public static String nameFilter(String name, int data) {
if (name.equals("stone")) {
switch (data) {
@@ -1381,24 +1175,6 @@ public class Util extends Queue {
return meta;
}
public static void removeHanging(final BlockState block, int delay) {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CoreProtect.getInstance(), () -> {
try {
for (Entity e : block.getChunk().getEntities()) {
if (e instanceof ItemFrame || e instanceof Painting) {
Location el = e.getLocation();
if (el.getBlockX() == block.getX() && el.getBlockY() == block.getY() && el.getBlockZ() == block.getZ()) {
e.remove();
}
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}, delay);
}
public static void sendBlockChange(Player player, Location location, BlockData blockData) {
player.sendBlockChange(location, blockData);
}
@@ -1428,607 +1204,6 @@ public class Util extends Queue {
block.setBlockData(blockData, update);
}
public static void spawnEntity(final BlockState block, final EntityType type, final List<Object> list) {
if (type == null) {
return;
}
Bukkit.getServer().getScheduler().runTask(CoreProtect.getInstance(), () -> {
try {
Location location = block.getLocation();
location.setX(location.getX() + 0.50);
location.setZ(location.getZ() + 0.50);
Entity entity = block.getLocation().getWorld().spawnEntity(location, type);
if (list.isEmpty()) {
return;
}
@SuppressWarnings("unchecked")
List<Object> age = (List<Object>) list.get(0);
@SuppressWarnings("unchecked")
List<Object> tame = (List<Object>) list.get(1);
@SuppressWarnings("unchecked")
List<Object> data = (List<Object>) list.get(2);
if (list.size() >= 5) {
entity.setCustomNameVisible((Boolean) list.get(3));
entity.setCustomName((String) list.get(4));
}
int unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
int wid = Util.getWorldId(block.getWorld().getName());
String token = "" + block.getX() + "." + block.getY() + "." + block.getZ() + "." + wid + "." + type.name() + "";
CacheHandler.entityCache.put(token, new Object[] { unixtimestamp, entity.getEntityId() });
if (entity instanceof Ageable) {
int count = 0;
Ageable ageable = (Ageable) entity;
for (Object value : age) {
if (count == 0) {
int set = (Integer) value;
ageable.setAge(set);
}
else if (count == 1) {
boolean set = (Boolean) value;
ageable.setAgeLock(set);
}
else if (count == 2) {
boolean set = (Boolean) value;
if (set) {
ageable.setAdult();
}
else {
ageable.setBaby();
}
}
else if (count == 3) {
boolean set = (Boolean) value;
ageable.setBreed(set);
}
else if (count == 4 && value != null) {
// deprecated
double set = (Double) value;
ageable.setMaxHealth(set);
}
count++;
}
}
if (entity instanceof Tameable) {
int count = 0;
Tameable tameable = (Tameable) entity;
for (Object value : tame) {
if (count == 0) {
boolean set = (Boolean) value;
tameable.setTamed(set);
}
else if (count == 1) {
String set = (String) value;
if (set.length() > 0) {
Player owner = Bukkit.getServer().getPlayer(set);
if (owner == null) {
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(set);
if (offlinePlayer != null) {
tameable.setOwner(offlinePlayer);
}
}
else {
tameable.setOwner(owner);
}
}
}
count++;
}
}
if (entity instanceof Attributable && list.size() >= 6) {
Attributable attributable = (Attributable) entity;
@SuppressWarnings("unchecked")
List<Object> attributes = (List<Object>) list.get(5);
for (Object value : attributes) {
@SuppressWarnings("unchecked")
List<Object> attributeData = (List<Object>) value;
Attribute attribute = (Attribute) attributeData.get(0);
Double baseValue = (Double) attributeData.get(1);
@SuppressWarnings("unchecked")
List<Object> attributeModifiers = (List<Object>) attributeData.get(2);
AttributeInstance entityAttribute = attributable.getAttribute(attribute);
if (entityAttribute != null) {
entityAttribute.setBaseValue(baseValue);
for (AttributeModifier modifier : entityAttribute.getModifiers()) {
entityAttribute.removeModifier(modifier);
}
for (Object modifier : attributeModifiers) {
@SuppressWarnings("unchecked")
Map<String, Object> serializedModifier = (Map<String, Object>) modifier;
entityAttribute.addModifier(AttributeModifier.deserialize(serializedModifier));
}
}
}
}
if (entity instanceof LivingEntity && list.size() >= 7) {
LivingEntity livingEntity = (LivingEntity) entity;
@SuppressWarnings("unchecked")
List<Object> details = (List<Object>) list.get(6);
int count = 0;
for (Object value : details) {
if (count == 0) {
boolean set = (Boolean) value;
livingEntity.setRemoveWhenFarAway(set);
}
else if (count == 1) {
boolean set = (Boolean) value;
livingEntity.setCanPickupItems(set);
}
count++;
}
}
int count = 0;
for (Object value : data) {
if (entity instanceof Creeper) {
Creeper creeper = (Creeper) entity;
if (count == 0) {
boolean set = (Boolean) value;
creeper.setPowered(set);
}
}
else if (entity instanceof Enderman) {
Enderman enderman = (Enderman) entity;
if (count == 1) {
String blockDataString = (String) value;
BlockData blockData = Bukkit.getServer().createBlockData(blockDataString);
enderman.setCarriedBlock(blockData);
}
}
else if (entity instanceof IronGolem) {
IronGolem irongolem = (IronGolem) entity;
if (count == 0) {
boolean set = (Boolean) value;
irongolem.setPlayerCreated(set);
}
}
else if (entity instanceof Cat) {
Cat cat = (Cat) entity;
if (count == 0) {
Cat.Type set = (Cat.Type) value;
cat.setCatType(set);
}
else if (count == 1) {
DyeColor set = (DyeColor) value;
cat.setCollarColor(set);
}
}
else if (entity instanceof Fox) {
Fox fox = (Fox) entity;
if (count == 0) {
Fox.Type set = (Fox.Type) value;
fox.setFoxType(set);
}
else if (count == 1) {
boolean set = (Boolean) value;
fox.setSitting(set);
}
}
else if (entity instanceof Panda) {
Panda panda = (Panda) entity;
if (count == 0) {
Gene set = (Gene) value;
panda.setMainGene(set);
}
else if (count == 1) {
Gene set = (Gene) value;
panda.setHiddenGene(set);
}
}
else if (entity instanceof Pig) {
Pig pig = (Pig) entity;
if (count == 0) {
boolean set = (Boolean) value;
pig.setSaddle(set);
}
}
else if (entity instanceof Sheep) {
Sheep sheep = (Sheep) entity;
if (count == 0) {
boolean set = (Boolean) value;
sheep.setSheared(set);
}
else if (count == 1) {
DyeColor set = (DyeColor) value;
sheep.setColor(set);
}
}
else if (entity instanceof MushroomCow) {
MushroomCow mushroomCow = (MushroomCow) entity;
if (count == 0) {
MushroomCow.Variant set = (MushroomCow.Variant) value;
mushroomCow.setVariant(set);
}
}
else if (entity instanceof Slime) {
Slime slime = (Slime) entity;
if (count == 0) {
int set = (Integer) value;
slime.setSize(set);
}
}
else if (entity instanceof Parrot) {
Parrot parrot = (Parrot) entity;
if (count == 0) {
Variant set = (Variant) value;
parrot.setVariant(set);
}
}
else if (entity instanceof TropicalFish) {
TropicalFish tropicalFish = (TropicalFish) entity;
if (count == 0) {
DyeColor set = (DyeColor) value;
tropicalFish.setBodyColor(set);
}
else if (count == 1) {
TropicalFish.Pattern set = (TropicalFish.Pattern) value;
tropicalFish.setPattern(set);
}
else if (count == 2) {
DyeColor set = (DyeColor) value;
tropicalFish.setPatternColor(set);
}
}
else if (entity instanceof Phantom) {
Phantom phantom = (Phantom) entity;
if (count == 0) {
int set = (Integer) value;
phantom.setSize(set);
}
}
else if (entity instanceof AbstractVillager) {
AbstractVillager abstractVillager = (AbstractVillager) entity;
if (count == 0) {
if (abstractVillager instanceof Villager) {
Villager villager = (Villager) abstractVillager;
Profession set = (Profession) value;
villager.setProfession(set);
}
}
else if (count == 1) {
if (abstractVillager instanceof Villager && value instanceof Villager.Type) {
Villager villager = (Villager) abstractVillager;
Villager.Type set = (Villager.Type) value;
villager.setVillagerType(set);
}
}
else if (count == 2) {
List<MerchantRecipe> merchantRecipes = new ArrayList<>();
@SuppressWarnings("unchecked")
List<Object> set = (List<Object>) value;
for (Object recipes : set) {
@SuppressWarnings("unchecked")
List<Object> recipe = (List<Object>) recipes;
@SuppressWarnings("unchecked")
List<Object> itemMap = (List<Object>) recipe.get(0);
@SuppressWarnings("unchecked")
ItemStack result = ItemStack.deserialize((Map<String, Object>) itemMap.get(0));
@SuppressWarnings("unchecked")
List<List<Map<String, Object>>> metadata = (List<List<Map<String, Object>>>) itemMap.get(1);
Object[] populatedStack = Rollback.populateItemStack(result, metadata);
result = (ItemStack) populatedStack[1];
int uses = (int) recipe.get(1);
int maxUses = (int) recipe.get(2);
boolean experienceReward = (boolean) recipe.get(3);
List<ItemStack> merchantIngredients = new ArrayList<>();
@SuppressWarnings("unchecked")
List<Object> ingredients = (List<Object>) recipe.get(4);
for (Object ingredient : ingredients) {
@SuppressWarnings("unchecked")
List<Object> ingredientMap = (List<Object>) ingredient;
@SuppressWarnings("unchecked")
ItemStack item = ItemStack.deserialize((Map<String, Object>) ingredientMap.get(0));
@SuppressWarnings("unchecked")
List<List<Map<String, Object>>> itemMetaData = (List<List<Map<String, Object>>>) ingredientMap.get(1);
populatedStack = Rollback.populateItemStack(item, itemMetaData);
item = (ItemStack) populatedStack[1];
merchantIngredients.add(item);
}
MerchantRecipe merchantRecipe = new MerchantRecipe(result, uses, maxUses, experienceReward);
if (recipe.size() > 6) {
int villagerExperience = (int) recipe.get(5);
float priceMultiplier = (float) recipe.get(6);
merchantRecipe = new MerchantRecipe(result, uses, maxUses, experienceReward, villagerExperience, priceMultiplier);
}
merchantRecipe.setIngredients(merchantIngredients);
merchantRecipes.add(merchantRecipe);
}
if (!merchantRecipes.isEmpty()) {
abstractVillager.setRecipes(merchantRecipes);
}
}
else {
Villager villager = (Villager) abstractVillager;
if (count == 3) {
int set = (int) value;
villager.setVillagerLevel(set);
}
else if (count == 4) {
int set = (int) value;
villager.setVillagerExperience(set);
}
}
}
else if (entity instanceof Raider) {
Raider raider = (Raider) entity;
if (count == 0) {
boolean set = (Boolean) value;
raider.setPatrolLeader(set);
}
if (entity instanceof Spellcaster && count == 1) {
Spellcaster spellcaster = (Spellcaster) entity;
Spell set = (Spell) value;
spellcaster.setSpell(set);
}
}
else if (entity instanceof Wolf) {
Wolf wolf = (Wolf) entity;
if (count == 0) {
boolean set = (Boolean) value;
wolf.setSitting(set);
}
else if (count == 1) {
DyeColor set = (DyeColor) value;
wolf.setCollarColor(set);
}
}
else if (entity instanceof ZombieVillager) {
ZombieVillager zombieVillager = (ZombieVillager) entity;
if (count == 0) {
boolean set = (Boolean) value;
zombieVillager.setBaby(set);
}
else if (count == 1) {
Profession set = (Profession) value;
zombieVillager.setVillagerProfession(set);
}
}
else if (entity instanceof Zombie) {
Zombie zombie = (Zombie) entity;
if (count == 0) {
boolean set = (Boolean) value;
zombie.setBaby(set);
}
}
else if (entity instanceof AbstractHorse) {
AbstractHorse abstractHorse = (AbstractHorse) entity;
if (count == 0 && value != null) {
// deprecated
boolean set = (Boolean) value;
if (entity instanceof ChestedHorse) {
ChestedHorse chestedHorse = (ChestedHorse) entity;
chestedHorse.setCarryingChest(set);
}
}
else if (count == 1 && value != null) {
// deprecated
org.bukkit.entity.Horse.Color set = (org.bukkit.entity.Horse.Color) value;
if (entity instanceof Horse) {
Horse horse = (Horse) entity;
horse.setColor(set);
}
}
else if (count == 2) {
int set = (Integer) value;
abstractHorse.setDomestication(set);
}
else if (count == 3) {
double set = (Double) value;
abstractHorse.setJumpStrength(set);
}
else if (count == 4) {
int set = (Integer) value;
abstractHorse.setMaxDomestication(set);
}
else if (count == 5 && value != null) {
// deprecated
Style set = (Style) value;
Horse horse = (Horse) entity;
horse.setStyle(set);
}
if (entity instanceof Horse) {
Horse horse = (Horse) entity;
if (count == 8) {
if (value != null) {
@SuppressWarnings("unchecked")
ItemStack set = ItemStack.deserialize((Map<String, Object>) value);
horse.getInventory().setSaddle(set);
}
}
else if (count == 9) {
org.bukkit.entity.Horse.Color set = (org.bukkit.entity.Horse.Color) value;
horse.setColor(set);
}
else if (count == 10) {
Style set = (Style) value;
horse.setStyle(set);
}
else if (count == 11) {
if (value != null) {
@SuppressWarnings("unchecked")
ItemStack set = ItemStack.deserialize((Map<String, Object>) value);
horse.getInventory().setArmor(set);
}
}
else if (count == 12 && value != null) {
@SuppressWarnings("unchecked")
org.bukkit.Color set = org.bukkit.Color.deserialize((Map<String, Object>) value);
ItemStack armor = horse.getInventory().getArmor();
if (armor != null) {
ItemMeta itemMeta = armor.getItemMeta();
if (itemMeta instanceof LeatherArmorMeta) {
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) itemMeta;
leatherArmorMeta.setColor(set);
armor.setItemMeta(leatherArmorMeta);
}
}
}
}
else if (entity instanceof ChestedHorse) {
if (count == 7) {
ChestedHorse chestedHorse = (ChestedHorse) entity;
boolean set = (Boolean) value;
chestedHorse.setCarryingChest(set);
}
if (entity instanceof Llama) {
Llama llama = (Llama) entity;
if (count == 8) {
if (value != null) {
@SuppressWarnings("unchecked")
ItemStack set = ItemStack.deserialize((Map<String, Object>) value);
llama.getInventory().setDecor(set);
}
}
else if (count == 9) {
Llama.Color set = (Llama.Color) value;
llama.setColor(set);
}
}
}
}
else {
BukkitAdapter.ADAPTER.setEntityMeta(entity, value, count);
}
count++;
}
}
catch (Exception e) {
e.printStackTrace();
}
});
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void spawnHanging(final BlockState blockstate, final Material rowType, final int rowData, int delay) {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CoreProtect.getInstance(), () -> {
try {
Block block = blockstate.getBlock();
int x = block.getX();
int y = block.getY();
int z = block.getZ();
for (Entity e : block.getChunk().getEntities()) {
if ((BukkitAdapter.ADAPTER.isItemFrame(rowType) && e instanceof ItemFrame) || (rowType.equals(Material.PAINTING) && e instanceof Painting)) {
Location el = e.getLocation();
if (el.getBlockX() == x && el.getBlockY() == y && el.getBlockZ() == z) {
e.remove();
break;
}
}
}
Block c1 = block.getWorld().getBlockAt((x + 1), y, z);
Block c2 = block.getWorld().getBlockAt((x - 1), y, z);
Block c3 = block.getWorld().getBlockAt(x, y, (z + 1));
Block c4 = block.getWorld().getBlockAt(x, y, (z - 1));
BlockFace faceSet = null;
if (!BlockGroup.NON_ATTACHABLE.contains(c1.getType())) {
faceSet = BlockFace.WEST;
block = c1;
}
else if (!BlockGroup.NON_ATTACHABLE.contains(c2.getType())) {
faceSet = BlockFace.EAST;
block = c2;
}
else if (!BlockGroup.NON_ATTACHABLE.contains(c3.getType())) {
faceSet = BlockFace.NORTH;
block = c3;
}
else if (!BlockGroup.NON_ATTACHABLE.contains(c4.getType())) {
faceSet = BlockFace.SOUTH;
block = c4;
}
BlockFace face = null;
if (!solidBlock(Util.getType(block.getRelative(BlockFace.EAST)))) {
face = BlockFace.EAST;
}
else if (!solidBlock(Util.getType(block.getRelative(BlockFace.NORTH)))) {
face = BlockFace.NORTH;
}
else if (!solidBlock(Util.getType(block.getRelative(BlockFace.WEST)))) {
face = BlockFace.WEST;
}
else if (!solidBlock(Util.getType(block.getRelative(BlockFace.SOUTH)))) {
face = BlockFace.SOUTH;
}
if (faceSet != null && face != null) {
if (rowType.equals(Material.PAINTING)) {
String name = Util.getArtName(rowData);
Art painting = Art.getByName(name.toUpperCase(Locale.ROOT));
int height = painting.getBlockHeight();
int width = painting.getBlockWidth();
int paintingX = x;
int paintingY = y;
int paintingZ = z;
if (height != 1 || width != 1) {
if (height > 1) {
if (height != 3) {
paintingY = paintingY - 1;
}
}
if (width > 1) {
if (faceSet.equals(BlockFace.WEST)) {
paintingZ--;
}
else if (faceSet.equals(BlockFace.SOUTH)) {
paintingX--;
}
}
}
Block spawnBlock = block.getRelative(face);
Util.setTypeAndData(spawnBlock, Material.AIR, null, true);
Painting hanging = null;
try {
hanging = block.getWorld().spawn(spawnBlock.getLocation(), Painting.class);
}
catch (Exception e) {
}
if (hanging != null) {
hanging.teleport(block.getWorld().getBlockAt(paintingX, paintingY, paintingZ).getLocation());
hanging.setFacingDirection(faceSet, true);
hanging.setArt(painting, true);
}
}
else if (BukkitAdapter.ADAPTER.isItemFrame(rowType)) {
try {
Block spawnBlock = block.getRelative(face);
Util.setTypeAndData(spawnBlock, Material.AIR, null, true);
Class itemFrame = BukkitAdapter.ADAPTER.getFrameClass(rowType);
Entity entity = block.getWorld().spawn(spawnBlock.getLocation(), itemFrame);
if (entity instanceof ItemFrame) {
ItemFrame hanging = (ItemFrame) entity;
hanging.teleport(block.getWorld().getBlockAt(x, y, z).getLocation());
hanging.setFacingDirection(faceSet, true);
Material type = Util.getType(rowData);
if (type != null) {
ItemStack istack = new ItemStack(type, 1);
hanging.setItem(istack);
}
}
}
catch (Exception e) {
}
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}, delay);
}
public static boolean successfulQuery(Connection connection, String query) {
boolean result = false;
try {
@@ -0,0 +1,547 @@
package net.coreprotect.utility.entity;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.attribute.Attributable;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.AbstractHorse;
import org.bukkit.entity.AbstractVillager;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Cat;
import org.bukkit.entity.ChestedHorse;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Enderman;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fox;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Style;
import org.bukkit.entity.IronGolem;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Llama;
import org.bukkit.entity.MushroomCow;
import org.bukkit.entity.Panda;
import org.bukkit.entity.Panda.Gene;
import org.bukkit.entity.Parrot;
import org.bukkit.entity.Parrot.Variant;
import org.bukkit.entity.Phantom;
import org.bukkit.entity.Pig;
import org.bukkit.entity.Player;
import org.bukkit.entity.Raider;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Spellcaster;
import org.bukkit.entity.Spellcaster.Spell;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.TropicalFish;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Villager.Profession;
import org.bukkit.entity.Wolf;
import org.bukkit.entity.Zombie;
import org.bukkit.entity.ZombieVillager;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.MerchantRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import net.coreprotect.CoreProtect;
import net.coreprotect.bukkit.BukkitAdapter;
import net.coreprotect.database.Rollback;
import net.coreprotect.thread.CacheHandler;
import net.coreprotect.utility.Util;
public class EntityUtil {
private EntityUtil() {
throw new IllegalStateException("Utility class");
}
public static void spawnEntity(final BlockState block, final EntityType type, final List<Object> list) {
if (type == null) {
return;
}
Bukkit.getServer().getScheduler().runTask(CoreProtect.getInstance(), () -> {
try {
Location location = block.getLocation();
location.setX(location.getX() + 0.50);
location.setZ(location.getZ() + 0.50);
Entity entity = block.getLocation().getWorld().spawnEntity(location, type);
if (list.isEmpty()) {
return;
}
@SuppressWarnings("unchecked")
List<Object> age = (List<Object>) list.get(0);
@SuppressWarnings("unchecked")
List<Object> tame = (List<Object>) list.get(1);
@SuppressWarnings("unchecked")
List<Object> data = (List<Object>) list.get(2);
if (list.size() >= 5) {
entity.setCustomNameVisible((Boolean) list.get(3));
entity.setCustomName((String) list.get(4));
}
int unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
int wid = Util.getWorldId(block.getWorld().getName());
String token = "" + block.getX() + "." + block.getY() + "." + block.getZ() + "." + wid + "." + type.name() + "";
CacheHandler.entityCache.put(token, new Object[] { unixtimestamp, entity.getEntityId() });
if (entity instanceof Ageable) {
int count = 0;
Ageable ageable = (Ageable) entity;
for (Object value : age) {
if (count == 0) {
int set = (Integer) value;
ageable.setAge(set);
}
else if (count == 1) {
boolean set = (Boolean) value;
ageable.setAgeLock(set);
}
else if (count == 2) {
boolean set = (Boolean) value;
if (set) {
ageable.setAdult();
}
else {
ageable.setBaby();
}
}
else if (count == 3) {
boolean set = (Boolean) value;
ageable.setBreed(set);
}
else if (count == 4 && value != null) {
// deprecated
double set = (Double) value;
ageable.setMaxHealth(set);
}
count++;
}
}
if (entity instanceof Tameable) {
int count = 0;
Tameable tameable = (Tameable) entity;
for (Object value : tame) {
if (count == 0) {
boolean set = (Boolean) value;
tameable.setTamed(set);
}
else if (count == 1) {
String set = (String) value;
if (set.length() > 0) {
Player owner = Bukkit.getServer().getPlayer(set);
if (owner == null) {
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(set);
if (offlinePlayer != null) {
tameable.setOwner(offlinePlayer);
}
}
else {
tameable.setOwner(owner);
}
}
}
count++;
}
}
if (entity instanceof Attributable && list.size() >= 6) {
Attributable attributable = (Attributable) entity;
@SuppressWarnings("unchecked")
List<Object> attributes = (List<Object>) list.get(5);
for (Object value : attributes) {
@SuppressWarnings("unchecked")
List<Object> attributeData = (List<Object>) value;
Attribute attribute = (Attribute) attributeData.get(0);
Double baseValue = (Double) attributeData.get(1);
@SuppressWarnings("unchecked")
List<Object> attributeModifiers = (List<Object>) attributeData.get(2);
AttributeInstance entityAttribute = attributable.getAttribute(attribute);
if (entityAttribute != null) {
entityAttribute.setBaseValue(baseValue);
for (AttributeModifier modifier : entityAttribute.getModifiers()) {
entityAttribute.removeModifier(modifier);
}
for (Object modifier : attributeModifiers) {
@SuppressWarnings("unchecked")
Map<String, Object> serializedModifier = (Map<String, Object>) modifier;
entityAttribute.addModifier(AttributeModifier.deserialize(serializedModifier));
}
}
}
}
if (entity instanceof LivingEntity && list.size() >= 7) {
LivingEntity livingEntity = (LivingEntity) entity;
@SuppressWarnings("unchecked")
List<Object> details = (List<Object>) list.get(6);
int count = 0;
for (Object value : details) {
if (count == 0) {
boolean set = (Boolean) value;
livingEntity.setRemoveWhenFarAway(set);
}
else if (count == 1) {
boolean set = (Boolean) value;
livingEntity.setCanPickupItems(set);
}
count++;
}
}
int count = 0;
for (Object value : data) {
if (entity instanceof Creeper) {
Creeper creeper = (Creeper) entity;
if (count == 0) {
boolean set = (Boolean) value;
creeper.setPowered(set);
}
}
else if (entity instanceof Enderman) {
Enderman enderman = (Enderman) entity;
if (count == 1) {
String blockDataString = (String) value;
BlockData blockData = Bukkit.getServer().createBlockData(blockDataString);
enderman.setCarriedBlock(blockData);
}
}
else if (entity instanceof IronGolem) {
IronGolem irongolem = (IronGolem) entity;
if (count == 0) {
boolean set = (Boolean) value;
irongolem.setPlayerCreated(set);
}
}
else if (entity instanceof Cat) {
Cat cat = (Cat) entity;
if (count == 0) {
Cat.Type set = (Cat.Type) value;
cat.setCatType(set);
}
else if (count == 1) {
DyeColor set = (DyeColor) value;
cat.setCollarColor(set);
}
}
else if (entity instanceof Fox) {
Fox fox = (Fox) entity;
if (count == 0) {
Fox.Type set = (Fox.Type) value;
fox.setFoxType(set);
}
else if (count == 1) {
boolean set = (Boolean) value;
fox.setSitting(set);
}
}
else if (entity instanceof Panda) {
Panda panda = (Panda) entity;
if (count == 0) {
Gene set = (Gene) value;
panda.setMainGene(set);
}
else if (count == 1) {
Gene set = (Gene) value;
panda.setHiddenGene(set);
}
}
else if (entity instanceof Pig) {
Pig pig = (Pig) entity;
if (count == 0) {
boolean set = (Boolean) value;
pig.setSaddle(set);
}
}
else if (entity instanceof Sheep) {
Sheep sheep = (Sheep) entity;
if (count == 0) {
boolean set = (Boolean) value;
sheep.setSheared(set);
}
else if (count == 1) {
DyeColor set = (DyeColor) value;
sheep.setColor(set);
}
}
else if (entity instanceof MushroomCow) {
MushroomCow mushroomCow = (MushroomCow) entity;
if (count == 0) {
MushroomCow.Variant set = (MushroomCow.Variant) value;
mushroomCow.setVariant(set);
}
}
else if (entity instanceof Slime) {
Slime slime = (Slime) entity;
if (count == 0) {
int set = (Integer) value;
slime.setSize(set);
}
}
else if (entity instanceof Parrot) {
Parrot parrot = (Parrot) entity;
if (count == 0) {
Variant set = (Variant) value;
parrot.setVariant(set);
}
}
else if (entity instanceof TropicalFish) {
TropicalFish tropicalFish = (TropicalFish) entity;
if (count == 0) {
DyeColor set = (DyeColor) value;
tropicalFish.setBodyColor(set);
}
else if (count == 1) {
TropicalFish.Pattern set = (TropicalFish.Pattern) value;
tropicalFish.setPattern(set);
}
else if (count == 2) {
DyeColor set = (DyeColor) value;
tropicalFish.setPatternColor(set);
}
}
else if (entity instanceof Phantom) {
Phantom phantom = (Phantom) entity;
if (count == 0) {
int set = (Integer) value;
phantom.setSize(set);
}
}
else if (entity instanceof AbstractVillager) {
AbstractVillager abstractVillager = (AbstractVillager) entity;
if (count == 0) {
if (abstractVillager instanceof Villager) {
Villager villager = (Villager) abstractVillager;
Profession set = (Profession) value;
villager.setProfession(set);
}
}
else if (count == 1) {
if (abstractVillager instanceof Villager && value instanceof Villager.Type) {
Villager villager = (Villager) abstractVillager;
Villager.Type set = (Villager.Type) value;
villager.setVillagerType(set);
}
}
else if (count == 2) {
List<MerchantRecipe> merchantRecipes = new ArrayList<>();
@SuppressWarnings("unchecked")
List<Object> set = (List<Object>) value;
for (Object recipes : set) {
@SuppressWarnings("unchecked")
List<Object> recipe = (List<Object>) recipes;
@SuppressWarnings("unchecked")
List<Object> itemMap = (List<Object>) recipe.get(0);
@SuppressWarnings("unchecked")
ItemStack result = ItemStack.deserialize((Map<String, Object>) itemMap.get(0));
@SuppressWarnings("unchecked")
List<List<Map<String, Object>>> metadata = (List<List<Map<String, Object>>>) itemMap.get(1);
Object[] populatedStack = Rollback.populateItemStack(result, metadata);
result = (ItemStack) populatedStack[1];
int uses = (int) recipe.get(1);
int maxUses = (int) recipe.get(2);
boolean experienceReward = (boolean) recipe.get(3);
List<ItemStack> merchantIngredients = new ArrayList<>();
@SuppressWarnings("unchecked")
List<Object> ingredients = (List<Object>) recipe.get(4);
for (Object ingredient : ingredients) {
@SuppressWarnings("unchecked")
List<Object> ingredientMap = (List<Object>) ingredient;
@SuppressWarnings("unchecked")
ItemStack item = ItemStack.deserialize((Map<String, Object>) ingredientMap.get(0));
@SuppressWarnings("unchecked")
List<List<Map<String, Object>>> itemMetaData = (List<List<Map<String, Object>>>) ingredientMap.get(1);
populatedStack = Rollback.populateItemStack(item, itemMetaData);
item = (ItemStack) populatedStack[1];
merchantIngredients.add(item);
}
MerchantRecipe merchantRecipe = new MerchantRecipe(result, uses, maxUses, experienceReward);
if (recipe.size() > 6) {
int villagerExperience = (int) recipe.get(5);
float priceMultiplier = (float) recipe.get(6);
merchantRecipe = new MerchantRecipe(result, uses, maxUses, experienceReward, villagerExperience, priceMultiplier);
}
merchantRecipe.setIngredients(merchantIngredients);
merchantRecipes.add(merchantRecipe);
}
if (!merchantRecipes.isEmpty()) {
abstractVillager.setRecipes(merchantRecipes);
}
}
else {
Villager villager = (Villager) abstractVillager;
if (count == 3) {
int set = (int) value;
villager.setVillagerLevel(set);
}
else if (count == 4) {
int set = (int) value;
villager.setVillagerExperience(set);
}
}
}
else if (entity instanceof Raider) {
Raider raider = (Raider) entity;
if (count == 0) {
boolean set = (Boolean) value;
raider.setPatrolLeader(set);
}
if (entity instanceof Spellcaster && count == 1) {
Spellcaster spellcaster = (Spellcaster) entity;
Spell set = (Spell) value;
spellcaster.setSpell(set);
}
}
else if (entity instanceof Wolf) {
Wolf wolf = (Wolf) entity;
if (count == 0) {
boolean set = (Boolean) value;
wolf.setSitting(set);
}
else if (count == 1) {
DyeColor set = (DyeColor) value;
wolf.setCollarColor(set);
}
}
else if (entity instanceof ZombieVillager) {
ZombieVillager zombieVillager = (ZombieVillager) entity;
if (count == 0) {
boolean set = (Boolean) value;
zombieVillager.setBaby(set);
}
else if (count == 1) {
Profession set = (Profession) value;
zombieVillager.setVillagerProfession(set);
}
}
else if (entity instanceof Zombie) {
Zombie zombie = (Zombie) entity;
if (count == 0) {
boolean set = (Boolean) value;
zombie.setBaby(set);
}
}
else if (entity instanceof AbstractHorse) {
AbstractHorse abstractHorse = (AbstractHorse) entity;
if (count == 0 && value != null) {
// deprecated
boolean set = (Boolean) value;
if (entity instanceof ChestedHorse) {
ChestedHorse chestedHorse = (ChestedHorse) entity;
chestedHorse.setCarryingChest(set);
}
}
else if (count == 1 && value != null) {
// deprecated
org.bukkit.entity.Horse.Color set = (org.bukkit.entity.Horse.Color) value;
if (entity instanceof Horse) {
Horse horse = (Horse) entity;
horse.setColor(set);
}
}
else if (count == 2) {
int set = (Integer) value;
abstractHorse.setDomestication(set);
}
else if (count == 3) {
double set = (Double) value;
abstractHorse.setJumpStrength(set);
}
else if (count == 4) {
int set = (Integer) value;
abstractHorse.setMaxDomestication(set);
}
else if (count == 5 && value != null) {
// deprecated
Style set = (Style) value;
Horse horse = (Horse) entity;
horse.setStyle(set);
}
if (entity instanceof Horse) {
Horse horse = (Horse) entity;
if (count == 8) {
if (value != null) {
@SuppressWarnings("unchecked")
ItemStack set = ItemStack.deserialize((Map<String, Object>) value);
horse.getInventory().setSaddle(set);
}
}
else if (count == 9) {
org.bukkit.entity.Horse.Color set = (org.bukkit.entity.Horse.Color) value;
horse.setColor(set);
}
else if (count == 10) {
Style set = (Style) value;
horse.setStyle(set);
}
else if (count == 11) {
if (value != null) {
@SuppressWarnings("unchecked")
ItemStack set = ItemStack.deserialize((Map<String, Object>) value);
horse.getInventory().setArmor(set);
}
}
else if (count == 12 && value != null) {
@SuppressWarnings("unchecked")
org.bukkit.Color set = org.bukkit.Color.deserialize((Map<String, Object>) value);
ItemStack armor = horse.getInventory().getArmor();
if (armor != null) {
ItemMeta itemMeta = armor.getItemMeta();
if (itemMeta instanceof LeatherArmorMeta) {
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) itemMeta;
leatherArmorMeta.setColor(set);
armor.setItemMeta(leatherArmorMeta);
}
}
}
}
else if (entity instanceof ChestedHorse) {
if (count == 7) {
ChestedHorse chestedHorse = (ChestedHorse) entity;
boolean set = (Boolean) value;
chestedHorse.setCarryingChest(set);
}
if (entity instanceof Llama) {
Llama llama = (Llama) entity;
if (count == 8) {
if (value != null) {
@SuppressWarnings("unchecked")
ItemStack set = ItemStack.deserialize((Map<String, Object>) value);
llama.getInventory().setDecor(set);
}
}
else if (count == 9) {
Llama.Color set = (Llama.Color) value;
llama.setColor(set);
}
}
}
}
else {
BukkitAdapter.ADAPTER.setEntityMeta(entity, value, count);
}
count++;
}
}
catch (Exception e) {
e.printStackTrace();
}
});
}
}
@@ -0,0 +1,169 @@
package net.coreprotect.utility.entity;
import java.util.Locale;
import org.bukkit.Art;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Painting;
import org.bukkit.inventory.ItemStack;
import net.coreprotect.CoreProtect;
import net.coreprotect.bukkit.BukkitAdapter;
import net.coreprotect.model.BlockGroup;
import net.coreprotect.utility.Util;
public class HangingUtil {
private HangingUtil() {
throw new IllegalStateException("Utility class");
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void spawnHanging(final BlockState blockstate, final Material rowType, final int rowData, int delay) {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CoreProtect.getInstance(), () -> {
try {
Block block = blockstate.getBlock();
int x = block.getX();
int y = block.getY();
int z = block.getZ();
for (Entity e : block.getChunk().getEntities()) {
if ((BukkitAdapter.ADAPTER.isItemFrame(rowType) && e instanceof ItemFrame) || (rowType.equals(Material.PAINTING) && e instanceof Painting)) {
Location el = e.getLocation();
if (el.getBlockX() == x && el.getBlockY() == y && el.getBlockZ() == z) {
e.remove();
break;
}
}
}
Block c1 = block.getWorld().getBlockAt((x + 1), y, z);
Block c2 = block.getWorld().getBlockAt((x - 1), y, z);
Block c3 = block.getWorld().getBlockAt(x, y, (z + 1));
Block c4 = block.getWorld().getBlockAt(x, y, (z - 1));
BlockFace faceSet = null;
if (!BlockGroup.NON_ATTACHABLE.contains(c1.getType())) {
faceSet = BlockFace.WEST;
block = c1;
}
else if (!BlockGroup.NON_ATTACHABLE.contains(c2.getType())) {
faceSet = BlockFace.EAST;
block = c2;
}
else if (!BlockGroup.NON_ATTACHABLE.contains(c3.getType())) {
faceSet = BlockFace.NORTH;
block = c3;
}
else if (!BlockGroup.NON_ATTACHABLE.contains(c4.getType())) {
faceSet = BlockFace.SOUTH;
block = c4;
}
BlockFace face = null;
if (!Util.solidBlock(Util.getType(block.getRelative(BlockFace.EAST)))) {
face = BlockFace.EAST;
}
else if (!Util.solidBlock(Util.getType(block.getRelative(BlockFace.NORTH)))) {
face = BlockFace.NORTH;
}
else if (!Util.solidBlock(Util.getType(block.getRelative(BlockFace.WEST)))) {
face = BlockFace.WEST;
}
else if (!Util.solidBlock(Util.getType(block.getRelative(BlockFace.SOUTH)))) {
face = BlockFace.SOUTH;
}
if (faceSet != null && face != null) {
if (rowType.equals(Material.PAINTING)) {
String name = Util.getArtName(rowData);
Art painting = Art.getByName(name.toUpperCase(Locale.ROOT));
int height = painting.getBlockHeight();
int width = painting.getBlockWidth();
int paintingX = x;
int paintingY = y;
int paintingZ = z;
if (height != 1 || width != 1) {
if (height > 1) {
if (height != 3) {
paintingY = paintingY - 1;
}
}
if (width > 1) {
if (faceSet.equals(BlockFace.WEST)) {
paintingZ--;
}
else if (faceSet.equals(BlockFace.SOUTH)) {
paintingX--;
}
}
}
Block spawnBlock = block.getRelative(face);
Util.setTypeAndData(spawnBlock, Material.AIR, null, true);
Painting hanging = null;
try {
hanging = block.getWorld().spawn(spawnBlock.getLocation(), Painting.class);
}
catch (Exception e) {
}
if (hanging != null) {
hanging.teleport(block.getWorld().getBlockAt(paintingX, paintingY, paintingZ).getLocation());
hanging.setFacingDirection(faceSet, true);
hanging.setArt(painting, true);
}
}
else if (BukkitAdapter.ADAPTER.isItemFrame(rowType)) {
try {
Block spawnBlock = block.getRelative(face);
Util.setTypeAndData(spawnBlock, Material.AIR, null, true);
Class itemFrame = BukkitAdapter.ADAPTER.getFrameClass(rowType);
Entity entity = block.getWorld().spawn(spawnBlock.getLocation(), itemFrame);
if (entity instanceof ItemFrame) {
ItemFrame hanging = (ItemFrame) entity;
hanging.teleport(block.getWorld().getBlockAt(x, y, z).getLocation());
hanging.setFacingDirection(faceSet, true);
Material type = Util.getType(rowData);
if (type != null) {
ItemStack istack = new ItemStack(type, 1);
hanging.setItem(istack);
}
}
}
catch (Exception e) {
}
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}, delay);
}
public static void removeHanging(final BlockState block, int delay) {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CoreProtect.getInstance(), () -> {
try {
for (Entity e : block.getChunk().getEntities()) {
if (e instanceof ItemFrame || e instanceof Painting) {
Location el = e.getLocation();
if (el.getBlockX() == block.getX() && el.getBlockY() == block.getY() && el.getBlockZ() == block.getZ()) {
e.remove();
}
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}, delay);
}
}