Skip to content

Commit b60739d

Browse files
committed
Add adapters concept
1 parent adabb05 commit b60739d

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

source/api/concepts/adapters.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Adapters
2+
========
3+
WorldEdit works across many Minecraft modding platforms. This implies that WorldEdit's API does not use any platform's
4+
API types, such as Bukkit's ``Player`` or Sponge's ``World``. Instead, WorldEdit has its own set of API types,
5+
and the platform-specific library (see :ref:`api-libraries`) contains an `adapter` class to turn the platform's
6+
API types into WorldEdit's API types, and vice versa. For example, you can turn an
7+
``org.bukkit.entity.Player`` into a ``com.sk89q.worldedit.entity.Player`` like so
8+
9+
.. code-block:: java
10+
11+
org.bukkit.entity.Player player = /* get a player */;
12+
Player wePlayer = BukkitAdapter.adapt(player);
13+
14+
Nearly every other WorldEdit type has a similar conversion from the platform type. These are best discovered by
15+
looking at the methods in the adapter classes in your IDE.

source/api/concepts/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ be read in the order provided, as later concepts sometimes reference earlier con
1414
regions
1515
registries
1616
edit-sessions
17+
adapters

source/api/index.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ WorldEdit provides a stable public interface for other mods and plugins to build
1313
platform-independent interfaces and classes for working with Minecraft blocks, biomes, and worlds.
1414
Limited entity support is present as well.
1515

16+
.. _api-libraries:
17+
18+
API Libraries
19+
-------------
20+
1621
You can get the API via a `Maven repository`_, compatible with Maven_, Gradle_, sbt_, and many other build systems.
1722
The repository is `<https://maven.enginehub.org/>`_, and WorldEdit is under the group ``com.sk89q.worldedit``.
1823
Depending on which parts of the API you need, choose one of the following names:

0 commit comments

Comments
 (0)