1.5h improve getters and setters
This commit is contained in:
parent
ad4ad7307f
commit
b21d622b93
|
@ -35,10 +35,10 @@ public class CmdFactionsOverride extends FactionsCommand
|
||||||
{
|
{
|
||||||
// Args
|
// Args
|
||||||
boolean target = this.readArg( ! msender.isOverriding());
|
boolean target = this.readArg( ! msender.isOverriding());
|
||||||
|
|
||||||
// Apply
|
// Apply
|
||||||
msender.setOverriding(target);
|
msender.setOverriding(target);
|
||||||
|
|
||||||
// Inform
|
// Inform
|
||||||
String desc = Txt.parse(msender.isOverriding() ? "<g>ENABLED" : "<b>DISABLED");
|
String desc = Txt.parse(msender.isOverriding() ? "<g>ENABLED" : "<b>DISABLED");
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@ import com.massivecraft.factions.event.EventFactionsChunkChangeType;
|
||||||
import com.massivecraft.factions.event.EventFactionsChunksChange;
|
import com.massivecraft.factions.event.EventFactionsChunksChange;
|
||||||
import com.massivecraft.factions.event.EventFactionsDisband;
|
import com.massivecraft.factions.event.EventFactionsDisband;
|
||||||
import com.massivecraft.factions.event.EventFactionsMembershipChange;
|
import com.massivecraft.factions.event.EventFactionsMembershipChange;
|
||||||
import com.massivecraft.factions.event.EventFactionsRemovePlayerMillis;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
|
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
|
||||||
|
import com.massivecraft.factions.event.EventFactionsRemovePlayerMillis;
|
||||||
import com.massivecraft.factions.util.RelationUtil;
|
import com.massivecraft.factions.util.RelationUtil;
|
||||||
import com.massivecraft.massivecore.mixin.MixinSenderPs;
|
import com.massivecraft.massivecore.mixin.MixinSenderPs;
|
||||||
import com.massivecraft.massivecore.mixin.MixinTitle;
|
import com.massivecraft.massivecore.mixin.MixinTitle;
|
||||||
|
@ -224,17 +224,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
|
||||||
|
|
||||||
public void setLastActivityMillis(long lastActivityMillis)
|
public void setLastActivityMillis(long lastActivityMillis)
|
||||||
{
|
{
|
||||||
// Clean input
|
this.lastActivityMillis = convertSet(lastActivityMillis, this.lastActivityMillis, 0L);
|
||||||
long target = lastActivityMillis;
|
|
||||||
|
|
||||||
// Detect Nochange
|
|
||||||
if (MUtil.equals(this.lastActivityMillis, target)) return;
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
this.lastActivityMillis = target;
|
|
||||||
|
|
||||||
// Mark as changed
|
|
||||||
this.changed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastActivityMillis()
|
public void setLastActivityMillis()
|
||||||
|
@ -255,21 +245,18 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
|
||||||
// This method never returns null
|
// This method never returns null
|
||||||
public String getFactionId()
|
public String getFactionId()
|
||||||
{
|
{
|
||||||
if (this.factionId == null) return MConf.get().defaultPlayerFactionId;
|
return convertGet(this.factionId, MConf.get().defaultPlayerFactionId);
|
||||||
return this.factionId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method never returns null
|
// This method never returns null
|
||||||
public Faction getFaction()
|
public Faction getFaction()
|
||||||
{
|
{
|
||||||
Faction ret = Faction.get(this.getFactionId());
|
return convertGet(Faction.get(this.getFactionId()), Faction.get(MConf.get().defaultPlayerFactionId));
|
||||||
if (ret == null) ret = Faction.get(MConf.get().defaultPlayerFactionId);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasFaction()
|
public boolean hasFaction()
|
||||||
{
|
{
|
||||||
return !this.getFactionId().equals(Factions.ID_NONE);
|
return !this.getFactionId().equals(MConf.get().defaultPlayerFactionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This setter is so long because it search for default/null case and takes
|
// This setter is so long because it search for default/null case and takes
|
||||||
|
@ -322,23 +309,12 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
|
||||||
|
|
||||||
public Rel getRole()
|
public Rel getRole()
|
||||||
{
|
{
|
||||||
if (this.role == null) return MConf.get().defaultPlayerRole;
|
return convertGet(this.role, MConf.get().defaultPlayerRole);
|
||||||
return this.role;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRole(Rel role)
|
public void setRole(Rel role)
|
||||||
{
|
{
|
||||||
// Clean input
|
this.role = convertSet(role, this.role, MConf.get().defaultPlayerRole);
|
||||||
Rel target = role;
|
|
||||||
|
|
||||||
// Detect Nochange
|
|
||||||
if (MUtil.equals(this.role, target)) return;
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
this.role = target;
|
|
||||||
|
|
||||||
// Mark as changed
|
|
||||||
this.changed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -352,8 +328,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
|
||||||
|
|
||||||
public String getTitle()
|
public String getTitle()
|
||||||
{
|
{
|
||||||
if (this.hasTitle()) return this.title;
|
return convertGet(this.title, Lang.PLAYER_NOTITLE);
|
||||||
return Lang.PLAYER_NOTITLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title)
|
public void setTitle(String title)
|
||||||
|
@ -378,14 +353,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
|
||||||
target = Txt.parse(target);
|
target = Txt.parse(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect Nochange
|
this.title = convertSet(target, this.title, null);
|
||||||
if (MUtil.equals(this.title, target)) return;
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
this.title = target;
|
|
||||||
|
|
||||||
// Mark as changed
|
|
||||||
this.changed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -394,25 +362,12 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
|
||||||
|
|
||||||
public double getPowerBoost()
|
public double getPowerBoost()
|
||||||
{
|
{
|
||||||
Double ret = this.powerBoost;
|
return convertGet(this.powerBoost, 0D);
|
||||||
if (ret == null) ret = 0D;
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPowerBoost(Double powerBoost)
|
public void setPowerBoost(Double powerBoost)
|
||||||
{
|
{
|
||||||
// Clean input
|
this.powerBoost = convertSet(powerBoost, this.powerBoost, 0D);
|
||||||
Double target = powerBoost;
|
|
||||||
if (target == null || target == 0) target = null;
|
|
||||||
|
|
||||||
// Detect Nochange
|
|
||||||
if (MUtil.equals(this.powerBoost, target)) return;
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
this.powerBoost = target;
|
|
||||||
|
|
||||||
// Mark as changed
|
|
||||||
this.changed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPowerBoost()
|
public boolean hasPowerBoost()
|
||||||
|
@ -486,25 +441,14 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
|
||||||
|
|
||||||
public double getPower()
|
public double getPower()
|
||||||
{
|
{
|
||||||
Double ret = this.power;
|
Double ret = convertGet(this.power, MConf.get().defaultPlayerPower);
|
||||||
if (ret == null) ret = MConf.get().defaultPlayerPower;
|
|
||||||
ret = this.getLimitedPower(ret);
|
ret = this.getLimitedPower(ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPower(Double power)
|
public void setPower(Double power)
|
||||||
{
|
{
|
||||||
// Clean input
|
this.power = convertSet(power, this.power, MConf.get().defaultPlayerPower);
|
||||||
Double target = power;
|
|
||||||
|
|
||||||
// Detect Nochange
|
|
||||||
if (MUtil.equals(this.power, target)) return;
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
this.power = target;
|
|
||||||
|
|
||||||
// Mark as changed
|
|
||||||
this.changed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FINER
|
// FINER
|
||||||
|
@ -520,25 +464,12 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
|
||||||
|
|
||||||
public boolean isMapAutoUpdating()
|
public boolean isMapAutoUpdating()
|
||||||
{
|
{
|
||||||
if (this.mapAutoUpdating == null) return false;
|
return convertGet(this.mapAutoUpdating);
|
||||||
if (this.mapAutoUpdating == false) return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMapAutoUpdating(Boolean mapAutoUpdating)
|
public void setMapAutoUpdating(Boolean mapAutoUpdating)
|
||||||
{
|
{
|
||||||
// Clean input
|
this.mapAutoUpdating = convertSet(mapAutoUpdating, this.mapAutoUpdating);
|
||||||
Boolean target = mapAutoUpdating;
|
|
||||||
if (MUtil.equals(target, false)) target = null;
|
|
||||||
|
|
||||||
// Detect Nochange
|
|
||||||
if (MUtil.equals(this.mapAutoUpdating, target)) return;
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
this.mapAutoUpdating = target;
|
|
||||||
|
|
||||||
// Mark as changed
|
|
||||||
this.changed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -547,32 +478,12 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
|
||||||
|
|
||||||
public boolean isOverriding()
|
public boolean isOverriding()
|
||||||
{
|
{
|
||||||
if (this.overriding == null) return false;
|
return convertGet(this.overriding, Perm.OVERRIDE);
|
||||||
if (this.overriding == false) return false;
|
|
||||||
|
|
||||||
if (!this.hasPermission(Perm.OVERRIDE, true))
|
|
||||||
{
|
|
||||||
this.setOverriding(false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOverriding(Boolean overriding)
|
public void setOverriding(Boolean overriding)
|
||||||
{
|
{
|
||||||
// Clean input
|
this.overriding = this.convertSet(overriding, this.overriding);
|
||||||
Boolean target = overriding;
|
|
||||||
if (MUtil.equals(target, false)) target = null;
|
|
||||||
|
|
||||||
// Detect Nochange
|
|
||||||
if (MUtil.equals(this.overriding, target)) return;
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
this.overriding = target;
|
|
||||||
|
|
||||||
// Mark as changed
|
|
||||||
this.changed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -582,24 +493,13 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
|
||||||
public boolean isTerritoryInfoTitles()
|
public boolean isTerritoryInfoTitles()
|
||||||
{
|
{
|
||||||
if (!MixinTitle.get().isAvailable()) return false;
|
if (!MixinTitle.get().isAvailable()) return false;
|
||||||
if (this.territoryInfoTitles == null) return MConf.get().territoryInfoTitlesDefault;
|
return convertGet(this.territoryInfoTitles, (Boolean) MConf.get().territoryInfoTitlesDefault);
|
||||||
return this.territoryInfoTitles;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTerritoryInfoTitles(Boolean territoryInfoTitles)
|
public void setTerritoryInfoTitles(Boolean territoryInfoTitles)
|
||||||
{
|
{
|
||||||
// Clean input
|
// Clean input
|
||||||
Boolean target = territoryInfoTitles;
|
this.territoryInfoTitles = this.convertSet(territoryInfoTitles, this.territoryInfoTitles);
|
||||||
if (MUtil.equals(target, MConf.get().territoryInfoTitlesDefault)) target = null;
|
|
||||||
|
|
||||||
// Detect Nochange
|
|
||||||
if (MUtil.equals(this.territoryInfoTitles, target)) return;
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
this.territoryInfoTitles = target;
|
|
||||||
|
|
||||||
// Mark as changed
|
|
||||||
this.changed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -923,7 +823,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
|
||||||
|
|
||||||
public static Set<MPlayer> getClaimInformees(MPlayer msender, Faction... factions)
|
public static Set<MPlayer> getClaimInformees(MPlayer msender, Faction... factions)
|
||||||
{
|
{
|
||||||
Set<MPlayer> ret = new HashSet<MPlayer>();
|
Set<MPlayer> ret = new HashSet<>();
|
||||||
|
|
||||||
if (msender != null) ret.add(msender);
|
if (msender != null) ret.add(msender);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue