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

1vs1 and TicTacToe reward

Discussion in 'Plugin Help' started by WylSmart, May 30, 2020.

  1. WylSmart

    WylSmart Slime

    Messages:
    93
    help me add reward money plugins 1vs1 and TicTacToe: >> EconomyAPI

    Win Player : 1vs1
    PHP:
    declare(strict_types=1);

    namespace 
    vixikhd\onevsone\event;

    use 
    pocketmine\event\plugin\PluginEvent;
    use 
    pocketmine\Player;
    use 
    vixikhd\onevsone\arena\Arena;
    use 
    vixikhd\onevsone\OneVsOne;

    /**
     * Class PlayerArenaWinEvent
     * @package onevsone\event
     */
    class PlayerArenaWinEvent extends PluginEvent {

        
    /** @var null $handlerList */
        
    public static $handlerList = \null;

        
    /** @var Player $player */
        
    protected $player;

        
    /** @var Arena $arena */
        
    protected $arena;

        
    /**
         * PlayerArenaWinEvent constructor.
         * @param OneVsOne $plugin
         * @param Player $player
         * @param Arena $arena
         */
        
    public function __construct(OneVsOne $pluginPlayer $playerArena $arena) {
            
    $this->player $player;
            
    $this->arena $arena;
            
    parent::__construct($plugin);
        }

        
    /**
         * @return Player $player
         */
        
    public function getPlayer(): Player {
            return 
    $this->player;
        }

        
    /**
         * @return Arena $arena
         */
        
    public function getArena(): Arena {
            return 
    $this->arena;
        }
    }
    Win Player : TicTacToe
    PHP:
        public function end(?int $winnerPlayerID null): bool{
            if(!
    $this->active){
                return 
    false;
            }
            foreach(
    $this->players as $playerData){
                
    $playerData[0]->getInventory()->clearAll();
            }
            if(
    $winnerPlayerID === null){ //draw
                
    foreach($this->players as $playerData){
                    
    $playerData[0]->sendMessage("Draw!");
                }
            }else{
                
    $this->players[$winnerPlayerID][0]->sendMessage("You won!");
                
    $this->players[$this->getOpponent($winnerPlayerID)][0]->sendMessage("You lost!");
            }
            
    $this->active false;
            
    $this->arena->deOccupy($this);
            
    $this->arena->getMain()->getPlayerManager()->onGameEnd($this);
            
    $this->arena null;
            
    $this->players null;
            return 
    true;
        }
    }
     
  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.