I need help I need a plugin which can make player get reward when they breaked 500 blocks and anti spam. Custom reward? Yeah! That will be awesome
Yeah. I arealy have a plugin like that but its effect Code: <?php namespace Muqsit; use pocketmine\Server; use pocketmine\Player; use pocketmine\plugin\PluginBase; use pocketmine\entity\Effect; use pocketmine\event\Listener; use pocketmine\event\block\BlockBreakEvent; use pocketmine\command\ConsoleCommandSender; use pocketmine\utils\Config; use pocketmine\item\Item; use pocketmine\utils\TextFormat as TF; class Main extends PluginBase implements Listener{ /** @var array $breaks */ private $breaks; // Will you even be needing this?? :o public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this, $this); @mkdir($this->getDataFolder()); # Config isn't used. $this->getLogger()->info(" enabled"); # Don't add this log message at beggining of function it can be misleading } // Thanks to @PrimusLV public static function onBlockBreak(BlockBreakEvent $event){ if($event->isCancelled()) return; $name = $event->getPlayer()->getName(); $player = $event->getPlayer(); if(self::$breaks[$name] >= 128){ $event->getPlayer()->sendMessage(TF::YELLOW . "You broke 128 blocks, " . TF::AQUA . "WHOOOO!"); self::giveEffect($player, 3, 100, 5); self::$breaks[$name] = 0; # Reset the counter, to avoid ^^ spam. }else{ self::$breaks[$name]++; } } /** * @param Player $player * @param int $id * @param int $duration * @param int $amplifier */ public static function giveEffect(Player $player, $id, $duration, $amplifier){ $effect = Effect::getEffect($id)->setDuration($duration)->setAmplifier($amplifier); # Fluent setters <3 $player->addEffect($effect); } }
I have made some changes to the code you previously posted. They can be viewed here. Please test and see if the changes I made work for you. PHP: /** @var $breaks int[] */ private static $breaks = []; public static function onBlockBreak(BlockBreakEvent $event){ if($event->isCancelled()) return; $player = $event->getPlayer(); $name = $player->getName(); if(self::$breaks[$name] >= 128){ $player->sendMessage(TF::YELLOW . "You broke 128 blocks, " . TF::AQUA . "WHOOOO!"); self::giveEffect($player, Effect::HASTE, 100, 5); // other rewards can go here self::$breaks[$name] = 0; # Reset the counter, to avoid ^^ spam. }else{ self::$breaks[$name]++; } }
Would it work? Code: <?php namespace Muqsit; use pocketmine\Server; use pocketmine\Player; use pocketmine\plugin\PluginBase; use pocketmine\entity\Effect; use pocketmine\event\Listener; use pocketmine\event\block\BlockBreakEvent; use pocketmine\command\ConsoleCommandSender; use pocketmine\utils\Config; use pocketmine\item\Item; use pocketmine\utils\TextFormat as TF; class Main extends PluginBase implements Listener{ /** @var $breaks int[] */ private static $breaks = []; public static function onBlockBreak(BlockBreakEvent $event){ if($event->isCancelled()) return; $player = $event->getPlayer(); $name = $player->getName(); if(self::$breaks[$name] >= 10){ $player->sendMessage(TF::YELLOW . "You broke 10 blocks, " . TF::AQUA . "WHOOOO!"); self::giveItem($player, Item::264, 0, 5); // other rewards can go here self::$breaks[$name] = 0; # Reset the counter, to avoid ^^ spam. }else{ self::$breaks[$name]++; } }
Why not just send it? Some weeks or months later, someone might come to this thread from Google and then be sad that the plugin exists but he/she can't have it. Relevant XKCD:
Here yours. This is my Vietnamese plugin. You just need editing the src file. And the config. Translate it for your best, ok?
i translated it and added a few blocks and added the key command for piggy crates Tell me if i did it worng please.
I recently made this plugin. Check it out if you still need it. https://poggit.pmmp.io/ci/davidgamingzz/MiningRewards/MiningRewards