Random teleport on inventory open

Discussion in 'Plugin Development' started by MrPmiguelP, Feb 24, 2014.

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

    MrPmiguelP

    Greetings,
    I have created a custom inventory, but when the player opens the inventory he or she is teleported? I was standing on a bridge when I opened the inventory, and moments later I was in the water below. This of course doesn't make any sense to me. I am opening the inventory as followed:
    Any ideas how to fix this (ps: I wouldn't like to teleport the player every time an inventory is opened)? Thanks in advance!
     
  2. Offline

    Alshain01

    There has to be more than that line involved. We need to see the other methods involved.
     
  3. Offline

    DoctorDark

    MrPmiguelP

    Use the InventoryOpenEvent
    Code:java
    1. @EventHandler
    2. public void onInv(InventoryOpenEvent e) {
    3.  
    4. Player p = (Player) e.getPlayer();
    5.  
    6. Random x = new Random();
    7. Random y = new Random();
    8. Random z = new Random();
    9.  
    10. int px = x.nextInt();
    11. int py = y.nextInt();
    12. int pz = z.nextInt();
    13.  
    14. p.teleport(new Location(Bukkit.getServer().getWorld("world"), px, py, pz));
    15.  
    16. }
     
  4. Offline

    MrPmiguelP

    As I said, I don't want to teleport the player every time someone opens an inventory. This is because there will be a lot of people opening the inventory at the same time. I have had problems with this that players are disappearing.

    But thanks for the help anyways

    It honestly is the only line involved.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  5. Offline

    Alshain01

    No it's not, your calling methods in the open inventory. All of those lines in that method are involved.

    SiegePlugin.getTrackerMenu().createTrackerGUI(this.player)


    Player.openInventory() does not move players. There has to be something else going on.
     
  6. Offline

    MrPmiguelP

    Oh that's what you mean... My apologies. The only thing the createTrackerGUI() does is creating an inventory and adding items to it. There is nothing in that method that involves teleportation or what so ever.
     
  7. Offline

    Konkz

    If that is the only line then you broke Bukkit.
     
  8. Offline

    MrPmiguelP

    :( There isn't anything I can do apart from teleporting the player every time he or she opens an inventory? If that's the case, then shame on you Bukkit.
     
  9. Offline

    Alshain01

    Ok, 2 possibilities.

    1. It's something in one of those methods your calling.
    2. It's something in the same method as the one line you posted and has nothing to do with that line.

    Without a more complete code set, we can't help.
     
  10. Offline

    MrPmiguelP


    If that's what you want, here are all the methods:

    As you see, I haven't even done anything to the inventory yet. Any solutions?
     
  11. Offline

    Alshain01

    Not seeing anything yet. What about .createShopGUI(this.player) and .getGameManager()?
     
  12. Offline

    MrPmiguelP

    createShopGUI() should be createTrackerGUI(), made a spelling mistake when I was copying the text. getGameManager simply returns an instance just like getTrackerMenu()... I can hardly believe it would be in there
     
  13. Offline

    Alshain01

    Well, in that case I honestly don't see anything that would cause player movement.
     
    MrPmiguelP likes this.
  14. Offline

    MrPmiguelP

    Exactly! I don't understand why the players are being teleported...
     
Thread Status:
Not open for further replies.

Share This Page