less strict check for fake players. also some reformatting
This commit is contained in:
parent
bea0349ddc
commit
0ac9453f7b
@ -4,7 +4,6 @@ import dev.architectury.injectables.annotations.ExpectPlatform;
|
|||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.effect.MobEffect;
|
import net.minecraft.world.effect.MobEffect;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
@ -47,8 +46,4 @@ public class CrossPlatformStuff {
|
|||||||
public static boolean blockDataContains(CompoundTag nbt, String tag) {
|
public static boolean blockDataContains(CompoundTag nbt, String tag) {
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isRealPlayer(Player player) {
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.google.common.collect.Lists;
|
|||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
import io.github.flemmli97.flan.CrossPlatformStuff;
|
import io.github.flemmli97.flan.CrossPlatformStuff;
|
||||||
import io.github.flemmli97.flan.Flan;
|
import io.github.flemmli97.flan.Flan;
|
||||||
import io.github.flemmli97.flan.api.data.IPermissionContainer;
|
import io.github.flemmli97.flan.api.data.IPermissionContainer;
|
||||||
@ -237,6 +238,7 @@ public class Claim implements IPermissionContainer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteract(ServerPlayer player, ClaimPermission perm, BlockPos pos, boolean message) {
|
public boolean canInteract(ServerPlayer player, ClaimPermission perm, BlockPos pos, boolean message) {
|
||||||
|
message = message && player.getClass().equals(ServerPlayer.class); //dont send messages to fake players
|
||||||
InteractionResult res = ClaimPermissionCheck.check(player, perm, pos);
|
InteractionResult res = ClaimPermissionCheck.check(player, perm, pos);
|
||||||
if (res != InteractionResult.PASS)
|
if (res != InteractionResult.PASS)
|
||||||
return res != InteractionResult.FAIL;
|
return res != InteractionResult.FAIL;
|
||||||
@ -706,8 +708,7 @@ public class Claim implements IPermissionContainer {
|
|||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj)
|
||||||
return true;
|
return true;
|
||||||
if (obj instanceof Claim) {
|
if (obj instanceof Claim other) {
|
||||||
Claim other = (Claim) obj;
|
|
||||||
if (this.claimID == null && other.claimID == null)
|
if (this.claimID == null && other.claimID == null)
|
||||||
return Arrays.equals(this.getDimensions(), ((Claim) obj).getDimensions());
|
return Arrays.equals(this.getDimensions(), ((Claim) obj).getDimensions());
|
||||||
if (this.claimID != null)
|
if (this.claimID != null)
|
||||||
@ -731,7 +732,7 @@ public class Claim implements IPermissionContainer {
|
|||||||
boolean perms = this.canInteract(player, PermissionRegistry.EDITPERMS, player.blockPosition());
|
boolean perms = this.canInteract(player, PermissionRegistry.EDITPERMS, player.blockPosition());
|
||||||
List<Component> l = new ArrayList<>();
|
List<Component> l = new ArrayList<>();
|
||||||
l.add(PermHelper.simpleColoredText("=============================================", ChatFormatting.GREEN));
|
l.add(PermHelper.simpleColoredText("=============================================", ChatFormatting.GREEN));
|
||||||
String ownerName = this.isAdminClaim() ? "Admin" : player.getServer().getProfileCache().get(this.owner).map(prof -> prof.getName()).orElse("<UNKNOWN>");
|
String ownerName = this.isAdminClaim() ? "Admin" : player.getServer().getProfileCache().get(this.owner).map(GameProfile::getName).orElse("<UNKNOWN>");
|
||||||
if (this.parent == null) {
|
if (this.parent == null) {
|
||||||
if (this.claimName.isEmpty())
|
if (this.claimName.isEmpty())
|
||||||
l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBasicInfo, ownerName, this.minX, this.minZ, this.maxX, this.maxZ, this.subClaims.size()), ChatFormatting.GOLD));
|
l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBasicInfo, ownerName, this.minX, this.minZ, this.maxX, this.maxZ, this.subClaims.size()), ChatFormatting.GOLD));
|
||||||
@ -778,9 +779,7 @@ public class Claim implements IPermissionContainer {
|
|||||||
|
|
||||||
interface ClaimUpdater {
|
interface ClaimUpdater {
|
||||||
|
|
||||||
Map<Integer, ClaimUpdater> updater = Config.createHashMap(map -> {
|
Map<Integer, ClaimUpdater> updater = Config.createHashMap(map -> map.put(2, claim -> claim.globalPerm.put(PermissionRegistry.LOCKITEMS, true)));
|
||||||
map.put(2, claim -> claim.globalPerm.put(PermissionRegistry.LOCKITEMS, true));
|
|
||||||
});
|
|
||||||
|
|
||||||
static void updateClaim(Claim claim) {
|
static void updateClaim(Claim claim) {
|
||||||
updater.entrySet().stream().filter(e -> e.getKey() > ConfigHandler.config.preConfigVersion).map(Map.Entry::getValue)
|
updater.entrySet().stream().filter(e -> e.getKey() > ConfigHandler.config.preConfigVersion).map(Map.Entry::getValue)
|
||||||
|
@ -91,7 +91,7 @@ public class ClaimStorage implements IPermissionStorage {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!data.isAdminIgnoreClaim() && ConfigHandler.config.maxClaims != -1 && !PermissionNodeHandler.permBelowEqVal(player, PermissionNodeHandler.permMaxClaims, this.playerClaimMap.getOrDefault(player.getUUID(), Sets.newHashSet()).size() + 1, ConfigHandler.config.maxClaims)) {
|
if (!data.isAdminIgnoreClaim() && ConfigHandler.config.maxClaims != -1 && !PermissionNodeHandler.permBelowEqVal(player, PermissionNodeHandler.permMaxClaims, this.playerClaimMap.getOrDefault(player.getUUID(), Sets.newHashSet()).size() + 1, ConfigHandler.config.maxClaims)) {
|
||||||
player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.maxClaims), ChatFormatting.RED), false);
|
player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.maxClaims, ChatFormatting.RED), false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!data.isAdminIgnoreClaim() && !data.canUseClaimBlocks(claim.getPlane())) {
|
if (!data.isAdminIgnoreClaim() && !data.canUseClaimBlocks(claim.getPlane())) {
|
||||||
|
@ -11,16 +11,11 @@ import net.minecraft.core.BlockPos;
|
|||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
|
||||||
public class GlobalClaim implements IPermissionContainer {
|
public record GlobalClaim(ServerLevel world) implements IPermissionContainer {
|
||||||
|
|
||||||
private final ServerLevel world;
|
|
||||||
|
|
||||||
public GlobalClaim(ServerLevel world) {
|
|
||||||
this.world = world;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteract(ServerPlayer player, ClaimPermission perm, BlockPos pos, boolean message) {
|
public boolean canInteract(ServerPlayer player, ClaimPermission perm, BlockPos pos, boolean message) {
|
||||||
|
message = message && player.getClass().equals(ServerPlayer.class); //dont send messages to fake players
|
||||||
Config.GlobalType global = ConfigHandler.config.getGlobal(this.world, perm);
|
Config.GlobalType global = ConfigHandler.config.getGlobal(this.world, perm);
|
||||||
if (global != Config.GlobalType.NONE && (player == null || !PlayerClaimData.get(player).isAdminIgnoreClaim())) {
|
if (global != Config.GlobalType.NONE && (player == null || !PlayerClaimData.get(player).isAdminIgnoreClaim())) {
|
||||||
if (global.getValue())
|
if (global.getValue())
|
||||||
|
@ -487,8 +487,7 @@ public class CommandClaim {
|
|||||||
|
|
||||||
private static int adminDeleteAll(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
private static int adminDeleteAll(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||||
CommandSourceStack src = context.getSource();
|
CommandSourceStack src = context.getSource();
|
||||||
if (src.getEntity() instanceof ServerPlayer) {
|
if (src.getEntity() instanceof ServerPlayer player) {
|
||||||
ServerPlayer player = (ServerPlayer) src.getEntity();
|
|
||||||
PlayerClaimData data = PlayerClaimData.get(player);
|
PlayerClaimData data = PlayerClaimData.get(player);
|
||||||
if (!data.confirmedDeleteAll()) {
|
if (!data.confirmedDeleteAll()) {
|
||||||
data.setConfirmDeleteAll(true);
|
data.setConfirmDeleteAll(true);
|
||||||
@ -634,34 +633,22 @@ public class CommandClaim {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static int editGlobalPerm(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
private static int editGlobalPerm(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||||
int mode = 0;
|
int mode = switch (StringArgumentType.getString(context, "toggle")) {
|
||||||
switch (StringArgumentType.getString(context, "toggle")) {
|
case "true" -> 1;
|
||||||
case "true":
|
case "false" -> 0;
|
||||||
mode = 1;
|
case "default" -> -1;
|
||||||
break;
|
default -> 0;
|
||||||
case "false":
|
};
|
||||||
mode = 0;
|
|
||||||
break;
|
|
||||||
case "default":
|
|
||||||
mode = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return editPerms(context, null, mode);
|
return editPerms(context, null, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int editGroupPerm(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
private static int editGroupPerm(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||||
int mode = 0;
|
int mode = switch (StringArgumentType.getString(context, "toggle")) {
|
||||||
switch (StringArgumentType.getString(context, "toggle")) {
|
case "true" -> 1;
|
||||||
case "true":
|
case "false" -> 0;
|
||||||
mode = 1;
|
case "default" -> -1;
|
||||||
break;
|
default -> 0;
|
||||||
case "false":
|
};
|
||||||
mode = 0;
|
|
||||||
break;
|
|
||||||
case "default":
|
|
||||||
mode = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return editPerms(context, StringArgumentType.getString(context, "group"), mode);
|
return editPerms(context, StringArgumentType.getString(context, "group"), mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -706,18 +693,12 @@ public class CommandClaim {
|
|||||||
private static int editPersonalPerm(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
private static int editPersonalPerm(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||||
String group = StringArgumentType.getString(context, "group");
|
String group = StringArgumentType.getString(context, "group");
|
||||||
int mode = 0;
|
int mode = switch (StringArgumentType.getString(context, "toggle")) {
|
||||||
switch (StringArgumentType.getString(context, "toggle")) {
|
case "true" -> 1;
|
||||||
case "true":
|
case "false" -> 0;
|
||||||
mode = 1;
|
case "default" -> -1;
|
||||||
break;
|
default -> 0;
|
||||||
case "false":
|
};
|
||||||
mode = 0;
|
|
||||||
break;
|
|
||||||
case "default":
|
|
||||||
mode = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ClaimPermission perm;
|
ClaimPermission perm;
|
||||||
String p = StringArgumentType.getString(context, "permission");
|
String p = StringArgumentType.getString(context, "permission");
|
||||||
try {
|
try {
|
||||||
|
@ -43,9 +43,8 @@ public class BlockInteractEvents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean breakBlocks(Level world, Player p, BlockPos pos, BlockState state, BlockEntity tile) {
|
public static boolean breakBlocks(Level world, Player p, BlockPos pos, BlockState state, BlockEntity tile) {
|
||||||
if (world.isClientSide || p.isSpectator())
|
if (!(p instanceof ServerPlayer player) || p.isSpectator())
|
||||||
return true;
|
return true;
|
||||||
ServerPlayer player = (ServerPlayer) p;
|
|
||||||
ClaimStorage storage = ClaimStorage.get((ServerLevel) world);
|
ClaimStorage storage = ClaimStorage.get((ServerLevel) world);
|
||||||
IPermissionContainer claim = storage.getForPermissionCheck(pos);
|
IPermissionContainer claim = storage.getForPermissionCheck(pos);
|
||||||
if (claim != null) {
|
if (claim != null) {
|
||||||
@ -62,9 +61,8 @@ public class BlockInteractEvents {
|
|||||||
|
|
||||||
//Right click block
|
//Right click block
|
||||||
public static InteractionResult useBlocks(Player p, Level world, InteractionHand hand, BlockHitResult hitResult) {
|
public static InteractionResult useBlocks(Player p, Level world, InteractionHand hand, BlockHitResult hitResult) {
|
||||||
if (world.isClientSide)
|
if (!(p instanceof ServerPlayer player))
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
ServerPlayer player = (ServerPlayer) p;
|
|
||||||
ItemStack stack = player.getItemInHand(hand);
|
ItemStack stack = player.getItemInHand(hand);
|
||||||
if (stack.getItem() == ConfigHandler.config.claimingItem) {
|
if (stack.getItem() == ConfigHandler.config.claimingItem) {
|
||||||
ItemInteractEvents.claimLandHandling(player, hitResult.getBlockPos());
|
ItemInteractEvents.claimLandHandling(player, hitResult.getBlockPos());
|
||||||
|
@ -63,7 +63,7 @@ public class EntityInteractEvents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static InteractionResult useAtEntity(Player player, Level world, InteractionHand hand, Entity entity, /* Nullable */ EntityHitResult hitResult) {
|
public static InteractionResult useAtEntity(Player player, Level world, InteractionHand hand, Entity entity, /* Nullable */ EntityHitResult hitResult) {
|
||||||
if (player.level.isClientSide || player.isSpectator() || canInteract(entity))
|
if (!(player instanceof ServerPlayer) || player.isSpectator() || canInteract(entity))
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
ClaimStorage storage = ClaimStorage.get((ServerLevel) world);
|
ClaimStorage storage = ClaimStorage.get((ServerLevel) world);
|
||||||
BlockPos pos = entity.blockPosition();
|
BlockPos pos = entity.blockPosition();
|
||||||
@ -78,9 +78,8 @@ public class EntityInteractEvents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static InteractionResult useEntity(Player p, Level world, InteractionHand hand, Entity entity) {
|
public static InteractionResult useEntity(Player p, Level world, InteractionHand hand, Entity entity) {
|
||||||
if (p.level.isClientSide || p.isSpectator() || canInteract(entity))
|
if (!(p instanceof ServerPlayer player) || p.isSpectator() || canInteract(entity))
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
ServerPlayer player = (ServerPlayer) p;
|
|
||||||
ClaimStorage storage = ClaimStorage.get((ServerLevel) world);
|
ClaimStorage storage = ClaimStorage.get((ServerLevel) world);
|
||||||
BlockPos pos = entity.blockPosition();
|
BlockPos pos = entity.blockPosition();
|
||||||
IPermissionContainer claim = storage.getForPermissionCheck(pos);
|
IPermissionContainer claim = storage.getForPermissionCheck(pos);
|
||||||
@ -96,8 +95,7 @@ public class EntityInteractEvents {
|
|||||||
return claim.canInteract(player, PermissionRegistry.TRADING, pos, true) ? InteractionResult.PASS : InteractionResult.FAIL;
|
return claim.canInteract(player, PermissionRegistry.TRADING, pos, true) ? InteractionResult.PASS : InteractionResult.FAIL;
|
||||||
if (entity instanceof ItemFrame)
|
if (entity instanceof ItemFrame)
|
||||||
return claim.canInteract(player, PermissionRegistry.ITEMFRAMEROTATE, pos, true) ? InteractionResult.PASS : InteractionResult.FAIL;
|
return claim.canInteract(player, PermissionRegistry.ITEMFRAMEROTATE, pos, true) ? InteractionResult.PASS : InteractionResult.FAIL;
|
||||||
if (entity instanceof TamableAnimal) {
|
if (entity instanceof TamableAnimal tame) {
|
||||||
TamableAnimal tame = (TamableAnimal) entity;
|
|
||||||
if (tame.isOwnedBy(player))
|
if (tame.isOwnedBy(player))
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
}
|
}
|
||||||
@ -117,8 +115,7 @@ public class EntityInteractEvents {
|
|||||||
if (proj.level.isClientSide)
|
if (proj.level.isClientSide)
|
||||||
return false;
|
return false;
|
||||||
Entity owner = proj.getOwner();
|
Entity owner = proj.getOwner();
|
||||||
if (owner instanceof ServerPlayer) {
|
if (owner instanceof ServerPlayer player) {
|
||||||
ServerPlayer player = (ServerPlayer) owner;
|
|
||||||
if (res.getType() == HitResult.Type.BLOCK) {
|
if (res.getType() == HitResult.Type.BLOCK) {
|
||||||
BlockHitResult blockRes = (BlockHitResult) res;
|
BlockHitResult blockRes = (BlockHitResult) res;
|
||||||
BlockPos pos = blockRes.getBlockPos();
|
BlockPos pos = blockRes.getBlockPos();
|
||||||
@ -138,8 +135,7 @@ public class EntityInteractEvents {
|
|||||||
return false;
|
return false;
|
||||||
boolean flag = !claim.canInteract(player, perm, pos, true);
|
boolean flag = !claim.canInteract(player, perm, pos, true);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
if (proj instanceof AbstractArrow) {
|
if (proj instanceof AbstractArrow pers) {
|
||||||
AbstractArrow pers = (AbstractArrow) proj;
|
|
||||||
((IPersistentProjectileVars) pers).setInBlockState(pers.level.getBlockState(pos));
|
((IPersistentProjectileVars) pers).setInBlockState(pers.level.getBlockState(pos));
|
||||||
Vec3 vec3d = blockRes.getLocation().subtract(pers.getX(), pers.getY(), pers.getZ());
|
Vec3 vec3d = blockRes.getLocation().subtract(pers.getX(), pers.getY(), pers.getZ());
|
||||||
pers.setDeltaMovement(vec3d);
|
pers.setDeltaMovement(vec3d);
|
||||||
@ -168,8 +164,7 @@ public class EntityInteractEvents {
|
|||||||
}
|
}
|
||||||
Entity hit = ((EntityHitResult) res).getEntity();
|
Entity hit = ((EntityHitResult) res).getEntity();
|
||||||
boolean fail = attackSimple(player, hit, true) != InteractionResult.PASS;
|
boolean fail = attackSimple(player, hit, true) != InteractionResult.PASS;
|
||||||
if (fail && proj instanceof AbstractArrow && ((AbstractArrow) proj).getPierceLevel() > 0) {
|
if (fail && proj instanceof AbstractArrow pers && ((AbstractArrow) proj).getPierceLevel() > 0) {
|
||||||
AbstractArrow pers = (AbstractArrow) proj;
|
|
||||||
IntOpenHashSet pierced = ((IPersistentProjectileVars) pers).getPiercedEntities();
|
IntOpenHashSet pierced = ((IPersistentProjectileVars) pers).getPiercedEntities();
|
||||||
if (pierced == null)
|
if (pierced == null)
|
||||||
pierced = new IntOpenHashSet(5);
|
pierced = new IntOpenHashSet(5);
|
||||||
@ -194,11 +189,10 @@ public class EntityInteractEvents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static InteractionResult attackSimple(Player p, Entity entity, boolean message) {
|
public static InteractionResult attackSimple(Player p, Entity entity, boolean message) {
|
||||||
if (p.level.isClientSide || p.isSpectator() || canInteract(entity))
|
if (!(p instanceof ServerPlayer player) || p.isSpectator() || canInteract(entity))
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
if (entity instanceof Enemy)
|
if (entity instanceof Enemy)
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
ServerPlayer player = (ServerPlayer) p;
|
|
||||||
ClaimStorage storage = ClaimStorage.get(player.getLevel());
|
ClaimStorage storage = ClaimStorage.get(player.getLevel());
|
||||||
BlockPos pos = entity.blockPosition();
|
BlockPos pos = entity.blockPosition();
|
||||||
IPermissionContainer claim = storage.getForPermissionCheck(pos);
|
IPermissionContainer claim = storage.getForPermissionCheck(pos);
|
||||||
@ -224,8 +218,7 @@ public class EntityInteractEvents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canCollideWith(Player player, Entity entity) {
|
public static boolean canCollideWith(Player player, Entity entity) {
|
||||||
if (player instanceof ServerPlayer) {
|
if (player instanceof ServerPlayer sPlayer) {
|
||||||
ServerPlayer sPlayer = (ServerPlayer) player;
|
|
||||||
if (entity instanceof ItemEntity) {
|
if (entity instanceof ItemEntity) {
|
||||||
IOwnedItem ownedItem = (IOwnedItem) entity;
|
IOwnedItem ownedItem = (IOwnedItem) entity;
|
||||||
if (ownedItem.getDeathPlayer() != null) {
|
if (ownedItem.getDeathPlayer() != null) {
|
||||||
@ -329,7 +322,7 @@ public class EntityInteractEvents {
|
|||||||
if (!currentClaim.canInteract(player, PermissionRegistry.CANSTAY, bPos, true)) {
|
if (!currentClaim.canInteract(player, PermissionRegistry.CANSTAY, bPos, true)) {
|
||||||
Claim sub = currentClaim.getSubClaim(bPos);
|
Claim sub = currentClaim.getSubClaim(bPos);
|
||||||
Vec3 tp = TeleportUtils.getTeleportPos(player, pos, storage, sub != null ? sub.getDimensions() : currentClaim.getDimensions(), true, bPos, (claim, nPos) -> claim.canInteract(player, PermissionRegistry.CANSTAY, nPos, false));
|
Vec3 tp = TeleportUtils.getTeleportPos(player, pos, storage, sub != null ? sub.getDimensions() : currentClaim.getDimensions(), true, bPos, (claim, nPos) -> claim.canInteract(player, PermissionRegistry.CANSTAY, nPos, false));
|
||||||
if(player.isPassenger())
|
if (player.isPassenger())
|
||||||
player.stopRiding();
|
player.stopRiding();
|
||||||
player.teleportToWithTicket(tp.x(), tp.y(), tp.z());
|
player.teleportToWithTicket(tp.x(), tp.y(), tp.z());
|
||||||
}
|
}
|
||||||
|
@ -43,9 +43,8 @@ import java.util.Set;
|
|||||||
public class ItemInteractEvents {
|
public class ItemInteractEvents {
|
||||||
|
|
||||||
public static InteractionResultHolder<ItemStack> useItem(Player p, Level world, InteractionHand hand) {
|
public static InteractionResultHolder<ItemStack> useItem(Player p, Level world, InteractionHand hand) {
|
||||||
if (world.isClientSide || p.isSpectator())
|
if (!(p instanceof ServerPlayer player) || p.isSpectator())
|
||||||
return InteractionResultHolder.pass(p.getItemInHand(hand));
|
return InteractionResultHolder.pass(p.getItemInHand(hand));
|
||||||
ServerPlayer player = (ServerPlayer) p;
|
|
||||||
ItemStack stack = player.getItemInHand(hand);
|
ItemStack stack = player.getItemInHand(hand);
|
||||||
if (stack.getItem() == ConfigHandler.config.claimingItem) {
|
if (stack.getItem() == ConfigHandler.config.claimingItem) {
|
||||||
HitResult ray = player.pick(64, 0, false);
|
HitResult ray = player.pick(64, 0, false);
|
||||||
@ -96,8 +95,7 @@ public class ItemInteractEvents {
|
|||||||
private static final Set<Item> blackListedItems = Sets.newHashSet(Items.COMPASS, Items.FILLED_MAP, Items.FIREWORK_ROCKET);
|
private static final Set<Item> blackListedItems = Sets.newHashSet(Items.COMPASS, Items.FILLED_MAP, Items.FIREWORK_ROCKET);
|
||||||
|
|
||||||
public static InteractionResult onItemUseBlock(UseOnContext context) {
|
public static InteractionResult onItemUseBlock(UseOnContext context) {
|
||||||
//Check for Fakeplayer. Since there is no api for that directly check the class
|
if (!(context.getPlayer() instanceof ServerPlayer player) || context.getItemInHand().isEmpty())
|
||||||
if (!(context.getPlayer() instanceof ServerPlayer) || !context.getPlayer().getClass().equals(ServerPlayer.class) || context.getItemInHand().isEmpty())
|
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
ClaimStorage storage = ClaimStorage.get((ServerLevel) context.getLevel());
|
ClaimStorage storage = ClaimStorage.get((ServerLevel) context.getLevel());
|
||||||
BlockPos placePos = new BlockPlaceContext(context).getClickedPos();
|
BlockPos placePos = new BlockPlaceContext(context).getClickedPos();
|
||||||
@ -107,7 +105,6 @@ public class ItemInteractEvents {
|
|||||||
if (blackListedItems.contains(context.getItemInHand().getItem()))
|
if (blackListedItems.contains(context.getItemInHand().getItem()))
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
boolean actualInClaim = !(claim instanceof Claim) || placePos.getY() >= ((Claim) claim).getDimensions()[4];
|
boolean actualInClaim = !(claim instanceof Claim) || placePos.getY() >= ((Claim) claim).getDimensions()[4];
|
||||||
ServerPlayer player = (ServerPlayer) context.getPlayer();
|
|
||||||
ClaimPermission perm = ObjectToPermissionMap.getFromItem(context.getItemInHand().getItem());
|
ClaimPermission perm = ObjectToPermissionMap.getFromItem(context.getItemInHand().getItem());
|
||||||
if (perm != null) {
|
if (perm != null) {
|
||||||
if (claim.canInteract(player, perm, placePos, false))
|
if (claim.canInteract(player, perm, placePos, false))
|
||||||
|
@ -81,10 +81,9 @@ public class WorldEvents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean lightningFire(LightningBolt lightning) {
|
public static boolean lightningFire(LightningBolt lightning) {
|
||||||
if (!(lightning.level instanceof ServerLevel))
|
if (!(lightning.level instanceof ServerLevel world))
|
||||||
return true;
|
return true;
|
||||||
BlockPos.MutableBlockPos mutable = lightning.blockPosition().mutable();
|
BlockPos.MutableBlockPos mutable = lightning.blockPosition().mutable();
|
||||||
ServerLevel world = (ServerLevel) lightning.level;
|
|
||||||
for (int x = -1; x <= 1; x++)
|
for (int x = -1; x <= 1; x++)
|
||||||
for (int z = -1; z <= 1; z++) {
|
for (int z = -1; z <= 1; z++) {
|
||||||
mutable.set(mutable.getX() + x, mutable.getY(), mutable.getZ() + z);
|
mutable.set(mutable.getX() + x, mutable.getY(), mutable.getZ() + z);
|
||||||
|
@ -48,48 +48,47 @@ public class ClaimMenuScreenHandler extends ServerOnlyScreenHandler<Claim> {
|
|||||||
protected void fillInventoryWith(Player player, SeparateInv inv, Claim claim) {
|
protected void fillInventoryWith(Player player, SeparateInv inv, Claim claim) {
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0 -> {
|
||||||
ItemStack close = new ItemStack(Items.TNT);
|
ItemStack close = new ItemStack(Items.TNT);
|
||||||
close.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenClose, ChatFormatting.DARK_RED));
|
close.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenClose, ChatFormatting.DARK_RED));
|
||||||
inv.updateStack(i, close);
|
inv.updateStack(i, close);
|
||||||
break;
|
}
|
||||||
case 2:
|
case 2 -> {
|
||||||
ItemStack perm = new ItemStack(Items.BEACON);
|
ItemStack perm = new ItemStack(Items.BEACON);
|
||||||
perm.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuGlobal, ChatFormatting.GOLD));
|
perm.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuGlobal, ChatFormatting.GOLD));
|
||||||
if (player instanceof ServerPlayer && !this.hasEditPerm(claim, (ServerPlayer) player))
|
if (player instanceof ServerPlayer && !this.hasEditPerm(claim, (ServerPlayer) player))
|
||||||
ServerScreenHelper.addLore(perm, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, ChatFormatting.DARK_RED));
|
ServerScreenHelper.addLore(perm, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, ChatFormatting.DARK_RED));
|
||||||
inv.updateStack(i, perm);
|
inv.updateStack(i, perm);
|
||||||
break;
|
}
|
||||||
case 3:
|
case 3 -> {
|
||||||
ItemStack group = new ItemStack(Items.WRITABLE_BOOK);
|
ItemStack group = new ItemStack(Items.WRITABLE_BOOK);
|
||||||
group.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuGroup, ChatFormatting.GOLD));
|
group.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuGroup, ChatFormatting.GOLD));
|
||||||
if (player instanceof ServerPlayer && !this.hasEditPerm(claim, (ServerPlayer) player))
|
if (player instanceof ServerPlayer && !this.hasEditPerm(claim, (ServerPlayer) player))
|
||||||
ServerScreenHelper.addLore(group, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, ChatFormatting.DARK_RED));
|
ServerScreenHelper.addLore(group, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, ChatFormatting.DARK_RED));
|
||||||
inv.updateStack(i, group);
|
inv.updateStack(i, group);
|
||||||
break;
|
}
|
||||||
case 4:
|
case 4 -> {
|
||||||
ItemStack potions = new ItemStack(Items.POTION);
|
ItemStack potions = new ItemStack(Items.POTION);
|
||||||
potions.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuPotion, ChatFormatting.GOLD));
|
potions.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuPotion, ChatFormatting.GOLD));
|
||||||
if (player instanceof ServerPlayer && !this.hasPerm(claim, (ServerPlayer) player, PermissionRegistry.EDITPOTIONS))
|
if (player instanceof ServerPlayer && !this.hasPerm(claim, (ServerPlayer) player, PermissionRegistry.EDITPOTIONS))
|
||||||
ServerScreenHelper.addLore(potions, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, ChatFormatting.DARK_RED));
|
ServerScreenHelper.addLore(potions, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, ChatFormatting.DARK_RED));
|
||||||
inv.updateStack(i, potions);
|
inv.updateStack(i, potions);
|
||||||
break;
|
}
|
||||||
case 5:
|
case 5 -> {
|
||||||
ItemStack sign = new ItemStack(Items.OAK_SIGN);
|
ItemStack sign = new ItemStack(Items.OAK_SIGN);
|
||||||
sign.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuClaimText, ChatFormatting.GOLD));
|
sign.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuClaimText, ChatFormatting.GOLD));
|
||||||
if (player instanceof ServerPlayer && !this.hasPerm(claim, (ServerPlayer) player, PermissionRegistry.EDITCLAIM))
|
if (player instanceof ServerPlayer && !this.hasPerm(claim, (ServerPlayer) player, PermissionRegistry.EDITCLAIM))
|
||||||
ServerScreenHelper.addLore(sign, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, ChatFormatting.DARK_RED));
|
ServerScreenHelper.addLore(sign, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, ChatFormatting.DARK_RED));
|
||||||
inv.updateStack(i, sign);
|
inv.updateStack(i, sign);
|
||||||
break;
|
}
|
||||||
case 8:
|
case 8 -> {
|
||||||
ItemStack delete = new ItemStack(Items.BARRIER);
|
ItemStack delete = new ItemStack(Items.BARRIER);
|
||||||
delete.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuDelete, ChatFormatting.RED));
|
delete.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuDelete, ChatFormatting.RED));
|
||||||
if (player instanceof ServerPlayer && !this.hasPerm(claim, (ServerPlayer) player, PermissionRegistry.EDITCLAIM))
|
if (player instanceof ServerPlayer && !this.hasPerm(claim, (ServerPlayer) player, PermissionRegistry.EDITCLAIM))
|
||||||
ServerScreenHelper.addLore(delete, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, ChatFormatting.DARK_RED));
|
ServerScreenHelper.addLore(delete, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, ChatFormatting.DARK_RED));
|
||||||
inv.updateStack(i, delete);
|
inv.updateStack(i, delete);
|
||||||
break;
|
}
|
||||||
default:
|
default -> inv.updateStack(i, ServerScreenHelper.emptyFiller());
|
||||||
inv.updateStack(i, ServerScreenHelper.emptyFiller());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,41 +51,40 @@ public class ClaimTextHandler extends ServerOnlyScreenHandler<Claim> {
|
|||||||
protected void fillInventoryWith(Player player, SeparateInv inv, Claim claim) {
|
protected void fillInventoryWith(Player player, SeparateInv inv, Claim claim) {
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0 -> {
|
||||||
ItemStack close = new ItemStack(Items.TNT);
|
ItemStack close = new ItemStack(Items.TNT);
|
||||||
close.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, ChatFormatting.DARK_RED));
|
close.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, ChatFormatting.DARK_RED));
|
||||||
inv.updateStack(i, close);
|
inv.updateStack(i, close);
|
||||||
break;
|
}
|
||||||
case 2:
|
case 2 -> {
|
||||||
ItemStack stack = new ItemStack(Items.OAK_SIGN);
|
ItemStack stack = new ItemStack(Items.OAK_SIGN);
|
||||||
stack.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenEnterText, ChatFormatting.GOLD));
|
stack.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenEnterText, ChatFormatting.GOLD));
|
||||||
if (claim.enterTitle != null)
|
if (claim.enterTitle != null)
|
||||||
ServerScreenHelper.addLore(stack, claim.enterTitle);
|
ServerScreenHelper.addLore(stack, claim.enterTitle);
|
||||||
inv.updateStack(i, stack);
|
inv.updateStack(i, stack);
|
||||||
break;
|
}
|
||||||
case 3:
|
case 3 -> {
|
||||||
ItemStack stack2 = new ItemStack(Items.OAK_SIGN);
|
ItemStack stack2 = new ItemStack(Items.OAK_SIGN);
|
||||||
stack2.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenEnterSubText, ChatFormatting.GOLD));
|
stack2.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenEnterSubText, ChatFormatting.GOLD));
|
||||||
if (claim.enterSubtitle != null)
|
if (claim.enterSubtitle != null)
|
||||||
ServerScreenHelper.addLore(stack2, claim.enterSubtitle);
|
ServerScreenHelper.addLore(stack2, claim.enterSubtitle);
|
||||||
inv.updateStack(i, stack2);
|
inv.updateStack(i, stack2);
|
||||||
break;
|
}
|
||||||
case 4:
|
case 4 -> {
|
||||||
ItemStack stack3 = new ItemStack(Items.OAK_SIGN);
|
ItemStack stack3 = new ItemStack(Items.OAK_SIGN);
|
||||||
stack3.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenLeaveText, ChatFormatting.GOLD));
|
stack3.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenLeaveText, ChatFormatting.GOLD));
|
||||||
if (claim.leaveTitle != null)
|
if (claim.leaveTitle != null)
|
||||||
ServerScreenHelper.addLore(stack3, claim.leaveTitle);
|
ServerScreenHelper.addLore(stack3, claim.leaveTitle);
|
||||||
inv.updateStack(i, stack3);
|
inv.updateStack(i, stack3);
|
||||||
break;
|
}
|
||||||
case 5:
|
case 5 -> {
|
||||||
ItemStack stack4 = new ItemStack(Items.OAK_SIGN);
|
ItemStack stack4 = new ItemStack(Items.OAK_SIGN);
|
||||||
stack4.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenLeaveSubText, ChatFormatting.GOLD));
|
stack4.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenLeaveSubText, ChatFormatting.GOLD));
|
||||||
if (claim.leaveSubtitle != null)
|
if (claim.leaveSubtitle != null)
|
||||||
ServerScreenHelper.addLore(stack4, claim.leaveSubtitle);
|
ServerScreenHelper.addLore(stack4, claim.leaveSubtitle);
|
||||||
inv.updateStack(i, stack4);
|
inv.updateStack(i, stack4);
|
||||||
break;
|
}
|
||||||
default:
|
default -> inv.updateStack(i, ServerScreenHelper.emptyFiller());
|
||||||
inv.updateStack(i, ServerScreenHelper.emptyFiller());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -102,21 +101,13 @@ public class ClaimTextHandler extends ServerOnlyScreenHandler<Claim> {
|
|||||||
player.getServer().execute(() -> ClaimMenuScreenHandler.openClaimMenu(player, this.claim));
|
player.getServer().execute(() -> ClaimMenuScreenHandler.openClaimMenu(player, this.claim));
|
||||||
ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f);
|
ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f);
|
||||||
} else {
|
} else {
|
||||||
Consumer<Component> cons = null;
|
Consumer<Component> cons = switch (index) {
|
||||||
switch (index) {
|
case 2 -> text -> this.claim.setEnterTitle(text, this.claim.enterSubtitle);
|
||||||
case 2:
|
case 3 -> text -> this.claim.setEnterTitle(this.claim.enterTitle, text);
|
||||||
cons = text -> this.claim.setEnterTitle(text, this.claim.enterSubtitle);
|
case 4 -> text -> this.claim.setLeaveTitle(text, this.claim.leaveSubtitle);
|
||||||
break;
|
case 5 -> text -> this.claim.setLeaveTitle(this.claim.leaveTitle, text);
|
||||||
case 3:
|
default -> null;
|
||||||
cons = text -> this.claim.setEnterTitle(this.claim.enterTitle, text);
|
};
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
cons = text -> this.claim.setLeaveTitle(text, this.claim.leaveSubtitle);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
cons = text -> this.claim.setLeaveTitle(this.claim.leaveTitle, text);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (cons != null) {
|
if (cons != null) {
|
||||||
player.closeContainer();
|
player.closeContainer();
|
||||||
Consumer<Component> finalCons = cons;
|
Consumer<Component> finalCons = cons;
|
||||||
|
@ -45,18 +45,17 @@ public class ConfirmScreenHandler extends ServerOnlyScreenHandler<Object> {
|
|||||||
protected void fillInventoryWith(Player player, SeparateInv inv, Object additionalData) {
|
protected void fillInventoryWith(Player player, SeparateInv inv, Object additionalData) {
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 3:
|
case 3 -> {
|
||||||
ItemStack yes = new ItemStack(Items.GREEN_WOOL);
|
ItemStack yes = new ItemStack(Items.GREEN_WOOL);
|
||||||
yes.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenYes, ChatFormatting.GREEN));
|
yes.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenYes, ChatFormatting.GREEN));
|
||||||
inv.updateStack(i, yes);
|
inv.updateStack(i, yes);
|
||||||
break;
|
}
|
||||||
case 5:
|
case 5 -> {
|
||||||
ItemStack no = new ItemStack(Items.RED_WOOL);
|
ItemStack no = new ItemStack(Items.RED_WOOL);
|
||||||
no.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNo, ChatFormatting.RED));
|
no.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNo, ChatFormatting.RED));
|
||||||
inv.updateStack(i, no);
|
inv.updateStack(i, no);
|
||||||
break;
|
}
|
||||||
default:
|
default -> inv.updateStack(i, ServerScreenHelper.emptyFiller());
|
||||||
inv.updateStack(i, ServerScreenHelper.emptyFiller());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,12 +68,8 @@ public class ConfirmScreenHandler extends ServerOnlyScreenHandler<Object> {
|
|||||||
@Override
|
@Override
|
||||||
protected boolean handleSlotClicked(ServerPlayer player, int index, Slot slot, int clickType) {
|
protected boolean handleSlotClicked(ServerPlayer player, int index, Slot slot, int clickType) {
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 3:
|
case 3 -> this.cons.accept(true);
|
||||||
this.cons.accept(true);
|
case 5 -> this.cons.accept(false);
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
this.cons.accept(false);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ import net.minecraft.world.item.ItemStack;
|
|||||||
public abstract class ServerOnlyScreenHandler<T> extends AbstractContainerMenu {
|
public abstract class ServerOnlyScreenHandler<T> extends AbstractContainerMenu {
|
||||||
|
|
||||||
private final SeparateInvImpl inventory;
|
private final SeparateInvImpl inventory;
|
||||||
private boolean update = true;
|
|
||||||
|
|
||||||
protected ServerOnlyScreenHandler(int syncId, Inventory playerInventory, int rows, T additionalData) {
|
protected ServerOnlyScreenHandler(int syncId, Inventory playerInventory, int rows, T additionalData) {
|
||||||
super(fromRows(rows), syncId);
|
super(fromRows(rows), syncId);
|
||||||
@ -65,19 +64,14 @@ public abstract class ServerOnlyScreenHandler<T> extends AbstractContainerMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static MenuType<ChestMenu> fromRows(int rows) {
|
private static MenuType<ChestMenu> fromRows(int rows) {
|
||||||
switch (rows) {
|
return switch (rows) {
|
||||||
case 2:
|
case 2 -> MenuType.GENERIC_9x2;
|
||||||
return MenuType.GENERIC_9x2;
|
case 3 -> MenuType.GENERIC_9x3;
|
||||||
case 3:
|
case 4 -> MenuType.GENERIC_9x4;
|
||||||
return MenuType.GENERIC_9x3;
|
case 5 -> MenuType.GENERIC_9x5;
|
||||||
case 4:
|
case 6 -> MenuType.GENERIC_9x6;
|
||||||
return MenuType.GENERIC_9x4;
|
default -> MenuType.GENERIC_9x1;
|
||||||
case 5:
|
};
|
||||||
return MenuType.GENERIC_9x5;
|
|
||||||
case 6:
|
|
||||||
return MenuType.GENERIC_9x6;
|
|
||||||
}
|
|
||||||
return MenuType.GENERIC_9x1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void fillInventoryWith(Player player, SeparateInv inv, T additionalData);
|
protected abstract void fillInventoryWith(Player player, SeparateInv inv, T additionalData);
|
||||||
@ -112,24 +106,6 @@ public abstract class ServerOnlyScreenHandler<T> extends AbstractContainerMenu {
|
|||||||
return slot.getItem().copy();
|
return slot.getItem().copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@Override
|
|
||||||
public void addSlotListener(ContainerListener listener) {
|
|
||||||
this.update = false;
|
|
||||||
super.addSlotListener(listener);
|
|
||||||
if (!this.listeners.contains(listener)) {
|
|
||||||
this.listeners.add(listener);
|
|
||||||
listener.refreshContainer(this, this.getItems());
|
|
||||||
this.update = true;
|
|
||||||
this.broadcastChanges();
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void broadcastChanges() {
|
|
||||||
//if (this.update)
|
|
||||||
super.broadcastChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract boolean isRightSlot(int slot);
|
protected abstract boolean isRightSlot(int slot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,30 +53,18 @@ public class ServerScreenHelper {
|
|||||||
if (claim.parentClaim() == null)
|
if (claim.parentClaim() == null)
|
||||||
permFlag = "" + (claim.permEnabled(perm) == 1);
|
permFlag = "" + (claim.permEnabled(perm) == 1);
|
||||||
else {
|
else {
|
||||||
switch (claim.permEnabled(perm)) {
|
permFlag = switch (claim.permEnabled(perm)) {
|
||||||
case -1:
|
case -1 -> ConfigHandler.lang.screenDefault;
|
||||||
permFlag = ConfigHandler.lang.screenDefault;
|
case 1 -> ConfigHandler.lang.screenTrue;
|
||||||
break;
|
default -> ConfigHandler.lang.screenFalse;
|
||||||
case 1:
|
};
|
||||||
permFlag = ConfigHandler.lang.screenTrue;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
permFlag = ConfigHandler.lang.screenFalse;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (claim.groupHasPerm(group, perm)) {
|
permFlag = switch (claim.groupHasPerm(group, perm)) {
|
||||||
case -1:
|
case -1 -> ConfigHandler.lang.screenDefault;
|
||||||
permFlag = ConfigHandler.lang.screenDefault;
|
case 1 -> ConfigHandler.lang.screenTrue;
|
||||||
break;
|
default -> ConfigHandler.lang.screenFalse;
|
||||||
case 1:
|
};
|
||||||
permFlag = ConfigHandler.lang.screenTrue;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
permFlag = ConfigHandler.lang.screenFalse;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Component text = ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenEnableText, permFlag), permFlag.equals(ConfigHandler.lang.screenTrue) ? ChatFormatting.GREEN : ChatFormatting.RED);
|
Component text = ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenEnableText, permFlag), permFlag.equals(ConfigHandler.lang.screenTrue) ? ChatFormatting.GREEN : ChatFormatting.RED);
|
||||||
lore.add(text);
|
lore.add(text);
|
||||||
|
@ -71,9 +71,8 @@ public class StringResultScreenHandler extends AnvilMenu {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clicked(int i, int j, ClickType actionType, Player playerEntity) {
|
public void clicked(int i, int j, ClickType actionType, Player playerEntity) {
|
||||||
if (i < 0 || !(playerEntity instanceof ServerPlayer))
|
if (i < 0 || !(playerEntity instanceof ServerPlayer player))
|
||||||
return;
|
return;
|
||||||
ServerPlayer player = (ServerPlayer) playerEntity;
|
|
||||||
Slot slot = this.slots.get(i);
|
Slot slot = this.slots.get(i);
|
||||||
if (((AbstractContainerAccessor) this).containerSync() != null)
|
if (((AbstractContainerAccessor) this).containerSync() != null)
|
||||||
((AbstractContainerAccessor) this).containerSync().sendCarriedChange(this, this.getCarried().copy());
|
((AbstractContainerAccessor) this).containerSync().sendCarriedChange(this, this.getCarried().copy());
|
||||||
@ -105,15 +104,6 @@ public class StringResultScreenHandler extends AnvilMenu {
|
|||||||
this.broadcastChanges();
|
this.broadcastChanges();
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
@Override
|
|
||||||
public void addSlotListener(ContainerListener listener) {
|
|
||||||
if (!this.listeners.contains(listener)) {
|
|
||||||
this.listeners.add(listener);
|
|
||||||
listener.refreshContainer(this, this.getItems());
|
|
||||||
this.broadcastChanges();
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void broadcastChanges() {
|
public void broadcastChanges() {
|
||||||
|
@ -29,16 +29,6 @@ public abstract class PlayerClaimMixin implements IPlayerClaimImpl {
|
|||||||
this.flanClaimData = new PlayerClaimData((ServerPlayer) (Object) this);
|
this.flanClaimData = new PlayerClaimData((ServerPlayer) (Object) this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@Inject(method = "readCustomDataFromTag", at = @At("RETURN"))
|
|
||||||
private void readData(CompoundTag tag, CallbackInfo info) {
|
|
||||||
this.claimData.read(this.server);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "writeCustomDataToTag", at = @At("RETURN"))
|
|
||||||
private void writeData(CompoundTag tag, CallbackInfo info) {
|
|
||||||
this.claimData.save(this.server);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@Inject(method = "tick", at = @At("HEAD"))
|
@Inject(method = "tick", at = @At("HEAD"))
|
||||||
private void tickData(CallbackInfo info) {
|
private void tickData(CallbackInfo info) {
|
||||||
this.flanClaimData.tick(this.flanCurrentClaim, claim -> this.flanCurrentClaim = claim);
|
this.flanClaimData.tick(this.flanCurrentClaim, claim -> this.flanCurrentClaim = claim);
|
||||||
|
@ -38,22 +38,22 @@ public class ClaimDisplay {
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
this.height = Math.max(1 + claim.getWorld().getMinBuildHeight(), y);
|
this.height = Math.max(1 + claim.getWorld().getMinBuildHeight(), y);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SUB:
|
case SUB -> {
|
||||||
this.corner = ParticleIndicators.SUBCLAIMCORNER;
|
this.corner = ParticleIndicators.SUBCLAIMCORNER;
|
||||||
this.middle = ParticleIndicators.SUBCLAIMMIDDLE;
|
this.middle = ParticleIndicators.SUBCLAIMMIDDLE;
|
||||||
break;
|
}
|
||||||
case CONFLICT:
|
case CONFLICT -> {
|
||||||
this.corner = ParticleIndicators.OVERLAPCLAIM;
|
this.corner = ParticleIndicators.OVERLAPCLAIM;
|
||||||
this.middle = ParticleIndicators.OVERLAPCLAIM;
|
this.middle = ParticleIndicators.OVERLAPCLAIM;
|
||||||
break;
|
}
|
||||||
case EDIT:
|
case EDIT -> {
|
||||||
this.corner = ParticleIndicators.EDITCLAIMCORNER;
|
this.corner = ParticleIndicators.EDITCLAIMCORNER;
|
||||||
this.middle = ParticleIndicators.EDITCLAIMMIDDLE;
|
this.middle = ParticleIndicators.EDITCLAIMMIDDLE;
|
||||||
break;
|
}
|
||||||
default:
|
default -> {
|
||||||
this.corner = ParticleIndicators.CLAIMCORNER;
|
this.corner = ParticleIndicators.CLAIMCORNER;
|
||||||
this.middle = ParticleIndicators.CLAIMMIDDLE;
|
this.middle = ParticleIndicators.CLAIMMIDDLE;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,8 +159,7 @@ public class PlayerClaimData implements IPlayerData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addDisplayClaim(IPermissionContainer cont, EnumDisplayType type, int height) {
|
public void addDisplayClaim(IPermissionContainer cont, EnumDisplayType type, int height) {
|
||||||
if (cont instanceof Claim) {
|
if (cont instanceof Claim claim) {
|
||||||
Claim claim = (Claim) cont;
|
|
||||||
this.displayToAdd.add(new ClaimDisplay(claim, type, height));
|
this.displayToAdd.add(new ClaimDisplay(claim, type, height));
|
||||||
if (type == EnumDisplayType.MAIN)
|
if (type == EnumDisplayType.MAIN)
|
||||||
for (Claim sub : claim.getAllSubclaims())
|
for (Claim sub : claim.getAllSubclaims())
|
||||||
@ -306,7 +305,7 @@ public class PlayerClaimData implements IPlayerData {
|
|||||||
tpTo.set(tpTo.getX(), tpTo.getY() + 1, tpTo.getZ());
|
tpTo.set(tpTo.getX(), tpTo.getY() + 1, tpTo.getZ());
|
||||||
} else
|
} else
|
||||||
tpTo.set(tpTo.getX(), yHighest, tpTo.getZ());
|
tpTo.set(tpTo.getX(), yHighest, tpTo.getZ());
|
||||||
if(this.player.isPassenger())
|
if (this.player.isPassenger())
|
||||||
this.player.stopRiding();
|
this.player.stopRiding();
|
||||||
this.player.teleportToWithTicket(tpTo.getX() + 0.5, tpTo.getY(), tpTo.getZ() + 0.5);
|
this.player.teleportToWithTicket(tpTo.getX() + 0.5, tpTo.getY(), tpTo.getZ() + 0.5);
|
||||||
this.tpPos = null;
|
this.tpPos = null;
|
||||||
@ -314,7 +313,7 @@ public class PlayerClaimData implements IPlayerData {
|
|||||||
Vec3 tp = TeleportUtils.getTeleportPos(this.player, this.player.position(), ClaimStorage.get(this.player.getLevel()),
|
Vec3 tp = TeleportUtils.getTeleportPos(this.player, this.player.position(), ClaimStorage.get(this.player.getLevel()),
|
||||||
((IPlayerClaimImpl) this.player).getCurrentClaim().getDimensions(),
|
((IPlayerClaimImpl) this.player).getCurrentClaim().getDimensions(),
|
||||||
TeleportUtils.roundedBlockPos(this.player.position()).mutable(), (claim, nPos) -> false);
|
TeleportUtils.roundedBlockPos(this.player.position()).mutable(), (claim, nPos) -> false);
|
||||||
if(this.player.isPassenger())
|
if (this.player.isPassenger())
|
||||||
this.player.stopRiding();
|
this.player.stopRiding();
|
||||||
this.player.teleportToWithTicket(tp.x(), tp.y(), tp.z());
|
this.player.teleportToWithTicket(tp.x(), tp.y(), tp.z());
|
||||||
}
|
}
|
||||||
@ -454,9 +453,7 @@ public class PlayerClaimData implements IPlayerData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void updateScoreFor(ServerPlayer player, ObjectiveCriteria criterion, int val) {
|
public static void updateScoreFor(ServerPlayer player, ObjectiveCriteria criterion, int val) {
|
||||||
player.getScoreboard().forAllObjectives(criterion, player.getScoreboardName(), (scoreboardPlayerScore) -> {
|
player.getScoreboard().forAllObjectives(criterion, player.getScoreboardName(), (scoreboardPlayerScore) -> scoreboardPlayerScore.setScore(val));
|
||||||
scoreboardPlayerScore.setScore(val);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void editForOfflinePlayer(MinecraftServer server, UUID uuid, int additionalClaimBlocks) {
|
public static void editForOfflinePlayer(MinecraftServer server, UUID uuid, int additionalClaimBlocks) {
|
||||||
|
@ -43,18 +43,10 @@ public class TeleportUtils {
|
|||||||
}
|
}
|
||||||
int[] newDim = claim.getDimensions();
|
int[] newDim = claim.getDimensions();
|
||||||
switch (pos.getA()) {
|
switch (pos.getA()) {
|
||||||
case NORTH:
|
case NORTH -> dim[2] = newDim[2];
|
||||||
dim[2] = newDim[2];
|
case SOUTH -> dim[3] = newDim[3];
|
||||||
break;
|
case EAST -> dim[1] = newDim[1];
|
||||||
case SOUTH:
|
default -> dim[0] = newDim[0];
|
||||||
dim[3] = newDim[3];
|
|
||||||
break;
|
|
||||||
case EAST:
|
|
||||||
dim[1] = newDim[1];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
dim[0] = newDim[0];
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return getTeleportPos(player, playerPos, storage, dim, checkSub, bPos, check);
|
return getTeleportPos(player, playerPos, storage, dim, checkSub, bPos, check);
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,7 @@ import io.github.flemmli97.flan.SimpleRegistryWrapper;
|
|||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class FabricRegistryWrapper<T> implements SimpleRegistryWrapper<T> {
|
public record FabricRegistryWrapper<T>(Registry<T> delegate) implements SimpleRegistryWrapper<T> {
|
||||||
|
|
||||||
private final Registry<T> delegate;
|
|
||||||
|
|
||||||
public FabricRegistryWrapper(Registry<T> delegate) {
|
|
||||||
this.delegate = delegate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T getFromId(ResourceLocation id) {
|
public T getFromId(ResourceLocation id) {
|
||||||
|
@ -15,8 +15,7 @@ public class PermissionNodeHandlerImpl {
|
|||||||
return Permissions.check(src, perm, ConfigHandler.config.permissionLevel);
|
return Permissions.check(src, perm, ConfigHandler.config.permissionLevel);
|
||||||
return Permissions.check(src, perm, true);
|
return Permissions.check(src, perm, true);
|
||||||
}
|
}
|
||||||
if (Flan.ftbRanks && src.getEntity() instanceof ServerPlayer) {
|
if (Flan.ftbRanks && src.getEntity() instanceof ServerPlayer player) {
|
||||||
ServerPlayer player = (ServerPlayer) src.getEntity();
|
|
||||||
return FTBRanksAPI.getPermissionValue(player, perm).asBoolean().orElse(!adminCmd || player.hasPermissions(ConfigHandler.config.permissionLevel));
|
return FTBRanksAPI.getPermissionValue(player, perm).asBoolean().orElse(!adminCmd || player.hasPermissions(ConfigHandler.config.permissionLevel));
|
||||||
}
|
}
|
||||||
return !adminCmd || src.hasPermission(ConfigHandler.config.permissionLevel);
|
return !adminCmd || src.hasPermission(ConfigHandler.config.permissionLevel);
|
||||||
|
@ -5,13 +5,8 @@ import net.minecraft.resources.ResourceLocation;
|
|||||||
import net.minecraftforge.registries.IForgeRegistry;
|
import net.minecraftforge.registries.IForgeRegistry;
|
||||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||||
|
|
||||||
public class ForgeRegistryWrapper<T extends IForgeRegistryEntry<T>> implements SimpleRegistryWrapper<T> {
|
public record ForgeRegistryWrapper<T extends IForgeRegistryEntry<T>>(
|
||||||
|
IForgeRegistry<T> registry) implements SimpleRegistryWrapper<T> {
|
||||||
private final IForgeRegistry<T> registry;
|
|
||||||
|
|
||||||
public ForgeRegistryWrapper(IForgeRegistry<T> registry) {
|
|
||||||
this.registry = registry;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T getFromId(ResourceLocation id) {
|
public T getFromId(ResourceLocation id) {
|
||||||
|
@ -8,9 +8,8 @@ import net.minecraft.server.level.ServerPlayer;
|
|||||||
public class PermissionNodeHandlerImpl {
|
public class PermissionNodeHandlerImpl {
|
||||||
|
|
||||||
public static boolean perm(CommandSourceStack src, String perm, boolean adminCmd) {
|
public static boolean perm(CommandSourceStack src, String perm, boolean adminCmd) {
|
||||||
if (!Flan.ftbRanks || !(src.getEntity() instanceof ServerPlayer))
|
if (!Flan.ftbRanks || !(src.getEntity() instanceof ServerPlayer player))
|
||||||
return !adminCmd || src.hasPermission(ConfigHandler.config.permissionLevel);
|
return !adminCmd || src.hasPermission(ConfigHandler.config.permissionLevel);
|
||||||
ServerPlayer player = (ServerPlayer) src.getEntity();
|
|
||||||
return /*FTBRanksAPI.getPermissionValue(player, perm).asBoolean().orElse(!adminCmd || */player.hasPermissions(ConfigHandler.config.permissionLevel);
|
return /*FTBRanksAPI.getPermissionValue(player, perm).asBoolean().orElse(!adminCmd || */player.hasPermissions(ConfigHandler.config.permissionLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user