Removing Potion Effects

Discussion in 'Plugin Development' started by CoderRevolq, Mar 14, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    CoderRevolq

    How do I clear a players WHOLE inventory, because when I do
    p.getInventory().clear();
    it clears the inventory, but the potions are still there, how do I remove the potions?
    In this code, where would I add the clear potion effects code?


    if (commandLabel.equalsIgnoreCase("spawn")) {
    //Check to see if the spawn has been set or not
    if (getConfig().getConfigurationSection("spawn") == null) {
    p.sendMessage(ChatColor.RED + "The spawn has not been set yet!");
    return true;
    }
    //Get the data from the string: spawn - and teleport the player to it
    World world = Bukkit.getServer().getWorld(getConfig().getString("spawn.world"));
    double x = getConfig().getDouble("spawn.x");
    double y = getConfig().getDouble("spawn.y");
    double z = getConfig().getDouble("spawn.z");
    p.getInventory().clear();
    p.teleport(new Location(world, x, y, z));
    p.playSound(p.getLocation(), Sound.ORB_PICKUP, 10, 1);
    p.sendMessage(ChatColor.GRAY + "Teleported to " + ChatColor.AQUA + "Spawn");
    }
     
  2. Offline

    Compressions

    CoderRevolq
    Code:
    for(PotionEffect pe : p.getActivePotionEffects()) {
    p.removePotionEffect(pe.getType());
    }
     
  3. Offline

    The Fancy Whale

    CoderRevolq Also please next time use
    (Make it easy on the eyes)
    Code:
     [syntax=java]//code here[/syntax]
     
Thread Status:
Not open for further replies.

Share This Page