Additional logging, with new conf.json settings to enable/disable logging of specific events:

"logFactionCreate": true,  - log faction creation
"logFactionDisband": true,  - log factions being disbanded, by command or by circumstance
"logFactionJoin": true,  - log player joining a faction
"logFactionKick": true,  - log player being kicked from a faction
"logFactionLeave": true,  - log player leaving a faction
"logLandClaims": true,  - log land being claimed (including safe zone and war zone)
"logLandUnclaims": true,  - log land being unclaimed (including safe zone and war zone)
"logMoneyTransactions": true,  - log money being deposited, withdrawn, and otherwise transferred in relation to faction banks

Also a fix for a potential NPE from players logging out and Spout appearance handler referencing them afterwards
This commit is contained in:
Brettflan 2011-10-23 12:50:02 -05:00
parent 46cae5a664
commit f8f3704cd4
16 changed files with 105 additions and 11 deletions

View File

@ -69,6 +69,16 @@ public class Conf
public static boolean worldGuardChecking = false;
// server logging options
public static boolean logFactionCreate = true;
public static boolean logFactionDisband = true;
public static boolean logFactionJoin = true;
public static boolean logFactionKick = true;
public static boolean logFactionLeave = true;
public static boolean logLandClaims = true;
public static boolean logLandUnclaims = true;
public static boolean logMoneyTransactions = true;
public static boolean homesEnabled = true;
public static boolean homesMustBeInClaimedTerritory = true;
public static boolean homesTeleportToOnDeath = true;

View File

@ -611,6 +611,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
{
fplayer.msg("%s<i> left %s<i>.", this.describeTo(fplayer, true), myFaction.describeTo(fplayer));
}
if (Conf.logFactionLeave)
P.p.log(this.getName()+" left the faction: "+myFaction.getTag());
}
this.resetFactionData();
@ -624,6 +627,8 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
}
myFaction.detach();
if (Conf.logFactionDisband)
P.p.log("The faction "+myFaction.getTag()+" ("+myFaction.getId()+") was disbanded due to the last player ("+this.getName()+") leaving.");
}
}
@ -772,6 +777,10 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
Board.setFactionAt(forFaction, flocation);
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
if (Conf.logLandClaims)
P.p.log(this.getName()+" claimed land at ("+flocation.getCoordString()+") for the faction: "+forFaction.getTag());
return true;
}

View File

@ -7,6 +7,7 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
@ -76,6 +77,9 @@ public class CmdCreate extends FCommand
}
msg("<i>You should now: %s", p.cmdBase.cmdDescription.getUseageTemplate());
if (Conf.logFactionCreate)
P.p.log(fme.getName()+" created a new faction: "+tag);
}
}

View File

@ -1,5 +1,6 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
@ -69,6 +70,7 @@ public class CmdDisband extends FCommand
fplayer.msg("<h>%s<i> disbanded the faction %s.", who, faction.getTag(fplayer));
}
}
if (Conf.logFactionDisband)
P.p.log("The faction "+faction.getTag()+" ("+faction.getId()+") was disbanded by "+(senderIsConsole ? "console command" : fme.getName())+".");
if (Econ.shouldBeUsed())

View File

@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
public class CmdJoin extends FCommand
@ -69,5 +70,8 @@ public class CmdJoin extends FCommand
fme.resetFactionData();
fme.setFaction(faction);
faction.deinvite(fme);
if (Conf.logFactionJoin)
P.p.log(fme.getName()+" joined the faction: "+faction.getTag());
}
}

View File

@ -4,6 +4,7 @@ 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.Permission;
public class CmdKick extends FCommand
@ -77,6 +78,9 @@ public class CmdKick extends FCommand
yourFaction.deinvite(you);
you.resetFactionData();
if (Conf.logFactionKick)
P.p.log(fme.getName()+" kicked "+you.getName()+" from the faction: "+yourFaction.getTag());
if (yourFaction.getFPlayers().isEmpty() && !yourFaction.isPermanent())
{
// Remove this faction
@ -85,6 +89,9 @@ public class CmdKick extends FCommand
fplayer.msg("The faction %s<i> was disbanded.", yourFaction.getTag(fplayer));
}
yourFaction.detach();
if (Conf.logFactionDisband)
P.p.log("The faction "+yourFaction.getTag()+" ("+yourFaction.getId()+") was disbanded since the last player was kicked by "+(senderIsConsole ? "console command" : fme.getName())+".");
}
}

View File

@ -1,6 +1,8 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.struct.Permission;
@ -33,6 +35,9 @@ public class CmdMoneyDeposit extends FCommand
Faction faction = this.argAsFaction(1, myFaction);
if (faction == null) return;
Econ.transferMoney(fme, fme, faction, amount);
if (Conf.logMoneyTransactions)
P.p.log(fme.getName()+" deposited "+Econ.moneyString(amount)+" into the faction bank: "+faction.getTag());
}
}

View File

@ -1,6 +1,8 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.struct.Permission;
@ -30,11 +32,14 @@ public class CmdMoneyTransferFf extends FCommand
public void perform()
{
double amount = this.argAsDouble(0, 0d);
EconomyParticipator from = this.argAsFaction(1);
Faction from = this.argAsFaction(1);
if (from == null) return;
EconomyParticipator to = this.argAsFaction(2);
Faction to = this.argAsFaction(2);
if (to == null) return;
Econ.transferMoney(fme, from, to, amount);
if (Conf.logMoneyTransactions)
P.p.log(fme.getName()+" transferred "+Econ.moneyString(amount)+" from the faction \""+from.getTag()+"\" to the faction \""+to.getTag()+"\"");
}
}

