1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Code for SW Cages?

Discussion in 'Development' started by A354-PH, Oct 19, 2018.

  1. A354-PH

    A354-PH Baby Zombie

    Messages:
    186
    GitHub:
    Kizu
    Hey guys! I need the code for SW Cages! The code should have the ff.
    - Remove when the game has started
     
  2. RedCraftPM

    RedCraftPM Spider

    Messages:
    8
    GitHub:
    redcraftgh
    Can you show what you have already tried--if you have tried anything? I am not going to outright give you the code unless you at least attempt it on your own.

    However, I can guide you in the right direction:
    You could build the cages when the plugin is enabled using setBlock() and then teleport players into the cages and setImmobile() when they join the game. Then when you would like the game to start you could use setBlock() to remove the cages around the players and use setImmobile() again to allow them to move, and when the game ends you can use setBlock to rebuild the cages in the locations you would like them to be.
     
  3. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    P.S. Because setImmobile() at it's current stage disables movement only client-sided, you will need to write a small PlayerMoveEvent handler.
    PHP:
    public function onMove(PlayerMoveEvent $event){
        if(
    $event->getPlayer()->isImmobile() && !$event->getTo()->equals($event->getFrom())){
            
    $event->setCancelled();
        }
    }
     
  4. A354-PH

    A354-PH Baby Zombie

    Messages:
    186
    GitHub:
    Kizu
    How to use the setBlock() and setImmobile()?
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.