Fix getters for motd and description

This commit is contained in:
Magnus Ulf Jørgensen 2017-05-09 10:59:38 +02:00
parent 25a54882c9
commit 4dba9140de
5 changed files with 31 additions and 19 deletions

View File

@ -48,7 +48,7 @@ public class CmdFactionsDescription extends FactionsCommand
// Inform // Inform
for (MPlayer follower : msenderFaction.getMPlayers()) for (MPlayer follower : msenderFaction.getMPlayers())
{ {
follower.msg("<i>%s <i>set your faction description to:\n%s", MixinDisplayName.get().getDisplayName(sender, follower), msenderFaction.getDescription()); follower.msg("<i>%s <i>set your faction description to:\n%s", MixinDisplayName.get().getDisplayName(sender, follower), msenderFaction.getDescriptionDesc());
} }
} }

View File

@ -1,6 +1,5 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.entity.MPerm;
import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.event.EventFactionsMotdChange; import com.massivecraft.factions.event.EventFactionsMotdChange;
@ -42,22 +41,17 @@ public class CmdFactionsMotd extends FactionsCommand
// Args // Args
String target = this.readArg(); String target = this.readArg();
// Clean input target = target.trim();
target = Faction.clean(target);
target = Txt.parse(target); target = Txt.parse(target);
// Get Old // Get Old
String old = null; String old = msenderFaction.getMotd();
if (msenderFaction.hasMotd())
{
old = msenderFaction.getMotd();
}
// NoChange // NoChange
if (MUtil.equals(old, target)) if (MUtil.equals(old, target))
{ {
msg("<i>The motd for %s <i>is already: <h>%s", msenderFaction.describeTo(msender, true), old == null ? Txt.parse("<silver>none") : old); msg("<i>The motd for %s <i>is already: <h>%s", msenderFaction.describeTo(msender, true), msenderFaction.getMotdDesc());
return; return;
} }
@ -73,7 +67,7 @@ public class CmdFactionsMotd extends FactionsCommand
// Inform // Inform
for (MPlayer follower : msenderFaction.getMPlayers()) for (MPlayer follower : msenderFaction.getMPlayers())
{ {
follower.msg("<i>%s <i>set your faction motd to:\n%s", MixinDisplayName.get().getDisplayName(sender, follower), msenderFaction.getMotd()); follower.msg("<i>%s <i>set your faction motd to:\n%s", MixinDisplayName.get().getDisplayName(sender, follower), msenderFaction.getMotdDesc());
} }
} }

View File

@ -114,7 +114,7 @@ public class EngineMoveChunk extends Engine
string = string.replace("{name}", faction.getName()); string = string.replace("{name}", faction.getName());
string = string.replace("{relcolor}", faction.getColorTo(mplayer).toString()); string = string.replace("{relcolor}", faction.getColorTo(mplayer).toString());
string = string.replace("{desc}", faction.getDescription()); string = string.replace("{desc}", faction.getDescriptionDesc());
return string; return string;
} }

View File

@ -59,7 +59,7 @@ public class EngineShow extends Engine
} }
// DESCRIPTION // DESCRIPTION
show(idPriorityLiness, Const.SHOW_ID_FACTION_DESCRIPTION, Const.SHOW_PRIORITY_FACTION_DESCRIPTION, "Description", faction.getDescription()); show(idPriorityLiness, Const.SHOW_ID_FACTION_DESCRIPTION, Const.SHOW_PRIORITY_FACTION_DESCRIPTION, "Description", faction.getDescriptionDesc());
// SECTION: NORMAL // SECTION: NORMAL
if (normal) if (normal)

View File

@ -237,8 +237,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
public String getDescription() public String getDescription()
{ {
if (this.hasDescription()) return this.description; return this.description;
return NODESCRIPTION;
} }
public void setDescription(String description) public void setDescription(String description)
@ -256,6 +255,15 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
this.changed(); this.changed();
} }
// FINER
public String getDescriptionDesc()
{
String motd = this.getDescription();
if (motd == null) motd = NODESCRIPTION;
return motd;
}
// -------------------------------------------- // // -------------------------------------------- //
// FIELD: motd // FIELD: motd
// -------------------------------------------- // // -------------------------------------------- //
@ -269,8 +277,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
public String getMotd() public String getMotd()
{ {
if (this.hasMotd()) return this.motd; return this.motd;
return NOMOTD;
} }
public void setMotd(String motd) public void setMotd(String motd)
@ -290,6 +297,17 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
// FINER // FINER
public String getMotdDesc()
{
return getMotdDesc(this.getMotd());
}
private static String getMotdDesc(String motd)
{
if (motd == null) motd = NOMOTD;
return motd;
}
public List<Object> getMotdMessages() public List<Object> getMotdMessages()
{ {
// Create // Create
@ -300,7 +318,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
title = Txt.titleize(title); title = Txt.titleize(title);
ret.add(title); ret.add(title);
String motd = Txt.parse("<i>" + this.getMotd()); String motd = Txt.parse("<i>") + this.getMotdDesc();
ret.add(motd); ret.add(motd);
ret.add(""); ret.add("");