Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. //Spawn Times
  2.  
  3. spawntimes = new HashMap<>();
  4.  
  5. statement = conn.prepareStatement("SELECT * FROM PIXELMONSPAWNTIMES");
  6. rs = statement.executeQuery();
  7.  
  8. while (rs.next()) spawntimes.put(rs.getInt(1), new SpawnTime(rs.getInt(3), rs.getInt(4), rs.getInt(5)));
  9. //Totals
  10.  
  11. statement = conn.prepareStatement("SELECT PIXELMONID, LOCATION FROM PIXELMONSPAWNLOCATIONS");
  12. rs = statement.executeQuery();
  13.  
  14. spawnlocations = new HashMap<>();
  15.  
  16. while(rs.next()) {
  17. spawnlocations.computeIfAbsent(rs.getInt(1), d -> new HashSet<>()).add(rs.getString(2));
  18. }
  19.  
  20. statement = conn.prepareStatement("SELECT BIOMENAME, PIXELMONID, PIXELMONSPAWNID FROM PIXELMONSPAWNBIOMES");
  21. rs = statement.executeQuery();
  22.  
  23. while (rs.next()) {
  24. int id = rs.getInt(2);
  25. String biome = rs.getString(1);
  26.  
  27. Integer rarity = Optional.ofNullable(Pokemon.id_list.get(id)).map(p -> p.rarity).orElse(0);
  28.  
  29. boolean day = Optional.ofNullable(Pokemon.id_list.get(id)).map(p -> spawntimes.get(p.time)).map(t -> t.day).orElse(0d) != 0;
  30. boolean night = Optional.ofNullable(Pokemon.id_list.get(id)).map(p -> spawntimes.get(p.time)).map(t -> t.night).orElse(0d) != 0;
  31. boolean duskdawn = Optional.ofNullable(Pokemon.id_list.get(id)).map(p -> spawntimes.get(p.time)).map(t -> t.duskdawn).orElse(0d) != 0;
  32.  
  33. Map<String, Map<String, Integer>> t = rate_total.get(biome);
  34.  
  35. if(id == 0) break;
  36.  
  37. for(String location : spawnlocations.get(id)) {
  38. if (day) {
  39. Map<String, Integer> temp = t.get(location);
  40. int temp1 = temp.get("day");
  41. temp1 += rarity;
  42. t.get(location).put("day", temp1);
  43. }
  44. if (night) {
  45. int temp = t.get(location).get("night") + rarity;
  46. t.get(location).put("night", temp);
  47. }
  48. if (duskdawn) {
  49. int temp = t.get(location).get("duskdawn") + rarity;
  50. t.get(location).put("duskdawn", temp);
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement