move mod integration to own package. flight permission
This commit is contained in:
parent
d6f7555f1c
commit
79051c9536
@ -7,6 +7,7 @@ import com.flemmli97.flan.config.ConfigHandler;
|
||||
import com.flemmli97.flan.event.BlockInteractEvents;
|
||||
import com.flemmli97.flan.event.EntityInteractEvents;
|
||||
import com.flemmli97.flan.event.ItemInteractEvents;
|
||||
import com.flemmli97.flan.integration.playerability.PlayerAbilityEvents;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
@ -24,8 +25,7 @@ public class Flan implements ModInitializer {
|
||||
|
||||
public static final Logger logger = LogManager.getLogger("flan");
|
||||
|
||||
public static boolean permissionAPI;
|
||||
public static boolean gunpowder;
|
||||
public static boolean permissionAPI, gunpowder, playerAbilityLib;
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
@ -42,6 +42,9 @@ public class Flan implements ModInitializer {
|
||||
|
||||
permissionAPI = FabricLoader.getInstance().isModLoaded("fabric-permissions-api-v0");
|
||||
gunpowder = FabricLoader.getInstance().isModLoaded("gunpowder-currency");
|
||||
playerAbilityLib = FabricLoader.getInstance().isModLoaded("playerabilitylib");
|
||||
if(playerAbilityLib)
|
||||
PlayerAbilityEvents.register();
|
||||
}
|
||||
|
||||
public void lockRegistry(MinecraftServer server) {
|
||||
|
@ -66,6 +66,7 @@ public class PermissionRegistry {
|
||||
public static ClaimPermission BREAKNONLIVING = register(new ClaimPermission("BREAKNONLIVING", () -> new ItemStack(Items.COMMAND_BLOCK_MINECART), "Permission to break things like minecarts or armor stands"));
|
||||
public static ClaimPermission DROP = register(new ClaimPermission("DROP", () -> new ItemStack(Items.BOWL), true, "Allow the drop of items"));
|
||||
public static ClaimPermission PICKUP = register(new ClaimPermission("PICKUP", () -> new ItemStack(Items.BRICK), true, "Allow the pickup of items"));
|
||||
public static ClaimPermission FLIGHT = register(new ClaimPermission("FLIGHT", () -> new ItemStack(Items.FEATHER), true, "Allow non creative flight"));
|
||||
|
||||
public static ClaimPermission HURTPLAYER = global(new ClaimPermission("HURTPLAYER", () -> new ItemStack(Items.DIAMOND_SWORD), "Permission to hurt other players"));
|
||||
public static ClaimPermission EXPLOSIONS = global(new ClaimPermission("EXPLOSIONS", () -> new ItemStack(Items.TNT), "Toggle explosions in claim"));
|
||||
|
@ -8,6 +8,8 @@ import com.flemmli97.flan.claim.PermHelper;
|
||||
import com.flemmli97.flan.config.ConfigHandler;
|
||||
import com.flemmli97.flan.gui.ClaimMenuScreenHandler;
|
||||
import com.flemmli97.flan.gui.PersonalGroupScreenHandler;
|
||||
import com.flemmli97.flan.integration.gunpowder.CommandCurrency;
|
||||
import com.flemmli97.flan.integration.permissionapi.CommandPermission;
|
||||
import com.flemmli97.flan.player.EnumDisplayType;
|
||||
import com.flemmli97.flan.player.EnumEditMode;
|
||||
import com.flemmli97.flan.player.OfflinePlayerData;
|
||||
|
@ -7,7 +7,7 @@ import com.flemmli97.flan.claim.ClaimStorage;
|
||||
import com.flemmli97.flan.claim.IPermissionContainer;
|
||||
import com.flemmli97.flan.claim.ObjectToPermissionMap;
|
||||
import com.flemmli97.flan.claim.PermHelper;
|
||||
import com.flemmli97.flan.commands.CommandPermission;
|
||||
import com.flemmli97.flan.integration.permissionapi.CommandPermission;
|
||||
import com.flemmli97.flan.config.ConfigHandler;
|
||||
import com.flemmli97.flan.player.EnumDisplayType;
|
||||
import com.flemmli97.flan.player.EnumEditMode;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.flemmli97.flan.commands;
|
||||
package com.flemmli97.flan.integration.gunpowder;
|
||||
|
||||
import com.flemmli97.flan.Flan;
|
||||
import com.flemmli97.flan.claim.PermHelper;
|
@ -1,4 +1,4 @@
|
||||
package com.flemmli97.flan.commands;
|
||||
package com.flemmli97.flan.integration.permissionapi;
|
||||
|
||||
import com.flemmli97.flan.Flan;
|
||||
import com.flemmli97.flan.config.ConfigHandler;
|
@ -0,0 +1,28 @@
|
||||
package com.flemmli97.flan.integration.playerability;
|
||||
|
||||
import com.flemmli97.flan.api.PermissionRegistry;
|
||||
import com.flemmli97.flan.claim.ClaimStorage;
|
||||
import com.flemmli97.flan.claim.IPermissionContainer;
|
||||
import io.github.ladysnake.pal.AbilitySource;
|
||||
import io.github.ladysnake.pal.PlayerAbility;
|
||||
import io.github.ladysnake.pal.PlayerAbilityEnableCallback;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class PlayerAbilityEvents {
|
||||
|
||||
public static void register() {
|
||||
PlayerAbilityEnableCallback.EVENT.register(PlayerAbilityEvents::checkAbility);
|
||||
}
|
||||
|
||||
public static boolean checkAbility(PlayerEntity player, PlayerAbility ability, AbilitySource abilitySource) {
|
||||
if (player.world.isClient)
|
||||
return true;
|
||||
BlockPos pos = player.getBlockPos();
|
||||
ClaimStorage storage = ClaimStorage.get((ServerWorld) player.world);
|
||||
IPermissionContainer claim = storage.getForPermissionCheck(pos);
|
||||
return claim.canInteract((ServerPlayerEntity) player, PermissionRegistry.FLIGHT, pos, true);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user