Fix some more small bugs
This commit is contained in:
		@@ -48,7 +48,7 @@ public class CmdFactionsJoin extends FCommand
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		if (faction == uplayerFaction)
 | 
							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;
 | 
								return;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -88,10 +88,10 @@ public class CmdFactionsJoin extends FCommand
 | 
				
			|||||||
		// Inform
 | 
							// Inform
 | 
				
			||||||
		if (!samePlayer)
 | 
							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));
 | 
							faction.msg("<i>%s <i>joined <lime>your faction<i>.", uplayer.describeTo(faction, true));
 | 
				
			||||||
		usender.msg("<i>%s successfully joined %s.", uplayer.describeTo(usender, true), faction.getName(usender));
 | 
							usender.msg("<i>%s <i>successfully joined %s<i>.", uplayer.describeTo(usender, true), faction.getName(usender));
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// Apply
 | 
							// Apply
 | 
				
			||||||
		uplayer.resetFactionData();
 | 
							uplayer.resetFactionData();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,7 +17,7 @@ public class CmdFactionsList extends FCommand
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	public CmdFactionsList()
 | 
						public CmdFactionsList()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		this.addAliases("ls", "list");
 | 
							this.addAliases("l", "list");
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		this.addOptionalArg("page", "1");
 | 
							this.addOptionalArg("page", "1");
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,7 +27,7 @@ public class CmdFactionsShow extends FCommand
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	public CmdFactionsShow()
 | 
						public CmdFactionsShow()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		this.addAliases("show", "who");
 | 
							this.addAliases("s", "show", "who");
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		this.addOptionalArg("faction", "you");
 | 
							this.addOptionalArg("faction", "you");
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
@@ -43,14 +43,11 @@ public class CmdFactionsShow extends FCommand
 | 
				
			|||||||
		
 | 
							
 | 
				
			||||||
		UConf uconf = UConf.get(faction);
 | 
							UConf uconf = UConf.get(faction);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		Collection<UPlayer> leaders = faction.getUPlayersWhereRole(Rel.LEADER);
 | 
							// INFO: Description
 | 
				
			||||||
		Collection<UPlayer> officers = faction.getUPlayersWhereRole(Rel.OFFICER);
 | 
					 | 
				
			||||||
		Collection<UPlayer> normals = faction.getUPlayersWhereRole(Rel.MEMBER);
 | 
					 | 
				
			||||||
		Collection<UPlayer> recruits = faction.getUPlayersWhereRole(Rel.RECRUIT);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		msg(Txt.titleize(faction.getName(usender)));
 | 
							msg(Txt.titleize(faction.getName(usender)));
 | 
				
			||||||
		msg("<a>Description: <i>%s", faction.getDescription());
 | 
							msg("<a>Description: <i>%s", faction.getDescription());
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
							// INFO: Age
 | 
				
			||||||
		long ageMillis = faction.getCreatedAtMillis() - System.currentTimeMillis();
 | 
							long ageMillis = faction.getCreatedAtMillis() - System.currentTimeMillis();
 | 
				
			||||||
		LinkedHashMap<TimeUnit, Long> ageUnitcounts = TimeDiffUtil.limit(TimeDiffUtil.unitcounts(ageMillis, TimeUnit.getAllButMillis()), 3);
 | 
							LinkedHashMap<TimeUnit, Long> ageUnitcounts = TimeDiffUtil.limit(TimeDiffUtil.unitcounts(ageMillis, TimeUnit.getAllButMillis()), 3);
 | 
				
			||||||
		String ageString = TimeDiffUtil.formatedVerboose(ageUnitcounts, "<i>");
 | 
							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>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();
 | 
							double powerBoost = faction.getPowerBoost();
 | 
				
			||||||
		String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? " (bonus: " : " (penalty: ") + powerBoost + ")";
 | 
							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);
 | 
							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));
 | 
							sendMessage(Txt.parse("<a>Enemies: ") + Txt.implode(relationNames.get(Rel.ENEMY), sepparator));
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// List the members...
 | 
							// 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> memberOnlineNames = new ArrayList<String>();
 | 
				
			||||||
		List<String> memberOfflineNames = new ArrayList<String>();
 | 
							List<String> memberOfflineNames = new ArrayList<String>();
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -423,8 +423,8 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	public String getNameAndSomething(String something)
 | 
						public String getNameAndSomething(String something)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		String ret = this.role.getPrefix();
 | 
							String ret = this.getRole().getPrefix();
 | 
				
			||||||
		if (something.length() > 0)
 | 
							if (something != null && something.length() > 0)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			ret += something+" ";
 | 
								ret += something+" ";
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -440,7 +440,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			return this.getName();
 | 
								return this.getNameAndSomething(null);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
