Skip to content

Commit

Permalink
Lands patch to use new function (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDiscordian authored Feb 11, 2024
1 parent d707950 commit fc7e5e0
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import me.angeschossen.lands.api.flags.enums.RoleFlagCategory;
import me.angeschossen.lands.api.flags.type.NaturalFlag;
import me.angeschossen.lands.api.flags.type.RoleFlag;
import me.angeschossen.lands.api.role.enums.RoleType;

import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
Expand Down Expand Up @@ -132,7 +134,6 @@ public void reload() {
return BlockProt.getInstance().getPlugin("Lands");
}

@SuppressWarnings("deprecation")
@Override
protected void filterFriendsInternal(@NotNull ArrayList<OfflinePlayer> friends, @NotNull Player player, @NotNull Block block) {
assert(this.integration != null);
Expand All @@ -146,7 +147,7 @@ protected void filterFriendsInternal(@NotNull ArrayList<OfflinePlayer> friends,

friends.removeIf(p -> {
var role = area.getRole(p.getUniqueId());
return role.isVisitorRole() || (area.hasNaturalFlag(requireProtectForFriendFlag) && role.hasFlag(protectContainersFlag));
return role.getType() == RoleType.VISITOR || (area.hasNaturalFlag(requireProtectForFriendFlag) && role.hasFlag(protectContainersFlag));
});
}

Expand All @@ -163,7 +164,7 @@ protected boolean filterFriendByUuid(@NotNull UUID friend, @NotNull Player playe

// TODO: This if-else abomination needs to be simplified
var role = area.getRole(player.getUniqueId());
if (role.isVisitorRole())
if (role.getType() == RoleType.VISITOR)
return false;
else if (area.hasNaturalFlag(requireProtectForFriendFlag))
return role.hasFlag(protectContainersFlag);
Expand All @@ -190,7 +191,7 @@ public void onAccessEditMenu(@NotNull final BlockAccessMenuEvent event) {
}

var role = area.getRole(event.getPlayer().getUniqueId());
if (!role.hasFlag(this.protectContainersFlag) || role.isVisitorRole()) {
if (!role.hasFlag(this.protectContainersFlag) || role.getType() == RoleType.VISITOR) {
event.removePermission(BlockAccessMenuEvent.MenuPermission.LOCK);
event.removePermission(BlockAccessMenuEvent.MenuPermission.MANAGER);
}
Expand All @@ -209,7 +210,7 @@ public void onLockOnPlace(@NotNull final BlockLockOnPlaceEvent event) {
}

var role = area.getRole(event.getPlayer().getUniqueId());
if (!role.hasFlag(this.protectContainersFlag) || role.isVisitorRole()) {
if (!role.hasFlag(this.protectContainersFlag) || role.getType() == RoleType.VISITOR) {
event.setCancelled(true);
}
}
Expand Down

0 comments on commit fc7e5e0

Please sign in to comment.