View File

@ -1,6 +1,9 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.P;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.struct.Permission;
@ -30,11 +33,14 @@ public class CmdMoneyTransferFp extends FCommand
public void perform()
{
double amount = this.argAsDouble(0, 0d);
EconomyParticipator from = this.argAsFaction(1);
Faction from = this.argAsFaction(1);
if (from == null) return;
EconomyParticipator to = this.argAsBestFPlayerMatch(2);
FPlayer to = this.argAsBestFPlayerMatch(2);
if (to == null) return;
Econ.transferMoney(fme, from, to, amount);
if (Conf.logMoneyTransactions)
P.p.log(fme.getName()+" transferred "+Econ.moneyString(amount)+" from the faction \""+from.getTag()+"\" to the player \""+to.getName()+"\"");
}
}

View File

@ -1,6 +1,9 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.P;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.struct.Permission;
@ -30,11 +33,14 @@ public class CmdMoneyTransferPf extends FCommand
public void perform()
{
double amount = this.argAsDouble(0, 0d);
EconomyParticipator from = this.argAsBestFPlayerMatch(1);
FPlayer from = this.argAsBestFPlayerMatch(1);
if (from == null) return;
EconomyParticipator to = this.argAsFaction(2);
Faction to = this.argAsFaction(2);
if (to == null) return;
Econ.transferMoney(fme, from, to, amount);
if (Conf.logMoneyTransactions)
P.p.log(fme.getName()+" transferred "+Econ.moneyString(amount)+" from the player \""+from.getName()+"\" to the faction \""+to.getTag()+"\"");
}
}

View File

@ -1,6 +1,8 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.struct.Permission;
@ -30,5 +32,8 @@ public class CmdMoneyWithdraw extends FCommand
Faction faction = this.argAsFaction(1, myFaction);
if (faction == null) return;
Econ.transferMoney(fme, faction, fme, amount);
if (Conf.logMoneyTransactions)
P.p.log(fme.getName()+" withdrew "+Econ.moneyString(amount)+" from the faction bank: "+faction.getTag());
}
}

View File

@ -1,7 +1,9 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
public class CmdSafeunclaimall extends FCommand
@ -31,6 +33,9 @@ public class CmdSafeunclaimall extends FCommand
{
Board.unclaimAll(Factions.i.getSafeZone().getId());
msg("<i>You unclaimed ALL safe zone land.");
if (Conf.logLandUnclaims)
P.p.log(fme.getName()+" unclaimed all safe zones.");
}
}

View File

@ -6,6 +6,7 @@ import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
@ -41,6 +42,9 @@ public class CmdUnclaim extends FCommand
Board.removeAt(flocation);
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
msg("<i>Safe zone was unclaimed.");
if (Conf.logLandUnclaims)
P.p.log(fme.getName()+" unclaimed land at ("+flocation.getCoordString()+") from the faction: "+otherFaction.getTag());
}
else
{
@ -55,6 +59,9 @@ public class CmdUnclaim extends FCommand
Board.removeAt(flocation);
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
msg("<i>War zone was unclaimed.");
if (Conf.logLandUnclaims)
P.p.log(fme.getName()+" unclaimed land at ("+flocation.getCoordString()+") from the faction: "+otherFaction.getTag());
}
else
{
@ -70,6 +77,10 @@ public class CmdUnclaim extends FCommand
otherFaction.msg("%s<i> unclaimed some of your land.", fme.describeTo(otherFaction, true));
msg("<i>You unclaimed this land.");
if (Conf.logLandUnclaims)
P.p.log(fme.getName()+" unclaimed land at ("+flocation.getCoordString()+") from the faction: "+otherFaction.getTag());
return;
}
@ -154,6 +165,9 @@ public class CmdUnclaim extends FCommand
Board.removeAt(flocation);
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
if (Conf.logLandUnclaims)
P.p.log(fme.getName()+" unclaimed land at ("+flocation.getCoordString()+") from the faction: "+otherFaction.getTag());
}
}

View File

@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.P;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
@ -44,6 +45,9 @@ public class CmdUnclaimall extends FCommand
Board.unclaimAll(myFaction.getId());
myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.describeTo(myFaction, true));
SpoutFeatures.updateTerritoryDisplayLoc(null);
if (Conf.logLandUnclaims)
P.p.log(fme.getName()+" unclaimed everything for the faction: "+myFaction.getTag());
}
}

View File

@ -1,7 +1,9 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
public class CmdWarunclaimall extends FCommand
@ -31,6 +33,9 @@ public class CmdWarunclaimall extends FCommand
{
Board.unclaimAll(Factions.i.getWarZone().getId());
msg("<i>You unclaimed ALL war zone land.");
if (Conf.logLandUnclaims)
P.p.log(fme.getName()+" unclaimed all war zones.");
}
}

View File

@ -221,6 +221,9 @@ public class SpoutFeatures
SpoutPlayer sPlayer = SpoutManager.getPlayer(viewer.getPlayer());
Player pViewed = viewed.getPlayer();
if (pViewed == null || viewer.getPlayer() == null)
return;
String viewedTitle = viewed.getTitle();
Role viewedRole = viewed.getRole();