Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.94 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. _ ___ _
  5. | | / (_) | |
  6. | |/ / _ ___ ___| | _____ __
  7. | \| / __|/ _ \ |/ _ \ \ / /
  8. | |\ \ \__ \ __/ | __/\ V /
  9. \_| \_/_|___/\___|_|\___| \_/
  10.  
  11. */
  12. namespace Kiselev;
  13.  
  14. use pocketmine\event\Listener;
  15. use pocketmine\plugin\PluginBase;
  16. use pocketmine\command\Command;
  17. use pocketmine\command\CommandSender;
  18. use pocketmine\event\player\PlayerInteractEvent;
  19. use pocketmine\utils\Config;
  20. use pocketmine\scheduler\CallbackTask;
  21. use pocketmine\plugin\Plugin;
  22. use pocketmine\level\particle\FloatingTextParticle;
  23. use pocketmine\level\Level;
  24. use pocketmine\math\Vector3;
  25. use pocketmine\event\block\BlockBreakEvent;
  26. use pocketmine\event\player\PlayerPreLoginEvent;
  27. use pocketmine\event\player\PlayerJoinEvent;
  28. use pocketmine\level\Position;
  29. use pocketmine\Server;
  30. use _64FF00\PurePerms\PurePerms;
  31. use onebone\economyapi\EconomyAPI;
  32.  
  33. class Main extends PluginBase implements Listener
  34. {
  35.  
  36. public $config;
  37. public $PurePerms;
  38. public $eco;
  39. public $check;
  40. public $c;
  41.  
  42. public function onEnable()
  43. {
  44. $this->getServer()->getPluginManager()->registerEvents($this, $this);
  45. $this->getLogger()->info("§6DonateCase §1успешно запущен!");
  46. $this->eco = $this->getServer()->getPluginManager()->getPlugin('EconomyAPI');
  47. $this->PurePerms = $this->getServer()->getPluginManager()->getPlugin("PurePerms");
  48. $this->check = true;
  49. $this->stop = false;
  50. @mkdir($this->getDataFolder());
  51. $this->config = new Config($this->getDataFolder() . "Config.yml", Config::YAML);
  52. }
  53.  
  54. public function onCommand(CommandSender $s, Command $c, $label, array $args)
  55. {
  56. switch ($c->getName()) {
  57. case "mykeys":
  58. $s->sendMessage("§eТвои ключи от кейса: §a".$this->config->get($p->getName()));
  59. break;
  60.  
  61. case "setdc":
  62. if (!$s->hasPermission("set.dc")) {
  63. $s->sendMessage("У тебя нет прав!");
  64. } else {
  65. if ($this->config->get("pos") == null) {
  66. $this->config->setNested("pos.x", $s->getFloorX());
  67. $this->config->setNested("pos.y", $s->getFloorY());
  68. $this->config->setNested("pos.z", $s->getFloorZ());
  69.  
  70. $this->config->setNested("tag-pos.x", $s->getFloorX() + 0.5);
  71. $this->config->setNested("tag-pos.y", $s->getFloorX() + 2);
  72. $this->config->setNested("tag-pos.z", $s->getFloorX() + 0.5);
  73.  
  74. $s->sendTitle("Сундук поставлен!");
  75. $s->getLevel->addParticle(new FloatingTextParticle(new Vector3($s->getFloorX() + 0.5, $s->getFloorY() + 2, $s->getFloorZ() + 0.5), "", "Донат Кейс"));
  76. $this->config->save();
  77. } else {
  78. $s->sendTitle("Сундук установлен ранее");
  79. }
  80. }
  81. break;
  82. case "givekey":
  83. if ($s->hasPermission(give.key)) {
  84. $s->sendMessage("Нет прав для выполния данной команды!");
  85. } else {
  86. if (!isset($args[0])) {
  87. $s->sendMessage("Использование: /givekey <количество> [ник]");
  88. }
  89. if (isset($args[0])) {
  90. if (isset($args[1])) {
  91. $this->config->set($s->getName(), $args[0]);
  92. $s->sendMessage("Ты получил ключи в размере {$args[0]}");
  93. $this->config->save();
  94. }
  95. if (isset($args[1])) {
  96. $p = $this->getServer()->getPlayer($args[1]);
  97. $this->config->set($p->getName(), $args[0]);
  98. $s->sendMessage("Ты выдал игроку {$p->getName()} ключи в размере {$args[0]}");
  99. $p->sendMessage("Тебе выдали ключи для кейса в размере {$args[0]}");
  100. $this->config->save();
  101. }
  102. }
  103. }
  104. break;
  105. }
  106. }
  107.  
  108. public function oChest(PlayerInteractEvent $event)
  109. {
  110. $p = $event->getPlayer();
  111. $n = $p->getName();
  112. $b = $event->getBlock();
  113. $id = $b->getId();
  114. $x = $this->config->getNested("pos.x");
  115. $y = $this->config->getNested("pos.y");
  116. $z = $this->config->getNested("pos.z");
  117. if ($id == 130) {
  118. if ($b->getFloorX() == $x && $b->getFloorY() == $y && $b->getFloorZ() == $z) {
  119. $event->setCancelled();
  120. if (!$this->check) {
  121. $p->sendMessage("Донат кейс занят");
  122. return;
  123. }
  124. if ($this->config->get($p->getName()) == 0) {
  125. $p->sendMessage("Нет ключей для открытия");
  126. } else {
  127. $this->check = false;
  128. $this->config->set($p->getName(), $this->config->get($p->getName()) - 1);
  129. $this->config->save();
  130. unset($this->c[$p->getName()]);
  131. $p->sendPopup("Открываем");
  132. $this->stop = false;
  133. $rand = mt_rand(0, 99);
  134. // 10 тысяч игровых 25%
  135. if ($rand >= 0 and 24 >= $rand) {
  136. $p->addTitle("Тебе выпало 10к");
  137. $this->eco->addMoney($p, "10000");
  138. $this->getServer()->broadcastMessage("Игроку $p выпали деньги");
  139. // Флай 20%
  140. } elseif ($rand >= 24 && 44 >= $rand) {
  141. $p->addTitle("Тебе выпал Флай");
  142. $this->PurePerms->getUserDataMgr()->setGroup($p, Fly);
  143. $this->getServer()->broadcastMessage("Игроку $p выпал донат Флай");
  144. // Бог 18%
  145. } elseif ($rand >= 44 && 62 >= $rand) {
  146. $p->addTitle("Тебе выпал Бог");
  147. $this->PurePerms->getUserDataMgr()->setGroup($p, Bog);
  148. $this->getServer()->broadcastMessage("Игроку $p выпал донат Бог");
  149. // Вип 15%
  150. } elseif ($rand >= 62 && 77 >= $rand) {
  151. $p->addTitle("Тебе выпал Vip");
  152. $this->PurePerms->getUserDataMgr()->setGroup($p, Vip);
  153. $this->getServer()->broadcastMessage("Игроку $p выпал донат Вип");
  154. //Гриф 10%
  155. } elseif ($rand >= 77 && 87 >= $rand) {
  156. $p->addTitle("Тебе выпал Гриф");
  157. $this->PurePerms->getUserDataMgr()->setGroup($p, Grif);
  158. $this->getServer()->broadcastMessage("Игроку $p выпал донат Гриф");
  159. //Креатив 8%
  160. } elseif ($rand >= 87 && 95 >= $rand) {
  161. $p->addTitle("Тебе выпал Креатив");
  162. $this->PurePerms->getUserDataMgr()->setGroup($p, Creative);
  163. $this->getServer()->broadcastMessage("Игроку $p выпал донат Креатив");
  164. //Ультра 3%
  165. } elseif ($rand >= 95 && 98 >= $rand) {
  166. $p->addTitle("Тебе выпал Ультра");
  167. $this->PurePerms->getUserDataMgr()->setGroup($p, Ultra);
  168. $this->getServer()->broadcastMessage("Игроку $p выпал донат Ультра");
  169. // Админ 1%
  170. } elseif ($rand >= 98 && 99 >= $rand) {
  171. $p->addTitle("Тебе выпал Админ");
  172. $this->PurePerms->getUserDataMgr()->setGroup($p, Admin);
  173. $this->getServer()->broadcastMessage("Игроку $p выпал донат Админ");
  174. }
  175. }
  176. }
  177. }
  178. }
  179.  
  180. public function preLogin(PlayerPreLoginEvent $e)
  181. {
  182. $n = $e->getPlayer()->getName();
  183. if ($this->config->get($n) == null) {
  184. $this->config->set($n, 0);
  185. $this->config->save();
  186. }
  187. }
  188.  
  189. public function onJoin(PlayerJoinEvent $e)
  190. {
  191. $p = $e->getPlayer()->getName();
  192. $x = $this->config->getNested("tag-pos.x");
  193. $y = $this->config->getNested("tag-pos.y");
  194. $z = $this->config->getNested("tag-pos.z");
  195. $p->getLevel()->addParticle(new FloatingTextParticle(new Vector3($x, $y, $z), "", "Донат кейс"));
  196. }
  197. public function ChestBreak(BlockBreakEvent $e)
  198. {
  199. $p = $e->getPlayer();
  200. $x = $this->config->getNested("pos.x");
  201. $y = $this->config->getNested("pos.y");
  202. $z = $this->config->getNested("pos.z");
  203. if ($e->getBlock()->getId() == 54) {
  204. if ($e->getBlock()->getX() == $x && $e->getBlock()->getY() == $y && $e->getBlock()->getZ() == $z) {
  205. if (!$p->hasPermission("breake.chest")) {
  206. $e->setCancelled();
  207. $p->sendMessage("Ты не можешь ломать этот сундук");
  208. }
  209. }
  210. }
  211. }
  212. public function onDisable(){
  213. $this->config->save();
  214. }
  215. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement