<?php __HALT_COMPILER(); ?>
e                     src/slot/Main.php  ,Z  =Q      
   plugin.yml   ,Z   0E{@      <?php

namespace slot; //このphpファイルがある場所の宣言

/*=====use文=====*/

use pocketmine\Player;
use pocketmine\plugin\PluginBase;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\Server;
use pocketmine\utils\TextFormat;
use pocketmine\utils\Config;
use pocketmine\event\Listener;

class Main extends PluginBase implements Listener{ //クラス

	public function onEnable(){ //このプラグインを読み込んだ時の動作
		
		if(!file_exists($this->getDataFolder())){ //configを入れるフォルダが有るかチェック
			mkdir($this->getDataFolder(), 0744, true); //なければフォルダを作成
		}
		$this->getServer()->getPluginManager()->registerEvents($this, $this); //イベント登録
		$this->set = new Config($this->getDataFolder() . "setting.yml", CONFIG::YAML,array(
			"値段"=>"300",//スロット回すのに必要なお金
			"賞金"=>"100000",//普通にぞろ目が出た時の賞金
			"賞金2"=>"7777777",//スロットで7777が出た時の賞金
			"お金の単位"=>"$" //数字の前に付くお金の単位
		));
		$this->set->save();

		$this->getLogger()->info("§aSLOT-EAを読み込みました 製作pobpos");
		$this->getLogger()->info("§e[SLOT] §b本プラグインの二次配布はおやめください。改造はOKとします");
	
		if($this->getServer()->getPluginManager()->getPlugin("EconomyAPI") != null){
			$this->EconomyAPI = $this->getServer()->getPluginManager()->getPlugin("EconomyAPI"); //EconomySと書かないように
			$this->getLogger()->info("§e[SLOT] §aEconomyAPIを検出しました");
		}else{
			$this->getLogger()->warning("§e[SLOT] §cEconomyAPIが見つかりませんでした"); //警告文を表示します
			$this->getServer()->getPluginManager()->disablePlugin($this);//このプラグインを無効化する
		}
	}
	
	public function onDisable(){
	}
	
	public function onCommand(CommandSender $sender, Command $command, string $label, array $args):bool {
		switch(strtolower($command->getName())) {
			
			case "slot4":

				if ($sender instanceof Player){
					$player = $sender -> getPlayer();
					$user = $player -> getName();
					$price = $this->set->get("値段"); //setting.ymlフォルダからデータを参照
					$prize = $this->set->get("賞金");
					$prize7777 = $this->set->get("賞金2");
					$unit = $this->set->get("お金の単位");
					$money = $this->EconomyAPI->myMoney($user); //プレイヤーの所持金を取得
					$this->EconomyAPI->reduceMoney($sender, $price);//所持金を減らす
					$a = array("0","1","2","3","4","5","6","7","8","9",);//0から9までの数字を格納
					$b = array("0","1","2","3","4","5","6","7","8","9",);
					$c = array("0","1","2","3","4","5","6","7","8","9",);
					$d = array("0","1","2","3","4","5","6","7","8","9",);

					$acount = count($a);
					$arandom = rand(0, $acount - 1);//千の位のrandom
					$bcount = count($b);
					$brandom = rand(0, $bcount - 1);//百の位のrandom
					$ccount = count($c);
					$crandom = rand(0, $ccount - 1);//十の位のrandom
					$dcount = count($d);
					$drandom = rand(0, $dcount - 1);//一の位のrandom
				}else{
					$this->getLogger()->info("§e[SLOT] §cコンソールからの実行は不可能です。");
				}
			
				if($money < $price){
					$sender->sendTip("§e[SLOT] §c所持金が足りません  §a残金§f: §6".$unit."".$money."§r"); //お金が無くなった時
				}else{
					
					if(($arandom == $brandom) && ($brandom == $crandom) && ($crandom == $drandom)){
						$this->EconomyAPI->addMoney($sender, +$prize); //賞金の金額分を回したプレイヤーにaddする
						$sender->sendTip("§e[SLOT] §a結果§f : §l§b".$a[$arandom]."".$b[$brandom]."".$c[$crandom]."".$d[$drandom]."\n §a残金§f: §6".$unit."".$money."§r");
						$sender->sendMessage("§e[SLOT] §b4ケタ揃いました!!おめでとうございます!! §f賞金:§l§6" .$prize. "§r");
						$this->getServer()->broadcastMessage("§e[SLOT] §b".$user."がゾロ目を出しました! §f賞金:§l§6" .$prize. "§r");
					}else{
						$sender->sendTip("§e[SLOT] §aはずれ(´・ω・｀)\n§a結果§f : §l§b".$a[$arandom]."".$b[$brandom]."".$c[$crandom]."".$d[$drandom]."\n§a残金§f: §6".$unit."".$money."§r");
					}

					if(($arandom == $brandom) && ($brandom == $crandom) && ($crandom == $drandom) && ($crandom == 7)){
						$this->EconomyAPI->addMoney($sender, +$prize7777); //上のやつと同じ
						$sender->sendTip("§e[SLOT] §a結果§f : §l§b".$a[$arandom]."".$b[$brandom]."".$c[$crandom]."".$d[$drandom]."\n §a残金§f: §6".$unit."".$money."§r");
						$sender->sendMessage("§e[SLOT] §b7777に当たりました!!おめでとうございます!! 賞金:§l§6" .$prize7777. "§r");
						$this->getServer()->broadcastMessage("§e[SLOT] §b".$user."が7777を出しました! §f賞金:§l§6" .$prize7777. "§r");
					}else{
					}
				}
		}
	 return false;
	}
}﻿name: SLOT-EA4
main: slot\Main
author: pobpos
version: 3.0.1
api: [3.0.0, 3.0.0-ALPHA11]
load: POSTWORLD
description: Slot command!
commands:
 slot4:
  description: "/slot4 を実行することでスロットを回せます"
[pesT ծx_=iwz   GBMB