[jetrix-cvs] jetrix/src/java/net/jetrix/config Special.java,1.4,1.5
Brought to you by:
smanux
From: Emmanuel B. <sm...@us...> - 2005-05-10 02:13:09
|
Update of /cvsroot/jetrix/jetrix/src/java/net/jetrix/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31680 Modified Files: Special.java Log Message: Added valueOf(char) abd changed the type of the letter (String -> char) Index: Special.java =================================================================== RCS file: /cvsroot/jetrix/jetrix/src/java/net/jetrix/config/Special.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Special.java 5 Jan 2005 17:16:02 -0000 1.4 --- Special.java 10 May 2005 02:13:01 -0000 1.5 *************** *** 1,5 **** /** * Jetrix TetriNET Server ! * Copyright (C) 2004 Emmanuel Bourg * * This program is free software; you can redistribute it and/or --- 1,5 ---- /** * Jetrix TetriNET Server ! * Copyright (C) 2004-2005 Emmanuel Bourg * * This program is free software; you can redistribute it and/or *************** *** 34,52 **** public enum Special { ! ADDLINE(0, "a", "addline"), ! CLEARLINE(1, "c", "clearline"), ! NUKEFIELD(2, "n", "nukefield"), ! RANDOMCLEAR(3, "r", "randomclear"), ! SWITCHFIELD(4, "s", "switchfield"), ! CLEARSPECIAL(5, "b", "clearspecial"), ! GRAVITY(6, "g", "gravity"), ! QUAKEFIELD(7, "q", "quakefield"), ! BLOCKBOMB(8, "o", "blockbomb"); private int value; ! private String letter; private String code; ! Special(int value, String letter, String code) { this.value = value; --- 34,52 ---- public enum Special { ! ADDLINE(0, 'a', "addline"), ! CLEARLINE(1, 'c', "clearline"), ! NUKEFIELD(2, 'n', "nukefield"), ! RANDOMCLEAR(3, 'r', "randomclear"), ! SWITCHFIELD(4, 's', "switchfield"), ! CLEARSPECIAL(5, 'b', "clearspecial"), ! GRAVITY(6, 'g', "gravity"), ! QUAKEFIELD(7, 'q', "quakefield"), ! BLOCKBOMB(8, 'o', "blockbomb"); private int value; ! private final char letter; private String code; ! Special(int value, char letter, String code) { this.value = value; *************** *** 60,64 **** } ! public String getLetter() { return letter; --- 60,64 ---- } ! public char getLetter() { return letter; *************** *** 74,76 **** --- 74,95 ---- return Language.getText("command.config.specials." + code, locale); } + + /** + * Return the special matching the specified letter. + * + * @param letter the letter of the special + * @since 0.3 + */ + public static Special valueOf(char letter) + { + for (Special special : values()) + { + if (special.getLetter() == letter) + { + return special; + } + } + + return null; + } } |