Compare commits

..
290 Commits
Author SHA1 Message Date
KennyTV 4074352a53 4.0.0 Release 🚀 2021-06-07 16:32:07 +02:00
KennyTV f909b55a84 1.17-rc2 2021-06-07 14:28:41 +02:00
KennyTV 593aa7564a Put the other filled 1.17 tags into the diff file 2021-06-07 09:58:52 +02:00
KennyTV 24efb48004 Add method to load extra tags from diff files 2021-06-06 17:17:51 +02:00
KennyTV 38b3f40f7d Add Java version warning
We will update the required Java version at some point, the only question is when.
2021-06-06 11:55:40 +02:00
KennyTV d89f916546 Cleanup 1.17 entity rewriter, fix DataItem amount check 2021-06-06 10:08:15 +02:00
KennyTV 62278f287c Update gson, junit, and checker-qual 2021-06-05 17:17:29 +02:00
KennyTV 72be978f8e Update issue template 2021-06-05 17:16:51 +02:00
creeper123123321 666f3d6c92 Explain "left-handed-handling" option (#2512) 2021-06-05 17:12:55 +02:00
KennyTV 8e7606ea1b 1.17-rc1 2021-06-04 16:00:38 +02:00
KennyTV 2b8c5082ed Make Item an interface, more OOP for the ItemRewriter 2021-06-04 12:15:14 +02:00
KennyTV 05f9fc1ddc 1.17-pre5 2021-06-03 20:22:48 +02:00
KennyTV fc1450fe38 Slightly more OOP, move registerPackets out of Protocol constructor
registerPackets being called within the constructor made it impossible to create instance objects then used in registerPackets (vs. having to then create the objects in registerPackets).
2021-06-03 17:28:02 +02:00
KennyTV e1072a8dc7 Fix docs 2021-06-03 10:45:58 +02:00
KennyTV 3290d4ae24 Expose lateBind field in ViaVersionPlugin 2021-06-03 10:40:25 +02:00
KennyTV b2855c2cd4 F 2021-06-02 23:22:09 +02:00
KennyTV fec777b349 Don't wrap direct type mappers 2021-06-02 23:22:00 +02:00
KennyTV 7b1f9c199a Produce less overhead in packet handler registering
Instead of creating a void type reader for every single PacketHandler registered, this just directly uses the consumer-like PacketHandler.

The distinction between ValueCreator and the normal PacketHandler was unnecessary given you could also just read something in a ValueCreator instance, effectively just being a consumer of a PacketWrapper instance.
2021-06-02 22:00:20 +02:00
KennyTV a8b3444ff5 1.17-pre4 2021-06-02 18:44:47 +02:00
KennyTV 6839334c1a Fix confirmation id encoding, remove old send methods 2021-06-02 12:44:49 +02:00
KennyTV d7e3aa7143 Whoops 2021-06-01 23:28:32 +02:00
KennyTV 48436e7caf Go through the rest of the send usages 2021-06-01 23:27:33 +02:00
KennyTV eaa58affd1 Minor changes 2021-06-01 22:52:05 +02:00
KennyTV 57cf1803f3 Fix 1.9 block entity data send 2021-06-01 19:36:25 +02:00
KennyTV 104fa4e29f Optimize protocol path finding
Not perfect, but better. This prevents the path checks from exponentially increasing (if it weren't for the maxProtocolPathSize fail safe).

By default, a path will never go to a protocol version that puts it farther from the desired server protocol version, even if a path existed.
Otherwise as well as previously, *all* possible paths will be checked until a fitting one is found.

Negative examples if the new boolean is set to true:
    A possible path from 3 to 5 in order of 3->10->5 will be dismissed.
    A possible path from 5 to 3 in order of 5->0->3 will be dismissed.

Negative examples if set to false:
    While searching for a path from 3 to 5, 3->2->1 could be checked first before 3->4->5 is found.
    While searching for a path from 5 to 3, 5->6->7 could be checked first before 5->4->3 is found.

Assuming custom platforms like Bedrock protocol use the normal registering methods, they will have to change the boolean to false to revert to previous behavior (tho still somewhat better optimized).
2021-06-01 18:54:36 +02:00
KennyTV 4011aee280 1.17-pre3 2021-06-01 18:10:53 +02:00
KennyTV 37fd69fa86 Make packet send methods use the current thread by default
Defaulting to submitting to the netty event loop caused issues more often than not - this also removes the `currentThread` flag and instead provides new scheduleSend methods so it is always obvious whether the packet is sent immediately.
2021-06-01 10:13:49 +02:00
KennyTV 3fb125592b Send entity destroy on current thread 2021-05-31 20:45:56 +02:00
KennyTV 7925fd2d8f Fix shulker meta handling 2021-05-31 20:17:43 +02:00
KennyTV 199324ee9d 1.17-pre2 2021-05-31 18:21:31 +02:00
KennyTV d5cac99b5f Reorder Type instances 2021-05-31 11:51:21 +02:00
KennyTV 3618914ce9 Add method to get Protocol by supported versions, some cleanup 2021-05-29 22:21:29 +02:00
KennyTV ff140c421a Add/change comments 2021-05-29 11:50:07 +02:00
RK_01 016b8f1dbc Correct ClientboundPackets1_9_3 packetid comments (#2503) 2021-05-29 09:34:24 +02:00
KennyTV 0d31054903 Fix view distance update packet in 1.13->1.14
The client world is initialized during the join packet, but the view distance packet was created during/before the join handling.
Fixes #2502
2021-05-28 10:02:26 +02:00
KennyTV 8beedffea2 Fix project root build/libs dir not being cleaned
The base plugin is usually applied by the java plugin, but since that has been moved into the platforms, cleaning was no longer applied to the root dir (created and filled by the universal submodule).
2021-05-27 23:56:31 +02:00
RK_01 4ef862e06d Correct packet id comment (#2501) 2021-05-27 15:42:51 +02:00
KennyTV 53642e9a3c 1.17-pre1 2021-05-27 15:36:53 +02:00
KennyTV fd9dab8aa1 Replace inventory ack by using 1.17 ping packets 2021-05-26 21:36:20 +02:00
KennyTV 703978e227 Don't require UserConnection holding class in stored objects 2021-05-26 21:35:28 +02:00
KennyTV 7195319eb5 Update adventure 2021-05-26 16:37:29 +02:00
KennyTV 2d0a597f74 Make Metadata fully type safe, remove "Discontinued" meta types
The Discontinued entry was a special edge case that could lead to a Metadata type returning null. Instead, just directly use null in the 1.8->1.9 code where it is checked against. Also renamed the Meta1_17Types entries to be in uppercase and properly represent their value type.
2021-05-26 16:36:47 +02:00
KennyTV bc89f57088 Slightly improve metadata iteration, remove redundant MetaHandlerEvent index
Lazily create the event if needed and share it with other filters when handling a metadata entry. Lastly, only add the additionally created meta once after the filter list, not once per filter.
2021-05-26 09:00:49 +02:00
KennyTV 57769c5671 Make metadata (almost) fail-safe
This could mean life and death, see
`new Metadata(17, MetaType1_14.Float, event.meta()).value()`
vs.
`new Metadata(17, MetaType1_14.Float, event.meta().value())`
2021-05-25 16:27:55 +02:00
LemonCaramel a6b4b16fd3 Add Missing Translation Mapping (#2484) 2021-05-25 16:27:19 +02:00
KennyTV 3a1e364d4a Refactor entity tracking and meta handling
This essentially merges the two approaches to the metadata handling from ViaVersion and ViaBackwards and improves on both designs.

ViaVersion did not track every single entity, but only those needed (at least in theory) and can work with untracked entities' metadata. It had a very simple method overridden by metadata rewriter implementations, directly operating on the full metadata list and manually handling meta index changes as well as item/block/particle id changes.

ViaBackwards on the other hand had to track *every single* entity and threw warnings otherwise - while less prone to errors due to giving obvious warnings in the console, it unnecessarily tracks a lot of entities, and those warnings also annoys users when encountering virtual entity plugins (operating asynchronously and sending update packets while already untracked or not yet tracked). Dedicated MetaHandlers made id changes and filtering a lot easier to read and write. However, the actual metadata list handling and its distribution to handlers was not very well implemented and required a lot of list copying and creation as well as exception throws to cancel individual metadata entries.

This version has MetaFilters built with a Builder containing multiple helper functions, and the entity tracking is properly given its own map, hashed by a Protocol's class, to be easily and generically accessible from anywhere with only a Protocol class from the UserConnection, along with more optimized metadata list iteration. The entity tracking is largely unchanged, keeping ViaVersion's approach to not having to track *all* entities (and being able to handle null types in meta handlers).

All of this is by no means absolutely perfect, but is much less prone to errors than both previous systems and takes a lot less effort to actually write. A last possible change would be to use a primitive int to object map that is built to be concurrency save for the EntityTracker, tho that would have to be chosen carefully.
2021-05-25 15:37:07 +02:00
Jason 03638028cd Make proper sources jar (#2495) 2021-05-25 09:44:57 +02:00
jmp d5f56784e2 Silence doclint 2021-05-25 09:07:06 +02:00
jmp cbf71e2289 Only add javadoc jar to common and api 2021-05-25 09:07:06 +02:00
jmp e2d9e44be3 Build script improvements 2021-05-25 09:07:06 +02:00
KennyTV 2d2a5fa79c Fill "needs tool" tags
Fixes #2493
2021-05-24 09:21:32 +02:00
RK_01 605331963d Fix typo in DumpSubCmd (#2492) 2021-05-23 19:42:01 +02:00
KennyTV 15a5d51248 Don't cast ChannelInitializer type to SocketChannel 2021-05-22 19:41:07 +02:00
KennyTV 8bcd8fd995 Add apiVersion to ViaAPI, some jd 2021-05-22 19:39:26 +02:00
Kamillaova 9484526d39 Fix README build command (gradlew) (#2489) 2021-05-22 13:37:53 +02:00
KennyTV ab1cc791b7 Fix enchantment parsing or lvl integers 2021-05-21 09:17:40 +02:00
KennyTV 1fe76dbb77 Add more jd to Chunk, ChunkSection, and ChunkSectionLight 2021-05-20 19:23:29 +02:00
KennyTV cf2adab728 Make ChunkSection an interface, don't allocate light arrays if not needed 2021-05-20 18:32:28 +02:00
KennyTV 04fedd2892 Add comments 2021-05-20 16:56:39 +02:00
KennyTV c172091944 21w20a 2021-05-19 18:54:38 +02:00
creeper123123321 16ba5aa4f9 Run some optipng (#2482) 2021-05-18 20:46:35 +02:00
KennyTV 5fa2c788e0 Add missing mineable tag entries
Fixes #2481
2021-05-18 17:07:57 +02:00
creeper123123321 c5a338137e Update fabric.mod.json (#2480) 2021-05-18 13:49:58 +02:00
KennyTV 01d79e2681 Fix non-full chunk sending to 1.17 clients 2021-05-17 17:31:42 +02:00
KennyTV 576682ef9f Handle invalid uuid int array
Closes #2475
2021-05-15 16:42:38 +02:00
KennyTV 54b0345017 Fix PS compatibility on Java 8 💩 2021-05-15 10:11:19 +02:00
KennyTV 4f9f3254be Fix PS compatibility on Java 16 2021-05-15 09:28:18 +02:00
KennyTV 1538ff5201 Expand unsupported software checks 2021-05-14 16:59:12 +02:00
creeper123123321 f17fb833a0 add internal getInputBuffer() (#2472) 2021-05-14 11:19:02 +02:00
KennyTV 84c064fc11 Fix legacy hover deserialization, add snapshot suffix to version 2021-05-14 10:59:43 +02:00
KennyTV 7b5b79f510 Update Gradle to 7.0.1 2021-05-12 16:00:42 +02:00
KennyTV 2588c6ecc8 21w19a (probably) 2021-05-12 15:19:33 +02:00
KennyTV 2df57bc37c Fix 1.14->1.15 meta ordering issue
Closes #2467
2021-05-10 13:27:12 +02:00
KennyTV efeaef3e4e Update shadow plugin 2021-05-09 10:25:57 +02:00
KennyTV cb7a7254a6 Make UnsupportedSoftware hold a list of class names 2021-05-08 10:05:43 +02:00
KennyTV fe3f247eb1 21w18a 2021-05-05 18:28:39 +02:00
Juan Cruz Linsalata 096415cf8e Don't inject if inactive (#2461) 2021-05-02 15:52:07 +02:00
KennyTV af0cf1d3f2 Rename PacketType methods
Just in case a packet with some magic id is going to be added, since the enum ordinal and name methods cannot be overridden
2021-05-02 11:14:38 +02:00
KennyTV d183d76c47 Remove platform bulk chunk transformers 2021-05-02 10:12:37 +02:00
KennyTV 44e928d53c Update copyright scopes 2021-04-30 19:05:07 +02:00
KennyTV 89127cad8a If possible, user Paper internal injection method 2021-04-29 23:32:13 +02:00
KennyTV ab93e0877c Rename platform task implementations 2021-04-29 17:46:29 +02:00
KennyTV 96b5051c75 Use primitive long in task methods 2021-04-29 17:31:16 +02:00
KennyTV 9e59ef4c4a Hold the rest of the primitive Type instances under their actual class
This brings no improvement now, but if primitive read/write methods for manual calls were implemented later, a signature break will have been prevented by this (aka breaking it now)
2021-04-28 21:12:19 +02:00
KennyTV 00746833ac ProtocolInfo is not a StoredObject
You can't actually call UserConnection#get with ProtocolInfo.class since the ProtocolInfo interface is not a StoredObject
2021-04-28 18:57:08 +02:00
KennyTV 8e15b6d42b 21w17a 2021-04-28 17:40:57 +02:00
KennyTV cad358322d Rename outgoing->clientbound, incoming->serverbound
Via can both be used on servers and clients, making a direction like "incoming" ambiguous
2021-04-28 16:30:34 +02:00
KennyTV a2b3906c9e Move bossbar to new legacy package, since it only works on <1.9
The newly created LegacyViaAPI is safe to use, but should hold methods that cannot be universally used on every version
2021-04-28 11:10:16 +02:00
KennyTV cadb5ec64c Rename abstract Protocol to AbstractProtocol
This prevents confusion around the previously equally named interface and abstract class
2021-04-27 18:21:51 +02:00
KennyTV 95e20677fd Clean up ProtocolPipeline
The filter functionality isn't something that's likely to be used again, so move out its usage and only check on <1.9 servers
2021-04-27 15:59:06 +02:00
KennyTV f1c8d271b1 Reformat imports
The package rename wasn't done through refactoring but through simple replaces to not make git choke on diffs
2021-04-27 13:42:36 +02:00
KennyTV 318c49cf30 More interfaces, keep ProtocolRegistry.SERVER_PROTOCOL legacy api 2021-04-27 13:25:18 +02:00
KennyTV d4bc31d11e Always create ProtocolInfo, store mappings as int[] 2021-04-27 10:29:30 +02:00
KennyTV 30d122e7fa Create some fancy interfaces 2021-04-26 23:01:55 +02:00
KennyTV 49d386063d Add ProtocolVersion to legacy api 2021-04-26 21:45:27 +02:00
KennyTV deec4b521e Move some packages and classes around 2021-04-26 21:27:59 +02:00
KennyTV dbf6a110f2 Keep wrapping Via, ViaAPI, and Bossbar API in api-legacy module 2021-04-26 20:55:24 +02:00
KennyTV a25a5634de Change package/imports in classes and build configs 2021-04-26 20:52:34 +02:00
KennyTV a3b1ce817e Repackage to com.viaversion
This process will be split into multiple commits for git not to choke on.
2021-04-26 20:46:30 +02:00
KennyTV c02047aaf8 Change group id to com.viaversion 2021-04-24 20:54:46 +02:00
Juan Cruz Linsalata f18e2b3875 Cancel Bungee packet encoding when closed (#2448) 2021-04-24 18:30:08 +02:00
KennyTV ad0842c107 Bump version to 4.0.0, remove ProtocolRegistry
The bump was overdue given the breakages that have happened
2021-04-23 22:48:08 +02:00
KennyTV 2b19a98809 21w16a 2021-04-21 19:40:51 +02:00
KennyTV d40ce9fc4a Minor optimizations in pipeline filling 2021-04-21 11:58:19 +02:00
KennyTV 144c24c276 Move packet tracking methods out of UserConnectionn 2021-04-20 13:24:10 +02:00
Mariell Hoversholm 2c884dc241 Feat (Bungee): Use only unsafe field modifications (#2440) 2021-04-17 09:59:24 +02:00
KennyTV d0882cf02c Update GsonUtil, more javadoc 2021-04-16 23:05:31 +02:00
RK_01 cfec0cc25f Improve 1.9->1.8 block place translation (and fix some bugs) (#2437) 2021-04-16 08:45:33 +02:00
KennyTVandjmp d3a3e366b1 Fix publishing
Co-authored-by: jmp <jasonpenilla2@me.com>
2021-04-15 11:07:40 +02:00
MrMicky f1eef0294f Fix Java 16 compatibility on Bukkit/Sponge 1.8 (#2438) 2021-04-15 08:43:05 +02:00
KennyTV 4df70de312 Add note on required jdk version for compilation 2021-04-14 20:43:30 +02:00
KennyTV 898521de9a 21w15a 2021-04-14 17:38:06 +02:00
Jason 87d54f1103 Clean up build scripts using new Gradle features (#2436)
* Make use of `TYPESAFE_PROJECT_ACCESSORS` and `VERSION_CATALOGS` Gradle feature previews to clean up build scripts

* Bump setup-java action to v2, specify AdoptOpenJDK distribution
2021-04-14 14:16:48 +02:00
KennyTV c7e5b4a297 Update to Gradle 7.0 2021-04-13 12:37:29 +02:00
Mariell Hoversholm 458279d111 Fix (Bungee): Java 16 compatibility (#2433)
This has been tested on the following:
 - AdoptOpenJDK Java 1.8.0_282
 - GraalVM CE 21.0.0 OpenJDK 11.0.10
 - AdoptOpenJDK Java 15.0.2
 - AdoptOpenJDK Java 16 (also tested with BungeeCord b1556)
 - Amazon Corretto OpenJDK 16.0.0.36.1

... with Waterfall b406 on Linux 5.10.28.
2021-04-13 11:42:32 +02:00
KennyTV 7300a69817 Use Paper method to get server protocol version if possible 2021-04-12 20:11:13 +02:00
LabyStudio 76e739e4f0 fix ghost shield issue and delayed interaction when switching to another item (#2432) 2021-04-12 16:56:53 +02:00
KennyTV 0ee80dc41f Don't throw an exception on hover parse failure 2021-04-11 13:35:53 +02:00
KennyTV 4473f863c6 Update ComponentRewriter 2021-04-10 17:03:43 +02:00
creeper123123321 9f380a7598 Handle minecart block data (#2424) 2021-04-09 17:09:30 +02:00
KennyTV 3c7d481a39 Fix namespaced 1.12->1.13 sound conversion 2021-04-09 14:56:44 +02:00
KennyTV b23c01c44b Javadoc additions 2021-04-08 21:44:45 +02:00
KennyTV 00b8289c61 Handle new entity pose from 21w13a 2021-04-07 17:27:51 +02:00
KennyTV e9fa5b49ca 21w14a 2021-04-07 16:55:22 +02:00
KennyTV ef8cb05703 Update build badge in readme 2021-04-06 19:02:05 +02:00
LabyStudio e83686d6fc Implement showShieldWhenSwordInHand option (#2417) 2021-04-05 18:53:57 +02:00
KennyTV 26bbc92f94 Warn about potentially unstable plugins/server software 2021-04-03 17:01:57 +02:00
MrMicky 9ccd8bff33 Fix error with shit-click on offhand slot on 1.8 servers (#2419) 2021-04-03 09:09:00 +02:00
KennyTV 29d6b55592 Fix ChunkSection nullability annotations 2021-04-02 18:29:51 +02:00
KennyTV 1251d43709 Fix invalid enchantment parsing
Fixes #2418
2021-04-02 18:22:18 +02:00
KennyTV 070c7f5808 Move to checker qual nullability annotations 2021-04-02 14:15:30 +02:00
KennyTV d79bd00f58 Minor log changes 2021-04-02 10:21:31 +02:00
creeper123123321 df7a644479 Add ShortByteArrayType, minor PacketWrapper changes (#2413) 2021-04-01 20:17:17 +02:00
R0bbyYT 956492bca6 Add option to fix delayed shield blocking (#2415) 2021-04-01 20:03:13 +02:00
creeper123123321 1d311284fd GitHub workflow (#2163) 2021-03-31 21:53:10 +02:00
KennyTV b251170c22 Add goat entity type 2021-03-31 20:40:02 +02:00
KennyTV ab376dc562 21w13a 2021-03-31 19:18:16 +02:00
KennyTV fd9442b077 Minor jd changes in ViaAPI, fix typo 2021-03-30 22:10:57 +02:00
KennyTV a63f2ab6fe Improve server version API 2021-03-26 12:51:38 +01:00
KennyTV d918fd27b6 Reduce boxing in protocol path getting
More of its implementation should probably be cleaned up later
2021-03-25 22:34:30 +01:00
KennyTV 63356207a3 ProtocolRegistry -> ProtocolManager interface 2021-03-24 15:30:03 +01:00
KennyTV 210cae70fd Add MIT copyright headers to the api module 2021-03-24 14:02:38 +01:00
KennyTV 0ab2c626aa Split parts of common into api; We are now GPL, api is MIT
This does not affect any previous states of this project; only future modifications as well as the project as a whole will be under the GNU General Public License from now on. The newly introduced api directory, partly split from common, is an exception to this, still being licensed under the MIT license.

See the README for details.
2021-03-24 14:02:37 +01:00
KennyTV b8072aad86 Merge remote-tracking branch 'origin/master' into dev
# Conflicts:
#	.github/ISSUE_TEMPLATE/config.yml
2021-03-22 15:39:34 +01:00
KennyTV 00b4c9b1f8 Add feature request template 2021-03-22 15:30:33 +01:00
KennyTV 2f45de2f6a Small changes to the issue form 2021-03-22 14:42:05 +01:00
KennyTV f60c0165e3 Issue forms, anyone? 2021-03-22 14:36:47 +01:00
KennyTV bfcfb4340e Add missing doc 2021-03-22 13:47:40 +01:00
KennyTV 9b4d50b214 Tidy up concurrent mapping loading 2021-03-21 20:25:52 +01:00
KennyTV bdeb5acae9 Fix license bundling 2021-03-21 20:07:32 +01:00
KennyTV 81b9f1b4cd 21w11a 2021-03-17 17:01:58 +01:00
KennyTV 0552863f28 Update adventure 2021-03-15 20:59:46 +01:00
KennyTV 0986e174a2 Fix drag desync 2021-03-15 14:50:58 +01:00
KennyTV b589561932 More primitive tag calls 2021-03-15 10:43:09 +01:00
KennyTV 388eb73782 Update nbt usage 2021-03-15 10:43:09 +01:00
KennyTV 2f7de53e9b Merge remote-tracking branch 'origin/master' into dev 2021-03-13 15:34:10 +01:00
KennyTV f7afe84982 21w10a (kind of) 2021-03-10 23:18:13 +01:00
LemonCaramel ea014656bc Add "forced-use-1_17-resource-pack" option (#2390) 2021-03-08 12:30:23 +01:00
LemonCaramel 72de597544 Fix Explosion Mapping (#2389) 2021-03-08 08:28:03 +01:00
KennyTV d7c8f3a594 Update Sponge repository url 2021-03-07 12:26:17 +01:00
LemonCaramel 6cc761e3b2 Title Packet fix (#2387) 2021-03-07 10:03:05 +01:00
Joseph Burton 2723302f56 Update bug_report.md 2021-03-06 18:34:34 +01:00
KennyTV 6497cca8bd Update adventure 2021-03-04 17:02:43 +01:00
KennyTV ec188db247 Shade relocated adventure without breaking native platform usage 2021-03-04 16:11:09 +01:00
KennyTV b84bc7668a Fixes 2021-03-04 16:11:09 +01:00
KennyTV cf8d11d530 Let's go on an <insert title card> 2021-03-04 16:11:09 +01:00
RK_01 7f8052c3cd Fix handling of unknown container ids (#2384) 2021-03-04 15:05:27 +01:00
KennyTV 08763a92ab Add 1.17 to table 2021-03-02 14:14:28 +01:00
LemonCaramel 6e9e757294 Fix ExceptionInInitializerError (#2372) 2021-02-28 00:42:37 +01:00
KennyTV 5e227cb4a5 Fix Bungee Chat relocation
Fixes #2371
2021-02-27 10:21:39 +01:00
RK_01 3c73d70f63 Fix handling of animation 3 in 1.8->1.9 (#2358) 2021-02-26 14:45:55 +01:00
KennyTV 9fbadc0ad5 Keep white background of version chart 2021-02-26 10:51:49 +01:00
KennyTV 6b7818e6f1 21w08b 2021-02-25 15:59:48 +01:00
KennyTV 16208b2a7f Update README 2021-02-25 10:21:11 +01:00
KennyTV a0351b8168 Update version 2021-02-25 09:20:31 +01:00
KennyTV 35ac41e1fa Fix subproject version/name 2021-02-25 09:19:18 +01:00
Jason 46a01cb0f0 Fix publishing (#2364) 2021-02-25 09:19:18 +01:00
Myles e437c656c5 Revert "Try /everything"
This reverts commit 902081b22b3b6c7a4ac56c7ec68fa76f917267bb.
2021-02-25 09:19:18 +01:00
KennyTV f5b8937a70 Try /everything 2021-02-25 09:19:17 +01:00
Myles 8e069812e0 Set maven authentication to basic 2021-02-25 09:19:17 +01:00
jmp b6bee8f4cc Configure artifacts for publication 2021-02-25 09:19:17 +01:00
KennyTV aaaa97f781 Fix local publishing 2021-02-25 09:19:17 +01:00
KennyTV 5b0d98f639 Remove test publishing 2021-02-25 09:19:16 +01:00
KennyTV 68985141f1 Try local publishing 2021-02-25 09:19:16 +01:00
KennyTV a48f717396 Add publish url 2021-02-25 09:19:16 +01:00
KennyTV a7a00e9f67 Update version 2021-02-25 09:19:16 +01:00
KennyTV c719b98ab3 Don't spam compiler warnings 2021-02-25 09:19:15 +01:00
KennyTV c059e57771 Move javassist to Bukkit moduke 2021-02-25 09:19:15 +01:00
KennyTV 5fde8c25a3 Change universal jar name 2021-02-25 09:19:15 +01:00
jmp 02f1ab1752 Uppercase jar names 2021-02-25 09:19:14 +01:00
jmp 024c36c584 Switch to indra, attempt to fix shading and universal jar 2021-02-25 09:19:14 +01:00
KennyTV ef6c347194 *cries in elephant* 2021-02-25 09:19:14 +01:00
KennyTV c0dabfe097 *cries in elephant* 2021-02-25 09:18:51 +01:00
KennyTV 0a41d36220 21w08a (aka the great splittening) 2021-02-24 23:38:28 +01:00
KennyTV 37004d8c4f 21w07a 2021-02-17 18:55:43 +01:00
KennyTV 01277d147e Deduplicate more entitytype code 2021-02-16 12:24:35 +01:00
KennyTV 1da0b38849 Merge remote-tracking branch 'origin/master' into dev 2021-02-16 12:21:32 +01:00
KennyTV 84f8e019c8 Fix 1.9to1.9.1 protocol registration 2021-02-15 20:02:31 +01:00
KennyTV 64b7e74d80 Cleanup modern entity types 2021-02-14 17:24:20 +01:00
creeper123123321 a141f871a9 ProtocolVersion.toString() space (#2343) 2021-02-13 13:21:02 +01:00
KennyTV 69609d536b Use chunk section length for fallback biome array 2021-02-11 21:45:36 +01:00
KennyTV b21de03710 Read byte in player position 2021-02-11 19:54:00 +01:00
KennyTV e7b489f66e This is actually 21w06a 2021-02-11 09:30:30 +01:00
KennyTV 7493c8d7b7 Add setSections to Chunk 2021-02-11 00:00:02 +01:00
KennyTV 4ff98256f6 21w06a 2021-02-10 19:09:33 +01:00
Myles d1a0d629df Merge branch 'master' into dev 2021-02-09 16:32:44 +00:00
Myles 50bfc86706 Revert "The bytebuf doesn't need to be rewritten"
This reverts commit ac877d0b1a.
2021-02-09 16:32:31 +00:00
Myles 76c83da382 Merge branch 'master' into dev 2021-02-09 10:54:34 +00:00
Myles f04a748e54 Ignore NBT with hanging comma, fixes #2319 2021-02-09 10:54:04 +00:00
Myles d39193400f Ignore NBT with hanging comma, fixes #2319 2021-02-09 10:50:11 +00:00
Myles 628979f923 Merge branch 'master' into dev 2021-02-09 10:36:54 +00:00
Myles 24b4cd8dbd Merge branch 'reduce-decode-rewriting' 2021-02-09 10:36:13 +00:00
Myles 727c575a1c Run QuickMove on next tick to improve likeliness of success (fixes #2044)
Since it is 5 ticks later, the inventory may be closed
2021-02-09 10:35:13 +00:00
Myles ac877d0b1a The bytebuf doesn't need to be rewritten 2021-02-06 15:29:36 +00:00
Myles 37d57af6ec Change ResourceLeakDetector to PARANOID for displayleaks 2021-02-06 15:26:21 +00:00
KennyTV e09c3b0159 Merge remote-tracking branch 'origin/master' into dev 2021-02-06 15:38:06 +01:00
Myles 22793dbac4 Re-add a semicolon
🥇
2021-02-06 14:30:18 +00:00
Myles 1998eca6c8 Merge pull request #2322 from creeper123123321/passbytebuf
Allow bytebuf passthrough on encode
2021-02-06 14:25:42 +00:00
creeper123123321 100ae1c680 Update SpongeEncodeHandler.java 2021-02-06 11:18:51 -03:00
creeper123123321 6941b48038 fixed pending #2291 changes 2021-02-06 10:21:34 -03:00
KennyTV 59c9018250 Call command argument handler with unmapped name 2021-02-05 13:04:57 +01:00
RK_01 bdfaf9a621 Remap declare command parser types in 1.14 -> 1.13.2 (#2316) 2021-02-05 12:18:28 +01:00
KennyTV 54488341bf Add abstract declare commands handler 2021-02-05 11:41:21 +01:00
KennyTV 59e05e3096 21w05b 2021-02-04 19:11:24 +01:00
KennyTV 554fbb49c5 21w05a 2021-02-03 19:30:28 +01:00
Jo0001 7faf4cf81a Change error message (#2286) 2021-02-01 14:51:03 +01:00
KennyTV ee2959ac5d Handle shulker meta change 2021-01-21 11:37:31 +01:00
KennyTV e679a0c2b0 Fix dust particle writing
The double/float inconsistency was fixed in 21w03a, yay
2021-01-21 09:26:56 +01:00
KennyTV 14bfb8d147 Fix glow squid entity id 2021-01-20 18:51:07 +01:00
KennyTV 3a9dd5c86d Add setBitmask to Chunk 2021-01-20 18:24:43 +01:00
KennyTV c8c54786fc 21w03a 2021-01-20 17:59:34 +01:00
KennyTV 4cc8a3f092 Return -1 in getPlayerVersion if the player is not connected 2021-01-17 13:59:26 +01:00
KennyTV 2beed20f1b Update 1.16.4/5 protocol name 2021-01-17 13:55:19 +01:00
Thibaut Gautier 91319402f3 Fixed encoding not properly working with other packet reading libraries
Injecting a message to byte encoder beforehand would break outbound packets in ViaVersion. This solution is a good fix which won't impact anything.
2021-01-17 13:12:18 +01:00
RK_01 ee147a4b37 Replace some hardcoded chunk section values (#2274) 2021-01-05 09:42:32 +01:00
KennyTV 127cae80bd Fix 1.17 entity tracking
Fixes #2250
2020-12-17 12:38:51 +01:00
KennyTV 55a2a0a779 Fix disconnect on respawn packet send
Closes #2251
2020-12-17 11:52:15 +01:00
KennyTV ed4d0bc134 Add methods to handle new tags format 2020-12-17 11:51:51 +01:00
KennyTV 6298eb42c5 Make TagRewriter.TagData public 2020-12-16 19:54:02 +01:00
KennyTV 823ac0e173 Add RegistryType#getByKey 2020-12-16 19:50:49 +01:00
KennyTV 6622b7dcff 20w51a 2020-12-16 18:57:16 +01:00
KennyTV 4858d75439 Change the outdated server message 2020-12-15 11:38:41 +01:00
KennyTV 4355f8987f Merge branch 'master' into dev
# Conflicts:
#	bukkit-legacy/pom.xml
#	bukkit/pom.xml
#	bungee/pom.xml
#	common/pom.xml
#	fabric/pom.xml
#	jar/pom.xml
#	pom.xml
#	sponge-legacy/pom.xml
#	sponge/pom.xml
#	velocity/pom.xml
2020-12-15 11:16:57 +01:00
Myles c0fb81946e Snapshot 2020-12-12 13:16:13 +00:00
Myles 6c440513ba 3.2.1 2020-12-12 13:07:59 +00:00
Myles 2da0e1cad7 Merge pull request #2198 from terrarier2111/patch-3
Created a local variable for ProxiedPlayers
2020-12-11 09:17:16 +00:00
Myles 3d777bdcda Merge pull request #2237 from mathiascode/statscheck
Add missing length check in 1.13 -> 1.12.2 stats code
2020-12-11 09:15:30 +00:00
Mat e22975cec4 Add missing length check in 1.13 -> 1.12.2 stats code 2020-12-11 03:08:34 +02:00
KennyTV f35c48bed2 Merge branch 'master' into dev 2020-12-09 21:39:13 +01:00
KennyTV 965814d833 Fix ProtocolLib check (again)
#BlameGerry (again)
2020-12-09 21:31:00 +01:00
KennyTV 459e3e68b8 Dust particle rgb values are now written as doubles 2020-12-09 12:41:26 +01:00
KennyTV 72205a5414 Whoops 2020-12-09 11:47:59 +01:00
KennyTV e7ad3970cc Complete vibration particle reading 2020-12-09 11:47:40 +01:00
KennyTV 4714a3f03a Merge branch 'master' into dev 2020-12-09 11:31:51 +01:00
KennyTV f08db2d234 Fix startup
#BlameGerry
2020-12-09 11:31:37 +01:00
KennyTV 5954c16f62 New particle meta type 2020-12-09 11:29:07 +01:00
KennyTV a4d1ac3b95 Add getSpawnParticleHandler method to ItemRewriter 2020-12-09 11:03:40 +01:00
KennyTV 52b95eab28 Merge remote-tracking branch 'origin/master' into dev 2020-12-09 09:17:37 +01:00
Gerrygames 24c56a239e Fix PacketWrapper#sendToServer bypassing ProtocolLib (#2229) 2020-12-08 19:15:55 +01:00
KennyTV 7858b998ca Reduce chance of quick move task while disabling
Closes #2226
2020-12-08 12:42:13 +01:00
creeper123123321 d75420a35b Use ArrayDeque, less ram for PacketWrapper.readableObjects (#2218) 2020-12-07 11:50:52 +01:00
KennyTV 137680ed9f Use generic y section count in 1.17 chunk reading 2020-12-03 11:53:05 +01:00
KennyTV e56ff898eb Use integer for y coordinate in Position 2020-12-03 11:14:46 +01:00
KennyTV 3aa35395f4 Fix tag processing in older versions, small refactor 2020-12-03 11:14:35 +01:00
KennyTV ff91dd7082 Finish 20w49a 2020-12-02 22:31:02 +01:00
KennyTV 8a11b577eb Current WIP 20w49a 2020-12-02 21:57:32 +01:00
_tomcraft 6882678bc4 Reduce useless List operations (#2214) 2020-11-29 21:31:18 +01:00
KennyTV 4555c5dbf3 Use FU map in FakeTileEntity 2020-11-29 16:40:40 +01:00
KennyTV 4cc0d2c1a2 Merge remote-tracking branch 'origin/master' into dev 2020-11-29 16:39:06 +01:00
KennyTV c671a6deed 20w48a (probably) 2020-11-25 17:15:43 +01:00
KennyTV 8de26a0ad3 Work around relocation of fastutil reflection call 2020-11-23 20:49:28 +01:00
KennyTV e128f6a7ed Merge branch 'master' into dev 2020-11-23 15:22:44 +01:00
KennyTV 9c0b187f31 Catch errors in Bungee chat parsing 2020-11-22 09:55:39 +01:00
terrarier2111 6a12f8139c Added missing import 2020-11-21 19:26:10 +01:00
KennyTV e85f9e7510 Fix npe
Fixes #2196
2020-11-20 13:23:23 +01:00
terrarier2111 0b256d15b2 Created a local variable for ProxiedPlayers 2020-11-15 21:15:42 +01:00
KennyTV 7abff77c51 Add method to get handler in sound rewriter 2020-11-15 12:01:01 +01:00
KennyTV 78972a5345 Add 1.9-1.11 sound mappings 2020-11-15 11:36:26 +01:00
KennyTV 7a6e45008b Fix entity item meta 2020-11-14 22:21:36 +01:00
_tomcraft a041610fe2 Prevent 1.12- clients to creative-pick server-side unknown block/item (#2180) 2020-11-13 14:27:29 +01:00
KennyTV ba776e5f88 Handle metadata and map data changes
Mapdata might be bork tho™️
2020-11-12 21:34:12 +01:00
KennyTV 67fda72bdd 20w46a 2020-11-11 19:13:31 +01:00
KennyTV 721c52e3f5 Fix multi block change reading 2020-11-11 16:54:19 +01:00
KennyTV 424e855d72 Uncache biome data on world change, process multi block change 2020-11-11 16:54:19 +01:00
KennyTV 88a1a42625 Finish update
Still unsure whether we also have to store block entity data and if/which respawn conditions have to be checked for biome uncaching
2020-11-11 16:54:18 +01:00
KennyTV 0d3f729679 20w45a
Missing: Diff mappings
2020-11-11 16:54:18 +01:00
KennyTV 692e53427b Change log message when executor is shut down 2020-11-11 16:53:47 +01:00
KennyTV 3b5aaa1ff5 Fix legacy nbt array weirdness
Closes #2176
2020-11-08 10:35:15 +01:00
KennyTV 95e0cff03c Fix italic item names in 1.12->1.13 protocol
Fixes #2165
2020-11-03 13:40:01 +01:00
KennyTV 91f3d0fdb7 Bump version to 3.2.1-SNAPSHOT 2020-11-03 09:49:46 +01:00
959 changed files with 67015 additions and 19162 deletions

No files matched your search

-31
View File
@@ -1,31 +0,0 @@
---
name: Bug report
about: Create a bug report so we can fix it
---
**Describe the bug, provide any errors**
A clear and concise description of what the bug is. If present, can you paste the error to https://paste.gg/?
**How can we reproduce it?**
Steps to reproduce the behavior:
1. Login on 1.12'
2. Click on '....'
3. The '....' is displayed wrong
**Expected behaviour**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**ViaVersion Dump**
- Type /viaversion dump, and put the link here.
**Additional server info**
Do you use a proxy (eg. BungeeCord)? What software do you use and what plugins?
**Checklist**
- [ ] I have included a Viaversion dump
- [ ] If applicable, I have included a paste (not a screenshot) of the error
- [ ] I have tried a build from https://ci.viaversion.com/ and the issue still persists
+91
View File
@@ -0,0 +1,91 @@
name: Bug Report
description: Report a bug or console error
body:
- type: markdown
attributes:
value: |
**Before reporting a bug, please see if using master/dev builds from https://ci.viaversion.com/ fixes your issue.**
Whenever you see fit, you can upload images or video to any of the textfields.
- type: input
attributes:
label: "`/viaversion dump` Output"
description: |
Run `/viaversion dump` in the console or in the chat, then copy and paste the given link here.
placeholder: |
https://dump.viaversion.com/...
validations:
required: true
- type: textarea
attributes:
label: Console Error
description: |
If you encounter warnings/errors in your console, **paste them with https://paste.gg/ and put the paste link here**.
If the error is small/less than 10 lines, you may put it directly into this field.
value: |
```
Put the paste.gg link or text here.
```
placeholder: Please do not remove the grave accents; simply replace the line of text in the middle.
validations:
required: false
- type: textarea
attributes:
label: Bug Description
description: |
Describe the unexpected behavior.
If you want to attach screenshots, use the comment field at the bottom of the page.
placeholder: |
Example: "Placing signs on 1.13.2 causes text to disappear."
validations:
required: true
- type: textarea
attributes:
label: Steps to Reproduce
description: |
List the steps on how we can reproduce the issue. Make sure we can easily understand what you mean with each step.
placeholder: |
Example:
1. Login with a 1.13.2 client
2. Place a sign
3. The sign text is displayed wrong
validations:
required: true
- type: textarea
attributes:
label: Expected Behavior
description: |
Describe what exactly you expected to happen.
placeholder: |
Example: "Placed sign text should not disappear."
validations:
required: true
- type: textarea
attributes:
label: Additional Server Info
description: |
Do you use a proxy (eg. BungeeCord)? What software do you use and what plugins?
placeholder: |
Example: "I also use BungeeCord with the following plugins: x, y, z"
validations:
required: false
- type: checkboxes
attributes:
label: Checklist
description: Make sure you have followed each of the steps outlined here.
options:
- label: Via plugins are only running on **EITHER** the backend servers (e.g. Paper) **OR** the proxy (e.g. BungeeCord), **not on both**.
required: true
- label: I have included a ViaVersion dump.
required: true
- label: If applicable, I have included a paste (**not a screenshot**) of the error.
required: true
- label: I have tried a build from https://ci.viaversion.com/ and the issue still persists.
required: true
+7
View File
@@ -1 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Dev builds
url: https://ci.viaversion.com/
about: Before reporting a bug, please check if using master/dev builds from our ci fixes your issue.
- name: ViaVersion Discord
url: https://discord.gg/viaversion
about: For smaller issues or questions, you can also join our Discord server.
-17
View File
@@ -1,17 +0,0 @@
---
name: Feature request
about: Suggest an idea for ViaVersion
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Which versions is this for?**
Does the feature apply to any specific versions? If so put them here.
@@ -0,0 +1,37 @@
name: Feature Request
description: Suggest a feature to be added
body:
- type: textarea
attributes:
label: Problem Description
description: |
Describe the issue you are facing or why you need the feature to be added.
placeholder: |
I am always frustrated with...
validations:
required: true
- type: textarea
attributes:
label: Solution Description
description: |
Describe the solution you would like to see.
validations:
required: true
- type: textarea
attributes:
label: Alternatives
description: |
Describe alternatives you have considered.
validations:
required: false
- type: textarea
attributes:
label: Additional Info
description: |
Does the feature apply to any specific version or environment?
validations:
required: false
+28
View File
@@ -0,0 +1,28 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Java CI with Gradle
on: [push, pull_request]
jobs:
build:
# Only run on PRs if the source branch is on a different repo. We do not need run everything twice.
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 11
- name: Build with Gradle
run: ./gradlew build
- uses: actions/upload-artifact@v2
with:
name: artifact
path: build/libs
-15
View File
@@ -1,15 +0,0 @@
sudo: false
language: java
jdk:
- openjdk11
cache:
directories:
- '$HOME/.m2/repository'
script:
- mvn dependency:purge-local-repository -DactTransitively=false -DreResolve=false
- mvn clean install -B -U
install: true
+670 -17
View File
@@ -1,21 +1,674 @@
MIT License
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (c) 2020
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Preamble
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
+40 -13
View File
@@ -1,29 +1,27 @@
# ViaVersion - Spigot, Sponge, BungeeCord, Velocity
[![Latest Release](https://img.shields.io/github/v/release/ViaVersion/ViaVersion)](https://viaversion.com)
[![Build Status](https://travis-ci.com/ViaVersion/ViaVersion.svg?branch=master)](https://travis-ci.com/ViaVersion/ViaVersion)
[![Build Status](https://github.com/ViaVersion/ViaVersion/actions/workflows/gradle.yml/badge.svg?branch=master)](https://github.com/ViaVersion/ViaVersion/actions)
[![Discord](https://img.shields.io/badge/chat-on%20discord-blue.svg)](https://viaversion.com/discord)
**Allows the connection of higher client versions to lower server versions**
Supported Versions:
![Table (https://i.imgur.com/0u20Y2u.png)](https://i.imgur.com/0u20Y2u.png)
![Table (https://i.imgur.com/uDM9HR8.png)](https://i.imgur.com/uDM9HR8.png)
On Paper you may also use ProtocolSupport, but ensure you have the right build for your server version.
**User Docs:** https://docs.viaversion.com/display/VIAVERSION/
Sources:
--------
**wiki.vg** (Used for various information, we also contribute back)
**[wiki.vg](https://wiki.vg)** (Used for information regarding packet structure, we also contribute back)
**Burger** (See [PAaaS](https://github.com/Matsv/Paaas))
**OpenNBT** (used for slot rewriting)
**[Burger](https://github.com/Pokechu22/Burger)** (See [PAaaS](https://github.com/Matsv/Paaas))
**[OpenNBT](https://github.com/ViaVersion/OpenNBT)**
Releases / Dev Builds:
@@ -32,7 +30,6 @@ You can find official releases here:
https://www.spigotmc.org/resources/viaversion.19254/history
----------
You can find official dev builds here:
@@ -41,12 +38,42 @@ You can find official dev builds here:
**JavaDocs:** https://jd.viaversion.com
**Maven Repo:** https://repo.viaversion.com
**Maven Repository:**
```xml
<repository>
<id>viaversion-repo</id>
<url>https://repo.viaversion.com</url>
</repository>
```
**API-artifact:**
```xml
<dependency>
<groupId>com.viaversion</groupId>
<artifactId>viaversion-api</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
```
Replace the version depending on your needs.
If you need access to the existing protocol or platform implementations, use the parent artifact `viaversion`.
Please note the [differences in licensing](#license).
Building:
--------
After cloning this repository, build the project with Gradle by running `./gradlew build` and take the created jar out of
the `build/libs` directory.
License:
--------
The entirety of the [API directory](api) (including the legacy API directory) is licensed under the MIT License; see [licenses/MIT.md](licenses/MIT.md) for
details.
MIT License, see LICENSE for more details.
Everything else, unless explicitly stated otherwise, is licensed under the GNU General Public License, including the end
product as a whole; see [licenses/GPL.md](licenses/GPL.md) for details.
Special thanks to all our [Contributors](https://github.com/ViaVersion/ViaVersion/graphs/contributors)
Special thanks to all our [Contributors](https://github.com/ViaVersion/ViaVersion/graphs/contributors).
+25
View File
@@ -0,0 +1,25 @@
plugins {
id("com.github.johnrengelman.shadow")
}
// Shade and relocate adventure in an extra module, so that common/the rest can directly depend on a
// relocated adventure without breaking native platform's adventure usage with project wide relocation
tasks {
shadowJar {
relocate("net.kyori", "com.viaversion.viaversion.libs.kyori")
}
build {
dependsOn(shadowJar)
}
}
dependencies {
api(libs.bundles.adventure) {
exclude("org.checkerframework")
exclude("net.kyori", "adventure-api")
exclude("net.kyori", "adventure-bom")
exclude("com.google.code.gson", "gson")
}
}
publishShadowJar()
+3
View File
@@ -0,0 +1,3 @@
dependencies {
compileOnly(projects.viaversionApi)
}
@@ -0,0 +1,102 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api;
import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion.api.boss.BossBar;
import us.myles.ViaVersion.api.boss.BossColor;
import us.myles.ViaVersion.api.boss.BossStyle;
import java.util.SortedSet;
import java.util.UUID;
/**
* @deprecated may be removed at some point, use {@link com.viaversion.viaversion.api.Via}
*/
@Deprecated
public class Via<T> implements ViaAPI<T> {
private static final ViaAPI INSTANCE = new Via();
private Via() {
}
@Deprecated
public static ViaAPI getAPI() {
return INSTANCE;
}
@Override
public int getPlayerVersion(T player) {
return com.viaversion.viaversion.api.Via.getAPI().getPlayerVersion(player);
}
@Override
public int getPlayerVersion(UUID uuid) {
return com.viaversion.viaversion.api.Via.getAPI().getPlayerVersion(uuid);
}
@Override
public boolean isInjected(UUID playerUUID) {
return com.viaversion.viaversion.api.Via.getAPI().isInjected(playerUUID);
}
@Override
public String getVersion() {
return com.viaversion.viaversion.api.Via.getAPI().getVersion();
}
@Override
public void sendRawPacket(T player, ByteBuf packet) {
com.viaversion.viaversion.api.Via.getAPI().sendRawPacket(player, packet);
}
@Override
public void sendRawPacket(UUID uuid, ByteBuf packet) {
com.viaversion.viaversion.api.Via.getAPI().sendRawPacket(uuid, packet);
}
@Override
public BossBar createBossBar(String title, BossColor color, BossStyle style) {
return new BossBar(com.viaversion.viaversion.api.Via.getAPI().legacyAPI().createLegacyBossBar(title,
com.viaversion.viaversion.api.legacy.bossbar.BossColor.values()[color.ordinal()],
com.viaversion.viaversion.api.legacy.bossbar.BossStyle.values()[style.ordinal()]));
}
@Override
public BossBar createBossBar(String title, float health, BossColor color, BossStyle style) {
return new BossBar(com.viaversion.viaversion.api.Via.getAPI().legacyAPI().createLegacyBossBar(title, health,
com.viaversion.viaversion.api.legacy.bossbar.BossColor.values()[color.ordinal()],
com.viaversion.viaversion.api.legacy.bossbar.BossStyle.values()[style.ordinal()]));
}
@Override
public SortedSet<Integer> getSupportedVersions() {
return com.viaversion.viaversion.api.Via.getAPI().getSupportedVersions();
}
@Override
public SortedSet<Integer> getFullSupportedVersions() {
return com.viaversion.viaversion.api.Via.getAPI().getFullSupportedVersions();
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api;
import com.viaversion.viaversion.api.Via;
import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion.api.boss.BossBar;
import us.myles.ViaVersion.api.boss.BossColor;
import us.myles.ViaVersion.api.boss.BossStyle;
import java.util.SortedSet;
import java.util.UUID;
/**
* @deprecated may be removed at some point, use {@link Via#getAPI()}
*/
@Deprecated
public interface ViaAPI<T> {
int getPlayerVersion(T player);
int getPlayerVersion(UUID uuid);
default boolean isPorted(UUID playerUUID) {
return isInjected(playerUUID);
}
boolean isInjected(UUID playerUUID);
String getVersion();
void sendRawPacket(T player, ByteBuf packet);
void sendRawPacket(UUID uuid, ByteBuf packet);
BossBar createBossBar(String title, BossColor color, BossStyle style);
BossBar createBossBar(String title, float health, BossColor color, BossStyle style);
SortedSet<Integer> getSupportedVersions();
SortedSet<Integer> getFullSupportedVersions();
}
@@ -0,0 +1,133 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api.boss;
import java.util.Set;
import java.util.UUID;
@Deprecated
public class BossBar<T> {
private final com.viaversion.viaversion.api.legacy.bossbar.BossBar bossBar;
public BossBar(com.viaversion.viaversion.api.legacy.bossbar.BossBar bossBar) {
this.bossBar = bossBar;
}
public String getTitle() {
return bossBar.getTitle();
}
public BossBar setTitle(String title) {
bossBar.setTitle(title);
return this;
}
public float getHealth() {
return bossBar.getHealth();
}
public BossBar setHealth(float health) {
bossBar.setHealth(health);
return this;
}
public BossColor getColor() {
return BossColor.values()[bossBar.getColor().ordinal()];
}
public BossBar setColor(BossColor color) {
bossBar.setColor(com.viaversion.viaversion.api.legacy.bossbar.BossColor.values()[color.ordinal()]);
return this;
}
public BossStyle getStyle() {
return BossStyle.values()[bossBar.getStyle().ordinal()];
}
public BossBar setStyle(BossStyle style) {
bossBar.setStyle(com.viaversion.viaversion.api.legacy.bossbar.BossStyle.values()[style.ordinal()]);
return this;
}
@Deprecated
public BossBar addPlayer(T player) {
return this;
}
public BossBar addPlayer(UUID player) {
bossBar.addPlayer(player);
return this;
}
@Deprecated
public BossBar addPlayers(T... players) {
return this;
}
@Deprecated
public BossBar removePlayer(T player) {
return this;
}
public BossBar removePlayer(UUID uuid) {
bossBar.removePlayer(uuid);
return this;
}
public BossBar addFlag(BossFlag flag) {
bossBar.addFlag(com.viaversion.viaversion.api.legacy.bossbar.BossFlag.values()[flag.ordinal()]);
return this;
}
public BossBar removeFlag(BossFlag flag) {
bossBar.removeFlag(com.viaversion.viaversion.api.legacy.bossbar.BossFlag.values()[flag.ordinal()]);
return this;
}
public boolean hasFlag(BossFlag flag) {
return bossBar.hasFlag(com.viaversion.viaversion.api.legacy.bossbar.BossFlag.values()[flag.ordinal()]);
}
public Set<UUID> getPlayers() {
return bossBar.getPlayers();
}
public BossBar show() {
bossBar.show();
return this;
}
public BossBar hide() {
bossBar.hide();
return this;
}
public boolean isVisible() {
return bossBar.isVisible();
}
public UUID getId() {
return bossBar.getId();
}
}
@@ -0,0 +1,45 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api.boss;
@Deprecated
public enum BossColor {
PINK(0),
BLUE(1),
RED(2),
GREEN(3),
YELLOW(4),
PURPLE(5),
WHITE(6);
private final int id;
BossColor(int id) {
this.id = id;
}
public int getId() {
return id;
}
}
@@ -0,0 +1,40 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api.boss;
@Deprecated
public enum BossFlag {
DARKEN_SKY(1),
PLAY_BOSS_MUSIC(2);
private final int id;
BossFlag(int id) {
this.id = id;
}
public int getId() {
return id;
}
}
@@ -0,0 +1,43 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api.boss;
@Deprecated
public enum BossStyle {
SOLID(0),
SEGMENTED_6(1),
SEGMENTED_10(2),
SEGMENTED_12(3),
SEGMENTED_20(4);
private final int id;
BossStyle(int id) {
this.id = id;
}
public int getId() {
return id;
}
}
@@ -0,0 +1,33 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api.protocol;
/**
* @deprecated may be removed at some point, use {@link com.viaversion.viaversion.api.protocol.ProtocolManager}
*/
@Deprecated
public class ProtocolRegistry {
@Deprecated
public static int SERVER_PROTOCOL = -1;
}
@@ -1,22 +1,48 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api.protocol;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.version.VersionRange;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
/**
* @deprecated will no longer be updated and may be removed at some point, use {@link com.viaversion.viaversion.api.protocol.version.ProtocolVersion}
*/
@Deprecated
public class ProtocolVersion {
private static final Int2ObjectMap<ProtocolVersion> versions = new Int2ObjectOpenHashMap<>();
private static final List<ProtocolVersion> versionList = new ArrayList<>();
// Before the Netty rewrite
public static final ProtocolVersion v1_4_6 = register(51, "1.4.6/7", new VersionRange("1.4", 6, 7));
public static final ProtocolVersion v1_5_1 = register(60, "1.5.1");
public static final ProtocolVersion v1_5_2 = register(61, "1.5.2");
@@ -24,7 +50,6 @@ public class ProtocolVersion {
public static final ProtocolVersion v_1_6_2 = register(74, "1.6.2");
public static final ProtocolVersion v_1_6_3 = register(77, "1.6.3");
public static final ProtocolVersion v_1_6_4 = register(78, "1.6.4");
// After the Netty rewrite
public static final ProtocolVersion v1_7_1 = register(4, "1.7-1.7.5", new VersionRange("1.7", 0, 5));
public static final ProtocolVersion v1_7_6 = register(5, "1.7.6-1.7.10", new VersionRange("1.7", 6, 10));
public static final ProtocolVersion v1_8 = register(47, "1.8.x");
@@ -53,7 +78,7 @@ public class ProtocolVersion {
public static final ProtocolVersion v1_16_1 = register(736, "1.16.1");
public static final ProtocolVersion v1_16_2 = register(751, "1.16.2");
public static final ProtocolVersion v1_16_3 = register(753, "1.16.3");
public static final ProtocolVersion v1_16_4 = register(754, "1.16.4");
public static final ProtocolVersion v1_16_4 = register(754, "1.16.4/5", new VersionRange("1.16", 4, 5));
public static final ProtocolVersion unknown = register(-1, "UNKNOWN");
public static ProtocolVersion register(int version, String name) {
@@ -82,8 +107,7 @@ public class ProtocolVersion {
return versions.containsKey(id);
}
@NotNull
public static ProtocolVersion getProtocol(int id) {
public static @NonNull ProtocolVersion getProtocol(int id) {
ProtocolVersion protocolVersion = versions.get(id);
if (protocolVersion != null) {
return protocolVersion;
@@ -100,8 +124,7 @@ public class ProtocolVersion {
return Collections.unmodifiableList(new ArrayList<>(versions.values()));
}
@Nullable
public static ProtocolVersion getClosest(String protocol) {
public static @Nullable ProtocolVersion getClosest(String protocol) {
for (ProtocolVersion version : versions.values()) {
String name = version.getName();
if (name.equals(protocol)) {
@@ -141,7 +164,7 @@ public class ProtocolVersion {
Preconditions.checkArgument(!versionWildcard || versionRange == null, "A version cannot be a wildcard and a range at the same time!");
if (versionRange != null) {
includedVersions = new HashSet<>();
includedVersions = new LinkedHashSet<>();
for (int i = versionRange.getRangeFrom(); i <= versionRange.getRangeTo(); i++) {
if (i == 0) {
includedVersions.add(versionRange.getBaseVersion()); // Keep both the base version and with ".0" appended
@@ -154,63 +177,36 @@ public class ProtocolVersion {
}
}
/**
* @return release version
*/
public int getVersion() {
return version;
}
/**
* @return snapshot protocol version without the snapshot indicator bit
* @throws IllegalArgumentException if the version if not a snapshot version
* @see #isSnapshot()
*/
public int getSnapshotVersion() {
Preconditions.checkArgument(isSnapshot());
return snapshotVersion;
}
/**
* @return snapshot protocol version with the snapshot indicator bit
* @throws IllegalArgumentException if the version if not a snapshot version
* @see #isSnapshot()
*/
public int getFullSnapshotVersion() {
Preconditions.checkArgument(isSnapshot());
return (1 << 30) | snapshotVersion; // Bit indicating snapshot versions
}
/**
* @return release version if release, snapshot version (with the snapshot indicator bit) if snapshot
*/
public int getOriginalVersion() {
return snapshotVersion == -1 ? version : ((1 << 30) | snapshotVersion);
}
/**
* @return true if the protocol includes a range of versions (but not an entire major version range), for example 1.7-1.7.5
* @see #getIncludedVersions()
*/
public boolean isKnown() {
return version != -1;
}
public boolean isRange() {
return includedVersions.size() != 1;
}
/**
* Returns an immutable set of all included versions if the protocol is a version range.
* If the protocol only includes a single Minecraft version or the entire major version as a wildcard ({@link #isVersionWildcard()}),
* the set will only contain the string given in {@link #getName()}.
*
* @return immutable set of all included versions if the protocol is a version range
* @see #isRange()
*/
public Set<String> getIncludedVersions() {
return Collections.unmodifiableSet(includedVersions);
}
/**
* @return true if the protocol includes an entire major version range (for example 1.8.x)
*/
public boolean isVersionWildcard() {
return versionWildcard;
}
@@ -223,11 +219,6 @@ public class ProtocolVersion {
return snapshotVersion != -1;
}
/**
* @return release version
* @deprecated ambiguous, see {@link #getOriginalVersion()}, {@link #getVersion()}, and {@link #getSnapshotVersion()}
*/
@Deprecated
public int getId() {
return version;
}
@@ -248,6 +239,6 @@ public class ProtocolVersion {
@Override
public String toString() {
return String.format("%s(%d)", this.name, this.version);
return String.format("%s (%d)", this.name, this.version);
}
}
+27
View File
@@ -0,0 +1,27 @@
plugins {
id("net.kyori.blossom")
id("via.shadow-conventions")
}
blossom {
replaceToken("\$VERSION", project.version)
replaceToken("\$IMPL_VERSION", "git-ViaVersion-${project.version}:${rootProject.latestCommitHash()}")
}
dependencies {
api(projects.adventure) {
targetConfiguration = "shadow"
}
api(libs.fastutil)
api(libs.openNBT)
api(libs.gson)
compileOnlyApi(libs.snakeYaml)
compileOnlyApi(libs.netty)
compileOnlyApi(libs.guava)
compileOnlyApi(libs.checkerQual)
}
java {
withJavadocJar()
}
@@ -0,0 +1,81 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
import com.viaversion.viaversion.api.platform.ViaPlatform;
public final class Via {
private static ViaManager manager;
/**
* Returns the API associated with the current platform.
*
* @return API instance
* @throws IllegalArgumentException if the platform has not loaded yet
*/
public static ViaAPI getAPI() {
return manager().getPlatform().getApi();
}
/**
* Returns the ViaManager with methods beyond the simple API {@link ViaAPI} provides.
*
* @return manager to interact with various Via parts
* @throws IllegalArgumentException if the platform has not loaded yet
*/
public static ViaManager getManager() {
return manager();
}
/**
* Returns the config associated with the current platform.
*
* @return config instance
* @throws IllegalArgumentException if the platform has not loaded yet
*/
public static ViaVersionConfig getConfig() {
return manager().getPlatform().getConf();
}
public static ViaPlatform getPlatform() {
return manager().getPlatform();
}
/**
* Register the ViaManager associated with the platform.
*
* @param viaManager The ViaManager
* @throws IllegalArgumentException if the manager has already been set
*/
public static void init(ViaManager viaManager) {
Preconditions.checkArgument(manager == null, "ViaManager is already set");
Via.manager = viaManager;
}
private static ViaManager manager() {
Preconditions.checkArgument(manager != null, "ViaVersion has not loaded the platform yet");
return manager;
}
}
@@ -0,0 +1,148 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api;
import com.viaversion.viaversion.api.connection.ConnectionManager;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.legacy.LegacyViaAPI;
import com.viaversion.viaversion.api.platform.ViaPlatform;
import com.viaversion.viaversion.api.protocol.ProtocolManager;
import com.viaversion.viaversion.api.protocol.version.ServerProtocolVersion;
import io.netty.buffer.ByteBuf;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.SortedSet;
import java.util.UUID;
/**
* General api point. For more specialized api methods, see {@link Via#getManager()}.
*
* @param <T> player type for the specific platform
* @see ViaManager
* @see ProtocolManager
* @see ConnectionManager
* @see ViaPlatform
*/
public interface ViaAPI<T> {
/**
* Returns the API version incremented with meaningful API changes.
* This includes breaking changes to existing API and larger additions.
*
* @return API version incremented with meaningful API changes
*/
default int apiVersion() {
return 3;
}
/**
* Returns the server's protocol version info.
*
* @return the server's protocol version info
*/
ServerProtocolVersion getServerVersion();
/**
* Returns the protocol version of a player.
* This will also retrieve the version from ProtocolSupport if it's being used.
*
* @param player the platform's player object, e.g. Bukkit this is Player
* @return protocol version, for example (47=1.8-1.8.8, 107=1.9, 108=1.9.1), or -1 if no longer connected
*/
int getPlayerVersion(T player);
/**
* Returns the protocol version of a player.
*
* @param uuid UUID of a player
* @return protocol version, for example (47=1.8-1.8.8, 107=1.9, 108=1.9.1), or -1 if not connected
*/
int getPlayerVersion(UUID uuid);
/**
* Returns whether Via injected into this player connection.
*
* @param uuid uuid of the player
* @return whether Via has a cached a UserConnection for this player
*/
boolean isInjected(UUID uuid);
/**
* Returns the Via injected UserConnection if present.
*
* @param uuid uuid of the player
* @return user connection if present
*/
@Nullable UserConnection getConnection(UUID uuid);
/**
* Returns the version of the plugin.
*
* @return plugin version
*/
String getVersion();
/**
* Sends a raw packet to the player.
*
* @param player the platform's player object, e.g. for Bukkit this is Player
* @param packet the packet; you need a VarInt Id, then the packet contents
* @throws IllegalArgumentException if the player is not injected by Via
*/
void sendRawPacket(T player, ByteBuf packet);
/**
* Sends a raw packet to the player.
*
* @param uuid the uuid from the player to send packet
* @param packet the packet; you need a VarInt Id, then the packet contents
* @throws IllegalArgumentException if the player is not injected by Via
*/
void sendRawPacket(UUID uuid, ByteBuf packet);
/**
* Returns the supported protocol versions.
* This method removes any blocked protocol versions.
*
* @return a list of protocol versions
* @see #getFullSupportedVersions() for a full list
*/
SortedSet<Integer> getSupportedVersions();
/**
* Returns the supported protocol versions, including blocked protocols.
*
* @return a list of protocol versions
*/
SortedSet<Integer> getFullSupportedVersions();
/**
* Returns legacy api only applicable on/to legacy versions.
* <p>
* These methods are safe to use and are unlikely to be removed,
* but it is important to be aware of their limited use.
*
* @return legacy api only applicable on/to legacy versions
*/
LegacyViaAPI<T> legacyAPI();
}
@@ -0,0 +1,114 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api;
import com.viaversion.viaversion.api.command.ViaVersionCommand;
import com.viaversion.viaversion.api.connection.ConnectionManager;
import com.viaversion.viaversion.api.platform.ViaInjector;
import com.viaversion.viaversion.api.platform.ViaPlatform;
import com.viaversion.viaversion.api.platform.ViaPlatformLoader;
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
import com.viaversion.viaversion.api.protocol.ProtocolManager;
import java.util.Set;
public interface ViaManager {
/**
* Returns the protocol manager for registering/getting protocols and their mapping data loading.
*
* @return protocol manager
*/
ProtocolManager getProtocolManager();
/**
* Returns platform for handling platform specific configuration, tasks, and plugin data.
*
* @return platform
*/
ViaPlatform<?> getPlatform();
/**
* Returns the userconnection manager for handling clients connected to the server.
*
* @return userconnection manager
*/
ConnectionManager getConnectionManager();
/**
* Returns the manager for Via providers.
*
* @return provider manager
*/
ViaProviders getProviders();
/**
* Returns the injector for injecting netty handlers and initially getting the server protocol version.
*
* @return injector
*/
ViaInjector getInjector();
/**
* Returns the command handler for managing ViaVersion subcommands.
*
* @return command handler
*/
ViaVersionCommand getCommandHandler();
/**
* Returns the platform loader responsible for registering listeners, providers and such.
*
* @return platform loader
*/
ViaPlatformLoader getLoader();
/**
* If debug is enabled, packets and other otherwise suppressed warnings will be logged.
*
* @return true if enabled
*/
boolean isDebug();
/**
* Sets the debug mode. If enabled, packets and other otherwise suppressed warnings will be logged.
*
* @param debug whether debug should be enabled
*/
void setDebug(boolean debug);
/**
* Returns a mutable set of self-added subplatform version strings.
* This set is expanded by the subplatform itself (e.g. ViaBackwards), and may not contain all running ones.
*
* @return mutable set of subplatform versions
*/
Set<String> getSubPlatforms();
/**
* Adds a runnable to be executed when ViaVersion has finished its init before the full server load.
*
* @param runnable runnable to be executed
*/
void addEnableListener(Runnable runnable);
}
@@ -0,0 +1,56 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.command;
import java.util.UUID;
public interface ViaCommandSender {
/**
* Check if the sender has a permission.
*
* @param permission Permission string eg. viaversion.admin
* @return True if the sender has the permission
*/
boolean hasPermission(String permission);
/**
* Send a message to the sender
*
* @param msg The message to send
*/
void sendMessage(String msg);
/**
* Get the senders UUID.
*
* @return The senders UUID
*/
UUID getUUID();
/**
* Get the senders name.
*
* @return The senders name
*/
String getName();
}
@@ -0,0 +1,105 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.command;
import com.viaversion.viaversion.util.ChatColorUtil;
import java.util.Collections;
import java.util.List;
public abstract class ViaSubCommand {
/**
* Subcommand name
*
* @return The commands name
*/
public abstract String name();
/**
* subcommand description, this'll show in /viaversion list
*
* @return The commands description
*/
public abstract String description();
/**
* Usage example:
* "playerversion [name]"
*
* @return The commands usage
*/
public String usage() {
return name();
}
/**
* Permission, null for everyone
*
* @return The permission required to use the commands
*/
public String permission() {
return "viaversion.admin";
}
/**
* Gets triggered on execution
*
* @param sender Command sender
* @param args Arguments
* @return commands executed succesfully if false, show usage
*/
public abstract boolean execute(ViaCommandSender sender, String[] args);
/**
* Yay, possibility to implement tab-completion
*
* @param sender Command sender
* @param args args
* @return tab complete possibilities
*/
public List<String> onTabComplete(ViaCommandSender sender, String[] args) {
return Collections.emptyList();
}
/**
* Replaces color codes in a string.
*
* @param s string to replace
* @return output String
*/
public static String color(String s) {
return ChatColorUtil.translateAlternateColorCodes(s);
}
/**
* Send a color coded string with replacements to a user.
*
* @param sender target to send the message to
* @param message message
* @param args objects to replace
*/
public static void sendMessage(ViaCommandSender sender, String message, Object... args) {
sender.sendMessage(color(args == null ? message : String.format(message, args)));
}
}
@@ -0,0 +1,73 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.command;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.List;
public interface ViaVersionCommand {
/**
* Register your own subcommand inside ViaVersion
*
* @param command Your own SubCommand instance to handle it.
* @throws Exception throws an exception when the subcommand already exists or if it's not valid, example: spacee
*/
void registerSubCommand(ViaSubCommand command) throws Exception;
/**
* Check if a subcommand is registered.
*
* @param name Subcommand name
* @return true if it exists
*/
boolean hasSubCommand(String name);
/**
* Get subcommand instance by name
*
* @param name subcommand name
* @return ViaSubCommand instance
*/
@Nullable ViaSubCommand getSubCommand(String name);
/**
* Executed when the Command sender executes the commands
*
* @param sender Sender object
* @param args arguments provided
* @return was successful
*/
boolean onCommand(ViaCommandSender sender, String[] args);
/**
* Executed when the Command sender tab-completes
*
* @param sender Sender object
* @param args arguments provided
* @return was successful
*/
List<String> onTabComplete(ViaCommandSender sender, String[] args);
void showHelp(ViaCommandSender sender);
}
@@ -0,0 +1,53 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.configuration;
import java.util.Map;
public interface ConfigurationProvider {
/**
* Sets the specified path to the given value.
*
* @param path Path of the object to set.
* @param value New value to set the path to
*/
void set(String path, Object value);
/**
* Saves the config
*/
void saveConfig();
/**
* Reloads the config
*/
void reloadConfig();
/**
* Get all the configuration values
*
* @return Map with key-values
*/
Map<String, Object> getValues();
}
@@ -1,4 +1,26 @@
package us.myles.ViaVersion.api;
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.configuration;
import it.unimi.dsi.fastutil.ints.IntSet;
@@ -54,6 +76,25 @@ public interface ViaVersionConfig {
*/
boolean isShieldBlocking();
/**
* Whether the player can block with the shield without a delay.
* <p>
* This option requires {@link #isShowShieldWhenSwordInHand()} to be disabled
*
* @return {@code true} if non delayed shield blocking is enabled.
*/
boolean isNoDelayShieldBlocking();
/**
* Puts the shield into the second hand when holding a sword.
* The shield will disappear when switching to another item.
* <p>
* This option requires {@link #isShieldBlocking()} to be enabled
*
* @return {@code true} if the shield should appear when holding a sword
*/
boolean isShowShieldWhenSwordInHand();
/**
* Get if armor stand positions are fixed so holograms show up at the correct height in 1.9 &amp; 1.10
*
@@ -366,4 +407,11 @@ public interface ViaVersionConfig {
* @return true if enabled
*/
boolean isIgnoreLong1_16ChannelNames();
/**
* Force 1.17+ client to accept the server resource pack.
*
* @return true if enabled
*/
boolean isForcedUse1_17ResourcePack();
}
@@ -0,0 +1,104 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.connection;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
/**
* Handles injected UserConnections
*/
public interface ConnectionManager {
/**
* Returns if Via injected into this player connection.
*
* @param playerId player uuid
* @return true if the player is handled by Via
*/
boolean isClientConnected(UUID playerId);
/**
* Frontend connections will have the UUID stored. Override this if your platform isn't always frontend.
* UUIDs can't be duplicate between frontend connections.
*
* @return true if the user is a frontend connection
*/
default boolean isFrontEnd(UserConnection connection) {
return !connection.isClientSide();
}
/**
* Returns the frontend UserConnection from the player connected to this proxy server
* Returns null when there isn't a server or connection was not found
* When ViaVersion is reloaded, this method may not return some players.
* May not return ProtocolSupport players.
* <p>
* Note that connections are removed as soon as their channel is closed,
* so avoid using this method during player quits for example.
*
* @return frontend UserConnection of the player connected to this proxy server
*/
@Nullable UserConnection getConnectedClient(UUID clientIdentifier);
/**
* Returns the UUID from the frontend connection to this proxy server
* Returns null when there isn't a server or this connection isn't frontend or it doesn't have an id
* When ViaVersion is reloaded, this method may not return some players.
* May not return ProtocolSupport players.
* <p>
* Note that connections are removed as soon as their channel is closed,
* so avoid using this method during player quits for example.
*
* @return UUID of the frontend connection to this proxy server
*/
@Nullable UUID getConnectedClientId(UserConnection connection);
/**
* Returns all UserConnections which are registered
* May contain duplicated UUIDs on multiple ProtocolInfo.
* May contain frontend, backend and/or client-sided connections.
* When ViaVersion is reloaded, this method may not return some players.
* May not contain ProtocolSupport players.
*
* @return connected UserConnections
*/
Set<UserConnection> getConnections();
/**
* Returns a map containing the UUIDs and frontend UserConnections from players connected to this proxy server
* Returns empty list when there isn't a server
* When ViaVersion is reloaded, this method may not return some players.
* May not contain ProtocolSupport players.
*
* @return map containing the UUIDs and frontend UserConnections from players connected to this proxy server
*/
Map<UUID, UserConnection> getConnectedClients();
void onLoginSuccess(UserConnection connection);
void onDisconnect(UserConnection connection);
}
@@ -0,0 +1,97 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.connection;
import com.viaversion.viaversion.api.protocol.ProtocolPipeline;
import com.viaversion.viaversion.api.protocol.packet.State;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.UUID;
public interface ProtocolInfo {
/**
* Returns the protocol state the user is currently in.
*
* @return protocol state
*/
State getState();
void setState(State state);
/**
* Returns the user's protocol version, or -1 if not set.
* This is set during the {@link State#HANDSHAKE} state.
*
* @return protocol version, or -1 if not set
*/
int getProtocolVersion();
void setProtocolVersion(int protocolVersion);
/**
* Returns the server protocol version the user is connected to, or -1 if not set.
* This is set during the {@link State#HANDSHAKE} state.
*
* @return server protocol version, or -1 if not set
*/
int getServerProtocolVersion();
void setServerProtocolVersion(int serverProtocolVersion);
/**
* Returns the username associated with this connection.
* This is set once the connection enters the {@link State#PLAY} state.
*
* @return username, set when entering the {@link State#PLAY} state
*/
@Nullable String getUsername();
void setUsername(String username);
/**
* Returns the uuid associated with this connection.
* This is set once the connection enters the {@link State#PLAY} state.
*
* @return uuid, set when entering the {@link State#PLAY} state
*/
@Nullable UUID getUuid();
void setUuid(UUID uuid);
/**
* Returns the user's pipeline.
*
* @return protocol pipeline
*/
ProtocolPipeline getPipeline();
void setPipeline(ProtocolPipeline pipeline);
/**
* Returns the user connection this info represents.
*
* @return user connection
*/
UserConnection getUser();
}
@@ -0,0 +1,32 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.connection;
/**
* Dummy interface used to explicitly identify objects storable in user connections.
*
* @see UserConnection#get(Class)
* @see UserConnection#put(StorableObject)
*/
public interface StorableObject {
}
@@ -0,0 +1,35 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.connection;
public abstract class StoredObject implements StorableObject {
private final UserConnection user;
protected StoredObject(UserConnection user) {
this.user = user;
}
public UserConnection getUser() {
return user;
}
}
@@ -0,0 +1,307 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.connection;
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.protocol.packet.PacketTracker;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.exception.CancelException;
import com.viaversion.viaversion.exception.InformativeException;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Collection;
import java.util.Map;
import java.util.UUID;
import java.util.function.Function;
public interface UserConnection {
/**
* Get an object from the storage.
*
* @param objectClass The class of the object to get
* @param <T> The type of the class you want to get.
* @return The requested object
*/
@Nullable <T extends StorableObject> T get(Class<T> objectClass);
/**
* Check if the storage has an object.
*
* @param objectClass The object class to check
* @return True if the object is in the storage
*/
boolean has(Class<? extends StorableObject> objectClass);
/**
* Put an object into the stored objects based on class.
*
* @param object The object to store.
*/
void put(StorableObject object);
/**
* Returns a collection of entity trackers currently registered.
*
* @return collection of entity trackers currently registered
*/
Collection<EntityTracker> getEntityTrackers();
/**
* Returns the entity tracker by the given protocol class if present.
*
* @param protocolClass protocol class
* @param <T> entity tracker type
* @return entity tracker if present
*/
@Nullable <T extends EntityTracker> T getEntityTracker(Class<? extends Protocol> protocolClass);
/**
* Adds an entity tracker to the user connection.
*
* @param protocolClass protocol class
* @param tracker entity tracker
*/
void addEntityTracker(Class<? extends Protocol> protocolClass, EntityTracker tracker);
/**
* Clear all the stored objects.
* Used for bungee when switching servers.
*/
void clearStoredObjects();
/**
* Sends a raw packet to the connection on the current thread.
*
* @param packet raw packet to send
*/
void sendRawPacket(ByteBuf packet);
/**
* Send a raw packet to the player, submitted to the netty event loop.
*
* @param packet raw packet to send
*/
void scheduleSendRawPacket(ByteBuf packet);
/**
* Send a raw packet to the player with returning the future.
*
* @param packet The raw packet to send
* @return ChannelFuture of the packet being sent
*/
ChannelFuture sendRawPacketFuture(ByteBuf packet);
/**
* Returns the user's packet tracker used for the inbuilt packet-limiter.
*
* @return packet tracker
*/
PacketTracker getPacketTracker();
/**
* Disconnect a connection.
*
* @param reason The reason to use, not used if player is not active.
*/
void disconnect(String reason);
/**
* Sends a raw packet to the server on the current thread.
*
* @param packet raw packet to be sent
*/
void sendRawPacketToServer(ByteBuf packet);
/**
* Sends a raw packet to the server, submitted to the netty event loop.
*
* @param packet raw packet to be sent
*/
void scheduleSendRawPacketToServer(ByteBuf packet);
/**
* Monitors serverbound packets and returns whether a packet can/should be processed.
*
* @return false if this packet should be cancelled
*/
boolean checkServerboundPacket();
/**
* Monitors clientbound packets and returns whether a packet can/should be processed.
*
* @return false if this packet should be cancelled
*/
boolean checkClientboundPacket();
/**
* @see #checkClientboundPacket()
* @see #checkServerboundPacket()
*/
default boolean checkIncomingPacket() {
return isClientSide() ? checkClientboundPacket() : checkServerboundPacket();
}
/**
* @see #checkClientboundPacket()
* @see #checkServerboundPacket()
*/
default boolean checkOutgoingPacket() {
return isClientSide() ? checkServerboundPacket() : checkClientboundPacket();
}
/**
* Checks if packets needs transforming.
*
* @return whether packets should be passed through
*/
boolean shouldTransformPacket();
/**
* Transforms the clientbound packet contained in ByteBuf.
*
* @param buf ByteBuf with packet id and packet contents
* @param cancelSupplier function called with original CancelException for generating the Exception when the packet is cancelled
* @throws CancelException if the packet should be cancelled
* @throws InformativeException if packet transforming failed
* @throws Exception if any other processing outside of transforming fails
*/
void transformClientbound(ByteBuf buf, Function<Throwable, Exception> cancelSupplier) throws Exception;
/**
* Transforms the serverbound packet contained in ByteBuf.
*
* @param buf ByteBuf with packet id and packet contents
* @param cancelSupplier Function called with original CancelException for generating the Exception used when
* packet is cancelled
* @throws CancelException if the packet should be cancelled
* @throws InformativeException if packet transforming failed
* @throws Exception if any other processing outside of transforming fails
*/
void transformServerbound(ByteBuf buf, Function<Throwable, Exception> cancelSupplier) throws Exception;
/**
* Transforms the packet depending on whether the connection is clientside or not.
*
* @see #transformClientbound(ByteBuf, Function)
* @see #transformServerbound(ByteBuf, Function)
*/
default void transformOutgoing(ByteBuf buf, Function<Throwable, Exception> cancelSupplier) throws Exception {
if (isClientSide()) {
transformServerbound(buf, cancelSupplier);
} else {
transformClientbound(buf, cancelSupplier);
}
}
/**
* Transforms the packet depending on whether the connection is clientside or not.
*
* @see #transformClientbound(ByteBuf, Function)
* @see #transformServerbound(ByteBuf, Function)
*/
default void transformIncoming(ByteBuf buf, Function<Throwable, Exception> cancelSupplier) throws Exception {
if (isClientSide()) {
transformClientbound(buf, cancelSupplier);
} else {
transformServerbound(buf, cancelSupplier);
}
}
/**
* Returns the internal id incremented for each new connection.
*
* @return internal id
*/
long getId();
/**
* Returns the netty channel if present.
*
* @return netty channel if present
*/
@Nullable Channel getChannel();
/**
* Returns info containing the current protocol state and userdata.
*
* @return info containing the current protocol state and userdata
*/
ProtocolInfo getProtocolInfo();
/**
* Returns a map of stored objects.
*
* @return map of stored objects
* @see #has(Class)
* @see #get(Class)
* @see #put(StorableObject)
*/
Map<Class<?>, StorableObject> getStoredObjects();
/**
* Returns whether the connection has protocols other than the base protocol applied.
*
* @return whether the connection is active
*/
boolean isActive();
void setActive(boolean active);
/**
* Returns whether the connection is pending a disconnect, initiated through {@link #disconnect(String)}.
*
* @return whether the connection is pending a disconnect
*/
boolean isPendingDisconnect();
void setPendingDisconnect(boolean pendingDisconnect);
/**
* Returns whether this is a client-side connection.
* This is a mod integrated into the client itself, or for example a backend Velocity connection.
*
* @return whether this is a client-side connection
*/
boolean isClientSide();
/**
* Returns whether {@link ViaVersionConfig#getBlockedProtocols()} should be checked for this connection.
*
* @return whether blocked protocols should be applied
*/
boolean shouldApplyBlockProtocol();
/**
* Returns a newly generated uuid that will let a packet be passed through without
* transformig its contents if used together with {@link PacketWrapper#PASSTHROUGH_ID}.
*
* @return generated passthrough token
*/
UUID generatePassthroughToken();
}
@@ -0,0 +1,122 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Arrays;
public class IntArrayMappings implements Mappings {
protected final int[] oldToNew;
public IntArrayMappings(int[] oldToNew) {
this.oldToNew = oldToNew;
}
/**
* Maps old identifiers to the new ones.
* If an old value cannot be found in the new mappings, the diffmapping will be checked for the given entry.
*
* @param size set size of the underlying short array
* @param oldMapping mappings to map from
* @param newMapping mappings to map to
* @param diffMapping extra mappings that will be used/scanned when an entry cannot be found
*/
public IntArrayMappings(int size, JsonObject oldMapping, JsonObject newMapping, @Nullable JsonObject diffMapping) {
oldToNew = new int[size];
Arrays.fill(oldToNew, -1);
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping);
}
public IntArrayMappings(JsonObject oldMapping, JsonObject newMapping, @Nullable JsonObject diffMapping) {
this(oldMapping.entrySet().size(), oldMapping, newMapping, diffMapping);
}
/**
* Maps old identifiers to the new ones.
*
* @param size set size of the underlying short array
* @param oldMapping mappings to map from
* @param newMapping mappings to map to
*/
public IntArrayMappings(int size, JsonObject oldMapping, JsonObject newMapping) {
oldToNew = new int[size];
Arrays.fill(oldToNew, -1);
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping);
}
public IntArrayMappings(JsonObject oldMapping, JsonObject newMapping) {
this(oldMapping.entrySet().size(), oldMapping, newMapping);
}
/**
* Maps old identifiers to the new ones.
*
* @param size set size of the underlying short array
* @param oldMapping mappings to map from
* @param newMapping mappings to map to
* @param diffMapping extra mappings that will be used/scanned when an entry cannot be found
* @param warnOnMissing should "No key for x" be printed if there is no matching identifier
*/
public IntArrayMappings(int size, JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping, boolean warnOnMissing) {
oldToNew = new int[size];
Arrays.fill(oldToNew, -1);
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping, warnOnMissing);
}
public IntArrayMappings(int size, JsonArray oldMapping, JsonArray newMapping, boolean warnOnMissing) {
this(size, oldMapping, newMapping, null, warnOnMissing);
}
public IntArrayMappings(JsonArray oldMapping, JsonArray newMapping, boolean warnOnMissing) {
this(oldMapping.size(), oldMapping, newMapping, warnOnMissing);
}
public IntArrayMappings(int size, JsonArray oldMapping, JsonArray newMapping) {
this(size, oldMapping, newMapping, true);
}
public IntArrayMappings(JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping) {
this(oldMapping.size(), oldMapping, newMapping, diffMapping, true);
}
public IntArrayMappings(JsonArray oldMapping, JsonArray newMapping) {
this(oldMapping.size(), oldMapping, newMapping, true);
}
@Override
public int getNewId(int id) {
return id >= 0 && id < oldToNew.length ? oldToNew[id] : -1;
}
@Override
public void setNewId(int id, int newId) {
oldToNew[id] = newId;
}
public int[] getOldToNew() {
return oldToNew;
}
}
@@ -0,0 +1,103 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data;
import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.TagData;
import com.viaversion.viaversion.util.Int2IntBiMap;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.List;
public interface MappingData {
/**
* Loads the mapping data.
*/
void load();
/**
* Returns the mapped block state id, or -1 if unmapped.
*
* @param id unmapped block state id
* @return mapped block state id, or -1 if unmapped
* @throws NullPointerException if this mappingdata does not hold block state mappings
*/
int getNewBlockStateId(int id);
/**
* Returns the mapped block id, or -1 if unmapped.
*
* @param id unmapped block id
* @return mapped block id, or -1 if unmapped
* @throws NullPointerException if this mappingdata does not hold block mappings
*/
int getNewBlockId(int id);
/**
* Returns the mapped item id, or -1 if unmapped.
*
* @param id unmapped item id
* @return mapped item id, or -1 if unmapped
* @throws NullPointerException if this mappingdata does not hold item mappings
*/
int getNewItemId(int id);
/**
* Returns the backwards mapped item id, or -1 if unmapped.
*
* @param id mapped item id
* @return backwards mapped item id, or -1 if unmapped
* @throws NullPointerException if this mappingdata does not hold item mappings
*/
int getOldItemId(int id);
/**
* Returns the mapped particle id, or -1 if unmapped.
*
* @param id unmapped particle id
* @return mapped particle id, or -1 if unmapped
* @throws NullPointerException if this mappingdata does not hold particle mappings
*/
int getNewParticleId(int id);
/**
* Returns a list of tags to send if present.
*
* @param type registry tag type
* @return list of tags to send if present, else null
*/
@Nullable List<TagData> getTags(RegistryType type);
@Nullable Int2IntBiMap getItemMappings();
@Nullable ParticleMappings getParticleMappings();
@Nullable Mappings getBlockMappings();
@Nullable Mappings getBlockStateMappings();
@Nullable Mappings getSoundMappings();
@Nullable Mappings getStatisticsMappings();
}
@@ -0,0 +1,234 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.TagData;
import com.viaversion.viaversion.util.Int2IntBiHashMap;
import com.viaversion.viaversion.util.Int2IntBiMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
public class MappingDataBase implements MappingData {
protected final String oldVersion;
protected final String newVersion;
protected final boolean hasDiffFile;
protected Int2IntBiMap itemMappings;
protected ParticleMappings particleMappings;
protected Mappings blockMappings;
protected Mappings blockStateMappings;
protected Mappings soundMappings;
protected Mappings statisticsMappings;
protected Map<RegistryType, List<TagData>> tags;
protected boolean loadItems = true;
public MappingDataBase(String oldVersion, String newVersion) {
this(oldVersion, newVersion, false);
}
public MappingDataBase(String oldVersion, String newVersion, boolean hasDiffFile) {
this.oldVersion = oldVersion;
this.newVersion = newVersion;
this.hasDiffFile = hasDiffFile;
}
@Override
public void load() {
getLogger().info("Loading " + oldVersion + " -> " + newVersion + " mappings...");
JsonObject diffmapping = hasDiffFile ? loadDiffFile() : null;
JsonObject oldMappings = MappingDataLoader.loadData("mapping-" + oldVersion + ".json", true);
JsonObject newMappings = MappingDataLoader.loadData("mapping-" + newVersion + ".json", true);
blockMappings = loadFromObject(oldMappings, newMappings, diffmapping, "blocks");
blockStateMappings = loadFromObject(oldMappings, newMappings, diffmapping, "blockstates");
soundMappings = loadFromArray(oldMappings, newMappings, diffmapping, "sounds");
statisticsMappings = loadFromArray(oldMappings, newMappings, diffmapping, "statistics");
Mappings particles = loadFromArray(oldMappings, newMappings, diffmapping, "particles");
if (particles != null) {
particleMappings = new ParticleMappings(oldMappings.getAsJsonArray("particles"), particles);
}
if (loadItems && newMappings.has("items")) {
itemMappings = new Int2IntBiHashMap();
itemMappings.defaultReturnValue(-1);
MappingDataLoader.mapIdentifiers(itemMappings, oldMappings.getAsJsonObject("items"), newMappings.getAsJsonObject("items"),
diffmapping != null ? diffmapping.getAsJsonObject("items") : null);
}
if (diffmapping != null && diffmapping.has("tags")) {
this.tags = new EnumMap<>(RegistryType.class);
JsonObject tags = diffmapping.getAsJsonObject("tags");
if (tags.has(RegistryType.ITEM.getResourceLocation())) {
loadTags(RegistryType.ITEM, tags, MappingDataLoader.indexedObjectToMap(newMappings.getAsJsonObject("items")));
}
if (tags.has(RegistryType.BLOCK.getResourceLocation())) {
loadTags(RegistryType.BLOCK, tags, MappingDataLoader.indexedObjectToMap(newMappings.getAsJsonObject("blocks")));
}
}
loadExtras(oldMappings, newMappings, diffmapping);
}
private void loadTags(RegistryType type, JsonObject object, Object2IntMap<String> typeMapping) {
JsonObject tags = object.getAsJsonObject(type.getResourceLocation());
List<TagData> tagsList = new ArrayList<>(tags.size());
for (Map.Entry<String, JsonElement> entry : tags.entrySet()) {
JsonArray array = entry.getValue().getAsJsonArray();
int[] entries = new int[array.size()];
int i = 0;
for (JsonElement element : array) {
String stringId = element.getAsString();
if (!typeMapping.containsKey(stringId) && !typeMapping.containsKey(stringId = stringId.replace("minecraft:", ""))) { // aaa
getLogger().warning(type + " Tags contains invalid type identifier " + stringId + " in tag " + entry.getKey());
continue;
}
entries[i++] = typeMapping.getInt(stringId);
}
tagsList.add(new TagData(entry.getKey(), entries));
}
this.tags.put(type, tagsList);
}
@Override
public int getNewBlockStateId(int id) {
return checkValidity(id, blockStateMappings.getNewId(id), "blockstate");
}
@Override
public int getNewBlockId(int id) {
return checkValidity(id, blockMappings.getNewId(id), "block");
}
@Override
public int getNewItemId(int id) {
return checkValidity(id, itemMappings.get(id), "item");
}
@Override
public int getOldItemId(int id) {
int oldId = itemMappings.inverse().get(id);
// Remap new items to stone
return oldId != -1 ? oldId : 1;
}
@Override
public int getNewParticleId(int id) {
return checkValidity(id, particleMappings.getMappings().getNewId(id), "particles");
}
@Override
public @Nullable List<TagData> getTags(RegistryType type) {
return tags != null ? tags.get(type) : null;
}
@Override
public @Nullable Int2IntBiMap getItemMappings() {
return itemMappings;
}
@Override
public @Nullable ParticleMappings getParticleMappings() {
return particleMappings;
}
@Override
public @Nullable Mappings getBlockMappings() {
return blockMappings;
}
@Override
public @Nullable Mappings getBlockStateMappings() {
return blockStateMappings;
}
@Override
public @Nullable Mappings getSoundMappings() {
return soundMappings;
}
@Override
public @Nullable Mappings getStatisticsMappings() {
return statisticsMappings;
}
protected @Nullable Mappings loadFromArray(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
return new IntArrayMappings(oldMappings.getAsJsonArray(key), newMappings.getAsJsonArray(key), diff);
}
protected @Nullable Mappings loadFromObject(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
return new IntArrayMappings(oldMappings.getAsJsonObject(key), newMappings.getAsJsonObject(key), diff);
}
protected @Nullable JsonObject loadDiffFile() {
return MappingDataLoader.loadData("mappingdiff-" + oldVersion + "to" + newVersion + ".json");
}
protected Logger getLogger() {
return Via.getPlatform().getLogger();
}
/**
* Returns the given mapped id if valid, else 0 with a warning logged to the console.
*
* @param id unmapped id
* @param mappedId mapped id
* @param type mapping type (e.g. "item")
* @return the given mapped id if valid, else 0
*/
protected int checkValidity(int id, int mappedId, String type) {
if (mappedId == -1) {
getLogger().warning(String.format("Missing %s %s for %s %s %d", newVersion, type, oldVersion, type, id));
return 0;
}
return mappedId;
}
/**
* To be overridden.
*
* @param oldMappings old mappings
* @param newMappings new mappings
* @param diffMappings diff mappings if present
*/
protected void loadExtras(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings) {
}
}
@@ -1,16 +1,38 @@
package us.myles.ViaVersion.api.data;
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonIOException;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.util.GsonUtil;
import com.viaversion.viaversion.util.Int2IntBiMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.util.GsonUtil;
import us.myles.ViaVersion.util.Int2IntBiMap;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.io.File;
import java.io.FileReader;
@@ -40,8 +62,9 @@ public class MappingDataLoader {
}
/**
* Returns the cached mappings. Cleared after Via has been fully loaded.
* Returns the cached mappings. Cleared after ViaVersion has been fully loaded.
*
* @return cached mapping file json objects
* @see #isCacheJsonMappings()
*/
public static Map<String, JsonObject> getMappingsCache() {
@@ -50,9 +73,10 @@ public class MappingDataLoader {
/**
* Loads the file from the plugin folder if present, else from the bundled resources.
*
* @return loaded json object, or null if not found or invalid
*/
@Nullable
public static JsonObject loadFromDataDir(String name) {
public static @Nullable JsonObject loadFromDataDir(String name) {
File file = new File(Via.getPlatform().getDataFolder(), name);
if (!file.exists()) return loadData(name);
@@ -71,9 +95,10 @@ public class MappingDataLoader {
/**
* Loads the file from the bundled resources. Uses the cache if enabled.
*
* @return loaded json object from bundled resources if present
*/
@Nullable
public static JsonObject loadData(String name) {
public static @Nullable JsonObject loadData(String name) {
return loadData(name, false);
}
@@ -81,9 +106,9 @@ public class MappingDataLoader {
* Loads the file from the bundled resources. Uses the cache if enabled.
*
* @param cacheIfEnabled whether loaded files should be cached
* @return loaded json object from bundled resources if present
*/
@Nullable
public static JsonObject loadData(String name, boolean cacheIfEnabled) {
public static @Nullable JsonObject loadData(String name, boolean cacheIfEnabled) {
if (cacheJsonMappings) {
JsonObject cached = MAPPINGS_CACHE.get(name);
if (cached != null) {
@@ -120,16 +145,16 @@ public class MappingDataLoader {
}
}
public static void mapIdentifiers(short[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
MappingDataLoader.mapIdentifiers(output, oldIdentifiers, newIdentifiers, null);
}
public static void mapIdentifiers(short[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, @Nullable JsonObject diffIdentifiers) {
Object2IntMap newIdentifierMap = MappingDataLoader.indexedObjectToMap(newIdentifiers);
public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, @Nullable JsonObject diffIdentifiers) {
Object2IntMap<String> newIdentifierMap = MappingDataLoader.indexedObjectToMap(newIdentifiers);
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
int value = mapIdentifierEntry(entry, newIdentifierMap, diffIdentifiers);
if (value != -1) {
output[Integer.parseInt(entry.getKey())] = (short) value;
output[Integer.parseInt(entry.getKey())] = value;
}
}
}
@@ -154,11 +179,11 @@ public class MappingDataLoader {
return value;
}
public static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, boolean warnOnMissing) {
public static void mapIdentifiers(int[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, boolean warnOnMissing) {
mapIdentifiers(output, oldIdentifiers, newIdentifiers, null, warnOnMissing);
}
public static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, @Nullable JsonObject diffIdentifiers, boolean warnOnMissing) {
public static void mapIdentifiers(int[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, @Nullable JsonObject diffIdentifiers, boolean warnOnMissing) {
Object2IntMap<String> newIdentifierMap = MappingDataLoader.arrayToMap(newIdentifiers);
for (int i = 0; i < oldIdentifiers.size(); i++) {
JsonElement oldIdentifier = oldIdentifiers.get(i);
@@ -181,11 +206,13 @@ public class MappingDataLoader {
continue;
}
}
output[i] = (short) mappedId;
output[i] = mappedId;
}
}
/**
* Returns a map of the object entries hashed by their id value.
*
* @param object json object
* @return map with indexes hashed by their id value
*/
@@ -199,6 +226,8 @@ public class MappingDataLoader {
}
/**
* Returns a map of the array entries hashed by their id value.
*
* @param array json array
* @return map with indexes hashed by their id value
*/
@@ -211,8 +240,7 @@ public class MappingDataLoader {
return map;
}
@Nullable
public static InputStream getResource(String name) {
public static @Nullable InputStream getResource(String name) {
return MappingDataLoader.class.getClassLoader().getResourceAsStream("assets/viaversion/data/" + name);
}
}
@@ -0,0 +1,43 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data;
public interface Mappings {
/**
* Returns the mapped id from the given id, or -1 if invalid/out of bounds.
*
* @param id unmapped id
* @return mapped id, or -1 if invalid/out of bounds
*/
int getNewId(int id);
/**
* Manually maps a specific id.
*
* @param id unmapped id
* @param newId mapped id
* @throws IndexOutOfBoundsException if the unmapped id is invalid
*/
void setNewId(int id, int newId);
}
@@ -0,0 +1,58 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data;
import com.google.gson.JsonArray;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
public class ParticleMappings {
private final Mappings mappings;
private final int blockId;
private final int fallingDustId;
private final int itemId;
public ParticleMappings(JsonArray oldMappings, Mappings mappings) {
this.mappings = mappings;
Object2IntMap<String> map = MappingDataLoader.arrayToMap(oldMappings);
blockId = map.getInt("block");
fallingDustId = map.getInt("falling_dust");
itemId = map.getInt("item");
}
public Mappings getMappings() {
return mappings;
}
public int getBlockId() {
return blockId;
}
public int getFallingDustId() {
return fallingDustId;
}
public int getItemId() {
return itemId;
}
}
@@ -0,0 +1,28 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data.entity;
public interface ClientEntityIdChangeListener {
void setClientEntityId(int entityId);
}
@@ -0,0 +1,129 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data.entity;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface EntityTracker {
/**
* User connection the tracker belongs to.
*
* @return user connection
*/
UserConnection user();
/**
* Tracks an entity.
*
* @param id entity id
* @param type entity type
*/
void addEntity(int id, EntityType type);
/**
* Returns whether the entity is currently tracked.
*
* @param id entity id
* @return whether the entity is tracked
*/
boolean hasEntity(int id);
/**
* Entity type of the entity if tracked.
* This returning null does not necessarily mean no entity by the id exists.
*
* @param id entity id
* @return entity type of the entity if tracked
*/
@Nullable EntityType entityType(int id);
/**
* Untracks an entity.
*
* @param id entity id
*/
void removeEntity(int id);
/**
* Returns the stored entity data if an entity with the id is tracked, else null.
* If no data has been initialized yet, it will be done and returned by this method.
*
* @param id entity id
* @return stored entity data if an entity with the id is tracked, else null
*/
@Nullable StoredEntityData entityData(int id);
/**
* Returns stored entity data if it has previously been initialized by {@link #entityData(int)}, else null.
*
* @param id entity id
* @return stored entity data if it has previously been initialized by {@link #entityData(int)}
*/
@Nullable StoredEntityData entityDataIfPresent(int id);
/**
* Returns the client entity id or -1 if unset.
*
* @return client entity id or -1 if unset
*/
int clientEntityId();
/**
* Sets the client entity id.
*
* @param clientEntityId client entity id
*/
void setClientEntityId(int clientEntityId);
/**
* Returns the current world section height.
* Always 16 for sub 1.17 worlds.
*
* @return current world section height
*/
int currentWorldSectionHeight();
/**
* Sets the current world section height.
*
* @param currentWorldSectionHeight world section height
*/
void setCurrentWorldSectionHeight(int currentWorldSectionHeight);
/**
* Returns the minimum y of the current player world.
*
* @return minimum y of the current world
*/
int currentMinY();
/**
* Sets the minimum y of the current player world.
*
* @param currentMinY minimum y of the current world
*/
void setCurrentMinY(int currentMinY);
}
@@ -0,0 +1,60 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data.entity;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface StoredEntityData {
/**
* Returns the entity type of the stored entity.
*
* @return entity type
*/
EntityType type();
/**
* Checks if the storage contains an object of the given type.
*
* @param objectClass object class to check
* @return whether an object of the given type is in the storage
*/
boolean has(Class<?> objectClass);
/**
* Returns an object from the storage if present.
*
* @param objectClass class of the object to get
* @param <T> object type
* @return object if present
*/
@Nullable <T> T get(Class<T> objectClass);
/**
* Stores an object based on its class.
*
* @param object object to store
*/
void put(Object object);
}
@@ -0,0 +1,58 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.legacy;
import com.viaversion.viaversion.api.legacy.bossbar.BossBar;
import com.viaversion.viaversion.api.legacy.bossbar.BossColor;
import com.viaversion.viaversion.api.legacy.bossbar.BossStyle;
/**
* API only applicable on or to legacy versions of Minecraft.
*
* @param <T> player type
*/
public interface LegacyViaAPI<T> {
/**
* Creates a new bossbar instance. This only works on pre 1.9 servers for 1.9+ clients.
*
* @param title title
* @param health health, between 0 and 1 (inclusive)
* @param color color
* @param style style
* @return new bossbar instance
*/
BossBar createLegacyBossBar(String title, float health, BossColor color, BossStyle style);
/**
* Creates a new bossbar instance with full health. This only works on pre 1.9 servers for 1.9+ clients.
*
* @param title title
* @param color color
* @param style style
* @return new bossbar instance
*/
default BossBar createLegacyBossBar(String title, BossColor color, BossStyle style) {
return createLegacyBossBar(title, 1F, color, style);
}
}
@@ -1,19 +1,40 @@
package us.myles.ViaVersion.api.boss;
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.legacy.bossbar;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
import com.viaversion.viaversion.api.connection.UserConnection;
import java.util.Set;
import java.util.UUID;
public abstract class BossBar<T> {
public interface BossBar {
/**
* Get the current title
*
* @return the title
*/
public abstract String getTitle();
String getTitle();
/**
* Change the title
@@ -21,14 +42,14 @@ public abstract class BossBar<T> {
* @param title Title can be in either JSON or just text
* @return The BossBar object
*/
public abstract BossBar setTitle(String title);
BossBar setTitle(String title);
/**
* Get the health
*
* @return float between 0F - 1F
*/
public abstract float getHealth();
float getHealth();
/**
* Change the health
@@ -36,14 +57,14 @@ public abstract class BossBar<T> {
* @param health this float has to be between 0F - 1F
* @return The BossBar object
*/
public abstract BossBar setHealth(float health);
BossBar setHealth(float health);
/**
* Get the bossbar color
*
* @return The colour
*/
public abstract BossColor getColor();
BossColor getColor();
/**
* Yay colors!
@@ -51,14 +72,14 @@ public abstract class BossBar<T> {
* @param color Whatever color you want!
* @return The BossBar object
*/
public abstract BossBar setColor(BossColor color);
BossBar setColor(BossColor color);
/**
* Get the bosbar style
*
* @return BossStyle
*/
public abstract BossStyle getStyle();
BossStyle getStyle();
/**
* Change the bosbar style
@@ -66,19 +87,7 @@ public abstract class BossBar<T> {
* @param style BossStyle
* @return The BossBar object
*/
public abstract BossBar setStyle(BossStyle style);
/**
* Show the bossbar to a player.
*
* @param player The player
* @return The BossBar object
* @deprecated Deprecated use UUID's instead of Player objects {@link #addPlayer(UUID)}
*/
@Deprecated
public BossBar addPlayer(T player) {
throw new UnsupportedOperationException("This method is not implemented for the platform " + Via.getPlatform().getPlatformName());
}
BossBar setStyle(BossStyle style);
/**
* Show the bossbar to a player (uuid). This only works for frontend connections. Use #addConnection(UserConnection) for other types.
@@ -86,7 +95,7 @@ public abstract class BossBar<T> {
* @param player uuid of the player
* @return The BossBar object
*/
public abstract BossBar addPlayer(UUID player);
BossBar addPlayer(UUID player);
/**
* Show the bossbar to a player connection.
@@ -94,31 +103,7 @@ public abstract class BossBar<T> {
* @param conn UserConnection of the connection
* @return The BossBar object
*/
public abstract BossBar addConnection(UserConnection conn);
/**
* add multiple players
*
* @param players list of players
* @return The BossBar object
* @deprecated Deprecated use UUID's instead of Player objects {@link #addPlayer(UUID)}
*/
@Deprecated
public BossBar addPlayers(T... players) {
throw new UnsupportedOperationException("This method is not implemented for the platform " + Via.getPlatform().getPlatformName());
}
/**
* Remove the bossbar from a player
*
* @param player The player
* @return The BossBar object
* @deprecated Deprecated use UUID's instead of Player objects {@link #removePlayer(UUID)}
*/
@Deprecated
public BossBar removePlayer(T player) {
throw new UnsupportedOperationException("This method is not implemented for the platform " + Via.getPlatform().getPlatformName());
}
BossBar addConnection(UserConnection conn);
/**
* Removes the bossbar from a player. This only works for frontend connections. For others types, use #removeConnection(UserConnection)
@@ -126,7 +111,7 @@ public abstract class BossBar<T> {
* @param uuid The players UUID
* @return The BossBar object
*/
public abstract BossBar removePlayer(UUID uuid);
BossBar removePlayer(UUID uuid);
/**
* Removes the bossbar from a player connection.
@@ -134,7 +119,7 @@ public abstract class BossBar<T> {
* @param conn The UserConnection
* @return The BossBar object
*/
public abstract BossBar removeConnection(UserConnection conn);
BossBar removeConnection(UserConnection conn);
/**
* Add flags
@@ -142,7 +127,7 @@ public abstract class BossBar<T> {
* @param flag The flag to add
* @return The BossBar object
*/
public abstract BossBar addFlag(BossFlag flag);
BossBar addFlag(BossFlag flag);
/**
* Remove flags.
@@ -150,53 +135,53 @@ public abstract class BossBar<T> {
* @param flag The flag to remove
* @return The BossBar object
*/
public abstract BossBar removeFlag(BossFlag flag);
BossBar removeFlag(BossFlag flag);
/**
* @param flag The flag to check against
* @return True if it has the flag
*/
public abstract boolean hasFlag(BossFlag flag);
boolean hasFlag(BossFlag flag);
/**
* Get players. Only returns UUIDs which are front-end. For all connections, use #getConnections()
*
* @return UUIDS from players (sorry I lied)
*/
public abstract Set<UUID> getPlayers();
Set<UUID> getPlayers();
/**
* Get UserConnections.
*
* @return UserConnection from players
*/
public abstract Set<UserConnection> getConnections();
Set<UserConnection> getConnections();
/**
* Show the bossbar to everyone (In the getPlayer set)
*
* @return The BossBar object
*/
public abstract BossBar show();
BossBar show();
/**
* Hide the bossbar from everyone (In the getPlayer set)
*
* @return The BossBar object
*/
public abstract BossBar hide();
BossBar hide();
/**
* Is it visible?
*
* @return visibility changable with show() and hide()
*/
public abstract boolean isVisible();
boolean isVisible();
/**
* Get the UUID of this bossbar
*
* @return Unique Id for this bossbar
*/
public abstract UUID getId();
UUID getId();
}
@@ -0,0 +1,44 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.legacy.bossbar;
public enum BossColor {
PINK(0),
BLUE(1),
RED(2),
GREEN(3),
YELLOW(4),
PURPLE(5),
WHITE(6);
private final int id;
BossColor(int id) {
this.id = id;
}
public int getId() {
return id;
}
}
@@ -0,0 +1,39 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.legacy.bossbar;
public enum BossFlag {
DARKEN_SKY(1),
PLAY_BOSS_MUSIC(2);
private final int id;
BossFlag(int id) {
this.id = id;
}
public int getId() {
return id;
}
}
@@ -0,0 +1,42 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.legacy.bossbar;
public enum BossStyle {
SOLID(0),
SEGMENTED_6(1),
SEGMENTED_10(2),
SEGMENTED_12(3),
SEGMENTED_20(4);
private final int id;
BossStyle(int id) {
this.id = id;
}
public int getId() {
return id;
}
}
@@ -0,0 +1,68 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public interface BlockChangeRecord {
/**
* Returns the relative x coordinate within the chunk section.
*
* @return relative x coordinate within the chunk section
*/
byte getSectionX();
/**
* Returns the relative y coordinate within the chunk section.
*
* @return relative y coordinate within the chunk section
*/
byte getSectionY();
/**
* Returns the relative z coordinate within the chunk section.
*
* @return relative z coordinate within the chunk section
*/
byte getSectionZ();
/**
* Returns the absolute y coordinate based on the given chunk section y.
*
* @param chunkSectionY chunk section
* @return absolute y coordinate
*/
short getY(int chunkSectionY);
/**
* @return absolute y coordinate
* @deprecated 1.16+ stores the relative y coordinate
*/
@Deprecated
default short getY() {
return getY(-1);
}
int getBlockId();
void setBlockId(int blockId);
}
@@ -1,4 +1,26 @@
package us.myles.ViaVersion.api.minecraft;
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
import com.google.common.base.Preconditions;
@@ -0,0 +1,76 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public class BlockChangeRecord1_8 implements BlockChangeRecord {
private final byte sectionX;
private final short y;
private final byte sectionZ;
private int blockId;
public BlockChangeRecord1_8(byte sectionX, short y, byte sectionZ, int blockId) {
this.sectionX = sectionX;
this.y = y;
this.sectionZ = sectionZ;
this.blockId = blockId;
}
public BlockChangeRecord1_8(int sectionX, int y, int sectionZ, int blockId) {
this((byte) sectionX, (short) y, (byte) sectionZ, blockId);
}
/**
* @return x coordinate within the chunk section
*/
public byte getSectionX() {
return sectionX;
}
@Override
public byte getSectionY() {
return (byte) (y & 0xF);
}
/**
* @return y coordinate
*/
@Override
public short getY(int chunkSectionY) {
return y;
}
/**
* @return z coordinate within the chunk section
*/
public byte getSectionZ() {
return sectionZ;
}
public int getBlockId() {
return blockId;
}
public void setBlockId(int blockId) {
this.blockId = blockId;
}
}
@@ -1,4 +1,26 @@
package us.myles.ViaVersion.api.minecraft;
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
import java.util.HashMap;
import java.util.Map;
@@ -0,0 +1,52 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public enum Environment {
NORMAL(0),
NETHER(-1),
END(1);
private final int id;
Environment(int id) {
this.id = id;
}
public int getId() {
return id;
}
public static Environment getEnvironmentById(int id) {
switch (id) {
default:
case -1:
return NETHER;
case 0:
return NORMAL;
case 1:
return END;
}
}
}
@@ -0,0 +1,47 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public class EulerAngle {
private final float x;
private final float y;
private final float z;
public EulerAngle(final float x, final float y, final float z) {
this.x = x;
this.y = y;
this.z = z;
}
public float getX() {
return x;
}
public float getY() {
return y;
}
public float getZ() {
return z;
}
}
@@ -0,0 +1,88 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public class Position {
private final int x;
private final int y;
private final int z;
public Position(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public Position(int x, short y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public Position(Position toCopy) {
this(toCopy.getX(), toCopy.getY(), toCopy.getZ());
}
public Position getRelative(BlockFace face) {
return new Position(x + face.getModX(), (short) (y + face.getModY()), z + face.getModZ());
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getZ() {
return z;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Position position = (Position) o;
if (x != position.x) return false;
if (y != position.y) return false;
return z == position.z;
}
@Override
public int hashCode() {
int result = x;
result = 31 * result + y;
result = 31 * result + z;
return result;
}
@Override
public String toString() {
return "Position{" +
"x=" + x +
", y=" + y +
", z=" + z +
'}';
}
}
@@ -0,0 +1,64 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.HashMap;
import java.util.Map;
public enum RegistryType {
BLOCK("block"),
ITEM("item"),
FLUID("fluid"),
ENTITY("entity_type"),
GAME_EVENT("game_event");
private static final Map<String, RegistryType> MAP = new HashMap<>();
private static final RegistryType[] VALUES = values();
static {
for (RegistryType type : getValues()) {
MAP.put(type.resourceLocation, type);
}
}
public static RegistryType[] getValues() {
return VALUES;
}
public static @Nullable RegistryType getByKey(String resourceKey) {
return MAP.get(resourceKey);
}
private final String resourceLocation;
RegistryType(final String resourceLocation) {
this.resourceLocation = resourceLocation;
}
public String getResourceLocation() {
return resourceLocation;
}
}
@@ -0,0 +1,41 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public final class TagData {
private final String identifier;
private final int[] entries;
public TagData(String identifier, int[] entries) {
this.identifier = identifier;
this.entries = entries;
}
public String identifier() {
return identifier;
}
public int[] entries() {
return entries;
}
}
@@ -0,0 +1,59 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public class Vector {
private int blockX;
private int blockY;
private int blockZ;
public Vector(int blockX, int blockY, int blockZ) {
this.blockX = blockX;
this.blockY = blockY;
this.blockZ = blockZ;
}
public int getBlockX() {
return blockX;
}
public void setBlockX(int blockX) {
this.blockX = blockX;
}
public int getBlockY() {
return blockY;
}
public void setBlockY(int blockY) {
this.blockY = blockY;
}
public int getBlockZ() {
return blockZ;
}
public void setBlockZ(int blockZ) {
this.blockZ = blockZ;
}
}
@@ -0,0 +1,47 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public class VillagerData {
private final int type;
private final int profession;
private final int level;
public VillagerData(final int type, final int profession, final int level) {
this.type = type;
this.profession = profession;
this.level = level;
}
public int getType() {
return type;
}
public int getProfession() {
return profession;
}
public int getLevel() {
return level;
}
}
@@ -0,0 +1,150 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.BitSet;
import java.util.List;
//TODO Move methods from distinctly different versions to different objects/interfaces
public class BaseChunk implements Chunk {
protected final int x;
protected final int z;
protected final boolean fullChunk;
protected boolean ignoreOldLightData;
protected BitSet chunkSectionBitSet;
protected int bitmask;
protected ChunkSection[] sections;
protected int[] biomeData;
protected CompoundTag heightMap;
protected final List<CompoundTag> blockEntities;
public BaseChunk(int x, int z, boolean fullChunk, boolean ignoreOldLightData, @Nullable BitSet chunkSectionBitSet,
ChunkSection[] sections, int @Nullable [] biomeData, @Nullable CompoundTag heightMap, List<CompoundTag> blockEntities) {
this.x = x;
this.z = z;
this.fullChunk = fullChunk;
this.ignoreOldLightData = ignoreOldLightData;
this.chunkSectionBitSet = chunkSectionBitSet;
this.sections = sections;
this.biomeData = biomeData;
this.heightMap = heightMap;
this.blockEntities = blockEntities;
}
public BaseChunk(int x, int z, boolean fullChunk, boolean ignoreOldLightData, int bitmask, ChunkSection[] sections, int[] biomeData, CompoundTag heightMap, List<CompoundTag> blockEntities) {
this(x, z, fullChunk, ignoreOldLightData, null, sections, biomeData, heightMap, blockEntities);
this.bitmask = bitmask;
}
public BaseChunk(int x, int z, boolean fullChunk, boolean ignoreOldLightData, int bitmask, ChunkSection[] sections, int[] biomeData, List<CompoundTag> blockEntities) {
this(x, z, fullChunk, ignoreOldLightData, bitmask, sections, biomeData, null, blockEntities);
}
@Override
public boolean isBiomeData() {
return biomeData != null;
}
@Override
public int getX() {
return x;
}
@Override
public int getZ() {
return z;
}
@Override
public boolean isFullChunk() {
return fullChunk;
}
@Override
public boolean isIgnoreOldLightData() {
return ignoreOldLightData;
}
@Override
public void setIgnoreOldLightData(boolean ignoreOldLightData) {
this.ignoreOldLightData = ignoreOldLightData;
}
@Override
public int getBitmask() {
return bitmask;
}
@Override
public void setBitmask(int bitmask) {
this.bitmask = bitmask;
}
@Override
public @Nullable BitSet getChunkMask() {
return chunkSectionBitSet;
}
@Override
public void setChunkMask(BitSet chunkSectionMask) {
this.chunkSectionBitSet = chunkSectionMask;
}
@Override
public ChunkSection[] getSections() {
return sections;
}
@Override
public void setSections(ChunkSection[] sections) {
this.sections = sections;
}
@Override
public int @Nullable [] getBiomeData() {
return biomeData;
}
@Override
public void setBiomeData(int @Nullable [] biomeData) {
this.biomeData = biomeData;
}
@Override
public @Nullable CompoundTag getHeightMap() {
return heightMap;
}
@Override
public void setHeightMap(final CompoundTag heightMap) {
this.heightMap = heightMap;
}
@Override
public List<CompoundTag> getBlockEntities() {
return blockEntities;
}
}
@@ -0,0 +1,118 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.BitSet;
import java.util.List;
public interface Chunk {
/**
* Returns the chunk x coordinate.
*
* @return chunk x coordinate
*/
int getX();
/**
* Returns the chunk z coordinate.
*
* @return chunk z coordinate
*/
int getZ();
/**
* Returns whether this chunk holds biome data, always true for 1.17+ chunks.
*
* @return true if this chunk holds biome data
*/
boolean isBiomeData();
/**
* Returns whether this is a full chunk, always true for 1.17+ chunks.
*
* @return true if this is a full chunk
*/
boolean isFullChunk();
boolean isIgnoreOldLightData();
void setIgnoreOldLightData(boolean ignoreOldLightData);
/**
* Returns the chunk section bit mask for chunks &lt; 1.17.
*
* @return chunk section bit mask for chunks &lt; 1.17
* @see #getChunkMask()
*/
int getBitmask();
void setBitmask(int bitmask);
/**
* Returns the chunk section bit mask, only non-null for 1.17+ chunks.
*
* @return chunk section bit mask, only non-null for 1.17+ chunks
* @see #getBitmask()
*/
@Nullable BitSet getChunkMask();
void setChunkMask(BitSet chunkSectionMask);
/**
* Returns an array of nullable chunk section entries.
*
* @return array of nullable chunk sections
*/
@Nullable ChunkSection[] getSections();
void setSections(ChunkSection[] sections);
/**
* Returns the chunk's raw biome data. The format the biomes are stored may vary.
*
* @return raw biome data
*/
int @Nullable [] getBiomeData();
void setBiomeData(int @Nullable [] biomeData);
/**
* Returns a compoundtag containing the chunk's heightmaps if present.
*
* @return compoundtag containing heightmaps if present
*/
@Nullable CompoundTag getHeightMap();
void setHeightMap(@Nullable CompoundTag heightMap);
/**
* Returns a list of block entities.
*
* @return list of block entities
*/
List<CompoundTag> getBlockEntities();
}
@@ -0,0 +1,60 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import java.util.ArrayList;
import java.util.List;
public class Chunk1_8 extends BaseChunk {
private boolean unloadPacket;
public Chunk1_8(int x, int z, boolean groundUp, int bitmask, ChunkSection[] sections, int[] biomeData, List<CompoundTag> blockEntities) {
super(x, z, groundUp, false, bitmask, sections, biomeData, blockEntities);
}
/**
* Chunk unload.
*
* @param x coord
* @param z coord
*/
public Chunk1_8(int x, int z) {
this(x, z, true, 0, new ChunkSection[16], null, new ArrayList<>());
this.unloadPacket = true;
}
/**
* Does this chunks have biome data
*
* @return True if the chunks has biome data
*/
public boolean hasBiomeData() {
return biomeData != null && fullChunk;
}
public boolean isUnloadPacket() {
return unloadPacket;
}
}
@@ -0,0 +1,201 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface ChunkSection {
/**
* Size (dimensions) of blocks in a chunks section.
*/
int SIZE = 16 * 16 * 16; // width * depth * height
/**
* Returns the block index of the given coordinates within a section.
*
* @param x section x
* @param y section y
* @param z section z
* @return section block index
*/
static int index(int x, int y, int z) {
return y << 8 | z << 4 | x;
}
/**
* Returns the block state of the given index.
*
* @param idx block index within the section
* @return block state of the given index
*/
int getFlatBlock(int idx);
/**
* Returns the block state of the section coordinate.
*
* @param x section x
* @param y section y
* @param z section z
* @return block state of the given section coordinate
*/
default int getFlatBlock(int x, int y, int z) {
return getFlatBlock(index(x, y, z));
}
/**
* Set a block state in the chunk section.
* This method will not update non-air blocks count.
*
* @param idx block index within the section
* @param id raw or flat id of the block state
*/
void setFlatBlock(int idx, int id);
/**
* Set a block state in the chunk section.
* This method will not update non-air blocks count.
*
* @param x section x
* @param y section y
* @param z section z
* @param id raw or flat id of the block state
*/
default void setFlatBlock(int x, int y, int z, int id) {
setFlatBlock(index(x, y, z), id);
}
default int getBlockWithoutData(int x, int y, int z) {
return getFlatBlock(x, y, z) >> 4;
}
default int getBlockData(int x, int y, int z) {
return getFlatBlock(x, y, z) & 0xF;
}
/**
* Set a block in the chunks.
* This method will not update non-air blocks count.
*
* @param x Block X
* @param y Block Y
* @param z Block Z
* @param type The type of the block
* @param data The data value of the block
*/
default void setBlockWithData(int x, int y, int z, int type, int data) {
setFlatBlock(index(x, y, z), type << 4 | (data & 0xF));
}
default void setBlockWithData(int idx, int type, int data) {
setFlatBlock(idx, type << 4 | (data & 0xF));
}
/**
* Sets a block to the given palette index.
*
* @param idx block index
* @param index palette index
*/
void setPaletteIndex(int idx, int index);
/**
* Returns the palette index of the given block index.
*
* @param idx block index
* @return palette index of the given block index
*/
int getPaletteIndex(int idx);
/**
* Returns the size of the palette.
*
* @return palette size
*/
int getPaletteSize();
/**
* Returns the block state assigned to the given palette index.
*
* @param index palette index
* @return block state assigned to the given palette index
*/
int getPaletteEntry(int index);
/**
* Assigns a block state assigned to the given palette index.
*
* @param index palette index
* @param id block state
*/
void setPaletteEntry(int index, int id);
/**
* Replaces a block state in the palette.
*
* @param oldId old block state
* @param newId new block state
*/
void replacePaletteEntry(int oldId, int newId);
/**
* Adds a new block state to the palette.
*
* @param id block state
*/
void addPaletteEntry(int id);
/**
* Clears the palette.
*/
void clearPalette();
/**
* Returns the number of non-air blocks in this section.
*
* @return non-air blocks in this section
*/
int getNonAirBlocksCount();
void setNonAirBlocksCount(int nonAirBlocksCount);
/**
* Returns whether this section holds light data.
* Only true for &lt; 1.14 chunks.
*
* @return whether this section holds light data
*/
default boolean hasLight() {
return getLight() != null;
}
/**
* Returns the light of the chunk section.
* Only present for &lt; 1.14 chunks, otherwise sent separately.
*
* @return chunk section light if present
*/
@Nullable ChunkSectionLight getLight();
void setLight(@Nullable ChunkSectionLight light);
}
@@ -0,0 +1,160 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import org.checkerframework.checker.nullness.qual.Nullable;
public class ChunkSectionImpl implements ChunkSection {
private final IntList palette;
private final Int2IntMap inversePalette;
private final int[] blocks;
private ChunkSectionLight light;
private int nonAirBlocksCount;
public ChunkSectionImpl(boolean holdsLight) {
this.blocks = new int[SIZE];
palette = new IntArrayList();
inversePalette = new Int2IntOpenHashMap();
inversePalette.defaultReturnValue(-1);
if (holdsLight) {
this.light = new ChunkSectionLightImpl();
}
}
public ChunkSectionImpl(boolean holdsLight, int expectedPaletteLength) {
this.blocks = new int[SIZE];
if (holdsLight) {
this.light = new ChunkSectionLightImpl();
}
// Pre-size the palette array/map
palette = new IntArrayList(expectedPaletteLength);
inversePalette = new Int2IntOpenHashMap(expectedPaletteLength);
inversePalette.defaultReturnValue(-1);
}
@Override
public int getFlatBlock(int idx) {
int index = blocks[idx];
return palette.getInt(index);
}
@Override
public void setFlatBlock(int idx, int id) {
int index = inversePalette.get(id);
if (index == -1) {
index = palette.size();
palette.add(id);
inversePalette.put(id, index);
}
blocks[idx] = index;
}
@Override
public int getPaletteIndex(int idx) {
return blocks[idx];
}
@Override
public void setPaletteIndex(int idx, int index) {
blocks[idx] = index;
}
@Override
public int getPaletteSize() {
return palette.size();
}
@Override
public int getPaletteEntry(int index) {
return palette.getInt(index);
}
@Override
public void setPaletteEntry(int index, int id) {
int oldId = palette.set(index, id);
if (oldId == id) return;
inversePalette.put(id, index);
if (inversePalette.get(oldId) == index) {
inversePalette.remove(oldId);
for (int i = 0; i < palette.size(); i++) {
if (palette.getInt(i) == oldId) {
inversePalette.put(oldId, i);
break;
}
}
}
}
@Override
public void replacePaletteEntry(int oldId, int newId) {
int index = inversePalette.remove(oldId);
if (index == -1) return;
inversePalette.put(newId, index);
for (int i = 0; i < palette.size(); i++) {
if (palette.getInt(i) == oldId) {
palette.set(i, newId);
}
}
}
@Override
public void addPaletteEntry(int id) {
inversePalette.put(id, palette.size());
palette.add(id);
}
@Override
public void clearPalette() {
palette.clear();
inversePalette.clear();
}
@Override
public int getNonAirBlocksCount() {
return nonAirBlocksCount;
}
@Override
public void setNonAirBlocksCount(int nonAirBlocksCount) {
this.nonAirBlocksCount = nonAirBlocksCount;
}
@Override
public @Nullable ChunkSectionLight getLight() {
return light;
}
@Override
public void setLight(@Nullable ChunkSectionLight light) {
this.light = light;
}
}
@@ -0,0 +1,113 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
import io.netty.buffer.ByteBuf;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface ChunkSectionLight {
/**
* Length of the sky and block light nibble arrays.
*/
int LIGHT_LENGTH = 16 * 16 * 16 / 2; // Dimensions / 2 (nibble bit count)
/**
* Returns whether the section has sky light.
*
* @return true if skylight is present
*/
boolean hasSkyLight();
/**
* Returns whether the section has block light.
* This returns true unless specifically set to null.
*
* @return true if skylight is present
*/
boolean hasBlockLight();
/**
* Returns the nibblearray's raw sky light byte array if present.
*
* @return the nibblearray's raw sky light byte array if present
* @see #hasSkyLight()
*/
byte @Nullable [] getSkyLight();
/**
* Returns the nibblearray's raw block light byte array if present.
*
* @return the nibblearray's raw block light byte array if present
* @see #hasBlockLight()
*/
byte @Nullable [] getBlockLight();
/**
* Set the sky light array.
*
* @param data raw sky light data
*/
void setSkyLight(byte[] data);
/**
* Set the block light array.
*
* @param data raw block light data
*/
void setBlockLight(byte[] data);
/**
* Returns the sky light nibblearray.
*
* @return sky light nibblearray
* @see #hasSkyLight()
*/
@Nullable NibbleArray getSkyLightNibbleArray();
/**
* Returns the block light nibblearray.
*
* @return block light nibblearray
* @see #hasBlockLight()
*/
@Nullable NibbleArray getBlockLightNibbleArray();
void readSkyLight(ByteBuf input);
void readBlockLight(ByteBuf input);
/**
* Write the sky light to a buffer.
*
* @param output buffer to write to
*/
void writeSkyLight(ByteBuf output);
/**
* Write the block light to a buffer.
*
* @param output buffer to write to
*/
void writeBlockLight(ByteBuf output);
}
@@ -0,0 +1,113 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
import io.netty.buffer.ByteBuf;
import org.checkerframework.checker.nullness.qual.Nullable;
public class ChunkSectionLightImpl implements ChunkSectionLight {
private NibbleArray blockLight;
private NibbleArray skyLight;
public ChunkSectionLightImpl() {
// Block light is always written
this.blockLight = new NibbleArray(ChunkSection.SIZE);
}
@Override
public void setBlockLight(byte[] data) {
if (data.length != LIGHT_LENGTH) throw new IllegalArgumentException("Data length != " + LIGHT_LENGTH);
if (this.blockLight == null) {
this.blockLight = new NibbleArray(data);
} else {
this.blockLight.setHandle(data);
}
}
@Override
public void setSkyLight(byte[] data) {
if (data.length != LIGHT_LENGTH) throw new IllegalArgumentException("Data length != " + LIGHT_LENGTH);
if (this.skyLight == null) {
this.skyLight = new NibbleArray(data);
} else {
this.skyLight.setHandle(data);
}
}
@Override
public byte @Nullable [] getBlockLight() {
return blockLight == null ? null : blockLight.getHandle();
}
@Override
public @Nullable NibbleArray getBlockLightNibbleArray() {
return blockLight;
}
@Override
public byte @Nullable [] getSkyLight() {
return skyLight == null ? null : skyLight.getHandle();
}
@Override
public @Nullable NibbleArray getSkyLightNibbleArray() {
return skyLight;
}
@Override
public void readBlockLight(ByteBuf input) {
if (this.blockLight == null) {
this.blockLight = new NibbleArray(LIGHT_LENGTH * 2);
}
input.readBytes(this.blockLight.getHandle());
}
@Override
public void readSkyLight(ByteBuf input) {
if (this.skyLight == null) {
this.skyLight = new NibbleArray(LIGHT_LENGTH * 2);
}
input.readBytes(this.skyLight.getHandle());
}
@Override
public void writeBlockLight(ByteBuf output) {
output.writeBytes(blockLight.getHandle());
}
@Override
public void writeSkyLight(ByteBuf output) {
output.writeBytes(skyLight.getHandle());
}
@Override
public boolean hasSkyLight() {
return skyLight != null;
}
@Override
public boolean hasBlockLight() {
return blockLight != null;
}
}
@@ -1,4 +1,26 @@
package us.myles.ViaVersion.api.minecraft.chunks;
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
import java.util.Arrays;
@@ -1,6 +1,28 @@
package us.myles.ViaVersion.api.entities;
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.entities;
import us.myles.ViaVersion.api.Via;
import com.viaversion.viaversion.api.Via;
import java.util.HashMap;
import java.util.Map;
@@ -25,7 +47,7 @@ public class Entity1_10Types {
return type.get();
}
public enum EntityType implements us.myles.ViaVersion.api.entities.EntityType {
public enum EntityType implements com.viaversion.viaversion.api.minecraft.entities.EntityType {
ENTITY(-1),
DROPPED_ITEM(1, ENTITY),
EXPERIENCE_ORB(2, ENTITY),
@@ -150,7 +172,7 @@ public class Entity1_10Types {
}
}
public enum ObjectType implements us.myles.ViaVersion.api.entities.ObjectType {
public enum ObjectType implements com.viaversion.viaversion.api.minecraft.entities.ObjectType {
BOAT(1, EntityType.BOAT),
ITEM(2, EntityType.DROPPED_ITEM),
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
@@ -1,6 +1,28 @@
package us.myles.ViaVersion.api.entities;
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.entities;
import us.myles.ViaVersion.api.Via;
import com.viaversion.viaversion.api.Via;
import java.util.HashMap;
import java.util.Map;
@@ -25,7 +47,7 @@ public class Entity1_11Types {
return type.get();
}
public enum EntityType implements us.myles.ViaVersion.api.entities.EntityType {
public enum EntityType implements com.viaversion.viaversion.api.minecraft.entities.EntityType {
ENTITY(-1),
DROPPED_ITEM(1, ENTITY),
EXPERIENCE_ORB(2, ENTITY),
@@ -178,7 +200,7 @@ public class Entity1_11Types {
}
}
public enum ObjectType implements us.myles.ViaVersion.api.entities.ObjectType {
public enum ObjectType implements com.viaversion.viaversion.api.minecraft.entities.ObjectType {
BOAT(1, EntityType.BOAT),
ITEM(2, EntityType.DROPPED_ITEM),
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
@@ -1,16 +1,29 @@
/*
* Copyright (c) 2016 Matsv
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api.entities;
package com.viaversion.viaversion.api.minecraft.entities;
import us.myles.ViaVersion.api.Via;
import com.viaversion.viaversion.api.Via;
import java.util.HashMap;
import java.util.Map;
@@ -35,7 +48,7 @@ public class Entity1_12Types {
return type.get();
}
public enum EntityType implements us.myles.ViaVersion.api.entities.EntityType {
public enum EntityType implements com.viaversion.viaversion.api.minecraft.entities.EntityType {
ENTITY(-1),
DROPPED_ITEM(1, ENTITY),
EXPERIENCE_ORB(2, ENTITY),
@@ -191,7 +204,7 @@ public class Entity1_12Types {
}
}
public enum ObjectType implements us.myles.ViaVersion.api.entities.ObjectType {
public enum ObjectType implements com.viaversion.viaversion.api.minecraft.entities.ObjectType {
BOAT(1, EntityType.BOAT),
ITEM(2, EntityType.DROPPED_ITEM),
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
@@ -1,12 +1,33 @@
package us.myles.ViaVersion.api.entities;
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.entities;
import us.myles.ViaVersion.api.Via;
import com.viaversion.viaversion.api.Via;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
// TODO auto generate 18w11a with PAaaS
public class Entity1_13Types {
public static EntityType getTypeFromId(int typeID, boolean isObject) {
@@ -25,7 +46,7 @@ public class Entity1_13Types {
return type.get();
}
public enum EntityType implements us.myles.ViaVersion.api.entities.EntityType {
public enum EntityType implements com.viaversion.viaversion.api.minecraft.entities.EntityType {
// Auto generated
ENTITY(-1), // abm
@@ -232,7 +253,7 @@ public class Entity1_13Types {
}
}
public enum ObjectType implements us.myles.ViaVersion.api.entities.ObjectType {
public enum ObjectType implements com.viaversion.viaversion.api.minecraft.entities.ObjectType {
BOAT(1, EntityType.BOAT),
ITEM(2, EntityType.ITEM),
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
@@ -0,0 +1,234 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.entities;
import com.viaversion.viaversion.util.EntityTypeUtil;
public enum Entity1_14Types implements EntityType {
ENTITY(-1),
AREA_EFFECT_CLOUD(0, ENTITY),
END_CRYSTAL(17, ENTITY),
EVOKER_FANGS(21, ENTITY),
EXPERIENCE_ORB(23, ENTITY),
EYE_OF_ENDER(24, ENTITY),
FALLING_BLOCK(25, ENTITY),
FIREWORK_ROCKET(26, ENTITY),
ITEM(34, ENTITY),
LLAMA_SPIT(39, ENTITY),
TNT(58, ENTITY),
SHULKER_BULLET(63, ENTITY),
FISHING_BOBBER(101, ENTITY),
LIVINGENTITY(-1, ENTITY),
ARMOR_STAND(1, LIVINGENTITY),
PLAYER(100, LIVINGENTITY),
ABSTRACT_INSENTIENT(-1, LIVINGENTITY),
ENDER_DRAGON(18, ABSTRACT_INSENTIENT),
ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT),
ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE),
VILLAGER(84, ABSTRACT_AGEABLE),
WANDERING_TRADER(88, ABSTRACT_AGEABLE),
// Animals
ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE),
DOLPHIN(13, ABSTRACT_INSENTIENT),
CHICKEN(8, ABSTRACT_ANIMAL),
COW(10, ABSTRACT_ANIMAL),
MOOSHROOM(49, COW),
PANDA(52, ABSTRACT_INSENTIENT),
PIG(54, ABSTRACT_ANIMAL),
POLAR_BEAR(57, ABSTRACT_ANIMAL),
RABBIT(59, ABSTRACT_ANIMAL),
SHEEP(61, ABSTRACT_ANIMAL),
TURTLE(77, ABSTRACT_ANIMAL),
FOX(27, ABSTRACT_ANIMAL),
ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL),
CAT(6, ABSTRACT_TAMEABLE_ANIMAL),
OCELOT(50, ABSTRACT_TAMEABLE_ANIMAL),
WOLF(93, ABSTRACT_TAMEABLE_ANIMAL),
ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL),
PARROT(53, ABSTRACT_PARROT),
// Horses
ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL),
CHESTED_HORSE(-1, ABSTRACT_HORSE),
DONKEY(12, CHESTED_HORSE),
MULE(48, CHESTED_HORSE),
LLAMA(38, CHESTED_HORSE),
TRADER_LLAMA(75, CHESTED_HORSE),
HORSE(31, ABSTRACT_HORSE),
SKELETON_HORSE(66, ABSTRACT_HORSE),
ZOMBIE_HORSE(95, ABSTRACT_HORSE),
// Golem
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE),
SNOW_GOLEM(69, ABSTRACT_GOLEM),
IRON_GOLEM(85, ABSTRACT_GOLEM),
SHULKER(62, ABSTRACT_GOLEM),
// Fish
ABSTRACT_FISHES(-1, ABSTRACT_CREATURE),
COD(9, ABSTRACT_FISHES),
PUFFERFISH(55, ABSTRACT_FISHES),
SALMON(60, ABSTRACT_FISHES),
TROPICAL_FISH(76, ABSTRACT_FISHES),
// Monsters
ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE),
BLAZE(4, ABSTRACT_MONSTER),
CREEPER(11, ABSTRACT_MONSTER),
ENDERMITE(20, ABSTRACT_MONSTER),
ENDERMAN(19, ABSTRACT_MONSTER),
GIANT(29, ABSTRACT_MONSTER),
SILVERFISH(64, ABSTRACT_MONSTER),
VEX(83, ABSTRACT_MONSTER),
WITCH(89, ABSTRACT_MONSTER),
WITHER(90, ABSTRACT_MONSTER),
RAVAGER(98, ABSTRACT_MONSTER),
// Illagers
ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER),
ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE),
EVOKER(22, ABSTRACT_EVO_ILLU_ILLAGER),
ILLUSIONER(33, ABSTRACT_EVO_ILLU_ILLAGER),
VINDICATOR(86, ABSTRACT_ILLAGER_BASE),
PILLAGER(87, ABSTRACT_ILLAGER_BASE),
// Skeletons
ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER),
SKELETON(65, ABSTRACT_SKELETON),
STRAY(74, ABSTRACT_SKELETON),
WITHER_SKELETON(91, ABSTRACT_SKELETON),
// Guardians
GUARDIAN(30, ABSTRACT_MONSTER),
ELDER_GUARDIAN(16, GUARDIAN),
// Spiders
SPIDER(72, ABSTRACT_MONSTER),
CAVE_SPIDER(7, SPIDER),
// Zombies - META CHECKED
ZOMBIE(94, ABSTRACT_MONSTER),
DROWNED(15, ZOMBIE),
HUSK(32, ZOMBIE),
ZOMBIE_PIGMAN(56, ZOMBIE),
ZOMBIE_VILLAGER(96, ZOMBIE),
// Flying entities
ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT),
GHAST(28, ABSTRACT_FLYING),
PHANTOM(97, ABSTRACT_FLYING),
ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT),
BAT(3, ABSTRACT_AMBIENT),
ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT),
SQUID(73, ABSTRACT_WATERMOB),
// Slimes
SLIME(67, ABSTRACT_INSENTIENT),
MAGMA_CUBE(40, SLIME),
// Hangable objects
ABSTRACT_HANGING(-1, ENTITY),
LEASH_KNOT(37, ABSTRACT_HANGING),
ITEM_FRAME(35, ABSTRACT_HANGING),
PAINTING(51, ABSTRACT_HANGING),
ABSTRACT_LIGHTNING(-1, ENTITY),
LIGHTNING_BOLT(99, ABSTRACT_LIGHTNING),
// Arrows
ABSTRACT_ARROW(-1, ENTITY),
ARROW(2, ABSTRACT_ARROW),
SPECTRAL_ARROW(71, ABSTRACT_ARROW),
TRIDENT(82, ABSTRACT_ARROW),
// Fireballs
ABSTRACT_FIREBALL(-1, ENTITY),
DRAGON_FIREBALL(14, ABSTRACT_FIREBALL),
FIREBALL(36, ABSTRACT_FIREBALL),
SMALL_FIREBALL(68, ABSTRACT_FIREBALL),
WITHER_SKULL(92, ABSTRACT_FIREBALL),
// Projectiles
PROJECTILE_ABSTRACT(-1, ENTITY),
SNOWBALL(70, PROJECTILE_ABSTRACT),
ENDER_PEARL(79, PROJECTILE_ABSTRACT),
EGG(78, PROJECTILE_ABSTRACT),
POTION(81, PROJECTILE_ABSTRACT),
EXPERIENCE_BOTTLE(80, PROJECTILE_ABSTRACT),
// Vehicles
MINECART_ABSTRACT(-1, ENTITY),
CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT),
CHEST_MINECART(42, CHESTED_MINECART_ABSTRACT),
HOPPER_MINECART(45, CHESTED_MINECART_ABSTRACT),
MINECART(41, MINECART_ABSTRACT),
FURNACE_MINECART(44, MINECART_ABSTRACT),
COMMAND_BLOCK_MINECART(43, MINECART_ABSTRACT),
TNT_MINECART(47, MINECART_ABSTRACT),
SPAWNER_MINECART(46, MINECART_ABSTRACT),
BOAT(5, ENTITY);
private static final EntityType[] TYPES;
private final int id;
private final EntityType parent;
Entity1_14Types(int id) {
this.id = id;
this.parent = null;
}
Entity1_14Types(int id, EntityType parent) {
this.id = id;
this.parent = parent;
}
@Override
public int getId() {
return id;
}
@Override
public EntityType getParent() {
return parent;
}
static {
TYPES = EntityTypeUtil.toOrderedArray(values());
}
public static EntityType getTypeFromId(int typeId) {
return EntityTypeUtil.getTypeFromId(TYPES, typeId, ENTITY);
}
}
@@ -0,0 +1,236 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.entities;
import com.viaversion.viaversion.util.EntityTypeUtil;
public enum Entity1_15Types implements EntityType {
ENTITY(-1),
AREA_EFFECT_CLOUD(0, ENTITY),
END_CRYSTAL(18, ENTITY),
EVOKER_FANGS(22, ENTITY),
EXPERIENCE_ORB(24, ENTITY),
EYE_OF_ENDER(25, ENTITY),
FALLING_BLOCK(26, ENTITY),
FIREWORK_ROCKET(27, ENTITY),
ITEM(35, ENTITY),
LLAMA_SPIT(40, ENTITY),
TNT(59, ENTITY),
SHULKER_BULLET(64, ENTITY),
FISHING_BOBBER(102, ENTITY),
LIVINGENTITY(-1, ENTITY),
ARMOR_STAND(1, LIVINGENTITY),
PLAYER(101, LIVINGENTITY),
ABSTRACT_INSENTIENT(-1, LIVINGENTITY),
ENDER_DRAGON(19, ABSTRACT_INSENTIENT),
BEE(4, ABSTRACT_INSENTIENT),
ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT),
ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE),
VILLAGER(85, ABSTRACT_AGEABLE),
WANDERING_TRADER(89, ABSTRACT_AGEABLE),
// Animals
ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE),
DOLPHIN(14, ABSTRACT_INSENTIENT),
CHICKEN(9, ABSTRACT_ANIMAL),
COW(11, ABSTRACT_ANIMAL),
MOOSHROOM(50, COW),
PANDA(53, ABSTRACT_INSENTIENT),
PIG(55, ABSTRACT_ANIMAL),
POLAR_BEAR(58, ABSTRACT_ANIMAL),
RABBIT(60, ABSTRACT_ANIMAL),
SHEEP(62, ABSTRACT_ANIMAL),
TURTLE(78, ABSTRACT_ANIMAL),
FOX(28, ABSTRACT_ANIMAL),
ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL),
CAT(7, ABSTRACT_TAMEABLE_ANIMAL),
OCELOT(51, ABSTRACT_TAMEABLE_ANIMAL),
WOLF(94, ABSTRACT_TAMEABLE_ANIMAL),
ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL),
PARROT(54, ABSTRACT_PARROT),
// Horses
ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL),
CHESTED_HORSE(-1, ABSTRACT_HORSE),
DONKEY(13, CHESTED_HORSE),
MULE(49, CHESTED_HORSE),
LLAMA(39, CHESTED_HORSE),
TRADER_LLAMA(76, CHESTED_HORSE),
HORSE(32, ABSTRACT_HORSE),
SKELETON_HORSE(67, ABSTRACT_HORSE),
ZOMBIE_HORSE(96, ABSTRACT_HORSE),
// Golem
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE),
SNOW_GOLEM(70, ABSTRACT_GOLEM),
IRON_GOLEM(86, ABSTRACT_GOLEM),
SHULKER(63, ABSTRACT_GOLEM),
// Fish
ABSTRACT_FISHES(-1, ABSTRACT_CREATURE),
COD(10, ABSTRACT_FISHES),
PUFFERFISH(56, ABSTRACT_FISHES),
SALMON(61, ABSTRACT_FISHES),
TROPICAL_FISH(77, ABSTRACT_FISHES),
// Monsters
ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE),
BLAZE(5, ABSTRACT_MONSTER),
CREEPER(12, ABSTRACT_MONSTER),
ENDERMITE(21, ABSTRACT_MONSTER),
ENDERMAN(20, ABSTRACT_MONSTER),
GIANT(30, ABSTRACT_MONSTER),
SILVERFISH(65, ABSTRACT_MONSTER),
VEX(84, ABSTRACT_MONSTER),
WITCH(90, ABSTRACT_MONSTER),
WITHER(91, ABSTRACT_MONSTER),
RAVAGER(99, ABSTRACT_MONSTER),
// Illagers
ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER),
ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE),
EVOKER(23, ABSTRACT_EVO_ILLU_ILLAGER),
ILLUSIONER(34, ABSTRACT_EVO_ILLU_ILLAGER),
VINDICATOR(87, ABSTRACT_ILLAGER_BASE),
PILLAGER(88, ABSTRACT_ILLAGER_BASE),
// Skeletons
ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER),
SKELETON(66, ABSTRACT_SKELETON),
STRAY(75, ABSTRACT_SKELETON),
WITHER_SKELETON(92, ABSTRACT_SKELETON),
// Guardians
GUARDIAN(31, ABSTRACT_MONSTER),
ELDER_GUARDIAN(17, GUARDIAN),
// Spiders
SPIDER(73, ABSTRACT_MONSTER),
CAVE_SPIDER(8, SPIDER),
// Zombies
ZOMBIE(95, ABSTRACT_MONSTER),
DROWNED(16, ZOMBIE),
HUSK(33, ZOMBIE),
ZOMBIE_PIGMAN(57, ZOMBIE),
ZOMBIE_VILLAGER(97, ZOMBIE),
// Flying entities
ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT),
GHAST(29, ABSTRACT_FLYING),
PHANTOM(98, ABSTRACT_FLYING),
ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT),
BAT(3, ABSTRACT_AMBIENT),
ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT),
SQUID(74, ABSTRACT_WATERMOB),
// Slimes
SLIME(68, ABSTRACT_INSENTIENT),
MAGMA_CUBE(41, SLIME),
// Hangable objects
ABSTRACT_HANGING(-1, ENTITY),
LEASH_KNOT(38, ABSTRACT_HANGING),
ITEM_FRAME(36, ABSTRACT_HANGING),
PAINTING(52, ABSTRACT_HANGING),
ABSTRACT_LIGHTNING(-1, ENTITY),
LIGHTNING_BOLT(100, ABSTRACT_LIGHTNING),
// Arrows
ABSTRACT_ARROW(-1, ENTITY),
ARROW(2, ABSTRACT_ARROW),
SPECTRAL_ARROW(72, ABSTRACT_ARROW),
TRIDENT(83, ABSTRACT_ARROW),
// Fireballs
ABSTRACT_FIREBALL(-1, ENTITY),
DRAGON_FIREBALL(15, ABSTRACT_FIREBALL),
FIREBALL(37, ABSTRACT_FIREBALL),
SMALL_FIREBALL(69, ABSTRACT_FIREBALL),
WITHER_SKULL(93, ABSTRACT_FIREBALL),
// Projectiles
PROJECTILE_ABSTRACT(-1, ENTITY),
SNOWBALL(71, PROJECTILE_ABSTRACT),
ENDER_PEARL(80, PROJECTILE_ABSTRACT),
EGG(79, PROJECTILE_ABSTRACT),
POTION(82, PROJECTILE_ABSTRACT),
EXPERIENCE_BOTTLE(81, PROJECTILE_ABSTRACT),
// Vehicles
MINECART_ABSTRACT(-1, ENTITY),
CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT),
CHEST_MINECART(43, CHESTED_MINECART_ABSTRACT),
HOPPER_MINECART(46, CHESTED_MINECART_ABSTRACT),
MINECART(42, MINECART_ABSTRACT),
FURNACE_MINECART(45, MINECART_ABSTRACT),
COMMAND_BLOCK_MINECART(44, MINECART_ABSTRACT),
TNT_MINECART(48, MINECART_ABSTRACT),
SPAWNER_MINECART(47, MINECART_ABSTRACT),
BOAT(6, ENTITY);
private static final EntityType[] TYPES;
private final int id;
private final EntityType parent;
Entity1_15Types(int id) {
this.id = id;
this.parent = null;
}
Entity1_15Types(int id, EntityType parent) {
this.id = id;
this.parent = parent;
}
@Override
public int getId() {
return id;
}
@Override
public EntityType getParent() {
return parent;
}
static {
TYPES = EntityTypeUtil.toOrderedArray(values());
}
public static EntityType getTypeFromId(int typeId) {
return EntityTypeUtil.getTypeFromId(TYPES, typeId, ENTITY);
}
}
@@ -0,0 +1,241 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.entities;
import com.viaversion.viaversion.util.EntityTypeUtil;
public enum Entity1_16Types implements EntityType {
ENTITY(-1),
AREA_EFFECT_CLOUD(0, ENTITY),
END_CRYSTAL(18, ENTITY),
EVOKER_FANGS(23, ENTITY),
EXPERIENCE_ORB(24, ENTITY),
EYE_OF_ENDER(25, ENTITY),
FALLING_BLOCK(26, ENTITY),
FIREWORK_ROCKET(27, ENTITY),
ITEM(37, ENTITY),
LLAMA_SPIT(43, ENTITY),
TNT(63, ENTITY),
SHULKER_BULLET(70, ENTITY),
FISHING_BOBBER(106, ENTITY),
LIVINGENTITY(-1, ENTITY),
ARMOR_STAND(1, LIVINGENTITY),
PLAYER(105, LIVINGENTITY),
ABSTRACT_INSENTIENT(-1, LIVINGENTITY),
ENDER_DRAGON(19, ABSTRACT_INSENTIENT),
BEE(4, ABSTRACT_INSENTIENT),
ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT),
ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE),
VILLAGER(92, ABSTRACT_AGEABLE),
WANDERING_TRADER(94, ABSTRACT_AGEABLE),
// Animals
ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE),
DOLPHIN(13, ABSTRACT_INSENTIENT),
CHICKEN(9, ABSTRACT_ANIMAL),
COW(11, ABSTRACT_ANIMAL),
MOOSHROOM(53, COW),
PANDA(56, ABSTRACT_INSENTIENT),
PIG(59, ABSTRACT_ANIMAL),
POLAR_BEAR(62, ABSTRACT_ANIMAL),
RABBIT(65, ABSTRACT_ANIMAL),
SHEEP(68, ABSTRACT_ANIMAL),
TURTLE(90, ABSTRACT_ANIMAL),
FOX(28, ABSTRACT_ANIMAL),
ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL),
CAT(7, ABSTRACT_TAMEABLE_ANIMAL),
OCELOT(54, ABSTRACT_TAMEABLE_ANIMAL),
WOLF(99, ABSTRACT_TAMEABLE_ANIMAL),
ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL),
PARROT(57, ABSTRACT_PARROT),
// Horses
ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL),
CHESTED_HORSE(-1, ABSTRACT_HORSE),
DONKEY(14, CHESTED_HORSE),
MULE(52, CHESTED_HORSE),
LLAMA(42, CHESTED_HORSE),
TRADER_LLAMA(88, CHESTED_HORSE),
HORSE(33, ABSTRACT_HORSE),
SKELETON_HORSE(73, ABSTRACT_HORSE),
ZOMBIE_HORSE(102, ABSTRACT_HORSE),
// Golem
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE),
SNOW_GOLEM(76, ABSTRACT_GOLEM),
IRON_GOLEM(36, ABSTRACT_GOLEM),
SHULKER(69, ABSTRACT_GOLEM),
// Fish
ABSTRACT_FISHES(-1, ABSTRACT_CREATURE),
COD(10, ABSTRACT_FISHES),
PUFFERFISH(64, ABSTRACT_FISHES),
SALMON(67, ABSTRACT_FISHES),
TROPICAL_FISH(89, ABSTRACT_FISHES),
// Monsters
ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE),
BLAZE(5, ABSTRACT_MONSTER),
CREEPER(12, ABSTRACT_MONSTER),
ENDERMITE(21, ABSTRACT_MONSTER),
ENDERMAN(20, ABSTRACT_MONSTER),
GIANT(30, ABSTRACT_MONSTER),
SILVERFISH(71, ABSTRACT_MONSTER),
VEX(91, ABSTRACT_MONSTER),
WITCH(95, ABSTRACT_MONSTER),
WITHER(96, ABSTRACT_MONSTER),
RAVAGER(66, ABSTRACT_MONSTER),
PIGLIN(60, ABSTRACT_MONSTER),
HOGLIN(32, ABSTRACT_ANIMAL),
STRIDER(82, ABSTRACT_ANIMAL),
ZOGLIN(100, ABSTRACT_MONSTER),
// Illagers
ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER),
ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE),
EVOKER(22, ABSTRACT_EVO_ILLU_ILLAGER),
ILLUSIONER(35, ABSTRACT_EVO_ILLU_ILLAGER),
VINDICATOR(93, ABSTRACT_ILLAGER_BASE),
PILLAGER(61, ABSTRACT_ILLAGER_BASE),
// Skeletons
ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER),
SKELETON(72, ABSTRACT_SKELETON),
STRAY(81, ABSTRACT_SKELETON),
WITHER_SKELETON(97, ABSTRACT_SKELETON),
// Guardians
GUARDIAN(31, ABSTRACT_MONSTER),
ELDER_GUARDIAN(17, GUARDIAN),
// Spiders
SPIDER(79, ABSTRACT_MONSTER),
CAVE_SPIDER(8, SPIDER),
// Zombies
ZOMBIE(101, ABSTRACT_MONSTER),
DROWNED(16, ZOMBIE),
HUSK(34, ZOMBIE),
ZOMBIFIED_PIGLIN(104, ZOMBIE),
ZOMBIE_VILLAGER(103, ZOMBIE),
// Flying entities
ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT),
GHAST(29, ABSTRACT_FLYING),
PHANTOM(58, ABSTRACT_FLYING),
ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT),
BAT(3, ABSTRACT_AMBIENT),
ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT),
SQUID(80, ABSTRACT_WATERMOB),
// Slimes
SLIME(74, ABSTRACT_INSENTIENT),
MAGMA_CUBE(44, SLIME),
// Hangable objects
ABSTRACT_HANGING(-1, ENTITY),
LEASH_KNOT(40, ABSTRACT_HANGING),
ITEM_FRAME(38, ABSTRACT_HANGING),
PAINTING(55, ABSTRACT_HANGING),
ABSTRACT_LIGHTNING(-1, ENTITY),
LIGHTNING_BOLT(41, ABSTRACT_LIGHTNING),
// Arrows
ABSTRACT_ARROW(-1, ENTITY),
ARROW(2, ABSTRACT_ARROW),
SPECTRAL_ARROW(78, ABSTRACT_ARROW),
TRIDENT(87, ABSTRACT_ARROW),
// Fireballs
ABSTRACT_FIREBALL(-1, ENTITY),
DRAGON_FIREBALL(15, ABSTRACT_FIREBALL),
FIREBALL(39, ABSTRACT_FIREBALL),
SMALL_FIREBALL(75, ABSTRACT_FIREBALL),
WITHER_SKULL(98, ABSTRACT_FIREBALL),
// Projectiles
PROJECTILE_ABSTRACT(-1, ENTITY),
SNOWBALL(77, PROJECTILE_ABSTRACT),
ENDER_PEARL(84, PROJECTILE_ABSTRACT),
EGG(83, PROJECTILE_ABSTRACT),
POTION(86, PROJECTILE_ABSTRACT),
EXPERIENCE_BOTTLE(85, PROJECTILE_ABSTRACT),
// Vehicles
MINECART_ABSTRACT(-1, ENTITY),
CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT),
CHEST_MINECART(46, CHESTED_MINECART_ABSTRACT),
HOPPER_MINECART(49, CHESTED_MINECART_ABSTRACT),
MINECART(45, MINECART_ABSTRACT),
FURNACE_MINECART(48, MINECART_ABSTRACT),
COMMAND_BLOCK_MINECART(47, MINECART_ABSTRACT),
TNT_MINECART(51, MINECART_ABSTRACT),
SPAWNER_MINECART(50, MINECART_ABSTRACT),
BOAT(6, ENTITY);
private static final EntityType[] TYPES;
private final int id;
private final EntityType parent;
Entity1_16Types(int id) {
this.id = id;
this.parent = null;
}
Entity1_16Types(int id, EntityType parent) {
this.id = id;
this.parent = parent;
}
@Override
public int getId() {
return id;
}
@Override
public EntityType getParent() {
return parent;
}
static {
TYPES = EntityTypeUtil.toOrderedArray(values());
}
public static EntityType getTypeFromId(int typeId) {
return EntityTypeUtil.getTypeFromId(TYPES, typeId, ENTITY);
}
}
@@ -0,0 +1,245 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.entities;
import com.viaversion.viaversion.util.EntityTypeUtil;
public enum Entity1_16_2Types implements EntityType {
ENTITY(-1),
AREA_EFFECT_CLOUD(0, ENTITY),
END_CRYSTAL(18, ENTITY),
EVOKER_FANGS(23, ENTITY),
EXPERIENCE_ORB(24, ENTITY),
EYE_OF_ENDER(25, ENTITY),
FALLING_BLOCK(26, ENTITY),
FIREWORK_ROCKET(27, ENTITY),
ITEM(37, ENTITY),
LLAMA_SPIT(43, ENTITY),
TNT(64, ENTITY),
SHULKER_BULLET(71, ENTITY),
FISHING_BOBBER(107, ENTITY),
LIVINGENTITY(-1, ENTITY),
ARMOR_STAND(1, LIVINGENTITY),
PLAYER(106, LIVINGENTITY),
ABSTRACT_INSENTIENT(-1, LIVINGENTITY),
ENDER_DRAGON(19, ABSTRACT_INSENTIENT),
BEE(4, ABSTRACT_INSENTIENT),
ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT),
ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE),
VILLAGER(93, ABSTRACT_AGEABLE),
WANDERING_TRADER(95, ABSTRACT_AGEABLE),
// Animals
ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE),
DOLPHIN(13, ABSTRACT_INSENTIENT),
CHICKEN(9, ABSTRACT_ANIMAL),
COW(11, ABSTRACT_ANIMAL),
MOOSHROOM(53, COW),
PANDA(56, ABSTRACT_INSENTIENT),
PIG(59, ABSTRACT_ANIMAL),
POLAR_BEAR(63, ABSTRACT_ANIMAL),
RABBIT(66, ABSTRACT_ANIMAL),
SHEEP(69, ABSTRACT_ANIMAL),
TURTLE(91, ABSTRACT_ANIMAL),
FOX(28, ABSTRACT_ANIMAL),
ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL),
CAT(7, ABSTRACT_TAMEABLE_ANIMAL),
OCELOT(54, ABSTRACT_TAMEABLE_ANIMAL),
WOLF(100, ABSTRACT_TAMEABLE_ANIMAL),
ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL),
PARROT(57, ABSTRACT_PARROT),
// Horses
ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL),
CHESTED_HORSE(-1, ABSTRACT_HORSE),
DONKEY(14, CHESTED_HORSE),
MULE(52, CHESTED_HORSE),
LLAMA(42, CHESTED_HORSE),
TRADER_LLAMA(89, CHESTED_HORSE),
HORSE(33, ABSTRACT_HORSE),
SKELETON_HORSE(74, ABSTRACT_HORSE),
ZOMBIE_HORSE(103, ABSTRACT_HORSE),
// Golem
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE),
SNOW_GOLEM(77, ABSTRACT_GOLEM),
IRON_GOLEM(36, ABSTRACT_GOLEM),
SHULKER(70, ABSTRACT_GOLEM),
// Fish
ABSTRACT_FISHES(-1, ABSTRACT_CREATURE),
COD(10, ABSTRACT_FISHES),
PUFFERFISH(65, ABSTRACT_FISHES),
SALMON(68, ABSTRACT_FISHES),
TROPICAL_FISH(90, ABSTRACT_FISHES),
// Monsters
ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE),
BLAZE(5, ABSTRACT_MONSTER),
CREEPER(12, ABSTRACT_MONSTER),
ENDERMITE(21, ABSTRACT_MONSTER),
ENDERMAN(20, ABSTRACT_MONSTER),
GIANT(30, ABSTRACT_MONSTER),
SILVERFISH(72, ABSTRACT_MONSTER),
VEX(92, ABSTRACT_MONSTER),
WITCH(96, ABSTRACT_MONSTER),
WITHER(97, ABSTRACT_MONSTER),
RAVAGER(67, ABSTRACT_MONSTER),
ABSTRACT_PIGLIN(-1, ABSTRACT_MONSTER),
PIGLIN(60, ABSTRACT_PIGLIN),
PIGLIN_BRUTE(61, ABSTRACT_PIGLIN),
HOGLIN(32, ABSTRACT_ANIMAL),
STRIDER(83, ABSTRACT_ANIMAL),
ZOGLIN(101, ABSTRACT_MONSTER),
// Illagers
ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER),
ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE),
EVOKER(22, ABSTRACT_EVO_ILLU_ILLAGER),
ILLUSIONER(35, ABSTRACT_EVO_ILLU_ILLAGER),
VINDICATOR(94, ABSTRACT_ILLAGER_BASE),
PILLAGER(62, ABSTRACT_ILLAGER_BASE),
// Skeletons
ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER),
SKELETON(73, ABSTRACT_SKELETON),
STRAY(82, ABSTRACT_SKELETON),
WITHER_SKELETON(98, ABSTRACT_SKELETON),
// Guardians
GUARDIAN(31, ABSTRACT_MONSTER),
ELDER_GUARDIAN(17, GUARDIAN),
// Spiders
SPIDER(80, ABSTRACT_MONSTER),
CAVE_SPIDER(8, SPIDER),
// Zombies
ZOMBIE(102, ABSTRACT_MONSTER),
DROWNED(16, ZOMBIE),
HUSK(34, ZOMBIE),
ZOMBIFIED_PIGLIN(105, ZOMBIE),
ZOMBIE_VILLAGER(104, ZOMBIE),
// Flying entities
ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT),
GHAST(29, ABSTRACT_FLYING),
PHANTOM(58, ABSTRACT_FLYING),
ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT),
BAT(3, ABSTRACT_AMBIENT),
ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT),
SQUID(81, ABSTRACT_WATERMOB),
// Slimes
SLIME(75, ABSTRACT_INSENTIENT),
MAGMA_CUBE(44, SLIME),
// Hangable objects
ABSTRACT_HANGING(-1, ENTITY),
LEASH_KNOT(40, ABSTRACT_HANGING),
ITEM_FRAME(38, ABSTRACT_HANGING),
PAINTING(55, ABSTRACT_HANGING),
ABSTRACT_LIGHTNING(-1, ENTITY),
LIGHTNING_BOLT(41, ABSTRACT_LIGHTNING),
// Arrows
ABSTRACT_ARROW(-1, ENTITY),
ARROW(2, ABSTRACT_ARROW),
SPECTRAL_ARROW(79, ABSTRACT_ARROW),
TRIDENT(88, ABSTRACT_ARROW),
// Fireballs
ABSTRACT_FIREBALL(-1, ENTITY),
DRAGON_FIREBALL(15, ABSTRACT_FIREBALL),
FIREBALL(39, ABSTRACT_FIREBALL),
SMALL_FIREBALL(76, ABSTRACT_FIREBALL),
WITHER_SKULL(99, ABSTRACT_FIREBALL),
// Projectiles
PROJECTILE_ABSTRACT(-1, ENTITY),
SNOWBALL(78, PROJECTILE_ABSTRACT),
ENDER_PEARL(85, PROJECTILE_ABSTRACT),
EGG(84, PROJECTILE_ABSTRACT),
POTION(87, PROJECTILE_ABSTRACT),
EXPERIENCE_BOTTLE(86, PROJECTILE_ABSTRACT),
// Vehicles
MINECART_ABSTRACT(-1, ENTITY),
CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT),
CHEST_MINECART(46, CHESTED_MINECART_ABSTRACT),
HOPPER_MINECART(49, CHESTED_MINECART_ABSTRACT),
MINECART(45, MINECART_ABSTRACT),
FURNACE_MINECART(48, MINECART_ABSTRACT),
COMMAND_BLOCK_MINECART(47, MINECART_ABSTRACT),
TNT_MINECART(51, MINECART_ABSTRACT),
SPAWNER_MINECART(50, MINECART_ABSTRACT),
BOAT(6, ENTITY);
private static final EntityType[] TYPES;
private final int id;
private final EntityType parent;
Entity1_16_2Types(int id) {
this.id = id;
this.parent = null;
}
Entity1_16_2Types(int id, EntityType parent) {
this.id = id;
this.parent = parent;
}
@Override
public int getId() {
return id;
}
@Override
public EntityType getParent() {
return parent;
}
static {
TYPES = EntityTypeUtil.toOrderedArray(values());
}
public static EntityType getTypeFromId(int typeId) {
return EntityTypeUtil.getTypeFromId(TYPES, typeId, ENTITY);
}
}
@@ -0,0 +1,250 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.entities;
import com.viaversion.viaversion.util.EntityTypeUtil;
public enum Entity1_17Types implements EntityType {
ENTITY(-1),
AREA_EFFECT_CLOUD(0, ENTITY),
END_CRYSTAL(19, ENTITY),
EVOKER_FANGS(24, ENTITY),
EXPERIENCE_ORB(25, ENTITY),
EYE_OF_ENDER(26, ENTITY),
FALLING_BLOCK(27, ENTITY),
FIREWORK_ROCKET(28, ENTITY),
ITEM(41, ENTITY),
LLAMA_SPIT(47, ENTITY),
TNT(69, ENTITY),
SHULKER_BULLET(76, ENTITY),
FISHING_BOBBER(112, ENTITY),
LIVINGENTITY(-1, ENTITY),
ARMOR_STAND(1, LIVINGENTITY),
MARKER(49, ENTITY),
PLAYER(111, LIVINGENTITY),
ABSTRACT_INSENTIENT(-1, LIVINGENTITY),
ENDER_DRAGON(20, ABSTRACT_INSENTIENT),
BEE(5, ABSTRACT_INSENTIENT),
ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT),
ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE),
VILLAGER(98, ABSTRACT_AGEABLE),
WANDERING_TRADER(100, ABSTRACT_AGEABLE),
// Animals
ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE),
AXOLOTL(3, ABSTRACT_ANIMAL),
DOLPHIN(14, ABSTRACT_INSENTIENT),
CHICKEN(10, ABSTRACT_ANIMAL),
COW(12, ABSTRACT_ANIMAL),
MOOSHROOM(58, COW),
PANDA(61, ABSTRACT_INSENTIENT),
PIG(64, ABSTRACT_ANIMAL),
POLAR_BEAR(68, ABSTRACT_ANIMAL),
RABBIT(71, ABSTRACT_ANIMAL),
SHEEP(74, ABSTRACT_ANIMAL),
TURTLE(96, ABSTRACT_ANIMAL),
FOX(29, ABSTRACT_ANIMAL),
GOAT(34, ABSTRACT_ANIMAL),
ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL),
CAT(8, ABSTRACT_TAMEABLE_ANIMAL),
OCELOT(59, ABSTRACT_TAMEABLE_ANIMAL),
WOLF(105, ABSTRACT_TAMEABLE_ANIMAL),
ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL),
PARROT(62, ABSTRACT_PARROT),
// Horses
ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL),
CHESTED_HORSE(-1, ABSTRACT_HORSE),
DONKEY(15, CHESTED_HORSE),
MULE(57, CHESTED_HORSE),
LLAMA(46, CHESTED_HORSE),
TRADER_LLAMA(94, CHESTED_HORSE),
HORSE(37, ABSTRACT_HORSE),
SKELETON_HORSE(79, ABSTRACT_HORSE),
ZOMBIE_HORSE(108, ABSTRACT_HORSE),
// Golem
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE),
SNOW_GOLEM(82, ABSTRACT_GOLEM),
IRON_GOLEM(40, ABSTRACT_GOLEM),
SHULKER(75, ABSTRACT_GOLEM),
// Fish
ABSTRACT_FISHES(-1, ABSTRACT_CREATURE),
COD(11, ABSTRACT_FISHES),
PUFFERFISH(70, ABSTRACT_FISHES),
SALMON(73, ABSTRACT_FISHES),
TROPICAL_FISH(95, ABSTRACT_FISHES),
// Monsters
ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE),
BLAZE(6, ABSTRACT_MONSTER),
CREEPER(13, ABSTRACT_MONSTER),
ENDERMITE(22, ABSTRACT_MONSTER),
ENDERMAN(21, ABSTRACT_MONSTER),
GIANT(31, ABSTRACT_MONSTER),
SILVERFISH(77, ABSTRACT_MONSTER),
VEX(97, ABSTRACT_MONSTER),
WITCH(101, ABSTRACT_MONSTER),
WITHER(102, ABSTRACT_MONSTER),
RAVAGER(72, ABSTRACT_MONSTER),
ABSTRACT_PIGLIN(-1, ABSTRACT_MONSTER),
PIGLIN(65, ABSTRACT_PIGLIN),
PIGLIN_BRUTE(66, ABSTRACT_PIGLIN),
HOGLIN(36, ABSTRACT_ANIMAL),
STRIDER(88, ABSTRACT_ANIMAL),
ZOGLIN(106, ABSTRACT_MONSTER),
// Illagers
ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER),
ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE),
EVOKER(23, ABSTRACT_EVO_ILLU_ILLAGER),
ILLUSIONER(39, ABSTRACT_EVO_ILLU_ILLAGER),
VINDICATOR(99, ABSTRACT_ILLAGER_BASE),
PILLAGER(67, ABSTRACT_ILLAGER_BASE),
// Skeletons
ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER),
SKELETON(78, ABSTRACT_SKELETON),
STRAY(87, ABSTRACT_SKELETON),
WITHER_SKELETON(103, ABSTRACT_SKELETON),
// Guardians
GUARDIAN(35, ABSTRACT_MONSTER),
ELDER_GUARDIAN(18, GUARDIAN),
// Spiders
SPIDER(85, ABSTRACT_MONSTER),
CAVE_SPIDER(9, SPIDER),
// Zombies
ZOMBIE(107, ABSTRACT_MONSTER),
DROWNED(17, ZOMBIE),
HUSK(38, ZOMBIE),
ZOMBIFIED_PIGLIN(110, ZOMBIE),
ZOMBIE_VILLAGER(109, ZOMBIE),
// Flying entities
ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT),
GHAST(30, ABSTRACT_FLYING),
PHANTOM(63, ABSTRACT_FLYING),
ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT),
BAT(4, ABSTRACT_AMBIENT),
ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT),
SQUID(86, ABSTRACT_WATERMOB),
GLOW_SQUID(33, SQUID),
// Slimes
SLIME(80, ABSTRACT_INSENTIENT),
MAGMA_CUBE(48, SLIME),
// Hangable objects
ABSTRACT_HANGING(-1, ENTITY),
LEASH_KNOT(44, ABSTRACT_HANGING),
ITEM_FRAME(42, ABSTRACT_HANGING),
GLOW_ITEM_FRAME(32, ITEM_FRAME),
PAINTING(60, ABSTRACT_HANGING),
ABSTRACT_LIGHTNING(-1, ENTITY),
LIGHTNING_BOLT(45, ABSTRACT_LIGHTNING),
// Arrows
ABSTRACT_ARROW(-1, ENTITY),
ARROW(2, ABSTRACT_ARROW),
SPECTRAL_ARROW(84, ABSTRACT_ARROW),
TRIDENT(93, ABSTRACT_ARROW),
// Fireballs
ABSTRACT_FIREBALL(-1, ENTITY),
DRAGON_FIREBALL(16, ABSTRACT_FIREBALL),
FIREBALL(43, ABSTRACT_FIREBALL),
SMALL_FIREBALL(81, ABSTRACT_FIREBALL),
WITHER_SKULL(104, ABSTRACT_FIREBALL),
// Projectiles
PROJECTILE_ABSTRACT(-1, ENTITY),
SNOWBALL(83, PROJECTILE_ABSTRACT),
ENDER_PEARL(90, PROJECTILE_ABSTRACT),
EGG(89, PROJECTILE_ABSTRACT),
POTION(92, PROJECTILE_ABSTRACT),
EXPERIENCE_BOTTLE(91, PROJECTILE_ABSTRACT),
// Vehicles
MINECART_ABSTRACT(-1, ENTITY),
CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT),
CHEST_MINECART(51, CHESTED_MINECART_ABSTRACT),
HOPPER_MINECART(54, CHESTED_MINECART_ABSTRACT),
MINECART(50, MINECART_ABSTRACT),
FURNACE_MINECART(53, MINECART_ABSTRACT),
COMMAND_BLOCK_MINECART(52, MINECART_ABSTRACT),
TNT_MINECART(56, MINECART_ABSTRACT),
SPAWNER_MINECART(55, MINECART_ABSTRACT),
BOAT(7, ENTITY);
private static final EntityType[] TYPES;
private final int id;
private final EntityType parent;
Entity1_17Types(int id) {
this.id = id;
this.parent = null;
}
Entity1_17Types(int id, EntityType parent) {
this.id = id;
this.parent = parent;
}
@Override
public int getId() {
return id;
}
@Override
public EntityType getParent() {
return parent;
}
static {
TYPES = EntityTypeUtil.toOrderedArray(values());
}
public static EntityType getTypeFromId(int typeId) {
return EntityTypeUtil.getTypeFromId(TYPES, typeId, ENTITY);
}
}
@@ -0,0 +1,82 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.entities;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface EntityType {
/**
* Returns the entity id.
*
* @return entity id
*/
int getId();
/**
* Returns the parent entity type if present.
*
* @return parent entity type if present
*/
@Nullable EntityType getParent();
/**
* Returns the entity type name, not necessarily matching the Vanilla type name.
*
* @return entity type name
*/
String name();
default boolean is(EntityType... types) {
for (EntityType type : types) {
if (this == type) {
return true;
}
}
return false;
}
default boolean is(EntityType type) {
return this == type;
}
/**
* Returns whether the current type is equal to the given type, or has it as a parent type.
*
* @param type entity type to check against
* @return true if the current type is equal to the given type, or has it as a parent type
*/
default boolean isOrHasParent(EntityType type) {
EntityType parent = this;
do {
if (parent == type) {
return true;
}
parent = parent.getParent();
} while (parent != null);
return false;
}
}
@@ -0,0 +1,33 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.entities;
/**
* Represents a legacy object entity type.
*/
public interface ObjectType {
int getId();
EntityType getType();
}
@@ -0,0 +1,124 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.item;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.google.gson.annotations.SerializedName;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Objects;
public class DataItem implements Item {
@SerializedName(value = "identifier", alternate = "id")
private int identifier;
private byte amount;
private short data;
private CompoundTag tag;
public DataItem() {
}
public DataItem(int identifier, byte amount, short data, @Nullable CompoundTag tag) {
this.identifier = identifier;
this.amount = amount;
this.data = data;
this.tag = tag;
}
public DataItem(Item toCopy) {
this(toCopy.identifier(), (byte) toCopy.amount(), toCopy.data(), toCopy.tag());
}
@Override
public int identifier() {
return identifier;
}
@Override
public void setIdentifier(int identifier) {
this.identifier = identifier;
}
@Override
public int amount() {
return amount;
}
@Override
public void setAmount(int amount) {
if (amount > Byte.MAX_VALUE || amount < Byte.MIN_VALUE) {
throw new IllegalArgumentException("Invalid item amount: " + amount);
}
this.amount = (byte) amount;
}
@Override
public short data() {
return data;
}
@Override
public void setData(short data) {
this.data = data;
}
@Override
public @Nullable CompoundTag tag() {
return tag;
}
@Override
public void setTag(@Nullable CompoundTag tag) {
this.tag = tag;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DataItem item = (DataItem) o;
if (identifier != item.identifier) return false;
if (amount != item.amount) return false;
if (data != item.data) return false;
return Objects.equals(tag, item.tag);
}
@Override
public int hashCode() {
int result = identifier;
result = 31 * result + (int) amount;
result = 31 * result + (int) data;
result = 31 * result + (tag != null ? tag.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "Item{" +
"identifier=" + identifier +
", amount=" + amount +
", data=" + data +
", tag=" + tag +
'}';
}
}
@@ -0,0 +1,90 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.item;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface Item {
/**
* Returns the item identifier.
*
* @return item identifier
*/
int identifier();
/**
* Sets the item identifier.
*
* @param identifier item identifier
*/
void setIdentifier(int identifier);
/**
* Returns the item amount.
*
* @return item amount
*/
int amount();
/**
* Returns the item amount.
*
* @param amount item amount
*/
void setAmount(int amount);
/**
* Returns the item data. Always 0 for 1.13+ items.
*
* @return item data
*/
default short data() {
return 0;
}
/**
* Sets the item data used in versions before 1.13.
*
* @param data item data
* @throws UnsupportedOperationException if the item implementation does not store data
*/
default void setData(short data) {
throw new UnsupportedOperationException();
}
/**
* Returns the item compound tag if present.
*
* @return item tag
*/
@Nullable CompoundTag tag();
/**
* Sets the item compound tag.
*
* @param tag item tag
*/
void setTag(@Nullable CompoundTag tag);
}
@@ -0,0 +1,42 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.metadata;
import com.viaversion.viaversion.api.type.Type;
public interface MetaType {
/**
* Get the write/read type
*
* @return Type instance
*/
Type type();
/**
* Get type id from the specific MetaDataType
*
* @return Type id as an integer
*/
int typeId();
}
@@ -0,0 +1,144 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.metadata;
import com.google.common.base.Preconditions;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Objects;
public final class Metadata {
private int id;
private MetaType metaType;
private Object value;
/**
* Creates a new metadata instance.
*
* @param id metadata index
* @param metaType metadata type
* @param value value if present
* @throws IllegalArgumentException if the value and metaType are incompatible
*/
public Metadata(int id, MetaType metaType, @Nullable Object value) {
this.id = id;
this.metaType = metaType;
this.value = checkValue(metaType, value);
}
public int id() {
return id;
}
public void setId(int id) {
this.id = id;
}
public MetaType metaType() {
return metaType;
}
/**
* Sets the metadata type if compatible with the current value.
*
* @param metaType metadata type
* @throws IllegalArgumentException if the metadata type and current value are incompatible
* @see #setTypeAndValue(MetaType, Object)
*/
public void setMetaType(MetaType metaType) {
checkValue(metaType, this.value);
this.metaType = metaType;
}
public @Nullable <T> T value() {
return (T) value;
}
public @Nullable Object getValue() {
return value;
}
/**
* Sets the metadata value if compatible with the current meta type.
*
* @param value value
* @throws IllegalArgumentException if the value and current metaType are incompatible
* @see #setTypeAndValue(MetaType, Object)
*/
public void setValue(@Nullable Object value) {
this.value = checkValue(this.metaType, value);
}
/**
* Sets metadata type and value.
*
* @param metaType metadata type
* @param value value
* @throws IllegalArgumentException if the value and metaType are incompatible
*/
public void setTypeAndValue(MetaType metaType, @Nullable Object value) {
this.value = checkValue(metaType, value);
this.metaType = metaType;
}
private Object checkValue(MetaType metaType, @Nullable Object value) {
Preconditions.checkNotNull(metaType);
if (value != null && !metaType.type().getOutputClass().isAssignableFrom(value.getClass())) {
throw new IllegalArgumentException("Metadata value and metaType are incompatible. Type=" + metaType
+ ", value=" + (value != null ? value + " (" + value.getClass().getSimpleName() + ")" : "null"));
}
return value;
}
@Deprecated
public void setMetaTypeUnsafe(MetaType type) {
this.metaType = type;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Metadata metadata = (Metadata) o;
if (id != metadata.id) return false;
if (metaType != metaType) return false;
return Objects.equals(value, metadata.value);
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + metaType.hashCode();
result = 31 * result + (value != null ? value.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "Metadata{" +
"id=" + id +
", metaType=" + metaType +
", value=" + value +
'}';
}
}
@@ -0,0 +1,65 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.metadata.types;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.Type;
public enum MetaType1_12 implements MetaType {
Byte(0, Type.BYTE),
VarInt(1, Type.VAR_INT),
Float(2, Type.FLOAT),
String(3, Type.STRING),
Chat(4, Type.COMPONENT),
Slot(5, Type.ITEM),
Boolean(6, Type.BOOLEAN),
Vector3F(7, Type.ROTATION),
Position(8, Type.POSITION),
OptPosition(9, Type.OPTIONAL_POSITION),
Direction(10, Type.VAR_INT),
OptUUID(11, Type.OPTIONAL_UUID),
BlockID(12, Type.VAR_INT),
NBTTag(13, Type.NBT);
private final int typeID;
private final Type type;
MetaType1_12(int typeID, Type type) {
this.typeID = typeID;
this.type = type;
}
public static MetaType1_12 byId(int id) {
return values()[id];
}
@Override
public int typeId() {
return typeID;
}
@Override
public Type type() {
return type;
}
}
@@ -0,0 +1,68 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.metadata.types;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_13;
public enum MetaType1_13 implements MetaType {
Byte(0, Type.BYTE),
VarInt(1, Type.VAR_INT),
Float(2, Type.FLOAT),
String(3, Type.STRING),
Chat(4, Type.COMPONENT),
OptChat(5, Type.OPTIONAL_COMPONENT),
Slot(6, Type.FLAT_ITEM),
Boolean(7, Type.BOOLEAN),
Vector3F(8, Type.ROTATION),
Position(9, Type.POSITION),
OptPosition(10, Type.OPTIONAL_POSITION),
Direction(11, Type.VAR_INT),
OptUUID(12, Type.OPTIONAL_UUID),
BlockID(13, Type.VAR_INT),
NBTTag(14, Type.NBT),
PARTICLE(15, Types1_13.PARTICLE);
private final int typeID;
private final Type type;
MetaType1_13(int typeID, Type type) {
this.typeID = typeID;
this.type = type;
}
public static MetaType1_13 byId(int id) {
return values()[id];
}
@Override
public int typeId() {
return typeID;
}
@Override
public Type type() {
return type;
}
}
@@ -0,0 +1,68 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.metadata.types;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
public enum MetaType1_13_2 implements MetaType {
Byte(0, Type.BYTE),
VarInt(1, Type.VAR_INT),
Float(2, Type.FLOAT),
String(3, Type.STRING),
Chat(4, Type.COMPONENT),
OptChat(5, Type.OPTIONAL_COMPONENT),
Slot(6, Type.FLAT_VAR_INT_ITEM),
Boolean(7, Type.BOOLEAN),
Vector3F(8, Type.ROTATION),
Position(9, Type.POSITION),
OptPosition(10, Type.OPTIONAL_POSITION),
Direction(11, Type.VAR_INT),
OptUUID(12, Type.OPTIONAL_UUID),
BlockID(13, Type.VAR_INT),
NBTTag(14, Type.NBT),
PARTICLE(15, Types1_13_2.PARTICLE);
private final int typeID;
private final Type type;
MetaType1_13_2(int typeID, Type type) {
this.typeID = typeID;
this.type = type;
}
public static MetaType1_13_2 byId(int id) {
return values()[id];
}
@Override
public int typeId() {
return typeID;
}
@Override
public Type type() {
return type;
}
}
@@ -0,0 +1,71 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.metadata.types;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_14;
public enum MetaType1_14 implements MetaType {
Byte(0, Type.BYTE),
VarInt(1, Type.VAR_INT),
Float(2, Type.FLOAT),
String(3, Type.STRING),
Chat(4, Type.COMPONENT),
OptChat(5, Type.OPTIONAL_COMPONENT),
Slot(6, Type.FLAT_VAR_INT_ITEM),
Boolean(7, Type.BOOLEAN),
Vector3F(8, Type.ROTATION),
Position(9, Type.POSITION1_14),
OptPosition(10, Type.OPTIONAL_POSITION_1_14),
Direction(11, Type.VAR_INT),
OptUUID(12, Type.OPTIONAL_UUID),
BlockID(13, Type.VAR_INT),
NBTTag(14, Type.NBT),
PARTICLE(15, Types1_14.PARTICLE),
VillagerData(16, Type.VILLAGER_DATA),
OptVarInt(17, Type.OPTIONAL_VAR_INT),
Pose(18, Type.VAR_INT);
private final int typeID;
private final Type type;
MetaType1_14(int typeID, Type type) {
this.typeID = typeID;
this.type = type;
}
public static MetaType1_14 byId(int id) {
return values()[id];
}
@Override
public int typeId() {
return typeID;
}
@Override
public Type type() {
return type;
}
}
@@ -0,0 +1,72 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.metadata.types;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_17;
public enum MetaType1_17 implements MetaType {
BYTE(0, Type.BYTE),
VAR_INT(1, Type.VAR_INT),
FLOAT(2, Type.FLOAT),
STRING(3, Type.STRING),
COMPONENT(4, Type.COMPONENT),
OPT_COMPONENT(5, Type.OPTIONAL_COMPONENT),
ITEM(6, Type.FLAT_VAR_INT_ITEM),
BOOLEAN(7, Type.BOOLEAN),
ROTATION(8, Type.ROTATION),
POSITION(9, Type.POSITION1_14),
OPT_POSITION(10, Type.OPTIONAL_POSITION_1_14),
DIRECTION(11, Type.VAR_INT),
OPT_UUID(12, Type.OPTIONAL_UUID),
BLOCK_STATE(13, Type.VAR_INT),
NBT(14, Type.NBT),
PARTICLE(15, Types1_17.PARTICLE),
VILLAGER_DATA(16, Type.VILLAGER_DATA),
OPT_VAR_INT(17, Type.OPTIONAL_VAR_INT),
POSE(18, Type.VAR_INT);
private static final MetaType1_17[] VALUES = values();
private final int typeId;
private final Type type;
MetaType1_17(int typeId, Type type) {
this.typeId = typeId;
this.type = type;
}
public static MetaType1_17 byId(int id) {
return VALUES[id];
}
@Override
public int typeId() {
return typeId;
}
@Override
public Type type() {
return type;
}
}
@@ -0,0 +1,61 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.metadata.types;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.Type;
public enum MetaType1_8 implements MetaType {
Byte(0, Type.BYTE),
Short(1, Type.SHORT),
Int(2, Type.INT),
Float(3, Type.FLOAT),
String(4, Type.STRING),
Slot(5, Type.ITEM),
Position(6, Type.VECTOR),
Rotation(7, Type.ROTATION),
@Deprecated
NonExistent(-1, Type.NOTHING);
private final int typeID;
private final Type type;
MetaType1_8(int typeID, Type type) {
this.typeID = typeID;
this.type = type;
}
public static MetaType1_8 byId(int id) {
return values()[id];
}
@Override
public int typeId() {
return typeID;
}
@Override
public Type type() {
return type;
}
}
@@ -0,0 +1,64 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.metadata.types;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.Type;
public enum MetaType1_9 implements MetaType {
Byte(0, Type.BYTE),
VarInt(1, Type.VAR_INT),
Float(2, Type.FLOAT),
String(3, Type.STRING),
Chat(4, Type.COMPONENT),
Slot(5, Type.ITEM),
Boolean(6, Type.BOOLEAN),
Vector3F(7, Type.ROTATION),
Position(8, Type.POSITION),
OptPosition(9, Type.OPTIONAL_POSITION),
Direction(10, Type.VAR_INT),
OptUUID(11, Type.OPTIONAL_UUID),
BlockID(12, Type.VAR_INT);
private final int typeID;
private final Type type;
MetaType1_9(int typeID, Type type) {
this.typeID = typeID;
this.type = type;
}
public static MetaType1_9 byId(int id) {
return values()[id];
}
@Override
public int typeId() {
return typeID;
}
@Override
public Type type() {
return type;
}
}
@@ -21,11 +21,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api.minecraft.nbt;
package com.viaversion.viaversion.api.minecraft.nbt;
import com.github.steveice10.opennbt.tag.TagRegistry;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import org.jetbrains.annotations.NotNull;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.io.BufferedInputStream;
import java.io.DataInput;
@@ -54,8 +53,7 @@ public final class BinaryTagIO {
* @return the compound tag
* @throws IOException if an exception was encountered while reading a compound tag
*/
@NotNull
public static CompoundTag readPath(final @NotNull Path path) throws IOException {
public static @NonNull CompoundTag readPath(final @NonNull Path path) throws IOException {
return readInputStream(Files.newInputStream(path));
}
@@ -66,8 +64,7 @@ public final class BinaryTagIO {
* @return the compound tag
* @throws IOException if an exception was encountered while reading a compound tag
*/
@NotNull
public static CompoundTag readInputStream(final @NotNull InputStream input) throws IOException {
public static @NonNull CompoundTag readInputStream(final @NonNull InputStream input) throws IOException {
try (final DataInputStream dis = new DataInputStream(input)) {
return readDataInput(dis);
}
@@ -80,8 +77,7 @@ public final class BinaryTagIO {
* @return the compound tag
* @throws IOException if an exception was encountered while reading a compound tag
*/
@NotNull
public static CompoundTag readCompressedPath(final @NotNull Path path) throws IOException {
public static @NonNull CompoundTag readCompressedPath(final @NonNull Path path) throws IOException {
return readCompressedInputStream(Files.newInputStream(path));
}
@@ -92,8 +88,7 @@ public final class BinaryTagIO {
* @return the compound tag
* @throws IOException if an exception was encountered while reading a compound tag
*/
@NotNull
public static CompoundTag readCompressedInputStream(final @NotNull InputStream input) throws IOException {
public static @NonNull CompoundTag readCompressedInputStream(final @NonNull InputStream input) throws IOException {
try (final DataInputStream dis = new DataInputStream(new BufferedInputStream(new GZIPInputStream(input)))) {
return readDataInput(dis);
}
@@ -106,15 +101,14 @@ public final class BinaryTagIO {
* @return the compound tag
* @throws IOException if an exception was encountered while reading a compound tag
*/
@NotNull
public static CompoundTag readDataInput(final @NotNull DataInput input) throws IOException {
public static @NonNull CompoundTag readDataInput(final @NonNull DataInput input) throws IOException {
byte type = input.readByte();
if (type != TagRegistry.getIdFor(CompoundTag.class)) {
if (type != CompoundTag.ID) {
throw new IOException(String.format("Expected root tag to be a CompoundTag, was %s", type));
}
input.skipBytes(input.readUnsignedShort()); // read empty name
final CompoundTag compoundTag = new CompoundTag("");
final CompoundTag compoundTag = new CompoundTag();
compoundTag.read(input);
return compoundTag;
}
@@ -126,7 +120,7 @@ public final class BinaryTagIO {
* @param path the path
* @throws IOException if an exception was encountered while writing the compound tag
*/
public static void writePath(final @NotNull CompoundTag tag, final @NotNull Path path) throws IOException {
public static void writePath(final @NonNull CompoundTag tag, final @NonNull Path path) throws IOException {
writeOutputStream(tag, Files.newOutputStream(path));
}
@@ -137,7 +131,7 @@ public final class BinaryTagIO {
* @param output the output stream
* @throws IOException if an exception was encountered while writing the compound tag
*/
public static void writeOutputStream(final @NotNull CompoundTag tag, final @NotNull OutputStream output) throws IOException {
public static void writeOutputStream(final @NonNull CompoundTag tag, final @NonNull OutputStream output) throws IOException {
try (final DataOutputStream dos = new DataOutputStream(output)) {
writeDataOutput(tag, dos);
}
@@ -150,7 +144,7 @@ public final class BinaryTagIO {
* @param path the path
* @throws IOException if an exception was encountered while writing the compound tag
*/
public static void writeCompressedPath(final @NotNull CompoundTag tag, final @NotNull Path path) throws IOException {
public static void writeCompressedPath(final @NonNull CompoundTag tag, final @NonNull Path path) throws IOException {
writeCompressedOutputStream(tag, Files.newOutputStream(path));
}
@@ -161,7 +155,7 @@ public final class BinaryTagIO {
* @param output the output stream
* @throws IOException if an exception was encountered while writing the compound tag
*/
public static void writeCompressedOutputStream(final @NotNull CompoundTag tag, final @NotNull OutputStream output) throws IOException {
public static void writeCompressedOutputStream(final @NonNull CompoundTag tag, final @NonNull OutputStream output) throws IOException {
try (final DataOutputStream dos = new DataOutputStream(new GZIPOutputStream(output))) {
writeDataOutput(tag, dos);
}
@@ -174,8 +168,8 @@ public final class BinaryTagIO {
* @param output the output
* @throws IOException if an exception was encountered while writing the compound tag
*/
public static void writeDataOutput(final @NotNull CompoundTag tag, final @NotNull DataOutput output) throws IOException {
output.writeByte(TagRegistry.getIdFor(CompoundTag.class));
public static void writeDataOutput(final @NonNull CompoundTag tag, final @NonNull DataOutput output) throws IOException {
output.writeByte(CompoundTag.ID);
output.writeUTF(""); // write empty name
tag.write(output);
}
@@ -187,8 +181,7 @@ public final class BinaryTagIO {
* @return the compound tag
* @throws IOException if an exception was encountered while reading a compound tag
*/
@NotNull
public static CompoundTag readString(final @NotNull String input) throws IOException {
public static @NonNull CompoundTag readString(final @NonNull String input) throws IOException {
try {
final CharBuffer buffer = new CharBuffer(input);
final TagStringReader parser = new TagStringReader(buffer);
@@ -209,8 +202,7 @@ public final class BinaryTagIO {
* @return the string
* @throws IOException if an exception was encountered while writing the compound tag
*/
@NotNull
public static String writeString(final @NotNull CompoundTag tag) throws IOException {
public static @NonNull String writeString(final @NonNull CompoundTag tag) throws IOException {
final StringBuilder sb = new StringBuilder();
try (final TagStringWriter emit = new TagStringWriter(sb)) {
emit.writeTag(tag);
@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api.minecraft.nbt;
package com.viaversion.viaversion.api.minecraft.nbt;
/* package */ final class CharBuffer {
private final CharSequence sequence;
@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api.minecraft.nbt;
package com.viaversion.viaversion.api.minecraft.nbt;
import java.io.IOException;
@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api.minecraft.nbt;
package com.viaversion.viaversion.api.minecraft.nbt;
import com.github.steveice10.opennbt.tag.builtin.ByteArrayTag;
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
@@ -33,11 +33,11 @@ import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.LongArrayTag;
import com.github.steveice10.opennbt.tag.builtin.LongTag;
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
import com.github.steveice10.opennbt.tag.builtin.ShortTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;
@@ -46,25 +46,15 @@ import java.util.stream.IntStream;
* See https://github.com/KyoriPowered/adventure.
*/
/* package */ final class TagStringReader {
private static final Field NAME_FIELD = getNameField();
private final CharBuffer buffer;
private static Field getNameField() {
try {
return Tag.class.getDeclaredField("name");
} catch (NoSuchFieldException e) {
e.printStackTrace();
throw new IllegalArgumentException(e);
}
}
public TagStringReader(final CharBuffer buffer) {
this.buffer = buffer;
}
public CompoundTag compound() throws StringTagParseException {
this.buffer.expect(Tokens.COMPOUND_BEGIN);
final CompoundTag compoundTag = new CompoundTag("");
final CompoundTag compoundTag = new CompoundTag();
if (this.buffer.peek() == Tokens.COMPOUND_END) {
this.buffer.take();
return compoundTag;
@@ -73,17 +63,7 @@ import java.util.stream.IntStream;
while (this.buffer.hasMore()) {
final String key = this.key();
final Tag tag = this.tag();
// Doesn't get around this with the steveice lib :/
try {
if (!NAME_FIELD.isAccessible()) {
NAME_FIELD.setAccessible(true);
}
NAME_FIELD.set(tag, key);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException(e);
}
compoundTag.put(tag);
compoundTag.put(key, tag);
if (this.separatorOrCompleteWith(Tokens.COMPOUND_END)) {
return compoundTag;
}
@@ -92,10 +72,15 @@ import java.util.stream.IntStream;
}
public ListTag list() throws StringTagParseException {
final ListTag listTag = new ListTag("");
final ListTag listTag = new ListTag();
this.buffer.expect(Tokens.ARRAY_BEGIN);
final boolean prefixedIndex = this.buffer.peek() == '0' && this.buffer.peek(1) == ':';
while (this.buffer.hasMore()) {
if (this.buffer.peek() == Tokens.ARRAY_END) {
this.buffer.advance();
return listTag;
}
if (prefixedIndex) {
this.buffer.takeUntil(':');
}
@@ -121,11 +106,11 @@ import java.util.stream.IntStream;
.expect(Tokens.ARRAY_SIGNATURE_SEPARATOR);
if (elementType == Tokens.TYPE_BYTE) {
return new ByteArrayTag("", this.byteArray());
return new ByteArrayTag(this.byteArray());
} else if (elementType == Tokens.TYPE_INT) {
return new IntArrayTag("", this.intArray());
return new IntArrayTag(this.intArray());
} else if (elementType == Tokens.TYPE_LONG) {
return new LongArrayTag("", this.longArray());
return new LongArrayTag(this.longArray());
} else {
throw this.buffer.makeError("Type " + elementType + " is not a valid element type in an array!");
}
@@ -159,7 +144,7 @@ import java.util.stream.IntStream;
if (!(value instanceof IntTag)) {
throw this.buffer.makeError("All elements of an int array must be ints!");
}
builder.add(((IntTag) value).getValue());
builder.add(((NumberTag) value).asInt());
if (this.separatorOrCompleteWith(Tokens.ARRAY_END)) {
return builder.build().toArray();
}
@@ -221,7 +206,7 @@ import java.util.stream.IntStream;
case Tokens.DOUBLE_QUOTE:
// definitely a string tag
this.buffer.advance();
return new StringTag("", unescape(this.buffer.takeUntil(startToken).toString()));
return new StringTag(unescape(this.buffer.takeUntil(startToken).toString()));
default: // scalar
return this.scalar();
}
@@ -246,19 +231,19 @@ import java.util.stream.IntStream;
switch (Character.toUpperCase(current)) { // try to read and return as a number
// case Tokens.TYPE_INTEGER: // handled below, ints are ~special~
case Tokens.TYPE_BYTE:
result = new ByteTag("", Byte.parseByte(builder.toString()));
result = new ByteTag(Byte.parseByte(builder.toString()));
break;
case Tokens.TYPE_SHORT:
result = new ShortTag("", (Short.parseShort(builder.toString())));
result = new ShortTag(Short.parseShort(builder.toString()));
break;
case Tokens.TYPE_LONG:
result = new LongTag("", (Long.parseLong(builder.toString())));
result = new LongTag(Long.parseLong(builder.toString()));
break;
case Tokens.TYPE_FLOAT:
result = new FloatTag("", (Float.parseFloat(builder.toString())));
result = new FloatTag(Float.parseFloat(builder.toString()));
break;
case Tokens.TYPE_DOUBLE:
result = new DoubleTag("", (Double.parseDouble(builder.toString())));
result = new DoubleTag(Double.parseDouble(builder.toString()));
break;
}
} catch (final NumberFormatException ex) {
@@ -283,12 +268,12 @@ import java.util.stream.IntStream;
final String built = builder.toString();
if (possiblyNumeric) {
try {
return new IntTag("", Integer.parseInt(built));
return new IntTag(Integer.parseInt(built));
} catch (final NumberFormatException ex) {
// ignore
}
}
return new StringTag("", built);
return new StringTag(built);
}
@@ -298,6 +283,10 @@ import java.util.stream.IntStream;
return true;
}
this.buffer.expect(Tokens.VALUE_SEPARATOR);
if (this.buffer.skipWhitespace().peek() == endCharacter) {
this.buffer.take();
return true;
}
return false;
}
@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api.minecraft.nbt;
package com.viaversion.viaversion.api.minecraft.nbt;
import com.github.steveice10.opennbt.tag.builtin.ByteArrayTag;
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
@@ -39,6 +39,7 @@ import com.github.steveice10.opennbt.tag.builtin.Tag;
import java.io.IOException;
import java.io.Writer;
import java.util.Map;
/**
* See https://github.com/KyoriPowered/adventure.
@@ -72,17 +73,17 @@ import java.io.Writer;
} else if (tag instanceof StringTag) {
return this.value(((StringTag) tag).getValue(), Tokens.EOF);
} else if (tag instanceof ByteTag) {
return this.value(Byte.toString(((ByteTag) tag).getValue()), Tokens.TYPE_BYTE);
return this.value(Byte.toString(((ByteTag) tag).asByte()), Tokens.TYPE_BYTE);
} else if (tag instanceof ShortTag) {
return this.value(Short.toString(((ShortTag) tag).getValue()), Tokens.TYPE_SHORT);
return this.value(Short.toString(((ShortTag) tag).asShort()), Tokens.TYPE_SHORT);
} else if (tag instanceof IntTag) {
return this.value(Integer.toString(((IntTag) tag).getValue()), Tokens.TYPE_INT);
return this.value(Integer.toString(((IntTag) tag).asInt()), Tokens.TYPE_INT);
} else if (tag instanceof LongTag) {
return this.value(Long.toString(((LongTag) tag).getValue()), Tokens.TYPE_LONG);
return this.value(Long.toString(((LongTag) tag).asLong()), Tokens.TYPE_LONG);
} else if (tag instanceof FloatTag) {
return this.value(Float.toString(((FloatTag) tag).getValue()), Tokens.TYPE_FLOAT);
return this.value(Float.toString(((FloatTag) tag).asFloat()), Tokens.TYPE_FLOAT);
} else if (tag instanceof DoubleTag) {
return this.value(Double.toString(((DoubleTag) tag).getValue()), Tokens.TYPE_DOUBLE);
return this.value(Double.toString(((DoubleTag) tag).asDouble()), Tokens.TYPE_DOUBLE);
} else {
throw new IOException("Unknown tag type: " + tag.getClass().getSimpleName());
// unknown!
@@ -91,9 +92,9 @@ import java.io.Writer;
private TagStringWriter writeCompound(final CompoundTag tag) throws IOException {
this.beginCompound();
for (Tag t : tag) {
this.key(t.getName());
this.writeTag(t);
for (Map.Entry<String, Tag> entry : tag.entrySet()) {
this.key(entry.getKey());
this.writeTag(entry.getValue());
}
this.endCompound();
return this;
@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api.minecraft.nbt;
package com.viaversion.viaversion.api.minecraft.nbt;
/**
* See https://github.com/KyoriPowered/adventure.
@@ -0,0 +1,46 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.platform;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* @param <T> task type
*/
public interface PlatformTask<T> {
/**
* Returns the actual object represented by this task/task id.
* Null if task cannot be instantly tracked.
*
* @return platform based object, or null if not tracked/cancellable
*/
@Nullable T getObject();
/**
* Cancels the task.
*
* @throws IllegalArgumentException if the task is not cancellable
*/
void cancel();
}
@@ -0,0 +1,47 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.platform;
public interface UnsupportedSoftware {
/**
* Returns the software name.
*
* @return software name
*/
String getName();
/**
* Returns the reason for being unsupported by Via.
*
* @return reason for being unsupported
*/
String getReason();
/**
* Returns whether the unsupported software is present.
*
* @return true if the unsupported software is found
*/
boolean findMatch();
}
@@ -0,0 +1,96 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.platform;
import com.google.gson.JsonObject;
import it.unimi.dsi.fastutil.ints.IntSortedSet;
import it.unimi.dsi.fastutil.ints.IntSortedSets;
public interface ViaInjector {
/**
* Inject into the current Platform
*
* @throws Exception If there is an error with injecting
*/
void inject() throws Exception;
/**
* Uninject into the current Platform
*
* @throws Exception If there is an error with uninjecting
*/
void uninject() throws Exception;
/**
* Returns true if the protocol version cannot be used in the early init.
* Namely, this returns true for forks of Vanilla without extra API to get the protocol version.
*
* @return true if the protocol version cannot be used in the early init
*/
default boolean lateProtocolVersionSetting() {
return false;
}
/**
* Returns the server protocol version.
* For proxies, this returns the lowest supported protocol version.
*
* @return server protocol version
* @throws Exception if there is an error with getting this info, eg. not binded
* @see ViaPlatform#isProxy()
*/
int getServerProtocolVersion() throws Exception;
/**
* Returns the supported server protocol versions.
*
* @return server protocol versions
* @throws Exception if there is an error with getting this info, eg. not binded
* @see ViaPlatform#isProxy()
*/
default IntSortedSet getServerProtocolVersions() throws Exception {
return IntSortedSets.singleton(getServerProtocolVersion());
}
/**
* Get the name of the encoder for then netty pipeline for this platform.
*
* @return The name
*/
String getEncoderName();
/**
* Get the name of the decoder for then netty pipeline for this platform.
*
* @return The name
*/
String getDecoderName();
/**
* Get any relevant data for debugging injection issues.
*
* @return JSONObject containing the data
*/
JsonObject getDump();
}
@@ -1,15 +1,37 @@
package us.myles.ViaVersion.api.platform;
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.platform;
import com.google.gson.JsonObject;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.ViaAPI;
import us.myles.ViaVersion.api.ViaVersionConfig;
import us.myles.ViaVersion.api.command.ViaCommandSender;
import us.myles.ViaVersion.api.configuration.ConfigurationProvider;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import com.viaversion.viaversion.api.ViaAPI;
import com.viaversion.viaversion.api.command.ViaCommandSender;
import com.viaversion.viaversion.api.configuration.ConfigurationProvider;
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
import com.viaversion.viaversion.api.connection.UserConnection;
import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.UUID;
import java.util.logging.Logger;
@@ -63,7 +85,7 @@ public interface ViaPlatform<T> {
* @param runnable The task to run
* @return The Task ID
*/
TaskId runAsync(Runnable runnable);
PlatformTask runAsync(Runnable runnable);
/**
* Run a task Sync
@@ -71,7 +93,7 @@ public interface ViaPlatform<T> {
* @param runnable The task to run
* @return The Task ID
*/
TaskId runSync(Runnable runnable);
PlatformTask runSync(Runnable runnable);
/**
* Run a task Sync after a interval
@@ -81,7 +103,7 @@ public interface ViaPlatform<T> {
* @param ticks The interval to run it after
* @return The Task ID
*/
TaskId runSync(Runnable runnable, Long ticks);
PlatformTask runSync(Runnable runnable, long ticks);
/**
* Run a task at a repeating interval.
@@ -91,14 +113,7 @@ public interface ViaPlatform<T> {
* @param ticks The interval to run it at
* @return The Task ID
*/
TaskId runRepeatingSync(Runnable runnable, Long ticks);
/**
* Cancel a task
*
* @param taskId The task ID to cancel
*/
void cancelTask(TaskId taskId);
PlatformTask runRepeatingSync(Runnable runnable, long ticks);
/**
* Get the online players
@@ -127,13 +142,13 @@ public interface ViaPlatform<T> {
/**
* Disconnects an UserConnection for a reason
*
* @param connection The UserConnection
* @param message The message to kick them with
* @param connection The UserConnection
* @param message The message to kick them with
* @return True if it was successful
*/
default boolean disconnect(UserConnection connection, String message) {
if (connection.isClientSide()) return false;
UUID uuid = connection.get(ProtocolInfo.class).getUuid();
UUID uuid = connection.getProtocolInfo().getUuid();
if (uuid == null) return false;
return kickPlayer(uuid, message);
}
@@ -194,5 +209,13 @@ public interface ViaPlatform<T> {
*/
boolean isOldClientsAllowed();
ViaConnectionManager getConnectionManager();
/**
* Returns an immutable collection of classes to be checked as unsupported software with their software name.
* If any of the classes exist at runtime, a warning about their potential instability will be given to the console.
*
* @return immutable collection of unsupported software to be checked
*/
default Collection<UnsupportedSoftware> getUnsupportedSoftwareClasses() {
return Collections.emptyList();
}
}
@@ -0,0 +1,33 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.platform;
public interface ViaPlatformLoader {
/**
* Initialise the loading for a platform, eg. registering listeners / providers / events etc.
*/
void load();
void unload();
}
@@ -0,0 +1,26 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.platform.providers;
public interface Provider {
}
Loaded 100 of 959 files, more files were not shown because too many files have changed in this diff. Show more