From f92d59e5c63ffe648b07d4f7ed1187c54136b62b Mon Sep 17 00:00:00 2001 From: drtshock Date: Tue, 27 Jan 2015 11:02:16 -0600 Subject: [PATCH] Add HCF raidable functionality. This will allow players to break blocks in factions that are raidable (power < claims) as well as open chests. It can also disable over claiming. --- .../listeners/FactionsBlockListener.java | 3 +++ .../listeners/FactionsPlayerListener.java | 13 ++++++++++--- .../factions/zcore/persist/MemoryFPlayer.java | 8 ++++---- src/main/resources/config.yml | 16 +++++++++++++++- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java index 9ddf6b22..29a31adc 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java @@ -213,6 +213,9 @@ public class FactionsBlockListener implements Listener { return false; } + if (P.p.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() >= otherFaction.getPowerRounded()) { + return true; + } Faction myFaction = me.getFaction(); Relation rel = myFaction.getRelationTo(otherFaction); diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index d5b0a130..5436c484 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -51,7 +51,7 @@ public class FactionsPlayerListener implements Listener { private void initPlayer(Player player) { // Make sure that all online players do have a fplayer. final FPlayer me = FPlayers.getInstance().getByPlayer(player); - ((MemoryFPlayer)me).setName(player.getName()); + ((MemoryFPlayer) me).setName(player.getName()); // Update the lastLoginTime for this fplayer me.setLastLoginTime(System.currentTimeMillis()); @@ -244,7 +244,6 @@ public class FactionsPlayerListener implements Listener { if (!playerCanUseItemHere(player, block.getLocation(), event.getMaterial(), false)) { event.setCancelled(true); - return; } } @@ -284,6 +283,10 @@ public class FactionsPlayerListener implements Listener { FLocation loc = new FLocation(location); Faction otherFaction = Board.getInstance().getFactionAt(loc); + if (P.p.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() >= otherFaction.getPowerRounded()) { + return true; + } + if (otherFaction.hasPlayersOnline()) { if (!Conf.territoryDenyUseageMaterials.contains(material)) { return true; // Item isn't one we're preventing for online factions. @@ -369,6 +372,10 @@ public class FactionsPlayerListener implements Listener { return true; } + if (P.p.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() >= otherFaction.getPowerRounded()) { + return true; + } + // Dupe fix. Faction myFaction = me.getFaction(); Relation rel = myFaction.getRelationTo(otherFaction); @@ -510,7 +517,7 @@ public class FactionsPlayerListener implements Listener { return true; } - if(Board.getInstance().getFactionAt(new FLocation(me)).isWarZone() && !Conf.warzoneDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.warzoneDenyCommands.iterator())) { + if (Board.getInstance().getFactionAt(new FLocation(me)).isWarZone() && !Conf.warzoneDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.warzoneDenyCommands.iterator())) { me.msg(TL.PLAYER_COMMAND_WARZONE, fullCmd); return true; } diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java index c9ae5acd..9a2910f1 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java @@ -623,7 +623,7 @@ public abstract class MemoryFPlayer implements FPlayer { } if (Conf.logFactionLeave) { - P.p.log(TL.LEAVE_LEFT.format(this.getName(),myFaction.getTag())); + P.p.log(TL.LEAVE_LEFT.format(this.getName(), myFaction.getTag())); } } @@ -638,7 +638,7 @@ public abstract class MemoryFPlayer implements FPlayer { Factions.getInstance().removeFaction(myFaction.getId()); if (Conf.logFactionDisband) { - P.p.log(TL.LEAVE_DISBANDEDLOG.format(myFaction.getTag(),myFaction.getId(),this.getName())); + P.p.log(TL.LEAVE_DISBANDEDLOG.format(myFaction.getTag(), myFaction.getId(), this.getName())); } } } @@ -677,7 +677,7 @@ public abstract class MemoryFPlayer implements FPlayer { error = P.p.txt.parse(TL.CLAIM_SAFEZONE.toString()); } else if (currentFaction.isWarZone()) { error = P.p.txt.parse(TL.CLAIM_WARZONE.toString()); - } else if (ownedLand >= forFaction.getPowerRounded()) { + } else if (P.p.getConfig().getBoolean("hcf.overclaim", true) && ownedLand >= forFaction.getPowerRounded()) { error = P.p.txt.parse(TL.CLAIM_POWER.toString()); } else if (Conf.claimedLandsMax != 0 && ownedLand >= Conf.claimedLandsMax && forFaction.isNormal()) { error = P.p.txt.parse(TL.CLAIM_LIMIT.toString()); @@ -766,7 +766,7 @@ public abstract class MemoryFPlayer implements FPlayer { Board.getInstance().setFactionAt(forFaction, flocation); if (Conf.logLandClaims) { - P.p.log(TL.CLAIM_CLAIMEDLOG.toString(),this.getName(),flocation.getCoordString(),forFaction.getTag()); + P.p.log(TL.CLAIM_CLAIMEDLOG.toString(), this.getName(), flocation.getCoordString(), forFaction.getTag()); } return true; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index adfb6bfe..47085f47 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -150,7 +150,9 @@ warmups: # Delay for /f warp f-warp: 0 -# HCF Features +###################################################### +#################### HCF Features #################### +###################################################### # These features were requested as part of Hardcore Factions or something. # All of them are disabled by default. @@ -166,3 +168,15 @@ max-relations: truce: 10 neutral: -1 enemy: 10 + +# Raids +# Allow a faction to be raided if they have more land than power. +# This will make claimed territory lose all protections +# allowing factions to open chests, break blocks, etc. if they +# have claimed chunks >= power. +hcf: + raidable: false + + # Should we allow Factions to over claim if they are raidable (above has no effect on this)? + # This has always been true, allowing factions to over claim others. + overclaim: true \ No newline at end of file