View Javadoc

1   /*
2    * Copyright (C) 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic
3    *
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16   */
17  package cz.cuni.amis.pogamut.ut2004.communication.messages;
18  import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
19  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Self;
20  import cz.cuni.amis.utils.maps.HashMapSet;
21  
22  import java.util.HashMap;
23  import java.util.Set;
24  
25  /**
26   *
27   * @author Evers
28   */
29  public class UT2004ItemType extends ItemType {
30  	
31  	/**
32       * Map of all registered ItemType prototypes.
33       */
34      protected static HashMap<String, ItemType> protos = new HashMap<String, ItemType>();
35      
36      /**
37       * Contains item types that belongs to their groups.
38       */
39      public static final HashMapSet<UT2004Group, ItemType> GROUPS = new HashMapSet<UT2004Group, ItemType>();
40      
41      /**
42       * Category of this item.
43       */
44      private Category category;
45      
46      /**
47       * Group of this item.
48       */
49      private UT2004Group group;
50  
51      @Override
52      public String toString() {
53          return "ItemType[name = " + name + ", category = " + category + ", group = " + group + "]";
54      }
55  
56      @Override
57      public Category getCategory() {
58          return category;
59      }
60  
61      @Override
62      public UT2004Group getGroup() {
63          return group;
64      }
65  
66      @Override
67      public boolean equals(Object obj) {
68          // the same object?
69          if (this == obj)
70              return true;
71  
72          // the same type?
73          if (obj instanceof UT2004ItemType) {
74              // same value
75              if ((category == ((UT2004ItemType) obj).getCategory()) && (group == ((UT2004ItemType) obj).getGroup())
76                      && (name == ((UT2004ItemType) obj).getName()))
77                  return true;
78          }
79  
80          return false;
81      }
82  
83      @Override
84      public int hashCode() {
85          return getName().hashCode();
86      }
87  
88      @Override
89      public int compareTo(ItemType o) {
90          if (o == null) return 1;
91          
92          if (getName() == null) {
93              if (o.getName() == null)
94                  return 0;
95              return 1;
96          } else {
97              if (o.getName() == null) 
98                  return -1;
99              return getName().compareTo(o.getName());
100         }
101     }
102         
103     /**
104      * List of all item groups. Groups fine down the categories into specific
105      * groups, based on what the item belongs to. Also, groups join items from
106      * different categories together, if they belong together (e.g. weapon with
107      * its ammo).
108      */
109     public enum UT2004Group implements Group {
110         /** Translocating weapon and accessory. */
111         TRANSLOCATOR("Translocator"),
112         /** ShieldGun weapon and accessory. */
113         SHIELD_GUN("ShieldGun"),
114         /** AssaultRifle weapon and accessory. */
115         ASSAULT_RIFLE("AssaultRifle"),
116         /** BioRifle weapon and accessory. */
117         BIO_RIFLE("BioRifle"),
118         /** ShockRifle weapon and accessory. */
119         SHOCK_RIFLE("ShockRifle"),
120         /** LinkGun weapon and accessory. */
121         LINK_GUN("LinkGun"),
122         /** Minigun weapon and accessory. */
123         MINIGUN("Minigun"),
124         /** FlakCannon weapon and accessory. */
125         FLAK_CANNON("FlakCannon"),
126         /** RocketLauncher weapon and accessory. */
127         ROCKET_LAUNCHER("RocketLauncher"),
128         /** LightningGun weapon and accessory. */
129         LIGHTNING_GUN("LightningGun"),
130         /** SniperRifle weapon and accessory. */
131         SNIPER_RIFLE("SniperRifle"),
132         /** IonPainter weapon and accessory. */
133         ION_PAINTER("IonPainter"),
134         /** Redeemer weapon and accessory. */
135         REDEEMER("Redeemer"),
136         /** SuperShockRifle weapon and accessory. */
137         SUPER_SHOCK_RIFLE("SuperShockRifle"),
138         /** OnsMineLayer weapon and accessory. */
139         ONS_MINE_LAYER("ONS MineLayer"),
140         /** OnsGrenadeLauncher weapon and accessory. */
141         ONS_GRENADE_LAUNCHER("ONS GrenadeLauncher"),
142         /** OnsAvril weapon and accessory. */
143         ONS_AVRIL("ONS AVRiL"),
144         /** TargetPainter weapon and accessory. */
145         ONS_TARGET_PAINTER("TargetPainter"),
146 
147         /** Classic health pack. */
148         HEALTH("HealthKit"),
149         /** Mini health vial. */
150         MINI_HEALTH("HealthVial"),
151         /** Big health recharger. */
152         SUPER_HEALTH("SuperHealth"),
153 
154         /** Shield pack. */
155         SMALL_ARMOR("SmallShield"),
156         /** Shield pack. */
157         SUPER_ARMOR("SuperShield"),
158 
159         /** Adrenaline packs and adrenaline restorers. */
160         ADRENALINE("Adrenaline"),
161         /** UDamage bonus items. */
162         UDAMAGE("UDamage"),
163         /** Keys. */
164         KEY("Key"),
165         /** Other items with user-defined group. */
166         OTHER("Unknown"),
167         /** No group, used for the prototype None */
168         NONE("None");
169 
170         /* =================================================================== */
171         
172         /** Human-readable name of the group. */
173         public String name;
174 
175         /* =================================================================== */
176 
177         /**
178          * Constructor.
179          * 
180          * @param name
181          *            Human-readable name of the group.
182          */
183         UT2004Group(String name) {
184                 this.name = name;
185         }
186 
187         @Override
188         public Set<ItemType> getTypes() {
189                 return GROUPS.get(this);
190         }
191         
192         @Override
193         public String getName() {
194             return this.name;
195         }
196     }
197     
198     /* ======================================================================== */
199 
200     /** Translocator. */
201     public static final UT2004ItemType TRANSLOCATOR = MakePrototype(Category.WEAPON, UT2004Group.TRANSLOCATOR, new String[] {
202                     "XWeapons.TransPickup", "XWeapons.Transpickup", "XWeapons.Translauncher" });
203 
204     /** Translocator Beacon. */
205     public static final UT2004ItemType TRANSLOCATOR_PROJECTILE = MakePrototype(Category.PROJECTILE, UT2004Group.TRANSLOCATOR,
206                     new String[] { "XWeapons.BlueBeacon", "XWeapons.RedBeacon" });
207 
208     /** ShieldGun weapon. */
209     public static final UT2004ItemType SHIELD_GUN = MakePrototype(Category.WEAPON, UT2004Group.SHIELD_GUN, new String[] {
210                     "XWeapons.ShieldGunPickup", "XWeapons.ShieldGun" });
211 
212     /** ShieldGun ammo - sent when the bot is spawned. */
213     public static final UT2004ItemType SHIELD_GUN_AMMO = MakePrototype(Category.AMMO, UT2004Group.SHIELD_GUN, new String[] {
214                     "XWeapons.ShieldAmmoPickup", "XWeapons.ShieldAmmo" });
215 
216     /** AssaultRifle weapon. */
217     public static final UT2004ItemType ASSAULT_RIFLE = MakePrototype(Category.WEAPON, UT2004Group.ASSAULT_RIFLE, new String[] {
218                     "XWeapons.AssaultRiflePickup", "XWeapons.AssaultRifle" });
219     /** AssaultRifle ammo. */
220     public static final UT2004ItemType ASSAULT_RIFLE_AMMO = MakePrototype(Category.AMMO, UT2004Group.ASSAULT_RIFLE, new String[] {
221                     "XWeapons.AssaultAmmoPickup", "XWeapons.AssaultAmmo" });
222     /** AssaultRifle secondary ammo. */
223     public static final UT2004ItemType ASSAULT_RIFLE_GRENADE = MakePrototype(Category.AMMO, UT2004Group.ASSAULT_RIFLE,
224                     new String[] { "XWeapons.GrenadeAmmoPickup", "XWeapons.GrenadeAmmo" });
225     /** AssaultRifle projectile. */
226     public static final UT2004ItemType ASSAULT_RIFLE_PROJECTILE = MakePrototype(Category.PROJECTILE, UT2004Group.ASSAULT_RIFLE,
227                     new String[] { "XWeapons.Grenade" });
228 
229     /** BioRifle weapon. */
230     public static final UT2004ItemType BIO_RIFLE = MakePrototype(Category.WEAPON, UT2004Group.BIO_RIFLE, new String[] {
231                     "XWeapons.BioRiflePickup", "UTClassic.ClassicBioRiflePickup", "XWeapons.BioRifle" });
232     /** BioRifle ammo. */
233     public static final UT2004ItemType BIO_RIFLE_AMMO = MakePrototype(Category.AMMO, UT2004Group.BIO_RIFLE, new String[] {
234                     "XWeapons.BioAmmoPickup", "XWeapons.BioAmmo" });
235 
236     /** BioRifle projectile. */
237     public static final UT2004ItemType BIO_RIFLE_PROJECTILE = MakePrototype(Category.PROJECTILE, UT2004Group.BIO_RIFLE,
238                     new String[] { "XWeapons.BioGlob" });
239 
240     /** ShockRifle weapon. */
241     public static final UT2004ItemType SHOCK_RIFLE = MakePrototype(Category.WEAPON, UT2004Group.SHOCK_RIFLE, new String[] {
242                     "XWeapons.ShockRiflePickup", "UTClassic.ClassicShockRiflePickup", "XWeapons.ShockRifle" });
243     /** ShockRifle ammo. */
244     public static final UT2004ItemType SHOCK_RIFLE_AMMO = MakePrototype(Category.AMMO, UT2004Group.SHOCK_RIFLE, new String[] {
245                     "XWeapons.ShockAmmoPickup", "XWeapons.ShockAmmo" });
246 
247     /** ShockRifle projectile. */
248     public static final UT2004ItemType SHOCK_RIFLE_PROJECTILE = MakePrototype(Category.PROJECTILE, UT2004Group.SHOCK_RIFLE,
249                     new String[] { "XWeapons.ShockProjectile" });
250 
251     /** LinkGun weapon. */
252     public static final UT2004ItemType LINK_GUN = MakePrototype(Category.WEAPON, UT2004Group.LINK_GUN, new String[] {
253                     "XWeapons.LinkGunPickup", "XWeapons.LinkGun" });
254     /** LinkGun ammo. */
255     public static final UT2004ItemType LINK_GUN_AMMO = MakePrototype(Category.AMMO, UT2004Group.LINK_GUN, new String[] {
256                     "XWeapons.LinkAmmoPickup", "XWeapons.LinkAmmo" });
257 
258     /** LinkGun projectile. */
259     public static final UT2004ItemType LINK_GUN_PROJECTILE = MakePrototype(Category.PROJECTILE, UT2004Group.LINK_GUN,
260                     new String[] { "XWeapons.LinkProjectile" });
261 
262     /** Minigun weapon. */
263     public static final UT2004ItemType MINIGUN = MakePrototype(Category.WEAPON, UT2004Group.MINIGUN, new String[] {
264                     "XWeapons.MinigunPickup", "UTClassic.ClassicMinigunPickup", "XWeapons.Minigun" });
265     /** Minigun ammo. */
266     public static final UT2004ItemType MINIGUN_AMMO = MakePrototype(Category.AMMO, UT2004Group.MINIGUN, new String[] {
267                     "XWeapons.MinigunAmmoPickup", "XWeapons.MinigunAmmo" });
268 
269     /** FlakCannon weapon. */
270     public static final UT2004ItemType FLAK_CANNON = MakePrototype(Category.WEAPON, UT2004Group.FLAK_CANNON, new String[] {
271                     "XWeapons.FlakCannonPickup", "UTClassic.ClassicFlakCannonPickup", "XWeapons.FlakCannon" });
272     /** FlakCannon ammo. */
273     public static final UT2004ItemType FLAK_CANNON_AMMO = MakePrototype(Category.AMMO, UT2004Group.FLAK_CANNON, new String[] {
274                     "XWeapons.FlakAmmoPickup", "XWeapons.FlakAmmo" });
275 
276     /** FlakCannon chunk projectile. */
277     public static final UT2004ItemType FLAK_CANNON_CHUNK = MakePrototype(Category.PROJECTILE, UT2004Group.FLAK_CANNON,
278                     new String[] { "XWeapons.FlakChunk" });
279 
280     /** FlakCannon shell projectile. */
281     public static final UT2004ItemType FLAK_CANNON_SHELL = MakePrototype(Category.PROJECTILE, UT2004Group.FLAK_CANNON,
282                     new String[] { "XWeapons.FlakShell" });
283 
284     /** RocketLauncher weapon. */
285     public static final UT2004ItemType ROCKET_LAUNCHER = MakePrototype(Category.WEAPON, UT2004Group.ROCKET_LAUNCHER, new String[] {
286                     "XWeapons.RocketLauncherPickup", "UTClassic.ClassicRocketLauncherPickup", "XWeapons.RocketLauncher" });
287     /** RocketLauncher ammo. */
288     public static final UT2004ItemType ROCKET_LAUNCHER_AMMO = MakePrototype(Category.AMMO, UT2004Group.ROCKET_LAUNCHER,
289                     new String[] { "XWeapons.RocketAmmoPickup", "XWeapons.RocketAmmo" });
290 
291     /** RocketLauncher projectile. */
292     public static final UT2004ItemType ROCKET_LAUNCHER_PROJECTILE = MakePrototype(Category.PROJECTILE, UT2004Group.ROCKET_LAUNCHER,
293                     new String[] { "XWeapons.RocketProj" /* Proj is correct */});
294 
295     /** LightningGun weapon (modern sniper weapon). */
296     public static final UT2004ItemType LIGHTNING_GUN = MakePrototype(Category.WEAPON, UT2004Group.LIGHTNING_GUN, new String[] {
297                     "XWeapons.SniperRiflePickup", "XWeapons.SniperRifle" });
298 
299     /** LightningGun ammo. */
300     public static final UT2004ItemType LIGHTNING_GUN_AMMO = MakePrototype(Category.AMMO, UT2004Group.LIGHTNING_GUN, new String[] {
301                     "XWeapons.SniperAmmoPickup", "XWeapons.SniperAmmo" });
302 
303     /** SniperRifle weapon (classic sniper weapon). */
304     public static final UT2004ItemType SNIPER_RIFLE = MakePrototype(Category.WEAPON, UT2004Group.SNIPER_RIFLE,
305                     new String[] { "UTClassic.ClassicSniperRiflePickup" });
306     /** SniperRifle ammo. */
307     public static final UT2004ItemType SNIPER_RIFLE_AMMO = MakePrototype(Category.AMMO, UT2004Group.SNIPER_RIFLE, new String[] {
308                     "UTClassic.ClassicSniperAmmoPickup", "UTClassic.ClassicSniperAmmo" });
309 
310     /** Redeemer weapon. */
311     public static final UT2004ItemType REDEEMER = MakePrototype(Category.WEAPON, UT2004Group.REDEEMER, new String[] {
312                     "XWeapons.RedeemerPickup", "XWeapons.Redeemer" });
313 
314     /** Redeemer ammo. Does not actually exist.*/
315     public static final UT2004ItemType REDEEMER_AMMO = MakePrototype(Category.AMMO, UT2004Group.REDEEMER, new String[] {
316                     "XWeapons.RedeemerAmmo" });
317 
318     /** Redeemer weapon. */
319     public static final UT2004ItemType REDEEMER_PROJECTILE = MakePrototype(Category.PROJECTILE, UT2004Group.REDEEMER,
320                     new String[] { "XWeapons.RedeemerProjectile" });
321 
322     /** SuperShockRifle weapon (instagib weapon). */
323     public static final UT2004ItemType SUPER_SHOCK_RIFLE = MakePrototype(Category.WEAPON, UT2004Group.SUPER_SHOCK_RIFLE,
324                     new String[] { "XWeapons.SuperShockRiflePickup", "XWeapons.SuperShockRifle" });
325 
326     /** IonPainter weapon. */
327     public static final UT2004ItemType ION_PAINTER = MakePrototype(Category.WEAPON, UT2004Group.ION_PAINTER, new String[] {
328                     "XWeapons.PainterPickup", "XWeapons.Painter" });
329     /** IonPainter ammo. Uses BallAmmo odly enough. */
330     public static final UT2004ItemType ION_PAINTER_AMMO = MakePrototype(Category.AMMO, UT2004Group.ION_PAINTER, new String[] {"XWeapons.BallAmmo" });
331 
332     /** MineLayer Onslaught weapon. */
333     public static final UT2004ItemType ONS_MINE_LAYER = MakePrototype(Category.WEAPON, UT2004Group.ONS_MINE_LAYER, new String[] {
334                     "Onslaught.ONSMineLayerPickup", "Onslaught.ONSMineLayer" });
335     /** MineLayer ammo. */
336     public static final UT2004ItemType ONS_MINE_LAYER_AMMO = MakePrototype(Category.AMMO, UT2004Group.ONS_MINE_LAYER, new String[] {
337                     "Onslaught.ONSMineAmmoPickup", "Onslaught.ONSMineAmmo" });
338 
339     /** MineLayer projectile. */
340     public static final UT2004ItemType ONS_MINE_LAYER_PROJECTILE = MakePrototype(Category.PROJECTILE, UT2004Group.ONS_MINE_LAYER,
341                     new String[] { "Onslaught.ONSMineProjectileRED", "Onslaught.ONSMineProjectileBLUE" });
342 
343     /** GrenadeLauncher Onslaught weapon. */
344     public static final UT2004ItemType ONS_GRENADE_LAUNCHER = MakePrototype(Category.WEAPON, UT2004Group.ONS_GRENADE_LAUNCHER,
345                     new String[] { "Onslaught.ONSGrenadePickup", "Onslaught.ONSGrenade" });
346 
347     /** GrenadeLauncher ammo. */
348     public static final UT2004ItemType ONS_GRENADE_LAUNCHER_AMMO = MakePrototype(Category.AMMO, UT2004Group.ONS_GRENADE_LAUNCHER,
349                     new String[] { "Onslaught.ONSGrenadeAmmoPickup" });
350 
351     /** GrenadeLauncher ammo. */
352     public static final UT2004ItemType ONS_GRENADE_LAUNCHER_PROJECTILE = MakePrototype(Category.PROJECTILE, UT2004Group.ONS_GRENADE_LAUNCHER,
353                     new String[] { "Onslaught.ONSGrenadeProjectile" });
354 
355     /** AVRiL Onslaught weapon. */
356     public static final UT2004ItemType ONS_AVRIL = MakePrototype(Category.WEAPON, UT2004Group.ONS_AVRIL, new String[] {
357                     "Onslaught.ONSAVRiLPickup", "Onslaught.ONSAVRiL" });
358     /** AVRiL ammo. */
359     public static final UT2004ItemType ONS_AVRIL_AMMO = MakePrototype(Category.AMMO, UT2004Group.ONS_AVRIL,
360                     new String[] { "Onslaught.ONSAVRiLAmmoPickup" });
361 
362     /** AVRiL projectile.	*/
363     public static final UT2004ItemType ONS_AVRIL_PROJECTILE = MakePrototype(Category.PROJECTILE, UT2004Group.ONS_AVRIL,
364                     new String[] { "Onslaught.ONSAVRiLRocket"});
365 
366     /** TargetPainter Onslaught weapon. */
367     public static final UT2004ItemType ONS_TARGET_PAINTER = MakePrototype(Category.WEAPON, UT2004Group.ONS_TARGET_PAINTER,
368                     new String[] { "OnslaughtFull.ONSPainterPickup", "OnslaughtFull.ONSPainter" });
369 
370     /** Health kit. */
371     public static final UT2004ItemType HEALTH_PACK = MakePrototype(Category.HEALTH, UT2004Group.HEALTH, new String[] {
372                     "XPickups.HealthPack", "XPickups.TournamentHealth" });
373     /** Health vial. */
374     public static final UT2004ItemType MINI_HEALTH_PACK = MakePrototype(Category.HEALTH,UT2004Group.MINI_HEALTH,
375                     new String[] { "XPickups.MiniHealthPack" });
376     /** SuperHealth charger. */
377     public static final UT2004ItemType SUPER_HEALTH_PACK = MakePrototype(Category.HEALTH, UT2004Group.SUPER_HEALTH,
378                     new String[] { "XPickups.SuperHealthPack" });
379 
380     /** SmallShield. */
381     public static final UT2004ItemType SHIELD_PACK = MakePrototype(Category.ARMOR, UT2004Group.SMALL_ARMOR, new String[] {
382                     "XPickups.ShieldPack", "XPickups.ShieldPickup" });
383     /** SuperShield. */
384     public static final UT2004ItemType SUPER_SHIELD_PACK = MakePrototype(Category.ARMOR, UT2004Group.SUPER_ARMOR,
385                     new String[] { "XPickups.SuperShieldPack" });
386 
387     /** UDamage bonus (damage multiplier). */
388     public static final UT2004ItemType U_DAMAGE_PACK = MakePrototype(Category.OTHER, UT2004Group.UDAMAGE, new String[] {
389                     "XPickups.UDamagePack", "XGame.UDamageReward" });
390 
391     /** Adrenaline capsule. */
392     public static final UT2004ItemType ADRENALINE_PACK = MakePrototype(Category.ADRENALINE, UT2004Group.ADRENALINE,
393                     new String[] { "XPickups.AdrenalinePickup" });
394 
395     /** Key. */
396     public static final UT2004ItemType KEY = MakePrototype(Category.OTHER, UT2004Group.KEY, new String[] { "UnrealGame.KeyPickup" });
397 
398     /** No ItemType */
399     public static final UT2004ItemType NONE = MakePrototype(Category.OTHER, UT2004Group.NONE,
400                     new String[] { "None", "NONE", "none" });   
401     
402     /**
403      * Public constructor - creates ItemType of the EXTRA category and Group
404      * OTHER.
405      * 
406      * @param name
407      *            Type name from GB engine.
408      */
409     public UT2004ItemType(String name) {
410         this.name = name;
411         this.category = Category.OTHER;
412         this.group = UT2004Group.OTHER;
413     }
414 
415     /**
416      * Prototypes constructor.
417      */
418     private UT2004ItemType(String name, Category category, UT2004Group group) {
419             this.name = name;
420             this.category = category;
421             this.group = group;
422     }
423     
424     /**
425      * Attempts to recognize the weapon you are currently holding...
426      * <p>
427      * <p>
428      * See {@link Self#getWeapon()}.
429      * <p>
430      * <p>
431      * May return null == weapon was not recognized. ALWAYS CHECK!
432      * 
433      * @return
434      */
435     public static ItemType getWeapon(UnrealId id) {
436         if (id == null)
437                 return null;
438         String str = id.getStringId();
439         if (str.contains("."))
440                 str = str.substring(str.lastIndexOf(".") + 1);
441         str = str.toLowerCase();
442         if (str.equals("assaultrifle"))
443                 return UT2004ItemType.ASSAULT_RIFLE;
444         if (str.equals("shieldgun"))
445                 return UT2004ItemType.SHIELD_GUN;
446         if (str.equals("flakcannon"))
447                 return UT2004ItemType.FLAK_CANNON;
448         if (str.equals("biorifle"))
449                 return UT2004ItemType.BIO_RIFLE;
450         if (str.equals("shockrifle"))
451                 return UT2004ItemType.SHOCK_RIFLE;
452         if (str.equals("linkgun"))
453                 return UT2004ItemType.LINK_GUN;
454         if (str.equals("sniperrifle"))
455                 return UT2004ItemType.SNIPER_RIFLE;
456         if (str.equals("rocketlauncher"))
457                 return UT2004ItemType.ROCKET_LAUNCHER;
458         if (str.equals("minigun"))
459                 return UT2004ItemType.MINIGUN;
460         if (str.equals("lightinggun"))
461                 return UT2004ItemType.LIGHTNING_GUN;
462         if (str.equals("translocator"))
463                 return UT2004ItemType.TRANSLOCATOR;
464         if (str.equals("translauncher"))
465                 return UT2004ItemType.TRANSLOCATOR;
466         if (str.equals("redeemer"))
467                 return UT2004ItemType.REDEEMER;
468         if (str.equals("painter"))
469                 return UT2004ItemType.ION_PAINTER;
470         if (str.equals("classicsniperrifle"))
471             return UT2004ItemType.SNIPER_RIFLE;
472         return null;
473     }
474     
475     /**
476      * Proto-constructor.
477      * 
478      * @param category
479      *            Category of the item.
480      * @param group
481      *            Group of the item.
482      * @param utNames
483      *            Names of the item in UT engine.
484      * @return Prototype of known ItemType.
485      */
486     public static UT2004ItemType MakePrototype(Category category, UT2004Group group, String[] utNames) {
487             UT2004ItemType type;
488             synchronized (protos) {
489                     // create new itemtype prototype
490                     type = new UT2004ItemType(utNames[0], category, group);
491                     // register the itemtype prototype
492                     for (String utName : utNames)
493                             protos.put(utName, type);
494                     // C'est la vie..
495                     if (category != null) {
496                             CATEGORIES.get(category).add(type);
497                     }
498                     if (group != null) {
499                             GROUPS.get(group).add(type);
500                     }
501             }
502             return type;
503     }
504     
505   
506     /**
507      * Name of the item in UT engine.
508      * 
509      * <p>
510      * Note: Items of the same type might have different names in UT engine. Use
511      * {@link #equals(Object)} to safely compare two ItemTypes. This name is
512      * informative only.
513      */
514     protected String name;
515     
516     /**
517      * Retrieves an ItemType for the specified item type name.
518      * 
519      * @param utName
520      *            e.g. Item.getType()
521      * @return
522      */
523     public static ItemType getItemType(String utName) {
524         ItemType type;
525                        
526         synchronized (protos) {                        
527                 type = protos.get(utName);
528                 if (type != null)
529                         return type;
530 
531                 type = new UT2004ItemType(utName);
532                 protos.put(utName, type);
533         }
534         return type;
535     }
536     
537 
538     public String getName() {
539         return name;
540     }
541         
542 }