[Bobbot-cvs] Plugins/Sphere/JailSystem JailEntry.cs,1.1,1.2 JailSystem.cs,1.1,1.2
Status: Alpha
Brought to you by:
iainmckay
From: Mr S. C. <mrs...@us...> - 2004-12-24 01:26:34
|
Update of /cvsroot/bobbot/Plugins/Sphere/JailSystem In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29920/Sphere/JailSystem Modified Files: JailEntry.cs JailSystem.cs Log Message: - Corrected a Spelling Mistake. - Added a 500ms delay between sending the login code and password when connecting the sphere to prevent losing the connection. - Added 'Jail Help <Command>' private command. Gives a more detailed description for each of the Jail Commands and provides examples. - Changed the command list (When providing unknown command for Jail) to display less detail for commands. - Put more spaces in the code. (so silly people like Jock can read it :D) Index: JailEntry.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/JailSystem/JailEntry.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JailEntry.cs 23 Dec 2004 23:02:28 -0000 1.1 --- JailEntry.cs 24 Dec 2004 01:25:47 -0000 1.2 *************** *** 90,94 **** if (m_JailTimer == null || !m_JailTimer.Enabled) return "Sentence Disabled"; ! return String.Format("{0} seconds left", m_JailTimer.Interval / 1000); } } --- 90,97 ---- if (m_JailTimer == null || !m_JailTimer.Enabled) return "Sentence Disabled"; ! ! TimeSpan sentence = m_JailEnd.Subtract(DateTime.Now); ! ! return String.Format("{0} hours left", Convert.ToInt32(sentence.TotalHours)); } } *************** *** 105,113 **** --- 108,119 ---- m_JailTimer.Dispose(); } + TimeSpan sentence = m_JailEnd.Subtract(DateTime.Now); + if (sentence.TotalMilliseconds < 30) m_JailTimer = new Timer(30); else m_JailTimer = new Timer(sentence.TotalMilliseconds); + m_JailTimer.AutoReset = false; m_JailTimer.Elapsed += new ElapsedEventHandler(this.OnSentenceServed); *************** *** 178,182 **** try { - //Bot.Core.Log.WriteLine("Sphere (JailDB)", "Attempting to release '{0}'", m_Account); if (!m_JailSystem.Release(this)) { --- 184,187 ---- *************** *** 187,193 **** return; } ! //Bot.Core.Log.WriteLine("Sphere (JailDB)", "Account '{0}' *SHOULD* be released :)", m_Account); return; } catch (System.Exception ex) { --- 192,199 ---- return; } ! return; } + catch (System.Exception ex) { Index: JailSystem.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/JailSystem/JailSystem.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JailSystem.cs 23 Dec 2004 23:02:28 -0000 1.1 --- JailSystem.cs 24 Dec 2004 01:25:47 -0000 1.2 *************** *** 43,50 **** --- 43,52 ---- private string JailDatabase = "JailDatabase.xml"; private SphereConnection m_Server; + private JailEntry[] m_JailEntries { get { return (JailEntry[]) m_JailEntryList.ToArray(typeof(JailEntry)); } } + private ArrayList m_JailEntryList; #endregion *************** *** 120,125 **** --- 122,129 ---- m_JailEntryList.Add(entry); } + return true; } + catch(Exception ex) { *************** *** 159,162 **** --- 163,167 ---- return true; } + catch(Exception ex) { *************** *** 174,177 **** --- 179,183 ---- if (IsJailed(account)) return false; + JailEntry entry = new JailEntry( this ); entry.Account = account; *************** *** 185,188 **** --- 191,195 ---- return true; } + catch { return false; } } *************** *** 194,197 **** --- 201,205 ---- if (!IsJailed(account)) return false; + for (int i = 0; i < m_JailEntryList.Count; i++) { *************** *** 201,207 **** --- 209,217 ---- return true; } + } return false; } + catch { return false; } } *************** *** 218,222 **** --- 228,234 ---- if (i.Account.ToLower() == account.ToLower()) return i; + } + return null; } *************** *** 226,229 **** --- 238,242 ---- if (args.Length < 5) return false; + return Jail(args[0], args[1], args[2], args[3], args[4]); } *************** *** 232,241 **** --- 245,257 ---- { if (!m_Server.IsConnected) { return false; } + try { if (reason == null || reason == "") reason = "None Set"; + if (character == null || character == "") character = "All"; + m_Server.Write(String.Format("account {0} jail 1", account), true); AddEntry(account, character, gm, TimeSpan.FromHours(double.Parse(length)), reason); *************** *** 243,246 **** --- 259,263 ---- return true; } + catch { return false; } } *************** *** 259,266 **** --- 276,285 ---- { if (!m_Server.IsConnected) { return false; } + try { if (!IsJailed(account)) return false; + m_Server.Write(String.Format("account {0} jail 0", account), true); DelEntry(account); *************** *** 268,271 **** --- 287,291 ---- return true; } + catch { return false; } } *************** *** 277,284 **** --- 297,306 ---- if (((JailEntry) m_JailEntryList[i]).Account.ToLower() == account.ToLower()) return true; + } return false; } + #endregion |