@@ -557,7 +557,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Event
 | 
							// Event
 | 
				
			||||||
		FactionsEventMembershipChange membershipChangeEvent = new FactionsEventMembershipChange(sender, this, myFaction, MembershipChangeReason.LEAVE);
 | 
							FactionsEventMembershipChange membershipChangeEvent = new FactionsEventMembershipChange(this.getSender(), this, myFaction, MembershipChangeReason.LEAVE);
 | 
				
			||||||
		membershipChangeEvent.run();
 | 
							membershipChangeEvent.run();
 | 
				
			||||||
		if (membershipChangeEvent.isCancelled()) return;
 | 
							if (membershipChangeEvent.isCancelled()) return;
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,7 @@ import com.massivecraft.mcore.mixin.Mixin;
 | 
				
			|||||||
import com.massivecraft.mcore.store.MStore;
 | 
					import com.massivecraft.mcore.store.MStore;
 | 
				
			||||||
import com.massivecraft.mcore.store.SenderColl;
 | 
					import com.massivecraft.mcore.store.SenderColl;
 | 
				
			||||||
import com.massivecraft.mcore.util.TimeUnit;
 | 
					import com.massivecraft.mcore.util.TimeUnit;
 | 
				
			||||||
 | 
					import com.massivecraft.mcore.util.Txt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class UPlayerColl extends SenderColl<UPlayer>
 | 
					public class UPlayerColl extends SenderColl<UPlayer>
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -64,11 +65,17 @@ public class UPlayerColl extends SenderColl<UPlayer>
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	public void clean()
 | 
						public void clean()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
 | 
							FactionColl factionColl = FactionColls.get().get(this);
 | 
				
			||||||
 | 
							String universe = this.getUniverse();
 | 
				
			||||||
		for (UPlayer uplayer : this.getAll())
 | 
							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);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,12 +17,17 @@ public abstract class XColls<C extends Coll<E>, E> extends Colls<C, E>
 | 
				
			|||||||
		
 | 
							
 | 
				
			||||||
		if (o instanceof Entity)
 | 
							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)
 | 
							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))
 | 
							if (SenderUtil.isNonplayer(o))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -131,20 +131,22 @@ public class FactionsListenerEcon implements Listener
 | 
				
			|||||||
		Double cost = null;		
 | 
							Double cost = null;		
 | 
				
			||||||
		String desc = null;
 | 
							String desc = null;
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
							UConf uconf = UConf.get(event.getSender());
 | 
				
			||||||
 | 
							if (uconf == null) return;
 | 
				
			||||||
 | 
							
 | 
				
			||||||
		if (event.getReason() == MembershipChangeReason.JOIN)
 | 
							if (event.getReason() == MembershipChangeReason.JOIN)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			cost = UConf.get(event.getSender()).econCostJoin;
 | 
								cost = uconf.econCostJoin;
 | 
				
			||||||
			desc = "join a faction";
 | 
								desc = "join a faction";
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else if (event.getReason() == MembershipChangeReason.LEAVE)
 | 
							else if (event.getReason() == MembershipChangeReason.LEAVE)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			// TODO: NPE once occurred on line below.
 | 
								cost = uconf.econCostLeave;
 | 
				
			||||||
			cost = UConf.get(event.getSender()).econCostLeave;
 | 
					 | 
				
			||||||
			desc = "leave a faction";
 | 
								desc = "leave a faction";
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else if (event.getReason() == MembershipChangeReason.KICK)
 | 
							else if (event.getReason() == MembershipChangeReason.KICK)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			cost = UConf.get(event.getSender()).econCostKick;
 | 
								cost = uconf.econCostKick;
 | 
				
			||||||
			desc = "kick someone from a faction";
 | 
								desc = "kick someone from a faction";
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user