Skip to content

Commit

Permalink
-allow server owners to adjust the suppression of the motd and rules
Browse files Browse the repository at this point in the history
  • Loading branch information
DraygoKorvan committed Jul 31, 2014
1 parent 1cc907b commit 8cccab7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
35 changes: 33 additions & 2 deletions SEMotd/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public class SEMotdSettings
private double m_interval = 300;
private bool m_enable = true;
private bool m_onJoinMessage = true;
private int m_motdRepeatSuppress = 60;
private int m_rulesRepeatSuppress = 60;

public string rules
{
get { return m_rules; }
Expand All @@ -67,6 +70,16 @@ public bool onJoinMessage
get { return m_onJoinMessage; }
set { m_onJoinMessage = value; }
}
public int rulesRepeatSuppress
{
get { return m_rulesRepeatSuppress; }
set { if (value > 0) m_rulesRepeatSuppress = value; else m_rulesRepeatSuppress = 1; }
}
public int motdRepeatSuppress
{
get { return m_motdRepeatSuppress; }
set { if (value > 0) m_motdRepeatSuppress = value; else m_motdRepeatSuppress = 1; }
}
}
public class SEMotd : PluginBase, IChatEventHandler , IPlayerEventHandler
{
Expand Down Expand Up @@ -169,6 +182,24 @@ public bool onJoinMessage
get { if (settings.onJoinMessage) return true; else return false; }
set { settings.onJoinMessage = value; }
}
[Category("SE Motd")]
[Description("Motd Repeat Suppress in seconds. Seconds until MOTD can be repeated")]
[Browsable(true)]
[ReadOnly(false)]
public int motdRepeatSuppress
{
get { return settings.motdRepeatSuppress; }
set { settings.motdRepeatSuppress = value; }
}
[Category("SE Motd")]
[Description("Rules Repeat Suppress in seconds. Seconds until rules can be repeated")]
[Browsable(true)]
[ReadOnly(false)]
public int rulesRepeatSuppress
{
get { return settings.rulesRepeatSuppress; }
set { settings.rulesRepeatSuppress = value; }
}
#endregion

#region "Methods"
Expand Down Expand Up @@ -283,7 +314,7 @@ public void OnChatReceived(SEModAPIExtensions.API.ChatManager.ChatEvent obj)
//proccess
if (words[0] == "/motd")
{
if (m_lastupdate + TimeSpan.FromMinutes(1) < DateTime.UtcNow)
if (m_lastupdate + TimeSpan.FromSeconds(motdRepeatSuppress) < DateTime.UtcNow)
{
m_lastupdate = DateTime.UtcNow;
sendMotd();
Expand All @@ -292,7 +323,7 @@ public void OnChatReceived(SEModAPIExtensions.API.ChatManager.ChatEvent obj)
}
if (words[0] == "/rules")
{
if (m_ruleslastupdate + TimeSpan.FromMinutes(1) < DateTime.UtcNow)
if (m_ruleslastupdate + TimeSpan.FromSeconds(rulesRepeatSuppress) < DateTime.UtcNow)
{
m_ruleslastupdate = DateTime.UtcNow;
sendRules();
Expand Down
4 changes: 2 additions & 2 deletions SEMotd/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("0.2.1.7")]
[assembly: AssemblyFileVersion("0.2.1.7")]
[assembly: AssemblyVersion("0.2.2.1")]
[assembly: AssemblyFileVersion("0.2.2.1")]

0 comments on commit 8cccab7

Please sign in to comment.