001package net.minecraft.scoreboard; 002 003import java.util.ArrayList; 004import java.util.Collection; 005import java.util.Collections; 006import java.util.HashMap; 007import java.util.Iterator; 008import java.util.List; 009import java.util.Map; 010 011public class Scoreboard 012{ 013 private final Map field_96545_a = new HashMap(); 014 private final Map field_96543_b = new HashMap(); 015 private final Map field_96544_c = new HashMap(); 016 private final ScoreObjective[] field_96541_d = new ScoreObjective[3]; 017 private final Map field_96542_e = new HashMap(); 018 private final Map field_96540_f = new HashMap(); 019 020 public ScoreObjective func_96518_b(String par1Str) 021 { 022 return (ScoreObjective)this.field_96545_a.get(par1Str); 023 } 024 025 public ScoreObjective func_96535_a(String par1Str, ScoreObjectiveCriteria par2ScoreObjectiveCriteria) 026 { 027 ScoreObjective scoreobjective = this.func_96518_b(par1Str); 028 029 if (scoreobjective != null) 030 { 031 throw new IllegalArgumentException("An objective with the name \'" + par1Str + "\' already exists!"); 032 } 033 else 034 { 035 scoreobjective = new ScoreObjective(this, par1Str, par2ScoreObjectiveCriteria); 036 Object object = (List)this.field_96543_b.get(par2ScoreObjectiveCriteria); 037 038 if (object == null) 039 { 040 object = new ArrayList(); 041 this.field_96543_b.put(par2ScoreObjectiveCriteria, object); 042 } 043 044 ((List)object).add(scoreobjective); 045 this.field_96545_a.put(par1Str, scoreobjective); 046 this.func_96522_a(scoreobjective); 047 return scoreobjective; 048 } 049 } 050 051 public Collection func_96520_a(ScoreObjectiveCriteria par1ScoreObjectiveCriteria) 052 { 053 Collection collection = (Collection)this.field_96543_b.get(par1ScoreObjectiveCriteria); 054 return collection == null ? new ArrayList() : new ArrayList(collection); 055 } 056 057 public Score func_96529_a(String par1Str, ScoreObjective par2ScoreObjective) 058 { 059 Object object = (Map)this.field_96544_c.get(par1Str); 060 061 if (object == null) 062 { 063 object = new HashMap(); 064 this.field_96544_c.put(par1Str, object); 065 } 066 067 Score score = (Score)((Map)object).get(par2ScoreObjective); 068 069 if (score == null) 070 { 071 score = new Score(this, par2ScoreObjective, par1Str); 072 ((Map)object).put(par2ScoreObjective, score); 073 } 074 075 return score; 076 } 077 078 public Collection func_96534_i(ScoreObjective par1ScoreObjective) 079 { 080 ArrayList arraylist = new ArrayList(); 081 Iterator iterator = this.field_96544_c.values().iterator(); 082 083 while (iterator.hasNext()) 084 { 085 Map map = (Map)iterator.next(); 086 Score score = (Score)map.get(par1ScoreObjective); 087 088 if (score != null) 089 { 090 arraylist.add(score); 091 } 092 } 093 094 Collections.sort(arraylist, Score.field_96658_a); 095 return arraylist; 096 } 097 098 public Collection func_96514_c() 099 { 100 return this.field_96545_a.values(); 101 } 102 103 public Collection func_96526_d() 104 { 105 return this.field_96544_c.keySet(); 106 } 107 108 public void func_96515_c(String par1Str) 109 { 110 Map map = (Map)this.field_96544_c.remove(par1Str); 111 112 if (map != null) 113 { 114 this.func_96516_a(par1Str); 115 } 116 } 117 118 public Collection func_96528_e() 119 { 120 Collection collection = this.field_96544_c.values(); 121 ArrayList arraylist = new ArrayList(); 122 123 if (collection != null) 124 { 125 Iterator iterator = collection.iterator(); 126 127 while (iterator.hasNext()) 128 { 129 Map map = (Map)iterator.next(); 130 arraylist.addAll(map.values()); 131 } 132 } 133 134 return arraylist; 135 } 136 137 public Map func_96510_d(String par1Str) 138 { 139 Object object = (Map)this.field_96544_c.get(par1Str); 140 141 if (object == null) 142 { 143 object = new HashMap(); 144 } 145 146 return (Map)object; 147 } 148 149 public void func_96519_k(ScoreObjective par1ScoreObjective) 150 { 151 this.field_96545_a.remove(par1ScoreObjective.func_96679_b()); 152 153 for (int i = 0; i < 3; ++i) 154 { 155 if (this.func_96539_a(i) == par1ScoreObjective) 156 { 157 this.func_96530_a(i, (ScoreObjective)null); 158 } 159 } 160 161 List list = (List)this.field_96543_b.get(par1ScoreObjective.func_96680_c()); 162 163 if (list != null) 164 { 165 list.remove(par1ScoreObjective); 166 } 167 168 Iterator iterator = this.field_96544_c.values().iterator(); 169 170 while (iterator.hasNext()) 171 { 172 Map map = (Map)iterator.next(); 173 map.remove(par1ScoreObjective); 174 } 175 176 this.func_96533_c(par1ScoreObjective); 177 } 178 179 public void func_96530_a(int par1, ScoreObjective par2ScoreObjective) 180 { 181 this.field_96541_d[par1] = par2ScoreObjective; 182 } 183 184 public ScoreObjective func_96539_a(int par1) 185 { 186 return this.field_96541_d[par1]; 187 } 188 189 public ScorePlayerTeam func_96508_e(String par1Str) 190 { 191 return (ScorePlayerTeam)this.field_96542_e.get(par1Str); 192 } 193 194 public ScorePlayerTeam func_96527_f(String par1Str) 195 { 196 ScorePlayerTeam scoreplayerteam = this.func_96508_e(par1Str); 197 198 if (scoreplayerteam != null) 199 { 200 throw new IllegalArgumentException("An objective with the name \'" + par1Str + "\' already exists!"); 201 } 202 else 203 { 204 scoreplayerteam = new ScorePlayerTeam(this, par1Str); 205 this.field_96542_e.put(par1Str, scoreplayerteam); 206 this.func_96523_a(scoreplayerteam); 207 return scoreplayerteam; 208 } 209 } 210 211 public void func_96511_d(ScorePlayerTeam par1ScorePlayerTeam) 212 { 213 this.field_96542_e.remove(par1ScorePlayerTeam.func_96661_b()); 214 Iterator iterator = par1ScorePlayerTeam.func_96670_d().iterator(); 215 216 while (iterator.hasNext()) 217 { 218 String s = (String)iterator.next(); 219 this.field_96540_f.remove(s); 220 } 221 222 this.func_96513_c(par1ScorePlayerTeam); 223 } 224 225 public void func_96521_a(String par1Str, ScorePlayerTeam par2ScorePlayerTeam) 226 { 227 if (this.func_96509_i(par1Str) != null) 228 { 229 this.func_96524_g(par1Str); 230 } 231 232 this.field_96540_f.put(par1Str, par2ScorePlayerTeam); 233 par2ScorePlayerTeam.func_96670_d().add(par1Str); 234 } 235 236 public boolean func_96524_g(String par1Str) 237 { 238 ScorePlayerTeam scoreplayerteam = this.func_96509_i(par1Str); 239 240 if (scoreplayerteam != null) 241 { 242 this.func_96512_b(par1Str, scoreplayerteam); 243 return true; 244 } 245 else 246 { 247 return false; 248 } 249 } 250 251 public void func_96512_b(String par1Str, ScorePlayerTeam par2ScorePlayerTeam) 252 { 253 if (this.func_96509_i(par1Str) != par2ScorePlayerTeam) 254 { 255 throw new IllegalStateException("Player is either on another team or not on any team. Cannot remove from team \'" + par2ScorePlayerTeam.func_96661_b() + "\'."); 256 } 257 else 258 { 259 this.field_96540_f.remove(par1Str); 260 par2ScorePlayerTeam.func_96670_d().remove(par1Str); 261 } 262 } 263 264 public Collection func_96531_f() 265 { 266 return this.field_96542_e.keySet(); 267 } 268 269 public Collection func_96525_g() 270 { 271 return this.field_96542_e.values(); 272 } 273 274 public ScorePlayerTeam func_96509_i(String par1Str) 275 { 276 return (ScorePlayerTeam)this.field_96540_f.get(par1Str); 277 } 278 279 public void func_96522_a(ScoreObjective par1ScoreObjective) {} 280 281 public void func_96532_b(ScoreObjective par1ScoreObjective) {} 282 283 public void func_96533_c(ScoreObjective par1ScoreObjective) {} 284 285 public void func_96536_a(Score par1Score) {} 286 287 public void func_96516_a(String par1Str) {} 288 289 public void func_96523_a(ScorePlayerTeam par1ScorePlayerTeam) {} 290 291 public void func_96538_b(ScorePlayerTeam par1ScorePlayerTeam) {} 292 293 public void func_96513_c(ScorePlayerTeam par1ScorePlayerTeam) {} 294 295 public static String func_96517_b(int par0) 296 { 297 switch (par0) 298 { 299 case 0: 300 return "list"; 301 case 1: 302 return "sidebar"; 303 case 2: 304 return "belowName"; 305 default: 306 return null; 307 } 308 } 309 310 public static int func_96537_j(String par0Str) 311 { 312 return par0Str.equalsIgnoreCase("list") ? 0 : (par0Str.equalsIgnoreCase("sidebar") ? 1 : (par0Str.equalsIgnoreCase("belowName") ? 2 : -1)); 313 } 314}