Compare commits

...

435 Commits

Author SHA1 Message Date
filoghost 6f343c5fc0 Fix viewers mutating after submitting async packet sending 2024-03-09 23:43:21 +01:00
filoghost 9dcf6035fe Remove duplicate thread initialization 2024-03-09 22:55:31 +01:00
filoghost 0754e0ac33 Experimental and potentially unstable: async packet sending 2024-02-19 23:11:34 +01:00
filoghost ed3bbad1fb Set version to 3.0.5-SNAPSHOT 2024-02-18 15:03:30 +01:00
filoghost 667668f0f0 Fix version (wrongfully set to 3.0.5) 2024-01-27 16:39:55 +01:00
filoghost c14141679f Set version to 3.0.4 2024-01-27 16:11:43 +01:00
filoghost 563df95561 Attempt to fix packet injector issues 2024-01-27 11:15:30 +01:00
Spongecade 3f067145b7 Update Minecraft wiki link to new domain 2024-01-26 22:48:48 +01:00
rayanbzd 9fd3bf2d0f Update to correct EntityTypeID 2024-01-26 22:27:32 +01:00
rayanbzd 0b289b017b 1.20.3 & 1.20.4 support 2024-01-26 22:27:32 +01:00
filoghost 07968520f0 Add support for Minecraft 1.20.2 2023-10-01 13:14:09 +02:00
filoghost 51fc2d0bd4 Set version to 3.0.4-SNAPSHOT 2023-10-01 13:12:53 +02:00
filoghost 5d22e2754d Set version to 3.0.3 2023-06-18 15:23:12 +02:00
Sascha Bartl a3c82bfddf Add support for Minecraft 1.20 2023-06-10 14:19:33 +02:00
filoghost 2fa71ad3e0 Only re-send spawn packets to respawned players on older versions 2023-05-01 22:14:02 +02:00
filoghost 917db5ad94 Update issue templates 2023-04-29 18:16:15 +02:00
filoghost 705abee6a3 Fix Maven build 2023-04-25 21:34:43 +02:00
filoghost 3727868dff Set version to 3.0.3-SNAPSHOT 2023-04-25 18:18:20 +02:00
filoghost fab8c9594d Set version to 3.0.2 2023-04-25 14:39:01 +02:00
filoghost ef890acacd Fix missing dependency 2023-03-25 15:59:38 +01:00
filoghost 2b5afc82af Add support for Minecraft 1.19.4 2023-03-25 15:55:52 +01:00
filoghost d057dd750c Drop support for less used minor Minecraft versions (1.16.0 to 1.16.3) 2023-03-19 16:49:08 +01:00
filoghost 27ebb9d2d8 Avoid extending internal NMS classes 2023-03-19 16:44:40 +01:00
filoghost 70779348af Set version to 3.0.2-SNAPSHOT 2023-02-05 15:12:30 +01:00
filoghost dd1f6f024d Set version to 3.0.1 2023-02-05 15:05:52 +01:00
filoghost 5d2c97f194 Add optional short format for PlaceholderAPI (e.g. %player% instead of {papi: player}) 2023-01-06 23:41:27 +01:00
filoghost 788cdc2c45 Add support for Minecraft 1.19.3 2022-12-13 23:37:57 +01:00
filoghost a5d9f58df3 Fix image rendering symbols 2022-12-04 15:06:40 +01:00
filoghost 850beaebb8 Refactoring 2022-12-04 12:39:01 +01:00
filoghost 2f83fdcfdb Update README.md versions 2022-11-18 22:09:22 +01:00
filoghost 39e51328cc Small simplification 2022-11-14 00:14:01 +01:00
filoghost 017b0a2346 Additional async checks 2022-11-14 00:12:58 +01:00
filoghost 80344c8503 Force initial refresh on line trackers 2022-11-13 23:54:30 +01:00
filoghost 39f0a02412 Make holograms view range configurable 2022-11-13 16:29:41 +01:00
filoghost 0e98b2f89a Move spaceBetweenLines to separate class 2022-11-13 16:29:41 +01:00
filoghost 0449fe65ca Set version to 3.0.1-SNAPSHOT 2022-10-30 10:19:13 +01:00
filoghost 37e411b978 Set version to 3.0.0 2022-10-23 16:56:45 +02:00
filoghost d670fae7ab Workaround attempt to fix holograms not displaying after teleport 2022-10-09 16:31:29 +02:00
filoghost d76739d332 Limit hologram view range with small view distance setting 2022-10-01 22:32:05 +02:00
filoghost 39f3f49504 Fix tests 2022-10-01 19:42:10 +02:00
filoghost 8ddb63835d Remove unused variable 2022-10-01 19:23:54 +02:00
filoghost 777b696f38 Add more thread-safety checks 2022-10-01 16:27:24 +02:00
filoghost c7e0f64469 Add options to disable PlaceholderAPI and to change the refresh interval 2022-09-10 14:41:41 +02:00
filoghost 459abdc2f8 Add missing Javadocs 2022-09-10 12:25:39 +02:00
filoghost c850488ba7 Optimization 2022-09-10 12:01:36 +02:00
filoghost d58adb7db8 Improve API Javadocs 2022-08-15 19:33:35 +02:00
filoghost 4431605a3a Fix v2 VisibilityManager 2022-07-10 12:10:52 +02:00
filoghost 018acd8299 Fix default settings using old custom placeholders 2022-06-19 11:10:50 +02:00
filoghost 7a63325620 Add support for Minecraft 1.19 2022-06-13 09:22:46 +02:00
filoghost da763ca8e9 Fix click on hologram lines 2022-06-11 12:47:49 +02:00
filoghost 624d206086 Use new API for Javadoc 2022-06-04 18:33:06 +02:00
filoghost 5bab55fb79 Move API to non-beta package 2022-06-04 18:04:18 +02:00
filoghost 2875020583 Remove unused code 2022-06-04 17:30:36 +02:00
filoghost 8018e52bbb Merge related classes 2022-06-04 15:44:29 +02:00
filoghost e0d47284b7 Move VisibilitySettings to BaseHologram 2022-06-01 23:33:05 +02:00
filoghost 5727de44dc Use separate view range for item and text lines 2022-05-29 16:44:10 +02:00
filoghost 370eb9806f Small optimization 2022-05-28 19:29:57 +02:00
filoghost d35648b4e4 Use Position instead of ImmutablePosition where possible 2022-05-22 21:01:32 +02:00
filoghost 525622b59a Remove unnecessary interfaces 2022-05-22 12:11:14 +02:00
filoghost 323998845b Move method 2022-05-22 00:54:11 +02:00
filoghost 32fc16b2c3 Quick refactoring 2022-05-22 00:23:19 +02:00
filoghost 619bc79cd8 Move core implementation to separate module 2022-05-22 00:10:31 +02:00
filoghost bf02837f9e Internal holograms refactoring 2022-05-18 00:06:13 +02:00
filoghost c6a14285a0 Fix wrong placeholder warning 2022-04-25 17:02:20 +02:00
filoghost da25d050ab API renaming 2022-04-24 12:41:37 +02:00
filoghost 0cd4ac8f3e API renaming 2022-04-22 20:01:29 +02:00
filoghost bf39afb630 Simplify placeholder API 2022-03-26 23:54:26 +01:00
filoghost 72e17365d6 Fix gradle instructions 2022-03-26 15:53:20 +01:00
filoghost 559cba600c Raise hologram line character limit 2022-03-12 00:15:51 +01:00
filoghost 54bc45ebb9 Expose internal hologram manager 2022-03-08 23:11:55 +01:00
filoghost 28479a85a9 Fix entity ID generator on 1.18.2 2022-03-05 19:38:32 +01:00
filoghost 6bee8d4d17 Add support for Minecraft 1.18.2 2022-03-05 17:46:52 +01:00
filoghost 0718e4ab80 Use the old API for Javadocs until the new API is finished 2022-02-27 15:59:30 +01:00
filoghost a8269e7867 Try to avoid error when player disconnects before packet listener is injected 2022-02-27 10:10:18 +01:00
filoghost cb12515755 Simplify field 2022-02-22 00:05:47 +01:00
filoghost 928609efb7 Only check viewers every 5 ticks 2022-02-22 00:05:46 +01:00
filoghost 38a99b95e1 Tiny optimization 2022-02-12 21:39:35 +01:00
filoghost fda3f4b933 Return registered placeholder in API 2022-02-12 15:42:17 +01:00
filoghost 045f363adb Re-add visibility settings for internal holograms 2022-02-05 12:09:59 +01:00
filoghost 2d177edced Suppress error when requesting info of unknown server to BungeeCord 2022-02-05 00:04:11 +01:00
filoghost 370558d4ce Fix holograms not being visible on respawn 2022-02-04 21:32:34 +01:00
filoghost b89e6264bb Optimization and memory leak fix 2022-01-31 23:41:28 +01:00
filoghost 2789a24295 Fix custom placeholders 2022-01-21 23:20:48 +01:00
filoghost 58907f075f Add compatibility format for placeholders registered with API v2 2022-01-21 22:22:58 +01:00
filoghost 4a8fd6a6fa Add escape character "\" for curly braces of placeholders 2022-01-12 23:28:04 +01:00
SilverFox b7663926d7 Maven Group ID fix and added Gradle Configuration
I Fixed Maven Group ID because `me.filoghost.holographicdisplays` only had versions above 3.0 and added Gradle Configuration maybe someone will need it
2022-01-01 19:46:59 +01:00
filoghost 9dbdbc36fd Expose internal hologram editor 2021-12-31 15:46:30 +01:00
filoghost 1ee23d4398 Fix outdated error message 2021-12-31 15:44:10 +01:00
filoghost a1d3eb5e26 Enable colors and custom placeholders inside animations 2021-12-31 12:35:19 +01:00
filoghost 243bf9ea0a Fix NullPointerException 2021-12-26 16:36:44 +01:00
filoghost ae7591f952 Allow null item when creating a line in the API 2021-12-25 12:18:41 +01:00
filoghost aade3ddbfe Extract lambda to class 2021-12-25 12:13:48 +01:00
filoghost 90e26af19b Optimizations 2021-12-24 16:49:05 +01:00
filoghost e25c2aca40 Do not update placeholders if there's no one viewing them 2021-12-19 17:03:24 +01:00
filoghost dccafdc839 Sort imports 2021-12-19 12:22:59 +01:00
filoghost 62e3cb563f Improve error logging for placeholders 2021-12-19 12:22:14 +01:00
filoghost 749d1ff5a0 Cleanup PlaceholderAPIHook 2021-12-19 12:07:53 +01:00
filoghost 76af200af9 Do not invoke PlaceholderAPI directly 2021-12-14 23:22:25 +01:00
filoghost 68b6a8bf30 Increment inactive placeholders' timeout ticks 2021-12-14 21:38:37 +01:00
filoghost b23abef7ab Rename method 2021-12-14 21:38:04 +01:00
filoghost 6ac35d3d62 Fix spam in console when a remote server is down 2021-12-13 23:40:53 +01:00
filoghost c1a223a863 Recommend old API until v3 is finished 2021-12-13 23:10:09 +01:00
filoghost 014f53dbce Merge branch 'v3' into master 2021-12-13 23:04:28 +01:00
filoghost 911170e50c Re-implement PlaceholderAPI as normal placeholder 2021-12-13 23:01:44 +01:00
filoghost 69f2ecbd23 Refactoring, temporarily remove PlaceholderAPI support 2021-12-13 23:01:44 +01:00
filoghost 4e21d317f3 Fix error on some Spigot forks 2021-12-13 23:01:44 +01:00
filoghost e1818a5a24 Refactoring 2021-12-13 23:01:44 +01:00
filoghost a8fcacefea Temporarily move API to "beta" package 2021-12-13 23:01:44 +01:00
filoghost 9be9ecb2ac Add support for Minecraft 1.18 2021-12-13 23:01:44 +01:00
filoghost 2c4aaa3f51 Rename API classes and methods 2021-12-13 23:01:44 +01:00
filoghost fdd76f179e Rename API methods 2021-12-13 23:01:43 +01:00
filoghost 1a9a80fe36 Fix API classes toString() implementations 2021-12-13 23:01:43 +01:00
filoghost 33ec96172c Reorder methods 2021-12-13 23:01:43 +01:00
filoghost ce437d21d3 Remove CollectableHologramLine 2021-12-13 23:01:43 +01:00
filoghost 2b062f35bf Directly implement RegisteredPlaceholder 2021-12-13 23:01:43 +01:00
filoghost 8a80c063b7 Do not make *PlaceholderReplacementSupplier extend *Placeholder 2021-12-13 23:01:43 +01:00
filoghost 6f6a214ecd Expand API 2021-09-25 12:15:56 +02:00
filoghost e8b2239c47 Fix NullPointerException 2021-09-25 12:09:58 +02:00
filoghost 66bdda8bed Small improvement 2021-09-25 11:55:21 +02:00
filoghost 11d57d40b7 Reduce unnecessary class visibility 2021-09-25 11:00:22 +02:00
filoghost 651ac2f019 Small optimization 2021-09-24 00:08:35 +02:00
filoghost 7700675e8b Manually clear active placeholder which become unused 2021-09-24 00:01:10 +02:00
filoghost b7b922fb37 Rename classes 2021-09-22 21:05:34 +02:00
filoghost d97751100e Reset global text field when using individual placeholders 2021-09-20 23:08:59 +02:00
filoghost 1da71326d7 Make some NMS classes package-private 2021-09-20 22:49:21 +02:00
filoghost 769d3dacb2 Rename PlaceholderReplacer to PlaceholderReplacementSupplier 2021-09-20 22:49:21 +02:00
filoghost dc9f0fe2b4 Use enum for enabling placeholder replacement in holograms 2021-09-19 20:59:40 +02:00
filoghost b4c8c6ede4 Improve ImmutablePosition and related classes 2021-09-15 11:57:02 +02:00
filoghost 3935af2bf9 Simplify chunk load state in HologramPosition 2021-09-15 11:34:02 +02:00
filoghost 33c2693172 Cache if display text contains individual placeholders or not 2021-09-15 11:14:30 +02:00
filoghost 0a80d91d5b Rename TrackedPlayer to Viewer 2021-09-15 09:18:28 +02:00
filoghost 15a7372c43 Use 0xFF instead of 255 2021-09-15 00:17:09 +02:00
filoghost 05488268b0 Optimize packet write 2021-09-14 23:55:19 +02:00
filoghost 03b6437f23 Add missing annotations 2021-09-14 23:33:34 +02:00
filoghost 134eba5f41 Large refactoring, periodically refresh individual placeholders 2021-09-14 21:44:08 +02:00
filoghost f900dbe690 Rename classes 2021-09-05 15:35:43 +02:00
filoghost b342a0b37e Update dependencies 2021-09-03 19:35:27 +02:00
filoghost a942c1725a Create class for common method 2021-09-01 20:41:31 +02:00
filoghost 899ade7ce2 Improve placeholder API 2021-09-01 20:30:19 +02:00
filoghost cd6dd1b4d2 Expand Position API 2021-09-01 09:18:10 +02:00
filoghost 7db51a6dae Rename API classes 2021-08-31 21:05:38 +02:00
filoghost 9ff7b0d7b6 Suppress warning in pom.xml 2021-08-31 12:18:49 +02:00
filoghost c27c34dd64 Move pom.xml "modules" section 2021-08-31 11:26:08 +02:00
filoghost b97fe93f96 Add more info to pom.xml 2021-08-31 11:17:49 +02:00
filoghost 40d7876bd8 Fix and improve Javadoc generation 2021-08-31 10:45:10 +02:00
filoghost d2130fe162 Remove outdated dependency 2021-08-29 10:40:45 +02:00
filoghost 6ae9ec8292 Update API 2021-08-29 09:32:28 +02:00
filoghost 5de079917e Rename method 2021-08-27 08:37:23 +02:00
filoghost cf2ca694bf Move classes to separate package 2021-08-26 16:42:05 +02:00
filoghost 8a9642d7fc Rearrange methods 2021-08-26 15:19:25 +02:00
filoghost 11abb356d6 Fix exception message 2021-08-26 13:59:08 +02:00
filoghost 76381660a3 Improve Position 2021-08-26 13:54:55 +02:00
filoghost 66d49727b8 Rename HologramPosition to Position and Position to PositionCoordinates 2021-08-25 18:27:45 +02:00
filoghost da2b221642 Separate modules "common" and "NMS common" 2021-08-25 15:45:33 +02:00
filoghost 7f70cd7b08 Rename parameter 2021-08-25 09:28:08 +02:00
filoghost 7efacd31f9 Remove unused class 2021-08-25 09:21:45 +02:00
filoghost 0b5a059a2f Modify exception messages 2021-08-25 09:09:00 +02:00
filoghost 92e18395b4 Move classes 2021-08-25 09:07:02 +02:00
filoghost 3008f28fb2 Refactoring 2021-08-25 08:54:56 +02:00
filoghost 2ddb972128 Rename subclasses 2021-08-24 14:56:20 +02:00
filoghost ed803fc4f6 Remove API method 2021-08-23 20:11:52 +02:00
filoghost 1aa8a17dab Remove unnecessary cooldown on hologram line click 2021-08-23 19:43:03 +02:00
filoghost 2da7d318df API changes 2021-08-23 19:28:15 +02:00
filoghost dba767dd79 Add createHologram with HologramPosition 2021-08-23 16:20:29 +02:00
filoghost ca5644153e Add deleteHolograms method to API 2021-08-23 14:09:51 +02:00
filoghost 087105ccd1 Refresh line positions on plugin reload for potential changes in option "space-between-lines" 2021-08-23 13:59:14 +02:00
filoghost b4e5edfa8e Separate v2 holograms from new API 2021-08-23 13:45:41 +02:00
filoghost c2ff8f536c Fix dynamic world loading 2021-08-23 12:42:59 +02:00
filoghost ac0bde854d Initial API update 2021-08-22 17:17:33 +02:00
filoghost b3d8aae193 Specify Locale with String.toLowerCase() 2021-08-20 18:33:56 +02:00
filoghost 41fb1bc347 Remove unnecessary armor stand with clickable slime 2021-08-20 09:55:07 +02:00
filoghost ad1cfe3f1f Move serializer constants to appropriate class 2021-08-20 08:56:06 +02:00
filoghost 614a56ca8a Use new Preconditions method 2021-08-19 15:57:55 +02:00
filoghost 55f690cec9 Make HologramPosition immutable 2021-08-19 15:36:10 +02:00
filoghost 9e966ea185 Refactoring 2021-08-19 11:56:28 +02:00
filoghost 163b881837 Refactoring 2021-08-19 10:37:18 +02:00
filoghost 9fc8fceea7 Remove unused method 2021-08-19 09:30:34 +02:00
filoghost ec5cf3ca94 Refactoring 2021-08-19 09:28:58 +02:00
filoghost 903c94657b Refactoring 2021-08-18 16:16:20 +02:00
filoghost 4f03b2e4e3 Make animation options required 2021-08-15 09:54:22 +02:00
filoghost 2cf789c8f2 Fix error when disabling plugin because of other error 2021-08-14 12:27:38 +02:00
filoghost 14541eb25d Remove unsupported versions and display error messages 2021-08-14 12:26:53 +02:00
filoghost e1009b8cd8 Small refactoring 2021-08-14 10:17:42 +02:00
filoghost f61ba7a02c Update command messages for users 2021-08-14 08:03:48 +02:00
filoghost a7b9b72f96 Fix Checkstyle warnings 2021-08-13 21:33:08 +02:00
filoghost 4f86a8e9c2 Add other major NMS implementations 2021-08-13 20:10:13 +02:00
filoghost 2d0969e171 Replace single quotes with double quotes 2021-08-13 07:51:51 +02:00
filoghost 3c10663c41 Fix create command 2021-08-13 07:41:05 +02:00
filoghost 8ca4108d4c Make HologramPosition.add() return the position itself 2021-08-09 21:14:58 +02:00
filoghost f5e320a420 Minor grammar and code changes 2021-08-09 08:17:24 +02:00
filoghost cc8b068bf0 Clarify comment 2021-08-09 08:00:21 +02:00
filoghost db24dfe965 Fix grammar 2021-08-08 20:16:42 +02:00
filoghost dc87be4e4a Rename parameter 2021-08-08 18:36:33 +02:00
filoghost 36e1d44d18 Move removeLine method to Hologram instead of HologramLine 2021-08-08 16:49:18 +02:00
filoghost 88bfa7c662 Make BaseHologramLines implement Iterable 2021-08-08 16:42:01 +02:00
filoghost 9d70087130 Prevent hologram being edited after deletion 2021-08-08 16:38:41 +02:00
filoghost b9d04d7f5c Refactor hologram lines into separate class 2021-08-08 16:36:27 +02:00
filoghost 176187e0c9 Remove outdated Javadoc 2021-08-08 15:55:22 +02:00
filoghost 7fb38d82e4 Refactor hologram position fields into separate class 2021-08-08 12:50:55 +02:00
filoghost 150cc4c62b Rename location references to "position" 2021-08-07 18:51:45 +02:00
filoghost 9b21ffdf76 Allow holograms to be in non-loaded worlds 2021-08-07 18:39:19 +02:00
filoghost 5225d34cb6 Add README.txt in backups folder 2021-08-07 16:13:29 +02:00
filoghost 72cdacb998 Improve automatic configuration upgrades and use separate folder for backups 2021-08-07 13:54:22 +02:00
filoghost 4dc46456a3 Update database format and add automatic converter 2021-08-06 19:13:18 +02:00
filoghost 15f88dacb3 Update toString() methods 2021-08-06 18:10:56 +02:00
filoghost 0a1f7998e9 Remove unused field 2021-08-06 11:52:29 +02:00
filoghost 14c7ebce69 Introduce HologramPosition API and refactor implementation 2021-08-06 11:44:55 +02:00
filoghost 1be79f05b0 Fix quick edit command tooltips 2021-08-05 18:12:23 +02:00
filoghost a1bafc4366 Refactor hologram location 2021-08-05 18:10:10 +02:00
filoghost f221f1ed72 Improve chunk loading detection 2021-08-05 12:09:39 +02:00
filoghost e3179576e4 Update placeholder tracker only when necessary 2021-08-05 07:52:51 +02:00
filoghost 3432a33ae6 Fix StringWithPlaceholders.containsPlaceholders() and update test 2021-08-04 21:32:36 +02:00
filoghost 2d99a0c36a Simplify placeholder replacement 2021-08-04 19:40:50 +02:00
filoghost e161dd18f9 Refactoring 2021-08-03 18:51:08 +02:00
filoghost d94cb681a8 Add automatic converter for animations with old format 2021-08-03 00:18:30 +02:00
filoghost 47c98100ff Rename 2021-08-02 23:09:07 +02:00
filoghost 8b12e3e2c5 Add null check 2021-08-02 23:05:27 +02:00
filoghost e7e27885b3 Optimize Placeholder API detection 2021-08-02 22:39:02 +02:00
filoghost 016de63f93 Use new YML format for animations 2021-08-02 10:00:23 +02:00
filoghost de3366a8a2 Don't apply display format inside placeholders 2021-08-01 12:48:58 +02:00
filoghost d251998cdd Cleanup HolographicDisplays class 2021-08-01 12:06:49 +02:00
filoghost 365366d929 Move class 2021-08-01 11:39:43 +02:00
filoghost 32be6b8654 Check player distance on clickable hologram lines 2021-08-01 11:26:59 +02:00
filoghost 7a6ea7b789 Rename methods 2021-08-01 10:18:44 +02:00
filoghost 2641ec7c0f Fix client-side slime collision box 2021-08-01 10:17:49 +02:00
filoghost bb48855396 Rename package 2021-07-31 17:28:19 +02:00
filoghost 54d089bf04 Add item pickup functionality 2021-07-31 17:27:21 +02:00
filoghost 089d1eaa7c Use concurrent hash set for click listener 2021-07-31 16:11:02 +02:00
filoghost 63efbf40fb Rename methods 2021-07-31 16:11:02 +02:00
filoghost 56ca2125fa Also check world on chunk load/unload 2021-07-31 16:11:02 +02:00
filoghost 07b55853dc Reorder methods 2021-07-31 16:11:02 +02:00
filoghost b9d55363c6 Make names more consistent 2021-07-31 16:11:02 +02:00
filoghost 4e028efb27 Rename API classes 2021-07-31 16:11:02 +02:00
filoghost b8860a9d60 Sort imports 2021-07-30 10:35:09 +02:00
filoghost c6b6ec1a42 Rename v2 API adapter classes 2021-07-30 10:34:22 +02:00
filoghost 7e0f23f220 Remove unused field 2021-07-30 10:18:01 +02:00
filoghost 665d8bb367 Prevent changes to deleted lines 2021-07-29 19:42:22 +02:00
filoghost ca50d9247d Improve readability 2021-07-29 19:33:02 +02:00
filoghost 825b0f2b2e Refactoring 2021-07-29 19:24:11 +02:00
filoghost 1d44491457 Remove outdated Javadoc 2021-07-29 10:50:34 +02:00
filoghost 8cac729a82 Remove unnecessary classes 2021-07-29 10:44:17 +02:00
filoghost f470dddc40 Add checks to BaseItemLine.onPickup() 2021-07-29 09:04:47 +02:00
filoghost 55643651c9 Refactoring 2021-07-28 21:00:14 +02:00
filoghost 438dcfb1dc Add back support for touch functionality 2021-07-28 15:11:07 +02:00
filoghost f3d3d07038 Improve NMSVersion description 2021-07-28 10:41:42 +02:00
filoghost e406dfc9a5 Set version to 2.4.9 2021-07-27 08:55:26 +02:00
filoghost 88b260ffb9 Improve placeholder handling 2021-07-25 22:17:28 +02:00
filoghost ed73b8e098 Add back support for placeholder toggle 2021-07-25 20:18:28 +02:00
filoghost 51b0f7fd30 Reuse single instance of PacketByteBuffer 2021-07-25 19:14:29 +02:00
filoghost 6be5f00f53 Improve NMS implementation 2021-07-25 19:02:48 +02:00
filoghost 98f27b73b4 Improve error logging 2021-07-25 11:57:25 +02:00
filoghost 496fd4ae41 Add support for visibility options 2021-07-24 18:41:13 +02:00
filoghost 6d54e73518 Add @FunctionalInterface annotations 2021-07-24 18:18:29 +02:00
filoghost 003181c256 Spacing and ordering 2021-07-24 18:18:08 +02:00
filoghost 21280b0b1f Add defensive copy for ItemStack 2021-07-24 15:20:00 +02:00
filoghost ce2dfd993b Improve tests 2021-07-24 15:08:16 +02:00
filoghost 1440a88387 Fix partial placeholder replacement, fix tests 2021-07-24 14:36:51 +02:00
filoghost 7d86538621 Use packets instead of entities
Missing:
* All implementations before 1.17
* Placeholder toggle
* Visibility settings
* Line touch handling
* Item pickup handling
2021-07-24 12:51:14 +02:00
filoghost 11664497cc Fix ProtocolLib on latest 1.17 version 2021-07-22 09:26:46 +02:00
filoghost 948b7c4eb2 Set version to 2.4.9-SNAPSHOT 2021-07-22 08:49:58 +02:00
filoghost c22f01c017 Fix animation speed 2021-07-19 09:25:51 +02:00
filoghost bbc08034f1 Fix hologram delete 2021-07-19 09:25:51 +02:00
filoghost 3539ae6a01 Uncolorize image lines for serialized value 2021-07-13 19:17:35 +02:00
filoghost 6d5c1e4a30 Change warning message 2021-07-13 19:17:35 +02:00
filoghost 05826266a5 Update FCommons methods 2021-07-13 19:17:35 +02:00
filoghost 2e68e95497 Change image rendering settings path 2021-07-13 19:17:35 +02:00
filoghost 6948afcfa9 Simplify image rendering settings 2021-07-13 19:17:35 +02:00
filoghost 0cb6fed921 Additional test 2021-07-13 19:17:35 +02:00
filoghost e67bfcd750 Rename inner class 2021-07-08 18:43:33 +02:00
filoghost 41e54d801e Rearrange API classes 2021-07-08 08:48:27 +02:00
filoghost 1871fbc8b7 Pass plugin instance instead of using static getInstance() method 2021-07-06 21:22:14 +02:00
filoghost 71de987628 Report all trailing whitespace 2021-07-06 21:22:14 +02:00
filoghost 1eb58dfd0a Use pinger utility in FCommons 2021-07-06 21:22:14 +02:00
filoghost f6c7fd5f0f Fix VisibilitySettings not working 2021-07-05 23:58:20 +02:00
filoghost 08410feb48 Migrate to issue templates for GitHub 2021-07-05 23:49:14 +02:00
filoghost 43427d6f81 Move method to FCommons library 2021-07-05 08:27:29 +02:00
filoghost fca1de85e0 Convert {empty} to an actual placeholder 2021-07-03 17:15:41 +02:00
filoghost 4399fd90a7 Refactor internal hologram editing 2021-07-03 17:01:31 +02:00
filoghost 0b649ff612 Clarify code 2021-07-03 09:29:59 +02:00
filoghost 157be9b679 Allow null item on ItemLine 2021-07-02 21:30:54 +02:00
filoghost b8dde1ab3e Fix stack overflow error 2021-07-01 22:55:44 +02:00
filoghost b594f79a2b Refactor ImageMessage 2021-06-27 23:51:08 +02:00
filoghost d52e374969 Rename classes 2021-06-24 17:38:38 +02:00
filoghost fa7c34ccf9 Refactoring 2021-06-24 17:13:32 +02:00
filoghost aa1a8d1232 Set version to 2.4.8 2021-06-24 12:43:31 +02:00
filoghost a2c6e1efe6 Fix VisibilityManager not working 2021-06-24 11:57:32 +02:00
filoghost 5de53c541a
Update 1-bug.yml 2021-06-23 10:49:17 +02:00
filoghost 78713fde8b Migrate to issue templates for GitHub 2021-06-22 23:50:29 +02:00
filoghost 95fd02b507 Small refactoring 2021-06-21 23:33:40 +02:00
filoghost 37cc961cab Ignore async threads in ProtocolLib listener 2021-06-21 23:29:29 +02:00
filoghost 8ef99b0352 Fix {motd} on 1.16+ 2021-06-21 23:28:48 +02:00
filoghost ad7003c939 Require JDK 16 because of Minecraft 1.17 2021-06-21 22:52:32 +02:00
filoghost 39d4e450d7 Add support for Minecraft 1.17 2021-06-21 22:51:30 +02:00
filoghost 2ebad9cbe1 Add setSlot override to NMS class 2021-06-20 20:25:17 +02:00
filoghost ae07fe0bb5 Remove trailing whitespace 2021-06-20 17:26:49 +02:00
filoghost 860d586750 Reformat and cleanup code 2021-06-20 17:09:52 +02:00
filoghost 46b4fd6bd7 Fix potential memory leak 2021-06-20 14:12:53 +02:00
filoghost 31f0ba206d Format imports 2021-06-20 12:41:52 +02:00
filoghost 4e47f5cf7c Update Checkstyle suppressions 2021-06-20 12:38:34 +02:00
filoghost 7b269ba0b1 Move external libraries in the same package 2021-06-20 12:36:56 +02:00
filoghost c190f10092 Fix formatting 2021-06-20 12:01:53 +02:00
filoghost f73e8405ea Restore copyright headers 2021-06-20 11:59:12 +02:00
filoghost 50b9ede70c Inline method 2021-06-20 11:50:09 +02:00
filoghost 73f0d23410 Rename module "core" to "common" 2021-06-20 11:14:26 +02:00
filoghost 22bacead97 Rename package "object" to "hologram" 2021-06-20 10:47:28 +02:00
filoghost 08d3219c37 Move API implementations to a common package 2021-06-20 10:46:45 +02:00
filoghost dfcc597a02 Make packages include module name and separate external libraries 2021-06-20 10:21:58 +02:00
filoghost eeec178e65 Improve and refactor individual placeholders 2021-06-19 19:04:13 +02:00
filoghost 5543edd47b Remove Checkstyle IllegalThrows rule 2021-06-19 19:03:27 +02:00
filoghost ed75cdee08 Ignore async threads in ProtocolLib listener 2021-06-19 14:07:40 +02:00
filoghost 664c6c6151 Fix {motd} on 1.16+ 2021-06-19 14:00:53 +02:00
filoghost f5d37f59df Fix for Paper 1.17 2021-06-16 22:25:13 +02:00
filoghost 849d685b6b Set version to 2.4.8-SNAPSHOT 2021-06-16 21:38:20 +02:00
filoghost 3e1f6d02b4 Set version to 2.4.7 2021-06-16 18:29:14 +02:00
filoghost e0bb4635df Fix ProtocolLib repository 2021-06-15 22:01:28 +02:00
filoghost 464c5804e6 Add support for Minecraft 1.17 2021-06-14 23:37:41 +02:00
filoghost fb68b946d2 Set version to 2.4.7-SNAPSHOT 2021-06-13 11:21:35 +02:00
filoghost b2989814b8 Initial refactoring for relative placeholders 2021-05-26 23:29:08 +02:00
filoghost 864f76eac6 Move classes 2021-05-25 21:05:10 +02:00
filoghost 33bdce7915 Fix Checkstyle warnings 2021-05-25 00:17:44 +02:00
filoghost 23029e874e Fix link on console update notification 2021-05-25 00:12:01 +02:00
filoghost f9a6163363 Change permissions prefix to "holographicdisplays." 2021-05-25 00:11:11 +02:00
filoghost 71bf06a8b5 Re-add rainbow color &u" as alias of "{rainbow}" 2021-05-24 22:55:30 +02:00
filoghost d58e9fe0a9 Code renaming 2021-05-24 22:42:44 +02:00
filoghost 123e9fb45c Avoid NullPointerException 2021-05-24 22:17:13 +02:00
filoghost 9e05bb61cb Improve StringWithPlaceholders 2021-05-24 18:36:21 +02:00
filoghost 3f14a67b73 Initial draft for PlaceholderAPI support (needs performance improvements) 2021-05-24 11:53:00 +02:00
filoghost bbb397068b Support latest ProtocolLib version 2021-05-24 10:20:32 +02:00
filoghost ffd0351a70 Simplify relative placeholder replacement 2021-05-24 09:50:31 +02:00
filoghost e8c4f58d9a Change VisibilityManager into VisibilitySettings and improve implementation 2021-05-19 20:41:15 +02:00
filoghost d67480749b Improve DefaultVisibilityManager 2021-05-18 18:04:43 +02:00
filoghost c1cd5b200c Fix Checkstyle violations by formatting code 2021-05-18 09:49:44 +02:00
filoghost 305931bd73 Tweak checkstyle settings 2021-05-18 09:48:24 +02:00
filoghost f370dfff4f Add missing header comments 2021-05-17 19:31:20 +02:00
filoghost 85f85e9b2c Add Checkstyle 2021-05-17 19:30:31 +02:00
filoghost ae89ad25b1 Update equals and hashCode methods 2021-05-17 18:30:46 +02:00
filoghost 523b866f8e Improve comments 2021-05-17 18:19:09 +02:00
filoghost 949018c60f Annotate overriding methods 2021-05-16 21:11:25 +02:00
filoghost a31f29cb32 Rename methods 2021-05-16 20:59:34 +02:00
filoghost 40d18d1235 Enable the v2 API through adapters 2021-05-16 20:48:31 +02:00
filoghost 1906cadf96 Remove the v1 API and start throwing exceptions 2021-05-10 22:48:24 +02:00
filoghost dfb6e0ab33 Change API error message 2021-05-10 22:22:07 +02:00
filoghost fe54ed7dc7 Increase distance for approximate check before sending packets 2021-05-06 21:13:00 +02:00
filoghost 29d43525b4 Use NMS entity tracker to determine which players should receive packets 2021-05-06 21:09:56 +02:00
filoghost 415f1c51bc Use internal entity tracker to send packets from NMS entities 2021-05-06 15:26:40 +02:00
filoghost 4f25e6550b Move distance check for packets to ProtocolLibHook 2021-05-05 12:42:41 +02:00
filoghost fe626053e6 Clarify comment 2021-05-05 11:15:52 +02:00
filoghost 9f7e2915c1 Use UUIDs in DefaultVisibilityManager 2021-05-05 10:29:14 +02:00
filoghost de3f967a21 Small refactoring 2021-05-04 20:37:51 +02:00
filoghost aacc7fdeb4 Small refactoring 2021-05-04 16:10:18 +02:00
filoghost 177598ae78 Use FCommons utility method 2021-05-04 09:13:39 +02:00
filoghost 588e2ed394 Add isRegisteredPlaceholder method to the API 2021-05-03 15:44:11 +02:00
filoghost a7a7fcc68b Use ArrayList instead of LinkedList 2021-05-02 20:32:39 +02:00
filoghost 1f6adc8679 Change @Nullable/@NotNull annotation placement 2021-05-02 20:29:57 +02:00
filoghost ee76d568dc Add null-related annotations to the API 2021-05-01 18:41:01 +02:00
filoghost b2cd0abfe7 Improve v1 API 2021-05-01 12:40:55 +02:00
filoghost 5bcf735808 Use new split modules 2021-05-01 12:40:34 +02:00
filoghost 8bdac17719 Split legacy APIs into separate sub-modules 2021-04-30 16:03:46 +02:00
filoghost aba0897dc7 Move repositories declarations to main POM 2021-04-29 20:43:58 +02:00
filoghost 03689e208b Update FCommons dependency to 1.2.7 2021-04-29 14:38:46 +02:00
filoghost 92bcda8f2d Fix non-replaced placeholders and add test case 2021-04-28 23:42:10 +02:00
filoghost ff77738a51 Initial refactoring of the API 2021-04-28 23:25:20 +02:00
filoghost d8930febfc Update download link in notification 2021-04-25 11:10:21 +02:00
filoghost 276d35bb72 Improve custom name NMS methods 2021-04-25 10:41:37 +02:00
filoghost 750e74360a Partial placeholder refactoring 2021-04-24 23:37:54 +02:00
filoghost 19f3a87ba3 Add dependencies for testing 2021-04-11 20:16:34 +02:00
filoghost dc567af24c Fix wrong import 2021-04-04 16:11:42 +02:00
filoghost f97c21e645 Add JetBrains annotations 2021-03-20 15:29:42 +01:00
filoghost 57fd78eac5 Refactor BungeeCord-related code 2021-03-19 19:48:13 +01:00
filoghost 9a56a032de Make some placeholder-related classes not static 2021-03-15 23:42:07 +01:00
filoghost 6cc28cc957 Small refactoring 2021-03-15 21:41:03 +01:00
filoghost f474684693 Make BungeeServerTracker and BungeeChannel not static 2021-03-15 19:48:12 +01:00
filoghost 4d3ccd1a2e Rename old references to "pieces" 2021-03-15 19:09:24 +01:00
filoghost 977a422bb3 Improve error display 2021-03-14 20:59:34 +01:00
filoghost c694877780 Fix unexpected initialization error 2021-03-13 11:28:23 +01:00
filoghost ae0a8d0a79 Fix recursive passenger 2021-03-13 11:18:11 +01:00
filoghost 5b4a9348cd Update for FCommons changes 2021-03-11 20:54:49 +01:00
filoghost 5371acfd2c Fix conversion of old placeholders with dots in them 2021-03-11 17:40:20 +01:00
filoghost 65a54165eb Simplify PacketListener 2021-03-06 20:55:42 +01:00
filoghost c332547f38 Refactor hologram-related objects, simplify editing 2021-03-06 18:44:52 +01:00
filoghost a8a44bec90 Simplify hologram database 2021-03-06 00:26:33 +01:00
filoghost cc0ef3bf7b Small rename 2021-03-05 18:56:35 +01:00
filoghost 470b8bfcbd Refactor and cleanup NMS-related classes 2021-03-05 17:42:24 +01:00
filoghost f7bc9b950f Small cleanup 2021-03-03 10:53:49 +01:00
filoghost a96e9e516f Further refactoring to hologram objects 2021-03-02 20:47:23 +01:00
filoghost dbfabc0e83 Refactor hologram-related objects, move some to "core" module 2021-02-28 11:05:59 +01:00
filoghost f42ad75ca3 Merge module "nms-interfaces" with "core" 2021-02-26 23:43:11 +01:00
filoghost 3b127c3d90 Rename module "commons" to "core" 2021-02-26 20:30:46 +01:00
filoghost 13e8fcf070 Merge legacy API modules 2021-02-26 19:56:37 +01:00
filoghost 6c58062940 Rename NMSManager implementations 2021-02-26 19:45:12 +01:00
filoghost a295243019 Initial refactoring on hologram objects 2021-02-26 19:39:29 +01:00
filoghost c17de21313 Remove duplicate (re)loading code 2021-02-22 14:58:31 +01:00
filoghost 0ff3b28fdd Large refactoring and cleanup 2021-02-22 13:02:50 +01:00
filoghost acd83a6fe6 Configuration refactoring, convert symbols.yml to custom-placeholders.yml 2021-02-19 21:37:56 +01:00
filoghost 40e1967d20 Refactor exceptions 2021-02-07 16:18:16 +01:00
filoghost d71df75036 Refactor commands using FCommons 2021-02-06 15:53:43 +01:00
filoghost b9bf8c0959 Set version to 2.4.6 2021-01-24 15:27:48 +01:00
filoghost b5852116d4 Use new Java 8 time API 2021-01-24 12:01:32 +01:00
filoghost b2b03f3e40 Small refactoring 2021-01-24 10:45:58 +01:00
filoghost aa8aad2b83 Use NIO java file API 2021-01-07 21:05:38 +01:00
filoghost 0babfefe5e Support latest ProtocolLib version 2021-01-06 18:59:37 +01:00
filoghost 275b2b1f94 Set version to 2.4.6-SNAPSHOT 2021-01-06 18:58:06 +01:00
filoghost 1f32c7127c Code refactoring and cleanup 2021-01-06 14:58:53 +01:00
filoghost 530fb2c23e Move debug error messages inside DebugLogger 2020-12-13 20:51:23 +01:00
filoghost a4900759c9 Add FCommons library and use it where possible (initial update) 2020-12-12 12:08:34 +01:00
filoghost fc7e147b73 Fix typos in issue templates 2020-11-12 11:05:57 +01:00
filoghost f88d8965b2 General cleanup 2020-11-12 11:02:43 +01:00
filoghost 836bd511da Change method to detect build number 2020-11-11 22:33:03 +01:00
filoghost 0b72d1e994 Rename module and package "utils" to "common" 2020-11-11 10:23:05 +01:00
filoghost f320c3eb15 Move classes to plugin module 2020-11-11 09:42:05 +01:00
filoghost 90dbfa5c07 Merge module "config" into "plugin" 2020-11-10 20:56:19 +01:00
filoghost 0f3f7b5f9d Move NBT library 2020-11-10 20:34:26 +01:00
filoghost b60c7818d6 Use compact copyright header 2020-11-10 12:29:00 +01:00
filoghost 09f99be342 Convert tabs to spaces 2020-11-10 10:27:41 +01:00
filoghost 9c97e0ed39 Include legacy compatibility modules only at runtime 2020-11-10 10:12:14 +01:00
filoghost 9281515385 Add module for v2 backwards compatibility 2020-11-10 09:34:32 +01:00
filoghost cca12d1aa5 Update maven info in README.md 2020-11-09 23:31:55 +01:00
filoghost 02c15aa354 Use correct class in plugin.yml 2020-11-09 23:31:03 +01:00
filoghost fb41de5651 Rename module "legacy" to "legacy-v1" 2020-11-09 23:20:27 +01:00
filoghost 6f64e09508 Rename packages and modules from "com.gmail.filoghost..." to "me.filoghost..." 2020-11-09 10:56:22 +01:00
filoghost 069e1fffbd Use lowercase module directories 2020-11-08 20:57:04 +01:00
filoghost d98708f6ae Update version to 3.0.0-SNAPSHOT 2020-11-08 20:41:39 +01:00
filoghost 00ea074838 Set version to 2.4.5 2020-11-04 10:41:26 +01:00
filoghost 6830699b48 Add HEX color support (using the format &#000000) 2020-11-03 15:23:53 +01:00
Esophose 51d63c282d Added 1.16.4 support 2020-11-03 14:43:51 +01:00
filoghost ca3c1f8c9e Use Locale.ROOT for decimal format 2020-11-02 23:51:42 +01:00
filoghost 8f81052370 Fix IndexOutOfBoundsException 2020-11-02 22:25:19 +01:00
filoghost af038ac93f Update version to 2.4.5-SNAPSHOT for development 2020-08-14 16:10:06 +02:00
filoghost 1c1001b065
Merge pull request #326 from Esophose/paper-1.16.2-fix
Paper 1.16.2 fix
2020-08-13 17:33:37 +02:00
Esophose 6f8d0a72a6 Resolve reflection issue with paper 1.16.2 2020-08-13 05:34:43 -06:00
Esophose e4635c575e Merge remote-tracking branch 'filoghost/master' 2020-08-13 05:28:21 -06:00
filoghost c56923f52a Update version to 2.4.4 for release 2020-08-13 11:50:19 +02:00
filoghost 56d33a0300
Merge pull request #324 from Esophose/master
Add 1.16.2 support
2020-08-13 09:54:52 +02:00
Esophose 8d1811145a Added 1.16.2 support 2020-08-11 19:13:26 -06:00
filoghost 16a6011950 Update version to 2.4.4-SNAPSHOT for development 2020-06-25 17:51:54 +02:00
828 changed files with 33096 additions and 30042 deletions

View File

@ -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) -->

