Detect if a player is standing on a certain block in a certain location set in the config?

Discussion in 'Plugin Development' started by FoxinatorDev, Nov 23, 2017.

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

    FoxinatorDev

    How do I detect if a player is standing on a certain block in a certain location set in the config? Config:
    Code:
    Teleporters:
      '1':
        Loc:
          World: world
          X: 46
          Y: 76
          Z: 574
      '2':
        Loc:
          World: world
          X: 54
          Y: 78
          Z: 574
    
    Code: https://pastebin.com/GkpF0Swp If you need anything else, I will give to you.


    Im also using id's to save the teleporters
     
  2. Offline

    MightyOne

    @FoxinatorDev use pressure plates. thats easier xD.
    Otherwise compare the single block-coordinates of the players location with the coordinates in the config.
     
    Last edited: Nov 23, 2017
  3. Offline

    Shxke

    Why would you use pressure plates when you can code java? It makes no sense, especially if you're trying to make a professional server. The correct way you can do it :

    You can use a PlayerMoveEvent, or an event that detects when a player moves. Then check the player's location with p.getLocation() and check if it equals a location you created. The location you created should be the coordinates for where you want to check the player is.

    To simplify, make a PlayerMoveEvent, and check the player's location. Make a Location for the area you want to check if the player is in. Then check if the player's location is equal to the location object you just created.

    This may sound complicated, but it's really easy. I just suck at explaining :p

    Why would you use pressure plates when you can code java? It makes no sense, especially if you're trying to make a professional server.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 23, 2017
  4. Offline

    Caderape2

    @Shxke When you are a good coder, u take care about performance.
    Bukkit already check the playerMoveEvent for detect when a player walk on a pressure plate. Why you would do a duplicate method if you don't care about the 'visibility' of the teleporters ?
     
    MightyOne likes this.
  5. Offline

    Shxke

    First of all, that is rude to say. Second of all, most people like having nice custom ways to do things. I'm not saying pressure plates are bad, but not having them makes it look nicer
     
  6. Offline

    MightyOne

    Dear @Shxke,

    I recently read the comment wrote to the thread "Detect if a player is standing on a certain block in a certain location set in the config?". I really could follow your thoughts but there are some points I would like to discuss. One aspact that cought my eyes was that Foxinaor already included a paste bin link in his first post where he used the player movement event. So in my mind it is questionable if it was necessary to explain it again. One argument you gave was that professional servers use the method you mentioned as well. On one hand I can confirm that by myself as I already played on several popular servers. On the other hand I am sure that those minecraft servers also connected several servers in real life to reduce the programs running on one at the same time. Assuming Foxinator does not run such a major server system I could just recommend to think about how to reduce lag. Furthermore I do not understand why you would prefer a lot (and maybe a mess) of code if you can simplify this entire undertaking by just one pressure plate. I hope this answer was not rude at all and maybe changed your mind.

    Your sincerely
    MightyOne
     
Thread Status:
Not open for further replies.

Share This Page