[Bobbot-cvs] Plugins/Sphere/JailSystem JailSystem.cs,1.2,1.3
Status: Alpha
Brought to you by:
iainmckay
From: Mr S. C. <mrs...@us...> - 2004-12-24 20:27:41
|
Update of /cvsroot/bobbot/Plugins/Sphere/JailSystem In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12404/Sphere/JailSystem Modified Files: JailSystem.cs Log Message: - Added 'Jail Edit <Account> <Length> [<Reason>]' as a private command. Edits an account entry by adding the <Length> (Can be a negative value) and amending the Reason set. - Added bool JailSystem.JailEdit(string[] args) - Added bool JailSystem.JailEdit(string account, string gm, string length, string reason) - Added bool JailSystem.EditEntry(string account, string gm, string length, string reason) Index: JailSystem.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/JailSystem/JailSystem.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** JailSystem.cs 24 Dec 2004 01:25:47 -0000 1.2 --- JailSystem.cs 24 Dec 2004 20:27:32 -0000 1.3 *************** *** 217,220 **** --- 217,252 ---- } + public bool EditEntry(string account, string gm, TimeSpan length, string reason) + { + try + { + if (!IsJailed(account)) + return false; + + JailEntry entry = GetJailEntry(account); + + if (entry.JailedBy.IndexOf(" (Amended by ") > -1) + entry.JailedBy = entry.JailedBy.Substring(0, entry.JailedBy.IndexOf(' ')); + if (gm != entry.JailedBy) + entry.JailedBy += " (Amended by " + gm + ")"; + + if (length.TotalMilliseconds > DateTime.Now.Subtract(entry.JailedUntil).TotalMilliseconds) + entry.JailedUntil = entry.JailedUntil.Add(length); + + if (reason != null) + entry.Reason = reason; + + entry.StartSentence(); + + if (!DelEntry(account)) + return false; + + m_JailEntryList.Add(entry); + return true; + } + + catch { return false; } + } + public JailEntry[] GetJailEntryList() { *************** *** 255,259 **** m_Server.Write(String.Format("account {0} jail 1", account), true); ! AddEntry(account, character, gm, TimeSpan.FromHours(double.Parse(length)), reason); Log.WriteLine("Sphere (JailDB)", "Account '{0}' is jailed by {1}! ({2} hours) (Reason: {3})", account, gm, length, reason); return true; --- 287,294 ---- m_Server.Write(String.Format("account {0} jail 1", account), true); ! ! if (!AddEntry(account, character, gm, TimeSpan.FromHours(double.Parse(length)), reason)) ! return false; ! Log.WriteLine("Sphere (JailDB)", "Account '{0}' is jailed by {1}! ({2} hours) (Reason: {3})", account, gm, length, reason); return true; *************** *** 263,266 **** --- 298,331 ---- } + public bool EditJail(string[] args) + { + if (args.Length < 5) + return false; + + return EditJail(args[0], args[1], args[2], args[3]); + } + + public bool EditJail(string account, string gm, string length, string reason) + { + if (!m_Server.IsConnected) { return false; } + + try + { + if (!IsJailed(account)) + return false; + + if (reason == null || reason == "") + reason = null; + + if (!EditEntry(account, gm, TimeSpan.FromHours(double.Parse(length)), reason)) + return false; + + Log.WriteLine("Sphere (JailDB)", "Account Entry '{0}' is edited by {1}! ({2} hours) (Reason: {3})", account, gm, (double.Parse(length) != 0? length : "Unedited"), (reason == null || reason == ""? "Unedited" : reason )); + return true; + } + + catch { return false; } + } + public bool Release(string[] args) { *************** *** 283,287 **** m_Server.Write(String.Format("account {0} jail 0", account), true); ! DelEntry(account); Log.WriteLine("Sphere (JailDB)", "Account '{0}' is released from jail!", account); return true; --- 348,355 ---- m_Server.Write(String.Format("account {0} jail 0", account), true); ! ! if (!DelEntry(account)) ! return false; ! Log.WriteLine("Sphere (JailDB)", "Account '{0}' is released from jail!", account); return true; |