If player teleport to a world named pvp

Discussion in 'Plugin Development' started by wydgabriel, Jan 19, 2014.

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

    wydgabriel

    Hello guys
    I know that is a noob question but what is the code to verify if the player teleported to a world named ''pvp''?
    Is the PlayerTeleportEvent?
    Thanks for the help!
     
  2. Offline

    Chinwe

  3. Offline

    wydgabriel

    Still not getting the right code to do what i want
     
  4. Offline

    Chinwe

    What are you trying? It should be a simple:
    Code:
    @EventHandler
    public void onWorldChange(PlayerChangedWorldEvent event)
    {
        if (event.getPlayer().getWorld().getName().equals("pvp"))
        { ... }
    }
     
  5. Offline

    wydgabriel

    Now i got another problem.
    My ''if''
    I got a lot of if if if if , but one ''if'' is being ignored, the first one, look :

    Code:
     if ((e.getTo().getWorld().getName().equalsIgnoreCase("arenaprin2"))  &&  (e.getPlayer().getEquipment().getBoots().getType()==Material.DIAMOND_BOOTS) || (e.getPlayer().getEquipment().getBoots().getType()==Material.GOLD_BOOTS) || (e.getPlayer().getEquipment().getBoots().getType()==Material.IRON_BOOTS)
                || (e.getPlayer().getEquipment().getBoots().getType()==Material.LEATHER_BOOTS) || (e.getPlayer().getEquipment().getLeggings().getType()==Material.LEATHER_LEGGINGS) || (e.getPlayer().getEquipment().getLeggings().getType()==Material.GOLD_LEGGINGS)
                || (e.getPlayer().getEquipment().getLeggings().getType()==Material.IRON_LEGGINGS)
                || (e.getPlayer().getEquipment().getLeggings().getType()==Material.DIAMOND_LEGGINGS)
                || (e.getPlayer().getEquipment().getChestplate().getType()==Material.LEATHER_CHESTPLATE)
                || (e.getPlayer().getEquipment().getChestplate().getType()==Material.IRON_CHESTPLATE)
                || (e.getPlayer().getEquipment().getChestplate().getType()==Material.GOLD_CHESTPLATE)
                || (e.getPlayer().getEquipment().getChestplate().getType()==Material.DIAMOND_CHESTPLATE)
                || (e.getPlayer().getEquipment().getHelmet().getType()==Material.LEATHER_HELMET)
                      || (e.getPlayer().getEquipment().getHelmet().getType()==Material.GOLD_HELMET)
                      || (e.getPlayer().getEquipment().getHelmet().getType()==Material.IRON_HELMET) || (e.getPlayer().getInventory().contains(new ItemStack(Material.DIAMOND_CHESTPLATE)))
              || (e.getPlayer().getInventory().contains(new ItemStack(Material.DIAMOND_HELMET))) 
                || (e.getPlayer().getInventory().contains(new ItemStack(Material.DIAMOND_LEGGINGS)))
                || (e.getPlayer().getInventory().contains(new ItemStack(Material.DIAMOND_BOOTS)))
                || (e.getPlayer().getInventory().contains(new ItemStack(Material.GOLD_CHESTPLATE)))
                || (e.getPlayer().getInventory().contains(new ItemStack(Material.GOLD_LEGGINGS)))
                || (e.getPlayer().getInventory().contains(new ItemStack(Material.GOLD_BOOTS))
              || (e.getPlayer().getInventory().contains(new ItemStack(Material.GOLD_HELMET)))
                || (e.getPlayer().getInventory().contains(new ItemStack(Material.IRON_HELMET)))
                || (e.getPlayer().getInventory().contains(new ItemStack(Material.IRON_LEGGINGS)))
                || (e.getPlayer().getInventory().contains(new ItemStack(Material.IRON_CHESTPLATE)))
    || (e.getPlayer().getInventory().contains(new ItemStack(Material.IRON_BOOTS)))   
                          || (e.getPlayer().getInventory().contains(new ItemStack(Material.LEATHER_HELMET)))
                || (e.getPlayer().getInventory().contains(new ItemStack(Material.LEATHER_LEGGINGS)))
                || (e.getPlayer().getInventory().contains(new ItemStack(Material.LEATHER_CHESTPLATE)))
    || (e.getPlayer().getInventory().contains(new ItemStack(Material.LEATHER_BOOTS))) ))        {
    This if ((e.getTo().getWorld().getName().equalsIgnoreCase("arenaprin2")) is being ignored if some of another if's happen, but why?
    I want to this first if ((e.getTo().getWorld().getName().equalsIgnoreCase("arenaprin2")) always being checked if some of the another ifs happen.
    If you dont understood, ask me and i try to explain :D
    Thanks
     
  6. Offline

    morshu9001

    No offense, but you really shouldn't have an if statement that huge. I can't really look at it and tell what the problem is. Why not make a method that checks if the player is wearing armor and call that instead of a big chain of "or"s and "and"s every time? You could also set up a static ItemStack for those items instead of allocating new ones every time, which wastes RAM and CPU.
     
  7. Offline

    wydgabriel

    Yo relax, I got it, I made another way, easier and lightweight :D
     
  8. Offline

    CraftBang

    You can shorten this : e.getPlayer().getEquipment().getBoots().getType()

    First make this check : if (e.getTo().getWorld().getName().equalsIgnoreCase("arenaprin2"){



    }
    After that make in that another if with the leather stuff.
    So if its not arenaprin2 than it won't do a sh!t :)
     
Thread Status:
Not open for further replies.

Share This Page