示例#1
0
 public function __construct(SimpleWarp $plugin, Warp $warp, Player $player)
 {
     parent::__construct($plugin);
     $this->warp = $warp;
     $this->player = $player;
     $this->position = $player->getPosition();
 }
示例#2
0
 public function onRun(array $args, Player $player)
 {
     $global = false;
     $anchor = $player->getPosition();
     $name = isset($args[0]) ? array_shift($args) : "default";
     while (isset($args[0])) {
         $arg = array_shift($args);
         switch ($arg) {
             case "g":
                 $global = $this->getMain()->getClipboardProvider();
                 break;
             case "a":
             case "anchor":
                 $anchor = $this->getMain()->getAnchor($player);
                 break;
         }
     }
     if ($global instanceof ClipboardProvider) {
         $clip = $global[$name];
     } else {
         $clip = $this->getMain()->getClip($player, $name);
     }
     if (!$clip instanceof Clip) {
         if ($global instanceof ClipboardProvider) {
             return "There isn't a global clip called {$name}!";
         } else {
             return "You don't have a clip called {$name}!";
         }
     }
     $clip->paste($anchor);
     return count($clip->getBlocks()) . " block(s) have been pasted.";
 }
示例#3
0
 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     if ($player === null or $player->isSurvival() !== true) {
         return false;
     }
     if ($target->getId() === Block::STILL_WATER or $target->getId() === Block::WATER) {
         $player->getServer()->getPluginManager()->callEvent($ev = new PlayerGlassBottleEvent($player, $target, $this));
         if ($ev->isCancelled()) {
             return false;
         } else {
             if ($this->count <= 1) {
                 $player->getInventory()->setItemInHand(Item::get(Item::POTION, 0, 1));
                 return true;
             } else {
                 $this->count--;
                 $player->getInventory()->setItemInHand($this);
             }
             if ($player->getInventory()->canAddItem(Item::get(Item::POTION, 0, 1)) === true) {
                 $player->getInventory()->AddItem(Item::get(Item::POTION, 0, 1));
             } else {
                 $motion = $player->getDirectionVector()->multiply(0.4);
                 $position = clone $player->getPosition();
                 $player->getLevel()->dropItem($position->add(0, 0.5, 0), Item::get(Item::POTION, 0, 1), $motion, 40);
             }
             return true;
         }
     }
     return false;
 }
 public function onRun(array $args, Player $player)
 {
     $mode = 0;
     $target = $player->getPosition();
     while (isset($args[0])) {
         $arg = array_shift($args);
         switch ($arg) {
             case "c":
             case "crosshair":
                 $target = WorldEditArt::getCrosshairTarget($player);
                 if (!$target instanceof Block) {
                     return "The block is too far/in the void/sky!";
                 }
                 break;
             case "v":
             case "view":
                 $mode = 1;
                 break;
         }
     }
     switch ($mode) {
         case 0:
             $this->getMain()->setAnchor($player, $target);
             return "Your anchor has been set to " . WorldEditArt::posToStr($target) . ".";
         case 1:
             $anchor = $this->getMain()->getAnchor($player);
             if (!$anchor instanceof Position) {
                 return "You don't have an anchor selected!";
             }
             return "Your anchor is at " . WorldEditArt::posToStr($anchor) . ".";
         default:
             return null;
     }
 }
 public function onShootRun(array $args, Player $player)
 {
     if (!isset($args[0]) or !is_numeric($args[0])) {
         return self::WRONG_USE;
     }
     $length = floatval(array_shift($args));
     $p1 = $player->getPosition()->floor();
     $p2 = $player->add($player->getDirectionVector()->multiply($length))->floor();
     if ($p1->y < 0 or $p1->y > (defined($path = "pemapmodder\\worldeditart\\MAX_WORLD_HEIGHT") ? constant($path) : 127)) {
         return "You must be inside the building height!";
     } elseif ($p2->y < 0 or $p2->y > (defined($path = "pemapmodder\\worldeditart\\MAX_WORLD_HEIGHT") ? constant($path) : 127)) {
         return "The selected area exceeded the world height limit!";
     }
     $player->getLevel()->loadChunk($p2->x >> 4, $p2->z >> 4);
     while (isset($args[0])) {
         $arg = array_shift($args);
         switch ($arg) {
             case "a":
             case "adverse":
                 $cache = [$p1, $p2];
                 $p1 = $cache[1];
                 $p2 = $cache[0];
                 break;
         }
     }
     $level = $player->getLevel();
     $this->getMain()->setSelection($player, $sel = new CuboidSpace($p1 = Position::fromObject($p1, $level), $p2 = Position::fromObject($p2, $level)));
     return "Cuboid selection set: {$sel} (" . count($sel->getPosList()) . " blocks)";
 }
