Source code: org/alicebot/server/core/Bots.java
1 // Decompiled by Jad v1.5.8c. Copyright 2001 Pavel Kouznetsov.
2 // Jad home page: http://www.geocities.com/kpdus/jad.html
3 // Decompiler options: packimports(3)
4
5 package org.alicebot.server.core;
6
7 import java.util.*;
8 import org.alicebot.server.core.util.DeveloperError;
9
10 // Referenced classes of package org.alicebot.server.core:
11 // Bot
12
13 public class Bots extends HashMap
14 {
15
16 private Bots()
17 {
18 }
19
20 public static boolean knowsBot(String s)
21 {
22 return myself.get(s) != null;
23 }
24
25 public static void addBot(String s, Bot bot)
26 {
27 myself.put(s, bot);
28 }
29
30 public static Bot getBot(String s)
31 {
32 Bot bot;
33 try
34 {
35 bot = (Bot)myself.get(s);
36 }
37 catch(ClassCastException classcastexception)
38 {
39 throw new DeveloperError("Something other than a Bot stored in Bots!");
40 }
41 if(bot == null)
42 throw new DeveloperError("Tried to get unknown bot \"" + s + "\".");
43 else
44 return bot;
45 }
46
47 public static Bot getFirstBot()
48 {
49 if(myself.size() > 0)
50 return (Bot)myself.values().iterator().next();
51 else
52 return null;
53 }
54
55 public static int getCount()
56 {
57 return myself.size();
58 }
59
60 public static String getNiceList()
61 {
62 if(myself.size() == 0)
63 return "";
64 StringBuffer stringbuffer = new StringBuffer();
65 for(Iterator iterator = myself.keySet().iterator(); iterator.hasNext(); stringbuffer.append((String)iterator.next()))
66 if(stringbuffer.length() > 0)
67 stringbuffer.append(' ');
68
69 return stringbuffer.toString();
70 }
71
72 public static Set getIDs()
73 {
74 return myself.keySet();
75 }
76
77 public static Iterator keysIterator()
78 {
79 return myself.keySet().iterator();
80 }
81
82 private static final Bots myself = new Bots();
83
84 }