Dual Compass Targets

Discussion in 'Plugin Development' started by ccrama, Nov 9, 2013.

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

    ccrama

    Hello Bukkit,
    I have two compasses in my inventory. I want to set each compass to point to a different location, but
    Code:java
    1. player.setCompassTarget(new Location(blah);
    would set both of them to the same target. Is there a way to set both compasses to point to DIFFERENT targets? That would be awesome! I am thinking there must be a way to create a variable for each compass, possibly set different byte data for each, and check if that compass has the specific data, then set the location.

    Thanks for the help,
    ccrama
     
  2. Offline

    Seadragon91

    I thin you could set item metas info, example the display name and then use the PlayerItemHeldEvent get the current item at the slot, check the display name and set the location.
     
  3. Offline

    ccrama

    Seadragon91, is it possible to set two different locations? Would I do something like
    Code:java
    1. for(Player player : Bukkit.getOnlinePlayers()){
    2. player.getItem().getItemStack().getItemMeta().getDisplayName().contains("COMPASS 1")){
    3. player.setCompassTarget(new Location(blah);
    4. }
     
  4. Offline

    Seadragon91

    I think that should work, because you change the compass location from different players.
    Edit: Fixed your code
    Code:
    for(Player player : Bukkit.getOnlinePlayers()){
        if (player.getItem().getItemStack().getItemMeta().getDisplayName().contains("COMPASS 1")) {
            player.setCompassTarget(new Location(blah);
        }
    }
     
  5. Offline

    RealDope

    No, players can only have one compass target and all compasses in their inventory will have that target.
     
  6. Offline

    Seadragon91


    I think that you are right, but he could make compasses with different display name and over the listener he could change the location of the selected compass based on the display name.
     
  7. Offline

    ccrama

  8. Offline

    dillyg10

    No, you can only have 1 compas target per player.
     
  9. Offline

    RealDope

    I don't understand what you guys are even trying to do..

    You can't set locations for individual compasses... Just look at the method, you call it on a player object. Detecting what compass it is using name is all fine and dandy, but what are you going to do past that?
     
  10. Offline

    ccrama

    RealDope I realize now what you are saying, and you are right. I really need two different compasses, though. Would it be possible to reskin the clock as a compass, then set the clock time to a degree measure, pseudo making a compass?

    If this is too complicated, I might just make a hit compass to switch directions function.
     
Thread Status:
Not open for further replies.

Share This Page