Пример #1
0
  public void clean() {

    PlayerInventory inv = this.player.getInventory();
    inv.setArmorContents(new ItemStack[4]);
    inv.setContents(new ItemStack[] {});

    this.player.setAllowFlight(false);
    this.player.setFlying(false);
    this.player.setExp(0.0F);
    this.player.setLevel(0);
    this.player.setSneaking(false);
    this.player.setSprinting(false);
    this.player.setFoodLevel(20);
    this.player.setMaxHealth(20.0D);
    this.player.setHealth(20.0D);
    this.player.setFireTicks(0);
    this.player.setGameMode(GameMode.SURVIVAL);

    boolean teamnameOnTab = Main.getInstance().getBooleanConfig("teamname-on-tab", true);
    boolean overwriteNames = Main.getInstance().getBooleanConfig("overwrite-names", false);
    if (overwriteNames) {
      Game game = Main.getInstance().getGameManager().getGameOfPlayer(this.player);
      if (game != null) {
        Team team = game.getPlayerTeam(this.player);
        if (team != null) {
          this.player.setDisplayName(team.getChatColor() + this.player.getName());
        } else {
          this.player.setDisplayName(this.player.getName());
        }
      }
    }

    if (teamnameOnTab && Utils.isSupportingTitles()) {
      Game game = Main.getInstance().getGameManager().getGameOfPlayer(this.player);
      if (game != null) {
        Team team = game.getPlayerTeam(this.player);
        if (team != null) {
          this.player.setPlayerListName(
              team.getChatColor()
                  + team.getName()
                  + ChatColor.WHITE
                  + " | "
                  + team.getChatColor()
                  + this.player.getName());
        } else {
          this.player.setPlayerListName(this.player.getName());
        }
      }
    }

    if (this.player.isInsideVehicle()) {
      this.player.leaveVehicle();
    }

    for (PotionEffect e : this.player.getActivePotionEffects()) {
      this.player.removePotionEffect(e.getType());
    }

    this.player.updateInventory();
  }
Пример #2
0
  public static void setContentsArmor(Inventory inventory, ItemStack[] armor) {
    PlayerInventory playerInventory = asPlayerInventory(inventory);
    if (playerInventory == null) return;

    playerInventory.setArmorContents(armor);
  }