Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5d063dced | ||
|
|
f0779d288c | ||
|
|
550c3038b8 | ||
|
|
d864bbe233 | ||
|
|
fc99c24a0a | ||
|
|
2d90f9cc08 | ||
|
|
ba0ad6c15c | ||
|
|
370558cec5 | ||
|
|
69184302c9 | ||
|
|
a61df070e6 | ||
|
|
3742e018c4 | ||
|
|
554e17df02 | ||
|
|
bc39bc03d6 | ||
|
|
da718de252 | ||
|
|
39cd888440 | ||
|
|
697ad1b3ce | ||
|
|
922e4478dc | ||
|
|
2fd366389b | ||
|
|
5e3a19f208 | ||
|
|
37d49a0900 |
No files matched your search
@@ -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
|
||||
@@ -13,10 +13,10 @@ 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 16
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: '8'
|
||||
java-version: '16'
|
||||
distribution: 'adopt-hotspot'
|
||||
- name: Cache Maven packages
|
||||
uses: actions/cache@v1
|
||||
|
||||
+4
-2
@@ -7,7 +7,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'net.coreprotect'
|
||||
String projectVersion = '20.1'
|
||||
String projectVersion = '20.2'
|
||||
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
@@ -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.
|
||||
|
||||
|
||||
+197
@@ -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
@@ -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}: 合并{启用|禁用}."
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.coreprotect</groupId>
|
||||
<artifactId>CoreProtect</artifactId>
|
||||
<version>20.1</version>
|
||||
<version>20.2</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
@@ -1 +1 @@
|
||||
mkdocs==1.2.1
|
||||
mkdocs==1.2.3
|
||||
@@ -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;
|
||||
@@ -488,7 +487,6 @@ public class CoreProtectAPI extends Queue {
|
||||
}
|
||||
|
||||
statement.close();
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
@@ -22,25 +22,25 @@ 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 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:
|
||||
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));
|
||||
|
||||
@@ -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;
|
||||
@@ -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));
|
||||
@@ -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));
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package net.coreprotect.command;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.*;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -94,14 +91,12 @@ public class PurgeCommand extends Consumer {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
try (Connection connection = Database.getConnection(false, 500)) {
|
||||
int timestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||
int ptime = timestamp - seconds;
|
||||
long removed = 0;
|
||||
|
||||
Connection connection = null;
|
||||
for (int i = 0; i <= 5; i++) {
|
||||
connection = Database.getConnection(false, 500);
|
||||
if (connection != null) {
|
||||
break;
|
||||
}
|
||||
@@ -344,8 +339,6 @@ public class PurgeCommand extends Consumer {
|
||||
}
|
||||
}
|
||||
|
||||
connection.close();
|
||||
|
||||
if (abort) {
|
||||
if (!Config.getGlobal().MYSQL) {
|
||||
(new File(ConfigHandler.path + ConfigHandler.sqlite + ".tmp")).delete();
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -14,6 +14,8 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -28,6 +30,7 @@ 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,12 @@ public class ConfigHandler extends Queue {
|
||||
}
|
||||
|
||||
public static void loadDatabase() {
|
||||
// close old pool when we reload the database, e.g. in purge command
|
||||
if (ConfigHandler.hikariDataSource != null) {
|
||||
ConfigHandler.hikariDataSource.close();
|
||||
ConfigHandler.hikariDataSource = null;
|
||||
}
|
||||
|
||||
if (!Config.getGlobal().MYSQL) {
|
||||
try {
|
||||
File tempFile = File.createTempFile("CoreProtect_" + System.currentTimeMillis(), ".tmp");
|
||||
@@ -197,11 +207,29 @@ public class ConfigHandler extends Queue {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
HikariConfig config = new HikariConfig();
|
||||
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("useSSL", "false");
|
||||
|
||||
ConfigHandler.hikariDataSource = new HikariDataSource(config);
|
||||
}
|
||||
|
||||
if (ConfigHandler.serverRunning) {
|
||||
Consumer.resetConnection = true;
|
||||
}
|
||||
Database.createDatabaseTables(ConfigHandler.prefix, false);
|
||||
}
|
||||
|
||||
@@ -361,12 +389,17 @@ 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 +427,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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.coreprotect.consumer.process;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
@@ -45,36 +46,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 +68,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 +171,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 +219,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 +263,6 @@ public class Process {
|
||||
users.clear();
|
||||
consumerObject.clear();
|
||||
consumerData.clear();
|
||||
|
||||
if (lastRun) {
|
||||
connection.close();
|
||||
connection = null;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -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) {
|
||||
@@ -316,8 +308,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 +348,6 @@ public class Database extends Queue {
|
||||
initializeTables(prefix, statement);
|
||||
}
|
||||
statement.close();
|
||||
connection.close();
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
@@ -369,8 +359,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 +542,6 @@ public class Database extends Queue {
|
||||
initializeTables(prefix, statement);
|
||||
}
|
||||
statement.close();
|
||||
connection.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -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;
|
||||
@@ -685,6 +686,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 +1096,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++;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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("io.papermc.paper.event.player.AsyncChatEvent");
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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,47 @@
|
||||
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 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:
|
||||
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,29 @@ 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 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:
|
||||
default:
|
||||
SpigotAdapter.ADAPTER = new Spigot_v1_16();
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user