Cant see why this isn't working..

Discussion in 'Plugin Development' started by dxwarlock, Sep 12, 2012.

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

    dxwarlock

    I cannot see why this isnt firing..everything lines up
    I transfer to the end..I get the message from 'player.sendMessage(worldin);' as 'world_the_end' in chat.

    but the 'test' message never shows..
    and the code RIGHT below that tells me what world im in..is checking a string to a string...
    anyone see whats wrong?

    Code:
        @EventHandler(priority=EventPriority.LOWEST, ignoreCancelled=true)
        public void onWorldChange(PlayerChangedWorldEvent event){
            Player player = event.getPlayer();
            String worldin = player.getWorld().getName();       
            //player.sendMessage(formatMessage(plugin.config.getString("worlds." + worldin + ".message"), player));       
            player.sendMessage(worldin);
            if (worldin == "world_the_end") {
                World end = player.getWorld();
                player.sendMessage("TEST");
                Location loc = new Location(end, 0.0, 64.0, 0.0);
                player.teleport(loc);
            }
        }
     
  2. Offline

    Sabersamus

    if(worldin.equalsIgnorecase("world_the_end")){

    Try that, do not compare strings with ==
     
  3. Offline

    dxwarlock

    ahh Ill try that, thanks.

    That did it!
    that was driving me crazy..thanks a ton.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  4. Offline

    Sabersamus

    if you are gonna use ==, use

    if(worldin == new String("world_the_end")){

    that or .equals(new String("world_the_end")){

    .equalsIgnoreCase() is better anyways :p
     
Thread Status:
Not open for further replies.

Share This Page