-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: introduce additional source sets to prevent using reflection o…
…n API currently it is demonstrated on 1.20.1, more source sets are coming in the future
- Loading branch information
Showing
4 changed files
with
65 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...rt_1_20_1/java/org/screamingsandals/lib/impl/bukkit/compat/v1_20_1/EntitySpawnCompat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.screamingsandals.lib.impl.bukkit.compat.v1_20_1; | ||
|
||
import lombok.experimental.UtilityClass; | ||
import org.bukkit.Location; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.Item; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
@UtilityClass | ||
public class EntitySpawnCompat { | ||
/** | ||
* Provides a way to spawn an entity with pre-spawn callback in 1.11-1.20.1. The overloaded variant | ||
* {@code spawn(org.bukkit.Location, Class, org.bukkit.util.Consumer)} does not exist anymore since 1.20.2, | ||
* making it unable to compile compatible version against newer API. | ||
*/ | ||
public static <T extends Entity> @NotNull T spawn(@NotNull Location location, @NotNull Class<T> type, @NotNull java.util.function.Consumer<T> consumer) { | ||
org.bukkit.util.Consumer<T> cons = consumer::accept; | ||
return location.getWorld().spawn(location, type, cons); | ||
} | ||
|
||
/** | ||
* Provides a way to drop an item with pre-spawn callback in 1.11-1.20.1. The overloaded variant | ||
* {@code spawn(org.bukkit.Location, org.bukkit.inventory.ItemStack, org.bukkit.util.Consumer)} does not exist anymore since 1.20.2, | ||
* making it unable to compile compatible version against newer API. | ||
*/ | ||
public static @NotNull Item dropItem(@NotNull Location location, @NotNull ItemStack item, @NotNull java.util.function.Consumer<Item> consumer) { | ||
org.bukkit.util.Consumer<Item> cons = consumer::accept; | ||
return location.getWorld().dropItem(location, item, cons); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters