Created
October 14, 2016 19:46
-
-
Save bartenbach/cc2acf3f5fea6e236c6b901ea0bef2df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package net.alureon.foundbiome.handler; | |
| import net.alureon.foundbiome.FoundBiome; | |
| import org.bukkit.block.Biome; | |
| import org.bukkit.entity.Player; | |
| import org.json.simple.JSONArray; | |
| import org.json.simple.JSONObject; | |
| import org.json.simple.parser.JSONParser; | |
| import org.json.simple.parser.ParseException; | |
| import java.io.File; | |
| import java.io.FileNotFoundException; | |
| import java.io.FileReader; | |
| import java.io.IOException; | |
| import java.util.ArrayList; | |
| import java.util.HashMap; | |
| import java.util.Iterator; | |
| public class MapHandler { | |
| private final HashMap<Player,ArrayList<Biome>> playerMap = new HashMap<>(); | |
| private FoundBiome fb; | |
| public MapHandler(FoundBiome fb) { | |
| this.fb = fb; | |
| } | |
| public void addToMap(Player player) { | |
| //playerMap.put(player, new ArrayList<Biome>()); | |
| ArrayList<Biome> biomes = new ArrayList<Biome>(); | |
| JSONParser parser = new JSONParser(); | |
| try { | |
| String uuid = player.getUniqueId().toString(); | |
| System.out.println(uuid); | |
| File worldFolder = fb.getServer().getWorld("world").getWorldFolder(); | |
| String statFile = worldFolder.getAbsolutePath() + "\\stats\\" + uuid + ".json"; | |
| System.out.println(statFile); | |
| Object obj = parser.parse(new FileReader(statFile)); | |
| JSONObject jsonObject = (JSONObject) obj; | |
| JSONObject biomeObject = (JSONObject) jsonObject.get("achievement.exploreAllBiomes"); | |
| JSONArray biomeArray = (JSONArray) biomeObject.get("progress"); | |
| for (Object o : biomeArray) { | |
| System.out.println(o.toString()); | |
| Biome biome = (Biome) Biome.valueOf(o.toString()); | |
| biomes.add(biome); | |
| } | |
| } catch (FileNotFoundException ex) { | |
| } catch (ParseException ex) { | |
| } catch (IOException ex) { | |
| } | |
| } | |
| public ArrayList<Biome> getPlayerBiomeList(Player player) { | |
| return playerMap.get(player); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment