feat(crafting): register verified manual character crafting
This commit is contained in:
1 parent
e7912d03ce
commit
1e7cdf888a
5 files changed
+468
-15
No files matched your search
@@ -0,0 +1,371 @@
|
||||
package games.dmg.fantasystick;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import games.dmg.fantasystick.items.CharacterSheets;
|
||||
import io.papermc.paper.plugin.configuration.PluginMeta;
|
||||
import io.papermc.paper.plugin.manager.NativeEventDispatcher;
|
||||
import io.papermc.paper.plugin.provider.classloader.ConfiguredPluginClassLoader;
|
||||
import io.papermc.paper.plugin.provider.classloader.PluginClassLoaderGroup;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
/** Loads the actual packaged entrypoint with native JavaPlugin lifecycle/dispatcher and explicit server ports. */
|
||||
class FantasyStickLifecycleNativeTest {
|
||||
@TempDir Path data;
|
||||
@BeforeAll static void bootstrap() throws Exception { NativeRuntime.bootstrap(); }
|
||||
|
||||
@Test
|
||||
void enableRegistersCraftControllerAndCrafterGuardBeforeExposingTheRecipe() throws Exception {
|
||||
try (var fixture = new Fixture(data)) {
|
||||
fixture.plugin.setEnabled(true);
|
||||
assertTrue(fixture.recipes.containsKey(CharacterSheets.RECIPE));
|
||||
int recipe = fixture.order.indexOf("recipe");
|
||||
assertTrue(fixture.order.indexOf("ManualCraftingController") >= 0);
|
||||
assertTrue(fixture.order.indexOf("ManualCraftingController") < recipe);
|
||||
assertTrue(fixture.order.indexOf("ManualCraftingGuard") >= 0);
|
||||
assertTrue(fixture.order.indexOf("ManualCraftingGuard") < recipe);
|
||||
assertTrue(fixture.tasks.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void disableRemovesOnlyItsRecipeAndListenersAndIsSafeToRepeat() throws Exception {
|
||||
try (var fixture = new Fixture(data)) {
|
||||
var otherKey = new NamespacedKey("unrelated", "character_sheet");
|
||||
var other = new org.bukkit.inventory.ShapelessRecipe(otherKey, new org.bukkit.inventory.ItemStack(org.bukkit.Material.DIAMOND))
|
||||
.addIngredient(org.bukkit.Material.STICK);
|
||||
fixture.recipes.put(otherKey, other);
|
||||
fixture.plugin.setEnabled(true);
|
||||
assertTrue(java.util.Arrays.stream(org.bukkit.event.inventory.CraftItemEvent.getHandlerList().getRegisteredListeners())
|
||||
.anyMatch(listener -> listener.getPlugin() == fixture.plugin));
|
||||
fixture.plugin.setEnabled(false);
|
||||
assertFalse(fixture.recipes.containsKey(CharacterSheets.RECIPE));
|
||||
assertSame(other, fixture.recipes.get(otherKey));
|
||||
assertFalse(java.util.Arrays.stream(org.bukkit.event.inventory.CraftItemEvent.getHandlerList().getRegisteredListeners())
|
||||
.anyMatch(listener -> listener.getPlugin() == fixture.plugin));
|
||||
assertFalse(java.util.Arrays.stream(org.bukkit.event.block.CrafterCraftEvent.getHandlerList().getRegisteredListeners())
|
||||
.anyMatch(listener -> listener.getPlugin() == fixture.plugin));
|
||||
fixture.plugin.onDisable();
|
||||
assertSame(other, fixture.recipes.get(otherKey));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void recipeCollisionAndPartialListenerRegistrationFailureRollbackOnlyThisEnableAttempt() throws Exception {
|
||||
for (boolean collision : new boolean[] {true, false}) {
|
||||
try (var fixture = new Fixture(data)) {
|
||||
var existing = new org.bukkit.inventory.ShapelessRecipe(CharacterSheets.RECIPE,
|
||||
new org.bukkit.inventory.ItemStack(org.bukkit.Material.DIAMOND)).addIngredient(org.bukkit.Material.STICK);
|
||||
if (collision) fixture.recipes.put(CharacterSheets.RECIPE, existing);
|
||||
else fixture.failRegistrationAt = "ManualCraftingGuard";
|
||||
assertThrows(IllegalStateException.class, () -> fixture.plugin.setEnabled(true));
|
||||
if (collision) assertSame(existing, fixture.recipes.get(CharacterSheets.RECIPE));
|
||||
else assertFalse(fixture.recipes.containsKey(CharacterSheets.RECIPE));
|
||||
assertFalse(java.util.Arrays.stream(org.bukkit.event.inventory.CraftItemEvent.getHandlerList().getRegisteredListeners())
|
||||
.anyMatch(listener -> listener.getPlugin() == fixture.plugin));
|
||||
assertFalse(java.util.Arrays.stream(org.bukkit.event.block.CrafterCraftEvent.getHandlerList().getRegisteredListeners())
|
||||
.anyMatch(listener -> listener.getPlugin() == fixture.plugin));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void registeredCraftDispatchUsesConfiguredPointsAndOnlySavesAcceptedCompletedAttempts() throws Exception {
|
||||
for (String points : List.of("40", "0", "922337203685477580812345")) {
|
||||
var directory = data.resolve(points);
|
||||
java.nio.file.Files.createDirectories(directory);
|
||||
if (!points.equals("40")) java.nio.file.Files.writeString(directory.resolve("config.yml"), "starting-points: '" + points + "'\n");
|
||||
try (var fixture = new Fixture(directory)) {
|
||||
fixture.plugin.setEnabled(true);
|
||||
var actor = new ManualCraftingControllerNativeTest.Actor(2, 2);
|
||||
assertFalse(java.nio.file.Files.exists(directory.resolve("characters")));
|
||||
assertTrue(new CharacterSheets().identify(fixture.recipes.get(CharacterSheets.RECIPE).getResult()).isEmpty());
|
||||
var cancelled = actor.fixture.event(org.bukkit.event.inventory.ClickType.LEFT,
|
||||
org.bukkit.event.inventory.InventoryAction.PICKUP_ALL);
|
||||
cancelled.setCancelled(true);
|
||||
fixture.dispatcher.accept(cancelled);
|
||||
assertTrue(fixture.tasks.isEmpty());
|
||||
assertFalse(java.nio.file.Files.exists(directory.resolve("characters")));
|
||||
var event = actor.fixture.event(org.bukkit.event.inventory.ClickType.LEFT,
|
||||
org.bukkit.event.inventory.InventoryAction.PICKUP_ALL);
|
||||
fixture.dispatcher.accept(event);
|
||||
assertTrue(event.isCancelled());
|
||||
assertTrue(actor.fixture.view.getCursor().isEmpty());
|
||||
var complete = fixture.tasks.poll(5, java.util.concurrent.TimeUnit.SECONDS); assertNotNull(complete);
|
||||
complete.run();
|
||||
var id = new CharacterSheets().identify(actor.fixture.view.getCursor()).orElseThrow();
|
||||
var saved = new games.dmg.fantasystick.persistence.YamlCharacterRepository(directory).load(id).orElseThrow();
|
||||
assertEquals(new java.math.BigInteger(points), saved.unspentPoints());
|
||||
assertEquals(1, saved.level());
|
||||
assertEquals(1, actor.fixture.grid.getMatrix()[0].getAmount());
|
||||
assertEquals(1, actor.syncs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void invalidStartingPointValuesFailBeforeInstallingAnyGameplay() throws Exception {
|
||||
for (String value : List.of("-1", "not-a-number", "1.5")) {
|
||||
var directory = data.resolve(value);
|
||||
java.nio.file.Files.createDirectories(directory);
|
||||
java.nio.file.Files.writeString(directory.resolve("config.yml"), "starting-points: '" + value + "'\n");
|
||||
try (var fixture = new Fixture(directory)) {
|
||||
assertThrows(IllegalArgumentException.class, () -> fixture.plugin.setEnabled(true));
|
||||
assertTrue(fixture.order.isEmpty());
|
||||
assertTrue(fixture.recipes.isEmpty());
|
||||
assertFalse(java.nio.file.Files.exists(directory.resolve("characters")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void installedGuardRejectsOnlyTheCharacterRecipeThroughTheNativeDispatcher() throws Exception {
|
||||
try (var fixture = new Fixture(data)) {
|
||||
fixture.plugin.setEnabled(true);
|
||||
var block = port(org.bukkit.block.Block.class, (name, args) -> { throw new AssertionError("Unexpected block access"); });
|
||||
for (boolean ours : new boolean[] {false, true}) {
|
||||
var recipe = ours ? new CharacterSheets().recipe() : new org.bukkit.inventory.ShapelessRecipe(
|
||||
new NamespacedKey("other", "character_sheet"), new org.bukkit.inventory.ItemStack(org.bukkit.Material.PAPER))
|
||||
.addIngredient(org.bukkit.Material.STICK);
|
||||
for (boolean cancelled : new boolean[] {false, true}) {
|
||||
var event = new org.bukkit.event.block.CrafterCraftEvent(block, recipe, recipe.getResult());
|
||||
event.setCancelled(cancelled);
|
||||
fixture.dispatcher.accept(event);
|
||||
assertEquals(ours || cancelled, event.isCancelled());
|
||||
assertEquals(recipe.getResult(), event.getResult());
|
||||
}
|
||||
}
|
||||
assertTrue(fixture.tasks.isEmpty());
|
||||
assertFalse(java.nio.file.Files.exists(data.resolve("characters")));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void disableInvalidatesAlreadyQueuedCraftCompletionBeforeStorageShutdown() throws Exception {
|
||||
try (var fixture = new Fixture(data)) {
|
||||
fixture.plugin.setEnabled(true);
|
||||
var actor = new ManualCraftingControllerNativeTest.Actor(2, 2);
|
||||
fixture.dispatcher.accept(actor.fixture.event(org.bukkit.event.inventory.ClickType.LEFT,
|
||||
org.bukkit.event.inventory.InventoryAction.PICKUP_ALL));
|
||||
var complete = fixture.tasks.poll(5, java.util.concurrent.TimeUnit.SECONDS); assertNotNull(complete);
|
||||
fixture.plugin.setEnabled(false);
|
||||
complete.run(); complete.run();
|
||||
assertTrue(actor.fixture.view.getCursor().isEmpty());
|
||||
assertEquals(2, actor.fixture.grid.getMatrix()[0].getAmount());
|
||||
assertEquals(0, actor.syncs);
|
||||
assertFalse(fixture.recipes.containsKey(CharacterSheets.RECIPE));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void installedManualRoutesDeliverSavedDistinctSheetsIncludingQAndCtrlQ() throws Exception {
|
||||
for (int route = 0; route < 6; route++) {
|
||||
var directory = data.resolve("route-" + route);
|
||||
try (var fixture = new Fixture(directory)) {
|
||||
fixture.plugin.setEnabled(true);
|
||||
var actor = new ManualCraftingControllerNativeTest.Actor(3, 2);
|
||||
var world = new PlayerSheetDropsNativeTest.WorldFixture();
|
||||
actor.eyeLocation = new org.bukkit.Location(world.world, 10, 66, 10);
|
||||
var dropped = new ArrayList<org.bukkit.inventory.ItemStack>();
|
||||
world.onSpawn = event -> {
|
||||
fixture.dispatcher.accept(event);
|
||||
if (!event.isCancelled()) dropped.add(event.getEntity().getItemStack().clone());
|
||||
};
|
||||
var click = switch (route) {
|
||||
case 0 -> org.bukkit.event.inventory.ClickType.RIGHT;
|
||||
case 1 -> org.bukkit.event.inventory.ClickType.SHIFT_LEFT;
|
||||
case 2 -> org.bukkit.event.inventory.ClickType.NUMBER_KEY;
|
||||
case 3 -> org.bukkit.event.inventory.ClickType.SWAP_OFFHAND;
|
||||
case 4 -> org.bukkit.event.inventory.ClickType.DROP;
|
||||
default -> org.bukkit.event.inventory.ClickType.CONTROL_DROP;
|
||||
};
|
||||
var action = switch (route) {
|
||||
case 0 -> org.bukkit.event.inventory.InventoryAction.PICKUP_HALF;
|
||||
case 1 -> org.bukkit.event.inventory.InventoryAction.MOVE_TO_OTHER_INVENTORY;
|
||||
case 2, 3 -> org.bukkit.event.inventory.InventoryAction.HOTBAR_SWAP;
|
||||
case 4 -> org.bukkit.event.inventory.InventoryAction.DROP_ONE_SLOT;
|
||||
default -> org.bukkit.event.inventory.InventoryAction.DROP_ALL_SLOT;
|
||||
};
|
||||
var event = new org.bukkit.event.inventory.CraftItemEvent(fixture.recipes.get(CharacterSheets.RECIPE),
|
||||
actor.fixture.view, org.bukkit.event.inventory.InventoryType.SlotType.RESULT, 0, click, action, route == 2 ? 4 : -1);
|
||||
fixture.dispatcher.accept(event);
|
||||
assertTrue(event.isCancelled());
|
||||
var complete = fixture.tasks.poll(5, java.util.concurrent.TimeUnit.SECONDS); assertNotNull(complete); complete.run();
|
||||
var outputs = new ArrayList<org.bukkit.inventory.ItemStack>(dropped);
|
||||
for (var item : actor.fixture.inventory.getContents()) if (new CharacterSheets().identify(item).isPresent()) outputs.add(item);
|
||||
if (new CharacterSheets().identify(actor.fixture.view.getCursor()).isPresent()) outputs.add(actor.fixture.view.getCursor());
|
||||
int quantity = route == 1 || route == 5 ? 2 : 1;
|
||||
assertEquals(quantity, outputs.size());
|
||||
var ids = outputs.stream().map(item -> new CharacterSheets().identify(item).orElseThrow()).toList();
|
||||
assertEquals(quantity, ids.stream().distinct().count());
|
||||
for (var id : ids) assertTrue(new games.dmg.fantasystick.persistence.YamlCharacterRepository(directory).load(id).isPresent());
|
||||
var first = actor.fixture.grid.getMatrix()[0];
|
||||
assertEquals(2 - quantity, first == null ? 0 : first.getAmount());
|
||||
assertEquals(1, actor.syncs);
|
||||
if (route >= 4) assertEquals(quantity, world.spawnCalls);
|
||||
complete.run();
|
||||
assertEquals(1, actor.syncs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void recipeRemovalFailureDoesNotPreventAttemptInvalidationOrListenerCleanup() throws Exception {
|
||||
try (var fixture = new Fixture(data)) {
|
||||
fixture.plugin.setEnabled(true);
|
||||
var actor = new ManualCraftingControllerNativeTest.Actor(2, 2);
|
||||
fixture.dispatcher.accept(actor.fixture.event(org.bukkit.event.inventory.ClickType.LEFT,
|
||||
org.bukkit.event.inventory.InventoryAction.PICKUP_ALL));
|
||||
var complete = fixture.tasks.poll(5, java.util.concurrent.TimeUnit.SECONDS); assertNotNull(complete);
|
||||
fixture.failRemoval = true;
|
||||
assertDoesNotThrow(() -> fixture.plugin.setEnabled(false));
|
||||
complete.run();
|
||||
assertTrue(actor.fixture.view.getCursor().isEmpty());
|
||||
assertEquals(2, actor.fixture.grid.getMatrix()[0].getAmount());
|
||||
assertFalse(java.util.Arrays.stream(org.bukkit.event.inventory.CraftItemEvent.getHandlerList().getRegisteredListeners())
|
||||
.anyMatch(listener -> listener.getPlugin() == fixture.plugin));
|
||||
fixture.failRemoval = false;
|
||||
fixture.plugin.onDisable();
|
||||
assertFalse(fixture.recipes.containsKey(CharacterSheets.RECIPE));
|
||||
}
|
||||
}
|
||||
|
||||
static final class Fixture implements AutoCloseable {
|
||||
final List<String> order = new ArrayList<>();
|
||||
final Map<NamespacedKey, Recipe> recipes = new HashMap<>();
|
||||
final LinkedBlockingQueue<Runnable> tasks = new LinkedBlockingQueue<>();
|
||||
final List<Listener> listeners = new ArrayList<>();
|
||||
String failRegistrationAt;
|
||||
boolean failRemoval;
|
||||
final NativeEventDispatcher dispatcher;
|
||||
final Server server;
|
||||
final Loader loader;
|
||||
final JavaPlugin plugin;
|
||||
|
||||
Fixture(Path data) throws Exception {
|
||||
var manager = port(PluginManager.class, (name, args) -> switch (name) {
|
||||
case "registerEvents" -> {
|
||||
var listener = (Listener) args[0];
|
||||
order.add(listener.getClass().getSimpleName());
|
||||
listeners.add(listener);
|
||||
dispatcher().register(listener, (org.bukkit.plugin.Plugin) args[1]);
|
||||
if (listener.getClass().getSimpleName().equals(failRegistrationAt)) throw new IllegalStateException("registration failed");
|
||||
yield null;
|
||||
}
|
||||
case "callEvent" -> { dispatcher().accept((org.bukkit.event.Event) args[0]); yield null; }
|
||||
default -> throw new AssertionError("Unexpected manager call " + name);
|
||||
});
|
||||
var scheduler = port(BukkitScheduler.class, (name, args) -> switch (name) {
|
||||
case "runTask" -> {
|
||||
assertTrue(((org.bukkit.plugin.Plugin) args[0]).isEnabled());
|
||||
tasks.add((Runnable) args[1]);
|
||||
yield port(BukkitTask.class, (method, values) -> { throw new AssertionError("Unexpected task call " + method); });
|
||||
}
|
||||
default -> throw new AssertionError("Unexpected scheduler call " + name);
|
||||
});
|
||||
server = port(Server.class, (name, args) -> switch (name) {
|
||||
case "getPluginManager" -> manager;
|
||||
case "getScheduler" -> scheduler;
|
||||
case "getLogger" -> Logger.getLogger("FantasyStick lifecycle fixture");
|
||||
case "isPrimaryThread" -> true;
|
||||
case "getOnlinePlayers" -> List.of();
|
||||
case "addRecipe" -> {
|
||||
order.add("recipe");
|
||||
var recipe = (Recipe) args[0];
|
||||
yield recipes.putIfAbsent(((Keyed) recipe).getKey(), recipe) == null;
|
||||
}
|
||||
case "getRecipe" -> recipes.get((NamespacedKey) args[0]);
|
||||
case "removeRecipe" -> {
|
||||
if (failRemoval) throw new IllegalStateException("Simulated registry removal failure");
|
||||
yield recipes.remove((NamespacedKey) args[0]) != null;
|
||||
}
|
||||
default -> throw new AssertionError("Unexpected server call " + name);
|
||||
});
|
||||
dispatcher = new NativeEventDispatcher(server);
|
||||
loader = new Loader(server, data);
|
||||
plugin = (JavaPlugin) loader.loadClass("games.dmg.fantasystick.FantasyStickPlugin").getConstructor().newInstance();
|
||||
}
|
||||
|
||||
private NativeEventDispatcher dispatcher() { return dispatcher; }
|
||||
@Override public void close() throws IOException {
|
||||
try { plugin.setEnabled(false); }
|
||||
finally { HandlerList.unregisterAll(plugin); loader.close(); }
|
||||
}
|
||||
}
|
||||
|
||||
static final class Loader extends URLClassLoader implements ConfiguredPluginClassLoader {
|
||||
private static final String ENTRY = "games.dmg.fantasystick.FantasyStickPlugin";
|
||||
private final Server server;
|
||||
private final Path data;
|
||||
private final Path jar = Path.of(System.getProperty("distribution.jar"));
|
||||
private final PluginDescriptionFile description;
|
||||
private JavaPlugin plugin;
|
||||
|
||||
Loader(Server server, Path data) throws Exception {
|
||||
super(new URL[] {Path.of(System.getProperty("distribution.jar")).toUri().toURL()}, FantasyStickLifecycleNativeTest.class.getClassLoader());
|
||||
this.server = server;
|
||||
this.data = data;
|
||||
try (var archive = new JarFile(jar.toFile()); var input = archive.getInputStream(archive.getJarEntry("plugin.yml"))) {
|
||||
description = new PluginDescriptionFile(input);
|
||||
}
|
||||
}
|
||||
|
||||
@Override protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
|
||||
synchronized (getClassLoadingLock(name)) {
|
||||
if (!name.equals(ENTRY)) return super.loadClass(name, resolve);
|
||||
var loaded = findLoadedClass(name);
|
||||
if (loaded == null) loaded = findClass(name);
|
||||
if (resolve) resolveClass(loaded);
|
||||
return loaded;
|
||||
}
|
||||
}
|
||||
@Override public Class<?> loadClass(String name, boolean resolve, boolean global, boolean libraries) throws ClassNotFoundException {
|
||||
return loadClass(name, resolve);
|
||||
}
|
||||
@Override public PluginMeta getConfiguration() { return description; }
|
||||
@Override public JavaPlugin getPlugin() { return plugin; }
|
||||
@Override public PluginClassLoaderGroup getGroup() { return null; }
|
||||
@Override public void init(JavaPlugin created) {
|
||||
plugin = created;
|
||||
created.init(server, description, data.toFile(), jar.toFile(), this, description, Logger.getLogger("FantasyStick lifecycle fixture"));
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface interface Call { Object invoke(String name, Object[] args); }
|
||||
static <T> T port(Class<T> type, Call call) {
|
||||
return type.cast(Proxy.newProxyInstance(type.getClassLoader(), new Class<?>[] {type}, (object, method, args) -> {
|
||||
if (method.getDeclaringClass() == Object.class) return switch (method.getName()) {
|
||||
case "equals" -> object == args[0];
|
||||
case "hashCode" -> System.identityHashCode(object);
|
||||
case "toString" -> "Lifecycle port " + type.getSimpleName();
|
||||
default -> throw new AssertionError(method.getName());
|
||||
};
|
||||
return call.invoke(method.getName(), args);
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -414,6 +414,7 @@ class ManualCraftingControllerNativeTest {
|
||||
final Player player;
|
||||
final Thread serverThread = Thread.currentThread();
|
||||
InventoryView current;
|
||||
org.bukkit.Location eyeLocation;
|
||||
boolean online = true;
|
||||
int syncs;
|
||||
Runnable onSync = () -> { };
|
||||
@@ -427,6 +428,7 @@ class ManualCraftingControllerNativeTest {
|
||||
return switch (method.getName()) {
|
||||
case "getUniqueId" -> id;
|
||||
case "getOpenInventory" -> current;
|
||||
case "getEyeLocation" -> java.util.Objects.requireNonNull(eyeLocation).clone();
|
||||
case "isOnline" -> online;
|
||||
case "updateInventory" -> { syncs++; onSync.run(); yield null; }
|
||||
case "equals" -> object == args[0];
|
||||
|
||||
@@ -11,4 +11,8 @@ public final class NativeEventDispatcher implements Consumer<Event> {
|
||||
public NativeEventDispatcher(Server server) { manager = new PaperEventManager(server); }
|
||||
|
||||
@Override public void accept(Event event) { manager.callEvent(event); }
|
||||
|
||||
public void register(org.bukkit.event.Listener listener, org.bukkit.plugin.Plugin plugin) {
|
||||
manager.registerEvents(listener, plugin);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user