Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Measure inAirTicks IN PLUGIN?

Comments in 'Plugin Development' started by Legoboy0215, Jan 30, 2016.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Is there any possible way to do that? I am currently making an Anti-Cheat plugin.
  2. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Why dont you check it on PlayerMoveEvent with getting the block under the player?
  3. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    what if the player jumps?
  4. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    You can check if the player flies:
    PHP:
    public $AirState = [];


    public function 
    onMove(PlayerMoveEvent $event){
    $player $event->getPlayer();
    if(
    $this->getServer()->getBlockIdAt($player->x$player->1$player->z) == 0){
    if(
    in_array($this->AirState$player->getName()){
    $this->AirState[$player->getName()] = $this->AirState[$player->getName] + 1;
    if(
    $this->AirState[$player->getName()] > 60 /* 3 seconds */){
    $player->kick("Flying to allowed.");
    unset(
    $this->AirState[$player->getName()];
    }else{
    $this->AirState[$player->getName()] = 1;
    }
    }else{
    if(
    in_array($this->AirState$player->getName()){
    unset(
    $this->AirState[$player->getName()];
    }
    }



    You could also use a scheduler to check if the player doesnt move but is in the air.
  5. Thunder33345
    Offline

    Thunder33345 Notable Member

    Joined:
    Apr 3, 2014
    Posts:
    755
    Minecraft User:
    Thunder33345
    well cnat you check how long it is in air and only kick it if it is in air for X sec?
  6. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Thats what it does in my posted code
  7. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Do you what is inAirTick? I am not making an Anti-Fly plugin.
    PEMapModder and applqpak like this.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Do you mean to overwrite the server's mechanism for measuring inAirTicks?
  9. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    I just want to get inAirTicks of a player so I can calculate 'stuff'.
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Create an issue/pull request on the PocketMine repo for adding its getter.
    Legoboy0215 likes this.
  11. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    I love the way you said "getter" :p And yes, thanks for the advice ;)
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    That's the professional term.
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    If you really use your brain, you would realize that your method is unreliable that:
    1. It will not increment if player is stationary mid-air.
    2. It rounds down the coordinates, so flying 0.5 block above ground would not be counted.
    3. https://php.net/in-array check the correct usage.
    4. There is something called the increment operator.
    5. It is a waste of resources to try to count that yourself while PocketMine already does that.

    Although hacky, using reflections is at least more reliable than your one.
  14. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Its a temporary way to get it then.

Share This Page

Advertisement