package NET.worlds.network; import NET.worlds.console.Console; import java.util.Enumeration; public class sessionInitCmd extends propCmd { public static final byte SESSIONINITCMD = 6; public sessionInitCmd() { this._commandType = 6; } public sessionInitCmd(String user, String pass, String proto, String avatars, String ver) { this._commandType = 6; assert user != null; this._propList.addProperty(new netProperty(2, user)); if (pass != null) { this._propList.addProperty(new netProperty(6, pass)); } this._propList.addProperty(new netProperty(3, proto)); this._propList.addProperty(new netProperty(7, avatars)); this._propList.addProperty(new netProperty(9, ver)); } public sessionInitCmd(OldPropertyList props) { this._commandType = 6; this._propList = props; } @Override void process(WorldServer serv) throws Exception { if (serv.getState() == 8) { for (int i = 0; i < this._propList.size(); i++) { netProperty tmpProp = this._propList.elementAt(i); switch (tmpProp.property()) { case 1: case 3: case 8: case 13: case 15: break; case 2: serv.setUsername(tmpProp.value()); serv.getGalaxy().setNewChatname(null); break; case 4: try { int errorval = Integer.parseInt(tmpProp.value()); if (errorval != 0) { throw new VarErrorException(errorval); } } catch (NumberFormatException var7) { System.err.println("sessionInitCmd: couldn't parse VAR_ERROR = " + tmpProp.value()); } break; case 5: serv.getGalaxy().setChannel(tmpProp.value()); break; case 6: serv.getGalaxy().setPassword(tmpProp.value()); serv.getGalaxy().setNewPassword(null); break; case 7: case 9: case 11: case 12: case 14: case 16: case 17: case 18: case 19: case 20: case 21: default: System.out.println("sessionInitCmd: received unknown property: " + tmpProp.property()); assert false; break; case 10: serv.getGalaxy().setSerialNum(tmpProp.value()); break; case 22: try { int priv = Integer.parseInt(tmpProp.value()); Enumeration list = serv.getGalaxy().getConsoles(); while (list.hasMoreElements()) { Console c = (Console)list.nextElement(); c.setVIP((priv & 8) != 0); c.setFullVIP((priv & 16) != 0); c.setSpecialGuest((priv & 64) != 0); } list = serv.getGalaxy().getConsoles(); while (list.hasMoreElements()) { Console c = (Console)list.nextElement(); c.enableBroadcast((priv & 2) != 0); } } catch (NumberFormatException var8) { } } } if (serv.getVersion() < 18) { serv.setState(9); } else { serv.setState(11); } } } @Override public String toString(WorldServer serv) { return "SESSINIT " + this._propList; } }