示例#6
0
 public function storePlayer(Player $player)
 {
     if (!isset($this->players[$player->getName()])) {
         $this->players[$player->getName()] = ["inventory" => serialize($player->getInventory()->getContents()), "armor" => serialize($player->getInventory()->getArmorContents()), "spawn" => serialize($player->getPosition()), "gamemode" => $player->getGamemode()];
         $player->setGamemode(0);
         $player->getInventory()->clearAll();
     }
 }
示例#7
0
 public function onRun(array $args, Space $space, Player $player)
 {
     $anchor = $player->getPosition();
     if (isset($args[0]) and ($args[0] === "-a" or $args[0] === "-anchor")) {
         $anchor = $this->getMain()->getAnchor($player);
     }
     if (!isset($args[0])) {
         array_unshift($args, "default");
     }
     $clip = new Clip($space, $anchor, array_shift($args));
     if (isset($args[0]) and ($args[0] === "g" or $args[0] === "global")) {
         $clipboard = $this->getMain()->getClipboardProvider();
         $clipboard[$clip->getName()] = $clip;
     } else {
         $this->getMain()->setClip($player, $clip, $clip->getName());
     }
     return "Clip " . $clip->getName() . " copied.";
 }
示例#8
0
文件: MagicUtil.php 项目: robozeri/SG
 public static function addPlayerFireworks(Player $player, Position $pos1, $count = 5)
 {
     $pos = new Position($player->getPosition()->x, $player->getPosition()->y + 3, $player->getPosition()->z, $player->getLevel());
     $pos2 = new Position($player->getPosition()->x, $player->getPosition()->y + 1, $player->getPosition()->z, $player->getLevel());
     $exp = new Explosion($pos, 1);
     $exp->explodeB();
     MagicUtil::addParticles($player->getLevel(), "explode", $pos2);
     for ($i = 0; $i < 5; $i++) {
         $pos = new Position($pos1->x + rand(-2, 3), $pos1->y + rand(0, 5), $pos1->z + rand(-2, 3), $player->getLevel());
         $player->getLevel()->addParticle(new DustParticle($pos, rand(1, 255), rand(1, 255), rand(1, 255)));
         $player->getLevel()->addParticle(new DustParticle($pos, rand(1, 255), rand(1, 255), rand(1, 255)));
         $player->getLevel()->addParticle(new DustParticle($pos, rand(1, 255), rand(1, 255), rand(1, 255)));
         $player->getLevel()->addParticle(new DustParticle($pos, rand(1, 255), rand(1, 255), rand(1, 255)));
         $player->getLevel()->addParticle(new DustParticle($pos, rand(1, 255), rand(1, 255), rand(1, 255)));
     }
     MagicUtil::addParticles($player->getLevel(), "driplava", $pos1);
 }
 public function onRun(array $args, Player $player)
 {
     if (!isset($args[0])) {
         return false;
     }
     $radius = floatval(array_shift($args));
     $anchor = $player->getPosition();
     while (isset($args[0])) {
         $arg = array_shift($args);
         switch ($arg) {
             case "a":
             case "anchor":
                 $anchor = $this->getMain()->getAnchor($player);
                 if (!$anchor instanceof Position) {
                     return self::NO_ANCHOR;
                 }
                 break;
         }
     }
     $sel = new SphereSpace($anchor, $radius);
     $this->getMain()->setSelection($player, $sel);
     return "You have selected {$sel}.";
 }
