Guest User

Untitled

a guest
Jul 26th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.48 KB | None | 0 0
  1. public void loadCharacter(Player p) {
  2. try {
  3. PreparedStatement ps = Server.mysql
  4. .getConnection()
  5. .prepareStatement(
  6. "select * from server_saves s left join Forums.vb_user u on s.ForumID = u.userid where u.username = '"
  7. + p.username + "'");
  8. ResultSet rs = ps.executeQuery();
  9. if (rs.next()) {
  10. // p.setUsergroupRights(rs.getInt("u.usergroupid"));
  11. p.isPremium = p.getPremiumRights(rs.getInt("u.usergroupid"),
  12. rs.getString("u.membergroupids"));
  13. p.rights = p.getRights(rs.getInt("u.usergroupid"),
  14. rs.getString("u.membergroupids"));
  15. p.developer = p.getDeveloper(rs.getInt("u.usergroupid"),
  16. rs.getString("u.membergroupids"));
  17. p.password = rs.getString("u.password");
  18. p.salt = rs.getString("u.salt");
  19. p.UserID = rs.getInt("s.ForumID");
  20. p.ForumId = rs.getInt("s.ForumRights");
  21. p.username = rs.getString("s.Username");
  22. if (MysqlIsEnabled) {
  23. p.teleportToX = rs.getInt("s.PosX");
  24. p.teleportToY = rs.getInt("s.PosY");
  25. p.heightLevel = rs.getInt("s.Height");
  26. p.runEnergy = rs.getInt("s.RunEnergy");
  27.  
  28. String[] skill = rs.getString("s.Skills").split(" ");
  29. for (int j = 0; j < (skill.length); j++) {
  30. String[] subValue = skill[j].split(",");
  31. if (subValue.length > 2) {
  32. System.out.println(subValue[0] + " " + subValue[1]
  33. + " " + subValue[2]);
  34. p.skillLvl[j] = Integer.parseInt(subValue[0]);
  35. p.skillXP[j] = Double.parseDouble(subValue[1]);
  36. p.skillTotXP[j] = Integer.parseInt(subValue[2]);
  37. }
  38. }
  39. p.gender = rs.getInt("s.Gender");
  40.  
  41. String[] LookValue = rs.getString("s.Look").split(" ");
  42. for (int j = 0; j < (LookValue.length); j++) {
  43. p.look[j] = Integer.parseInt(LookValue[j]);
  44. }
  45. String[] ColorValue = rs.getString("s.Color").split(" ");
  46. if (ColorValue.length > 1)
  47. for (int j = 0; j < (ColorValue.length); j++) {
  48. p.color[j] = Integer.parseInt(ColorValue[j]);
  49. }
  50.  
  51. p.AttackStyle = rs.getInt("s.AttackStyle");
  52.  
  53. String[] EquiptValue = rs.getString("s.Equipment").split(
  54. " ");
  55. if (EquiptValue.length > 1)
  56. for (int j = 0; j < (EquiptValue.length); j++) {
  57. String[] subValue = EquiptValue[j].split(",");
  58. p.equipment[j] = Integer.parseInt(subValue[0]);
  59. p.equipmentN[j] = Integer.parseInt(subValue[1]);
  60. }
  61.  
  62. String[] Inventory = rs.getString("s.Inventory").split(" ");
  63. if (Inventory.length > 1)
  64. for (int j = 0; j < (Inventory.length); j++) {
  65. String[] subValue = Inventory[j].split(",");
  66. p.items[j] = Integer.parseInt(subValue[0]);
  67. p.itemsN[j] = Integer.parseInt(subValue[1]);
  68. }
  69.  
  70. String[] BankValue = rs.getString("s.BankItems").split(" ");
  71. if (BankValue.length > 1)
  72. for (int j = 0; j < (BankValue.length); j++) {
  73. String[] subValue = BankValue[j].split(",");
  74. p.bankItems[j] = Integer.parseInt(subValue[0]);
  75. p.bankItemsN[j] = Integer.parseInt(subValue[1]);
  76. }
  77. }
  78. } else {
  79. p.newCharacter = true;
  80. p.equipment[3] = 1321;
  81. p.equipmentN[3] = 1;
  82. p.equipment[5] = 1171;
  83. p.equipmentN[5] = 1;
  84. p.items[0] = 1856;
  85. p.itemsN[0] = 1;
  86. p.bankItems[0] = 995;
  87. p.bankItemsN[0] = 1000;
  88. try {
  89. ps = Server.mysql
  90. .getConnection()
  91. .prepareStatement(
  92. "select userid,usergroupid, membergroupids, username, password, salt from Forums.vb_user where username = ?");
  93. ps.setString(1, p.username);
  94. rs = ps.executeQuery();
  95. if (rs.next()) {
  96. p.UserID = rs.getInt("userid");
  97. p.password = rs.getString("password");
  98. p.salt = rs.getString("salt");
  99. int usergroup = rs.getInt("usergroupid");
  100. // String addGroups =
  101. // rs.getString("membergroupids");
  102. p.setUsergroupRights(usergroup);
  103. } else {
  104.  
  105. }
  106. } catch (SQLException e) {
  107. e.printStackTrace();
  108. }
  109. }
  110. } catch (SQLException e1) {
  111. e1.printStackTrace();
  112. }
  113. if (!MysqlIsEnabled) {
  114. stream.inOffset = 0;
  115. try {
  116. FileInputStream in = new FileInputStream(
  117. "./data/characters/mainsave/" + p.username + ".dat");
  118. in.read(stream.inBuffer);
  119. in.close();
  120. in = null;
  121. } catch (Exception e) {
  122. e.printStackTrace();
  123. return;
  124. }
  125. String line;
  126. try {
  127. while ((line = stream.readString()) != null
  128. && line.length() > 0 && !line.equals("null")) {
  129. /*
  130. * if (line.startsWith("rights:")) p.rights =
  131. * Integer.parseInt(line.substring(7)); else
  132. */if (line.startsWith("Style:"))
  133. p.AttackStyle = Integer.parseInt(line.substring(6));
  134. else if (line.startsWith("absx:"))
  135. p.teleportToX = Integer.parseInt(line.substring(5));
  136. else if (line.startsWith("absy:"))
  137. p.teleportToY = Integer.parseInt(line.substring(5));
  138. else if (line.startsWith("height:"))
  139. p.heightLevel = Integer.parseInt(line.substring(7));
  140. else if (line.startsWith("Muted:"))
  141. p.mutedTime = Long.parseLong(line.substring(6));
  142. else if (line.startsWith("Banned:"))
  143. p.bannedTime = Long.parseLong(line.substring(7));
  144. else if (line.startsWith("runenergy:"))
  145. p.runEnergy = Integer.parseInt(line.substring(10));
  146. else if (line.startsWith("friend")) {
  147. long friendName = Long.parseLong(line.substring(line
  148. .indexOf(":") + 1));
  149. p.friends.add(friendName);
  150. } else if (line.startsWith("ignore")) {
  151. long ignoreName = Long.parseLong(line.substring(line
  152. .indexOf(":") + 1));
  153. p.ignores.add(ignoreName);
  154. } else if (line.startsWith("gender:"))
  155. p.gender = Integer.parseInt(line.substring(7));
  156. else if (line.startsWith("look"))
  157. p.look[Integer.parseInt(line.substring(4, 5))] = Integer
  158. .parseInt(line.substring(6));
  159. else if (line.startsWith("color"))
  160. p.color[Integer.parseInt(line.substring(5, 6))] = Integer
  161. .parseInt(line.substring(7));
  162. else if (line.startsWith("skill")) {
  163. p.skillLvl[Integer.parseInt(line.substring(5,
  164. line.indexOf(":")))] = Integer.parseInt(line
  165. .substring(line.indexOf(":") + 1,
  166. line.indexOf(",")));
  167. p.skillXP[Integer.parseInt(line.substring(5,
  168. line.indexOf(":")))] = Double.parseDouble(line
  169. .substring(line.indexOf(",") + 1));
  170. } else if (line.startsWith("equipment")) {
  171. p.equipment[Integer.parseInt(line.substring(9,
  172. line.indexOf(":")))] = Integer.parseInt(line
  173. .substring(line.indexOf(":") + 1,
  174. line.indexOf(",")));
  175. p.equipmentN[Integer.parseInt(line.substring(9,
  176. line.indexOf(":")))] = Integer.parseInt(line
  177. .substring(line.indexOf(",") + 1));
  178. } else if (line.startsWith("item")) {
  179. p.items[Integer.parseInt(line.substring(4,
  180. line.indexOf(":")))] = Integer.parseInt(line
  181. .substring(line.indexOf(":") + 1,
  182. line.indexOf(",")));
  183. p.itemsN[Integer.parseInt(line.substring(4,
  184. line.indexOf(":")))] = Integer.parseInt(line
  185. .substring(line.indexOf(",") + 1));
  186. } else if (line.startsWith("bankitem")) {
  187. p.bankItems[Integer.parseInt(line.substring(8,
  188. line.indexOf(":")))] = Integer.parseInt(line
  189. .substring(line.indexOf(":") + 1,
  190. line.indexOf(",")));
  191. p.bankItemsN[Integer.parseInt(line.substring(8,
  192. line.indexOf(":")))] = Integer.parseInt(line
  193. .substring(line.indexOf(",") + 1));
  194. }
  195. }
  196. } catch (Exception e) {
  197. e.printStackTrace();
  198. }
  199. }
  200. }
Add Comment
Please, Sign In to add comment