Exemple #1
0
  @Override
  public void handlePacket(int index, Player pl, DataInputStream dataStream) throws IOException {
    int pokemonID = dataStream.readInt();
    int removeIndex = dataStream.readInt();

    EntityPlayerMP player = (EntityPlayerMP) pl;
    PlayerStorage storage = PixelmonStorage.PokeballManager.getPlayerStorage(player);
    EntityPixelmon p;
    if (storage.EntityAlreadyExists(pokemonID, player.worldObj))
      p = storage.getAlreadyExists(pokemonID, player.worldObj);
    else p = storage.sendOut(pokemonID, player.worldObj);
    ChatHandler.sendChat(
        player, "Your " + p.getName() + " forgot " + p.moveset.get(removeIndex).attackName + "!");
    p.moveset.remove(removeIndex);
    storage.updateNBT(p);
  }
 @SuppressWarnings("unchecked")
 public void loadPlayer(EntityPlayerMP player) {
   File saveDirPath = new File(getSaveFolder(player));
   if (!saveDirPath.exists()) saveDirPath.mkdirs();
   File playerFile = new File(getSaveFolder(player) + player.username + ".pk");
   if (playerFile.exists()) {
     PlayerStorage p = new PlayerStorage(player);
     try {
       p.readFromNBT(
           CompressedStreamTools.read(new DataInputStream(new FileInputStream(playerFile))));
     } catch (FileNotFoundException e) {
       System.out.println("Couldn't read player data file for " + player.username);
     } catch (IOException e) {
       System.out.println("Couldn't read player data file for " + player.username);
     }
     playerPokemonList.add(p);
   } else {
     PlayerStorage p = new PlayerStorage(player);
     playerPokemonList.add(p);
   }
 }