Exemple #1
0
  private boolean hasFireResistance(Player player) {
    for (PotionEffect pe : player.getActivePotionEffects()) {
      if (pe.getType().equals(PotionEffectType.FIRE_RESISTANCE)) return true;
    }

    return false;
  }
  public PlayerState(final Player player) {
    name = player.getName();
    debug.i("creating PlayerState of " + name, player);

    fireticks = player.getFireTicks();
    foodlevel = player.getFoodLevel();
    gamemode = player.getGameMode().getValue();
    health = player.getHealth();
    maxhealth = player.getMaxHealth();

    exhaustion = player.getExhaustion();
    experience = player.getExp();
    explevel = player.getLevel();
    saturation = player.getSaturation();

    potionEffects = player.getActivePotionEffects();

    flying = player.isFlying();

    final ArenaPlayer aPlayer = ArenaPlayer.parsePlayer(player.getName());
    final Arena arena = aPlayer.getArena();

    if (arena.getArenaConfig().getBoolean(CFG.CHAT_COLORNICK)) {
      displayname = player.getDisplayName();
    }

    fullReset(arena, player);
    final int time = arena.getArenaConfig().getInt(CFG.GENERAL_TIME);
    if (time != -1) {
      player.setPlayerTime(time, false);
    }
  }
  @EventHandler
  public void onPlayerDeath(PlayerDiedEvent event) {
    if (event.getGame() != this.game) return;

    Player player = event.getPlayer();

    if (deadPlayers.containsKey(player)) return;

    DeadPlayer deadPlayer = new DeadPlayer(player, this.game);
    deadPlayers.put(player, deadPlayer);
    deadPlayer.spawn();

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

    game.broadcast(ChatColor.BOLD.toString() + ChatColor.DARK_RED + event.getDeathMessage());

    for (Player p : game.getPlayers()) {
      plugin.sendActionbarMessage(
          p,
          ChatColor.YELLOW.toString()
              + ChatColor.BOLD.toString()
              + player.getName()
              + " has been downed! Go revive them!");
    }

    if (deadPlayers.size() == game.getPlayers().size()) safelyEndGame();
  }
  @EventHandler(priority = EventPriority.NORMAL)
  public void onPlayerDamage(EntityDamageByEntityEvent evt) {
    if (evt.getDamager() instanceof Player) {
      Player p = (Player) evt.getDamager();

      if (p.hasPotionEffect(PotionEffectType.INCREASE_DAMAGE)) {
        for (PotionEffect eff : p.getActivePotionEffects()) {
          if (eff.getType().equals(PotionEffectType.INCREASE_DAMAGE)) {
            double div = (eff.getAmplifier() + 1) * 1.3D + 1.0D;
            int dmg;

            if (evt.getDamage() / div <= 1.0D) {
              dmg = (eff.getAmplifier() + 1) * 3 + 1;
            } else {
              double flatdmg = 2.0;
              dmg = (int) (evt.getDamage() / div) + (int) ((eff.getAmplifier() + 1) * flatdmg);
            }

            evt.setDamage(dmg);
            break;
          }
        }
      }
    }
  }
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    boolean hasarg = false;
    Player p = null;
    if (args.length == 1) {
      hasarg = true;
      p = this.getServer().getPlayer(args[0]);
    }

    if (sender instanceof Player) {
      if (!((Player) sender).hasPermission("command.rmeffect")) {
        sender.sendMessage("You can't use this command.");
        return true;
      }
    }
    for (Player player : this.getServer().getOnlinePlayers()) {
      for (PotionEffect effect : player.getActivePotionEffects()) {
        if (hasarg && p != null) {
          p.removePotionEffect(effect.getType());
        } else {
          player.removePotionEffect(effect.getType());
        }
      }
    }
    getServer().dispatchCommand(sender, "effect night_vision all");
    sender.sendMessage("Effects removed.");

    return true;
  }
  public static void restoreInventory(Player player) {
    player.getInventory().clear();
    player.teleport((Location) locations.get(player.getName()));
    for (PotionEffect effect : player.getActivePotionEffects()) {
      player.removePotionEffect(effect.getType());
    }
    player.getInventory().setContents((ItemStack[]) inventoryContents.get(player.getName()));
    player.getInventory().setArmorContents((ItemStack[]) armourContents.get(player.getName()));
    player.setExp(((Float) xp.get(player.getName())).floatValue());
    player.setLevel(((Integer) xpLevel.get(player.getName())).intValue());
    player.setGameMode((GameMode) gameModes.get(player.getName()));
    player.addPotionEffects((Collection<PotionEffect>) potions.get(player.getName()));
    player.setFoodLevel(((Integer) foodLevel.get(player.getName())).intValue());
    player.setHealth(((Double) Health.get(player.getName())).doubleValue());
    player.setAllowFlight(((Boolean) flight.get(player.getName())).booleanValue());

    flight.remove(player.getName());
    Health.remove(player.getName());
    foodLevel.remove(player.getName());
    potions.remove(player.getName());
    xpLevel.remove(player.getName());
    xp.remove(player.getName());
    locations.remove(player.getName());
    armourContents.remove(player.getName());
    inventoryContents.remove(player.getName());
    gameModes.remove(player.getName());
  }