示例#10
0
文件: MapPortal.php 项目: robozeri/SG
 public static final function teleportToMap($levelname, Player $player)
 {
     if (!$player->getServer()->isLevelLoaded($levelname)) {
         $ret = $player->getServer()->loadLevel($levelname);
         if (!$ret) {
             $player->sendMessage("[HG]Error, unable load World: " . $levelname);
             return;
         }
     }
     if (!$player->getServer()->isLevelGenerated($levelname)) {
         $player->sendMessage("[HG] world generation is not ready! try later.");
         return;
     }
     $level = $player->getServer()->getLevelByName($levelname);
     if (is_null($level)) {
         $player->sendMessage("[HG] Error, unable access world: " . $levelname);
         return;
     }
     $player->getLevel()->updateAllLight($player->getPosition());
     $player->getLevel()->updateAround($player->getPosition());
     $player->teleport($level->getSafeSpawn());
 }
示例#11
0
 /**
  *
  * Handle Tap On Arena Signs
  *
  * @param Player $player        	
  * @param unknown $b        	
  * @return boolean
  */
 public function handleTapOnArenaSigns(Player $player, $b)
 {
     foreach ($this->arenas as &$arena) {
         if ($arena instanceof MapArenaModel) {
             // tap on vote sign
             if (!empty($arena->signVote)) {
                 $blockPosKey = round($b->x) . "." . round($b->y) . "." . round($b->z);
                 $casePosKey = round($arena->signVote->x) . "." . round($arena->signVote->y) . "." . round($arena->signVote->z);
                 if ($blockPosKey === $casePosKey && $blockPosKey != "0.0.0") {
                     if (!$arena->published) {
                         $player->sendMessage("[HG] This map is not available yet! please try another one.");
                         break;
                     }
                     $players[] = $player;
                     $player->getLevel()->addSound(new ClickSound($player->getPosition()), $players);
                     MagicUtil::addParticles($player->getLevel(), "reddust", $arena->signVote, 20);
                     if ($arena->vote === 0 && isset($arena->votedPlayers[$player->getName()])) {
                         unset($arena->votedPlayers[$player->getName()]);
                     }
                     if (!isset($arena->votedPlayers[$player->getName()])) {
                         $arena->vote++;
                         $arena->votedPlayers[$player->getName()] = $player;
                     } else {
                         $player->sendMessage(TextFormat::YELLOW . "[HG] Already voted! [" . $arena->displayName . "]");
                     }
                     $player->sendMessage(TextFormat::GRAY . "[HG] " . $arena->displayName . " map votes [" . TextFormat::YELLOW . $arena->vote . TextFormat::GRAY . "]");
                     break;
                 }
             }
             if (!empty($arena->signExit) && !empty($arena->arenaExitPos)) {
                 $blockPosKey = round($b->x) . "." . round($b->y) . "." . round($b->z);
                 $casePosKey = round($arena->signExit->x) . "." . round($arena->signExit->y) . "." . round($arena->signExit->z);
                 if ($blockPosKey === $casePosKey && $blockPosKey != "0.0.0") {
                     $players[] = $player;
                     $player->level->addSound(new ClickSound($player->getPosition()), $players);
                     MagicUtil::addParticles($player->getLevel(), "portal", $player->getPosition(), 100);
                     unset($arena->joinedPlayers[$player->getName()]);
                     unset($arena->livePlayers[$player->getName()]);
                     $player->teleport($arena->arenaExitPos);
                     break;
                 }
             }
             if (!empty($arena->signJoin) && !empty($arena->arenaEnterPos)) {
                 $blockPosKey = round($b->x) . "." . round($b->y) . "." . round($b->z);
                 $casePosKey = round($arena->signJoin->x) . "." . round($arena->signJoin->y) . "." . round($arena->signJoin->z);
                 if ($blockPosKey === $casePosKey && $blockPosKey != "0.0.0") {
                     $players[] = $player;
                     $player->level->addSound(new ClickSound($player->getPosition()), $players);
                     MagicUtil::addParticles($player->getLevel(), "portal", $player->getPosition(), 100);
                     MapPortal::teleportToMap($arena->levelName, $player);
                     $player->teleport($arena->arenaEnterPos);
                     break;
                 }
             }
         }
     }
 }
示例#12
0
 public function addItem(Item $item, Player $player, Item $result)
 {
     if ($item->getCount() <= 1) {
         $player->getInventory()->setItemInHand($result);
     } else {
         $item->setCount($item->getCount() - 1);
         if ($player->getInventory()->canAddItem($result) === true) {
             $player->getInventory()->addItem($result);
         } else {
             $motion = $player->getDirectionVector()->multiply(0.4);
             $position = clone $player->getPosition();
             $player->getLevel()->dropItem($position->add(0, 0.5, 0), $result, $motion, 40);
         }
     }
 }
示例#13
0
 private function fire(Player $c, $fuse, $speed)
 {
     $pos = $c->getPosition();
     $pos->y += $c->getEyeHeight();
     $dir = $c->getDirectionVector();
     $dir->x = $dir->x * $speed;
     $dir->y = $dir->y * $speed;
     $dir->z = $dir->z * $speed;
     $this->scorchit($pos, $dir, $fuse);
 }
 public function onRun(array $args, Player $player)
 {
     $flag = 0;
     // 0 for me, 1 for anchor, 2 for crosshair
     if (isset($args[0])) {
         $arg = array_shift($args);
         switch ($arg) {
             case "a":
             case "anchor":
                 $flag = 1;
                 break;
             case "c":
             case "crosshair":
                 $flag = 2;
                 break;
         }
     }
     $selected = $player->getPosition();
     if ($flag === 1) {
         $selected = $this->getMain()->getAnchor($player);
         if (!$selected instanceof Position) {
             return self::NO_ANCHOR;
         }
     }
     if ($flag === 2) {
         $selected = WorldEditArt::getCrosshairTarget($player);
         if (!$selected instanceof Position) {
             return "The block is too far/in the void/in the sky.";
         }
     }
     if ($selected->y < 0 or $selected->y > (defined($path = "pemapmodder\\worldeditart\\MAX_WORLD_HEIGHT") ? constant($path) : 127)) {
         return "The selected point is too high/too low.";
     }
     $selected->getLevel()->loadChunk($selected->x >> 4, $selected->z >> 4);
     $selected = Position::fromObject($selected->floor(), $selected->getLevel());
     $space = $this->getMain()->getSelection($player);
     if ($space instanceof CuboidSpace and $space->getLevel() === $selected->getLevel()) {
         if ($this->is2) {
             $space->set1($selected);
         } else {
             $space->set0($selected);
         }
         goto end;
     }
     $temp = $this->getMain()->getTempPos($player);
     if (is_array($temp) and $temp["#"] !== $this->is2) {
         /** @var Position $pos */
         $pos = $temp["position"];
         if ($pos->getLevel() === $selected->getLevel()) {
             if ($this->is2) {
                 $this->getMain()->setSelection($player, new CuboidSpace($pos, $selected));
             } else {
                 $this->getMain()->setSelection($player, new CuboidSpace($selected, $pos));
             }
             goto end;
         }
     }
     $this->getMain()->unsetSelection($player);
     $this->getMain()->setTempPos($player, $selected, $this->is2);
     end:
     $space = $this->getMain()->getSelection($player);
     if ($space instanceof Space) {
         $cnt = count($space);
     }
     return ($this->is2 ? "Second" : "First") . " position set to " . "({$selected->x}, {$selected->y}, {$selected->z})." . (isset($cnt) ? "\n  (Cuboid selected with {$cnt} blocks)" : "");
 }
示例#15
0
 /**
  *
  * @param GameLevelModel $lv        	
  * @param Player $player        	
  * @return boolean
  */
 public function portalEnter(HungerGamesPlugIn $plugin, GameLevelModel $lv, Player $player)
 {
     if ($player->getLevel()->getName() != $lv->levelName) {
         return true;
     }
     if ($lv->insideLevelEntracePortal($player->getPosition())) {
         if (!isset($this->joinedPlayers[$player->getName()])) {
             if ($plugin->storyenforceaccess && $lv->type != 1) {
                 $w = $plugin->storyManager->hasPlayerWonLevel($player->getName(), $lv->type - 1);
                 if (!$w) {
                     $player->sendMessage(TextFormat::RED . "[HG Story Mode Enabled]");
                     $player->sendMessage(TextFormat::YELLOW . "Required " . TextFormat::GOLD . "WIN " . TextFormat::YELLOW . "previous level before play this level!");
                     $player->getLevel()->addSound(new LaunchSound($player->getPosition()), array($player));
                     if ($player->isOp()) {
                         $player->sendMessage(TextFormat::AQUA . "[Admin BY-PASS Story Mode Checking]");
                     } else {
                         $player->teleport($lv->enterpos);
                         return;
                     }
                 }
             }
             $this->joinedPlayers[$player->getName()] = $player;
             $message = TextFormat::GRAY . "[HG] [" . TextFormat::AQUA . $player->getName() . TextFormat::GRAY . "] joined " . $lv->displayName . " [" . TextFormat::GREEN . count($lv->joinedPlayers) . TextFormat::GRAY . " |" . TextFormat::WHITE . "minimal " . TextFormat::YELLOW . $lv->minPlayers . TextFormat::GRAY . "]";
             $player->getServer()->broadcastMessage($message, $this->joinedPlayers);
             $lv->level->addSound(new DoorSound($player->getPosition()), $lv->joinedPlayers);
             $effect = MagicUtil::addEffect($player, Effect::STRENGTH);
             if ($effect != null) {
                 $this->playersWithEffects[$player->getName()] = $effect;
             }
             if (!$player->isOp()) {
                 if (!$player->isSurvival()) {
                     $player->setGamemode(Player::SURVIVAL);
                 }
             }
             $player->sendMessage(TextFormat::YELLOW . "[HG] Please wait here");
             $player->sendMessage(TextFormat::GRAY . "[HG] The game auto start with minimal players");
         }
     } else {
         if (isset($this->joinedPlayers[$player->getName()])) {
             $message = TextFormat::GRAY . "[ " . $player->getName() . " ] left " . $lv->displayName;
             $player->getServer()->broadcastMessage($message, $this->joinedPlayers);
             $lv->level->addSound(new DoorSound($player), $lv->joinedPlayers);
             unset($this->joinedPlayers[$player->getName()]);
             if (count($this->joinedPlayers) < $lv->minPlayers) {
                 $lv->joinDownCounter = $lv->joinDownCounterReset;
             }
             foreach ($plugin->arenaManager->arenas as &$arena) {
                 if ($arena instanceof MapArenaModel) {
                     if (isset($arena->votedPlayers[$player->getName()])) {
                         unset($arena->votedPlayers[$player->getName()]);
                         if ($arena->vote >= 1) {
                             $arena->vote--;
                         }
                         break;
                     }
                 }
             }
             if (isset($this->playersWithEffects[$player->getName()])) {
                 $effect = $this->playersWithEffects[$player->getName()];
                 if ($effect != null) {
                     $player->removeEffect($effect->getId());
                     unset($this->playersWithEffects[$player->getName()]);
                 }
             }
         }
     }
 }
示例#16
0
 /**
  *
  * @param Player $player        	
  * @return boolean
  */
 private function checkBlockBreakAndPlacementPermission(Player $player, $block)
 {
     $player->getLevel()->updateAllLight($player->getPosition());
     $allow = false;
     // check llobby
     if ($player->getLevel()->getName() === $this->plugin->hubLevelName || $player->getLevel()->getName() === $this->plugin->vipLevelName) {
         if (!$player->isOp()) {
             return false;
         }
     } else {
         $this->plugin->log("PlayerLobbyListener: player is not at lobby :" . $player->getLevel()->getName());
         if ($player instanceof Player && !$player->isOp() && !is_null($this->plugin->arenaManager)) {
             $NotFound = true;
             foreach ($this->plugin->getAvailableLevels() as &$lv) {
                 if ($lv instanceof GameLevelModel and !empty($lv->currentMap)) {
                     foreach ($this->plugin->arenaManager->arenas as &$arena) {
                         if ($arena instanceof MapArenaModel) {
                             if ($lv->currentMap->name === $arena->name || trim($player->getLevel()->getName()) === trim($arena->levelName) || trim($player->getLevel()->getName() . "_TEMP") === trim($arena->levelName . "_TEMP")) {
                                 $NotFound = false;
                                 if ($arena->allowBreakBlock || $arena->allowBlockPlace) {
                                     $this->plugin->log("PlayerLobbyListener: ARENA allow Break = true");
                                 }
                                 $allow = true;
                                 break;
                             }
                         }
                     }
                 }
                 if ($NotFound) {
                     $this->plugin->log("PlayerLobbyListener: arena not found :  ALLOW BREAK : TRUE");
                     $allow = true;
                 }
                 if ($allow) {
                     break;
                 }
             }
         }
     }
     if ($player->isOp()) {
         $allow = true;
     }
     return $allow;
 }
示例#17
-1
 public function handleTapOnGameLevelSigns(Player $player, $b)
 {
     $success = true;
     foreach ($this->plugin->getAvailableLevels() as &$lv) {
         if ($lv instanceof GameLevelModel) {
             if (!empty($lv->signStats)) {
                 $blockPosKey = round($b->x) . "." . round($b->y) . "." . round($b->z);
                 $casePosKey = round($lv->signStats->x) . "." . round($lv->signStats->y) . "." . round($lv->signStats->z);
                 if ($blockPosKey === $casePosKey && $blockPosKey != "0.0.0") {
                     if ($lv->status != GameLevelModel::STATUS_AVAILABLE) {
                         $player->sendMessage("[HG] The Hunger level #1 status [" . $lv->status . "]. Please join later.");
                         return;
                     }
                     if (count($lv->joinedPlayers) >= $lv->maxPlayers) {
                         $player->sendMessage("[HG] The Hunger level is full. Please join later.");
                         return;
                     }
                     $player->sendMessage(TextFormat::WHITE . "[HG] " . $lv->name . " is available!");
                     break;
                 }
             }
             if (!empty($lv->signJoin)) {
                 $blockPosKey = round($b->x) . "." . round($b->y) . "." . round($b->z);
                 $casePosKey = round($lv->signJoin->x) . "." . round($lv->signJoin->y) . "." . round($lv->signJoin->z);
                 if ($blockPosKey === $casePosKey && $blockPosKey != "0.0.0") {
                     if ($lv->status != GameLevelModel::STATUS_AVAILABLE) {
                         $player->sendMessage("[HG] The Hunger level #1 status [" . $lv->status . "]. Please join later.");
                         return;
                     }
                     if (count($lv->joinedPlayers) >= $lv->maxPlayers) {
                         $player->sendMessage("[HG] The Hunger level is full. Please join later.");
                         return;
                     }
                     $player->sendMessage(TextFormat::WHITE . "[HG] " . $lv->name . " is available!");
                     break;
                 }
             }
             if (!empty($lv->signJoin2)) {
                 $blockPosKey = round($b->x) . "." . round($b->y) . "." . round($b->z);
                 $casePosKey = round($lv->signJoin2->x) . "." . round($lv->signJoin2->y) . "." . round($lv->signJoin2->z);
                 if ($blockPosKey === $casePosKey && $blockPosKey != "0.0.0") {
                     $players[] = $player;
                     $player->getLevel()->addSound(new LaunchSound($player->getPosition()), $players);
                     if (is_null($lv->enterpos)) {
                         $this->plugin->log("[Error] Missing Game level entrance confguration");
                     } else {
                         $player->teleport($lv->enterpos);
                     }
                 }
             }
             if (!empty($lv->signExit) && !empty($lv->exitPos)) {
                 $blockPosKey = round($b->x) . "." . round($b->y) . "." . round($b->z);
                 $casePosKey = round($lv->signExit->x) . "." . round($lv->signExit->y) . "." . round($lv->signExit->z);
                 if ($blockPosKey === $casePosKey && $blockPosKey != "0.0.0") {
                     $player->teleport($lv->exitPos);
                     $this->handlePlayerLeaveTheGame($player);
                     break;
                 }
             }
         }
     }
     return $success;
 }