Merge branch 'master' of github.com:MassiveCraft/Factions

This commit is contained in:
Brettflan 2012-01-07 15:57:01 -06:00
commit 1c918ad52e
6 changed files with 54 additions and 23 deletions

View File

@ -102,7 +102,7 @@ permissions:
factions.kick: factions.kick:
description: kick a player from the faction description: kick a player from the faction
factions.leader: factions.leader:
description: hand over your leader rights description: hand over leader rights
factions.leave: factions.leave:
description: leave your faction description: leave your faction
factions.list: factions.list:

View File

@ -32,7 +32,7 @@ public class Conf
// Power // Power
public static double powerPlayerMax = 10.0; public static double powerPlayerMax = 10.0;
public static double powerPlayerMin = -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 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 double powerPerDeath = 4.0; // A death makes you lose 4 power
public static boolean scaleNegativePower = false; // Power regeneration rate increase as power decreases public static boolean scaleNegativePower = false; // Power regeneration rate increase as power decreases

View File

@ -62,8 +62,10 @@ public class FPlayers extends PlayerEntityCollection<FPlayer>
{ {
if (now - fplayer.getLastLoginTime() > toleranceMillis) if (now - fplayer.getLastLoginTime() > toleranceMillis)
{ {
if (Conf.logFactionLeave || Conf.logFactionKick) // TODO: This stops the memory leak crashes but does not solve the issue: MEMBERS ARE NOT KICKED!!!
P.p.log("Player "+fplayer.getName()+" was auto-removed due to inactivity."); // 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 player is faction leader, sort out the faction since he's going away
if (fplayer.getRole() == Rel.LEADER) if (fplayer.getRole() == Rel.LEADER)

View File

@ -2,10 +2,8 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P; import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.FFlag;
import com.massivecraft.factions.struct.FPerm; import com.massivecraft.factions.struct.FPerm;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.struct.Rel;
@ -42,6 +40,12 @@ public class CmdKick extends FCommand
msg("<i>You might want to: %s", p.cmdBase.cmdLeave.getUseageTemplate(false)); msg("<i>You might want to: %s", p.cmdBase.cmdLeave.getUseageTemplate(false));
return; return;
} }
if (you.getRole() == Rel.LEADER && !(this.senderIsConsole || fme.hasAdminMode()))
{
msg("<b>The leader can not be kicked.");
return;
}
if ( ! Conf.canLeaveWithNegativePower && you.getPower() < 0) if ( ! Conf.canLeaveWithNegativePower && you.getPower() < 0)
{ {

View File

@ -2,8 +2,10 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.struct.Rel;
import com.massivecraft.factions.util.RelationUtil;
public class CmdLeader extends FCommand public class CmdLeader extends FCommand
{ {
@ -13,43 +15,67 @@ public class CmdLeader extends FCommand
this.aliases.add("leader"); this.aliases.add("leader");
this.requiredArgs.add("player"); this.requiredArgs.add("player");
//this.optionalArgs.put("", ""); this.optionalArgs.put("faction", "your");
this.permission = Permission.LEADER.node; this.permission = Permission.LEADER.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeOfficer = false; senderMustBeOfficer = false;
senderMustBeLeader = true; senderMustBeLeader = false;
} }
@Override @Override
public void perform() public void perform()
{ {
FPlayer fyou = this.argAsBestFPlayerMatch(0); FPlayer newLeader = this.argAsBestFPlayerMatch(0);
if (fyou == null) return; 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<i> is not a member in your faction.", fyou.describeTo(fme, true)); // Do whatever you wish
return; }
else
{
// Follow the standard rules
if (fme.getRole() != Rel.LEADER)
{
sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort()));
return;
}
if (newLeader.getFaction() != myFaction)
{
msg("%s<i> is not a member in your faction.", newLeader.describeTo(fme, true));
return;
}
if (newLeader == fme)
{
msg("<b>The target player musn't be yourself.");
return;
}
} }
if (fyou == fme) // Perform the switching
if (targetFactionCurrentLeader != null)
{ {
msg("<b>The target player musn't be yourself."); targetFactionCurrentLeader.setRole(Rel.OFFICER);
return;
} }
newLeader.setFaction(targetFaction);
fme.setRole(Rel.OFFICER); newLeader.setRole(Rel.LEADER);
fyou.setRole(Rel.LEADER);
// Inform all players // Inform all players
for (FPlayer fplayer : FPlayers.i.getOnline()) for (FPlayer fplayer : FPlayers.i.getOnline())
{ {
fplayer.msg("%s<i> gave %s<i> the leadership of %s", fme.describeTo(fplayer, true), fyou.describeTo(fplayer), myFaction.describeTo(fplayer)); fplayer.msg("%s<i> gave %s<i> the leadership of %s", RelationUtil.describeThatToMe(fme, fplayer, true), newLeader.describeTo(fplayer), targetFaction.describeTo(fplayer));
} }
} }
} }

View File

@ -27,7 +27,6 @@ import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P; import com.massivecraft.factions.P;
import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.FPerm; import com.massivecraft.factions.struct.FPerm;