Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void loadCharacter(Player p) {
- try {
- PreparedStatement ps = Server.mysql
- .getConnection()
- .prepareStatement(
- "select * from server_saves s left join Forums.vb_user u on s.ForumID = u.userid where u.username = '"
- + p.username + "'");
- ResultSet rs = ps.executeQuery();
- if (rs.next()) {
- // p.setUsergroupRights(rs.getInt("u.usergroupid"));
- p.isPremium = p.getPremiumRights(rs.getInt("u.usergroupid"),
- rs.getString("u.membergroupids"));
- p.rights = p.getRights(rs.getInt("u.usergroupid"),
- rs.getString("u.membergroupids"));
- p.developer = p.getDeveloper(rs.getInt("u.usergroupid"),
- rs.getString("u.membergroupids"));
- p.password = rs.getString("u.password");
- p.salt = rs.getString("u.salt");
- p.UserID = rs.getInt("s.ForumID");
- p.ForumId = rs.getInt("s.ForumRights");
- p.username = rs.getString("s.Username");
- if (MysqlIsEnabled) {
- p.teleportToX = rs.getInt("s.PosX");
- p.teleportToY = rs.getInt("s.PosY");
- p.heightLevel = rs.getInt("s.Height");
- p.runEnergy = rs.getInt("s.RunEnergy");
- String[] skill = rs.getString("s.Skills").split(" ");
- for (int j = 0; j < (skill.length); j++) {
- String[] subValue = skill[j].split(",");
- if (subValue.length > 2) {
- System.out.println(subValue[0] + " " + subValue[1]
- + " " + subValue[2]);
- p.skillLvl[j] = Integer.parseInt(subValue[0]);
- p.skillXP[j] = Double.parseDouble(subValue[1]);
- p.skillTotXP[j] = Integer.parseInt(subValue[2]);
- }
- }
- p.gender = rs.getInt("s.Gender");
- String[] LookValue = rs.getString("s.Look").split(" ");
- for (int j = 0; j < (LookValue.length); j++) {
- p.look[j] = Integer.parseInt(LookValue[j]);
- }
- String[] ColorValue = rs.getString("s.Color").split(" ");
- if (ColorValue.length > 1)
- for (int j = 0; j < (ColorValue.length); j++) {
- p.color[j] = Integer.parseInt(ColorValue[j]);
- }
- p.AttackStyle = rs.getInt("s.AttackStyle");
- String[] EquiptValue = rs.getString("s.Equipment").split(
- " ");
- if (EquiptValue.length > 1)
- for (int j = 0; j < (EquiptValue.length); j++) {
- String[] subValue = EquiptValue[j].split(",");
- p.equipment[j] = Integer.parseInt(subValue[0]);
- p.equipmentN[j] = Integer.parseInt(subValue[1]);
- }
- String[] Inventory = rs.getString("s.Inventory").split(" ");
- if (Inventory.length > 1)
- for (int j = 0; j < (Inventory.length); j++) {
- String[] subValue = Inventory[j].split(",");
- p.items[j] = Integer.parseInt(subValue[0]);
- p.itemsN[j] = Integer.parseInt(subValue[1]);
- }
- String[] BankValue = rs.getString("s.BankItems").split(" ");
- if (BankValue.length > 1)
- for (int j = 0; j < (BankValue.length); j++) {
- String[] subValue = BankValue[j].split(",");
- p.bankItems[j] = Integer.parseInt(subValue[0]);
- p.bankItemsN[j] = Integer.parseInt(subValue[1]);
- }
- }
- } else {
- p.newCharacter = true;
- p.equipment[3] = 1321;
- p.equipmentN[3] = 1;
- p.equipment[5] = 1171;
- p.equipmentN[5] = 1;
- p.items[0] = 1856;
- p.itemsN[0] = 1;
- p.bankItems[0] = 995;
- p.bankItemsN[0] = 1000;
- try {
- ps = Server.mysql
- .getConnection()
- .prepareStatement(
- "select userid,usergroupid, membergroupids, username, password, salt from Forums.vb_user where username = ?");
- ps.setString(1, p.username);
- rs = ps.executeQuery();
- if (rs.next()) {
- p.UserID = rs.getInt("userid");
- p.password = rs.getString("password");
- p.salt = rs.getString("salt");
- int usergroup = rs.getInt("usergroupid");
- // String addGroups =
- // rs.getString("membergroupids");
- p.setUsergroupRights(usergroup);
- } else {
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- if (!MysqlIsEnabled) {
- stream.inOffset = 0;
- try {
- FileInputStream in = new FileInputStream(
- "./data/characters/mainsave/" + p.username + ".dat");
- in.read(stream.inBuffer);
- in.close();
- in = null;
- } catch (Exception e) {
- e.printStackTrace();
- return;
- }
- String line;
- try {
- while ((line = stream.readString()) != null
- && line.length() > 0 && !line.equals("null")) {
- /*
- * if (line.startsWith("rights:")) p.rights =
- * Integer.parseInt(line.substring(7)); else
- */if (line.startsWith("Style:"))
- p.AttackStyle = Integer.parseInt(line.substring(6));
- else if (line.startsWith("absx:"))
- p.teleportToX = Integer.parseInt(line.substring(5));
- else if (line.startsWith("absy:"))
- p.teleportToY = Integer.parseInt(line.substring(5));
- else if (line.startsWith("height:"))
- p.heightLevel = Integer.parseInt(line.substring(7));
- else if (line.startsWith("Muted:"))
- p.mutedTime = Long.parseLong(line.substring(6));
- else if (line.startsWith("Banned:"))
- p.bannedTime = Long.parseLong(line.substring(7));
- else if (line.startsWith("runenergy:"))
- p.runEnergy = Integer.parseInt(line.substring(10));
- else if (line.startsWith("friend")) {
- long friendName = Long.parseLong(line.substring(line
- .indexOf(":") + 1));
- p.friends.add(friendName);
- } else if (line.startsWith("ignore")) {
- long ignoreName = Long.parseLong(line.substring(line
- .indexOf(":") + 1));
- p.ignores.add(ignoreName);
- } else if (line.startsWith("gender:"))
- p.gender = Integer.parseInt(line.substring(7));
- else if (line.startsWith("look"))
- p.look[Integer.parseInt(line.substring(4, 5))] = Integer
- .parseInt(line.substring(6));
- else if (line.startsWith("color"))
- p.color[Integer.parseInt(line.substring(5, 6))] = Integer
- .parseInt(line.substring(7));
- else if (line.startsWith("skill")) {
- p.skillLvl[Integer.parseInt(line.substring(5,
- line.indexOf(":")))] = Integer.parseInt(line
- .substring(line.indexOf(":") + 1,
- line.indexOf(",")));
- p.skillXP[Integer.parseInt(line.substring(5,
- line.indexOf(":")))] = Double.parseDouble(line
- .substring(line.indexOf(",") + 1));
- } else if (line.startsWith("equipment")) {
- p.equipment[Integer.parseInt(line.substring(9,
- line.indexOf(":")))] = Integer.parseInt(line
- .substring(line.indexOf(":") + 1,
- line.indexOf(",")));
- p.equipmentN[Integer.parseInt(line.substring(9,
- line.indexOf(":")))] = Integer.parseInt(line
- .substring(line.indexOf(",") + 1));
- } else if (line.startsWith("item")) {
- p.items[Integer.parseInt(line.substring(4,
- line.indexOf(":")))] = Integer.parseInt(line
- .substring(line.indexOf(":") + 1,
- line.indexOf(",")));
- p.itemsN[Integer.parseInt(line.substring(4,
- line.indexOf(":")))] = Integer.parseInt(line
- .substring(line.indexOf(",") + 1));
- } else if (line.startsWith("bankitem")) {
- p.bankItems[Integer.parseInt(line.substring(8,
- line.indexOf(":")))] = Integer.parseInt(line
- .substring(line.indexOf(":") + 1,
- line.indexOf(",")));
- p.bankItemsN[Integer.parseInt(line.substring(8,
- line.indexOf(":")))] = Integer.parseInt(line
- .substring(line.indexOf(",") + 1));
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment