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;
  }
예제 #2
0
 private void endLeap(Player player, AnniPlayer p) {
   if (p.getData("Cur") != null) {
     Object obj = p.getData("Arm");
     if (obj != null && player != null) player.getInventory().setArmorContents((ItemStack[]) obj);
     p.setData("Arm", null);
     if (player != null) {
       player.removePotionEffect(PotionEffectType.INVISIBILITY);
       player.removePotionEffect(PotionEffectType.SPEED);
       player.removePotionEffect(PotionEffectType.FAST_DIGGING);
     }
     p.setData("Cur", null);
   }
 }
예제 #3
0
  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());
  }
예제 #4
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);
 }
  @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();
  }
예제 #6
0
 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);
   }
 }
예제 #7
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());
    }
  }
예제 #8
0
 @EventHandler
 public void speedIIremove(final ArmorEquipEvent e) {
   if (e.getOldArmorPiece().getItemMeta().getLore() != null
       && e.getOldArmorPiece().getItemMeta().getLore().contains(ChatColor.GRAY + "Speed II")) {
     Player p = e.getPlayer();
     p.removePotionEffect(PotionEffectType.SPEED);
   }
 }
예제 #9
0
 @EventHandler
 public void onJoin(PlayerJoinEvent e) {
   Player p = e.getPlayer();
   cInv.createPotionGUI();
   for (PotionEffect effect : p.getActivePotionEffects()) {
     p.removePotionEffect(effect.getType());
   }
 }
예제 #10
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();
    }
  }
예제 #11
0
 @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());
   }
 }
예제 #12
0
 @EventHandler
 public void onEat(PlayerItemConsumeEvent e) {
   if (e.getItem() != null) {
     final Player p = e.getPlayer();
     ItemStack item = e.getItem();
     if (Slimefun.hasUnlocked(p, item, true)) {
       if (SlimefunManager.isItemSimiliar(item, SlimefunItems.MONSTER_JERKY, true)) {
         PlayerInventory.consumeItemInHand(p);
         e.setItem(new ItemStack(Material.APPLE));
       } else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.FORTUNE_COOKIE, true))
         p.sendMessage(
             Messages.local
                 .getTranslation("messages.fortune-cookie")
                 .get(
                     CSCoreLib.randomizer()
                         .nextInt(
                             Messages.local.getTranslation("messages.fortune-cookie").size())));
       else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.BEEF_JERKY, true))
         p.setSaturation((Integer) Slimefun.getItemValue("BEEF_JERKY", "Saturation"));
       else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.GRILLED_CHEESE, true))
         p.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 8, 0));
       else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.BUTTERED_POTATO, true))
         p.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 8, 0));
       else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.MEDICINE, true)) {
         if (p.hasPotionEffect(PotionEffectType.POISON))
           p.removePotionEffect(PotionEffectType.POISON);
         if (p.hasPotionEffect(PotionEffectType.WITHER))
           p.removePotionEffect(PotionEffectType.WITHER);
         if (p.hasPotionEffect(PotionEffectType.SLOW)) p.removePotionEffect(PotionEffectType.SLOW);
         if (p.hasPotionEffect(PotionEffectType.SLOW_DIGGING))
           p.removePotionEffect(PotionEffectType.SLOW_DIGGING);
         if (p.hasPotionEffect(PotionEffectType.WEAKNESS))
           p.removePotionEffect(PotionEffectType.WEAKNESS);
         if (p.hasPotionEffect(PotionEffectType.CONFUSION))
           p.removePotionEffect(PotionEffectType.CONFUSION);
         if (p.hasPotionEffect(PotionEffectType.BLINDNESS))
           p.removePotionEffect(PotionEffectType.BLINDNESS);
         p.setFireTicks(0);
       } else if (item.getType() == Material.POTION) {
         SlimefunItem sfItem = SlimefunItem.getByItem(item);
         if (sfItem != null && sfItem instanceof Juice) {
           Bukkit.getScheduler()
               .scheduleSyncDelayedTask(
                   main.instance,
                   new Runnable() {
                     @Override
                     public void run() {
                       p.getInventory().removeItem(new ItemStack(Material.GLASS_BOTTLE, 1));
                     }
                   },
                   1L);
         }
       }
     } else e.setCancelled(true);
   }
 }
예제 #13
0
 @EventHandler
 public void onInventoryClose(InventoryCloseEvent event) {
   Player p = (Player) event.getPlayer();
   if (p.hasPermission("speedboost.speedboost.one")) {
     p.removePotionEffect(PotionEffectType.SPEED);
     p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 18000, 0));
   }
   if (p.hasPermission("speedboost.speedboost.two")) {
     p.removePotionEffect(PotionEffectType.SPEED);
     p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 18000, 1));
   }
   if (p.hasPermission("speedboost.speedboost.three")) {
     p.removePotionEffect(PotionEffectType.SPEED);
     p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 18000, 2));
   }
   if (p.hasPermission("speedboost.jump.one")) {
     p.removePotionEffect(PotionEffectType.JUMP);
     p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 18000, 0));
   }
   if (p.hasPermission("speedboost.jump.two")) {
     p.removePotionEffect(PotionEffectType.JUMP);
     p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 18000, 1));
   }
   if (p.hasPermission("speedboost.jump.three")) {
     p.removePotionEffect(PotionEffectType.JUMP);
     p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 18000, 2));
   }
 }
예제 #14
0
 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());
     }
   }
 }
예제 #15
0
 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());
     }
   }
 }
예제 #16
0
	@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();
	}
예제 #17
0
 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());
 }
예제 #18
0
 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);
 }
예제 #19
0
 @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
 public void damageHandler(EntityDamageEvent event) {
   if (event.getEntityType() == EntityType.PLAYER) {
     AnniPlayer p = AnniPlayer.getPlayer(event.getEntity().getUniqueId());
     if (p != null
         && p.getTeam() != null
         && !p.getTeam().isTeamDead()
         && p.getTeam().getNexus().getLocation() != null
         && p.getKit().equals(this)) {
       Player player = (Player) event.getEntity();
       if (player.getLocation().distanceSquared(p.getTeam().getNexus().getLocation().toLocation())
           <= 20 * 20)
         player.addPotionEffect(
             new PotionEffect(PotionEffectType.REGENERATION, Integer.MAX_VALUE, 0));
       else player.removePotionEffect(PotionEffectType.REGENERATION);
     }
   }
 }
예제 #20
0
 public static void end(final Player player) {
   if (Main.getInstance().getConfig().getBoolean("variable.EnableConfusionEffect")) {
     player.removePotionEffect(PotionEffectType.CONFUSION);
   }
   PlayerMoveListener.getInTPProcess().remove(player.getName()).cancel();
   Main.getInstance()
       .getServer()
       .getScheduler()
       .scheduleSyncDelayedTask(
           Main.getInstance(),
           new Runnable() {
             @Override
             public void run() {
               if (!PlayerMoveListener.getInTPProcess().containsKey(player.getName())) {
                 TeleportationTask.noFallDamage.remove(player.getName());
               }
             }
           },
           20);
 }
예제 #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));
    }
  }
예제 #22
0
  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);
  }
예제 #23
0
 @Override
 public void onDisable() {
   if (output) {
     console.sendMessage(prefix + "Disabling...");
   }
   for (Player player : getServer().getOnlinePlayers()) {
     for (Player target : getServer().getOnlinePlayers()) {
       target.showPlayer(player);
     }
     if (user.get(player.getName()).spectating) {
       player.removePotionEffect(PotionEffectType.HEAL);
       player.setAllowFlight(false);
       player.setGameMode(getServer().getDefaultGameMode());
       player.getInventory().clear();
       if (scoreboard) {
         team.removePlayer(player);
       }
       loadPlayerInv(player);
       spawnPlayer(player);
       user.get(player.getName()).spectating = false;
     }
   }
 }
예제 #24
0
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerJoinEvent(PlayerJoinEvent e) {
    e.setJoinMessage("");
    Player p = e.getPlayer();
    Game.players.add(p.getUniqueId());
    p.setHealth(20.0);
    p.setExp(0);
    ChatUtilities.broadcast(e.getPlayer().getDisplayName() + " has joined!");
    p.removePotionEffect(PotionEffectType.INVISIBILITY);
    p.setGameMode(GameMode.ADVENTURE);
    p.getInventory().clear();
    p.getInventory().setHelmet(null);
    Game.setCanStart(Bukkit.getOnlinePlayers().size() >= 2);
    LocationUtilities.teleportToLobby(p);

    CraftPlayer craftplayer = (CraftPlayer) p;
    PlayerConnection connection = craftplayer.getHandle().playerConnection;
    IChatBaseComponent header = ChatSerializer.a("{\"text\": \"   §3Villager Hunt   \"}");
    IChatBaseComponent footer = ChatSerializer.a("{\"text\": \"   §4Development Test   \"}");
    PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter();

    try {
      Field headerField = packet.getClass().getDeclaredField("a");
      headerField.setAccessible(true);
      headerField.set(packet, header);
      headerField.setAccessible(!headerField.isAccessible());

      Field footerField = packet.getClass().getDeclaredField("b");
      footerField.setAccessible(true);
      footerField.set(packet, footer);
      footerField.setAccessible(!footerField.isAccessible());
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    connection.sendPacket(packet);
  }
예제 #25
0
 public static void removeEffects(final Player player) {
   for (PotionEffect pe : player.getActivePotionEffects()) {
     player.removePotionEffect(pe.getType());
   }
 }
예제 #26
0
 public void setUnscoped(Player player, PlayerDataClass playerData) {
   playerData.setScoped(false);
   player.removePotionEffect(PotionEffectType.SLOW);
   player.setWalkSpeed((float) 0.25);
 }
예제 #27
0
  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);
  }
예제 #28
0
 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();
 }
예제 #29
0
 public void removeAllEffects(Player player) {
   for (PotionEffect effect : player.getActivePotionEffects()) {
     player.removePotionEffect(effect.getType());
   }
 }
 public void removeBuff(Player player) {
   if (getTarget().equals("player")) {
     player.removePotionEffect(PotionEffectType.SLOW_DIGGING);
   }
 }