diff --git a/fabric/build.gradle b/fabric/build.gradle index 285853274..d3ec6fc96 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -21,7 +21,8 @@ dependencies { 'fabric-api-base', 'fabric-command-api-v2', 'fabric-lifecycle-events-v1', - 'fabric-networking-api-v1' + 'fabric-networking-api-v1', + 'fabric-entity-events-v1' ] apiModules.forEach { diff --git a/fabric/src/main/java/me/lucko/luckperms/fabric/context/FabricPlayerCalculator.java b/fabric/src/main/java/me/lucko/luckperms/fabric/context/FabricPlayerCalculator.java index 4313f42f1..303f8dccb 100644 --- a/fabric/src/main/java/me/lucko/luckperms/fabric/context/FabricPlayerCalculator.java +++ b/fabric/src/main/java/me/lucko/luckperms/fabric/context/FabricPlayerCalculator.java @@ -29,7 +29,7 @@ import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.common.util.EnumNamer; import me.lucko.luckperms.fabric.LPFabricPlugin; -import me.lucko.luckperms.fabric.event.PlayerChangeWorldCallback; +import net.fabricmc.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents; import net.luckperms.api.context.Context; import net.luckperms.api.context.ContextCalculator; import net.luckperms.api.context.ContextConsumer; @@ -67,7 +67,7 @@ public class FabricPlayerCalculator implements ContextCalculator - * Copyright (c) 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 me.lucko.luckperms.fabric.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; - -// TODO: Use Fabric API alternative when merged. -public interface PlayerChangeWorldCallback { - Event EVENT = EventFactory.createArrayBacked(PlayerChangeWorldCallback.class, callbacks -> (originalWorld, destination, player) -> { - for (PlayerChangeWorldCallback callback : callbacks) { - callback.onChangeWorld(originalWorld, destination, player); - } - }); - - void onChangeWorld(ServerWorld originalWorld, ServerWorld destination, ServerPlayerEntity player); -} diff --git a/fabric/src/main/java/me/lucko/luckperms/fabric/mixin/ServerPlayerEntityMixin.java b/fabric/src/main/java/me/lucko/luckperms/fabric/mixin/ServerPlayerEntityMixin.java index 6d91f8074..ce68c2eca 100644 --- a/fabric/src/main/java/me/lucko/luckperms/fabric/mixin/ServerPlayerEntityMixin.java +++ b/fabric/src/main/java/me/lucko/luckperms/fabric/mixin/ServerPlayerEntityMixin.java @@ -31,7 +31,6 @@ import me.lucko.luckperms.common.context.manager.QueryOptionsCache; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.verbose.event.CheckOrigin; import me.lucko.luckperms.fabric.context.FabricContextManager; -import me.lucko.luckperms.fabric.event.PlayerChangeWorldCallback; import me.lucko.luckperms.fabric.model.MixinUser; import net.luckperms.api.query.QueryOptions; import net.luckperms.api.util.Tristate; @@ -161,9 +160,4 @@ public abstract class ServerPlayerEntityMixin implements MixinUser { MixinUser oldMixin = (MixinUser) oldPlayer; luckperms$initializePermissions(oldMixin.luckperms$getUser()); } - - @Inject(at = @At("TAIL"), method = "worldChanged") - private void luckperms$onChangeDimension(ServerWorld targetWorld, CallbackInfo ci) { - PlayerChangeWorldCallback.EVENT.invoker().onChangeWorld(this.getServerWorld(), targetWorld, (ServerPlayerEntity) (Object) this); - } }