This commit is contained in:
Jesse Boyd 2017-08-21 23:39:20 +10:00
parent 316e55a724
commit a73e44c88c
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F

View File

@ -22,28 +22,33 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener {
}
public boolean isAllowed(Player player, ClaimedResidence residence, MaskType type) {
return residence != null && (residence.getOwner().equals(player.getName()) || residence.getOwner().equals(player.getUniqueId().toString()) || type == MaskType.MEMBER && residence.getPlayersInResidence().contains(player));
return residence != null && (residence.getOwner().equals(player.getName()) || residence.getOwner().equals(player.getUniqueId().toString()) || type == MaskType.MEMBER && residence.getPermissions().playerHas(player, "build", false));
}
@Override
public BukkitMask getMask(final FawePlayer<Player> fp, final MaskType type) {
final Player player = fp.parent;
final Location location = player.getLocation();
final ClaimedResidence residence = Residence.getInstance().getResidenceManager().getByLoc(location);
ClaimedResidence residence = Residence.getInstance().getResidenceManager().getByLoc(location);
if (residence != null) {
if (isAllowed(player, residence, type)) {
boolean isAllowed;
while (!(isAllowed = isAllowed(player, residence, type)) && residence != null) {
residence = residence.getSubzoneByLoc(location);
}
if (isAllowed) {
final CuboidArea area = residence.getAreaArray()[0];
final Location pos1 = area.getHighLoc();
final Location pos2 = area.getLowLoc();
final ClaimedResidence finalResidence = residence;
return new BukkitMask(pos1, pos2) {
@Override
public String getName() {
return "RESIDENCE: " + residence.getName();
return "RESIDENCE: " + finalResidence.getName();
}
@Override
public boolean isValid(FawePlayer player, MaskType type) {
return isAllowed((Player) player.parent, residence, type);
return isAllowed((Player) player.parent, finalResidence, type);
}
};
}