View File

@ -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 -->

View File

@ -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) -->

View File

@ -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) -->

73
.github/ISSUE_TEMPLATE/bug.yml vendored Normal file
View File

@ -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.

View File

@ -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"

View File

@ -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.3</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>

View File

@ -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 &lt; 0 || index &gt;= 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 &lt; 0 || index &gt;= 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 &lt; 0 || index &gt;= 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 &lt; 0 || index &gt;= 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();
}

View File

@ -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);
}
}

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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.3</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>

View File

@ -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;
}
}

View File

@ -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;
}
}
}

View File

@ -1,69 +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 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 decimalFormat;
static {
// More precision is not needed at all.
decimalFormat = new DecimalFormat("0.000");
DecimalFormatSymbols formatSymbols = decimalFormat.getDecimalFormatSymbols();
formatSymbols.setDecimalSeparator('.');
decimalFormat.setDecimalFormatSymbols(formatSymbols);
}
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() + ", " + decimalFormat.format(loc.getX()) + ", " + decimalFormat.format(loc.getY()) + ", " + decimalFormat.format(loc.getZ()));
}
}

View File

@ -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;
}
}

View File

@ -1,31 +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 org.bukkit.ChatColor;
public class StringConverter {
public static String toReadableFormat(String input) {
if (input == null) {
return null;
}
input = UnicodeSymbols.placeholdersToSymbols(input);
input = ChatColor.translateAlternateColorCodes('&', input);
return input;
}
}

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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.3</version>
</parent>
<artifactId>holographicdisplays-example-deathholograms</artifactId>
<name>HolographicDisplays Example DeathHolograms</name>
</project>

View File

@ -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()));
}
}

View File

@ -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.3</version>
</parent>
<artifactId>holographicdisplays-example-powerups</artifactId>
<name>HolographicDisplays Example PowerUps</name>
</project>

View File

@ -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();
}
});
}
}
}

View File

@ -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.3</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>

View File

@ -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.3</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>

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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");
}
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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.3</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>

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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);
}

View File

@ -1,32 +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.3</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>
</modules>
</project>

View File

@ -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.3</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>

View File

@ -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) { }
}

View File

@ -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) { }
}

View File

@ -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) { }
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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.3</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>

View File

@ -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) { }
}

View File

@ -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) { }
}

View File

@ -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) { }
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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.3</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>

View File

@ -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) { }
}

View File

@ -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) { }
}

View File

@ -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) { }
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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.3</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>

View File

@ -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) { }
}

View File

@ -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) { }
}

View File

@ -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) { }
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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);
}
}
}

View File

@ -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;
}
}
}
}

View File

@ -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;
}
}

View File

@ -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.3</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>

View File

@ -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) { }
}

View File

@ -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) { }
}

View File

@ -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) { }
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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