mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-28 21:56:33 +01:00
Fixes #668
This commit is contained in:
parent
316e55a724
commit
a73e44c88c
@ -22,28 +22,33 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAllowed(Player player, ClaimedResidence residence, MaskType type) {
|
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
|
@Override
|
||||||
public BukkitMask getMask(final FawePlayer<Player> fp, final MaskType type) {
|
public BukkitMask getMask(final FawePlayer<Player> fp, final MaskType type) {
|
||||||
final Player player = fp.parent;
|
final Player player = fp.parent;
|
||||||
final Location location = player.getLocation();
|
final Location location = player.getLocation();
|
||||||
final ClaimedResidence residence = Residence.getInstance().getResidenceManager().getByLoc(location);
|
ClaimedResidence residence = Residence.getInstance().getResidenceManager().getByLoc(location);
|
||||||
if (residence != null) {
|
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 CuboidArea area = residence.getAreaArray()[0];
|
||||||
final Location pos1 = area.getHighLoc();
|
final Location pos1 = area.getHighLoc();
|
||||||
final Location pos2 = area.getLowLoc();
|
final Location pos2 = area.getLowLoc();
|
||||||
|
final ClaimedResidence finalResidence = residence;
|
||||||
return new BukkitMask(pos1, pos2) {
|
return new BukkitMask(pos1, pos2) {
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "RESIDENCE: " + residence.getName();
|
return "RESIDENCE: " + finalResidence.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(FawePlayer player, MaskType type) {
|
public boolean isValid(FawePlayer player, MaskType type) {
|
||||||
return isAllowed((Player) player.parent, residence, type);
|
return isAllowed((Player) player.parent, finalResidence, type);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user