From: Hendrik <nh...@us...> - 2007-01-07 05:06:44
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/player In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv8546/src/games/stendhal/server/entity/player Modified Files: Player.java PlayerRPClass.java Log Message: moved method readAdminsFromFile from Player to PlayerRPClass Index: Player.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/player/Player.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Player.java 7 Jan 2007 05:01:58 -0000 1.7 --- Player.java 7 Jan 2007 05:06:43 -0000 1.8 *************** *** 100,106 **** Player player = new Player(object); - // Port from 0.48 to 0.50 - player.readAdminsFromFile(); - player.stop(); player.stopAttack(); --- 100,103 ---- *************** *** 108,111 **** --- 105,109 ---- StendhalQuestSystem.get().onPlayerLogin(player); + PlayerRPClass.readAdminsFromFile(player); PlayerRPClass.placePlayerIntoWorldOnLogin(object, player); PlayerRPClass.loadItemsIntoSlots(player); *************** *** 240,284 **** } - private static List<String> adminNames; - - private void readAdminsFromFile() { - if (adminNames == null) { - adminNames = new LinkedList<String>(); - - String adminFilename="data/conf/admins.list"; - - try { - InputStream is = getClass().getClassLoader() - .getResourceAsStream(adminFilename); - - if (is == null) { - logger.info("data/conf/admins.list does not exist."); - } else { - - BufferedReader in = new BufferedReader( - new InputStreamReader(is)); - - String line; - while ((line = in.readLine()) != null) { - adminNames.add(line); - } - in.close(); - } - } catch (Exception e) { - logger.error("Error loading admin names from: "+adminFilename, e); - } - } - - boolean isAdmin = adminNames.contains(getName()); - - if (isAdmin) { - put("adminlevel", AdministrationAction.REQUIRED_ADMIN_LEVEL_FOR_SUPER); - } else { - if (!has("adminlevel")) { - put("adminlevel", "0"); - } - } - } - /** * Returns the admin level of this user. See AdministrationAction.java for details. --- 238,241 ---- Index: PlayerRPClass.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/player/PlayerRPClass.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PlayerRPClass.java 7 Jan 2007 05:01:58 -0000 1.6 --- PlayerRPClass.java 7 Jan 2007 05:06:43 -0000 1.7 *************** *** 13,16 **** --- 13,19 ---- package games.stendhal.server.entity.player; + import java.io.BufferedReader; + import java.io.InputStream; + import java.io.InputStreamReader; import java.util.LinkedList; import java.util.List; *************** *** 20,23 **** --- 23,27 ---- import games.stendhal.server.StendhalRPWorld; import games.stendhal.server.StendhalRPZone; + import games.stendhal.server.actions.AdministrationAction; import games.stendhal.server.entity.creature.Sheep; import games.stendhal.server.entity.item.Item; *************** *** 37,40 **** --- 41,48 ---- private static Logger logger = Logger.getLogger(PlayerRPClass.class); + /** list of super admins read from admins.list */ + private static List<String> adminNames = null; + + /** * Generates the RPClass and specifies slots and attributes. *************** *** 150,153 **** --- 158,208 ---- /** + * reads the admins from admins.list + * + * @param player Player to check for super admin status. + */ + static void readAdminsFromFile(Player player) { + if (adminNames == null) { + adminNames = new LinkedList<String>(); + + String adminFilename="data/conf/admins.list"; + + try { + InputStream is = player.getClass().getClassLoader() + .getResourceAsStream(adminFilename); + + if (is == null) { + logger.info("data/conf/admins.list does not exist."); + } else { + + BufferedReader in = new BufferedReader( + new InputStreamReader(is)); + try { + String line; + while ((line = in.readLine()) != null) { + adminNames.add(line); + } + } catch (Exception e) { + logger.error("Error loading admin names from: "+adminFilename, e); + } + in.close(); + } + } catch (Exception e) { + logger.error("Error loading admin names from: "+adminFilename, e); + } + } + + boolean isAdmin = adminNames.contains(player.getName()); + + if (isAdmin) { + player.put("adminlevel", AdministrationAction.REQUIRED_ADMIN_LEVEL_FOR_SUPER); + } else { + if (!player.has("adminlevel")) { + player.put("adminlevel", "0"); + } + } + } + + /** * Places the player (and his/her sheep if there is one) into the world on login * |