Disconsented

Untitled

Jun 9th, 2014
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.64 KB | None | 0 0
  1. package disconsented.anssrpg.data;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.Map;
  6.  
  7. import net.minecraft.entity.player.EntityPlayer;
  8. import net.minecraftforge.event.entity.EntityJoinWorldEvent;
  9. import net.minecraftforge.event.entity.living.LivingDeathEvent;
  10. import cpw.mods.fml.common.eventhandler.SubscribeEvent;
  11. import disconsented.anssrpg.config.ConfigurationHandler;
  12.  
  13. public class DataSave {
  14.     Map expMap = new HashMap();
  15.     ArrayList perks = new ArrayList();
  16.      @SubscribeEvent
  17.         public void onEntityJoinWorldEvent(EntityJoinWorldEvent event){        
  18.                 if (event.entity instanceof EntityPlayer){
  19.                     System.out.println("Player Respawn detected");
  20.                     PlayerInformation playerInfo = PlayerInformation.get((EntityPlayer) event.entity);
  21.                     for(int i = 0; i < ConfigurationHandler.skillInfo.size();i++ ){
  22.                         if(expMap.get(event.entity.getUniqueID()+ConfigurationHandler.skillInfo.get(i).name) != null ){
  23.                             playerInfo.setXP((Integer) expMap.get(event.entity.getUniqueID()+ConfigurationHandler.skillInfo.get(i).name), ConfigurationHandler.skillInfo.get(i).name);
  24.                         }
  25.                     }
  26.                 }
  27.             }
  28.         @SubscribeEvent
  29.         public void onLivingDeath(LivingDeathEvent event)
  30.         {
  31.             EntityPlayer entityPlayer;
  32.             if (event.entityLiving instanceof EntityPlayer){
  33.                 PlayerInformation playerInfo = PlayerInformation.get((EntityPlayer) event.entity);
  34.                 for(int i = 0; i < ConfigurationHandler.skillInfo.size()-1;i++ ){
  35.                     expMap.put(event.entity.getUniqueID()+ConfigurationHandler.skillInfo.get(i).name, playerInfo.getXP(ConfigurationHandler.skillInfo.get(i).name));
  36.                 }          
  37.             }
  38.         }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment