Equals Block and Item for CTF

Discussion in 'Plugin Development' started by surtic, Nov 21, 2011.

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

    surtic

    Hello @all,

    Im new in the Plugin Development for Bukkit and now i want to make a CTF Plugin for SimpleClans.
    But now i stand for a Problem. I have a Wool Block as Flag and want to Track it that i know who has the Flag.

    First i have think that i show when once Picks a Item up with onPlayerPickupItem but then is the Block a item and i cant equal it with my Block.



    here a code snipet from the onPlayerPickupItem()

    Code:
    for ( Clan clan : plugin.getCaptureTheFlag().getClans() ) {
    
        // HashCode form Block and Item
        event.getPlayer().sendMessage("----------");
        event.getPlayer().sendMessage("Block - " + clan.getFlag().hashCode());
        event.getPlayer().sendMessage("Item  - " + event.getItem().hashCode());
        event.getPlayer().sendMessage("----------");
     
        // One Option
        if ( clan.getFlag() == event.getItem() ) {
    
            // TODO You Have the Flag from clan.getName()
    
        }
     
        // One Option
        if ( clan.getFlag().equals(event.getItem()) ) {
    
            // TODO You Have the Flag from clan.getName()
    
        }
    
    }




    Any Idea?

    Sorry for my bad English.
     
  2. Offline

    Jogy34

    I think it should be instanceof not .equals()
     
  3. Offline

    surtic

    There is no instanceof Mehtode on the Block ore Item... ore how i must make this?

    I have testet but i cant

    if ( clan.getFlag() instanceof event.getItem() ) {
    }

    "event cannot be resolved to type"

    Anyone a Idea how i can make this? That i know witch Player has now the flag after a other on lost it? On the World has more than 3 Flags.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 21, 2016
Thread Status:
Not open for further replies.

Share This Page