Fix some more small bugs

This commit is contained in:
Olof Larsson 2013-04-25 16:02:37 +02:00
parent c6757fae60
commit ea06c468fc
7 changed files with 43 additions and 24 deletions

View File

@ -48,7 +48,7 @@ public class CmdFactionsJoin extends FCommand
if (faction == uplayerFaction)
{
msg("<b>%s %s already a member of %s", uplayer.describeTo(usender, true), (samePlayer ? "are" : "is"), faction.getName(usender));
msg("<i>%s <i>%s already a member of %s<i>.", uplayer.describeTo(usender, true), (samePlayer ? "are" : "is"), faction.getName(usender));
return;
}
@ -88,10 +88,10 @@ public class CmdFactionsJoin extends FCommand
// Inform
if (!samePlayer)
{
uplayer.msg("<i>%s moved you into the faction %s.", usender.describeTo(uplayer, true), faction.getName(uplayer));
uplayer.msg("<i>%s <i>moved you into the faction %s<i>.", usender.describeTo(uplayer, true), faction.getName(uplayer));
}
faction.msg("<i>%s joined your faction.", uplayer.describeTo(faction, true));
usender.msg("<i>%s successfully joined %s.", uplayer.describeTo(usender, true), faction.getName(usender));
faction.msg("<i>%s <i>joined <lime>your faction<i>.", uplayer.describeTo(faction, true));
usender.msg("<i>%s <i>successfully joined %s<i>.", uplayer.describeTo(usender, true), faction.getName(usender));
// Apply
uplayer.resetFactionData();

View File

@ -17,7 +17,7 @@ public class CmdFactionsList extends FCommand
{
public CmdFactionsList()
{
this.addAliases("ls", "list");
this.addAliases("l", "list");
this.addOptionalArg("page", "1");

View File

@ -27,7 +27,7 @@ public class CmdFactionsShow extends FCommand
{
public CmdFactionsShow()
{
this.addAliases("show", "who");
this.addAliases("s", "show", "who");
this.addOptionalArg("faction", "you");
@ -42,15 +42,12 @@ public class CmdFactionsShow extends FCommand
if (faction == null) return;
UConf uconf = UConf.get(faction);
Collection<UPlayer> leaders = faction.getUPlayersWhereRole(Rel.LEADER);
Collection<UPlayer> officers = faction.getUPlayersWhereRole(Rel.OFFICER);
Collection<UPlayer> normals = faction.getUPlayersWhereRole(Rel.MEMBER);
Collection<UPlayer> recruits = faction.getUPlayersWhereRole(Rel.RECRUIT);
// INFO: Description
msg(Txt.titleize(faction.getName(usender)));
msg("<a>Description: <i>%s", faction.getDescription());
// INFO: Age
long ageMillis = faction.getCreatedAtMillis() - System.currentTimeMillis();
LinkedHashMap<TimeUnit, Long> ageUnitcounts = TimeDiffUtil.limit(TimeDiffUtil.unitcounts(ageMillis, TimeUnit.getAllButMillis()), 3);
String ageString = TimeDiffUtil.formatedVerboose(ageUnitcounts, "<i>");
@ -68,8 +65,10 @@ public class CmdFactionsShow extends FCommand
msg("<a>This faction is peaceful - in truce with everyone.");
}
msg("<a>Joining: <i>"+(faction.isOpen() ? "no invitation is needed" : "invitation is required"));
// INFO: Open
msg("<a>Open: <i>"+(faction.isOpen() ? "<lime>Yes <i>- anyone can join" : "<rose>No <i>- only invited people can join"));
// INFO: Power
double powerBoost = faction.getPowerBoost();
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? " (bonus: " : " (penalty: ") + powerBoost + ")";
msg("<a>Land / Power / Maxpower: <i> %d/%d/%d %s", faction.getLandCount(), faction.getPowerRounded(), faction.getPowerMaxRounded(), boost);
@ -124,6 +123,12 @@ public class CmdFactionsShow extends FCommand
sendMessage(Txt.parse("<a>Enemies: ") + Txt.implode(relationNames.get(Rel.ENEMY), sepparator));
// List the members...
Collection<UPlayer> leaders = faction.getUPlayersWhereRole(Rel.LEADER);
Collection<UPlayer> officers = faction.getUPlayersWhereRole(Rel.OFFICER);
Collection<UPlayer> normals = faction.getUPlayersWhereRole(Rel.MEMBER);
Collection<UPlayer> recruits = faction.getUPlayersWhereRole(Rel.RECRUIT);
List<String> memberOnlineNames = new ArrayList<String>();
List<String> memberOfflineNames = new ArrayList<String>();

View File

@ -423,8 +423,8 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
public String getNameAndSomething(String something)
{
String ret = this.role.getPrefix();
if (something.length() > 0)
String ret = this.getRole().getPrefix();
if (something != null && something.length() > 0)
{
ret += something+" ";
}
@ -440,7 +440,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
}
else
{
return this.getName();
return this.getNameAndSomething(null);
}
}
@ -557,7 +557,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
}
// Event
FactionsEventMembershipChange membershipChangeEvent = new FactionsEventMembershipChange(sender, this, myFaction, MembershipChangeReason.LEAVE);
FactionsEventMembershipChange membershipChangeEvent = new FactionsEventMembershipChange(this.getSender(), this, myFaction, MembershipChangeReason.LEAVE);
membershipChangeEvent.run();
if (membershipChangeEvent.isCancelled()) return;

