Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- _ ___ _
- | | / (_) | |
- | |/ / _ ___ ___| | _____ __
- | \| / __|/ _ \ |/ _ \ \ / /
- | |\ \ \__ \ __/ | __/\ V /
- \_| \_/_|___/\___|_|\___| \_/
- */
- namespace Kiselev;
- use pocketmine\event\Listener;
- use pocketmine\plugin\PluginBase;
- use pocketmine\command\Command;
- use pocketmine\command\CommandSender;
- use pocketmine\event\player\PlayerInteractEvent;
- use pocketmine\utils\Config;
- use pocketmine\scheduler\CallbackTask;
- use pocketmine\plugin\Plugin;
- use pocketmine\level\particle\FloatingTextParticle;
- use pocketmine\level\Level;
- use pocketmine\math\Vector3;
- use pocketmine\event\block\BlockBreakEvent;
- use pocketmine\event\player\PlayerPreLoginEvent;
- use pocketmine\event\player\PlayerJoinEvent;
- use pocketmine\level\Position;
- use pocketmine\Server;
- use _64FF00\PurePerms\PurePerms;
- use onebone\economyapi\EconomyAPI;
- class Main extends PluginBase implements Listener
- {
- public $config;
- public $PurePerms;
- public $eco;
- public $check;
- public $c;
- public function onEnable()
- {
- $this->getServer()->getPluginManager()->registerEvents($this, $this);
- $this->getLogger()->info("§6DonateCase §1успешно запущен!");
- $this->eco = $this->getServer()->getPluginManager()->getPlugin('EconomyAPI');
- $this->PurePerms = $this->getServer()->getPluginManager()->getPlugin("PurePerms");
- $this->check = true;
- $this->stop = false;
- @mkdir($this->getDataFolder());
- $this->config = new Config($this->getDataFolder() . "Config.yml", Config::YAML);
- }
- public function onCommand(CommandSender $s, Command $c, $label, array $args)
- {
- switch ($c->getName()) {
- case "mykeys":
- $s->sendMessage("§eТвои ключи от кейса: §a".$this->config->get($p->getName()));
- break;
- case "setdc":
- if (!$s->hasPermission("set.dc")) {
- $s->sendMessage("У тебя нет прав!");
- } else {
- if ($this->config->get("pos") == null) {
- $this->config->setNested("pos.x", $s->getFloorX());
- $this->config->setNested("pos.y", $s->getFloorY());
- $this->config->setNested("pos.z", $s->getFloorZ());
- $this->config->setNested("tag-pos.x", $s->getFloorX() + 0.5);
- $this->config->setNested("tag-pos.y", $s->getFloorX() + 2);
- $this->config->setNested("tag-pos.z", $s->getFloorX() + 0.5);
- $s->sendTitle("Сундук поставлен!");
- $s->getLevel->addParticle(new FloatingTextParticle(new Vector3($s->getFloorX() + 0.5, $s->getFloorY() + 2, $s->getFloorZ() + 0.5), "", "Донат Кейс"));
- $this->config->save();
- } else {
- $s->sendTitle("Сундук установлен ранее");
- }
- }
- break;
- case "givekey":
- if ($s->hasPermission(give.key)) {
- $s->sendMessage("Нет прав для выполния данной команды!");
- } else {
- if (!isset($args[0])) {
- $s->sendMessage("Использование: /givekey <количество> [ник]");
- }
- if (isset($args[0])) {
- if (isset($args[1])) {
- $this->config->set($s->getName(), $args[0]);
- $s->sendMessage("Ты получил ключи в размере {$args[0]}");
- $this->config->save();
- }
- if (isset($args[1])) {
- $p = $this->getServer()->getPlayer($args[1]);
- $this->config->set($p->getName(), $args[0]);
- $s->sendMessage("Ты выдал игроку {$p->getName()} ключи в размере {$args[0]}");
- $p->sendMessage("Тебе выдали ключи для кейса в размере {$args[0]}");
- $this->config->save();
- }
- }
- }
- break;
- }
- }
- public function oChest(PlayerInteractEvent $event)
- {
- $p = $event->getPlayer();
- $n = $p->getName();
- $b = $event->getBlock();
- $id = $b->getId();
- $x = $this->config->getNested("pos.x");
- $y = $this->config->getNested("pos.y");
- $z = $this->config->getNested("pos.z");
- if ($id == 130) {
- if ($b->getFloorX() == $x && $b->getFloorY() == $y && $b->getFloorZ() == $z) {
- $event->setCancelled();
- if (!$this->check) {
- $p->sendMessage("Донат кейс занят");
- return;
- }
- if ($this->config->get($p->getName()) == 0) {
- $p->sendMessage("Нет ключей для открытия");
- } else {
- $this->check = false;
- $this->config->set($p->getName(), $this->config->get($p->getName()) - 1);
- $this->config->save();
- unset($this->c[$p->getName()]);
- $p->sendPopup("Открываем");
- $this->stop = false;
- $rand = mt_rand(0, 99);
- // 10 тысяч игровых 25%
- if ($rand >= 0 and 24 >= $rand) {
- $p->addTitle("Тебе выпало 10к");
- $this->eco->addMoney($p, "10000");
- $this->getServer()->broadcastMessage("Игроку $p выпали деньги");
- // Флай 20%
- } elseif ($rand >= 24 && 44 >= $rand) {
- $p->addTitle("Тебе выпал Флай");
- $this->PurePerms->getUserDataMgr()->setGroup($p, Fly);
- $this->getServer()->broadcastMessage("Игроку $p выпал донат Флай");
- // Бог 18%
- } elseif ($rand >= 44 && 62 >= $rand) {
- $p->addTitle("Тебе выпал Бог");
- $this->PurePerms->getUserDataMgr()->setGroup($p, Bog);
- $this->getServer()->broadcastMessage("Игроку $p выпал донат Бог");
- // Вип 15%
- } elseif ($rand >= 62 && 77 >= $rand) {
- $p->addTitle("Тебе выпал Vip");
- $this->PurePerms->getUserDataMgr()->setGroup($p, Vip);
- $this->getServer()->broadcastMessage("Игроку $p выпал донат Вип");
- //Гриф 10%
- } elseif ($rand >= 77 && 87 >= $rand) {
- $p->addTitle("Тебе выпал Гриф");
- $this->PurePerms->getUserDataMgr()->setGroup($p, Grif);
- $this->getServer()->broadcastMessage("Игроку $p выпал донат Гриф");
- //Креатив 8%
- } elseif ($rand >= 87 && 95 >= $rand) {
- $p->addTitle("Тебе выпал Креатив");
- $this->PurePerms->getUserDataMgr()->setGroup($p, Creative);
- $this->getServer()->broadcastMessage("Игроку $p выпал донат Креатив");
- //Ультра 3%
- } elseif ($rand >= 95 && 98 >= $rand) {
- $p->addTitle("Тебе выпал Ультра");
- $this->PurePerms->getUserDataMgr()->setGroup($p, Ultra);
- $this->getServer()->broadcastMessage("Игроку $p выпал донат Ультра");
- // Админ 1%
- } elseif ($rand >= 98 && 99 >= $rand) {
- $p->addTitle("Тебе выпал Админ");
- $this->PurePerms->getUserDataMgr()->setGroup($p, Admin);
- $this->getServer()->broadcastMessage("Игроку $p выпал донат Админ");
- }
- }
- }
- }
- }
- public function preLogin(PlayerPreLoginEvent $e)
- {
- $n = $e->getPlayer()->getName();
- if ($this->config->get($n) == null) {
- $this->config->set($n, 0);
- $this->config->save();
- }
- }
- public function onJoin(PlayerJoinEvent $e)
- {
- $p = $e->getPlayer()->getName();
- $x = $this->config->getNested("tag-pos.x");
- $y = $this->config->getNested("tag-pos.y");
- $z = $this->config->getNested("tag-pos.z");
- $p->getLevel()->addParticle(new FloatingTextParticle(new Vector3($x, $y, $z), "", "Донат кейс"));
- }
- public function ChestBreak(BlockBreakEvent $e)
- {
- $p = $e->getPlayer();
- $x = $this->config->getNested("pos.x");
- $y = $this->config->getNested("pos.y");
- $z = $this->config->getNested("pos.z");
- if ($e->getBlock()->getId() == 54) {
- if ($e->getBlock()->getX() == $x && $e->getBlock()->getY() == $y && $e->getBlock()->getZ() == $z) {
- if (!$p->hasPermission("breake.chest")) {
- $e->setCancelled();
- $p->sendMessage("Ты не можешь ломать этот сундук");
- }
- }
- }
- }
- public function onDisable(){
- $this->config->save();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement