Parkour Plugin Help

Discussion in 'Plugin Development' started by GeorgeeeHD, Oct 25, 2014.

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

    GeorgeeeHD

    I need help on making the most efficient way to detect if a player goes off of the course. Getting their Y axis is not good as the parkour has different elevations. I thought of having a List<Material> allowedMaterials and in there are the blocks that are allowed to be stepped on in the parkour eg glowstone and emerald blocks, but if they were to go in for example water, as its not in the list it teleports them back to the start.

    With one parkour map, there a glowstone pathway across water like this. If they jump from one glowstone to another, there is water underneath them so it sends them back. An easy fix would be to make the glowstone pillars 1 higher, but I want to know how I could do it if that fix was not acceptable.
     
  2. GeorgeeeHD I did something like this and it worked, may you show me the code?
     
  3. Offline

    Googlelover1234

    Although it probably isn't the most efficient, a PlayerMoveEvent probably won't lag you too much... that is, if your server isn't busy.

    You could even make it so it will only check for a PlayerMoveEvent if they right clicked a villager like in Mineplex, or if they used a specific warp. That probably won't slow down the server at all, but like I said, it depends on how many players are doing it.

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

    GeorgeeeHD

    Googlelover1234
    Well yeah xD But that doesn't really answer the question :S
     
  5. Offline

    Googlelover1234

    GeorgeeeHD
    Yeah, I must be blind. Didn't read the rest, let me think about it.
     
  6. Offline

    teej107

  7. Offline

    GeorgeeeHD

    Code:java
    1. @EventHandler(priority = EventPriority.NORMAL)
    2. public void onMove(PlayerMoveEvent e) {
    3.  
    4. Player p = e.getPlayer();
    5.  
    6. if(eventUtils.getCurrentEvent() != null && eventUtils.getCurrentEvent().getType() == EventType.DEATH_RUN) {
    7. if (eventUtils.isStarted()) {
    8. if (eventUtils.getAllPlayersInEvent().contains(p.getName())) {
    9.  
    10. if(eventUtils.getDeathRunArenaType().getFinishBlock() == p.getLocation().getBlock().getRelative(BlockFace.DOWN).getType()) {
    11. eventUtils.getCurrentEvent().endEvent(p);
    12. return;
    13. }
    14.  
    15. if(eventUtils.getDeathRunArenaType().getAllowedBlocks().contains(p.getLocation().getBlock().getRelative(BlockFace.DOWN).getType())) return;
    16.  
    17. p.teleport(eventUtils.getDeathRunArenaType().getSpawnLocation());
    18. p.setFireTicks(0);
    19.  
    20. }
    21. }
    22. }
    23.  
    24. }


    teej107 ^
    (didn't edit post cos it messes up formatting)
    If you have any questions on what my methods do just ask, but they should be self-explanatory

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

    Googlelover1234

    Even though I am horrible with block manipulation, you could try the WorldEdit API, and do it somewhat like that.
     
  9. Offline

    teej107

    In your last if statement, just check the player's location rather than the block's relative location.

    Btw PHP code tag doesn't remove spaces if you edit the post.
     
Thread Status:
Not open for further replies.

Share This Page