Exemple #7
0
 public static void resetPlayer(Player player) {
   player.setHealth(player.getMaxHealth());
   player.setFoodLevel(20);
   player.setSaturation(20);
   player.getInventory().clear();
   player
       .getInventory()
       .setArmorContents(
           new ItemStack[] {
             new ItemStack(Material.AIR),
             new ItemStack(Material.AIR),
             new ItemStack(Material.AIR),
             new ItemStack(Material.AIR)
           });
   for (PotionEffect effect : player.getActivePotionEffects()) {
     try {
       player.removePotionEffect(effect.getType());
     } catch (NullPointerException ignored) {
     }
   }
   player.setTotalExperience(0);
   player.setExp(0);
   player.setPotionParticles(true);
   player.setWalkSpeed(0.2F);
   player.setFlySpeed(0.2F);
 }
 private void join(String player) {
   if (p1.equals(player)) {
     Bukkit.broadcastMessage(
         ChatColor.LIGHT_PURPLE + "[BattleReverie] " + ChatColor.GOLD + player + " joins!");
     Player p = Bukkit.getPlayer(p1);
     p.teleport(new Location(Bukkit.getWorld(getName()), 14, 72, 0, 269.9F, 0.8F));
     for (PotionEffect po : p.getActivePotionEffects()) {
       p.removePotionEffect(po.getType());
     }
     p.setHealth(20);
     p.setFoodLevel(20);
     handKit(p);
   } else if (p2.equals(player)) {
     Bukkit.broadcastMessage(
         ChatColor.LIGHT_PURPLE + "[BattleReverie] " + ChatColor.GOLD + player + " joins!");
     Player p = Bukkit.getPlayer(p2);
     p.teleport(new Location(Bukkit.getWorld(getName()), 0, 72, 14, 0.7F, 0.1F));
     for (PotionEffect po : p.getActivePotionEffects()) {
       p.removePotionEffect(po.getType());
     }
     p.setHealth(20);
     p.setFoodLevel(20);
     handKit(p);
   } else if (p3.equals(player)) {
     Bukkit.broadcastMessage(
         ChatColor.LIGHT_PURPLE + "[BattleReverie] " + ChatColor.GOLD + player + " joins!");
     Player p = Bukkit.getPlayer(p3);
     p.teleport(new Location(Bukkit.getWorld(getName()), -14, 72, 0, 89.7F, 0.1F));
     for (PotionEffect po : p.getActivePotionEffects()) {
       p.removePotionEffect(po.getType());
     }
     p.setHealth(20);
     p.setFoodLevel(20);
     handKit(p);
   } else if (p4.equals(player)) {
     Bukkit.broadcastMessage(
         ChatColor.LIGHT_PURPLE + "[BattleReverie] " + ChatColor.GOLD + player + " joins!");
     Player p = Bukkit.getPlayer(p4);
     p.teleport(new Location(Bukkit.getWorld(getName()), 0, 72, -14, 178.6F, 2.3F));
     for (PotionEffect po : p.getActivePotionEffects()) {
       p.removePotionEffect(po.getType());
     }
     p.setHealth(20);
     p.setFoodLevel(20);
     handKit(p);
   }
 }
Exemple #9
0
 @EventHandler
 public void onJoin(PlayerJoinEvent e) {
   Player p = e.getPlayer();
   cInv.createPotionGUI();
   for (PotionEffect effect : p.getActivePotionEffects()) {
     p.removePotionEffect(effect.getType());
   }
 }
Exemple #10
0
  /**
   * Clears the player's inventory and removes any active potion effects.
   *
   * @param player
   */
  public void clear(Player player) {
    player.getInventory().clear();
    player.getInventory().setArmorContents(null);

    for (PotionEffect pot : player.getActivePotionEffects()) {
      player.removePotionEffect(pot.getType());
    }
  }
	@SuppressWarnings("deprecation")
	public void saveState() {
		bukkitPlayer.setGameMode(GameMode.SURVIVAL);//Set to survival
		
		//Define player states variables
		ItemStack[] contents = bukkitPlayer.getInventory().getContents();
		
		ItemStack helmet = bukkitPlayer.getInventory().getHelmet();
		ItemStack chestplate = bukkitPlayer.getInventory().getChestplate();
		ItemStack leggings = bukkitPlayer.getInventory().getLeggings();
		ItemStack boots = bukkitPlayer.getInventory().getBoots();
		
		float exhaustion = bukkitPlayer.getExhaustion();
		float saturation = bukkitPlayer.getSaturation();
		
		int foodLevel = bukkitPlayer.getFoodLevel();
		double health = bukkitPlayer.getHealth();
		
		GameMode gm = bukkitPlayer.getGameMode();
		Collection<PotionEffect> potionEffects = bukkitPlayer.getActivePotionEffects();
		
		float exp = bukkitPlayer.getExp();
		int level = bukkitPlayer.getLevel();
		
		boolean fly = bukkitPlayer.getAllowFlight();
		
		//Save state
		state = new PlayerState(contents, helmet, chestplate, leggings, boots, exhaustion, saturation, foodLevel, health, gm, potionEffects, exp, level, fly);
		
		//Set to default state
		bukkitPlayer.setFoodLevel(20);
		bukkitPlayer.setHealth(20.0);
		bukkitPlayer.setAllowFlight(false);//Disable fly mode (Essentials etc.)
		bukkitPlayer.setFireTicks(0);
		bukkitPlayer.getInventory().clear();
		bukkitPlayer.getInventory().setArmorContents(new ItemStack[4]);
		bukkitPlayer.setLevel(0);
		bukkitPlayer.setExp(0);
		
		for (PotionEffect effect : bukkitPlayer.getActivePotionEffects()) {
			bukkitPlayer.removePotionEffect(effect.getType());
		}
		
		bukkitPlayer.sendMessage(I18N._("stateSaved"));
		bukkitPlayer.updateInventory();
	}
Exemple #12
0
 private void writeConfig(MovingVan van, Player p, String name, String perm) {
   ArrayList<String> tmpList = new ArrayList<String>();
   for (ItemStack is : Arrays.asList(p.getInventory().getContents())) {
     if (is != null) {
       tmpList.add(new String(is.getTypeId() + ":" + is.getAmount() + ":" + is.getDurability()));
     }
   }
   config.set("Kits." + name + ".Perm", perm);
   config.set("Kits." + name + ".Items", tmpList.toArray());
   if (p.getInventory().getHelmet() != null) {
     config.set("Kits." + name + ".Armor.Head", p.getInventory().getHelmet().getTypeId());
   } else {
     config.set("Kits." + name + ".Armor.Head", 0);
   }
   if (p.getInventory().getChestplate() != null) {
     config.set("Kits." + name + ".Armor.Chest", p.getInventory().getChestplate().getTypeId());
   } else {
     config.set("Kits." + name + ".Armor.Chest", 0);
   }
   if (p.getInventory().getLeggings() != null) {
     config.set("Kits." + name + ".Armor.Legs", p.getInventory().getLeggings().getTypeId());
   } else {
     config.set("Kits." + name + ".Armor.Legs", 0);
   }
   if (p.getInventory().getBoots() != null) {
     config.set("Kits." + name + ".Armor.Boots", p.getInventory().getBoots().getTypeId());
   } else {
     config.set("Kits." + name + ".Armor.Boots", 0);
   }
   ArrayList<Integer> tmpPots = new ArrayList<Integer>();
   for (PotionEffect pot : p.getActivePotionEffects()) {
     tmpPots.add(pot.getType().getId());
   }
   ArrayList<Integer> tmpInts = new ArrayList<Integer>();
   for (PotionEffect pot : p.getActivePotionEffects()) {
     tmpInts.add(pot.getType().getId());
   }
   config.set("Kits." + name + ".PotionEffects.Day", tmpInts.toArray());
   config.set("Kits." + name + ".PotionEffects.Night", tmpInts.toArray());
   saveConfig();
   reloadConfig();
   config = getConfig();
 }
