Package com.tommytony.war.utility

Examples of com.tommytony.war.utility.PlayerState


      playerTitle = SpoutManager.getPlayer(player).getTitle();
    }
   
    this.playerStates.put(
        player.getName(),
        new PlayerState(player.getGameMode(), contents, inventory
            .getHelmet(), inventory.getChestplate(), inventory
            .getLeggings(), inventory.getBoots(), player
            .getHealth(), player.getExhaustion(), player
            .getSaturation(), player.getFoodLevel(), player
            .getActivePotionEffects(), playerTitle, player
View Full Code Here


            .getActivePotionEffects(), playerTitle, player
            .getLevel(), player.getExp(), player.getAllowFlight()));
  }

  public void restorePlayerState(Player player) {
    PlayerState originalState = this.playerStates.remove(player.getName());
    PlayerInventory playerInv = player.getInventory();
    if (originalState != null) {
      // prevent item hacking thru CRAFTING personal inventory slots
      this.preventItemHackingThroughOpenedInventory(player);
     
      this.playerInvFromInventoryStash(playerInv, originalState);
      player.setGameMode(originalState.getGamemode());
      player.setHealth(Math.max(Math.min(originalState.getHealth(), 20.0D), 0.0D));
      player.setExhaustion(originalState.getExhaustion());
      player.setSaturation(originalState.getSaturation());
      player.setFoodLevel(originalState.getFoodLevel());
      PotionEffectHelper.restorePotionEffects(player, originalState.getPotionEffects());
      player.setLevel(originalState.getLevel());
      player.setExp(originalState.getExp());
      player.setAllowFlight(originalState.canFly());
     
      if (War.war.isSpoutServer()) {
        SpoutManager.getPlayer(player).setTitle(originalState.getPlayerTitle());
      }
    }
    player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
  }
View Full Code Here

    }
  }

  private HashMap<Integer, ItemStack> getPlayerInventoryFromSavedState(Player player) {
    HashMap<Integer, ItemStack> playerItems = new HashMap<Integer, ItemStack>();
    PlayerState originalState = this.playerStates.get(player.getName());

    if (originalState != null) {
      int invIndex = 0;
      playerItems = new HashMap<Integer, ItemStack>();
      for (ItemStack item : originalState.getContents()) {
        if (item != null && item.getType() != Material.AIR) {
          playerItems.put(invIndex, item);
        }
        invIndex++;
      }
      if (originalState.getFeet() != null) {
        playerItems.put(100, originalState.getFeet());
      }
      if (originalState.getLegs() != null) {
        playerItems.put(101, originalState.getLegs());
      }
      if (originalState.getChest() != null) {
        playerItems.put(102, originalState.getChest());
      }
      if (originalState.getHelmet() != null) {
        playerItems.put(103, originalState.getHelmet());
      }
     
      if (War.war.isSpoutServer()) {
        SpoutManager.getPlayer(player).setTitle(originalState.getPlayerTitle());
      }
    }
   
    return playerItems;
  }
View Full Code Here

TOP

Related Classes of com.tommytony.war.utility.PlayerState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.