Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Spawn Times
- spawntimes = new HashMap<>();
- statement = conn.prepareStatement("SELECT * FROM PIXELMONSPAWNTIMES");
- rs = statement.executeQuery();
- while (rs.next()) spawntimes.put(rs.getInt(1), new SpawnTime(rs.getInt(3), rs.getInt(4), rs.getInt(5)));
- //Totals
- statement = conn.prepareStatement("SELECT PIXELMONID, LOCATION FROM PIXELMONSPAWNLOCATIONS");
- rs = statement.executeQuery();
- spawnlocations = new HashMap<>();
- while(rs.next()) {
- spawnlocations.computeIfAbsent(rs.getInt(1), d -> new HashSet<>()).add(rs.getString(2));
- }
- statement = conn.prepareStatement("SELECT BIOMENAME, PIXELMONID, PIXELMONSPAWNID FROM PIXELMONSPAWNBIOMES");
- rs = statement.executeQuery();
- while (rs.next()) {
- int id = rs.getInt(2);
- String biome = rs.getString(1);
- Integer rarity = Optional.ofNullable(Pokemon.id_list.get(id)).map(p -> p.rarity).orElse(0);
- boolean day = Optional.ofNullable(Pokemon.id_list.get(id)).map(p -> spawntimes.get(p.time)).map(t -> t.day).orElse(0d) != 0;
- boolean night = Optional.ofNullable(Pokemon.id_list.get(id)).map(p -> spawntimes.get(p.time)).map(t -> t.night).orElse(0d) != 0;
- boolean duskdawn = Optional.ofNullable(Pokemon.id_list.get(id)).map(p -> spawntimes.get(p.time)).map(t -> t.duskdawn).orElse(0d) != 0;
- Map<String, Map<String, Integer>> t = rate_total.get(biome);
- if(id == 0) break;
- for(String location : spawnlocations.get(id)) {
- if (day) {
- Map<String, Integer> temp = t.get(location);
- int temp1 = temp.get("day");
- temp1 += rarity;
- t.get(location).put("day", temp1);
- }
- if (night) {
- int temp = t.get(location).get("night") + rarity;
- t.get(location).put("night", temp);
- }
- if (duskdawn) {
- int temp = t.get(location).get("duskdawn") + rarity;
- t.get(location).put("duskdawn", temp);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement