Last active
June 10, 2021 15:44
-
-
Save svilex/fb5d1b541798edf74f8da8486c5cc903 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* _ _ | |
* ___ __ __ (_) | | ___ | |
* / __| \ \ / / | | | | / _ \ | |
* \__ \ \ / / | | | | | __/ | |
* |___/ \_/ |_| |_| \___| | |
* | |
* @Author: svile | |
* @Kik: _svile_ | |
* @Telegram_Group: https://telegram.me/svile | |
* @E-mail: [email protected] | |
* @Github: https://github.com/svilex | |
* | |
* | |
* @name thing | |
* @main svile\thing\Main | |
* @version 1.0 | |
* @api 3.0.0 | |
* @description This is used on a local PocketMine server the proxy is initially connected to | |
* @author svile | |
* @load: STARTUP | |
* | |
*/ | |
namespace svile\thing { | |
use pocketmine\plugin\PluginBase; | |
use pocketmine\event\Listener; | |
use pocketmine\event\block\BlockBreakEvent; | |
use pocketmine\event\player\PlayerInteractEvent; | |
use pocketmine\event\block\BlockPlaceEvent; | |
use pocketmine\event\player\PlayerMoveEvent; | |
use pocketmine\event\player\PlayerJoinEvent; | |
use pocketmine\event\player\PlayerQuitEvent; | |
use pocketmine\event\player\PlayerChatEvent; | |
use pocketmine\event\player\PlayerCommandPreprocessEvent; | |
use pocketmine\entity\Effect; | |
use pocketmine\entity\EffectInstance; | |
use pocketmine\item\Item; | |
class Main extends PluginBase implements Listener | |
{ | |
private $players = []; | |
public function onEnable() | |
{ | |
$this->getServer()->getPluginManager()->registerEvents($this, $this); | |
$this->getScheduler()->scheduleRepeatingTask(new Timer($this), 20); | |
Item::clearCreativeItems(); | |
} | |
public function onBlockBreakEvent(BlockBreakEvent $ev) | |
{ | |
$ev->setCancelled(); | |
} | |
public function onPlayerInteractEvent(PlayerInteractEvent $ev) | |
{ | |
$ev->setCancelled(); | |
} | |
public function onBlockPlaceEvent(BlockPlaceEvent $ev) | |
{ | |
$ev->setCancelled(); | |
} | |
public function onPlayerMoveEvent(PlayerMoveEvent $ev) | |
{ | |
$ev->setCancelled(); | |
} | |
public function onPlayerJoinEvent(PlayerJoinEvent $ev) | |
{ | |
$ev->getPlayer()->setGamemode(1); | |
//$ev->getPlayer()->setImmobile(); | |
$e = Effect::getEffect(Effect::BLINDNESS); | |
$ei = new EffectInstance($e, 360000, 0xff, false, false); | |
$ev->getPlayer()->addEffect($ei); | |
$ev->setJoinMessage(''); | |
foreach ($this->getServer()->getOnlinePlayers() as $p) { | |
$ev->getPlayer()->hidePlayer($p); | |
$p->hidePlayer($ev->getPlayer()); | |
} | |
$this->players[$ev->getPlayer()->getName()] = 1; | |
} | |
public function onPlayerQuitEvent(PlayerQuitEvent $ev) | |
{ | |
$ev->setQuitMessage(''); | |
unset($this->players[$ev->getPlayer()->getName()]); | |
} | |
public function onPlayerChatEvent(PlayerChatEvent $ev) | |
{ | |
$ev->setCancelled(); | |
} | |
public function onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent $ev) | |
{ | |
$ev->setCancelled(); | |
} | |
public function tick() | |
{ | |
foreach ($this->players as $name => &$ticks) { | |
if (++$ticks > 600) { | |
$p = $this->getServer()->getPlayerExact($name); | |
if ($p !== null) | |
$p->kick("§c\xe2\x80\xa2You're taking too long to choose a server\n§cContact §fsvile#9322 §con Discord if you need help", false); | |
unset($this->players[$name]); | |
} | |
} | |
} | |
} | |
use pocketmine\scheduler\Task; | |
class Timer extends Task | |
{ | |
private $plugin; | |
public function __construct(Main $plugin) | |
{ | |
$this->plugin = $plugin; | |
} | |
public function onRun(int $currentTick) | |
{ | |
$this->plugin->tick(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It’s fine for me Works every time Nice job making this.