View File

@ -7,6 +7,7 @@ import com.massivecraft.mcore.mixin.Mixin;
import com.massivecraft.mcore.store.MStore;
import com.massivecraft.mcore.store.SenderColl;
import com.massivecraft.mcore.util.TimeUnit;
import com.massivecraft.mcore.util.Txt;
public class UPlayerColl extends SenderColl<UPlayer>
{
@ -64,11 +65,17 @@ public class UPlayerColl extends SenderColl<UPlayer>
public void clean()
{
FactionColl factionColl = FactionColls.get().get(this);
String universe = this.getUniverse();
for (UPlayer uplayer : this.getAll())
{
if (FactionColls.get().get(this).containsId(uplayer.getFactionId())) continue;
String factionId = uplayer.getFactionId();
if (factionColl.containsId(factionId)) continue;
Factions.get().log("Reset faction data (invalid faction) for player "+uplayer.getName());
uplayer.resetFactionData();
String message = Txt.parse("<i>Reset data for <h>%s <i>in <h>%s <i>universe. Unknown factionId <h>%s", uplayer.getDisplayName(), universe, factionId);
Factions.get().log(message);
}
}

View File

@ -17,12 +17,17 @@ public abstract class XColls<C extends Coll<E>, E> extends Colls<C, E>
if (o instanceof Entity)
{
return this.getForUniverse(((Entity<?>)o).getUniverse());
String universe = ((Entity<?>)o).getUniverse();
if (universe == null) return null;
return this.getForUniverse(universe);
}
if (o instanceof Coll)
{
return this.getForUniverse(((Coll<?>)o).getUniverse());
String universe = ((Coll<?>)o).getUniverse();
if (universe == null) return null;
return this.getForUniverse(universe);
}
if (SenderUtil.isNonplayer(o))

View File

@ -131,20 +131,22 @@ public class FactionsListenerEcon implements Listener
Double cost = null;
String desc = null;
UConf uconf = UConf.get(event.getSender());
if (uconf == null) return;
if (event.getReason() == MembershipChangeReason.JOIN)
{
cost = UConf.get(event.getSender()).econCostJoin;
cost = uconf.econCostJoin;
desc = "join a faction";
}
else if (event.getReason() == MembershipChangeReason.LEAVE)
{
// TODO: NPE once occurred on line below.
cost = UConf.get(event.getSender()).econCostLeave;
cost = uconf.econCostLeave;
desc = "leave a faction";
}
else if (event.getReason() == MembershipChangeReason.KICK)
{
cost = UConf.get(event.getSender()).econCostKick;
cost = uconf.econCostKick;
desc = "kick someone from a faction";
}
else