Factions Player Listener (Access Item Def)
This commit is contained in:
parent
e5a9b82bdf
commit
2586908ce3
@ -101,6 +101,8 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(me.getFaction() == otherFaction) return true;
|
||||||
|
|
||||||
if (P.p.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() > otherFaction.getPowerRounded()) {
|
if (P.p.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() > otherFaction.getPowerRounded()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -156,7 +158,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Access access = otherFaction.getAccess(me, PermissableAction.ITEM);
|
Access access = otherFaction.getAccess(me, PermissableAction.ITEM);
|
||||||
return CheckPlayerAccess(player, me, loc, myFaction, access, PermissableAction.ITEM, false);
|
return CheckPlayerAccess(player, me, loc, otherFaction, access, PermissableAction.ITEM, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@ -304,23 +306,26 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
if (access != null && access != Access.UNDEFINED) {
|
if (access != null && access != Access.UNDEFINED) {
|
||||||
// TODO: Update this once new access values are added other than just allow / deny.
|
// TODO: Update this once new access values are added other than just allow / deny.
|
||||||
boolean landOwned = (factionToCheck.doesLocationHaveOwnersSet(loc) && !factionToCheck.getOwnerList(loc).isEmpty());
|
boolean landOwned = (factionToCheck.doesLocationHaveOwnersSet(loc) && !factionToCheck.getOwnerList(loc).isEmpty());
|
||||||
if ((landOwned && factionToCheck.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(factionToCheck.getId())))
|
if ((landOwned && factionToCheck.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(factionToCheck.getId()))) {
|
||||||
return true;
|
return true;
|
||||||
else if (landOwned && !factionToCheck.getOwnerListString(loc).contains(player.getName())) {
|
} else if (landOwned && !factionToCheck.getOwnerListString(loc).contains(player.getName())) {
|
||||||
me.msg("<b>You can't do that in this territory, it is owned by: " + factionToCheck.getOwnerListString(loc));
|
me.msg("<b>You can't do that in this territory, it is owned by: " + factionToCheck.getOwnerListString(loc));
|
||||||
if (doPain) {
|
if (doPain) {
|
||||||
player.damage(Conf.actionDeniedPainAmount);
|
player.damage(Conf.actionDeniedPainAmount);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else if (!landOwned && access == Access.ALLOW) return true;
|
} else if (!landOwned && access == Access.ALLOW) {
|
||||||
else {
|
return true;
|
||||||
|
} else {
|
||||||
me.msg("You cannot " + action + " in the territory of " + factionToCheck.getTag(me.getFaction()));
|
me.msg("You cannot " + action + " in the territory of " + factionToCheck.getTag(me.getFaction()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Approves any permission check if the player in question is a leader AND owns the faction.
|
// Approves any permission check if the player in question is a leader AND owns the faction.
|
||||||
if (me.getRole().equals(Role.LEADER) && me.getFaction().equals(factionToCheck)) return true;
|
if (me.getRole().equals(Role.LEADER) && me.getFaction().equals(factionToCheck)) return true;
|
||||||
me.msg("You cannot " + action + " in the territory of " + factionToCheck.getTag(me.getFaction()));
|
if (factionToCheck != null) {
|
||||||
|
me.msg(TL.PLAYER_USE_TERRITORY, action, factionToCheck.getTag(me.getFaction()));
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -800,7 +805,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
// Check if the material is bypassing protection
|
// Check if the material is bypassing protection
|
||||||
if (block == null) return; // clicked in air, apparently
|
if (block == null) return; // clicked in air, apparently
|
||||||
if (Conf.territoryBypassProtectedMaterials.contains(block.getType())) return;
|
if (Conf.territoryBypassProtectedMaterials.contains(event.getItem().getType())) return;
|
||||||
if (GetPermissionFromUsableBlock(event.getClickedBlock().getType()) != null) {
|
if (GetPermissionFromUsableBlock(event.getClickedBlock().getType()) != null) {
|
||||||
if (!canPlayerUseBlock(player, block, false)) {
|
if (!canPlayerUseBlock(player, block, false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -817,8 +822,8 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event.getMaterial().isSolid()) return;
|
if (event.getItem() == null) return;
|
||||||
if (!playerCanUseItemHere(player, block.getLocation(), event.getMaterial(), false)) {
|
if (!playerCanUseItemHere(player, block.getLocation(), event.getItem().getType(), false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.setUseInteractedBlock(Event.Result.DENY);
|
event.setUseInteractedBlock(Event.Result.DENY);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user