Compare commits
419 Commits
Author | SHA1 | Date |
---|---|---|
filoghost | 6f343c5fc0 | |
filoghost | 9dcf6035fe | |
filoghost | 0754e0ac33 | |
filoghost | ed3bbad1fb | |
filoghost | 667668f0f0 | |
filoghost | c14141679f | |
filoghost | 563df95561 | |
Spongecade | 3f067145b7 | |
rayanbzd | 9fd3bf2d0f | |
rayanbzd | 0b289b017b | |
filoghost | 07968520f0 | |
filoghost | 51fc2d0bd4 | |
filoghost | 5d22e2754d | |
Sascha Bartl | a3c82bfddf | |
filoghost | 2fa71ad3e0 | |
filoghost | 917db5ad94 | |
filoghost | 705abee6a3 | |
filoghost | 3727868dff | |
filoghost | fab8c9594d | |
filoghost | ef890acacd | |
filoghost | 2b5afc82af | |
filoghost | d057dd750c | |
filoghost | 27ebb9d2d8 | |
filoghost | 70779348af | |
filoghost | dd1f6f024d | |
filoghost | 5d2c97f194 | |
filoghost | 788cdc2c45 | |
filoghost | a5d9f58df3 | |
filoghost | 850beaebb8 | |
filoghost | 2f83fdcfdb | |
filoghost | 39e51328cc | |
filoghost | 017b0a2346 | |
filoghost | 80344c8503 | |
filoghost | 39f0a02412 | |
filoghost | 0e98b2f89a | |
filoghost | 0449fe65ca | |
filoghost | 37e411b978 | |
filoghost | d670fae7ab | |
filoghost | d76739d332 | |
filoghost | 39f3f49504 | |
filoghost | 8ddb63835d | |
filoghost | 777b696f38 | |
filoghost | c7e0f64469 | |
filoghost | 459abdc2f8 | |
filoghost | c850488ba7 | |
filoghost | d58adb7db8 | |
filoghost | 4431605a3a | |
filoghost | 018acd8299 | |
filoghost | 7a63325620 | |
filoghost | da763ca8e9 | |
filoghost | 624d206086 | |
filoghost | 5bab55fb79 | |
filoghost | 2875020583 | |
filoghost | 8018e52bbb | |
filoghost | e0d47284b7 | |
filoghost | 5727de44dc | |
filoghost | 370eb9806f | |
filoghost | d35648b4e4 | |
filoghost | 525622b59a | |
filoghost | 323998845b | |
filoghost | 32fc16b2c3 | |
filoghost | 619bc79cd8 | |
filoghost | bf02837f9e | |
filoghost | c6a14285a0 | |
filoghost | da25d050ab | |
filoghost | 0cd4ac8f3e | |
filoghost | bf39afb630 | |
filoghost | 72e17365d6 | |
filoghost | 559cba600c | |
filoghost | 54bc45ebb9 | |
filoghost | 28479a85a9 | |
filoghost | 6bee8d4d17 | |
filoghost | 0718e4ab80 | |
filoghost | a8269e7867 | |
filoghost | cb12515755 | |
filoghost | 928609efb7 | |
filoghost | 38a99b95e1 | |
filoghost | fda3f4b933 | |
filoghost | 045f363adb | |
filoghost | 2d177edced | |
filoghost | 370558d4ce | |
filoghost | b89e6264bb | |
filoghost | 2789a24295 | |
filoghost | 58907f075f | |
filoghost | 4a8fd6a6fa | |
SilverFox | b7663926d7 | |
filoghost | 9dbdbc36fd | |
filoghost | 1ee23d4398 | |
filoghost | a1d3eb5e26 | |
filoghost | 243bf9ea0a | |
filoghost | ae7591f952 | |
filoghost | aade3ddbfe | |
filoghost | 90e26af19b | |
filoghost | e25c2aca40 | |
filoghost | dccafdc839 | |
filoghost | 62e3cb563f | |
filoghost | 749d1ff5a0 | |
filoghost | 76af200af9 | |
filoghost | 68b6a8bf30 | |
filoghost | b23abef7ab | |
filoghost | 6ac35d3d62 | |
filoghost | c1a223a863 | |
filoghost | 014f53dbce | |
filoghost | 911170e50c | |
filoghost | 69f2ecbd23 | |
filoghost | 4e21d317f3 | |
filoghost | e1818a5a24 | |
filoghost | a8fcacefea | |
filoghost | 9be9ecb2ac | |
filoghost | 2c4aaa3f51 | |
filoghost | fdd76f179e | |
filoghost | 1a9a80fe36 | |
filoghost | 33ec96172c | |
filoghost | ce437d21d3 | |
filoghost | 2b062f35bf | |
filoghost | 8a80c063b7 | |
filoghost | 6f6a214ecd | |
filoghost | e8b2239c47 | |
filoghost | 66bdda8bed | |
filoghost | 11d57d40b7 | |
filoghost | 651ac2f019 | |
filoghost | 7700675e8b | |
filoghost | b7b922fb37 | |
filoghost | d97751100e | |
filoghost | 1da71326d7 | |
filoghost | 769d3dacb2 | |
filoghost | dc9f0fe2b4 | |
filoghost | b4c8c6ede4 | |
filoghost | 3935af2bf9 | |
filoghost | 33c2693172 | |
filoghost | 0a80d91d5b | |
filoghost | 15a7372c43 | |
filoghost | 05488268b0 | |
filoghost | 03b6437f23 | |
filoghost | 134eba5f41 | |
filoghost | f900dbe690 | |
filoghost | b342a0b37e | |
filoghost | a942c1725a | |
filoghost | 899ade7ce2 | |
filoghost | cd6dd1b4d2 | |
filoghost | 7db51a6dae | |
filoghost | 9ff7b0d7b6 | |
filoghost | c27c34dd64 | |
filoghost | b97fe93f96 | |
filoghost | 40d7876bd8 | |
filoghost | d2130fe162 | |
filoghost | 6ae9ec8292 | |
filoghost | 5de079917e | |
filoghost | cf2ca694bf | |
filoghost | 8a9642d7fc | |
filoghost | 11abb356d6 | |
filoghost | 76381660a3 | |
filoghost | 66d49727b8 | |
filoghost | da2b221642 | |
filoghost | 7f70cd7b08 | |
filoghost | 7efacd31f9 | |
filoghost | 0b5a059a2f | |
filoghost | 92e18395b4 | |
filoghost | 3008f28fb2 | |
filoghost | 2ddb972128 | |
filoghost | ed803fc4f6 | |
filoghost | 1aa8a17dab | |
filoghost | 2da7d318df | |
filoghost | dba767dd79 | |
filoghost | ca5644153e | |
filoghost | 087105ccd1 | |
filoghost | b4e5edfa8e | |
filoghost | c2ff8f536c | |
filoghost | ac0bde854d | |
filoghost | b3d8aae193 | |
filoghost | 41fb1bc347 | |
filoghost | ad1cfe3f1f | |
filoghost | 614a56ca8a | |
filoghost | 55f690cec9 | |
filoghost | 9e966ea185 | |
filoghost | 163b881837 | |
filoghost | 9fc8fceea7 | |
filoghost | ec5cf3ca94 | |
filoghost | 903c94657b | |
filoghost | 4f03b2e4e3 | |
filoghost | 2cf789c8f2 | |
filoghost | 14541eb25d | |
filoghost | e1009b8cd8 | |
filoghost | f61ba7a02c | |
filoghost | a7b9b72f96 | |
filoghost | 4f86a8e9c2 | |
filoghost | 2d0969e171 | |
filoghost | 3c10663c41 | |
filoghost | 8ca4108d4c | |
filoghost | f5e320a420 | |
filoghost | cc8b068bf0 | |
filoghost | db24dfe965 | |
filoghost | dc87be4e4a | |
filoghost | 36e1d44d18 | |
filoghost | 88bfa7c662 | |
filoghost | 9d70087130 | |
filoghost | b9d04d7f5c | |
filoghost | 176187e0c9 | |
filoghost | 7fb38d82e4 | |
filoghost | 150cc4c62b | |
filoghost | 9b21ffdf76 | |
filoghost | 5225d34cb6 | |
filoghost | 72cdacb998 | |
filoghost | 4dc46456a3 | |
filoghost | 15f88dacb3 | |
filoghost | 0a1f7998e9 | |
filoghost | 14c7ebce69 | |
filoghost | 1be79f05b0 | |
filoghost | a1bafc4366 | |
filoghost | f221f1ed72 | |
filoghost | e3179576e4 | |
filoghost | 3432a33ae6 | |
filoghost | 2d99a0c36a | |
filoghost | e161dd18f9 | |
filoghost | d94cb681a8 | |
filoghost | 47c98100ff | |
filoghost | 8b12e3e2c5 | |
filoghost | e7e27885b3 | |
filoghost | 016de63f93 | |
filoghost | de3366a8a2 | |
filoghost | d251998cdd | |
filoghost | 365366d929 | |
filoghost | 32be6b8654 | |
filoghost | 7a6ea7b789 | |
filoghost | 2641ec7c0f | |
filoghost | bb48855396 | |
filoghost | 54d089bf04 | |
filoghost | 089d1eaa7c | |
filoghost | 63efbf40fb | |
filoghost | 56ca2125fa | |
filoghost | 07b55853dc | |
filoghost | b9d55363c6 | |
filoghost | 4e028efb27 | |
filoghost | b8860a9d60 | |
filoghost | c6b6ec1a42 | |
filoghost | 7e0f23f220 | |
filoghost | 665d8bb367 | |
filoghost | ca50d9247d | |
filoghost | 825b0f2b2e | |
filoghost | 1d44491457 | |
filoghost | 8cac729a82 | |
filoghost | f470dddc40 | |
filoghost | 55643651c9 | |
filoghost | 438dcfb1dc | |
filoghost | f3d3d07038 | |
filoghost | e406dfc9a5 | |
filoghost | 88b260ffb9 | |
filoghost | ed73b8e098 | |
filoghost | 51b0f7fd30 | |
filoghost | 6be5f00f53 | |
filoghost | 98f27b73b4 | |
filoghost | 496fd4ae41 | |
filoghost | 6d54e73518 | |
filoghost | 003181c256 | |
filoghost | 21280b0b1f | |
filoghost | ce2dfd993b | |
filoghost | 1440a88387 | |
filoghost | 7d86538621 | |
filoghost | 11664497cc | |
filoghost | 948b7c4eb2 | |
filoghost | c22f01c017 | |
filoghost | bbc08034f1 | |
filoghost | 3539ae6a01 | |
filoghost | 6d5c1e4a30 | |
filoghost | 05826266a5 | |
filoghost | 2e68e95497 | |
filoghost | 6948afcfa9 | |
filoghost | 0cb6fed921 | |
filoghost | e67bfcd750 | |
filoghost | 41e54d801e | |
filoghost | 1871fbc8b7 | |
filoghost | 71de987628 | |
filoghost | 1eb58dfd0a | |
filoghost | f6c7fd5f0f | |
filoghost | 08410feb48 | |
filoghost | 43427d6f81 | |
filoghost | fca1de85e0 | |
filoghost | 4399fd90a7 | |
filoghost | 0b649ff612 | |
filoghost | 157be9b679 | |
filoghost | b8dde1ab3e | |
filoghost | b594f79a2b | |
filoghost | d52e374969 | |
filoghost | fa7c34ccf9 | |
filoghost | aa1a8d1232 | |
filoghost | a2c6e1efe6 | |
filoghost | 5de53c541a | |
filoghost | 78713fde8b | |
filoghost | 95fd02b507 | |
filoghost | 37cc961cab | |
filoghost | 8ef99b0352 | |
filoghost | ad7003c939 | |
filoghost | 39d4e450d7 | |
filoghost | 2ebad9cbe1 | |
filoghost | ae07fe0bb5 | |
filoghost | 860d586750 | |
filoghost | 46b4fd6bd7 | |
filoghost | 31f0ba206d | |
filoghost | 4e47f5cf7c | |
filoghost | 7b269ba0b1 | |
filoghost | c190f10092 | |
filoghost | f73e8405ea | |
filoghost | 50b9ede70c | |
filoghost | 73f0d23410 | |
filoghost | 22bacead97 | |
filoghost | 08d3219c37 | |
filoghost | dfcc597a02 | |
filoghost | eeec178e65 | |
filoghost | 5543edd47b | |
filoghost | ed75cdee08 | |
filoghost | 664c6c6151 | |
filoghost | f5d37f59df | |
filoghost | 849d685b6b | |
filoghost | 3e1f6d02b4 | |
filoghost | e0bb4635df | |
filoghost | 464c5804e6 | |
filoghost | fb68b946d2 | |
filoghost | b2989814b8 | |
filoghost | 864f76eac6 | |
filoghost | 33bdce7915 | |
filoghost | 23029e874e | |
filoghost | f9a6163363 | |
filoghost | 71bf06a8b5 | |
filoghost | d58e9fe0a9 | |
filoghost | 123e9fb45c | |
filoghost | 9e05bb61cb | |
filoghost | 3f14a67b73 | |
filoghost | bbb397068b | |
filoghost | ffd0351a70 | |
filoghost | e8c4f58d9a | |
filoghost | d67480749b | |
filoghost | c1cd5b200c | |
filoghost | 305931bd73 | |
filoghost | f370dfff4f | |
filoghost | 85f85e9b2c | |
filoghost | ae89ad25b1 | |
filoghost | 523b866f8e | |
filoghost | 949018c60f | |
filoghost | a31f29cb32 | |
filoghost | 40d18d1235 | |
filoghost | 1906cadf96 | |
filoghost | dfb6e0ab33 | |
filoghost | fe54ed7dc7 | |
filoghost | 29d43525b4 | |
filoghost | 415f1c51bc | |
filoghost | 4f25e6550b | |
filoghost | fe626053e6 | |
filoghost | 9f7e2915c1 | |
filoghost | de3f967a21 | |
filoghost | aacc7fdeb4 | |
filoghost | 177598ae78 | |
filoghost | 588e2ed394 | |
filoghost | a7a7fcc68b | |
filoghost | 1f6adc8679 | |
filoghost | ee76d568dc | |
filoghost | b2cd0abfe7 | |
filoghost | 5bcf735808 | |
filoghost | 8bdac17719 | |
filoghost | aba0897dc7 | |
filoghost | 03689e208b | |
filoghost | 92bcda8f2d | |
filoghost | ff77738a51 | |
filoghost | d8930febfc | |
filoghost | 276d35bb72 | |
filoghost | 750e74360a | |
filoghost | 19f3a87ba3 | |
filoghost | dc567af24c | |
filoghost | f97c21e645 | |
filoghost | 57fd78eac5 | |
filoghost | 9a56a032de | |
filoghost | 6cc28cc957 | |
filoghost | f474684693 | |
filoghost | 4d3ccd1a2e | |
filoghost | 977a422bb3 | |
filoghost | c694877780 | |
filoghost | ae0a8d0a79 | |
filoghost | 5b4a9348cd | |
filoghost | 5371acfd2c | |
filoghost | 65a54165eb | |
filoghost | c332547f38 | |
filoghost | a8a44bec90 | |
filoghost | cc0ef3bf7b | |
filoghost | 470b8bfcbd | |
filoghost | f7bc9b950f | |
filoghost | a96e9e516f | |
filoghost | dbfabc0e83 | |
filoghost | f42ad75ca3 | |
filoghost | 3b127c3d90 | |
filoghost | 13e8fcf070 | |
filoghost | 6c58062940 | |
filoghost | a295243019 | |
filoghost | c17de21313 | |
filoghost | 0ff3b28fdd | |
filoghost | acd83a6fe6 | |
filoghost | 40e1967d20 | |
filoghost | d71df75036 | |
filoghost | b5852116d4 | |
filoghost | b2b03f3e40 | |
filoghost | aa8aad2b83 | |
filoghost | 1f32c7127c | |
filoghost | 530fb2c23e | |
filoghost | a4900759c9 | |
filoghost | fc7e147b73 | |
filoghost | f88d8965b2 | |
filoghost | 836bd511da | |
filoghost | 0b72d1e994 | |
filoghost | f320c3eb15 | |
filoghost | 90dbfa5c07 | |
filoghost | 0f3f7b5f9d | |
filoghost | b60c7818d6 | |
filoghost | 09f99be342 | |
filoghost | 9c97e0ed39 | |
filoghost | 9281515385 | |
filoghost | cca12d1aa5 | |
filoghost | 02c15aa354 | |
filoghost | fb41de5651 | |
filoghost | 6f64e09508 | |
filoghost | 069e1fffbd | |
filoghost | d98708f6ae |
|
@ -1,38 +0,0 @@
|
|||
---
|
||||
name: 🐞 Bug report
|
||||
about: Report a bug or some unexpected behavior.
|
||||
labels: Bug
|
||||
---
|
||||
<!--
|
||||
|
||||
⚠️ READ BELOW BEFOR SUBMITTING ⚠️
|
||||
|
||||
Before opening a bug report:
|
||||
* Read the FAQ: https://filoghost.me/docs/holographic-displays/faq
|
||||
* Try the latest development build: https://ci.codemc.io/job/filoghost/job/HolographicDisplays
|
||||
* Make sure the bug hasn't already been reported (you can add comments to the existing issue)
|
||||
|
||||
Don't paste long text files in the description, upload them as attachments or on Pastebin.
|
||||
|
||||
You MUST fill out the template below, without modifying or deleting the existing text, otherwise the issue will be automatically closed.
|
||||
|
||||
-->
|
||||
|
||||
### Description
|
||||
<!-- Write a clear and concise description of the bug -->
|
||||
|
||||
|
||||
### How to reproduce
|
||||
<!-- A list of steps to reproduce the bug -->
|
||||
|
||||
|
||||
### Platform
|
||||
<!-- Fill in the list below -->
|
||||
- Server version (output of `/version`):
|
||||
- Holographic Displays version (check with `/hd`):
|
||||
- ProtocolLib version, if installed (check with `/protocol version`):
|
||||
- Do you use plugins to allow players to join with multiple Minecraft versions (such as ViaVersion, ProtocolSupport, ...):
|
||||
|
||||
|
||||
### Additional context
|
||||
<!-- Screenshots, errors, configurations (if relevant) -->
|
|
@ -1,17 +0,0 @@
|
|||
---
|
||||
name: 💡 Suggestion
|
||||
about: "Suggest a new feature or an improvement. ⚠ Note: suggestions have low priority, I will answer them only if possible."
|
||||
labels: Enhancement
|
||||
---
|
||||
<!--
|
||||
|
||||
⚠️ READ BELOW BEFOR SUBMITTING ⚠️
|
||||
|
||||
Please only suggest changes that would benefit many users, not just a specific situation.
|
||||
|
||||
You MUST fill out the template below, without modifying or deleting the existing text, otherwise the issue will be automatically closed.
|
||||
|
||||
-->
|
||||
|
||||
### Description
|
||||
<!-- Describe the new feature or the improvement you would like to see -->
|
|
@ -1,38 +0,0 @@
|
|||
---
|
||||
name: 📝 Help request
|
||||
about: "Ask a question about the plugin. ⚠ Note: help requests have low priority, I will answer them only if possible."
|
||||
labels: Help
|
||||
---
|
||||
<!--
|
||||
|
||||
⚠️ READ BELOW BEFOR SUBMITTING ⚠️
|
||||
|
||||
Before asking for help:
|
||||
* Read the documentation: https://filoghost.me/docs/holographic-displays
|
||||
* Read the FAQ: https://filoghost.me/docs/holographic-displays/faq
|
||||
* Update the plugin: https://dev.bukkit.org/projects/holographic-displays
|
||||
|
||||
Don't paste long text files in the description, upload them as attachments or on Pastebin.
|
||||
|
||||
You MUST fill out the template below, without modifying or deleting the existing text, otherwise the issue will be automatically closed.
|
||||
|
||||
-->
|
||||
|
||||
### What are you trying to do?
|
||||
<!-- Describe the goal you want to achieve -->
|
||||
|
||||
|
||||
### What have you tried so far?
|
||||
<!-- If you already tried something, please elaborate -->
|
||||
|
||||
|
||||
### Platform
|
||||
<!-- Fill in the list below -->
|
||||
- Server version (output of `/version`):
|
||||
- Holographic Displays version (check with `/hd`):
|
||||
- ProtocolLib version, if installed (check with `/protocol version`):
|
||||
- Do you use plugins to allow players to join with multiple Minecraft versions (such as ViaVersion, ProtocolSupport, ...):
|
||||
|
||||
|
||||
### Additional context
|
||||
<!-- Screenshots, errors, configurations (if relevant) -->
|
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
name: 📚 Documentation improvement
|
||||
about: "Request an improvement for the official documention."
|
||||
labels: Documentation
|
||||
---
|
||||
<!--
|
||||
|
||||
⚠️ READ BELOW BEFOR SUBMITTING ⚠️
|
||||
|
||||
You MUST fill out the template below, without modifying or deleting the existing text, otherwise the issue will be automatically closed.
|
||||
|
||||
-->
|
||||
|
||||
### Description
|
||||
<!-- Describe what should be improved (and if possible, how) -->
|
|
@ -0,0 +1,73 @@
|
|||
name: 🐞 Bug Report
|
||||
description: "Report a bug or some unexpected behavior."
|
||||
labels:
|
||||
- "Bug"
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |-
|
||||
Please fill this form carefully and provide the requested details. Thank you for contributing to the project.
|
||||
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: "Confirmation"
|
||||
description: "Please confirm to have done the following checks before opening a new issue."
|
||||
options:
|
||||
- label: "I have read the [FAQ](https://filoghost.me/docs/holographic-displays/faq)."
|
||||
required: true
|
||||
- label: "I have tested the [latest development build](https://ci.codemc.io/job/filoghost/job/HolographicDisplays) of Holographic Displays and the bug is still present."
|
||||
required: true
|
||||
- label: "I have updated **Spigot** to the latest release for my particular Minecraft version."
|
||||
required: true
|
||||
- label: "I made sure the bug hasn't already been reported on the [issue tracker](https://github.com/filoghost/HolographicDisplays/issues?q=is%3Aissue)."
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Description"
|
||||
description: |-
|
||||
Clear and concise description of the bug.
|
||||
<ins>**Avoid long error logs**</ins>, add them in the "Addition information" area at the bottom of this form.
|
||||
placeholder: "What happened? What did you expect to happen instead?"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "How to reproduce"
|
||||
description: "List of steps to reproduce the bug."
|
||||
placeholder: |-
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
label: "Server version"
|
||||
description: "Output of the command `/version`."
|
||||
placeholder: "This server is running CraftBukkit version 3132-Spigot-66f9d3c-40caacc (MC: 1.17) (Implementing API version 1.17-R0.1-SNAPSHOT)"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
label: "Holographic Displays version"
|
||||
description: "Output of the command `/version HolographicDisplays`."
|
||||
placeholder: "HolographicDisplays version 2.4.8-SNAPSHOT-b174"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
label: "Installed plugins that allow players to join with multiple Minecraft versions"
|
||||
description: "List plugins such as ViaVersion, ViaBackwards, ProtocolSupport that you're using (if any)."
|
||||
placeholder: "ViaVersion, ViaBackwards"
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Additional information
|
||||
description: |-
|
||||
Relevant attachments such as **screenshots**, **server logs**, **configurations files** or any other additional information that might be useful.
|
||||
Text files can also be uploaded to [Pastebin](https://pastebin.com) and shared through the generated link.
|
|
@ -1,33 +0,0 @@
|
|||
comment: >-
|
||||
This issue has been automatically closed because it doesn't follow the issue template.
|
||||
|
||||
|
||||
Please open a new issue and make sure to **follow the provided template**,
|
||||
fill out the sections **without modifying** or **deleting** the existing text.
|
||||
|
||||
|
||||
Templates are necessary to manage the project efficiently,
|
||||
as basic questions don't need to be asked again each time.
|
||||
|
||||
issueConfigs:
|
||||
|
||||
# Bug
|
||||
- content:
|
||||
- "# Description"
|
||||
- "# How to reproduce"
|
||||
- "# Platform"
|
||||
|
||||
# Feature / Documentation
|
||||
- content:
|
||||
- "# Description"
|
||||
|
||||
# Help
|
||||
- content:
|
||||
- "# What are you trying to do"
|
||||
- "# What have you tried so far"
|
||||
- "# Platform"
|
||||
|
||||
caseInsensitive: true
|
||||
label: "Closed by bot"
|
||||
exception:
|
||||
- "filoghost"
|
29
API/pom.xml
29
API/pom.xml
|
@ -1,29 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-parent</artifactId>
|
||||
<version>2.4.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-api</artifactId>
|
||||
<name>HolographicDisplays API</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,220 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.ItemLine;
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.TextLine;
|
||||
|
||||
/**
|
||||
* An object made of various lines, that can be items or holograms.
|
||||
* Holographic lines appear as a nametag without any entity below.
|
||||
* To create one, please see {@link HologramsAPI#createHologram(org.bukkit.plugin.Plugin, Location)}.
|
||||
*/
|
||||
public interface Hologram {
|
||||
|
||||
/**
|
||||
* Appends a text line to end of this hologram.
|
||||
*
|
||||
* @param text the content of the line, can be null for an empty line
|
||||
* @return the new TextLine appended
|
||||
*/
|
||||
public TextLine appendTextLine(String text);
|
||||
|
||||
|
||||
/**
|
||||
* Appends an item line to end of this hologram.
|
||||
*
|
||||
* @param itemStack the content of the line
|
||||
* @return the new ItemLine appended
|
||||
*/
|
||||
public ItemLine appendItemLine(ItemStack itemStack);
|
||||
|
||||
|
||||
/**
|
||||
* Inserts a text line in this hologram.
|
||||
*
|
||||
* @param index the line is inserted before this index. If 0, the new line will
|
||||
* be inserted before the first line.
|
||||
* @param text the content of the line, can be null for an empty line
|
||||
* @return the new TextLine inserted
|
||||
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
||||
*/
|
||||
public TextLine insertTextLine(int index, String text);
|
||||
|
||||
|
||||
/**
|
||||
* Inserts an item line in this hologram.
|
||||
*
|
||||
* @param index the line is inserted before this index. If 0, the new line will
|
||||
* be inserted before the first line.
|
||||
* @param itemStack the content of the line
|
||||
* @return the new ItemLine inserted
|
||||
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
||||
*/
|
||||
public ItemLine insertItemLine(int index, ItemStack itemStack);
|
||||
|
||||
|
||||
/**
|
||||
* Finds the element at a given index in the lines.
|
||||
*
|
||||
* @param index the index of the line to retrieve.
|
||||
* @return the hologram line at the given index, can be an {@link ItemLine} or a {@link TextLine}.
|
||||
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
||||
*/
|
||||
public HologramLine getLine(int index);
|
||||
|
||||
/**
|
||||
* Removes a line at a given index. Since: v2.0.1
|
||||
*
|
||||
* @param index the index of the line, that should be between 0 and size() - 1.
|
||||
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
||||
*/
|
||||
public void removeLine(int index);
|
||||
|
||||
|
||||
/**
|
||||
* Removes all the lines from this hologram.
|
||||
*/
|
||||
public void clearLines();
|
||||
|
||||
|
||||
/**
|
||||
* Checks the amount of lines of the hologram.
|
||||
*
|
||||
* @return the amount of lines
|
||||
*/
|
||||
public int size();
|
||||
|
||||
|
||||
/**
|
||||
* The physical height of the hologram, counting all the lines. Since: v2.1.4
|
||||
*
|
||||
* @return the height of the hologram, counting all the lines and the gaps between them
|
||||
*/
|
||||
public double getHeight();
|
||||
|
||||
|
||||
/**
|
||||
* Teleports a hologram to the given location.
|
||||
*
|
||||
* @param location the new location
|
||||
*/
|
||||
public void teleport(Location location);
|
||||
|
||||
|
||||
/**
|
||||
* Teleports a hologram to the given location.
|
||||
*
|
||||
* @param world the world where the hologram should be teleported,
|
||||
* use {@link #getWorld()} to teleport it in the same world.
|
||||
* @param x the X coordinate
|
||||
* @param y the Y coordinate
|
||||
* @param z the Z coordinate
|
||||
*/
|
||||
public void teleport(World world, double x, double y, double z);
|
||||
|
||||
/**
|
||||
* Returns the position of the hologram.
|
||||
*
|
||||
* @return the Location of the hologram
|
||||
*/
|
||||
public Location getLocation();
|
||||
|
||||
/**
|
||||
* Returns the X coordinate.
|
||||
*
|
||||
* @return the X coordinate of the hologram
|
||||
*/
|
||||
public double getX();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the Y coordinate.
|
||||
*
|
||||
* @return the Y coordinate of the hologram
|
||||
*/
|
||||
public double getY();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the Z coordinate.
|
||||
*
|
||||
* @return the Z coordinate of the hologram
|
||||
*/
|
||||
public double getZ();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the world.
|
||||
*
|
||||
* @return the world of the hologram
|
||||
*/
|
||||
public World getWorld();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the {@link VisibilityManager} of this hologram.
|
||||
* <br><b style = "color: red">Note</b>: the usage of the VisibilityManager requires ProtocolLib.
|
||||
* Without the plugin, holograms will be always visible.
|
||||
*
|
||||
* @return the VisibilityManager of this hologram
|
||||
*/
|
||||
public VisibilityManager getVisibilityManager();
|
||||
|
||||
|
||||
/**
|
||||
* Returns when the hologram was created. Useful for removing old holograms.
|
||||
*
|
||||
* @return the timestamp of when the hologram was created, in milliseconds
|
||||
*/
|
||||
public long getCreationTimestamp();
|
||||
|
||||
/**
|
||||
* Checks if the hologram will track and replace placeholders.
|
||||
* This is false by default.
|
||||
*
|
||||
* @return if the hologram allows placeholders
|
||||
*/
|
||||
public boolean isAllowPlaceholders();
|
||||
|
||||
/**
|
||||
* Sets if the hologram should track and replace placeholders.
|
||||
* By default if will not track them.
|
||||
*
|
||||
* @param allowPlaceholders if the hologram should track placeholders
|
||||
*/
|
||||
public void setAllowPlaceholders(boolean allowPlaceholders);
|
||||
|
||||
/**
|
||||
* Deletes this hologram. Editing or teleporting the hologram when deleted
|
||||
* will throw an exception. Lines will be automatically cleared.
|
||||
* You should remove all the references of the hologram after deletion.
|
||||
*/
|
||||
public void delete();
|
||||
|
||||
|
||||
/**
|
||||
* Checks if a hologram was deleted.
|
||||
*
|
||||
* @return true if this hologram was deleted
|
||||
*/
|
||||
public boolean isDeleted();
|
||||
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.api;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.internal.BackendAPI;
|
||||
import com.gmail.filoghost.holographicdisplays.api.placeholder.PlaceholderReplacer;
|
||||
|
||||
/**
|
||||
* This the main class of the <b>Holographic Displays API</b>.
|
||||
* It provides methods to create holograms and to register custom placeholders.
|
||||
*/
|
||||
public class HologramsAPI {
|
||||
|
||||
|
||||
private HologramsAPI() {
|
||||
// No constructor needed.
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a hologram at given location.
|
||||
*
|
||||
* @param plugin the plugin that creates it
|
||||
* @param source the location where it will appear
|
||||
* @return the new hologram created
|
||||
*/
|
||||
public static Hologram createHologram(Plugin plugin, Location source) {
|
||||
return BackendAPI.getImplementation().createHologram(plugin, source);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds all the holograms created by a given plugin.
|
||||
*
|
||||
* @param plugin the plugin to search for in holograms
|
||||
* @return the holograms created by a plugin. the Collection is a copy
|
||||
* and modifying it has no effect on the holograms.
|
||||
*/
|
||||
public static Collection<Hologram> getHolograms(Plugin plugin) {
|
||||
return BackendAPI.getImplementation().getHolograms(plugin);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers a new placeholder that can be used in holograms created with commands.
|
||||
* With this method, you can basically expand the core of HolographicDisplays.
|
||||
*
|
||||
* @param plugin the owner plugin of the placeholder
|
||||
* @param textPlaceholder the text that the placeholder will be associated to (e.g.: "{onlinePlayers}")
|
||||
* @param refreshRate the refresh rate of the placeholder, in seconds. Keep in mind that the minimum is 0.1 seconds, and that will be rounded to tenths of seconds
|
||||
* @param replacer the implementation that will return the text to replace the placeholder, where the update() method is called every <b>refreshRate</b> seconds
|
||||
* @return true if the registration was successfull, false if it was already registered
|
||||
*/
|
||||
public static boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer) {
|
||||
return BackendAPI.getImplementation().registerPlaceholder(plugin, textPlaceholder, refreshRate, replacer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds all the placeholders registered by a given plugin.
|
||||
*
|
||||
* @param plugin the plugin to search for
|
||||
* @return a collection of placeholders registered by the plugin
|
||||
*/
|
||||
public static Collection<String> getRegisteredPlaceholders(Plugin plugin) {
|
||||
return BackendAPI.getImplementation().getRegisteredPlaceholders(plugin);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unregister a placeholder created by a plugin.
|
||||
*
|
||||
* @param plugin the plugin that owns the placeholder
|
||||
* @param textPlaceholder the placeholder to remove
|
||||
* @return true if found and removed, false otherwise
|
||||
*/
|
||||
public static boolean unregisterPlaceholder(Plugin plugin, String textPlaceholder) {
|
||||
return BackendAPI.getImplementation().unregisterPlaceholder(plugin, textPlaceholder);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resets and removes all the placeholders registered by a plugin. This is useful
|
||||
* when you have configurable placeholders and you want to remove all of them.
|
||||
*
|
||||
* @param plugin the plugin that owns the placeholders
|
||||
*/
|
||||
public static void unregisterPlaceholders(Plugin plugin) {
|
||||
BackendAPI.getImplementation().unregisterPlaceholders(plugin);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if an entity is part of a hologram.
|
||||
*
|
||||
* @param bukkitEntity the entity to check
|
||||
* @return true if the entity is a part of a hologram
|
||||
*/
|
||||
public static boolean isHologramEntity(Entity bukkitEntity) {
|
||||
return BackendAPI.getImplementation().isHologramEntity(bukkitEntity);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* This object is used to manage the visibility of a hologram.
|
||||
* It allows to hide/show the hologram to certain players, and the default behaviour
|
||||
* (when a hologram is not specifically being hidden/shown to a player) can be customized.
|
||||
*/
|
||||
public interface VisibilityManager {
|
||||
|
||||
/**
|
||||
* Returns if the hologram is visible by default. If not changed, this value
|
||||
* is true by default so the hologram is visible to everyone.
|
||||
*
|
||||
* @return if the hologram hologram is visible by default
|
||||
*/
|
||||
public boolean isVisibleByDefault();
|
||||
|
||||
/**
|
||||
* Sets if the hologram is visible by default. If not changed, this value
|
||||
* is true by default so the hologram is visible to everyone.
|
||||
*
|
||||
* @param visibleByDefault the new behaviour
|
||||
*/
|
||||
public void setVisibleByDefault(boolean visibleByDefault);
|
||||
|
||||
/**
|
||||
* Shows the hologram to a player, overriding the value of {@link #isVisibleByDefault()}.
|
||||
* This is persistent if the players goes offline.
|
||||
*
|
||||
* @param player the involved player
|
||||
*/
|
||||
public void showTo(Player player);
|
||||
|
||||
/**
|
||||
* Hides the hologram to a player, overriding the value of {@link #isVisibleByDefault()}.
|
||||
* This is persistent if the players goes offline.
|
||||
*
|
||||
* @param player the involved player
|
||||
*/
|
||||
public void hideTo(Player player);
|
||||
|
||||
/**
|
||||
* Checks if a hologram is visible to a player.
|
||||
*
|
||||
* @param player the involved player
|
||||
* @return if the player can see the hologram
|
||||
*/
|
||||
public boolean isVisibleTo(Player player);
|
||||
|
||||
/**
|
||||
* Resets the visibility to the default value. If you previously called {@link #showTo(Player)}
|
||||
* or {@link #hideTo(Player)} to override the default visibility, this method will reset it
|
||||
* to reflect the value of {@link #isVisibleByDefault()}.
|
||||
*
|
||||
* @param player the involved player
|
||||
*/
|
||||
public void resetVisibility(Player player);
|
||||
|
||||
/**
|
||||
* Resets the visibility for all the players. See {@link #resetVisibility(Player)} for more details.
|
||||
*/
|
||||
public void resetVisibilityAll();
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.api.handler;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Interface to handle items being picked up by players.
|
||||
*/
|
||||
public interface PickupHandler {
|
||||
|
||||
/**
|
||||
* Called when a player picks up the item.
|
||||
* @param player the player who picked up the item
|
||||
*/
|
||||
public void onPickup(Player player);
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.api.handler;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Interface to handle touch holograms.
|
||||
*/
|
||||
public interface TouchHandler {
|
||||
|
||||
/**
|
||||
* Called when a player interacts with the hologram (right click).
|
||||
* @param player the player who interacts
|
||||
*/
|
||||
public void onTouch(Player player);
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.api.internal;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.Hologram;
|
||||
import com.gmail.filoghost.holographicdisplays.api.placeholder.PlaceholderReplacer;
|
||||
|
||||
public abstract class BackendAPI {
|
||||
|
||||
private static BackendAPI implementation;
|
||||
|
||||
public static void setImplementation(BackendAPI implementation) {
|
||||
BackendAPI.implementation = implementation;
|
||||
}
|
||||
|
||||
public static BackendAPI getImplementation() {
|
||||
if (implementation == null) {
|
||||
throw new IllegalStateException("No API implementation set. Is Holographic Displays enabled?");
|
||||
}
|
||||
|
||||
return implementation;
|
||||
}
|
||||
|
||||
public abstract Hologram createHologram(Plugin plugin, Location source);
|
||||
|
||||
public abstract Collection<Hologram> getHolograms(Plugin plugin);
|
||||
|
||||
public abstract boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer);
|
||||
|
||||
public abstract Collection<String> getRegisteredPlaceholders(Plugin plugin);
|
||||
|
||||
public abstract boolean unregisterPlaceholder(Plugin plugin, String textPlaceholder);
|
||||
|
||||
public abstract void unregisterPlaceholders(Plugin plugin);
|
||||
|
||||
public abstract boolean isHologramEntity(Entity bukkitEntity);
|
||||
|
||||
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.api.line;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.handler.PickupHandler;
|
||||
|
||||
/**
|
||||
* A line of a Hologram that can be picked up.
|
||||
*/
|
||||
public interface CollectableLine extends HologramLine {
|
||||
|
||||
/**
|
||||
* Sets the PickupHandler for this line.
|
||||
*
|
||||
* @param pickupHandler the new PickupHandler, can be null.
|
||||
*/
|
||||
public void setPickupHandler(PickupHandler pickupHandler);
|
||||
|
||||
/**
|
||||
* Returns the current PickupHandler of this line.
|
||||
*
|
||||
* @return the current PickupHandler, can be null.
|
||||
*/
|
||||
public PickupHandler getPickupHandler();
|
||||
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.api.line;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.Hologram;
|
||||
|
||||
/**
|
||||
* Interface to represent a line in a Hologram.
|
||||
*/
|
||||
public interface HologramLine {
|
||||
|
||||
/**
|
||||
* Returns the parent Hologram of this line.
|
||||
*
|
||||
* @return the parent Hologram.
|
||||
*/
|
||||
public Hologram getParent();
|
||||
|
||||
/**
|
||||
* Removes this line from the parent Hologram. Since: v2.0.1
|
||||
* Do not call if the Hologram has been deleted, an exception will be thrown.
|
||||
*/
|
||||
public void removeLine();
|
||||
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.api.line;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface ItemLine extends CollectableLine, TouchableLine {
|
||||
|
||||
/**
|
||||
* Returns the ItemStack of this ItemLine.
|
||||
*
|
||||
* @return the ItemStack if this ItemLine.
|
||||
*/
|
||||
public ItemStack getItemStack();
|
||||
|
||||
/**
|
||||
* Sets the ItemStack for this ItemLine.
|
||||
*
|
||||
* @param itemStack the new item, should not be null.
|
||||
*/
|
||||
public void setItemStack(ItemStack itemStack);
|
||||
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.api.line;
|
||||
|
||||
public interface TextLine extends TouchableLine {
|
||||
|
||||
/**
|
||||
* Returns the current text of this TextLine.
|
||||
*
|
||||
* @return the current text of this line.
|
||||
*/
|
||||
public String getText();
|
||||
|
||||
/**
|
||||
* Sets the text of this TextLine.
|
||||
*
|
||||
* @param text the new text of this line.
|
||||
*/
|
||||
public void setText(String text);
|
||||
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.api.line;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler;
|
||||
|
||||
/**
|
||||
* A line of a Hologram that can be touched (right click).
|
||||
*/
|
||||
public interface TouchableLine extends HologramLine {
|
||||
|
||||
/**
|
||||
* Sets the TouchHandler for this line.
|
||||
*
|
||||
* @param touchHandler the new TouchHandler, can be null.
|
||||
*/
|
||||
public void setTouchHandler(TouchHandler touchHandler);
|
||||
|
||||
/**
|
||||
* Returns the current TouchHandler of this line.
|
||||
*
|
||||
* @return the current TouchHandler, can be null.
|
||||
*/
|
||||
public TouchHandler getTouchHandler();
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.api.placeholder;
|
||||
|
||||
public interface PlaceholderReplacer {
|
||||
|
||||
/**
|
||||
* Called to update a placeholder's replacement.
|
||||
* @return the replacement
|
||||
*/
|
||||
public String update();
|
||||
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-parent</artifactId>
|
||||
<version>2.4.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-config</artifactId>
|
||||
<name>HolographicDisplays Config</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.disk;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public enum ConfigNode {
|
||||
|
||||
SPACE_BETWEEN_LINES("space-between-lines", 0.02),
|
||||
QUICK_EDIT_COMMANDS("quick-edit-commands", true),
|
||||
IMAGES_SYMBOL("images.symbol", "[x]"),
|
||||
TRANSPARENCY_SPACE("images.transparency.space", " [|] "),
|
||||
TRANSPARENCY_COLOR("images.transparency.color", "&7"),
|
||||
UPDATE_NOTIFICATION("update-notification", true),
|
||||
BUNGEE_REFRESH_SECONDS("bungee.refresh-seconds", 3),
|
||||
BUNGEE_USE_REDIS_BUNGEE("bungee.use-RedisBungee", false),
|
||||
BUNGEE_USE_FULL_PINGER("bungee.pinger.enable", false),
|
||||
BUNGEE_PINGER_TIMEOUT("bungee.pinger.timeout", 500),
|
||||
BUNGEE_PINGER_OFFLINE_MOTD("bungee.pinger.offline-motd", "&cOffline, couldn't get the MOTD."),
|
||||
BUNGEE_PINGER_ONLINE_FORMAT("bungee.pinger.status.online", "&aOnline"),
|
||||
BUNGEE_PINGER_OFFLINE_FORMAT("bungee.pinger.status.offline", "&cOffline"),
|
||||
BUNGEE_PINGER_TRIM_MOTD("bungee.pinger.motd-remove-leading-trailing-spaces", true),
|
||||
BUNGEE_PINGER_SERVERS("bungee.pinger.servers", Arrays.asList("hub: 127.0.0.1:25565", "survival: 127.0.0.1:25566", "minigames: 127.0.0.1:25567")),
|
||||
TIME_FORMAT("time.format", "H:mm"),
|
||||
TIME_ZONE("time.zone", "GMT+1"),
|
||||
DEBUG("debug", false);
|
||||
|
||||
private final String path;
|
||||
private final Object value;
|
||||
|
||||
private ConfigNode(String path, Object defaultValue) {
|
||||
this.path = path;
|
||||
value = defaultValue;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public Object getDefaultValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,221 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.disk;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||
|
||||
/**
|
||||
* Just a bunch of static varibles to hold the settings.
|
||||
* Useful for fast access.
|
||||
*/
|
||||
public class Configuration {
|
||||
|
||||
public static double spaceBetweenLines;
|
||||
public static boolean quickEditCommands;
|
||||
public static String imageSymbol;
|
||||
public static String transparencySymbol;
|
||||
public static boolean updateNotification;
|
||||
public static ChatColor transparencyColor;
|
||||
|
||||
public static SimpleDateFormat timeFormat;
|
||||
|
||||
public static int bungeeRefreshSeconds;
|
||||
public static boolean useRedisBungee;
|
||||
|
||||
public static boolean pingerEnable;
|
||||
public static int pingerTimeout;
|
||||
public static String pingerOfflineMotd;
|
||||
public static String pingerStatusOnline;
|
||||
public static String pingerStatusOffline;
|
||||
public static boolean pingerTrimMotd;
|
||||
public static Map<String, ServerAddress> pingerServers;
|
||||
|
||||
|
||||
public static void load(Plugin plugin) {
|
||||
File configFile = new File(plugin.getDataFolder(), "config.yml");
|
||||
if (!configFile.exists()) {
|
||||
plugin.getDataFolder().mkdirs();
|
||||
plugin.saveResource("config.yml", true);
|
||||
}
|
||||
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
try {
|
||||
config.load(configFile);
|
||||
} catch (InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
ConsoleLogger.log(Level.WARNING, "The configuration is not a valid YAML file! Please check it with a tool like http://yaml-online-parser.appspot.com/");
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
ConsoleLogger.log(Level.WARNING, "I/O error while reading the configuration. Was the file in use?");
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ConsoleLogger.log(Level.WARNING, "Unhandled exception while reading the configuration!");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean needsSave = false;
|
||||
|
||||
for (ConfigNode node : ConfigNode.values()) {
|
||||
if (!config.isSet(node.getPath())) {
|
||||
needsSave = true;
|
||||
config.set(node.getPath(), node.getDefaultValue());
|
||||
}
|
||||
}
|
||||
|
||||
// Check the old values.
|
||||
List<String> nodesToRemove = Arrays.asList(
|
||||
"vertical-spacing",
|
||||
"time-format",
|
||||
"bungee-refresh-seconds",
|
||||
"using-RedisBungee",
|
||||
"bungee-online-format",
|
||||
"bungee-offline-format",
|
||||
"precise-hologram-movement"
|
||||
);
|
||||
|
||||
for (String oldNode : nodesToRemove) {
|
||||
if (config.isSet(oldNode)) {
|
||||
config.set(oldNode, null);
|
||||
needsSave = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (needsSave) {
|
||||
config.options().header(String.join("\n",
|
||||
".",
|
||||
". Read the tutorial at: http://dev.bukkit.org/bukkit-plugins/holographic-displays/",
|
||||
".",
|
||||
". Plugin created by filoghost.",
|
||||
"."));
|
||||
config.options().copyHeader(true);
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
ConsoleLogger.log(Level.WARNING, "I/O error while saving the configuration. Was the file in use?");
|
||||
}
|
||||
}
|
||||
|
||||
spaceBetweenLines = config.getDouble(ConfigNode.SPACE_BETWEEN_LINES.getPath());
|
||||
quickEditCommands = config.getBoolean(ConfigNode.QUICK_EDIT_COMMANDS.getPath());
|
||||
|
||||
updateNotification = config.getBoolean(ConfigNode.UPDATE_NOTIFICATION.getPath());
|
||||
|
||||
imageSymbol = StringConverter.toReadableFormat(config.getString(ConfigNode.IMAGES_SYMBOL.getPath()));
|
||||
transparencySymbol = StringConverter.toReadableFormat(config.getString(ConfigNode.TRANSPARENCY_SPACE.getPath()));
|
||||
bungeeRefreshSeconds = config.getInt(ConfigNode.BUNGEE_REFRESH_SECONDS.getPath());
|
||||
useRedisBungee = config.getBoolean(ConfigNode.BUNGEE_USE_REDIS_BUNGEE.getPath());
|
||||
|
||||
pingerEnable = config.getBoolean(ConfigNode.BUNGEE_USE_FULL_PINGER.getPath());
|
||||
pingerTimeout = config.getInt(ConfigNode.BUNGEE_PINGER_TIMEOUT.getPath());
|
||||
pingerTrimMotd = config.getBoolean(ConfigNode.BUNGEE_PINGER_TRIM_MOTD.getPath());
|
||||
|
||||
pingerOfflineMotd = StringConverter.toReadableFormat(config.getString(ConfigNode.BUNGEE_PINGER_OFFLINE_MOTD.getPath()));
|
||||
pingerStatusOnline = StringConverter.toReadableFormat(config.getString(ConfigNode.BUNGEE_PINGER_ONLINE_FORMAT.getPath()));
|
||||
pingerStatusOffline = StringConverter.toReadableFormat(config.getString(ConfigNode.BUNGEE_PINGER_OFFLINE_FORMAT.getPath()));
|
||||
|
||||
if (pingerTimeout <= 0) {
|
||||
pingerTimeout = 100;
|
||||
} else if (pingerTimeout >= 10000) {
|
||||
pingerTimeout = 10000;
|
||||
}
|
||||
|
||||
pingerServers = new HashMap<>();
|
||||
|
||||
if (pingerEnable) {
|
||||
for (String singleServer : config.getStringList(ConfigNode.BUNGEE_PINGER_SERVERS.getPath())) {
|
||||
String[] nameAndAddress = singleServer.split(":", 2);
|
||||
if (nameAndAddress.length < 2) {
|
||||
ConsoleLogger.log(Level.WARNING, "The server info \"" + singleServer + "\" is not valid. There should be a name and an address, separated by a colon.");
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = nameAndAddress[0].trim();
|
||||
String address = nameAndAddress[1].replace(" ", "");
|
||||
|
||||
String ip;
|
||||
int port;
|
||||
|
||||
if (address.contains(":")) {
|
||||
String[] ipAndPort = address.split(":", 2);
|
||||
ip = ipAndPort[0];
|
||||
try {
|
||||
port = Integer.parseInt(ipAndPort[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
ConsoleLogger.log(Level.WARNING, "Invalid port number in the server info \"" + singleServer + "\".");
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
ip = address;
|
||||
port = 25565; // The default Minecraft port.
|
||||
}
|
||||
|
||||
pingerServers.put(name, new ServerAddress(ip, port));
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleLogger.setDebugEnabled(config.getBoolean(ConfigNode.DEBUG.getPath()));
|
||||
|
||||
String tempColor = config.getString(ConfigNode.TRANSPARENCY_COLOR.getPath()).replace('&', ChatColor.COLOR_CHAR);
|
||||
boolean foundColor = false;
|
||||
for (ChatColor chatColor : ChatColor.values()) {
|
||||
if (chatColor.toString().equals(tempColor)) {
|
||||
Configuration.transparencyColor = chatColor;
|
||||
foundColor = true;
|
||||
}
|
||||
}
|
||||
if (!foundColor) {
|
||||
Configuration.transparencyColor = ChatColor.GRAY;
|
||||
ConsoleLogger.log(Level.WARNING, "You didn't set a valid chat color for transparency in the configuration, light gray (&7) will be used.");
|
||||
}
|
||||
|
||||
try {
|
||||
timeFormat = new SimpleDateFormat(config.getString(ConfigNode.TIME_FORMAT.getPath()));
|
||||
timeFormat.setTimeZone(TimeZone.getTimeZone(config.getString(ConfigNode.TIME_ZONE.getPath())));
|
||||
} catch (IllegalArgumentException ex) {
|
||||
timeFormat = new SimpleDateFormat("H:mm");
|
||||
ConsoleLogger.log(Level.WARNING, "Time format not valid in the configuration, using the default.");
|
||||
}
|
||||
|
||||
if (bungeeRefreshSeconds < 1) {
|
||||
ConsoleLogger.log(Level.WARNING, "The minimum interval for pinging BungeeCord's servers is 1 second. It has been automatically set.");
|
||||
bungeeRefreshSeconds = 1;
|
||||
}
|
||||
|
||||
if (bungeeRefreshSeconds > 60) {
|
||||
ConsoleLogger.log(Level.WARNING, "The maximum interval for pinging BungeeCord's servers is 60 seconds. It has been automatically set.");
|
||||
bungeeRefreshSeconds = 60;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.disk;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.exception.InvalidFormatException;
|
||||
import com.gmail.filoghost.holographicdisplays.exception.WorldNotFoundException;
|
||||
|
||||
public class LocationSerializer {
|
||||
|
||||
private static DecimalFormat numberFormat = new DecimalFormat("0.000", DecimalFormatSymbols.getInstance(Locale.ROOT));
|
||||
|
||||
public static Location locationFromString(String input) throws WorldNotFoundException, InvalidFormatException {
|
||||
if (input == null) {
|
||||
throw new InvalidFormatException();
|
||||
}
|
||||
|
||||
String[] parts = input.split(",");
|
||||
|
||||
if (parts.length != 4) {
|
||||
throw new InvalidFormatException();
|
||||
}
|
||||
|
||||
try {
|
||||
double x = Double.parseDouble(parts[1].replace(" ", ""));
|
||||
double y = Double.parseDouble(parts[2].replace(" ", ""));
|
||||
double z = Double.parseDouble(parts[3].replace(" ", ""));
|
||||
|
||||
World world = Bukkit.getWorld(parts[0].trim());
|
||||
if (world == null) {
|
||||
throw new WorldNotFoundException(parts[0].trim());
|
||||
}
|
||||
|
||||
return new Location(world, x, y, z);
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new InvalidFormatException();
|
||||
}
|
||||
}
|
||||
|
||||
public static String locationToString(Location loc) {
|
||||
return (loc.getWorld().getName() + ", " + numberFormat.format(loc.getX()) + ", " + numberFormat.format(loc.getY()) + ", " + numberFormat.format(loc.getZ()));
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.disk;
|
||||
|
||||
public class ServerAddress {
|
||||
|
||||
private String ip;
|
||||
private int port;
|
||||
|
||||
public ServerAddress(String ip, int port) {
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ip + ":" + port;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.disk;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class StringConverter {
|
||||
|
||||
private static final boolean HEX_CHAT_COLORS_ENABLED = Utils.classExists("org.bukkit.entity.Strider");
|
||||
private static final int HEX_COLOR_LENGTH = 6;
|
||||
|
||||
public static String toReadableFormat(String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
input = UnicodeSymbols.placeholdersToSymbols(input);
|
||||
input = addColors(input);
|
||||
return input;
|
||||
}
|
||||
|
||||
public static String addColors(String input) {
|
||||
if (!input.contains("&")) {
|
||||
return input;
|
||||
}
|
||||
|
||||
StringBuilder output = new StringBuilder(input.length());
|
||||
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
char current = input.charAt(i);
|
||||
|
||||
if (current == '&' && i + 1 < input.length()) {
|
||||
char next = input.charAt(i + 1);
|
||||
|
||||
if (next == '#' && HEX_CHAT_COLORS_ENABLED && isValidHexColor(input, i + 2)) {
|
||||
output.append(ChatColor.COLOR_CHAR);
|
||||
output.append('x');
|
||||
|
||||
for (int j = 0; j < HEX_COLOR_LENGTH; j++) {
|
||||
output.append(ChatColor.COLOR_CHAR);
|
||||
output.append(Character.toLowerCase(input.charAt(i + 2 + j)));
|
||||
}
|
||||
|
||||
i += 1 + HEX_COLOR_LENGTH; // Skip '#' and hex string, which are already converted and added
|
||||
|
||||
} else if (isColorCode(next)) {
|
||||
output.append(ChatColor.COLOR_CHAR);
|
||||
output.append(Character.toLowerCase(next));
|
||||
|
||||
i++; // Skip next character, which is already added
|
||||
|
||||
} else {
|
||||
output.append(current);
|
||||
}
|
||||
} else {
|
||||
output.append(current);
|
||||
}
|
||||
}
|
||||
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
private static boolean isValidHexColor(String input, int startIndex) {
|
||||
if (input.length() - startIndex < HEX_COLOR_LENGTH) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < HEX_COLOR_LENGTH; i++) {
|
||||
if (!isHexCode(input.charAt(startIndex + i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isHexCode(char c) {
|
||||
return "0123456789AaBbCcDdEeFf".indexOf(c) > -1;
|
||||
}
|
||||
|
||||
private static boolean isColorCode(char c) {
|
||||
return "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(c) > -1;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.disk;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||
import com.gmail.filoghost.holographicdisplays.util.FileUtils;
|
||||
|
||||
public class UnicodeSymbols {
|
||||
|
||||
private static Map<String, String> placeholders = new HashMap<>();
|
||||
|
||||
public static void load(Plugin plugin) {
|
||||
placeholders.clear();
|
||||
|
||||
File file = new File(plugin.getDataFolder(), "symbols.yml");
|
||||
|
||||
if (!file.exists()) {
|
||||
plugin.getDataFolder().mkdirs();
|
||||
plugin.saveResource("symbols.yml", true);
|
||||
}
|
||||
|
||||
List<String> lines;
|
||||
try {
|
||||
lines = FileUtils.readLines(file);
|
||||
} catch (IOException e) {
|
||||
ConsoleLogger.log(Level.WARNING, "I/O error while reading symbols.yml. Was the file in use?", e);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.log(Level.WARNING, "Unhandled exception while reading symbols.yml!", e);
|
||||
return;
|
||||
}
|
||||
|
||||
for (String line : lines) {
|
||||
|
||||
// Comment or empty line.
|
||||
if (line.length() == 0 || line.startsWith("#")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!line.contains(":")) {
|
||||
ConsoleLogger.log(Level.WARNING, "Unable to parse a line(" + line + ") from symbols.yml: it must contain ':' to separate the placeholder and the replacement.");
|
||||
continue;
|
||||
}
|
||||
|
||||
int indexOf = line.indexOf(':');
|
||||
String placeholder = unquote(line.substring(0, indexOf).trim());
|
||||
String replacement = StringEscapeUtils.unescapeJava(unquote(line.substring(indexOf + 1, line.length()).trim()));
|
||||
|
||||
if (placeholder.isEmpty() || replacement.isEmpty()) {
|
||||
ConsoleLogger.log(Level.WARNING, "Unable to parse a line(" + line + ") from symbols.yml: the placeholder and the replacement must have both at least 1 character.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (placeholder.length() > 30) {
|
||||
ConsoleLogger.log(Level.WARNING, "Unable to parse a line(" + line + ") from symbols.yml: the placeholder cannot be longer than 30 characters.");
|
||||
continue;
|
||||
}
|
||||
|
||||
placeholders.put(placeholder, replacement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected static String placeholdersToSymbols(String input) {
|
||||
for (Entry<String, String> entry : placeholders.entrySet()) {
|
||||
input = input.replace(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
|
||||
private static String unquote(String input) {
|
||||
if (input.length() < 2) {
|
||||
// Cannot be quoted.
|
||||
return input;
|
||||
}
|
||||
if (input.startsWith("'") && input.endsWith("'")) {
|
||||
return input.substring(1, input.length() - 1);
|
||||
} else if (input.startsWith("\"") && input.endsWith("\"")) {
|
||||
return input.substring(1, input.length() - 1);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.exception;
|
||||
|
||||
public class InvalidFormatException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.exception;
|
||||
|
||||
public class WorldNotFoundException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public WorldNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-example</artifactId>
|
||||
<version>2.4.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-example-deathholograms</artifactId>
|
||||
<name>HolographicDisplays Example DeathHolograms</name>
|
||||
|
||||
</project>
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.example.deathholograms;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.Hologram;
|
||||
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
|
||||
|
||||
public class DeathHolograms extends JavaPlugin implements Listener {
|
||||
|
||||
public void onEnable() {
|
||||
|
||||
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
|
||||
getLogger().severe("*** HolographicDisplays is not installed or not enabled. ***");
|
||||
getLogger().severe("*** This plugin will be disabled. ***");
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
|
||||
Hologram hologram = HologramsAPI.createHologram(this, event.getEntity().getEyeLocation());
|
||||
|
||||
hologram.appendTextLine(ChatColor.RED + "Player " + ChatColor.GOLD + event.getEntity().getName() + ChatColor.RED + " died here!");
|
||||
hologram.appendTextLine(ChatColor.GRAY + "Time of death: " + new SimpleDateFormat("H:m").format(new Date()));
|
||||
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-example</artifactId>
|
||||
<version>2.4.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-example-powerups</artifactId>
|
||||
<name>HolographicDisplays Example PowerUps</name>
|
||||
|
||||
</project>
|
|
@ -1,86 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.example.powerups;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.Hologram;
|
||||
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
|
||||
import com.gmail.filoghost.holographicdisplays.api.handler.PickupHandler;
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.ItemLine;
|
||||
|
||||
public class PowerUps extends JavaPlugin implements Listener {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
|
||||
getLogger().severe("*** HolographicDisplays is not installed or not enabled. ***");
|
||||
getLogger().severe("*** This plugin will be disabled. ***");
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
|
||||
if (event.getEntityType() == EntityType.ZOMBIE) {
|
||||
|
||||
// Remove normal drops and exp.
|
||||
event.getDrops().clear();
|
||||
event.setDroppedExp(0);
|
||||
|
||||
// Spawn the floating item with a label.
|
||||
final Hologram hologram = HologramsAPI.createHologram(this, event.getEntity().getLocation().add(0.0, 0.9, 0.0));
|
||||
hologram.appendTextLine(ChatColor.AQUA + "" + ChatColor.BOLD + "Speed PowerUp");
|
||||
ItemLine icon = hologram.appendItemLine(new ItemStack(Material.SUGAR));
|
||||
|
||||
icon.setPickupHandler(new PickupHandler() {
|
||||
|
||||
@Override
|
||||
public void onPickup(Player player) {
|
||||
|
||||
// Play an effect.
|
||||
player.playEffect(hologram.getLocation(), Effect.MOBSPAWNER_FLAMES, null);
|
||||
|
||||
// 30 seconds of speed II.
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 30 * 20, 1), true);
|
||||
|
||||
// Delete the hologram.
|
||||
hologram.delete();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-parent</artifactId>
|
||||
<version>2.4.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-example</artifactId>
|
||||
<name>HolographicDisplays Example</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>DeathHolograms</module>
|
||||
<module>PowerUps</module>
|
||||
</modules>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,39 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-parent</artifactId>
|
||||
<version>2.4.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-legacy</artifactId>
|
||||
<name>HolographicDisplays Legacy</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* @deprecated Please use the new API!
|
||||
*/
|
||||
@Deprecated
|
||||
public interface FloatingItem {
|
||||
|
||||
@Deprecated
|
||||
public boolean update();
|
||||
|
||||
@Deprecated
|
||||
public void hide();
|
||||
|
||||
@Deprecated
|
||||
public void setItemStack(ItemStack itemstack);
|
||||
|
||||
@Deprecated
|
||||
public ItemStack getItemStack();
|
||||
|
||||
@Deprecated
|
||||
public Location getLocation();
|
||||
|
||||
@Deprecated
|
||||
public double getX();
|
||||
|
||||
@Deprecated
|
||||
public double getY();
|
||||
|
||||
@Deprecated
|
||||
public double getZ();
|
||||
|
||||
@Deprecated
|
||||
public World getWorld();
|
||||
|
||||
@Deprecated
|
||||
public void teleport(Location location);
|
||||
|
||||
@Deprecated
|
||||
public void setTouchHandler(ItemTouchHandler handler);
|
||||
|
||||
@Deprecated
|
||||
public ItemTouchHandler getTouchHandler();
|
||||
|
||||
@Deprecated
|
||||
public boolean hasTouchHandler();
|
||||
|
||||
@Deprecated
|
||||
public void setPickupHandler(PickupHandler handler);
|
||||
|
||||
@Deprecated
|
||||
public PickupHandler getPickupHandler();
|
||||
|
||||
@Deprecated
|
||||
public boolean hasPickupHandler();
|
||||
|
||||
@Deprecated
|
||||
public long getCreationTimestamp();
|
||||
|
||||
@Deprecated
|
||||
public void delete();
|
||||
|
||||
@Deprecated
|
||||
public boolean isDeleted();
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
/**
|
||||
* @deprecated Please use the new API!
|
||||
*/
|
||||
@Deprecated
|
||||
public interface Hologram {
|
||||
|
||||
@Deprecated
|
||||
public boolean update();
|
||||
|
||||
@Deprecated
|
||||
public void hide();
|
||||
|
||||
@Deprecated
|
||||
public void addLine(String text);
|
||||
|
||||
@Deprecated
|
||||
public void removeLine(int index);
|
||||
|
||||
@Deprecated
|
||||
public void setLine(int index, String text);
|
||||
|
||||
@Deprecated
|
||||
public void insertLine(int index, String text);
|
||||
|
||||
@Deprecated
|
||||
public String[] getLines();
|
||||
|
||||
@Deprecated
|
||||
public int getLinesLength();
|
||||
|
||||
@Deprecated
|
||||
public void clearLines();
|
||||
|
||||
@Deprecated
|
||||
public Location getLocation();
|
||||
|
||||
@Deprecated
|
||||
public double getX();
|
||||
|
||||
@Deprecated
|
||||
public double getY();
|
||||
|
||||
@Deprecated
|
||||
public double getZ();
|
||||
|
||||
@Deprecated
|
||||
public World getWorld();
|
||||
|
||||
@Deprecated
|
||||
public void setLocation(Location location);
|
||||
|
||||
@Deprecated
|
||||
public void teleport(Location location);
|
||||
|
||||
@Deprecated
|
||||
public void setTouchHandler(TouchHandler handler);
|
||||
|
||||
@Deprecated
|
||||
public TouchHandler getTouchHandler();
|
||||
|
||||
@Deprecated
|
||||
public boolean hasTouchHandler();
|
||||
|
||||
@Deprecated
|
||||
public long getCreationTimestamp();
|
||||
|
||||
@Deprecated
|
||||
public void delete();
|
||||
|
||||
@Deprecated
|
||||
public boolean isDeleted();
|
||||
|
||||
}
|
|
@ -1,168 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.filoghost.holograms.api.adapter.FloatingItemAdapter;
|
||||
import com.gmail.filoghost.holograms.api.adapter.HologramAdapter;
|
||||
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.ItemLine;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||
|
||||
/**
|
||||
* @deprecated Please use the new API!
|
||||
*/
|
||||
@Deprecated
|
||||
public class HolographicDisplaysAPI {
|
||||
|
||||
private static Set<String> notifiedPlugins = new HashSet<>();
|
||||
|
||||
private static void notifyOldAPI(Plugin plugin) {
|
||||
Validator.notNull(plugin, "plugin");
|
||||
|
||||
if (notifiedPlugins.add(plugin.getName())) {
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[Holographic Displays] The plugin \"" + plugin.getName() + "\" is still using the old API of Holographic Displays. "
|
||||
+ "Please notify the author and ask them to update it, the old API will be removed soon.");
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram createHologram(Plugin plugin, Location source, String... lines) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
|
||||
com.gmail.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
for (String line : lines) {
|
||||
hologram.appendTextLine(line);
|
||||
}
|
||||
return new HologramAdapter(plugin, hologram);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem createFloatingItem(Plugin plugin, Location source, ItemStack itemstack) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
validateItem(itemstack);
|
||||
|
||||
com.gmail.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
ItemLine itemLine = hologram.appendItemLine(itemstack);
|
||||
return new FloatingItemAdapter(plugin, hologram, itemLine);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram createIndividualHologram(Plugin plugin, Location source, Player whoCanSee, String... lines) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
return createIndividualHologram(plugin, source, Arrays.asList(whoCanSee), lines);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram createIndividualHologram(Plugin plugin, Location source, List<Player> whoCanSee, String... lines) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
|
||||
com.gmail.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
|
||||
hologram.getVisibilityManager().setVisibleByDefault(false);
|
||||
if (whoCanSee != null) {
|
||||
for (Player player : whoCanSee) {
|
||||
hologram.getVisibilityManager().showTo(player);
|
||||
}
|
||||
}
|
||||
|
||||
for (String line : lines) {
|
||||
hologram.appendTextLine(line);
|
||||
}
|
||||
|
||||
return new HologramAdapter(plugin, hologram);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, Player whoCanSee, ItemStack itemstack) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
return createIndividualFloatingItem(plugin, source, Arrays.asList(whoCanSee), itemstack);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, List<Player> whoCanSee, ItemStack itemstack) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
validateItem(itemstack);
|
||||
|
||||
com.gmail.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
ItemLine itemLine = hologram.appendItemLine(itemstack);
|
||||
|
||||
hologram.getVisibilityManager().setVisibleByDefault(false);
|
||||
if (whoCanSee != null) {
|
||||
for (Player player : whoCanSee) {
|
||||
hologram.getVisibilityManager().showTo(player);
|
||||
}
|
||||
}
|
||||
|
||||
return new FloatingItemAdapter(plugin, hologram, itemLine);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram[] getHolograms(Plugin plugin) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
Collection<HologramAdapter> pluginHolograms = HologramAdapter.activeHolograms.getOrDefault(plugin, Collections.emptyList());
|
||||
return pluginHolograms.toArray(new HologramAdapter[0]);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem[] getFloatingItems(Plugin plugin) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
Collection<FloatingItemAdapter> pluginFloatingItems = FloatingItemAdapter.activeFloatingItems.getOrDefault(plugin, Collections.emptyList());
|
||||
return pluginFloatingItems.toArray(new FloatingItemAdapter[0]);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean isHologramEntity(Entity bukkitEntity) {
|
||||
return HologramsAPI.isHologramEntity(bukkitEntity);
|
||||
}
|
||||
|
||||
private static void validateLocation(Location loc) {
|
||||
Validator.notNull(loc, "location");
|
||||
Validator.notNull(loc.getWorld(), "location's world");
|
||||
}
|
||||
|
||||
private static void validateItem(ItemStack itemstack) {
|
||||
Validator.notNull(itemstack, "itemstack");
|
||||
Validator.isTrue(itemstack.getType() != Material.AIR, "itemstack cannot be AIR");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @deprecated Please use the new API!
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ItemTouchHandler {
|
||||
|
||||
@Deprecated
|
||||
public void onTouch(FloatingItem floatingItem, Player player);
|
||||
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @deprecated Please use the new API!
|
||||
*/
|
||||
@Deprecated
|
||||
public interface PickupHandler {
|
||||
|
||||
@Deprecated
|
||||
public void onPickup(FloatingItem floatingItem, Player player);
|
||||
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @deprecated Please use the new API!
|
||||
*/
|
||||
@Deprecated
|
||||
public interface TouchHandler {
|
||||
|
||||
@Deprecated
|
||||
public void onTouch(Hologram hologram, Player player);
|
||||
|
||||
}
|
|
@ -1,161 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api.adapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.filoghost.holograms.api.FloatingItem;
|
||||
import com.gmail.filoghost.holograms.api.ItemTouchHandler;
|
||||
import com.gmail.filoghost.holograms.api.PickupHandler;
|
||||
import com.gmail.filoghost.holographicdisplays.api.Hologram;
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.ItemLine;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class FloatingItemAdapter implements FloatingItem {
|
||||
|
||||
public static Map<Plugin, Collection<FloatingItemAdapter>> activeFloatingItems = new HashMap<>();
|
||||
|
||||
private Plugin plugin;
|
||||
public Hologram hologram;
|
||||
private ItemLine itemLine;
|
||||
private ItemTouchHandler touchHandler;
|
||||
private PickupHandler pickupHandler;
|
||||
|
||||
public FloatingItemAdapter(Plugin plugin, Hologram delegateHologram, ItemLine delegateItemLine) {
|
||||
this.plugin = plugin;
|
||||
this.hologram = delegateHologram;
|
||||
this.itemLine = delegateItemLine;
|
||||
|
||||
activeFloatingItems.computeIfAbsent(plugin, __ -> new ArrayList<>()).add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemStack(ItemStack itemstack) {
|
||||
itemLine.setItemStack(itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return itemLine.getItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return hologram.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getX() {
|
||||
return hologram.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getY() {
|
||||
return hologram.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getZ() {
|
||||
return hologram.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return hologram.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Location location) {
|
||||
hologram.teleport(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTouchHandler(ItemTouchHandler handler) {
|
||||
this.touchHandler = handler;
|
||||
|
||||
if (handler != null) {
|
||||
itemLine.setTouchHandler(new ItemTouchHandlerAdapter(this, handler));
|
||||
} else {
|
||||
itemLine.setTouchHandler(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTouchHandler getTouchHandler() {
|
||||
return touchHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTouchHandler() {
|
||||
return touchHandler != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPickupHandler(PickupHandler handler) {
|
||||
this.pickupHandler = handler;
|
||||
|
||||
if (handler != null) {
|
||||
itemLine.setPickupHandler(new PickupHandlerAdapter(this, handler));
|
||||
} else {
|
||||
itemLine.setPickupHandler(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PickupHandler getPickupHandler() {
|
||||
return pickupHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPickupHandler() {
|
||||
return pickupHandler != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCreationTimestamp() {
|
||||
return hologram.getCreationTimestamp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
hologram.delete();
|
||||
|
||||
activeFloatingItems.get(plugin).remove(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return hologram.isDeleted();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,202 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api.adapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.filoghost.holograms.api.Hologram;
|
||||
import com.gmail.filoghost.holograms.api.TouchHandler;
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.TextLine;
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.TouchableLine;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class HologramAdapter implements Hologram {
|
||||
|
||||
public static Map<Plugin, Collection<HologramAdapter>> activeHolograms = new HashMap<>();
|
||||
|
||||
private Plugin plugin;
|
||||
private com.gmail.filoghost.holographicdisplays.api.Hologram hologram;
|
||||
private TouchHandler touchHandler;
|
||||
|
||||
public HologramAdapter(Plugin plugin, com.gmail.filoghost.holographicdisplays.api.Hologram delegate) {
|
||||
this.plugin = plugin;
|
||||
this.hologram = delegate;
|
||||
|
||||
activeHolograms.computeIfAbsent(plugin, __ -> new ArrayList<>()).add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean update() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void hide() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void addLine(String text) {
|
||||
hologram.appendTextLine(text);
|
||||
updateTouchHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setLine(int index, String text) {
|
||||
hologram.removeLine(index);
|
||||
hologram.insertTextLine(index, text);
|
||||
updateTouchHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void insertLine(int index, String text) {
|
||||
hologram.insertTextLine(index, text);
|
||||
updateTouchHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String[] getLines() {
|
||||
String[] lines = new String[hologram.size()];
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
HologramLine lineObject = hologram.getLine(i);
|
||||
if (lineObject instanceof TextLine) {
|
||||
lines[i] = ((TextLine) lineObject).getText();
|
||||
} else {
|
||||
lines[i] = "";
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getLinesLength() {
|
||||
return hologram.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setLocation(Location location) {
|
||||
hologram.teleport(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setTouchHandler(TouchHandler handler) {
|
||||
this.touchHandler = handler;
|
||||
updateTouchHandler();
|
||||
}
|
||||
|
||||
private void updateTouchHandler() {
|
||||
for (int i = 0; i < hologram.size(); i++) {
|
||||
HologramLine line = hologram.getLine(i);
|
||||
if (!(line instanceof TouchableLine)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TouchableLine touchableLine = (TouchableLine) line;
|
||||
|
||||
if (touchHandler != null) {
|
||||
touchableLine.setTouchHandler(new HologramTouchHandlerAdapter(this, touchHandler));
|
||||
} else {
|
||||
touchableLine.setTouchHandler(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public TouchHandler getTouchHandler() {
|
||||
return touchHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean hasTouchHandler() {
|
||||
return touchHandler != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLine(int index) {
|
||||
hologram.removeLine(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearLines() {
|
||||
hologram.clearLines();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return hologram.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getX() {
|
||||
return hologram.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getY() {
|
||||
return hologram.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getZ() {
|
||||
return hologram.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return hologram.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Location location) {
|
||||
hologram.teleport(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCreationTimestamp() {
|
||||
return hologram.getCreationTimestamp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
hologram.delete();
|
||||
|
||||
activeHolograms.get(plugin).remove(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return hologram.isDeleted();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api.adapter;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.filoghost.holograms.api.Hologram;
|
||||
import com.gmail.filoghost.holograms.api.TouchHandler;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class HologramTouchHandlerAdapter implements com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler {
|
||||
|
||||
protected TouchHandler oldHandler;
|
||||
private Hologram hologram;
|
||||
|
||||
public HologramTouchHandlerAdapter(Hologram hologram, TouchHandler oldHandler) {
|
||||
this.hologram = hologram;
|
||||
this.oldHandler = oldHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouch(Player player) {
|
||||
oldHandler.onTouch(hologram, player);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api.adapter;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.filoghost.holograms.api.FloatingItem;
|
||||
import com.gmail.filoghost.holograms.api.ItemTouchHandler;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ItemTouchHandlerAdapter implements com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler {
|
||||
|
||||
protected ItemTouchHandler oldHandler;
|
||||
private FloatingItem item;
|
||||
|
||||
public ItemTouchHandlerAdapter(FloatingItem item, ItemTouchHandler oldHandler) {
|
||||
this.item = item;
|
||||
this.oldHandler = oldHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouch(Player player) {
|
||||
oldHandler.onTouch(item, player);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api.adapter;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.filoghost.holograms.api.FloatingItem;
|
||||
import com.gmail.filoghost.holograms.api.PickupHandler;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class PickupHandlerAdapter implements com.gmail.filoghost.holographicdisplays.api.handler.PickupHandler {
|
||||
|
||||
public PickupHandler oldHandler;
|
||||
private FloatingItem item;
|
||||
|
||||
public PickupHandlerAdapter(FloatingItem item, PickupHandler oldPickupHandler) {
|
||||
this.item = item;
|
||||
this.oldHandler = oldPickupHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickup(Player player) {
|
||||
oldHandler.onPickup(item, player);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<version>2.4.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||
<name>HolographicDisplays NMS Interfaces</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.interfaces;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ChatComponentAdapter<T> {
|
||||
|
||||
T cast(Object chatComponentObject);
|
||||
|
||||
String getText(T chatComponent);
|
||||
|
||||
List<T> getSiblings(T chatComponent);
|
||||
|
||||
void addSibling(T chatComponent, T newSibling);
|
||||
|
||||
default T cloneComponent(T chatComponent) {
|
||||
return cloneComponent(chatComponent, getText(chatComponent));
|
||||
}
|
||||
|
||||
T cloneComponent(T chatComponent, String newText);
|
||||
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.interfaces;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CustomNameHelper {
|
||||
|
||||
|
||||
public static String replaceCustomNameString(Object customNameObject, String target, String replacement) {
|
||||
String customName = (String) customNameObject;
|
||||
if (customName.contains(target)) {
|
||||
return customName.replace(target, replacement);
|
||||
} else {
|
||||
return customName;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T replaceCustomNameChatComponent(ChatComponentAdapter<T> versionAdapter, Object customNameObject, String target, String replacement) {
|
||||
// Custom name is expected to be a ChatComponentText with empty text and child components (called "siblings") that do not contain more components.
|
||||
T rootComponent = versionAdapter.cast(customNameObject);
|
||||
if (!versionAdapter.getText(rootComponent).isEmpty()) {
|
||||
throw new IllegalArgumentException("Expected root component with empty text");
|
||||
}
|
||||
|
||||
boolean[] childrenContainingTarget = null;
|
||||
List<T> children = versionAdapter.getSiblings(rootComponent);
|
||||
int childrenSize = children.size();
|
||||
|
||||
for (int i = 0; i < childrenSize; i++) {
|
||||
T childComponent = versionAdapter.cast(children.get(i));
|
||||
|
||||
if (!versionAdapter.getSiblings(childComponent).isEmpty()) {
|
||||
throw new IllegalArgumentException("Expected child component without sub-nodes");
|
||||
}
|
||||
|
||||
if (versionAdapter.getText(childComponent).contains(target)) {
|
||||
// Lazy initialization for performance, since this method can be called frequently.
|
||||
if (childrenContainingTarget == null) {
|
||||
childrenContainingTarget = new boolean[childrenSize];
|
||||
}
|
||||
childrenContainingTarget[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (childrenContainingTarget == null) {
|
||||
// No match found, return original unmodified object.
|
||||
return rootComponent;
|
||||
}
|
||||
|
||||
// Clone all the objects and apply replacements where needed.
|
||||
T clonedRoot = versionAdapter.cloneComponent(rootComponent);
|
||||
for (int i = 0; i < childrenSize; i++) {
|
||||
T childComponent = children.get(i);
|
||||
|
||||
String newText = versionAdapter.getText(childComponent);
|
||||
if (childrenContainingTarget[i]) {
|
||||
newText = newText.replace(target, replacement);
|
||||
}
|
||||
|
||||
T clonedChild = versionAdapter.cloneComponent(childComponent, newText);
|
||||
versionAdapter.addSibling(clonedRoot, clonedChild);
|
||||
}
|
||||
|
||||
return clonedRoot;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.interfaces;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.Hologram;
|
||||
import com.gmail.filoghost.holographicdisplays.api.handler.PickupHandler;
|
||||
|
||||
public interface ItemPickupManager {
|
||||
|
||||
public void handleItemLinePickup(Player player, PickupHandler pickupHandler, Hologram hologram);
|
||||
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.interfaces;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.ItemLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSSlime;
|
||||
|
||||
public interface NMSManager {
|
||||
|
||||
// A method to register all the custom entities of the plugin, it may fail.
|
||||
public void setup() throws Exception;
|
||||
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket);
|
||||
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager);
|
||||
|
||||
public NMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece);
|
||||
|
||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity);
|
||||
|
||||
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity);
|
||||
|
||||
public NMSEntityBase getNMSEntityBaseFromID(World bukkitWorld, int entityID);
|
||||
|
||||
public Object replaceCustomNameText(Object customNameObject, String target, String replacement);
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.interfaces.entity;
|
||||
|
||||
public interface NMSArmorStand extends NMSNameable {
|
||||
|
||||
// Sets the location through NMS and optionally broadcast an additional teleport packet containing the location.
|
||||
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket);
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.interfaces.entity;
|
||||
|
||||
public interface NMSCanMount extends NMSEntityBase {
|
||||
|
||||
// Sets the passenger of this entity through NMS.
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase);
|
||||
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.interfaces.entity;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
|
||||
/**
|
||||
* An interface to represent a custom NMS entity being part of a hologram.
|
||||
*/
|
||||
public interface NMSEntityBase {
|
||||
|
||||
// Returns the linked CraftHologramLine, all the entities are part of a piece. Should never be null.
|
||||
public HologramLine getHologramLine();
|
||||
|
||||
// Returns if the entity is dead through NMS.
|
||||
public boolean isDeadNMS();
|
||||
|
||||
// Kills the entity through NMS.
|
||||
public void killEntityNMS();
|
||||
|
||||
// The entity ID.
|
||||
public int getIdNMS();
|
||||
|
||||
// Returns the bukkit entity.
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS();
|
||||
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.interfaces.entity;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface NMSItem extends NMSEntityBase, NMSCanMount {
|
||||
|
||||
// Sets the location through NMS.
|
||||
public void setLocationNMS(double x, double y, double z);
|
||||
|
||||
// Sets the bukkit ItemStack for this item.
|
||||
public void setItemStackNMS(ItemStack stack);
|
||||
|
||||
// Sets if this item can be picked up by players.
|
||||
public void allowPickup(boolean pickup);
|
||||
|
||||
// The raw NMS ItemStack object.
|
||||
public Object getRawItemStack();
|
||||
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.interfaces.entity;
|
||||
|
||||
public interface NMSNameable extends NMSEntityBase {
|
||||
|
||||
// Sets a custom name as a String.
|
||||
public void setCustomNameNMS(String name);
|
||||
|
||||
// Returns the custom name as a String.
|
||||
public String getCustomNameStringNMS();
|
||||
|
||||
// Returns the custom name as version-dependent NMS object (String for MC 1.12 and below, ChatComponent for MC 1.13+ a ChatComponent).
|
||||
public Object getCustomNameObjectNMS();
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.interfaces.entity;
|
||||
|
||||
public interface NMSSlime extends NMSEntityBase, NMSCanMount {
|
||||
|
||||
// Sets the location through NMS.
|
||||
public void setLocationNMS(double x, double y, double z);
|
||||
|
||||
}
|
34
NMS/pom.xml
34
NMS/pom.xml
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-parent</artifactId>
|
||||
<version>2.4.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<name>HolographicDisplays NMS</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>Interfaces</module>
|
||||
<module>v1_8_R2</module>
|
||||
<module>v1_8_R3</module>
|
||||
<module>v1_9_R1</module>
|
||||
<module>v1_9_R2</module>
|
||||
<module>v1_10_R1</module>
|
||||
<module>v1_11_R1</module>
|
||||
<module>v1_12_R1</module>
|
||||
<module>v1_13_R1</module>
|
||||
<module>v1_13_R2</module>
|
||||
<module>v1_14_R1</module>
|
||||
<module>v1_15_R1</module>
|
||||
<module>v1_16_R1</module>
|
||||
<module>v1_16_R2</module>
|
||||
<module>v1_16_R3</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
|
@ -1,41 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<version>2.4.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-nms-v1_10_r1</artifactId>
|
||||
<name>HolographicDisplays NMS v1_10_R1</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nms-repo</id>
|
||||
<url>https://repo.codemc.io/repository/nms/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_10_R1;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftNMSArmorStand extends CraftArmorStand {
|
||||
|
||||
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Armor stand class
|
||||
@Override public void setArms(boolean arms) { }
|
||||
@Override public void setBasePlate(boolean basePlate) { }
|
||||
@Override public void setBodyPose(EulerAngle pose) { }
|
||||
@Override public void setBoots(ItemStack item) { }
|
||||
@Override public void setChestplate(ItemStack item) { }
|
||||
@Override public void setHeadPose(EulerAngle pose) { }
|
||||
@Override public void setHelmet(ItemStack item) { }
|
||||
@Override public void setItemInHand(ItemStack item) { }
|
||||
@Override public void setLeftArmPose(EulerAngle pose) { }
|
||||
@Override public void setLeftLegPose(EulerAngle pose) { }
|
||||
@Override public void setLeggings(ItemStack item) { }
|
||||
@Override public void setRightArmPose(EulerAngle pose) { }
|
||||
@Override public void setRightLegPose(EulerAngle pose) { }
|
||||
@Override public void setSmall(boolean small) { }
|
||||
@Override public void setVisible(boolean visible) { }
|
||||
@Override public void setMarker(boolean marker) { }
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_10_R1;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftItem;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftNMSItem extends CraftItem {
|
||||
|
||||
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from Item
|
||||
@Override public void setItemStack(ItemStack stack) { }
|
||||
@Override public void setPickupDelay(int delay) { }
|
||||
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_10_R1;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftSlime;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftNMSSlime extends CraftSlime {
|
||||
|
||||
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from Slime
|
||||
@Override public void setSize(int size) { }
|
||||
|
||||
}
|
|
@ -1,243 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_10_R1;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
||||
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_10_R1.DamageSource;
|
||||
import net.minecraft.server.v1_10_R1.EntityArmorStand;
|
||||
import net.minecraft.server.v1_10_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_10_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_10_R1.EnumHand;
|
||||
import net.minecraft.server.v1_10_R1.EnumInteractionResult;
|
||||
import net.minecraft.server.v1_10_R1.EnumItemSlot;
|
||||
import net.minecraft.server.v1_10_R1.ItemStack;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.Vec3D;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
||||
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
super.setArms(false);
|
||||
super.setNoGravity(true);
|
||||
super.setBasePlate(true);
|
||||
super.setMarker(true);
|
||||
super.collides = false;
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
|
||||
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, ItemStack itemstack, EnumHand enumhand) {
|
||||
// Prevent stand being equipped
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(int i, ItemStack item) {
|
||||
// Prevent stand being equipped
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(customName);
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameStringNMS() {
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCustomNameObjectNMS() {
|
||||
return super.getCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
||||
super.setPosition(x, y, z);
|
||||
if (broadcastLocationPacket) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (Object obj : super.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
}
|
|
@ -1,272 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_10_R1;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.ItemLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.ItemPickupManager;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ItemUtils;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
||||
import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectField;
|
||||
|
||||
import net.minecraft.server.v1_10_R1.Blocks;
|
||||
import net.minecraft.server.v1_10_R1.DamageSource;
|
||||
import net.minecraft.server.v1_10_R1.Entity;
|
||||
import net.minecraft.server.v1_10_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_10_R1.EntityItem;
|
||||
import net.minecraft.server.v1_10_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_10_R1.ItemStack;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagList;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagString;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutMount;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
||||
|
||||
private ItemLine parentPiece;
|
||||
private ItemPickupManager itemPickupManager;
|
||||
|
||||
private int resendMountPacketTicks;
|
||||
|
||||
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
||||
super(world);
|
||||
super.pickupDelay = Integer.MAX_VALUE;
|
||||
this.parentPiece = piece;
|
||||
this.itemPickupManager = itemPickupManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
|
||||
if (resendMountPacketTicks++ > 20) {
|
||||
resendMountPacketTicks = 0;
|
||||
|
||||
if (bB() != null) {
|
||||
// Send a packet near to "remind" players that the item is riding the armor stand (Spigot bug or client bug)
|
||||
PacketPlayOutMount mountPacket = new PacketPlayOutMount(bB());
|
||||
|
||||
for (Object obj : super.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||
if (distanceSquared < 1024 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
// Method called when a player is near.
|
||||
@Override
|
||||
public void d(EntityHuman human) {
|
||||
|
||||
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
||||
// Too low or too high, it's a bit weird.
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
||||
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
||||
// It is never added to the inventory.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
// This override prevents items from being picked up by hoppers.
|
||||
// Should have no side effects.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
|
||||
ItemStack newItem = CraftItemStack.asNMSCopy(stack);
|
||||
|
||||
if (newItem == null) {
|
||||
newItem = new ItemStack(Blocks.BEDROCK);
|
||||
}
|
||||
|
||||
if (newItem.getTag() == null) {
|
||||
newItem.setTag(new NBTTagCompound());
|
||||
}
|
||||
NBTTagCompound display = newItem.getTag().getCompound("display");
|
||||
|
||||
if (!newItem.getTag().hasKey("display")) {
|
||||
newItem.getTag().set("display", display);
|
||||
}
|
||||
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
||||
display.set("Lore", tagList);
|
||||
|
||||
setItemStack(newItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allowPickup(boolean pickup) {
|
||||
if (pickup) {
|
||||
super.pickupDelay = 0;
|
||||
} else {
|
||||
super.pickupDelay = Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.bB() != null) {
|
||||
Entity oldVehicle = super.bB();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getRawItemStack() {
|
||||
return super.getItemStack();
|
||||
}
|
||||
}
|
|
@ -1,246 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_10_R1;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSSlime;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
||||
import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectField;
|
||||
|
||||
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_10_R1.DamageSource;
|
||||
import net.minecraft.server.v1_10_R1.Entity;
|
||||
import net.minecraft.server.v1_10_R1.EntityDamageSource;
|
||||
import net.minecraft.server.v1_10_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_10_R1.EntitySlime;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutMount;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
||||
|
||||
private HologramLine parentPiece;
|
||||
|
||||
private int resendMountPacketTicks;
|
||||
|
||||
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.persistent = true;
|
||||
super.collides = false;
|
||||
a(0.0F, 0.0F);
|
||||
setSize(1);
|
||||
setInvisible(true);
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
|
||||
if (resendMountPacketTicks++ > 20) {
|
||||
resendMountPacketTicks = 0;
|
||||
|
||||
if (bB() != null) {
|
||||
// Send a packet near to "remind" players that the slime is riding the armor stand (Spigot bug or client bug)
|
||||
PacketPlayOutMount mountPacket = new PacketPlayOutMount(bB());
|
||||
|
||||
for (Object obj : super.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||
if (distanceSquared < 1024 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damageSource, float amount) {
|
||||
if (damageSource instanceof EntityDamageSource) {
|
||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.bB() != null) {
|
||||
Entity oldVehicle = super.bB();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,156 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_10_R1;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.ItemLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.ItemPickupManager;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.CustomNameHelper;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.NMSManager;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||
import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectField;
|
||||
|
||||
import net.minecraft.server.v1_10_R1.Entity;
|
||||
import net.minecraft.server.v1_10_R1.EntityTypes;
|
||||
import net.minecraft.server.v1_10_R1.MathHelper;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
import net.minecraft.server.v1_10_R1.WorldServer;
|
||||
|
||||
public class NmsManagerImpl implements NMSManager {
|
||||
|
||||
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "d");
|
||||
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f");
|
||||
|
||||
private Method validateEntityMethod;
|
||||
|
||||
@Override
|
||||
public void setup() throws Exception {
|
||||
registerCustomEntity(EntityNMSArmorStand.class, "ArmorStand", 30);
|
||||
registerCustomEntity(EntityNMSItem.class, "Item", 1);
|
||||
registerCustomEntity(EntityNMSSlime.class, "Slime", 55);
|
||||
|
||||
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
||||
validateEntityMethod.setAccessible(true);
|
||||
}
|
||||
|
||||
public void registerCustomEntity(Class<?> entityClass, String name, int id) throws Exception {
|
||||
ENTITY_NAMES_BY_CLASS_FIELD.getStatic().put(entityClass, name);
|
||||
ENTITY_IDS_BY_CLASS_FIELD.getStatic().put(entityClass, Integer.valueOf(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
||||
customItem.setLocationNMS(x, y, z);
|
||||
customItem.setItemStackNMS(stack);
|
||||
if (!addEntityToWorld(nmsWorld, customItem)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return customItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
||||
touchSlime.setLocationNMS(x, y, z);
|
||||
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return touchSlime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
||||
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
||||
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return invisibleArmorStand;
|
||||
}
|
||||
|
||||
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
||||
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
||||
|
||||
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
|
||||
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
|
||||
|
||||
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
|
||||
// This should never happen
|
||||
nmsEntity.dead = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity);
|
||||
nmsWorld.entityList.add(nmsEntity);
|
||||
|
||||
try {
|
||||
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object replaceCustomNameText(Object customNameObject, String target, String replacement) {
|
||||
return CustomNameHelper.replaceCustomNameString(customNameObject, target, replacement);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,123 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_10_R1;
|
||||
|
||||
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.MovingObjectPosition;
|
||||
import net.minecraft.server.v1_10_R1.Vec3D;
|
||||
|
||||
public class NullBoundingBox extends AxisAlignedBB {
|
||||
|
||||
public NullBoundingBox() {
|
||||
super(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double a() {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double a(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double b(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean b(AxisAlignedBB arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double c(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB c(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB shrink(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(BlockPosition arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean b(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB e(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB g(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<version>2.4.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-nms-v1_11_r1</artifactId>
|
||||
<name>HolographicDisplays NMS v1_11_R1</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nms-repo</id>
|
||||
<url>https://repo.codemc.io/repository/nms/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.11-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_11_R1;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftNMSArmorStand extends CraftArmorStand {
|
||||
|
||||
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Armor stand class
|
||||
@Override public void setArms(boolean arms) { }
|
||||
@Override public void setBasePlate(boolean basePlate) { }
|
||||
@Override public void setBodyPose(EulerAngle pose) { }
|
||||
@Override public void setBoots(ItemStack item) { }
|
||||
@Override public void setChestplate(ItemStack item) { }
|
||||
@Override public void setHeadPose(EulerAngle pose) { }
|
||||
@Override public void setHelmet(ItemStack item) { }
|
||||
@Override public void setItemInHand(ItemStack item) { }
|
||||
@Override public void setLeftArmPose(EulerAngle pose) { }
|
||||
@Override public void setLeftLegPose(EulerAngle pose) { }
|
||||
@Override public void setLeggings(ItemStack item) { }
|
||||
@Override public void setRightArmPose(EulerAngle pose) { }
|
||||
@Override public void setRightLegPose(EulerAngle pose) { }
|
||||
@Override public void setSmall(boolean small) { }
|
||||
@Override public void setVisible(boolean visible) { }
|
||||
@Override public void setMarker(boolean marker) { }
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_11_R1;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftItem;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftNMSItem extends CraftItem {
|
||||
|
||||
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from Item
|
||||
@Override public void setItemStack(ItemStack stack) { }
|
||||
@Override public void setPickupDelay(int delay) { }
|
||||
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_11_R1;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftSlime;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftNMSSlime extends CraftSlime {
|
||||
|
||||
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from Slime
|
||||
@Override public void setSize(int size) { }
|
||||
|
||||
}
|
|
@ -1,243 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_11_R1;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
||||
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_11_R1.DamageSource;
|
||||
import net.minecraft.server.v1_11_R1.EntityArmorStand;
|
||||
import net.minecraft.server.v1_11_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_11_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_11_R1.EnumHand;
|
||||
import net.minecraft.server.v1_11_R1.EnumInteractionResult;
|
||||
import net.minecraft.server.v1_11_R1.EnumItemSlot;
|
||||
import net.minecraft.server.v1_11_R1.ItemStack;
|
||||
import net.minecraft.server.v1_11_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.v1_11_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_11_R1.Vec3D;
|
||||
import net.minecraft.server.v1_11_R1.World;
|
||||
|
||||
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
||||
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
super.setArms(false);
|
||||
super.setNoGravity(true);
|
||||
super.setBasePlate(true);
|
||||
super.setMarker(true);
|
||||
super.collides = false;
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
|
||||
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void A_() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
||||
// Prevent stand being equipped
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(int i, ItemStack item) {
|
||||
// Prevent stand being equipped
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(customName);
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameStringNMS() {
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCustomNameObjectNMS() {
|
||||
return super.getCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
||||
super.setPosition(x, y, z);
|
||||
if (broadcastLocationPacket) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (Object obj : super.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
}
|
|
@ -1,247 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_11_R1;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.ItemLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.ItemPickupManager;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ItemUtils;
|
||||
import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectField;
|
||||
|
||||
import net.minecraft.server.v1_11_R1.Blocks;
|
||||
import net.minecraft.server.v1_11_R1.DamageSource;
|
||||
import net.minecraft.server.v1_11_R1.Entity;
|
||||
import net.minecraft.server.v1_11_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_11_R1.EntityItem;
|
||||
import net.minecraft.server.v1_11_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_11_R1.ItemStack;
|
||||
import net.minecraft.server.v1_11_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_11_R1.NBTTagList;
|
||||
import net.minecraft.server.v1_11_R1.NBTTagString;
|
||||
import net.minecraft.server.v1_11_R1.World;
|
||||
|
||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
||||
|
||||
private ItemLine parentPiece;
|
||||
private ItemPickupManager itemPickupManager;
|
||||
|
||||
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
||||
super(world);
|
||||
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
|
||||
this.parentPiece = piece;
|
||||
this.itemPickupManager = itemPickupManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void A_() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
// Method called when a player is near.
|
||||
@Override
|
||||
public void d(EntityHuman human) {
|
||||
|
||||
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
||||
// Too low or too high, it's a bit weird.
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
||||
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
||||
// It is never added to the inventory.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
// This override prevents items from being picked up by hoppers.
|
||||
// Should have no side effects.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
|
||||
ItemStack newItem = CraftItemStack.asNMSCopy(stack); // ItemStack.a is returned if the stack is null, invalid or the material is not an Item
|
||||
|
||||
if (newItem == null || newItem == ItemStack.a) {
|
||||
newItem = new ItemStack(Blocks.BEDROCK);
|
||||
}
|
||||
|
||||
if (newItem.getTag() == null) {
|
||||
newItem.setTag(new NBTTagCompound());
|
||||
}
|
||||
NBTTagCompound display = newItem.getTag().getCompound("display"); // Returns a new NBTTagCompound if not existing
|
||||
if (!newItem.getTag().hasKey("display")) {
|
||||
newItem.getTag().set("display", display);
|
||||
}
|
||||
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
||||
display.set("Lore", tagList);
|
||||
|
||||
setItemStack(newItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allowPickup(boolean pickup) {
|
||||
if (pickup) {
|
||||
super.pickupDelay = 0;
|
||||
} else {
|
||||
super.pickupDelay = 32767;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.bB() != null) {
|
||||
Entity oldVehicle = super.bB();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getRawItemStack() {
|
||||
return super.getItemStack();
|
||||
}
|
||||
}
|
|
@ -1,222 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_11_R1;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSSlime;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||
import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectField;
|
||||
|
||||
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_11_R1.DamageSource;
|
||||
import net.minecraft.server.v1_11_R1.Entity;
|
||||
import net.minecraft.server.v1_11_R1.EntityDamageSource;
|
||||
import net.minecraft.server.v1_11_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_11_R1.EntitySlime;
|
||||
import net.minecraft.server.v1_11_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_11_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_11_R1.World;
|
||||
|
||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
||||
|
||||
private HologramLine parentPiece;
|
||||
|
||||
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.persistent = true;
|
||||
super.collides = false;
|
||||
a(0.0F, 0.0F);
|
||||
setSize(1, false);
|
||||
setInvisible(true);
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void A_() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damageSource, float amount) {
|
||||
if (damageSource instanceof EntityDamageSource) {
|
||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.bB() != null) {
|
||||
Entity oldVehicle = super.bB();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,165 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_11_R1;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.ItemLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.ItemPickupManager;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.CustomNameHelper;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.NMSManager;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||
import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectField;
|
||||
|
||||
import net.minecraft.server.v1_11_R1.Entity;
|
||||
import net.minecraft.server.v1_11_R1.EntityTypes;
|
||||
import net.minecraft.server.v1_11_R1.MathHelper;
|
||||
import net.minecraft.server.v1_11_R1.RegistryID;
|
||||
import net.minecraft.server.v1_11_R1.RegistryMaterials;
|
||||
import net.minecraft.server.v1_11_R1.World;
|
||||
import net.minecraft.server.v1_11_R1.WorldServer;
|
||||
|
||||
public class NmsManagerImpl implements NMSManager {
|
||||
|
||||
private static final ReflectField<RegistryID<Class<? extends Entity>>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "a");
|
||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d");
|
||||
|
||||
private Method validateEntityMethod;
|
||||
|
||||
@Override
|
||||
public void setup() throws Exception {
|
||||
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
||||
validateEntityMethod.setAccessible(true);
|
||||
|
||||
registerCustomEntity(EntityNMSSlime.class, 55);
|
||||
}
|
||||
|
||||
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
||||
// Use reflection to get the RegistryID of entities.
|
||||
RegistryID<Class<? extends Entity>> registryID = REGISTRY_ID_FIELD.get(EntityTypes.b);
|
||||
Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID);
|
||||
|
||||
// Save the the ID -> entity class mapping before the registration.
|
||||
Object oldValue = idToClassMap[id];
|
||||
|
||||
// Register the entity class.
|
||||
registryID.a(entityClass, id);
|
||||
|
||||
// Restore the ID -> entity class mapping.
|
||||
idToClassMap[id] = oldValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
||||
customItem.setLocationNMS(x, y, z);
|
||||
customItem.setItemStackNMS(stack);
|
||||
if (!addEntityToWorld(nmsWorld, customItem)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return customItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
||||
touchSlime.setLocationNMS(x, y, z);
|
||||
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return touchSlime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
||||
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
||||
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return invisibleArmorStand;
|
||||
}
|
||||
|
||||
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
||||
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
||||
|
||||
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
|
||||
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
|
||||
|
||||
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
|
||||
// This should never happen
|
||||
nmsEntity.dead = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity);
|
||||
nmsWorld.entityList.add(nmsEntity);
|
||||
|
||||
try {
|
||||
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object replaceCustomNameText(Object customNameObject, String target, String replacement) {
|
||||
return CustomNameHelper.replaceCustomNameString(customNameObject, target, replacement);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,141 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_11_R1;
|
||||
|
||||
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_11_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_11_R1.MovingObjectPosition;
|
||||
import net.minecraft.server.v1_11_R1.Vec3D;
|
||||
|
||||
public class NullBoundingBox extends AxisAlignedBB {
|
||||
|
||||
public NullBoundingBox() {
|
||||
super(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double a() {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double a(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double b(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double c(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB shrink(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(BlockPosition arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean b(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB e(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB g(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(Vec3D arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB b(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB b(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(AxisAlignedBB arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB d(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean e(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<version>2.4.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-nms-v1_12_r1</artifactId>
|
||||
<name>HolographicDisplays NMS v1_12_R1</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nms-repo</id>
|
||||
<url>https://repo.codemc.io/repository/nms/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.12-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,93 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_12_R1;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftNMSArmorStand extends CraftArmorStand {
|
||||
|
||||
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Armor stand class
|
||||
|
||||
@Override public void setArms(boolean arms) { }
|
||||
@Override public void setBasePlate(boolean basePlate) { }
|
||||
@Override public void setBodyPose(EulerAngle pose) { }
|
||||
@Override public void setBoots(ItemStack item) { }
|
||||
@Override public void setChestplate(ItemStack item) { }
|
||||
@Override public void setHeadPose(EulerAngle pose) { }
|
||||
@Override public void setHelmet(ItemStack item) { }
|
||||
@Override public void setItemInHand(ItemStack item) { }
|
||||
@Override public void setLeftArmPose(EulerAngle pose) { }
|
||||
@Override public void setLeftLegPose(EulerAngle pose) { }
|
||||
@Override public void setLeggings(ItemStack item) { }
|
||||
@Override public void setRightArmPose(EulerAngle pose) { }
|
||||
@Override public void setRightLegPose(EulerAngle pose) { }
|
||||
@Override public void setSmall(boolean small) { }
|
||||
@Override public void setVisible(boolean visible) { }
|
||||
@Override public void setMarker(boolean marker) { }
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_12_R1;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftItem;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftNMSItem extends CraftItem {
|
||||
|
||||
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from Item
|
||||
@Override public void setItemStack(ItemStack stack) { }
|
||||
@Override public void setPickupDelay(int delay) { }
|
||||
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_12_R1;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftSlime;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftNMSSlime extends CraftSlime {
|
||||
|
||||
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from Slime
|
||||
@Override public void setSize(int size) { }
|
||||
|
||||
}
|
|
@ -1,243 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_12_R1;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
||||
import net.minecraft.server.v1_12_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_12_R1.DamageSource;
|
||||
import net.minecraft.server.v1_12_R1.EntityArmorStand;
|
||||
import net.minecraft.server.v1_12_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_12_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_12_R1.EnumHand;
|
||||
import net.minecraft.server.v1_12_R1.EnumInteractionResult;
|
||||
import net.minecraft.server.v1_12_R1.EnumItemSlot;
|
||||
import net.minecraft.server.v1_12_R1.ItemStack;
|
||||
import net.minecraft.server.v1_12_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.v1_12_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_12_R1.Vec3D;
|
||||
import net.minecraft.server.v1_12_R1.World;
|
||||
|
||||
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
||||
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
super.setArms(false);
|
||||
super.setNoGravity(true);
|
||||
super.setBasePlate(true);
|
||||
super.setMarker(true);
|
||||
super.collides = false;
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
|
||||
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void B_() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
||||
// Prevent stand being equipped
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(int i, ItemStack item) {
|
||||
// Prevent stand being equipped
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(customName);
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameStringNMS() {
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCustomNameObjectNMS() {
|
||||
return super.getCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
||||
super.setPosition(x, y, z);
|
||||
if (broadcastLocationPacket) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (Object obj : super.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
}
|
|
@ -1,247 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_12_R1;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.ItemLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.ItemPickupManager;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ItemUtils;
|
||||
import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectField;
|
||||
|
||||
import net.minecraft.server.v1_12_R1.Blocks;
|
||||
import net.minecraft.server.v1_12_R1.DamageSource;
|
||||
import net.minecraft.server.v1_12_R1.Entity;
|
||||
import net.minecraft.server.v1_12_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_12_R1.EntityItem;
|
||||
import net.minecraft.server.v1_12_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_12_R1.ItemStack;
|
||||
import net.minecraft.server.v1_12_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_12_R1.NBTTagList;
|
||||
import net.minecraft.server.v1_12_R1.NBTTagString;
|
||||
import net.minecraft.server.v1_12_R1.World;
|
||||
|
||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
||||
|
||||
private ItemLine parentPiece;
|
||||
private ItemPickupManager itemPickupManager;
|
||||
|
||||
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
||||
super(world);
|
||||
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
|
||||
this.parentPiece = piece;
|
||||
this.itemPickupManager = itemPickupManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void B_() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
// Method called when a player is near.
|
||||
@Override
|
||||
public void d(EntityHuman human) {
|
||||
|
||||
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
||||
// Too low or too high, it's a bit weird.
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
||||
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
||||
// It is never added to the inventory.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
// This override prevents items from being picked up by hoppers.
|
||||
// Should have no side effects.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
|
||||
ItemStack newItem = CraftItemStack.asNMSCopy(stack); // ItemStack.a is returned if the stack is null, invalid or the material is not an Item
|
||||
|
||||
if (newItem == null || newItem == ItemStack.a) {
|
||||
newItem = new ItemStack(Blocks.BEDROCK);
|
||||
}
|
||||
|
||||
if (newItem.getTag() == null) {
|
||||
newItem.setTag(new NBTTagCompound());
|
||||
}
|
||||
NBTTagCompound display = newItem.getTag().getCompound("display"); // Returns a new NBTTagCompound if not existing
|
||||
if (!newItem.getTag().hasKey("display")) {
|
||||
newItem.getTag().set("display", display);
|
||||
}
|
||||
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
||||
display.set("Lore", tagList);
|
||||
|
||||
setItemStack(newItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allowPickup(boolean pickup) {
|
||||
if (pickup) {
|
||||
super.pickupDelay = 0;
|
||||
} else {
|
||||
super.pickupDelay = 32767;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.bJ() != null) {
|
||||
Entity oldVehicle = super.bJ();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getRawItemStack() {
|
||||
return super.getItemStack();
|
||||
}
|
||||
}
|
|
@ -1,222 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_12_R1;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSSlime;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||
import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectField;
|
||||
|
||||
import net.minecraft.server.v1_12_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_12_R1.DamageSource;
|
||||
import net.minecraft.server.v1_12_R1.Entity;
|
||||
import net.minecraft.server.v1_12_R1.EntityDamageSource;
|
||||
import net.minecraft.server.v1_12_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_12_R1.EntitySlime;
|
||||
import net.minecraft.server.v1_12_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_12_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_12_R1.World;
|
||||
|
||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
||||
|
||||
private HologramLine parentPiece;
|
||||
|
||||
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.persistent = true;
|
||||
super.collides = false;
|
||||
a(0.0F, 0.0F);
|
||||
setSize(1, false);
|
||||
setInvisible(true);
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void B_() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damageSource, float amount) {
|
||||
if (damageSource instanceof EntityDamageSource) {
|
||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.bJ() != null) {
|
||||
Entity oldVehicle = super.bJ();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,165 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_12_R1;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.ItemLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.ItemPickupManager;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.CustomNameHelper;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.NMSManager;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||
import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectField;
|
||||
|
||||
import net.minecraft.server.v1_12_R1.Entity;
|
||||
import net.minecraft.server.v1_12_R1.EntityTypes;
|
||||
import net.minecraft.server.v1_12_R1.MathHelper;
|
||||
import net.minecraft.server.v1_12_R1.RegistryID;
|
||||
import net.minecraft.server.v1_12_R1.RegistryMaterials;
|
||||
import net.minecraft.server.v1_12_R1.World;
|
||||
import net.minecraft.server.v1_12_R1.WorldServer;
|
||||
|
||||
public class NmsManagerImpl implements NMSManager {
|
||||
|
||||
private static final ReflectField<RegistryID<Class<? extends Entity>>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "a");
|
||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d");
|
||||
|
||||
private Method validateEntityMethod;
|
||||
|
||||
@Override
|
||||
public void setup() throws Exception {
|
||||
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
||||
validateEntityMethod.setAccessible(true);
|
||||
|
||||
registerCustomEntity(EntityNMSSlime.class, 55);
|
||||
}
|
||||
|
||||
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
||||
// Use reflection to get the RegistryID of entities.
|
||||
RegistryID<Class<? extends Entity>> registryID = REGISTRY_ID_FIELD.get(EntityTypes.b);
|
||||
Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID);
|
||||
|
||||
// Save the the ID -> entity class mapping before the registration.
|
||||
Object oldValue = idToClassMap[id];
|
||||
|
||||
// Register the entity class.
|
||||
registryID.a(entityClass, id);
|
||||
|
||||
// Restore the ID -> entity class mapping.
|
||||
idToClassMap[id] = oldValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
||||
customItem.setLocationNMS(x, y, z);
|
||||
customItem.setItemStackNMS(stack);
|
||||
if (!addEntityToWorld(nmsWorld, customItem)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return customItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
||||
touchSlime.setLocationNMS(x, y, z);
|
||||
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return touchSlime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
||||
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
||||
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return invisibleArmorStand;
|
||||
}
|
||||
|
||||
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
||||
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
||||
|
||||
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
|
||||
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
|
||||
|
||||
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
|
||||
// This should never happen
|
||||
nmsEntity.dead = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity);
|
||||
nmsWorld.entityList.add(nmsEntity);
|
||||
|
||||
try {
|
||||
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object replaceCustomNameText(Object customNameObject, String target, String replacement) {
|
||||
return CustomNameHelper.replaceCustomNameString(customNameObject, target, replacement);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,141 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_12_R1;
|
||||
|
||||
import net.minecraft.server.v1_12_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_12_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_12_R1.MovingObjectPosition;
|
||||
import net.minecraft.server.v1_12_R1.Vec3D;
|
||||
|
||||
public class NullBoundingBox extends AxisAlignedBB {
|
||||
|
||||
public NullBoundingBox() {
|
||||
super(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double a() {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double a(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double b(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double c(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB shrink(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(BlockPosition arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean b(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB e(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB g(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(Vec3D arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB b(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB b(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(AxisAlignedBB arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB d(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean e(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<version>2.4.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-nms-v1_13_r1</artifactId>
|
||||
<name>HolographicDisplays NMS v1_13_R1</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nms-repo</id>
|
||||
<url>https://repo.codemc.io/repository/nms/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.13-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,95 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_13_R1;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.entity.CraftArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftNMSArmorStand extends CraftArmorStand {
|
||||
|
||||
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Armor stand class
|
||||
|
||||
@Override public void setArms(boolean arms) { }
|
||||
@Override public void setBasePlate(boolean basePlate) { }
|
||||
@Override public void setBodyPose(EulerAngle pose) { }
|
||||
@Override public void setBoots(ItemStack item) { }
|
||||
@Override public void setChestplate(ItemStack item) { }
|
||||
@Override public void setHeadPose(EulerAngle pose) { }
|
||||
@Override public void setHelmet(ItemStack item) { }
|
||||
@Override public void setItemInHand(ItemStack item) { }
|
||||
@Override public void setLeftArmPose(EulerAngle pose) { }
|
||||
@Override public void setLeftLegPose(EulerAngle pose) { }
|
||||
@Override public void setLeggings(ItemStack item) { }
|
||||
@Override public void setRightArmPose(EulerAngle pose) { }
|
||||
@Override public void setRightLegPose(EulerAngle pose) { }
|
||||
@Override public void setSmall(boolean small) { }
|
||||
@Override public void setVisible(boolean visible) { }
|
||||
@Override public void setMarker(boolean marker) { }
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) { }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_13_R1;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.entity.CraftItem;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftNMSItem extends CraftItem {
|
||||
|
||||
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from Item
|
||||
@Override public void setItemStack(ItemStack stack) { }
|
||||
@Override public void setPickupDelay(int delay) { }
|
||||
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_13_R1;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.entity.CraftSlime;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftNMSSlime extends CraftSlime {
|
||||
|
||||
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) { }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
|
||||
// Methods from Slime
|
||||
@Override public void setSize(int size) { }
|
||||
@Override public void setTarget(LivingEntity target) { }
|
||||
|
||||
}
|
|
@ -1,246 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_13_R1;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_13_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.util.CraftChatMessage;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
||||
|
||||
import net.minecraft.server.v1_13_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_13_R1.DamageSource;
|
||||
import net.minecraft.server.v1_13_R1.EntityArmorStand;
|
||||
import net.minecraft.server.v1_13_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_13_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_13_R1.EnumHand;
|
||||
import net.minecraft.server.v1_13_R1.EnumInteractionResult;
|
||||
import net.minecraft.server.v1_13_R1.EnumItemSlot;
|
||||
import net.minecraft.server.v1_13_R1.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_13_R1.ItemStack;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_13_R1.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.v1_13_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_13_R1.Vec3D;
|
||||
import net.minecraft.server.v1_13_R1.World;
|
||||
|
||||
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
||||
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
super.setArms(false);
|
||||
super.setNoGravity(true);
|
||||
super.setBasePlate(true);
|
||||
super.setMarker(true);
|
||||
super.collides = false;
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
|
||||
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(IChatBaseComponent ichatbasecomponent) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
||||
// Prevent stand being equipped
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(int i, ItemStack item) {
|
||||
// Prevent stand being equipped
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(CraftChatMessage.fromStringOrNull(customName));
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameStringNMS() {
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCustomNameObjectNMS() {
|
||||
return super.getCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
||||
super.setPosition(x, y, z);
|
||||
if (broadcastLocationPacket) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (Object obj : super.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
}
|
|
@ -1,247 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_13_R1;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_13_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.ItemLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.ItemPickupManager;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ItemUtils;
|
||||
import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectField;
|
||||
|
||||
import net.minecraft.server.v1_13_R1.Blocks;
|
||||
import net.minecraft.server.v1_13_R1.DamageSource;
|
||||
import net.minecraft.server.v1_13_R1.Entity;
|
||||
import net.minecraft.server.v1_13_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_13_R1.EntityItem;
|
||||
import net.minecraft.server.v1_13_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_13_R1.ItemStack;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagList;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagString;
|
||||
import net.minecraft.server.v1_13_R1.World;
|
||||
|
||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "ax");
|
||||
|
||||
private ItemLine parentPiece;
|
||||
private ItemPickupManager itemPickupManager;
|
||||
|
||||
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
||||
super(world);
|
||||
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
|
||||
this.parentPiece = piece;
|
||||
this.itemPickupManager = itemPickupManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
// Method called when a player is near.
|
||||
@Override
|
||||
public void d(EntityHuman human) {
|
||||
|
||||
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
||||
// Too low or too high, it's a bit weird.
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
||||
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
||||
// It is never added to the inventory.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
// This override prevents items from being picked up by hoppers.
|
||||
// Should have no side effects.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
|
||||
ItemStack newItem = CraftItemStack.asNMSCopy(stack); // ItemStack.a is returned if the stack is null, invalid or the material is not an Item
|
||||
|
||||
if (newItem == null || newItem == ItemStack.a) {
|
||||
newItem = new ItemStack(Blocks.BEDROCK);
|
||||
}
|
||||
|
||||
if (newItem.getTag() == null) {
|
||||
newItem.setTag(new NBTTagCompound());
|
||||
}
|
||||
NBTTagCompound display = newItem.getTag().getCompound("display"); // Returns a new NBTTagCompound if not existing
|
||||
if (!newItem.getTag().hasKey("display")) {
|
||||
newItem.getTag().set("display", display);
|
||||
}
|
||||
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
||||
display.set("Lore", tagList);
|
||||
|
||||
setItemStack(newItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allowPickup(boolean pickup) {
|
||||
if (pickup) {
|
||||
super.pickupDelay = 0;
|
||||
} else {
|
||||
super.pickupDelay = 32767;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.getVehicle() != null) {
|
||||
Entity oldVehicle = super.getVehicle();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getRawItemStack() {
|
||||
return super.getItemStack();
|
||||
}
|
||||
}
|
|
@ -1,223 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_13_R1;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.entity.CraftEntity;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSSlime;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||
import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectField;
|
||||
|
||||
import net.minecraft.server.v1_13_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_13_R1.DamageSource;
|
||||
import net.minecraft.server.v1_13_R1.Entity;
|
||||
import net.minecraft.server.v1_13_R1.EntityDamageSource;
|
||||
import net.minecraft.server.v1_13_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_13_R1.EntitySlime;
|
||||
import net.minecraft.server.v1_13_R1.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_13_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_13_R1.World;
|
||||
|
||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "ax");
|
||||
|
||||
private HologramLine parentPiece;
|
||||
|
||||
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.persistent = true;
|
||||
super.collides = false;
|
||||
a(0.0F, 0.0F);
|
||||
setSize(1, false);
|
||||
setInvisible(true);
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damageSource, float amount) {
|
||||
if (damageSource instanceof EntityDamageSource) {
|
||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(IChatBaseComponent ichatbasecomponent) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.getVehicle() != null) {
|
||||
Entity oldVehicle = super.getVehicle();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,215 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_13_R1;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.entity.CraftEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.ItemLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.ChatComponentAdapter;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.ItemPickupManager;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.CustomNameHelper;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.NMSManager;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||
import com.gmail.filoghost.holographicdisplays.util.VersionUtils;
|
||||
import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectField;
|
||||
|
||||
import net.minecraft.server.v1_13_R1.ChatComponentText;
|
||||
import net.minecraft.server.v1_13_R1.Entity;
|
||||
import net.minecraft.server.v1_13_R1.EntityTypes;
|
||||
import net.minecraft.server.v1_13_R1.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_13_R1.MathHelper;
|
||||
import net.minecraft.server.v1_13_R1.RegistryID;
|
||||
import net.minecraft.server.v1_13_R1.RegistryMaterials;
|
||||
import net.minecraft.server.v1_13_R1.World;
|
||||
import net.minecraft.server.v1_13_R1.WorldServer;
|
||||
|
||||
public class NmsManagerImpl implements NMSManager {
|
||||
|
||||
private static final ReflectField<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "a");
|
||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d");
|
||||
private static final ReflectField<List<Entity>> ENTITY_LIST_FIELD = new ReflectField<>(World.class, "entityList");
|
||||
|
||||
private Method validateEntityMethod;
|
||||
|
||||
@Override
|
||||
public void setup() throws Exception {
|
||||
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
||||
validateEntityMethod.setAccessible(true);
|
||||
|
||||
registerCustomEntity(EntityNMSSlime.class, 55);
|
||||
}
|
||||
|
||||
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
||||
// Use reflection to get the RegistryID of entities.
|
||||
RegistryID<EntityTypes<?>> registryID = REGISTRY_ID_FIELD.get(EntityTypes.REGISTRY);
|
||||
Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID);
|
||||
|
||||
// Save the the ID -> EntityTypes mapping before the registration.
|
||||
Object oldValue = idToClassMap[id];
|
||||
|
||||
// Register the EntityTypes object.
|
||||
registryID.a(new EntityTypes<>(entityClass, world -> null, true, true, null), id);
|
||||
|
||||
// Restore the ID -> EntityTypes mapping.
|
||||
idToClassMap[id] = oldValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
||||
customItem.setLocationNMS(x, y, z);
|
||||
customItem.setItemStackNMS(stack);
|
||||
if (!addEntityToWorld(nmsWorld, customItem)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return customItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
||||
touchSlime.setLocationNMS(x, y, z);
|
||||
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return touchSlime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
||||
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
||||
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return invisibleArmorStand;
|
||||
}
|
||||
|
||||
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
||||
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
||||
|
||||
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
|
||||
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
|
||||
|
||||
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
|
||||
// This should never happen
|
||||
nmsEntity.dead = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity);
|
||||
if (VersionUtils.isPaperServer()) {
|
||||
try {
|
||||
// Workaround because nmsWorld.entityList is a different class in Paper, if used without reflection it throws NoSuchFieldError.
|
||||
ENTITY_LIST_FIELD.get(nmsWorld).add(nmsEntity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
nmsWorld.entityList.add(nmsEntity);
|
||||
}
|
||||
|
||||
try {
|
||||
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object replaceCustomNameText(Object customNameObject, String target, String replacement) {
|
||||
return CustomNameHelper.replaceCustomNameChatComponent(NMSChatComponentAdapter.INSTANCE, customNameObject, target, replacement);
|
||||
}
|
||||
|
||||
private static enum NMSChatComponentAdapter implements ChatComponentAdapter<IChatBaseComponent> {
|
||||
|
||||
INSTANCE {
|
||||
|
||||
public ChatComponentText cast(Object chatComponentObject) {
|
||||
return (ChatComponentText) chatComponentObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(IChatBaseComponent chatComponent) {
|
||||
return chatComponent.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IChatBaseComponent> getSiblings(IChatBaseComponent chatComponent) {
|
||||
return chatComponent.a();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSibling(IChatBaseComponent chatComponent, IChatBaseComponent newSibling) {
|
||||
chatComponent.addSibling(newSibling);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatComponentText cloneComponent(IChatBaseComponent chatComponent, String newText) {
|
||||
ChatComponentText clonedChatComponent = new ChatComponentText(newText);
|
||||
clonedChatComponent.setChatModifier(chatComponent.getChatModifier().clone());
|
||||
return clonedChatComponent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,132 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_13_R1;
|
||||
|
||||
import net.minecraft.server.v1_13_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_13_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_13_R1.EnumDirection.EnumAxis;
|
||||
import net.minecraft.server.v1_13_R1.MovingObjectPosition;
|
||||
import net.minecraft.server.v1_13_R1.Vec3D;
|
||||
|
||||
public class NullBoundingBox extends AxisAlignedBB {
|
||||
|
||||
public NullBoundingBox() {
|
||||
super(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double a() {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB shrink(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(BlockPosition arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean b(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB g(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(Vec3D arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB b(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB b(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(AxisAlignedBB arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB d(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double a(EnumAxis arg0) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition a(Vec3D arg0, Vec3D arg1, BlockPosition arg2) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double b(EnumAxis arg0) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean e(double arg0, double arg1, double arg2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB f(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<version>2.4.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-nms-v1_13_r2</artifactId>
|
||||
<name>HolographicDisplays NMS v1_13_R2</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nms-repo</id>
|
||||
<url>https://repo.codemc.io/repository/nms/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.13.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_13_R2;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftNMSArmorStand extends CraftArmorStand {
|
||||
|
||||
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Armor stand class
|
||||
|
||||
@Override public void setArms(boolean arms) { }
|
||||
@Override public void setBasePlate(boolean basePlate) { }
|
||||
@Override public void setBodyPose(EulerAngle pose) { }
|
||||
@Override public void setBoots(ItemStack item) { }
|
||||
@Override public void setChestplate(ItemStack item) { }
|
||||
@Override public void setHeadPose(EulerAngle pose) { }
|
||||
@Override public void setHelmet(ItemStack item) { }
|
||||
@Override public void setItemInHand(ItemStack item) { }
|
||||
@Override public void setLeftArmPose(EulerAngle pose) { }
|
||||
@Override public void setLeftLegPose(EulerAngle pose) { }
|
||||
@Override public void setLeggings(ItemStack item) { }
|
||||
@Override public void setRightArmPose(EulerAngle pose) { }
|
||||
@Override public void setRightLegPose(EulerAngle pose) { }
|
||||
@Override public void setSmall(boolean small) { }
|
||||
@Override public void setVisible(boolean visible) { }
|
||||
@Override public void setMarker(boolean marker) { }
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) { }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
@Override public void setPersistent(boolean flag) { }
|
||||
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_13_R2;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftItem;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftNMSItem extends CraftItem {
|
||||
|
||||
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
@Override public void setPersistent(boolean flag) { }
|
||||
|
||||
// Methods from Item
|
||||
@Override public void setItemStack(ItemStack stack) { }
|
||||
@Override public void setPickupDelay(int delay) { }
|
||||
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_13_R2;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftSlime;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.loot.LootTable;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftNMSSlime extends CraftSlime {
|
||||
|
||||
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) { }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
@Override public void setPersistent(boolean flag) { }
|
||||
|
||||
// Methods from Mob
|
||||
@Override public void setLootTable(LootTable table) { }
|
||||
@Override public void setSeed(long seed) { }
|
||||
|
||||
// Methods from Slime
|
||||
@Override public void setSize(int size) { }
|
||||
@Override public void setTarget(LivingEntity target) { }
|
||||
|
||||
}
|
|
@ -1,246 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_13_R2;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.util.CraftChatMessage;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
||||
|
||||
import net.minecraft.server.v1_13_R2.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_13_R2.DamageSource;
|
||||
import net.minecraft.server.v1_13_R2.EntityArmorStand;
|
||||
import net.minecraft.server.v1_13_R2.EntityHuman;
|
||||
import net.minecraft.server.v1_13_R2.EntityPlayer;
|
||||
import net.minecraft.server.v1_13_R2.EnumHand;
|
||||
import net.minecraft.server.v1_13_R2.EnumInteractionResult;
|
||||
import net.minecraft.server.v1_13_R2.EnumItemSlot;
|
||||
import net.minecraft.server.v1_13_R2.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_13_R2.ItemStack;
|
||||
import net.minecraft.server.v1_13_R2.NBTTagCompound;
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.v1_13_R2.SoundEffect;
|
||||
import net.minecraft.server.v1_13_R2.Vec3D;
|
||||
import net.minecraft.server.v1_13_R2.World;
|
||||
|
||||
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
||||
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
super.setArms(false);
|
||||
super.setNoGravity(true);
|
||||
super.setBasePlate(true);
|
||||
super.setMarker(true);
|
||||
super.collides = false;
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
|
||||
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(IChatBaseComponent ichatbasecomponent) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
||||
// Prevent stand being equipped
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(int i, ItemStack item) {
|
||||
// Prevent stand being equipped
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(CraftChatMessage.fromStringOrNull(customName));
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameStringNMS() {
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCustomNameObjectNMS() {
|
||||
return super.getCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
||||
super.setPosition(x, y, z);
|
||||
if (broadcastLocationPacket) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (Object obj : super.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
}
|
|
@ -1,247 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_13_R2;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.ItemLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.ItemPickupManager;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ItemUtils;
|
||||
import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectField;
|
||||
|
||||
import net.minecraft.server.v1_13_R2.Blocks;
|
||||
import net.minecraft.server.v1_13_R2.DamageSource;
|
||||
import net.minecraft.server.v1_13_R2.Entity;
|
||||
import net.minecraft.server.v1_13_R2.EntityHuman;
|
||||
import net.minecraft.server.v1_13_R2.EntityItem;
|
||||
import net.minecraft.server.v1_13_R2.EntityPlayer;
|
||||
import net.minecraft.server.v1_13_R2.ItemStack;
|
||||
import net.minecraft.server.v1_13_R2.NBTTagCompound;
|
||||
import net.minecraft.server.v1_13_R2.NBTTagList;
|
||||
import net.minecraft.server.v1_13_R2.NBTTagString;
|
||||
import net.minecraft.server.v1_13_R2.World;
|
||||
|
||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "vehicle");
|
||||
|
||||
private ItemLine parentPiece;
|
||||
private ItemPickupManager itemPickupManager;
|
||||
|
||||
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
||||
super(world);
|
||||
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
|
||||
this.parentPiece = piece;
|
||||
this.itemPickupManager = itemPickupManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
// Method called when a player is near.
|
||||
@Override
|
||||
public void d(EntityHuman human) {
|
||||
|
||||
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
||||
// Too low or too high, it's a bit weird.
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
||||
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
||||
// It is never added to the inventory.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
// This override prevents items from being picked up by hoppers.
|
||||
// Should have no side effects.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
|
||||
ItemStack newItem = CraftItemStack.asNMSCopy(stack); // ItemStack.a is returned if the stack is null, invalid or the material is not an Item
|
||||
|
||||
if (newItem == null || newItem == ItemStack.a) {
|
||||
newItem = new ItemStack(Blocks.BEDROCK);
|
||||
}
|
||||
|
||||
if (newItem.getTag() == null) {
|
||||
newItem.setTag(new NBTTagCompound());
|
||||
}
|
||||
NBTTagCompound display = newItem.getTag().getCompound("display"); // Returns a new NBTTagCompound if not existing
|
||||
if (!newItem.getTag().hasKey("display")) {
|
||||
newItem.getTag().set("display", display);
|
||||
}
|
||||
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
||||
display.set("Lore", tagList);
|
||||
|
||||
setItemStack(newItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allowPickup(boolean pickup) {
|
||||
if (pickup) {
|
||||
super.pickupDelay = 0;
|
||||
} else {
|
||||
super.pickupDelay = 32767;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.getVehicle() != null) {
|
||||
Entity oldVehicle = super.getVehicle();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getRawItemStack() {
|
||||
return super.getItemStack();
|
||||
}
|
||||
}
|
|
@ -1,223 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_13_R2;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSSlime;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||
import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectField;
|
||||
|
||||
import net.minecraft.server.v1_13_R2.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_13_R2.DamageSource;
|
||||
import net.minecraft.server.v1_13_R2.Entity;
|
||||
import net.minecraft.server.v1_13_R2.EntityDamageSource;
|
||||
import net.minecraft.server.v1_13_R2.EntityPlayer;
|
||||
import net.minecraft.server.v1_13_R2.EntitySlime;
|
||||
import net.minecraft.server.v1_13_R2.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_13_R2.NBTTagCompound;
|
||||
import net.minecraft.server.v1_13_R2.SoundEffect;
|
||||
import net.minecraft.server.v1_13_R2.World;
|
||||
|
||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "vehicle");
|
||||
|
||||
private HologramLine parentPiece;
|
||||
|
||||
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.persistent = true;
|
||||
super.collides = false;
|
||||
a(0.0F, 0.0F);
|
||||
setSize(1, false);
|
||||
setInvisible(true);
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damageSource, float amount) {
|
||||
if (damageSource instanceof EntityDamageSource) {
|
||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(IChatBaseComponent ichatbasecomponent) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.getVehicle() != null) {
|
||||
Entity oldVehicle = super.getVehicle();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue