Can someone test it please?

This commit is contained in:
Ad5001 2016-08-20 12:04:41 +03:00
parent 32837ca6cd
commit 0df1413a31

View file

@ -17,6 +17,7 @@ use pocketmine\event\player\PlayerChatEvent;
use pocketmine\event\player\PlayerQuitEvent; use pocketmine\event\player\PlayerQuitEvent;
use pocketmine\event\player\PlayerRespawnEvent; use pocketmine\event\player\PlayerRespawnEvent;
use pocketmine\event\entity\EntityRegainHealthEvent; use pocketmine\event\entity\EntityRegainHealthEvent;
use pocketmine\item\Item;
use pocketmine\plugin\PluginBase; use pocketmine\plugin\PluginBase;
use pocketmine\Server; use pocketmine\Server;
use pocketmine\Player; use pocketmine\Player;
@ -91,33 +92,6 @@ class Main extends PluginBase implements Listener{
$this->UHCManager->registerLevel($event->getLevel()); $this->UHCManager->registerLevel($event->getLevel());
} }
} }
public function onRespawn(PlayerRespawnEvent $event) {
foreach($this->games as $game) {
$game->onRespawn($event);
}
}
public function onPlayerQuit(PlayerQuitEvent $event) {
foreach($this->games as $game) {
$game->onPlayerQuit($event);
}
}
public function onPlayerDeath(PlayerDeathEvent $event) {
foreach($this->games as $game) {
$game->onPlayerDeath($event);
}
}
public function onHeal(EntityRegainHealthEvent $event) {
foreach($this->games as $game) {
$game->onHeal($event);
}
}
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args){ public function onCommand(CommandSender $sender, Command $cmd, $label, array $args){
@ -131,7 +105,19 @@ switch($cmd->getName()){
foreach($sender->getLevel()->getPlayers() as $player) { foreach($sender->getLevel()->getPlayers() as $player) {
$player->sendMessage(self::PREFIX . "Starting game..."); $player->sendMessage(self::PREFIX . "Starting game...");
} }
$this->startGame($this->UHCMananger->getLevels()[$sender->getLevel()->getName()]); $this->UHCMananger->startUHC($sender->getLevel());
} else {
$sender->sendMessage("You are not in a UHC world or UHC is already started");
}
return true;
break;
case "stop":
if(isset($this->UHCMananger->getStartedUHCs()[$sender->getLevel()->getName()])) {
$this->getLogger()->debug("Starting game {$sender->getLevel()->getName()}");
foreach($sender->getLevel()->getPlayers() as $player) {
$player->sendMessage(self::PREFIX . "Starting game...");
}
$this->stopUHC($sender->getLevel());
} else { } else {
$sender->sendMessage("You are not in a UHC world or UHC is already started"); $sender->sendMessage("You are not in a UHC world or UHC is already started");
} }
@ -141,7 +127,7 @@ switch($cmd->getName()){
} }
break; break;
case "scenarios": case "scenarios":
if(isset($args[0])) { if(isset($args[0]) and $sender instanceof Player) {
if(isset($this->UHCMananger->getLevels()[$sender->getLevel()->getName()]) and !isset($this->UHCMananger->getStartedGames()[$sender->getLevel()->getName()])) { if(isset($this->UHCMananger->getLevels()[$sender->getLevel()->getName()]) and !isset($this->UHCMananger->getStartedGames()[$sender->getLevel()->getName()])) {
switch($args[0]) { switch($args[0]) {
case "add": case "add":
@ -192,6 +178,10 @@ switch($cmd->getName()){
} else { } else {
$sender->sendMessage(self::PREFIX . "You're not in a UHC world !") $sender->sendMessage(self::PREFIX . "You're not in a UHC world !")
} }
} else {
if(isset($this->UHCMananger->getLevels()[$sender->getLevel()->getName()]) and !isset($this->UHCMananger->getStartedGames()[$sender->getLevel()->getName()])) {
$sender->sendMessage(self::PREFIX . "Current enabled scenarios : " . implode(", ", $this->UHCManager[$sender->getLevel()->getName()]->scenarioManager->getUsedScenarios()))
}
} }
break; break;
} }
@ -369,6 +359,17 @@ return false;
$sc->onDataPacketReceive($event); $sc->onDataPacketReceive($event);
} }
} }
if($event->getPacket() instanceof \pocketmine\network\protocol\UseItemPacket) {
if($event->getPlayer()->getInventory()->getItemInHand()->getId() == Item::GOLD_APPLE and !$ev->isCancelled()) { // Golden apple
$e = \pocketmine\entity\Effect::getEffectByName("ABSORBTION");
$e->setDuration(120000);
$event->getPlayer()->addEffect($e);
$e = \pocketmine\entity\Effect::getEffectByName("REGENERATION");
$e->setDuration(5000);
$e->setAmplifier(2);
$event->getPlayer()->addEffect($e);
}
}
} }