public boolean playerCanUseItemHere(Player player, Block block, Material material) { if (Conf.adminBypassPlayers.contains(player.getName())) { return true; } FLocation loc = new FLocation(block); Faction otherFaction = Board.getFactionAt(loc); if (otherFaction.hasPlayersOnline()) { if (!Conf.territoryDenyUseageMaterials.contains(material)) { return true; // Item isn't one we're preventing for online factions. } } else { if (!Conf.territoryDenyUseageMaterialsWhenOffline.contains(material)) { return true; // Item isn't one we're preventing for offline factions. } } FPlayer me = FPlayer.get(player); if (otherFaction.isNone()) { if (!Conf.wildernessDenyUseage || Factions.hasPermAdminBypass(player) || Conf.worldsNoWildernessProtection.contains(block.getWorld().getName())) { return true; // This is not faction territory. Use whatever you like here. } me.sendMessage("You can't use " + TextUtil.getMaterialName(material) + " in the wilderness."); return false; } else if (otherFaction.isSafeZone()) { if (!Conf.safeZoneDenyUseage || Factions.hasPermManageSafeZone(player)) { return true; } me.sendMessage("You can't use " + TextUtil.getMaterialName(material) + " in a safe zone."); return false; } else if (otherFaction.isWarZone()) { if (!Conf.warZoneDenyUseage || Factions.hasPermManageWarZone(player)) { return true; } me.sendMessage("You can't use " + TextUtil.getMaterialName(material) + " in a war zone."); return false; } Faction myFaction = me.getFaction(); Relation rel = myFaction.getRelation(otherFaction); boolean ownershipFail = Conf.ownedAreasEnabled && Conf.ownedAreaDenyUseage && !otherFaction.playerHasOwnershipRights(me, loc); // Cancel if we are not in our own territory if (!rel.isMember() && rel.confDenyUseage()) { me.sendMessage( "You can't use " + TextUtil.getMaterialName(material) + " in the territory of " + otherFaction.getTag(myFaction)); return false; } // Also cancel if player doesn't have ownership rights for this claim else if (rel.isMember() && ownershipFail && !Factions.hasPermOwnershipBypass(player)) { me.sendMessage( "You can't use " + TextUtil.getMaterialName(material) + " in this territory, it is owned by: " + myFaction.getOwnerListString(loc)); return false; } return true; }
@Override public void onPlayerMove(PlayerMoveEvent event) { Player player = event.getPlayer(); FPlayer me = FPlayer.get(player); // Did we change coord? FLocation from = me.getLastStoodAt(); FLocation to = new FLocation(player.getLocation()); if (from.equals(to)) { return; } // Yes we did change coord (: me.setLastStoodAt(to); if (me.isMapAutoUpdating()) { me.sendMessage(Board.getMap(me.getFaction(), to, player.getLocation().getYaw())); } else { // Did we change "host"(faction)? Faction factionFrom = Board.getFactionAt(from); Faction factionTo = Board.getFactionAt(to); Faction myFaction = me.getFaction(); String ownersTo = myFaction.getOwnerListString(to); if (factionFrom != factionTo) { me.sendFactionHereMessage(); if (Conf.ownedAreasEnabled && Conf.ownedMessageOnBorder && myFaction == factionTo && !ownersTo.isEmpty()) { me.sendMessage(Conf.ownedLandMessage + ownersTo); } } else if (Conf.ownedAreasEnabled && Conf.ownedMessageInsideTerritory && factionFrom == factionTo && myFaction == factionTo) { String ownersFrom = myFaction.getOwnerListString(from); if (Conf.ownedMessageByChunk || !ownersFrom.equals(ownersTo)) { if (!ownersTo.isEmpty()) { me.sendMessage(Conf.ownedLandMessage + ownersTo); } else if (!Conf.publicLandMessage.isEmpty()) { me.sendMessage(Conf.publicLandMessage); } } } } if (me.autoClaimEnabled()) { Faction myFaction = me.getFaction(); Faction otherFaction = Board.getFactionAt(to); double cost = Econ.calculateClaimCost(myFaction.getLandRounded(), otherFaction.isNormal()); if (me.getRole().value < Role.MODERATOR.value) { me.sendMessage("You must be " + Role.MODERATOR + " to claim land."); me.enableAutoClaim(false); } else if (Conf.worldsNoClaiming.contains(to.getWorldName())) { me.sendMessage("Sorry, this world has land claiming disabled."); me.enableAutoClaim(false); } else if (myFaction.getLandRounded() >= myFaction.getPowerRounded()) { me.sendMessage("You can't claim more land! You need more power!"); me.enableAutoClaim(false); } else if (!Econ.canAfford(player.getName(), cost)) { String costString = Econ.moneyString(cost); me.sendMessage( "Claiming this land will cost " + costString + ", which you can't currently afford."); me.enableAutoClaim(false); } else me.attemptClaim(false); } else if (me.autoSafeZoneEnabled()) { if (!Factions.hasPermManageSafeZone((CommandSender) player)) { me.enableAutoSafeZone(false); } else { FLocation playerFlocation = new FLocation(me); if (!Board.getFactionAt(playerFlocation).isSafeZone()) { Board.setFactionAt(Faction.getSafeZone(), playerFlocation); me.sendMessage("This land is now a safe zone."); } } } else if (me.autoWarZoneEnabled()) { if (!Factions.hasPermManageWarZone((CommandSender) player)) { me.enableAutoWarZone(false); } else { FLocation playerFlocation = new FLocation(me); if (!Board.getFactionAt(playerFlocation).isWarZone()) { Board.setFactionAt(Faction.getWarZone(), playerFlocation); me.sendMessage("This land is now a war zone."); } } } }