Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SuppressWarnings("unchecked")
- @Override
- public void onEnable(){
- File f = new File(this.getDataFolder() + "/database/" + "data.hashmap");
- map = HashBiMap.create();
- if(!f.exists()){
- System.out.println("Hashmap not found, creating a new one");
- map = HashBiMap.create();
- }else{
- try{
- System.out.println("Hashmap found, loading...");
- FileInputStream fileIn = new FileInputStream(this.getDataFolder() + "/database/" + "data.hashmap");
- ObjectInputStream in = new ObjectInputStream(fileIn);
- map = (HashBiMap<String, BlockVector>) in.readObject();
- in.close();
- fileIn.close();
- }catch (Exception e){
- e.printStackTrace();
- }
- }
- getServer().getPluginManager().registerEvents(this, this);
- }
- @Override
- public void onDisable(){
- try{
- System.out.println("Saving hashmap...");
- FileOutputStream fileOut = new
- FileOutputStream(this.getDataFolder() + "/database/" +
- "data.hashmap");
- ObjectOutputStream out = new ObjectOutputStream(fileOut);
- out.writeObject(map);
- out.flush();
- out.close();
- fileOut.flush();
- fileOut.close();
- }catch (Exception e){
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement