Messing arund a bit with defaults
This commit is contained in:
@ -269,24 +269,25 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
this.changed();
|
||||
}
|
||||
|
||||
public boolean hasPowerBoost()
|
||||
{
|
||||
return this.getPowerBoost() != 0D;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FIELD: open
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean isDefaultOpen()
|
||||
{
|
||||
return UConf.get(this).defaultFactionOpen;
|
||||
}
|
||||
|
||||
public boolean isOpen()
|
||||
{
|
||||
Boolean ret = this.open;
|
||||
if (ret == null) ret = UConf.get(this).newFactionsDefaultOpen;
|
||||
if (ret == null) ret = this.isDefaultOpen();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setOpen(Boolean open)
|
||||
{
|
||||
if (open == null || MUtil.equals(open, this.isDefaultOpen())) open = null;
|
||||
this.open = open;
|
||||
this.changed();
|
||||
}
|
||||
@ -664,7 +665,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
public double getPowerMax()
|
||||
{
|
||||
if (this.getFlag(FFlag.INFPOWER)) return 999999;
|
||||
return UConf.get(this).powerFactionMax + this.getPowerBoost();
|
||||
return UConf.get(this).factionPowerMax + this.getPowerBoost();
|
||||
}
|
||||
|
||||
public int getPowerRounded()
|
||||
|
@ -27,31 +27,29 @@ public class UConf extends Entity<UConf>
|
||||
// CORE
|
||||
// -------------------------------------------- //
|
||||
|
||||
public Map<FFlag, Boolean> factionFlagDefaults = FFlag.getDefaultDefaults();
|
||||
public Map<FPerm, Set<Rel>> factionPermDefaults = FPerm.getDefaultDefaults();
|
||||
|
||||
public String playerDefaultFactionId = Const.FACTIONID_NONE;
|
||||
public Rel playerDefaultRole = Rel.RECRUIT;
|
||||
|
||||
public boolean canLeaveWithNegativePower = true;
|
||||
|
||||
public int factionMemberLimit = 0;
|
||||
public double factionPowerMax = 1000.0;
|
||||
|
||||
public int factionTagLengthMin = 3;
|
||||
public int factionTagLengthMax = 10;
|
||||
public boolean factionTagForceUpperCase = false;
|
||||
|
||||
public boolean newFactionsDefaultOpen = false;
|
||||
|
||||
public int factionMemberLimit = 0;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// POWER
|
||||
// DEFAULTS
|
||||
// -------------------------------------------- //
|
||||
|
||||
// TODO: Group default values together?
|
||||
// TODO: should I add a nofaction id here?
|
||||
// And perhaps for safezone and warzone as well.
|
||||
|
||||
public double powerPlayerDefault = 0.0;
|
||||
public String defaultPlayerFactionId = Const.FACTIONID_NONE;
|
||||
public double defaultPlayerPower = 0.0;
|
||||
public Rel defaultPlayerRole = Rel.RECRUIT;
|
||||
|
||||
public double powerFactionMax = 1000.0;
|
||||
public boolean defaultFactionOpen = false;
|
||||
public Map<FFlag, Boolean> defaultFactionFlags = FFlag.getDefaultDefaults();
|
||||
public Map<FPerm, Set<Rel>> defaultFactionPerms = FPerm.getDefaultDefaults();
|
||||
|
||||
// -------------------------------------------- //
|
||||
// DENY COMMANDS
|
||||
|
@ -26,6 +26,7 @@ import com.massivecraft.mcore.mixin.Mixin;
|
||||
import com.massivecraft.mcore.money.Money;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
import com.massivecraft.mcore.store.SenderEntity;
|
||||
import com.massivecraft.mcore.util.MUtil;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
|
||||
@ -58,13 +59,10 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
||||
@Override
|
||||
public boolean isDefault()
|
||||
{
|
||||
// TODO: What if I incorporated the "default" word into the system?
|
||||
// Rename?: hasFaction --> isFactionDefault
|
||||
|
||||
if (this.hasFaction()) return false;
|
||||
// Role means nothing without a faction.
|
||||
// Title means nothing without a faction.
|
||||
if (this.getPowerRounded() != (int) Math.round(UConf.get(this).powerPlayerDefault)) return false;
|
||||
if (this.getPowerRounded() != (int) Math.round(UConf.get(this).defaultPlayerPower)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -174,10 +172,15 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
||||
// FIELD: factionId
|
||||
// -------------------------------------------- //
|
||||
|
||||
public String getDefaultFactionId()
|
||||
{
|
||||
return UConf.get(this).defaultPlayerFactionId;
|
||||
}
|
||||
|
||||
// This method never returns null
|
||||
public String getFactionId()
|
||||
{
|
||||
if (this.factionId == null) return UConf.get(this).playerDefaultFactionId;
|
||||
if (this.factionId == null) return this.getDefaultFactionId();
|
||||
return this.factionId;
|
||||
}
|
||||
|
||||
@ -185,7 +188,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
||||
public Faction getFaction()
|
||||
{
|
||||
Faction ret = FactionColls.get().get(this).get(this.getFactionId());
|
||||
if (ret == null) ret = FactionColls.get().get(this).get(UConf.get(this).playerDefaultFactionId);
|
||||
if (ret == null) ret = FactionColls.get().get(this).get(UConf.get(this).defaultPlayerFactionId);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -198,7 +201,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
||||
public void setFactionId(String factionId)
|
||||
{
|
||||
// Avoid null input
|
||||
if (factionId == null) factionId = Const.FACTIONID_NONE;
|
||||
if (factionId == null) factionId = this.getDefaultFactionId();
|
||||
|
||||
// Get the old value
|
||||
String oldFactionId = this.getFactionId();
|
||||
@ -207,14 +210,8 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
||||
if (factionId.equals(oldFactionId)) return;
|
||||
|
||||
// Apply change
|
||||
if (factionId.equals(Const.FACTIONID_NONE))
|
||||
{
|
||||
this.factionId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.factionId = factionId;
|
||||
}
|
||||
if (factionId.equals(this.getDefaultFactionId())) factionId = null;
|
||||
this.factionId = factionId;
|
||||
|
||||
// Next we must be attached and inited
|
||||
if (!this.attached()) return;
|
||||
@ -241,22 +238,21 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
||||
// FIELD: role
|
||||
// -------------------------------------------- //
|
||||
|
||||
public Rel getDefaultRole()
|
||||
{
|
||||
return UConf.get(this).defaultPlayerRole;
|
||||
}
|
||||
|
||||
public Rel getRole()
|
||||
{
|
||||
if (this.role == null) return UConf.get(this).playerDefaultRole;
|
||||
if (this.role == null) return this.getDefaultRole();
|
||||
return this.role;
|
||||
}
|
||||
|
||||
public void setRole(Rel role)
|
||||
{
|
||||
if (role == null || role == UConf.get(this).playerDefaultRole)
|
||||
{
|
||||
this.role = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.role = role;
|
||||
}
|
||||
if (role == null || MUtil.equals(role, this.getDefaultRole())) role = null;
|
||||
this.role = role;
|
||||
this.changed();
|
||||
}
|
||||
|
||||
@ -295,23 +291,22 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
||||
|
||||
// RAW
|
||||
|
||||
public double getDefaultPower()
|
||||
{
|
||||
return UConf.get(this).defaultPlayerPower;
|
||||
}
|
||||
|
||||
public double getPower()
|
||||
{
|
||||
Double ret = this.power;
|
||||
if (ret == null) ret = UConf.get(this).powerPlayerDefault;
|
||||
if (ret == null) ret = this.getDefaultPower();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setPower(Double power)
|
||||
{
|
||||
if (power == null || power == UConf.get(this).powerPlayerDefault)
|
||||
{
|
||||
this.power = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.power = power;
|
||||
}
|
||||
if (power == null || MUtil.equals(power, this.getDefaultPower())) power = null;
|
||||
this.power = power;
|
||||
this.changed();
|
||||
}
|
||||
|
||||
@ -333,11 +328,9 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
||||
|
||||
public String getTag()
|
||||
{
|
||||
if ( ! this.hasFaction())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return this.getFaction().getTag();
|
||||
Faction faction = this.getFaction();
|
||||
if (faction.isNone()) return "";
|
||||
return faction.getTag();
|
||||
}
|
||||
|
||||
// Base concatenations:
|
||||
|
Reference in New Issue
Block a user