Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace BoyFarmer;
- use pocketmine\plugin\PluginBase;
- use pocketmine\event\Listener;
- use pocketmine\event\block\BlockPlaceEvent;
- use pocketmine\math\Vector3;
- use pocketmine\block\Block;
- use pocketmine\utils\TextFormat;
- use pocketmine\Player;
- use pocketmine\item\Item;
- use pocketmine\command\Command;
- use pocketmine\command\CommandSender;
- class Main extends PluginBase implements Listener
- {
- private $mysqli_player_exists;
- private $price;
- private $mysqli;
- public function getApi() {
- return $this->getServer()->getPluginManager()->getPlugin("FactionsPro");
- }
- public function formatMessage($string) {
- return str_replace('&', '§', "&f• &c> [AMPE] $string &f•");
- }
- public function onEnable()
- {
- $this->saveDefaultConfig();
- $this->getServer()->getPluginManager()->registerEvents($this, $this);
- }
- public function onDisable()
- {
- }
- public function onCommand(CommandSender $sender, Command $command, $label, array $args)
- {
- $boyfarmer = Item::get(120, 0, 3);
- $boyfarmer->setCustomName("•Boyfarmerâ");
- if(strtolower($command->getName()) === "boyfarmer")
- {
- if(count($args) === 0)
- {
- foreach($this->getConfig()->getNested("boyfarmer.info") as $i)
- {
- $sender->sendMessage(str_replace('&', '§', $i));
- }
- return true;
- }
- if(count($args) === 1)
- {
- if($args[0] === "kup")
- {
- if($sender instanceof Player)
- {
- if($sender->getInventory()->contains(Item::get(264, 0, $this->getConfig()->getNested("boyfarmer.price.diamond"))) && $sender->getInventory()->contains(Item::get(49, 0, $this->getConfig()->getNested("boyfarmer.price.obsidian")))){
- $sender->getInventory()->removeItem(Item::get(264, 0, $this->getConfig()->getNested("boyfarmer.price.diamond")));
- $sender->getInventory()->removeItem(Item::get(49, 0, $this->getConfig()->getNested("boyfarmer.price.obsidian")));
- $sender->getInventory()->addItem($boyfarmer);
- $sender->sendMessage($this->formatMessage("&fPomyslnie kupiles Boyfarmer za " . $this->price . "$."));
- } else {
- $sender->sendMessage($this->formatMessage("&fNie stac Cie! Potrzebujesz jeszcze " . (($this->price) - $this->getMoney($sender->getName())) . "$."));
- return true;
- }
- }
- else
- {
- $sender->sendMessage("[AMPE] Blad! Musisz byc w grze.");
- return true;
- }
- }
- if($args[0] === "reload")
- {
- if($sender->hasPermission("boyfarmer.admin"))
- {
- $this->reloadConfig();
- $sender->sendMessage(TextFormat::RED . "[AMPE] Plugin zostal przeladowany.");
- return true;
- }
- else
- {
- $sender->sendMessage(TextFormat::RED . "[AMPE] Nie masz do tego uprawnien.");
- return true;
- }
- }
- }
- }
- return false;
- }
- public function onBlockPlace(BlockPlaceEvent $e)
- {
- if(!$e->isCancelled())
- {
- if($e->getPlayer()->getInventory()->getIteminHand()->getCustomName() === "•Boyfarmerâ")
- {
- $cobblex = Item::get(120, 0, 1);
- $cobblex->setCustomName("•Boyfarmerâ");
- $player = $e->getPlayer()->getName();
- $e->setCancelled(true);
- $e->getPlayer()->getInventory()->removeItem($cobblex);
- if(!$this->getApi()->inOwnPlot($e->getPlayer(), $e->getBlock()->getX(), $e->getBlock()->getZ()) && $this->getApi()->isInPlot($e->getBlock()->getX(), $e->getBlock()->getZ()) && !$e->getPlayer()->isOp()) {
- $e->setCancelled(true);
- $e->getPlayer()->sendMessage(TextFormat::WHITE . "• " . TextFormat::YELLOW . "[AMPE] " . TextFormat::RED . "Nie mozesz postawic BoyFarmera na terenie innej gildii!" . TextFormat::WHITE . "•");
- return true;
- }
- if($e->getBlock()->getY() <= $this->getConfig()->getNested("boyfarmer.coordinator-y"))
- {
- $e->setCancelled(true);
- $e->getPlayer()->sendMessage(TextFormat::WHITE . "• " . TextFormat::YELLOW . "[AMPE] " . TextFormat::GRAY . "BoyFarmer zostal aktywowany! " . TextFormat::WHITE . "•");
- $e->getPlayer()->getInventory()->removeItem(Item::get(120, 0, 1));
- $e->getBlock()->getLevel()->setBlock(new Vector3($e->getBlock()->x, $e->getBlock()->y, $e->getBlock()->z), Block::get(Block::OBSIDIAN));
- for($i=1; $i<200; $i++)
- {
- $block = $e->getBlock()->getLevel()->getBlock(new Vector3($e->getBlock()->x, $e->getBlock()->y -$i, $e->getBlock()->z));
- if($block->getId() === 0)
- {
- $e->getBlock()->getLevel()->setBlock(new Vector3($e->getBlock()->x, $e->getBlock()->y -$i, $e->getBlock()->z), Block::get(Block::OBSIDIAN));
- }
- }
- }
- else
- {
- $e->getPlayer()->sendMessage(TextFormat::WHITE . "• " . TextFormat::YELLOW . "[AMPE] " . TextFormat::RED . "Blad! BoyFarmer nie moze przekroczyc koordynatu Y: " . $this->getConfig()->getNested("boyfarmer.coordinator-y") . TextFormat::RED . ". " . TextFormat::WHITE . "•");
- $e->setCancelled();
- }
- }
- } else
- {
- $e->setCancelled();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement