Solved A way to freeze a player

Discussion in 'Plugin Development' started by Aragone, Jul 15, 2019.

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

    Aragone

    Hello there !

    I made something to check if their is an air block over the player and then, place a barrier block at its place. It runs well but, because it's a new block I think, the lantern is like an air block for java.

    So I would like to make something to reput the lantern if it was removed by an other thing than the player.

    Is it possible do you think ?

    Thanks !
     
  2. Online

    timtower Administrator Administrator Moderator

    @Aragone Define "is like an air block"
     
  3. Offline

    Kars

    What lantern? Sea lantern? It's a non solid block not an air block. If you are checking for the block to be air it should not be replaced to begin with. No need to reput.

    Sounds like you're doing something wrong.
     
  4. Offline

    Aragone

    @Kars If I say it, it's because it's true...

    @timtower In the plugin I check if there is a block of air just over the player. But Java seems to consider a lantern like an air block because the code runs.

    Here the code : https://pastebin.com/raw/uC1ZuFTy

    If I need to do all of this instructions it's because there is an animation of particle (portal). And if the player is falling when he performs the command /spawn, I need to freeze him in the air. Not by teleporting because the server is crashing (little server :'( ), but by setting a block of barrier just under and over the player.
     
  5. Online

    timtower Administrator Administrator Moderator

  6. Offline

    Aragone

  7. Online

    timtower Administrator Administrator Moderator

    Did you try to print out the block type?
     
  8. Offline

    KarimAKL

    @Aragone It seems to me like you are creating a variable with the material from the block (which is air), then setting it to a barrier block if it's air, and then setting it back to an air block if it was air before setting it to a barrier block.
    What is your desired outcome?
     
  9. Offline

    Aragone

    @timtower @KarimAKL I ditched this way to do because there are others bug. I rename this thread. In reality, I'm searching a way to freeze a player without teleporting. Do you have any Idea ? He must be freezed, even if he is in the air, water, etc...

    Any ideas ?
     
  10. Offline

    KarimAKL

    @Aragone You can check if the player is frozen, if so cancel the PlayerMoveEvent.
     
  11. Offline

    Aragone

    @KarimAKL How? I would like to freeze the player when he performs a command
     
  12. Online

    timtower Administrator Administrator Moderator

    @Aragone Have a list of frozen players, if you get a PlayerMoveEvent for a player in that list then cancel the event.
     
    KarimAKL likes this.
  13. Offline

    KarimAKL

    @Aragone If you want to make the player unable to move (X,Y,Z) but still look around; use the 'setTo(Location)' method instead of cancelling the event, then set the yaw and pitch to the 'getTo()'s yaw and pitch, and set the X, Y and Z to 'getFrom()'s X, Y and Z.
     
  14. Offline

    Aragone

    @timtower @KarimAKL I would like to freeze the player if he performs the command /spawn when he is falling for example. This is because I want to do that. So I can't check if the player is frozen. I just want to make him frozen when he performs the command /spawn.

    @KarimAKL You're talking about canceling an event. Which one ?
     
  15. Offline

    CraftCreeper6

    @Aragone
    When the player types /spawn, add them to a list.

    Using PlayerMoveEvent, check if there are any players that are moving that are in the list, if they are, cancel PlayerMoveEvent. Then, once they reach spawn, remove them from the list again.
     
  16. Offline

    Aragone

  17. Offline

    KarimAKL

    PlayerMoveEvent
    I said that you could either cancel the event, or set the location the player should be moved to, using PlayerMoveEvent#setTo(Location)
     
  18. Offline

    Aragone

    CraftCreeper6 and KarimAKL like this.
Thread Status:
Not open for further replies.

Share This Page