mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-27 04:35:21 +01:00
Removing player index to reduce complexity since I doubt its required. Decouble and nullify faction descriptions.
This commit is contained in:
parent
6ef15bc2db
commit
1ccefc93b5
@ -71,9 +71,6 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
||||
public boolean hasFaction() { return this.factionId != null && ! factionId.equals(Const.FACTIONID_NONE); }
|
||||
public void setFaction(Faction faction)
|
||||
{
|
||||
Faction oldFaction = this.getFaction();
|
||||
if (oldFaction != null) oldFaction.removeFPlayer(this);
|
||||
faction.addFPlayer(this);
|
||||
this.factionId = faction.getId();
|
||||
SpoutFeatures.updateTitle(this, null);
|
||||
SpoutFeatures.updateTitle(null, this);
|
||||
@ -157,15 +154,6 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
||||
|
||||
public final void resetFactionData(boolean doSpoutUpdate)
|
||||
{
|
||||
if (this.factionId != null && FactionColl.get().containsId(this.factionId)) // Avoid infinite loop! TODO: I think that this is needed is a sign we need to refactor.
|
||||
{
|
||||
Faction currentFaction = this.getFaction();
|
||||
if (currentFaction != null)
|
||||
{
|
||||
currentFaction.removeFPlayer(this);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Should we not rather use ConfServer.newPlayerStartingFactionID here?
|
||||
this.factionId = Const.FACTIONID_NONE; // The default neutral faction
|
||||
|
||||
@ -476,7 +464,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
||||
}
|
||||
Faction factionHere = BoardColl.get().getFactionAt(this.getCurrentChunk());
|
||||
String msg = Txt.parse("<i>")+" ~ "+factionHere.getTag(this);
|
||||
if (factionHere.getDescription().length() > 0)
|
||||
if (factionHere.hasDescription())
|
||||
{
|
||||
msg += " - "+factionHere.getDescription();
|
||||
}
|
||||
@ -564,7 +552,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
||||
PS ps = PS.valueOf(location);
|
||||
Faction myFaction = this.getFaction();
|
||||
Faction currentFaction = BoardColl.get().getFactionAt(ps);
|
||||
int ownedLand = forFaction.getLandRounded();
|
||||
int ownedLand = forFaction.getLandCount();
|
||||
|
||||
if (ConfServer.worldGuardChecking && Worldguard.checkForRegionsInChunk(location))
|
||||
{
|
||||
@ -611,7 +599,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
||||
(
|
||||
ConfServer.claimsMustBeConnected
|
||||
&& ! this.isUsingAdminMode()
|
||||
&& myFaction.getLandRoundedInWorld(ps.getWorld()) > 0
|
||||
&& myFaction.getLandCountInWorld(ps.getWorld()) > 0
|
||||
&& !BoardColl.get().isConnectedPs(ps, myFaction)
|
||||
&& (!ConfServer.claimsCanBeUnconnectedIfOwnedByOtherFaction || !currentFaction.isNormal())
|
||||
)
|
||||
@ -649,7 +637,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
||||
PS flocation = PS.valueOf(location).getChunk(true);
|
||||
Faction currentFaction = BoardColl.get().getFactionAt(flocation);
|
||||
|
||||
int ownedLand = forFaction.getLandRounded();
|
||||
int ownedLand = forFaction.getLandCount();
|
||||
|
||||
if ( ! this.canClaimForFactionAtLocation(forFaction, location, notifyFailure)) return false;
|
||||
|
||||
@ -662,7 +650,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
|
||||
{
|
||||
cost = Econ.calculateClaimCost(ownedLand, currentFaction.isNormal());
|
||||
|
||||
if (ConfServer.econClaimUnconnectedFee != 0.0 && forFaction.getLandRoundedInWorld(flocation.getWorld()) > 0 && !BoardColl.get().isConnectedPs(flocation, forFaction))
|
||||
if (ConfServer.econClaimUnconnectedFee != 0.0 && forFaction.getLandCountInWorld(flocation.getWorld()) > 0 && !BoardColl.get().isConnectedPs(flocation, forFaction))
|
||||
cost += ConfServer.econClaimUnconnectedFee;
|
||||
|
||||
if(ConfServer.bankEnabled && ConfServer.bankFactionPaysLandCosts && this.hasFaction())
|
||||
|
@ -2,8 +2,10 @@ package com.massivecraft.factions;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||
@ -13,7 +15,7 @@ import com.massivecraft.factions.integration.SpoutFeatures;
|
||||
import com.massivecraft.factions.util.*;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
import com.massivecraft.mcore.store.Entity;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
import com.massivecraft.mcore.util.SenderUtil;
|
||||
import com.massivecraft.mcore.xlib.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
@ -39,7 +41,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
this.invitedPlayerIds = that.invitedPlayerIds;
|
||||
this.open = that.open;
|
||||
this.tag = that.tag;
|
||||
this.description = that.description;
|
||||
this.setDescription(that.description);
|
||||
this.home = that.home;
|
||||
this.cape = that.cape;
|
||||
this.powerBoost = that.powerBoost;
|
||||
@ -53,10 +55,6 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
// FIELDS: RAW
|
||||
// -------------------------------------------- //
|
||||
|
||||
// speedy lookup of players in faction
|
||||
private transient Set<FPlayer> fplayers = new HashSet<FPlayer>();
|
||||
// TODO
|
||||
|
||||
private Map<String, Rel> relationWish;
|
||||
// TODO
|
||||
|
||||
@ -84,8 +82,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
this.invitedPlayerIds = target;
|
||||
}
|
||||
|
||||
// TODO: Add when we use a true mcore entity.
|
||||
// this.changed();
|
||||
this.changed();
|
||||
}
|
||||
|
||||
private boolean open;
|
||||
@ -116,10 +113,31 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
|
||||
// FIELD: description
|
||||
private String description;
|
||||
public String getDescription() { return this.description; }
|
||||
public void setDescription(String value) { this.description = value; }
|
||||
public boolean hasDescription()
|
||||
{
|
||||
return this.description != null;
|
||||
}
|
||||
public String getDescription()
|
||||
{
|
||||
if (this.hasDescription()) return this.description;
|
||||
return Lang.FACTION_NODESCRIPTION;
|
||||
}
|
||||
public void setDescription(String description)
|
||||
{
|
||||
if (description != null)
|
||||
{
|
||||
description = description.trim();
|
||||
// This code should be kept for a while to clean out the previous default text that was actually stored in the database.
|
||||
if (description.length() == 0 || description.equalsIgnoreCase("Default faction description :("))
|
||||
{
|
||||
description = null;
|
||||
}
|
||||
}
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
// FIELD: home
|
||||
// TODO: Use a PS instead!
|
||||
private LazyLocation home;
|
||||
public void setHome(Location home) { this.home = new LazyLocation(home); }
|
||||
public boolean hasHome() { return this.getHome() != null; }
|
||||
@ -166,8 +184,6 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
// FIELDS: Flag management
|
||||
// TODO: This will save... defaults if they where changed to...
|
||||
|
||||
|
||||
|
||||
private Map<FFlag, Boolean> flagOverrides; // Contains the modifications to the default values
|
||||
public boolean getFlag(FFlag flag)
|
||||
{
|
||||
@ -245,15 +261,15 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
|
||||
|
||||
// -------------------------------------------- //
|
||||
// Construct
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public Faction()
|
||||
{
|
||||
this.relationWish = new HashMap<String, Rel>();
|
||||
this.relationWish = new LinkedHashMap<String, Rel>();
|
||||
this.open = ConfServer.newFactionsDefaultOpen;
|
||||
this.tag = "???";
|
||||
this.description = "Default faction description :(";
|
||||
this.description = null;
|
||||
this.powerBoost = 0.0;
|
||||
this.flagOverrides = new LinkedHashMap<FFlag, Boolean>();
|
||||
this.permOverrides = new LinkedHashMap<FPerm, Set<Rel>>();
|
||||
@ -306,26 +322,23 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
this.removeInvitedPlayerId(fplayer.getId());
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
// Understand the types
|
||||
// -------------------------------
|
||||
|
||||
// TODO: These should be gone after the refactoring...
|
||||
|
||||
public boolean isNormal()
|
||||
{
|
||||
//return ! (this.isNone() || this.isSafeZone() || this.isWarZone());
|
||||
return ! this.isNone();
|
||||
}
|
||||
// -------------------------------------------- //
|
||||
// NONE OR NORMAL?
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean isNone()
|
||||
{
|
||||
return this.getId().equals(Const.FACTIONID_NONE);
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
// Relation and relation colors
|
||||
// -------------------------------
|
||||
public boolean isNormal()
|
||||
{
|
||||
return ! this.isNone();
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// RELATION AND COLORS
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String describeTo(RelationParticipator observer, boolean ucfirst)
|
||||
@ -402,8 +415,9 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
|
||||
// TODO: Implement a has enough feature.
|
||||
// -------------------------------------------- //
|
||||
// Power
|
||||
// POWER
|
||||
// -------------------------------------------- //
|
||||
|
||||
public double getPower()
|
||||
{
|
||||
if (this.getFlag(FFlag.INFPOWER))
|
||||
@ -412,7 +426,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
}
|
||||
|
||||
double ret = 0;
|
||||
for (FPlayer fplayer : fplayers)
|
||||
for (FPlayer fplayer : this.getFPlayers())
|
||||
{
|
||||
ret += fplayer.getPower();
|
||||
}
|
||||
@ -431,7 +445,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
}
|
||||
|
||||
double ret = 0;
|
||||
for (FPlayer fplayer : fplayers)
|
||||
for (FPlayer fplayer : this.getFPlayers())
|
||||
{
|
||||
ret += fplayer.getPowerMax();
|
||||
}
|
||||
@ -452,119 +466,91 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
return (int) Math.round(this.getPowerMax());
|
||||
}
|
||||
|
||||
// TODO: Why "rounded"? Rename to getLandCount? or getChunkCount?
|
||||
public int getLandRounded()
|
||||
public int getLandCount()
|
||||
{
|
||||
return BoardColl.get().getCount(this);
|
||||
}
|
||||
public int getLandRoundedInWorld(String worldName)
|
||||
public int getLandCountInWorld(String worldName)
|
||||
{
|
||||
return BoardColl.get().get(worldName).getCount(this);
|
||||
}
|
||||
|
||||
public boolean hasLandInflation()
|
||||
{
|
||||
return this.getLandRounded() > this.getPowerRounded();
|
||||
return this.getLandCount() > this.getPowerRounded();
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FPlayers
|
||||
// FPLAYERS
|
||||
// -------------------------------------------- //
|
||||
|
||||
// maintain the reference list of FPlayers in this faction
|
||||
public void refreshFPlayers()
|
||||
public List<FPlayer> getFPlayers()
|
||||
{
|
||||
fplayers.clear();
|
||||
if (this.isNone()) return;
|
||||
|
||||
List<FPlayer> ret = new ArrayList<FPlayer>();
|
||||
for (FPlayer fplayer : FPlayerColl.get().getAll())
|
||||
{
|
||||
if (fplayer.getFaction() == this)
|
||||
{
|
||||
fplayers.add(fplayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected boolean addFPlayer(FPlayer fplayer)
|
||||
{
|
||||
if (this.isNone()) return false;
|
||||
|
||||
return fplayers.add(fplayer);
|
||||
}
|
||||
protected boolean removeFPlayer(FPlayer fplayer)
|
||||
{
|
||||
if (this.isNone()) return false;
|
||||
|
||||
return fplayers.remove(fplayer);
|
||||
}
|
||||
|
||||
public Set<FPlayer> getFPlayers()
|
||||
{
|
||||
// return a shallow copy of the FPlayer list, to prevent tampering and concurrency issues
|
||||
Set<FPlayer> ret = new HashSet<FPlayer>(fplayers);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Set<FPlayer> getFPlayersWhereOnline(boolean online)
|
||||
{
|
||||
Set<FPlayer> ret = new HashSet<FPlayer>();
|
||||
|
||||
for (FPlayer fplayer : fplayers)
|
||||
{
|
||||
if (fplayer.isOnline() == online)
|
||||
{
|
||||
if (fplayer.getFaction() != this) continue;
|
||||
ret.add(fplayer);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public FPlayer getFPlayerLeader()
|
||||
public List<FPlayer> getFPlayersWhereOnline(boolean online)
|
||||
{
|
||||
//if ( ! this.isNormal()) return null;
|
||||
|
||||
for (FPlayer fplayer : fplayers)
|
||||
List<FPlayer> ret = new ArrayList<FPlayer>();
|
||||
for (FPlayer fplayer : FPlayerColl.get().getAll())
|
||||
{
|
||||
if (fplayer.getRole() == Rel.LEADER)
|
||||
{
|
||||
return fplayer;
|
||||
if (fplayer.getFaction() != this) continue;
|
||||
if (fplayer.isOnline() != online) continue;
|
||||
ret.add(fplayer);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<FPlayer> getFPlayersWhereRole(Rel role)
|
||||
{
|
||||
List<FPlayer> ret = new ArrayList<FPlayer>();
|
||||
for (FPlayer fplayer : FPlayerColl.get().getAll())
|
||||
{
|
||||
if (fplayer.getFaction() != this) continue;
|
||||
if (fplayer.getRole() != role) continue;
|
||||
ret.add(fplayer);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public FPlayer getLeader()
|
||||
{
|
||||
for (FPlayer fplayer : FPlayerColl.get().getAll())
|
||||
{
|
||||
if (fplayer.getFaction() != this) continue;
|
||||
if (fplayer.getRole() != Rel.LEADER) continue;
|
||||
return fplayer;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<FPlayer> getFPlayersWhereRole(Rel role)
|
||||
public List<CommandSender> getOnlineCommandSenders()
|
||||
{
|
||||
ArrayList<FPlayer> ret = new ArrayList<FPlayer>();
|
||||
//if ( ! this.isNormal()) return ret;
|
||||
|
||||
for (FPlayer fplayer : fplayers)
|
||||
List<CommandSender> ret = new ArrayList<CommandSender>();
|
||||
for (CommandSender player : SenderUtil.getOnlineSenders())
|
||||
{
|
||||
if (fplayer.getRole() == role)
|
||||
{
|
||||
ret.add(fplayer);
|
||||
FPlayer fplayer = FPlayerColl.get().get(player);
|
||||
if (fplayer.getFaction() != this) continue;
|
||||
ret.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// TODO: Makes use of bukkit instead of mixin. Fix that?
|
||||
public ArrayList<Player> getOnlinePlayers()
|
||||
public List<Player> getOnlinePlayers()
|
||||
{
|
||||
ArrayList<Player> ret = new ArrayList<Player>();
|
||||
//if (this.isPlayerFreeType()) return ret;
|
||||
|
||||
for (Player player: Factions.get().getServer().getOnlinePlayers())
|
||||
List<Player> ret = new ArrayList<Player>();
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
FPlayer fplayer = FPlayerColl.get().get(player);
|
||||
if (fplayer.getFaction() == this)
|
||||
{
|
||||
if (fplayer.getFaction() != this) continue;
|
||||
ret.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -574,25 +560,31 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
if ( ! this.isNormal()) return;
|
||||
if (this.getFlag(FFlag.PERMANENT) && ConfServer.permanentFactionsDisableLeaderPromotion) return;
|
||||
|
||||
FPlayer oldLeader = this.getFPlayerLeader();
|
||||
FPlayer oldLeader = this.getLeader();
|
||||
|
||||
// get list of officers, or list of normal members if there are no officers
|
||||
ArrayList<FPlayer> replacements = this.getFPlayersWhereRole(Rel.OFFICER);
|
||||
List<FPlayer> replacements = this.getFPlayersWhereRole(Rel.OFFICER);
|
||||
if (replacements == null || replacements.isEmpty())
|
||||
{
|
||||
replacements = this.getFPlayersWhereRole(Rel.MEMBER);
|
||||
}
|
||||
|
||||
if (replacements == null || replacements.isEmpty())
|
||||
{ // faction leader is the only member; one-man faction
|
||||
if (this.getFlag(FFlag.PERMANENT))
|
||||
{
|
||||
if (oldLeader != null)
|
||||
{
|
||||
oldLeader.setRole(Rel.MEMBER);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// no members left and faction isn't permanent, so disband it
|
||||
if (ConfServer.logFactionDisband)
|
||||
{
|
||||
Factions.get().log("The faction "+this.getTag()+" ("+this.getId()+") has been disbanded since it has no members left.");
|
||||
}
|
||||
|
||||
for (FPlayer fplayer : FPlayerColl.get().getAllOnline())
|
||||
{
|
||||
@ -604,7 +596,10 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
else
|
||||
{ // promote new faction leader
|
||||
if (oldLeader != null)
|
||||
{
|
||||
oldLeader.setRole(Rel.MEMBER);
|
||||
}
|
||||
|
||||
replacements.get(0).setRole(Rel.LEADER);
|
||||
this.msg("<i>Faction leader <h>%s<i> has been removed. %s<i> has been promoted as the new faction leader.", oldLeader == null ? "" : oldLeader.getName(), replacements.get(0).getName());
|
||||
Factions.get().log("Faction "+this.getTag()+" ("+this.getId()+") leader was removed. Replacement leader: "+replacements.get(0).getName());
|
||||
@ -612,37 +607,66 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// Messages
|
||||
// MESSAGES
|
||||
// -------------------------------------------- //
|
||||
// These methods are simply proxied in from the SenderEntity class using a for loop.
|
||||
|
||||
// TODO: Invalid code since Mixin introduction. Fix this.
|
||||
public boolean msg(String message, Object... args)
|
||||
// CONVENIENCE SEND MESSAGE
|
||||
|
||||
public boolean sendMessage(String message)
|
||||
{
|
||||
message = Txt.parse(message, args);
|
||||
|
||||
for (FPlayer fplayer : this.getFPlayersWhereOnline(true))
|
||||
for (FPlayer fplayer : this.getFPlayers())
|
||||
{
|
||||
fplayer.sendMessage(message);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void sendMessage(String message)
|
||||
public boolean sendMessage(String... messages)
|
||||
{
|
||||
for (FPlayer fplayer : this.getFPlayersWhereOnline(true))
|
||||
{
|
||||
fplayer.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMessage(List<String> messages)
|
||||
{
|
||||
for (FPlayer fplayer : this.getFPlayersWhereOnline(true))
|
||||
for (FPlayer fplayer : this.getFPlayers())
|
||||
{
|
||||
fplayer.sendMessage(messages);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean sendMessage(Collection<String> messages)
|
||||
{
|
||||
for (FPlayer fplayer : this.getFPlayers())
|
||||
{
|
||||
fplayer.sendMessage(messages);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// CONVENIENCE MSG
|
||||
|
||||
public boolean msg(String msg)
|
||||
{
|
||||
for (FPlayer fplayer : this.getFPlayers())
|
||||
{
|
||||
fplayer.msg(msg);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean msg(String msg, Object... args)
|
||||
{
|
||||
for (FPlayer fplayer : this.getFPlayers())
|
||||
{
|
||||
fplayer.msg(msg, args);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean msg(Collection<String> msgs)
|
||||
{
|
||||
for (FPlayer fplayer : this.getFPlayers())
|
||||
{
|
||||
fplayer.msg(msgs);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -41,14 +41,6 @@ public class FactionColl extends Coll<Faction>
|
||||
this.migrate();
|
||||
|
||||
this.createDefaultFactions();
|
||||
|
||||
// TODO: Refactor and fix with the member-index.
|
||||
// populate all faction player lists
|
||||
// or as you also could describe it: Reindex of Members
|
||||
for (Faction faction : this.getAll())
|
||||
{
|
||||
faction.refreshFPlayers();
|
||||
}
|
||||
}
|
||||
|
||||
public void migrate()
|
||||
@ -194,10 +186,10 @@ public class FactionColl extends Coll<Faction>
|
||||
Factions.get().log("Running econLandRewardRoutine...");
|
||||
for (Faction faction : this.getAll())
|
||||
{
|
||||
int landCount = faction.getLandRounded();
|
||||
int landCount = faction.getLandCount();
|
||||
if (!faction.getFlag(FFlag.PEACEFUL) && landCount > 0)
|
||||
{
|
||||
Set<FPlayer> players = faction.getFPlayers();
|
||||
List<FPlayer> players = faction.getFPlayers();
|
||||
int playerCount = players.size();
|
||||
double reward = ConfServer.econLandReward * landCount / playerCount;
|
||||
for (FPlayer player : players)
|
||||
|
@ -28,7 +28,7 @@ public class FactionListComparator implements Comparator<Faction>
|
||||
if (f2 == null) ret = +1;
|
||||
if (ret != 0) return ret;
|
||||
|
||||
// None
|
||||
// None a.k.a. Wilderness
|
||||
if (f1.isNone() && f2.isNone()) ret = 0;
|
||||
if (f1.isNone()) ret = -1;
|
||||
if (f2.isNone()) ret = +1;
|
||||
|
8
src/com/massivecraft/factions/Lang.java
Normal file
8
src/com/massivecraft/factions/Lang.java
Normal file
@ -0,0 +1,8 @@
|
||||
package com.massivecraft.factions;
|
||||
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
public class Lang
|
||||
{
|
||||
public static final String FACTION_NODESCRIPTION = Txt.parse("<em><silver>no description set");
|
||||
}
|
@ -7,7 +7,6 @@ import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
public class CmdFactionsDescription extends FCommand
|
||||
{
|
||||
@ -28,22 +27,21 @@ public class CmdFactionsDescription extends FCommand
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if ( ! payForCommand(ConfServer.econCostDesc, "to change faction description", "for changing faction description")) return;
|
||||
|
||||
// TODO: This must be an invalid replace-approach. The call order is wrong somehow?
|
||||
myFaction.setDescription(Txt.implode(args, " ").replaceAll("(&([a-f0-9]))", "& $2")); // since "&" color tags seem to work even through plain old FPlayer.sendMessage() for some reason, we need to break those up
|
||||
|
||||
if ( ! ConfServer.broadcastDescriptionChanges)
|
||||
if (ConfServer.broadcastDescriptionChanges)
|
||||
{
|
||||
fme.msg("You have changed the description for <h>%s<i> to:", myFaction.describeTo(fme));
|
||||
fme.sendMessage(myFaction.getDescription());
|
||||
return;
|
||||
}
|
||||
|
||||
// Broadcast the description to everyone
|
||||
for (FPlayer fplayer : FPlayerColl.get().getAllOnline())
|
||||
{
|
||||
fplayer.msg("<h>%s<i> changed their description to:", myFaction.describeTo(fplayer));
|
||||
fplayer.sendMessage(myFaction.getDescription()); // players can inject "&" or "`" or "<i>" or whatever in their description, thus exploitable (masquerade as server messages or whatever); by the way, &k is particularly interesting looking
|
||||
fplayer.sendMessage(myFaction.getDescription());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fme.msg("You have changed the description for <h>%s<i> to:", myFaction.describeTo(fme));
|
||||
fme.sendMessage(myFaction.getDescription());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class CmdFactionsLeader extends FCommand
|
||||
Faction targetFaction = this.arg(1, ARFaction.get(), myFaction);
|
||||
if (targetFaction == null) return;
|
||||
|
||||
FPlayer targetFactionCurrentLeader = targetFaction.getFPlayerLeader();
|
||||
FPlayer targetFactionCurrentLeader = targetFaction.getLeader();
|
||||
|
||||
// We now have fplayer and the target faction
|
||||
if (this.senderIsConsole || fme.isUsingAdminMode() || Perm.LEADER_ANY.has(sender, false))
|
||||
|
@ -64,7 +64,7 @@ public class CmdFactionsList extends FCommand
|
||||
faction.getTag(fme),
|
||||
faction.getFPlayersWhereOnline(true).size(),
|
||||
faction.getFPlayers().size(),
|
||||
faction.getLandRounded(),
|
||||
faction.getLandCount(),
|
||||
faction.getPowerRounded(),
|
||||
faction.getPowerMaxRounded())
|
||||
);
|
||||
|
@ -61,12 +61,12 @@ public class CmdFactionsShow extends FCommand
|
||||
|
||||
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.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded(), boost);
|
||||
msg("<a>Land / Power / Maxpower: <i> %d/%d/%d %s", faction.getLandCount(), faction.getPowerRounded(), faction.getPowerMaxRounded(), boost);
|
||||
|
||||
// show the land value
|
||||
if (Econ.shouldBeUsed())
|
||||
{
|
||||
double value = Econ.calculateTotalLandValue(faction.getLandRounded());
|
||||
double value = Econ.calculateTotalLandValue(faction.getLandCount());
|
||||
double refund = value * ConfServer.econClaimRefundMultiplier;
|
||||
if (value > 0)
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ public class CmdFactionsUnclaim extends FCommand
|
||||
//String moneyBack = "<i>";
|
||||
if (Econ.shouldBeUsed())
|
||||
{
|
||||
double refund = Econ.calculateClaimRefund(myFaction.getLandRounded());
|
||||
double refund = Econ.calculateClaimRefund(myFaction.getLandCount());
|
||||
|
||||
if(ConfServer.bankEnabled && ConfServer.bankFactionPaysLandCosts)
|
||||
{
|
||||
|
@ -28,7 +28,7 @@ public class CmdFactionsUnclaimall extends FCommand
|
||||
{
|
||||
if (Econ.shouldBeUsed())
|
||||
{
|
||||
double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded());
|
||||
double refund = Econ.calculateTotalLandRefund(myFaction.getLandCount());
|
||||
if(ConfServer.bankEnabled && ConfServer.bankFactionPaysLandCosts)
|
||||
{
|
||||
if ( ! Econ.modifyMoney(myFaction, refund, "to unclaim all faction land", "for unclaiming all faction land")) return;
|
||||
|
@ -113,8 +113,10 @@ public class SpoutMainListener implements Listener
|
||||
|
||||
String msg = tag;
|
||||
|
||||
if (ConfServer.spoutTerritoryDisplayShowDescription && !factionHere.getDescription().isEmpty())
|
||||
if (ConfServer.spoutTerritoryDisplayShowDescription && factionHere.hasDescription())
|
||||
{
|
||||
msg += " - " + factionHere.getDescription();
|
||||
}
|
||||
|
||||
label.setText(msg);
|
||||
alignLabel(label, msg);
|
||||
@ -141,8 +143,10 @@ public class SpoutMainListener implements Listener
|
||||
|
||||
String msg = tag;
|
||||
|
||||
if (ConfServer.spoutTerritoryNoticeShowDescription && !factionHere.getDescription().isEmpty())
|
||||
if (ConfServer.spoutTerritoryNoticeShowDescription && factionHere.hasDescription())
|
||||
{
|
||||
msg += " - " + factionHere.getDescription();
|
||||
}
|
||||
|
||||
label.setText(msg);
|
||||
alignLabel(label, msg, 2);
|
||||
|
Loading…
Reference in New Issue
Block a user