From 3dc70e82d950772db6bc0fb275034aa0603c653d Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Sun, 18 Dec 2011 22:47:48 +0100 Subject: [PATCH 1/3] Unused imports cause warings in eclipse. --- src/com/massivecraft/factions/cmd/CmdKick.java | 2 -- .../massivecraft/factions/listeners/FactionsPlayerListener.java | 1 - 2 files changed, 3 deletions(-) diff --git a/src/com/massivecraft/factions/cmd/CmdKick.java b/src/com/massivecraft/factions/cmd/CmdKick.java index 544bdaf7..faead566 100644 --- a/src/com/massivecraft/factions/cmd/CmdKick.java +++ b/src/com/massivecraft/factions/cmd/CmdKick.java @@ -2,10 +2,8 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; -import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; import com.massivecraft.factions.P; -import com.massivecraft.factions.struct.FFlag; import com.massivecraft.factions.struct.FPerm; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Rel; diff --git a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java index bd4d33bb..ebd1dcc1 100644 --- a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -27,7 +27,6 @@ import com.massivecraft.factions.Conf; import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayers; -import com.massivecraft.factions.Faction; import com.massivecraft.factions.P; import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.struct.FPerm; From 81d24ecbc48bd0a5ebbd60c25a6fbea3224a259d Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Fri, 23 Dec 2011 01:13:55 +0100 Subject: [PATCH 2/3] Leaders can now not be kicked by their officers. Improved leader command. --- plugin.yml | 2 +- .../massivecraft/factions/cmd/CmdKick.java | 6 ++ .../massivecraft/factions/cmd/CmdLeader.java | 58 ++++++++++++++----- 3 files changed, 49 insertions(+), 17 deletions(-) diff --git a/plugin.yml b/plugin.yml index 20a84d8a..8cf5ea90 100644 --- a/plugin.yml +++ b/plugin.yml @@ -102,7 +102,7 @@ permissions: factions.kick: description: kick a player from the faction factions.leader: - description: hand over your leader rights + description: hand over leader rights factions.leave: description: leave your faction factions.list: diff --git a/src/com/massivecraft/factions/cmd/CmdKick.java b/src/com/massivecraft/factions/cmd/CmdKick.java index faead566..094b9d66 100644 --- a/src/com/massivecraft/factions/cmd/CmdKick.java +++ b/src/com/massivecraft/factions/cmd/CmdKick.java @@ -40,6 +40,12 @@ public class CmdKick extends FCommand msg("You might want to: %s", p.cmdBase.cmdLeave.getUseageTemplate(false)); return; } + + if (you.getRole() == Rel.LEADER && !(this.senderIsConsole || fme.hasAdminMode())) + { + msg("The leader can not be kicked."); + return; + } if ( ! Conf.canLeaveWithNegativePower && you.getPower() < 0) { diff --git a/src/com/massivecraft/factions/cmd/CmdLeader.java b/src/com/massivecraft/factions/cmd/CmdLeader.java index 26efc465..7a801bef 100644 --- a/src/com/massivecraft/factions/cmd/CmdLeader.java +++ b/src/com/massivecraft/factions/cmd/CmdLeader.java @@ -2,8 +2,10 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayers; +import com.massivecraft.factions.Faction; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Rel; +import com.massivecraft.factions.util.RelationUtil; public class CmdLeader extends FCommand { @@ -13,43 +15,67 @@ public class CmdLeader extends FCommand this.aliases.add("leader"); this.requiredArgs.add("player"); - //this.optionalArgs.put("", ""); + this.optionalArgs.put("faction", "your"); this.permission = Permission.LEADER.node; this.disableOnLock = true; - senderMustBePlayer = true; + senderMustBePlayer = false; senderMustBeMember = false; senderMustBeOfficer = false; - senderMustBeLeader = true; + senderMustBeLeader = false; } @Override public void perform() { - FPlayer fyou = this.argAsBestFPlayerMatch(0); - if (fyou == null) return; + FPlayer newLeader = this.argAsBestFPlayerMatch(0); + if (newLeader == null) return; - if (fyou.getFaction() != myFaction) + Faction targetFaction = this.argAsFaction(1, myFaction); + if (targetFaction == null) return; + + FPlayer targetFactionCurrentLeader = targetFaction.getFPlayerLeader(); + + // We now have fplayer and the target faction + if (this.senderIsConsole || fme.hasAdminMode()) { - msg("%s is not a member in your faction.", fyou.describeTo(fme, true)); - return; + // Do whatever you wish + } + else + { + // Follow the standard rules + if (fme.getRole() != Rel.LEADER) + { + sender.sendMessage(p.txt.parse("Only faction admins can %s.", this.getHelpShort())); + return; + } + + if (newLeader.getFaction() != myFaction) + { + msg("%s is not a member in your faction.", newLeader.describeTo(fme, true)); + return; + } + + if (newLeader == fme) + { + msg("The target player musn't be yourself."); + return; + } } - if (fyou == fme) + // Perform the switching + if (targetFactionCurrentLeader != null) { - msg("The target player musn't be yourself."); - return; + targetFactionCurrentLeader.setRole(Rel.OFFICER); } - - fme.setRole(Rel.OFFICER); - fyou.setRole(Rel.LEADER); + newLeader.setFaction(targetFaction); + newLeader.setRole(Rel.LEADER); // Inform all players for (FPlayer fplayer : FPlayers.i.getOnline()) { - fplayer.msg("%s gave %s the leadership of %s", fme.describeTo(fplayer, true), fyou.describeTo(fplayer), myFaction.describeTo(fplayer)); + fplayer.msg("%s gave %s the leadership of %s", RelationUtil.describeThatToMe(fme, fplayer, true), newLeader.describeTo(fplayer), targetFaction.describeTo(fplayer)); } } - } From f0627017b5a8d3fc973af404d5ddea89348bc9ea Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 4 Jan 2012 00:30:07 +0100 Subject: [PATCH 3/3] Found a bug I did NOT FIX. --- src/com/massivecraft/factions/Conf.java | 2 +- src/com/massivecraft/factions/FPlayers.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/com/massivecraft/factions/Conf.java b/src/com/massivecraft/factions/Conf.java index c88db147..e3e73903 100644 --- a/src/com/massivecraft/factions/Conf.java +++ b/src/com/massivecraft/factions/Conf.java @@ -32,7 +32,7 @@ public class Conf // Power public static double powerPlayerMax = 10.0; public static double powerPlayerMin = -10.0; - public static double powerPlayerStarting = 0.0; // New players start out with this power level + public static double powerPlayerStarting = 10.0; // New players start out with this power level public static double powerPerMinute = 0.2; // Default health rate... it takes 5 min to heal one power public static double powerPerDeath = 4.0; // A death makes you lose 4 power public static boolean scaleNegativePower = false; // Power regeneration rate increase as power decreases diff --git a/src/com/massivecraft/factions/FPlayers.java b/src/com/massivecraft/factions/FPlayers.java index d2148861..af240f83 100644 --- a/src/com/massivecraft/factions/FPlayers.java +++ b/src/com/massivecraft/factions/FPlayers.java @@ -62,8 +62,10 @@ public class FPlayers extends PlayerEntityCollection { if (now - fplayer.getLastLoginTime() > toleranceMillis) { - if (Conf.logFactionLeave || Conf.logFactionKick) - P.p.log("Player "+fplayer.getName()+" was auto-removed due to inactivity."); + // TODO: This stops the memory leak crashes but does not solve the issue: MEMBERS ARE NOT KICKED!!! + // TODO: DO SOMETHING ABOUT THIS + /*if (Conf.logFactionLeave || Conf.logFactionKick) + P.p.log("Player "+fplayer.getName()+" was auto-removed due to inactivity.");*/ // if player is faction leader, sort out the faction since he's going away if (fplayer.getRole() == Rel.LEADER)