Skip to content
This repository has been archived by the owner on Dec 30, 2023. It is now read-only.

Commit

Permalink
PM5 update, fix #18
Browse files Browse the repository at this point in the history
  • Loading branch information
NgLam2911 authored Jun 2, 2023
1 parent deeeeff commit 2713744
Show file tree
Hide file tree
Showing 38 changed files with 1,850 additions and 1,831 deletions.
126 changes: 63 additions & 63 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
name: lmao
main: NgLam2911\lmao\Lmao
api: 4.0.0
version: 0.1.0
authors:
- NgLamVN
description: An Ultimate Troll plugin for PocketMine-MP

virions:
- Commando

permissions:
lmao:
default: op
lmao.burn:
default: op
lmao.fakeop:
default: op
lmao.launch:
default: op
lmao.alone:
default: op
lmao.bolt:
default: op
lmao.boom:
default: op
lmao.crash:
default: op
lmao.fakedeop:
default: op
lmao.shuffle:
default: op
lmao.push:
default: op
lmao.dropinv:
default: op
lmao.chat:
default: op
lmao.fakeban:
default: op
lmao.flip:
default: op
lmao.spin:
default: op
lmao.spam:
default: op
lmao.swap:
default: op
lmao.creeper:
default: op
lmao.nomine:
default: op
lmao.noplace:
default: op
lmao.nopick:
default: op
lmao.rickroll:
default: op
lmao.pumpkinhead:
default: op
lmao.starve:
default: op
lmao.infinitedeath:
name: lmao
main: NgLam2911\lmao\Lmao
api: 5.0.0
version: 0.2.0
authors:
- NgLamVN
description: An Ultimate Troll plugin for PocketMine-MP

virions:
- Commando

permissions:
lmao:
default: op
lmao.burn:
default: op
lmao.fakeop:
default: op
lmao.launch:
default: op
lmao.alone:
default: op
lmao.bolt:
default: op
lmao.boom:
default: op
lmao.crash:
default: op
lmao.fakedeop:
default: op
lmao.shuffle:
default: op
lmao.push:
default: op
lmao.dropinv:
default: op
lmao.chat:
default: op
lmao.fakeban:
default: op
lmao.flip:
default: op
lmao.spin:
default: op
lmao.spam:
default: op
lmao.swap:
default: op
lmao.creeper:
default: op
lmao.nomine:
default: op
lmao.noplace:
default: op
lmao.nopick:
default: op
lmao.rickroll:
default: op
lmao.pumpkinhead:
default: op
lmao.starve:
default: op
lmao.infinitedeath:
default: op
206 changes: 104 additions & 102 deletions src/NgLam2911/lmao/EventListener.php
Original file line number Diff line number Diff line change
@@ -1,103 +1,105 @@
<?php
declare(strict_types=1);

namespace NgLam2911\lmao;

use NgLam2911\lmao\session\Session;
use pocketmine\event\block\BlockBreakEvent;
use pocketmine\event\block\BlockPlaceEvent;
use pocketmine\event\entity\EntityItemPickupEvent;
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerJoinEvent;
use pocketmine\event\player\PlayerQuitEvent;
use pocketmine\event\player\PlayerRespawnEvent;
use pocketmine\player\Player;
use pocketmine\scheduler\ClosureTask;

class EventListener implements Listener{

/**
* @param PlayerJoinEvent $event
* @priority HIGHEST
*/
public function onJoin(PlayerJoinEvent $event) : void{
$player = $event->getPlayer();
Lmao::getInstance()->getSessionManager()->registerSession(new Session($player));
}

/**
* @param PlayerQuitEvent $event
* @priority HIGHEST
*/
public function onQuit(PlayerQuitEvent $event) : void{
$player = $event->getPlayer();
Lmao::getInstance()->getSessionManager()->removeSession(new Session($player));
}

/**
* @param BlockBreakEvent $event
* @priority LOW
* @handleCancelled FALSE
*/
public function onBreak(BlockBreakEvent $event) : void{
$player = $event->getPlayer();
$session = Lmao::getInstance()->getSessionManager()->getSession($player);
if (is_null($session)){
return;
}
if ($session->isNoMine()){
$event->cancel();
}
}

/**
* @param BlockPlaceEvent $event
* @priority LOW
* @handleCancelled FALSE
*/
public function onPlace(BlockPlaceEvent $event){
$player = $event->getPlayer();
$session = Lmao::getInstance()->getSessionManager()->getSession($player);
if (is_null($session)){
return;
}
if ($session->isNoPlace()){
$event->cancel();
}
}

/**
* @param EntityItemPickupEvent $event
* @priority LOW
* @handleCancelled FALSE
*/
public function onPickup(EntityItemPickupEvent $event){
$entity = $event->getEntity();
if (!$entity instanceof Player){
return;
}
$session = Lmao::getInstance()->getSessionManager()->getSession($entity);
if (is_null($session)){
return;
}
if ($session->isNoPick()){
$event->cancel();
}
}

/**
* @param PlayerRespawnEvent $event
* @priority LOW
*/
public function onRespawn(PlayerRespawnEvent $event){
$session = Lmao::getInstance()->getSessionManager()->getSession($event->getPlayer());
if (is_null($session)){
return;
}
if ($session->isInfiniteDeath()){
Lmao::getInstance()->getScheduler()->scheduleDelayedTask(new ClosureTask(function() use ($session) : void {
$session->getPlayer()->kill();
}), 3);
}
}
<?php
declare(strict_types=1);

namespace NgLam2911\lmao;

use NgLam2911\lmao\session\Session;
use pocketmine\block\tile\Chest as ChestTile;
use pocketmine\event\block\BlockBreakEvent;
use pocketmine\event\block\BlockPlaceEvent;
use pocketmine\event\entity\EntityItemPickupEvent;
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerInteractEvent;
use pocketmine\event\player\PlayerJoinEvent;
use pocketmine\event\player\PlayerQuitEvent;
use pocketmine\event\player\PlayerRespawnEvent;
use pocketmine\player\Player;
use pocketmine\scheduler\ClosureTask;

class EventListener implements Listener{

/**
* @param PlayerJoinEvent $event
* @priority HIGHEST
*/
public function onJoin(PlayerJoinEvent $event) : void{
$player = $event->getPlayer();
Lmao::getInstance()->getSessionManager()->registerSession(new Session($player));
}

/**
* @param PlayerQuitEvent $event
* @priority HIGHEST
*/
public function onQuit(PlayerQuitEvent $event) : void{
$player = $event->getPlayer();
Lmao::getInstance()->getSessionManager()->removeSession(new Session($player));
}

/**
* @param BlockBreakEvent $event
* @priority LOW
* @handleCancelled FALSE
*/
public function onBreak(BlockBreakEvent $event) : void{
$player = $event->getPlayer();
$session = Lmao::getInstance()->getSessionManager()->getSession($player);
if (is_null($session)){
return;
}
if ($session->isNoMine()){
$event->cancel();
}
}

/**
* @param BlockPlaceEvent $event
* @priority LOW
* @handleCancelled FALSE
*/
public function onPlace(BlockPlaceEvent $event) : void{
$player = $event->getPlayer();
$session = Lmao::getInstance()->getSessionManager()->getSession($player);
if (is_null($session)){
return;
}
if ($session->isNoPlace()){
$event->cancel();
}
}

/**
* @param EntityItemPickupEvent $event
* @priority LOW
* @handleCancelled FALSE
*/
public function onPickup(EntityItemPickupEvent $event) : void{
$entity = $event->getEntity();
if (!$entity instanceof Player){
return;
}
$session = Lmao::getInstance()->getSessionManager()->getSession($entity);
if (is_null($session)){
return;
}
if ($session->isNoPick()){
$event->cancel();
}
}

/**
* @param PlayerRespawnEvent $event
* @priority LOW
*/
public function onRespawn(PlayerRespawnEvent $event) : void{
$session = Lmao::getInstance()->getSessionManager()->getSession($event->getPlayer());
if (is_null($session)){
return;
}
if ($session->isInfiniteDeath()){
Lmao::getInstance()->getScheduler()->scheduleDelayedTask(new ClosureTask(function() use ($session) : void {
$session->getPlayer()->kill();
}), 3);
}
}
}
Loading

0 comments on commit 2713744

Please sign in to comment.