Exemple #13
0
  @SuppressWarnings("deprecation")
  public void leaveGame(Player player, boolean normalLeave) {

    player.setGameMode(GameMode.CREATIVE);
    // player.setAllowFlight(true);

    player.setHealth(20.0);
    player.setFoodLevel(20);
    player.setLevel(0);

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

    // Session session = HyperPVP.getSession(player);
    // session.setInterruptThread(true);

    if (normalLeave) {
      player.sendMessage(ChatColor.AQUA + "You are now spectating!");
      HyperPVP.setListName(ChatColor.AQUA, player);
      player.getInventory().clear();
      player.updateInventory();
    }

    CycleUtil.addSpectator(player, normalLeave);
    HyperPVP.getGameSessions().remove(player.getName());

    CycleUtil.hidePlayerWhereAppropriate(player, false);
    player.getInventory().setHelmet(null);
    player.getInventory().setBoots(null);
    player.getInventory().setChestplate(null);
    player.getInventory().setLeggings(null);

    try {
      HyperPVP.getStorage()
          .executeQuery(
              "UPDATE servers SET team_one = '"
                  + this.getTeamMembers(this.teams.get(0).getColor()).size()
                  + "' WHERE bungee_name = '"
                  + HyperPVP.getConfiguration().getConfig().getString("Server").toLowerCase()
                  + "'");

      if (this.type != GameType.FFA) {
        HyperPVP.getStorage()
            .executeQuery(
                "UPDATE servers SET team_two = '"
                    + this.getTeamMembers(this.teams.get(1).getColor()).size()
                    + "' WHERE bungee_name = '"
                    + HyperPVP.getConfiguration().getConfig().getString("Server").toLowerCase()
                    + "'");
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
 @EventHandler
 public void potionEffects(PlayerChangedWorldEvent e) {
   if (!Config.separateInv || !Config.removePotionEffects) return;
   Player p = e.getPlayer();
   Collection<PotionEffect> potionEffects = p.getActivePotionEffects();
   if (potionEffects.isEmpty()) return;
   for (PotionEffect pe : potionEffects) {
     if (!p.hasPotionEffect(pe.getType())) continue;
     p.removePotionEffect(pe.getType());
   }
 }
  public static void saveInventory(Player player) {
    armourContents.put(player.getName(), player.getInventory().getArmorContents());
    inventoryContents.put(player.getName(), player.getInventory().getContents());
    locations.put(player.getName(), player.getLocation());
    xp.put(player.getName(), Float.valueOf(player.getExp()));
    xpLevel.put(player.getName(), Integer.valueOf(player.getLevel()));
    gameModes.put(player.getName(), player.getGameMode());
    potions.put(player.getName(), player.getActivePotionEffects());
    foodLevel.put(player.getName(), Integer.valueOf(player.getFoodLevel()));
    Health.put(player.getName(), Double.valueOf(player.getHealth()));
    flight.put(player.getName(), Boolean.valueOf(player.getAllowFlight()));

    player.setAllowFlight(false);
    player.setHealth(20.0D);
    player.setFoodLevel(20);
    for (PotionEffect effect : player.getActivePotionEffects()) {
      player.removePotionEffect(effect.getType());
    }
    player.getInventory().clear();
    player.setLevel(0);
    player.setExp(0.0F);
    player.setGameMode(GameMode.SURVIVAL);
  }
 public void removeAllNegativeEffects(Player player) {
   for (PotionEffect effect : player.getActivePotionEffects()) {
     if (effect.getType() == PotionEffectType.BLINDNESS
         || effect.getType() == PotionEffectType.BLINDNESS
         || effect.getType() == PotionEffectType.CONFUSION
         || effect.getType() == PotionEffectType.HARM
         || effect.getType() == PotionEffectType.HUNGER
         || effect.getType() == PotionEffectType.POISON
         || effect.getType() == PotionEffectType.SLOW
         || effect.getType() == PotionEffectType.SLOW_DIGGING
         || effect.getType() == PotionEffectType.WEAKNESS) {
       player.removePotionEffect(effect.getType());
     }
   }
 }
 public void removeAllPositiveEffects(Player player) {
   for (PotionEffect effect : player.getActivePotionEffects()) {
     if (effect.getType() == PotionEffectType.DAMAGE_RESISTANCE
         || effect.getType() == PotionEffectType.DAMAGE_RESISTANCE
         || effect.getType() == PotionEffectType.FAST_DIGGING
         || effect.getType() == PotionEffectType.FIRE_RESISTANCE
         || effect.getType() == PotionEffectType.HEAL
         || effect.getType() == PotionEffectType.INCREASE_DAMAGE
         || effect.getType() == PotionEffectType.JUMP
         || effect.getType() == PotionEffectType.REGENERATION
         || effect.getType() == PotionEffectType.SPEED
         || effect.getType() == PotionEffectType.WATER_BREATHING) {
       player.removePotionEffect(effect.getType());
     }
   }
 }
 public static void clearupperson(Player p) {
   p.setAllowFlight(false);
   p.setLevel(0);
   p.setExp(0);
   p.setFoodLevel(20);
   p.setSaturation(10);
   p.setHealth(20D);
   PlayerInventory pi = p.getInventory();
   pi.clear();
   pi.setHeldItemSlot(0);
   ItemStack Air = new ItemStack(Material.AIR);
   pi.setHelmet(Air);
   pi.setChestplate(Air);
   pi.setLeggings(Air);
   pi.setBoots(Air);
   for (PotionEffect effect : p.getActivePotionEffects()) p.removePotionEffect(effect.getType());
 }
 private void endRound() {
   Bukkit.broadcastMessage(
       ChatColor.LIGHT_PURPLE + "[BattleReverie] " + ChatColor.GOLD + "Round over!");
   try {
     if (!p1.equals("???"))
       Bukkit.getPlayer(p1)
           .teleport(new Location(Bukkit.getWorld(getName()), 0, 87, 0, 87.998F, 7.1F));
     if (!p2.equals("???"))
       Bukkit.getPlayer(p2)
           .teleport(new Location(Bukkit.getWorld(getName()), 0, 87, 0, 87.998F, 7.1F));
     if (!p3.equals("???"))
       Bukkit.getPlayer(p3)
           .teleport(new Location(Bukkit.getWorld(getName()), 0, 87, 0, 87.998F, 7.1F));
     if (!p4.equals("???"))
       Bukkit.getPlayer(p4)
           .teleport(new Location(Bukkit.getWorld(getName()), 0, 87, 0, 87.998F, 7.1F));
   } catch (NullPointerException ex) {
   }
   p1 = "???";
   p2 = "???";
   p3 = "???";
   p4 = "???";
   for (Player p : getInGame()) {
     p.getInventory().clear();
     p.getInventory().setHelmet(new ItemStack(Material.AIR, 1));
     p.getInventory().setChestplate(new ItemStack(Material.AIR, 1));
     p.getInventory().setBoots(new ItemStack(Material.AIR, 1));
     p.getInventory().setLeggings(new ItemStack(Material.AIR, 1));
     for (PotionEffect po : p.getActivePotionEffects()) {
       p.removePotionEffect(po.getType());
     }
     p.setHealth(20);
     p.setFoodLevel(20);
     p.updateInventory();
   }
   Bukkit.getScheduler()
       .runTaskLater(
           plugin,
           new Runnable() {
             public void run() {
               newRound();
             }
           },
           40L);
 }
 @Override
 public void tick(Player player) {
   if (item.getHasPermission() == true && player.hasPermission(item.getPermission()) == false) {
     player.sendMessage(ChatColor.RED + String.format(Locale.get("message.error.permission")));
   } else {
     boolean hasEffect = false;
     for (PotionEffect potionEffect : player.getActivePotionEffects()) {
       if (potionEffect.getType().equals(effect)) {
         hasEffect = true;
         if (potionEffect.getDuration() <= 10)
           player.addPotionEffect(new PotionEffect(effect, 30, amplifier, true), true);
         break;
       }
     }
     if (!hasEffect) {
       player.addPotionEffect(new PotionEffect(effect, 30, amplifier, true), true);
     }
   }
 }
Exemple #21
0
  public void playerLeave(final Player p, boolean teleport) {
    msgFall(PrefixType.INFO, "game.playerleavegame", "player-" + p.getName());
    if (teleport) {
      p.teleport(SettingsManager.getInstance().getLobbySpawn());
    }
    // Remove any potion/fire effects
    for (PotionEffect effect : p.getActivePotionEffects()) {
      p.removePotionEffect(effect.getType());
    }
    if (p.getFireTicks() > 0) {
      p.setFireTicks(0);
    }

    sm.removePlayer(p, gameID);
    scoreBoard.removePlayer(p);
    activePlayers.remove(p);
    inactivePlayers.remove(p);
    voted.remove(p);

    for (Object in : spawns.keySet().toArray()) {
      if (spawns.get(in) == p) spawns.remove(in);
    }

    HookManager.getInstance().runHook("PLAYER_REMOVED", "player-" + p.getName());
    LobbyManager.getInstance().updateWall(gameID);

    if (activePlayers.size() < 2 && mode == GameMode.INGAME) {
      mode = GameMode.FINISHING;
      tasks.add(
          Bukkit.getScheduler()
              .scheduleSyncDelayedTask(
                  GameManager.getInstance().getPlugin(),
                  new Runnable() {
                    public void run() {
                      playerWin(p);
                      endGame();
                    }
                  },
                  1L));
    }
  }
  /** Sends the self disguise to the player */
  public static void sendSelfDisguise(final Player player, final TargetedDisguise disguise) {
    try {
      if (!disguise.isDisguiseInUse()
          || !player.isValid()
          || !player.isOnline()
          || !disguise.isSelfDisguiseVisible()
          || !disguise.canSee(player)) {
        return;
      }
      Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(player);
      if (entityTrackerEntry == null) {
        // A check incase the tracker is null.
        // If it is, then this method will be run again in one tick. Which is when it should be
        // constructed.
        // Else its going to run in a infinite loop hue hue hue..
        // At least until this disguise is discarded
        Bukkit.getScheduler()
            .runTask(
                libsDisguises,
                new Runnable() {
                  public void run() {
                    if (DisguiseAPI.getDisguise(player, player) == disguise) {
                      sendSelfDisguise(player, disguise);
                    }
                  }
                });
        return;
      }
      // Add himself to his own entity tracker
      ((HashSet<Object>)
              ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
                  .get(entityTrackerEntry))
          .add(ReflectionManager.getNmsEntity(player));
      ProtocolManager manager = ProtocolLibrary.getProtocolManager();
      // Send the player a packet with himself being spawned
      manager.sendServerPacket(
          player,
          manager
              .createPacketConstructor(PacketType.Play.Server.NAMED_ENTITY_SPAWN, player)
              .createPacket(player));
      WrappedDataWatcher dataWatcher = WrappedDataWatcher.getEntityWatcher(player);
      sendSelfPacket(
          player,
          manager
              .createPacketConstructor(
                  PacketType.Play.Server.ENTITY_METADATA, player.getEntityId(), dataWatcher, true)
              .createPacket(player.getEntityId(), dataWatcher, true));

      boolean isMoving = false;
      try {
        Field field =
            ReflectionManager.getNmsClass("EntityTrackerEntry").getDeclaredField("isMoving");
        field.setAccessible(true);
        isMoving = field.getBoolean(entityTrackerEntry);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
      // Send the velocity packets
      if (isMoving) {
        Vector velocity = player.getVelocity();
        sendSelfPacket(
            player,
            manager
                .createPacketConstructor(
                    PacketType.Play.Server.ENTITY_VELOCITY,
                    player.getEntityId(),
                    velocity.getX(),
                    velocity.getY(),
                    velocity.getZ())
                .createPacket(
                    player.getEntityId(), velocity.getX(), velocity.getY(), velocity.getZ()));
      }

      // Why the hell would he even need this. Meh.
      if (player.getVehicle() != null && player.getEntityId() > player.getVehicle().getEntityId()) {
        sendSelfPacket(
            player,
            manager
                .createPacketConstructor(
                    PacketType.Play.Server.ATTACH_ENTITY, 0, player, player.getVehicle())
                .createPacket(0, player, player.getVehicle()));
      } else if (player.getPassenger() != null
          && player.getEntityId() > player.getPassenger().getEntityId()) {
        sendSelfPacket(
            player,
            manager
                .createPacketConstructor(
                    PacketType.Play.Server.ATTACH_ENTITY, 0, player.getPassenger(), player)
                .createPacket(0, player.getPassenger(), player));
      }

      // Resend the armor
      for (int i = 0; i < 5; i++) {
        ItemStack item;
        if (i == 0) {
          item = player.getItemInHand();
        } else {
          item = player.getInventory().getArmorContents()[i - 1];
        }

        if (item != null && item.getType() != Material.AIR) {
          sendSelfPacket(
              player,
              manager
                  .createPacketConstructor(
                      PacketType.Play.Server.ENTITY_EQUIPMENT, player.getEntityId(), i, item)
                  .createPacket(player.getEntityId(), i, item));
        }
      }
      Location loc = player.getLocation();
      // If the disguised is sleeping for w/e reason
      if (player.isSleeping()) {
        sendSelfPacket(
            player,
            manager
                .createPacketConstructor(
                    PacketType.Play.Server.BED,
                    player,
                    loc.getBlockX(),
                    loc.getBlockY(),
                    loc.getBlockZ())
                .createPacket(player, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
      }

      // Resend any active potion effects
      for (Object potionEffect : player.getActivePotionEffects()) {
        sendSelfPacket(
            player,
            manager
                .createPacketConstructor(
                    PacketType.Play.Server.ENTITY_EFFECT, player.getEntityId(), potionEffect)
                .createPacket(player.getEntityId(), potionEffect));
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Exemple #23
0
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    if (!(sender instanceof Player)) {
      sender.sendMessage("Players only please!");
      return true;
    }
    Player p = (Player) sender;
    if (cmd.getName().equalsIgnoreCase("sync")
        && args.length > 0
        && args[0].equalsIgnoreCase("time")
        && p.isOp()) {
      p.sendMessage(ChatColor.GREEN + "Time sync'd!");
      resetTime();
    }
    if (cmd.getName().equalsIgnoreCase("kit")) {
      if (args.length == 1 && !args[0].equalsIgnoreCase("list")) {
        for (MovingVan van : vans) {
          if (van.getName().equalsIgnoreCase(args[0])) {
            van.users.add(p.getName());
            write();
            if (hasKit.contains(p.getName())) {
              p.sendMessage(ChatColor.RED + "You already have a kit!");
              return true;
            }
            if (!getConfig().getString("Kits." + args[0] + ".Perm").equalsIgnoreCase("NA")
                && !p.hasPermission(getConfig().getString("Kits." + args[0] + ".Perm"))) {
              p.sendMessage(ChatColor.RED + "You don't have permission!");
              return true;
            }
            p.getInventory().clear();
            removeAllPotionEffects(p);

            for (String s : getConfig().getStringList("Kits." + args[0] + ".Items")) {
              String[] tmp = s.split(":");
              if (Short.parseShort(tmp[2]) == 0) {
                p.getInventory()
                    .addItem(new ItemStack(Integer.parseInt(tmp[0]), Integer.parseInt(tmp[1])));
              } else {
                p.getInventory()
                    .addItem(
                        new ItemStack(
                            Integer.parseInt(tmp[0]),
                            Integer.parseInt(tmp[1]),
                            Short.parseShort(tmp[2])));
              }
            }
            p.getInventory()
                .setHelmet(new ItemStack(config.getInt("Kits." + args[0] + ".Armor.Head")));
            p.getInventory()
                .setChestplate(new ItemStack(config.getInt("Kits." + args[0] + ".Armor.Chest")));
            p.getInventory()
                .setLeggings(new ItemStack(config.getInt("Kits." + args[0] + ".Armor.Legs")));
            p.getInventory()
                .setBoots(new ItemStack(config.getInt("Kits." + args[0] + ".Armor.Boots")));

            if (p.getWorld().getTime() < 12000) {
              for (int i : config.getIntegerList("Kits." + args[0] + ".PotionEffects.Day")) {
                p.addPotionEffect(new PotionEffect(PotionEffectType.getById(i), 999999999, 1));
              }
            } else {
              for (int i : config.getIntegerList("Kits." + args[0] + ".PotionEffects.Night")) {
                p.addPotionEffect(new PotionEffect(PotionEffectType.getById(i), 999999999, 1));
              }
            }
            hasKit.add(p.getName());
            if (invince.contains(p.getName())) {
              invince.remove(p.getName());
            }
            tpRandom(p);
            p.sendMessage(ChatColor.GREEN + "Kit recieved!");
            return true;
          }
        }
        p.sendMessage(ChatColor.RED + "Kit not found!");
      } else if (args.length == 1 && args[0].equalsIgnoreCase("list")) {
        p.sendMessage(
            ChatColor.DARK_GREEN
                + "---- "
                + ChatColor.GREEN
                + "KITS"
                + ChatColor.DARK_GREEN
                + " ----");
        for (MovingVan van : vans) {
          p.sendMessage(ChatColor.BLUE + van.getName());
        }
      } else if (args.length == 2 && p.isOp()) {
        if (args[0].equalsIgnoreCase("set")) {
          MovingVan tmp =
              new MovingVan(args[1], p.getInventory(), p.getActivePotionEffects(), "NA");
          checkKit(tmp);
          vans.add(tmp);
          writeConfig(tmp, p, args[1], "NA");
          write();
          p.getInventory().clear();
          p.getInventory().setHelmet(new ItemStack(0));
          p.getInventory().setChestplate(new ItemStack(0));
          p.getInventory().setLeggings(new ItemStack(0));
          p.getInventory().setBoots(new ItemStack(0));
          removeAllPotionEffects(p);
          p.sendMessage(ChatColor.GREEN + "Kit set!");
        }
      } else if (args.length == 3 && p.isOp()) {
        if (args[0].equalsIgnoreCase("set")) {
          MovingVan tmp =
              new MovingVan(args[1], p.getInventory(), p.getActivePotionEffects(), args[2]);
          checkKit(tmp);
          vans.add(tmp);
          writeConfig(tmp, p, args[1], args[2]);
          write();
          p.getInventory().clear();
          p.getInventory().setHelmet(new ItemStack(0));
          p.getInventory().setChestplate(new ItemStack(0));
          p.getInventory().setLeggings(new ItemStack(0));
          p.getInventory().setBoots(new ItemStack(0));
          removeAllPotionEffects(p);
          p.sendMessage(ChatColor.GREEN + "Kit set!");
        }
      }
    }
    return true;
  }
Exemple #24
0
  @SuppressWarnings("deprecation")
  public void joinGame(Player player, String name) {

    int rank = 1;

    try {
      rank =
          HyperPVP.getStorage()
              .readInt32("SELECT rank FROM users WHERE username = '******'");
    } catch (SQLException e) {
      e.printStackTrace();
    }

    if (this.type == GameType.FFA) {

      List<Session> first = this.getTeamMembers(this.teams.get(0).getColor());

      if (first.size() >= this.maxPlayers && rank == 1) {

        System.out.println(this.maxPlayers);
        player.sendMessage(
            ChatColor.RED
                + "Teams full - "
                + ChatColor.GOLD
                + "hyperpvp.us/shop"
                + ChatColor.GREEN
                + " to join full teams or view other servers at "
                + ChatColor.GREEN
                + "hyperpvp.us/servers");
        return;
      }

    } else {

      List<Session> first = this.getTeamMembers(this.teams.get(0).getColor());
      List<Session> second = this.getTeamMembers(this.teams.get(1).getColor());

      if ((first.size() + second.size()) >= this.maxPlayers && rank == 1) {

        System.out.println(this.maxPlayers);
        player.sendMessage(
            ChatColor.RED
                + "Teams full - "
                + ChatColor.GOLD
                + "hyperpvp.us/shop"
                + ChatColor.GREEN
                + " to join full teams or view other servers at "
                + ChatColor.GREEN
                + "hyperpvp.us/servers");
        return;
      }
    }

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

    if (HyperPVP.hasMatchBeenAnnounced()) {
      player.setGameMode(GameMode.SURVIVAL);
    } else {
      player.setGameMode(GameMode.CREATIVE);
    }

    player.getInventory().clear();
    player.updateInventory();

    Session session = new Session(player);

    HyperPVP.getSpectators().remove(player.getName());
    CycleUtil.addGameSession(player, session);

    if (this.type == GameType.FFA) {
      session.setTeam(this.teams.get(0));
    } else {

      if (name != null) {

        TeamMap team = this.getTeamByName(name);
        session.setTeam(team);

      } else {

        List<Session> first = this.getTeamMembers(this.teams.get(0).getColor());
        List<Session> second = this.getTeamMembers(this.teams.get(1).getColor());

        if (first.size() == second.size()) {
          session.setTeam(this.teams.get(0));
        } else {

          if (first.size() > second.size()) {
            session.setTeam(this.teams.get(1));

          } else session.setTeam(this.teams.get(0));
        }
      }
    }

    /*if (HyperPVP.hasMatchBeenAnnounced()) {
    	player.sendMessage(this.matchInfoToString(player));
    }*/

    player.sendMessage(
        ChatColor.GRAY
            + "You joined the "
            + session.getTeam().getColor()
            + HyperPVP.capitalize(
                session
                    .getTeam()
                    .getColor()
                    .name()
                    .toLowerCase()
                    .replace("_", " ")
                    .replace("dark ", ""))
            + " Team");

    HyperPVP.setListName(session.getTeam().getColor(), player);

    TagAPI.refreshPlayer(player);

    player.setFallDistance(0F);

    if (HyperPVP.hasMatchBeenAnnounced()) {

      CycleUtil.hidePlayerWhereAppropriate(player, true);
      player.teleport(this.getRandomSpawn(player));
    }

    if (!HyperPVP.hasMatchBeenAnnounced()) {
      player.getInventory().clear();
      player.getInventory().addItem(new ItemStack(Material.COMPASS, 1));
      player.updateInventory();
      player.closeInventory();
    }

    try {
      HyperPVP.getStorage()
          .executeQuery(
              "UPDATE servers SET team_one = '"
                  + this.getTeamMembers(this.teams.get(0).getColor()).size()
                  + "' WHERE bungee_name = '"
                  + HyperPVP.getConfiguration().getConfig().getString("Server").toLowerCase()
                  + "'");

      if (this.type != GameType.FFA) {
        HyperPVP.getStorage()
            .executeQuery(
                "UPDATE servers SET team_two = '"
                    + this.getTeamMembers(this.teams.get(1).getColor()).size()
                    + "' WHERE bungee_name = '"
                    + HyperPVP.getConfiguration().getConfig().getString("Server").toLowerCase()
                    + "'");
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }

    System.out.println(session.toValue());
  }
Exemple #25
0
  @Override
  public final void check(IProfile player) {
    final Player p = player.getBukkitPlayer();
    if (p.isInsideVehicle())
      return; // Riding a horse or minecart makes it possible to move much faster
    if (p.getAllowFlight()) return;
    // If they have both speed AND slowness, we're just going to ignore them...

    if (p.hasPotionEffect(PotionEffectType.SPEED) && !p.hasPotionEffect(PotionEffectType.SLOW)) {
      PotionEffect potionEffect = null;

      for (PotionEffect effect : p.getActivePotionEffects()) {
        if (effect.getType().equals(PotionEffectType.SPEED)) {
          potionEffect = effect;
          break;
        }
      }

      double maxBps = this.maxBlocksPerSecond;

      if (potionEffect != null) {
        // They have speed
        int amp = potionEffect.getAmplifier();
        maxBps =
            maxBlocksPerSecond
                + (maxBlocksPerSecond * ((amp + 1) * 0.20)); // Speed increases by 20%
      }

      double bps = player.getProfileData().getBlocksPerSecond();

      if (bps > maxBps) {
        fail(player);
      }

    } else if (p.hasPotionEffect(PotionEffectType.SLOW)
        && !p.hasPotionEffect(PotionEffectType.SPEED)) {
      // Slowness decreases by 15% * potion level
      PotionEffect potionEffect = null;
      for (PotionEffect effect : p.getActivePotionEffects()) {
        if (effect.getType().equals(PotionEffectType.SLOW)) {
          potionEffect = effect;
          break;
        }
      }

      double maxBps = this.maxBlocksPerSecond;

      if (potionEffect != null) {
        // They have slow
        int amp = potionEffect.getAmplifier();
        maxBps = maxBlocksPerSecond * (amp - (amp * 0.15)); // Slow decreases by 15%
      }

      double bps = player.getProfileData().getBlocksPerSecond();

      if (bps > maxBps) {
        fail(player);
      }
    } else if (!p.hasPotionEffect(PotionEffectType.SPEED)
        && !p.hasPotionEffect(PotionEffectType.SLOW)) {

      double bps = player.getProfileData().getBlocksPerSecond();

      if (bps > this.maxBlocksPerSecond) {
        fail(player);
      }
    }

    // Reset their blocks per second
    player.getProfileData().setBlocksPerSecond(0);
  }
 public void removeAllEffects(Player player) {
   for (PotionEffect effect : player.getActivePotionEffects()) {
     player.removePotionEffect(effect.getType());
   }
 }
 public void manageDeath(PlayerKilledEvent event) {
   Gamer killed = event.getKilled();
   final Player p = killed.getPlayer();
   p.setHealth(20);
   if (event.isCancelled()) return;
   for (HumanEntity human : p.getInventory().getViewers()) human.closeInventory();
   p.leaveVehicle();
   p.eject();
   p.setLevel(0);
   p.setExp(0F);
   if (event.getDeathMessage().equals(ChatColor.stripColor(event.getDeathMessage())))
     event.setDeathMessage(ChatColor.DARK_RED + event.getDeathMessage());
   event.setDeathMessage(
       this.formatDeathMessage(
           event.getDeathMessage().replace("%Remaining%", "" + (getAliveGamers().size() - 1)), p));
   if (event.getKillerPlayer() != null) {
     event.getKillerPlayer().addKill();
     event.setDeathMessage(
         this.formatDeathMessage(event.getDeathMessage(), event.getKillerPlayer().getPlayer()));
   }
   Bukkit.broadcastMessage(event.getDeathMessage());
   int reward = hg.getPrize(getAliveGamers().size());
   if (reward > 0) killed.addBalance(reward);
   hg.cannon();
   killed.clearInventory();
   World world = p.getWorld();
   for (ItemStack item : event.getDrops()) {
     if (item == null
         || item.getType() == Material.AIR
         || item.containsEnchantment(EnchantmentManager.UNLOOTABLE)) continue;
     else if (item.hasItemMeta())
       world
           .dropItemNaturally(event.getDropsLocation(), item.clone())
           .getItemStack()
           .setItemMeta(item.getItemMeta());
     else world.dropItemNaturally(event.getDropsLocation(), item);
   }
   setSpectator(killed);
   ScoreboardManager.makeScore(
       "Main", DisplaySlot.SIDEBAR, cm.getScoreboardPlayersLength(), getAliveGamers().size());
   hg.checkWinner();
   p.setVelocity(new Vector());
   for (PotionEffect effect : p.getActivePotionEffects()) p.removePotionEffect(effect.getType());
   p.teleport(p.getWorld().getHighestBlockAt(p.getLocation()).getLocation().clone().add(0, 10, 0));
   p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 40, 9), true);
   p.sendBlockChange(p.getLocation(), Material.PORTAL.getId(), (byte) 0);
   p.sendBlockChange(p.getLocation(), Material.AIR.getId(), (byte) 0);
   for (Entity entity : p.getWorld().getEntities()) {
     if (entity instanceof Tameable
         && ((Tameable) entity).isTamed()
         && ((Tameable) entity).getOwner().getName().equals(p.getName())) {
       if (entity instanceof Wolf) ((Wolf) entity).setSitting(true);
       else if (entity instanceof Ocelot) ((Ocelot) entity).setSitting(true);
       else entity.remove();
     }
     if (entity instanceof Creature && ((Creature) entity).getTarget() == p)
       ((Creature) entity).setTarget(null);
   }
   if (HungergamesApi.getConfigManager().getMainConfig().isKickOnDeath()
       && !p.hasPermission("hungergames.spectate"))
     p.kickPlayer(String.format(cm.getKickDeathMessage(), event.getDeathMessage()));
   HungergamesApi.getAbilityManager().unregisterPlayer(p);
   HungergamesApi.getInventoryManager().updateSpectatorHeads();
 }
  private void handKit(final Player player, final Group group) {
    player.sendMessage(
        ChatColor.GREEN
            + "You have chosen "
            + ChatColor.AQUA
            + group.toString().toLowerCase()
            + ChatColor.GREEN
            + " as your class!");

    player.getInventory().clear();
    player.getInventory().setHelmet(new ItemStack(Material.AIR, 0));
    player.getInventory().setChestplate(new ItemStack(Material.AIR, 0));
    player.getInventory().setLeggings(new ItemStack(Material.AIR, 0));
    player.getInventory().setBoots(new ItemStack(Material.AIR, 0));
    player.updateInventory();

    for (PotionEffect effect : player.getActivePotionEffects()) {
      player.removePotionEffect(effect.getType());
      player.updateInventory();
    }
    selecting.add(player.getName());
    player.updateInventory();

    Bukkit.getScheduler()
        .runTaskLater(
            plugin,
            new Runnable() {
              public void run() {
                switch (group) {
                  case FIREARMS:
                    ItemStack AMMO = new ItemStack(Material.FLINT, 46);
                    ItemStack BLAZE_ROD = new ItemStack(Material.BLAZE_ROD, 1);

                    ItemMeta blaze_rod = BLAZE_ROD.getItemMeta();
                    blaze_rod.setDisplayName(ChatColor.BLUE + "Retro Wartown Gun");
                    BLAZE_ROD.setItemMeta(blaze_rod);

                    ItemMeta ammo = AMMO.getItemMeta();
                    ammo.setDisplayName(ChatColor.BLUE + "Ammunition");
                    AMMO.setItemMeta(ammo);

                    player.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET, 1));
                    player.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE, 1));
                    player.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS, 1));
                    player.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS, 1));

                    player.getInventory().setItem(0, new ItemStack(Material.STONE_SWORD, 1));
                    player.getInventory().setItem(1, BLAZE_ROD);
                    player.getInventory().setItem(2, new ItemStack(Material.COOKED_BEEF, 3));
                    player.getInventory().setItem(9, AMMO);
                    player.updateInventory();
                    break;

                  case SPY:
                    ItemStack SPY_WATCH = new ItemStack(Material.WATCH, 5);
                    ItemMeta spywatchMeta = SPY_WATCH.getItemMeta();
                    spywatchMeta.setDisplayName(ChatColor.BLUE + "Spy Watch");
                    List<String> spyLore = new ArrayList<String>();
                    spyLore.add(
                        org.bukkit.ChatColor.BLUE
                            + "Interact with this watch to go temporarily invisible!");
                    spywatchMeta.setLore(spyLore);
                    SPY_WATCH.setItemMeta(spywatchMeta);

                    player.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET, 1));
                    player.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE, 1));
                    player.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS, 1));
                    player.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS, 1));

                    player.getInventory().setItem(0, new ItemStack(Material.STONE_SWORD, 1));
                    player.getInventory().setItem(2, SPY_WATCH);
                    player.getInventory().setItem(1, new ItemStack(Material.COOKED_BEEF, 3));
                    player.updateInventory();
                    break;

                  case KNIGHT:
                    player.getInventory().setHelmet(new ItemStack(Material.GOLD_HELMET, 1));
                    player.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE, 1));
                    player.getInventory().setLeggings(new ItemStack(Material.GOLD_LEGGINGS, 1));
                    player.getInventory().setBoots(new ItemStack(Material.DIAMOND_BOOTS, 1));

                    player.getInventory().setItem(0, new ItemStack(Material.IRON_SWORD, 1));
                    player.getInventory().setItem(1, new ItemStack(Material.COOKED_BEEF, 3));
                    player.updateInventory();
                    break;

                  case DEMOLITION:
                    player.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET, 1));
                    player.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE, 1));
                    player.getInventory().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS, 1));
                    player.getInventory().setBoots(new ItemStack(Material.LEATHER_BOOTS, 1));

                    player.getInventory().setItem(0, new ItemStack(Material.GOLD_SWORD, 1));
                    player.getInventory().setItem(1, new ItemStack(Material.COOKED_BEEF, 3));
                    player.getInventory().setItem(2, new ItemStack(Material.TNT, 32));
                    player.updateInventory();
                    break;

                  case TANK:
                    player.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET, 1));
                    player
                        .getInventory()
                        .setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE, 1));
                    player.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS, 1));
                    player.getInventory().setBoots(new ItemStack(Material.DIAMOND_BOOTS, 1));

                    player
                        .getInventory()
                        .setItem(0, new ItemStack(Material.IRON_SWORD, 1, (short) -200));
                    player.getInventory().setItem(1, new ItemStack(Material.COOKED_BEEF, 3));
                    player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20000 * 20, 1));
                    player.updateInventory();
                    break;

                  case ARCHER:
                    player.getInventory().setBoots(new ItemStack(Material.GOLD_BOOTS, 1));

                    ItemStack BOW = new ItemStack(Material.BOW, 1);
                    BOW.addEnchantment(Enchantment.ARROW_INFINITE, 1);
                    player.getInventory().setItem(0, BOW);
                    player.getInventory().setItem(1, new ItemStack(Material.COOKED_BEEF, 3));
                    player.getInventory().setItem(9, new ItemStack(Material.ARROW, 1));
                    player.updateInventory();
                    break;

                  case MEDIC:
                    player.getInventory().setHelmet(new ItemStack(Material.GOLD_HELMET, 1));
                    player.getInventory().setChestplate(new ItemStack(Material.GOLD_CHESTPLATE, 1));
                    player.getInventory().setLeggings(new ItemStack(Material.GOLD_LEGGINGS, 1));
                    player.getInventory().setBoots(new ItemStack(Material.GOLD_BOOTS, 1));

                    player.getInventory().setItem(0, new ItemStack(Material.STONE_SWORD, 1));
                    player
                        .getInventory()
                        .setItem(1, new ItemStack(Material.POTION, 48, (short) 16437));
                    player.getInventory().setItem(2, new ItemStack(Material.COOKED_BEEF, 3));
                    player.updateInventory();
                    break;

                  case SCOUT:
                    ItemStack LEATHER_CHESTPLATE = new ItemStack(Material.LEATHER_CHESTPLATE, 1);
                    ArmourUtils.colourArmourAccordingToTeam(
                        BattlePlayer.getBattlePlayer(player), new ItemStack[] {LEATHER_CHESTPLATE});
                    player.getInventory().setChestplate(LEATHER_CHESTPLATE);

                    player.getInventory().setItem(0, new ItemStack(Material.WOOD_SWORD, 1));
                    player.getInventory().setItem(1, new ItemStack(Material.COOKED_BEEF, 3));

                    player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 20000 * 20, 1));
                    player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20000 * 20, 1));
                    player.updateInventory();
                    break;
                }
                selecting.remove(player.getName());
                try {
                  Team team = BattlePlayer.getBattlePlayer(player).getTeamType();
                  if (team == Team.TDM_RED)
                    player.teleport(new Location(player.getWorld(), 46, 73, -5));
                  if (team == Team.TDM_BLUE)
                    player.teleport(new Location(player.getWorld(), -25, 73, 0));
                } catch (Exception ex) {

                }
              }
            },
            30L);
  }
  public void task() {

    Plugin plugin = Bukkit.getPluginManager().getPlugin(pluginName);
    GamemodeCheck gamemodeCheck = new GamemodeCheck();

    plugin
        .getServer()
        .getScheduler()
        .runTaskTimerAsynchronously(
            plugin,
            () ->
                plugin
                    .getServer()
                    .getScheduler()
                    .runTask(
                        plugin,
                        () -> {
                          if (!rocketPower.isEmpty()) {
                            for (Map.Entry<UUID, Integer> entry : rocketPower.entrySet()) {

                              Player player = Bukkit.getPlayer(entry.getKey());

                              if (gamemodeCheck.check(
                                  player, GameMode.SURVIVAL, GameMode.ADVENTURE))
                                if (player.getWorld().getName().equals("world"))
                                  if (rocketVariant.containsKey(player.getUniqueId()))
                                    if (player.isFlying()) {

                                      Variant bootVariant = rocketVariant.get(player.getUniqueId());
                                      PotionEffect[] effects = bootVariant.getPotionEffects();

                                      for (PotionEffect effect : player.getActivePotionEffects())
                                        player.removePotionEffect(effect.getType());

                                      if (effects != null) {
                                        for (PotionEffect effect : effects) {
                                          rocketEffects.add(player.getUniqueId());
                                          player.addPotionEffect(effect);
                                        }
                                      }

                                      if (bootVariant.equals(STEALTH))
                                        for (Player onlinePlayer : Bukkit.getOnlinePlayers())
                                          onlinePlayer.hidePlayer(player);

                                    } else if (rocketEffects.contains(player.getUniqueId())) {

                                      for (PotionEffect effect : player.getActivePotionEffects())
                                        player.removePotionEffect(effect.getType());

                                      for (Player onlinePlayer : Bukkit.getOnlinePlayers())
                                        onlinePlayer.showPlayer(player);

                                      rocketEffects.remove(player.getUniqueId());
                                    }
                            }
                          }
                        }),
            0,
            0);
  }
 public static void removeEffects(final Player player) {
   for (PotionEffect pe : player.getActivePotionEffects()) {
     player.removePotionEffect(pe.getType());
   }
 }