How to detect if a player has activated a certain pressure plate in a minigame?

Discussion in 'Spigot Plugin Help' started by tntcreeperking, May 14, 2016.

  1. Hi,

    This is a difficult one to ask and explain what I am after, (But I'll try)

    My question is, how can I detect if a player has hit a pressure plate or possibly, create a new type of pressure plate or block that will count up points (or coins).

    Essentially my minigame is Sonic Dash which I created ages ago and posted on the Minecraft Forum, I would now like to make a plugin so you can play together on my server. The problem is, how can I get it so that when a player touches a golden pressure plate, it adds a coin, if they run into a grey wool block, they loose there coins (or they die if they have 0 coins), etc. It's difficult to explain but I am very much beginner but there isn't any good tutorials out there that explains this kind of stuff.

    Edit: I don't know how to add events and make them get checked when a command is run, for example, the only command I have at the minute is /sdtest which teleports you to test the map. When the player runs a command, I want to be checking for something and then when they finish it stops checking

    Thanks,
    Dan
     
    #1 tntcreeperking, May 14, 2016
    Last edited: May 14, 2016
  2. Check for the PlayerInteractEvent and the action type is Action.PHYSICAL for pressure plates
     
  3. Thanks, but I didn't make this clear (So I apologise), How do I add this event so that it is being checked all the time, I don't know how I make this an event that is checked when they run a specific command or something. At the minute, the only main command I have is /sdtest which essentially teleports you, plays the music and let's you test the map.
     
  4. wow4201

    Patron

    "How do I add this event so that it is being checked all the time"

    Events are run when the trigger happens.
    In this case when a player touches a pressure plate.

    This event is being checked everytime it needs to be checked.

    Here is an example of checking this event
    http://hastebin.com/iqumakugec.java
     
    • Agree Agree x 1
  5. He is right
     
  6. Use the cords of the pressure plate, I think this will work

    nvm I don't think you can do that.
     
    #6 Hamsterz_, May 18, 2016
    Last edited by a moderator: May 22, 2016
  7. You can, but it is inefficient