add CLAIMMESSAGE permission for enter/leave messages

This commit is contained in:
Flemmli97 2022-03-17 15:32:23 +01:00
parent 439a492a86
commit 761e54be1b
6 changed files with 19 additions and 3 deletions

View File

@ -1,3 +1,9 @@
Flan 1.7.5
================
- Fix a type in the default lang file
- Add CLAIMMESSAGE permission for specifically editing the
enter/leave message of a claim
Flan 1.7.4
================
- 1.18.2

View File

@ -3,9 +3,11 @@ package io.github.flemmli97.flan.api;
import io.github.flemmli97.flan.api.data.IPermissionContainer;
import io.github.flemmli97.flan.api.data.IPermissionStorage;
import io.github.flemmli97.flan.api.data.IPlayerData;
import io.github.flemmli97.flan.api.permission.ClaimPermission;
import io.github.flemmli97.flan.claim.ClaimStorage;
import io.github.flemmli97.flan.player.OfflinePlayerData;
import io.github.flemmli97.flan.player.PlayerClaimData;
import net.minecraft.core.BlockPos;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
@ -14,6 +16,13 @@ import java.util.UUID;
public class ClaimHandler {
/**
* Check if a player do an interaction at the given position
*/
public static boolean canInteract(ServerPlayer player, BlockPos pos, ClaimPermission permission) {
return ClaimStorage.get(player.getLevel()).getClaimAt(pos).canInteract(player, permission, pos);
}
/**
* Get the permission storage for the world to check for permissions.
* You can then use IPermissionContainer#getForPermissionCheck

View File

@ -73,6 +73,7 @@ public class PermissionRegistry {
public static ClaimPermission CANSTAY = register(new ClaimPermission("CANSTAY", () -> new ItemStack(Items.PAPER), true, "Allow players to enter your claim"));
public static ClaimPermission TELEPORT = register(new ClaimPermission("TELEPORT", () -> new ItemStack(Items.END_PORTAL_FRAME), false, "Allow player to teleport to your claim home position"));
public static ClaimPermission NOHUNGER = register(new ClaimPermission("NOHUNGER", () -> new ItemStack(Items.COOKED_BEEF), false, "Disable hunger"));
public static ClaimPermission CLAIMMESSAGE = register(new ClaimPermission("CLAIMMESSAGE", () -> new ItemStack(Items.OAK_SIGN), false, "Permission to edit the enter/leave message"));
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"));

View File

@ -770,7 +770,7 @@ public class CommandClaim {
((MutableComponent) text).setStyle(style);
}
ServerPlayer player = context.getSource().getPlayerOrException();
Claim claim = PermHelper.checkReturn(player, PermissionRegistry.EDITPERMS, PermHelper.genericNoPermMessage(player));
Claim claim = PermHelper.checkReturn(player, PermissionRegistry.CLAIMMESSAGE, PermHelper.genericNoPermMessage(player));
if (claim == null)
return 0;
boolean sub = StringArgumentType.getString(context, "title").equals("subtitle");

View File

@ -130,7 +130,7 @@ public class ClaimMenuScreenHandler extends ServerOnlyScreenHandler<Claim> {
ServerScreenHelper.playSongToPlayer(player, SoundEvents.VILLAGER_NO, 1, 1f);
break;
case 5:
if (this.hasPerm(this.claim, player, PermissionRegistry.EDITCLAIM)) {
if (this.hasPerm(this.claim, player, PermissionRegistry.CLAIMMESSAGE)) {
player.closeContainer();
player.getServer().execute(() -> ClaimTextHandler.openClaimMenu(player, this.claim));
ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f);

View File

@ -11,7 +11,7 @@ forge_version=1.18.2-40.0.3
loader_version=0.13.2
# Mod Properties
mod_version=1.7.4
mod_version=1.7.5
maven_group=io.github.flemmli97
archives_base_name=flan