├── README.md ├── src └── BlockHunt │ ├── Entities │ ├── ArenaState.php │ ├── ArenaType.php │ ├── Enum.php │ └── Arena.php │ ├── Commands │ └── DefaultCMD.php │ ├── Tasks │ ├── PlayerObserverTask.php │ └── ArenaObserverTask.php │ ├── PlayerArenaData.php │ ├── Managers │ ├── ConfigX.php │ ├── CommandM.php │ ├── CommandX.php │ ├── ConfigM.php │ └── MessageM.php │ ├── Listeners │ └── OnSignChangeEvent.php │ ├── Storage.php │ ├── Handlers │ ├── SignsHandler.php │ └── ArenaHandler.php │ ├── BlockHunt.php │ └── ConfigC.php ├── plugin.yml ├── resources └── config.yml └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | HideHunt (Pocketmine-MP plugin) 2 | =================== 3 | 4 | PocketMine-MP Hide n Seek Plugin 5 | -------------------------------------------------------------------------------- /src/BlockHunt/Entities/ArenaState.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/BlockHunt/Commands/DefaultCMD.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /plugin.yml: -------------------------------------------------------------------------------- 1 | name: BlockHunt 2 | main: BlockHunt\BlockHunt 3 | version: 0.1.1 4 | api: 3.0.0 5 | author: Kagehis4 6 | website: https://github.com/ryuzaki01/pocketmine-HideHunt 7 | commands: 8 | BlockHunt: 9 | usage: / 10 | description: N/A 11 | aliases: 12 | - bh 13 | - blockhunt 14 | permissions: 15 | BlockHunt: 16 | default: op 17 | description: "All the permissions to use the BlockHunt" 18 | -------------------------------------------------------------------------------- /src/BlockHunt/Entities/ArenaType.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/BlockHunt/Tasks/PlayerObserverTask.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 13 | } 14 | 15 | public function onRun($currentTick){ 16 | 17 | } 18 | } 19 | 20 | ?> -------------------------------------------------------------------------------- /src/BlockHunt/PlayerArenaData.php: -------------------------------------------------------------------------------- 1 | pGameMode = $pGameMode; 19 | $this->pInventory = $pInventory; 20 | $this->pArmor = $pArmor; 21 | $this->pEXP = $pEXP; 22 | $this->pEXPL = $pEXPL; 23 | $this->pHealth = $pHealth; 24 | $this->pFood = $pFood; 25 | $this->pPotionEffects = $pPotionEffects; 26 | $this->pFlying = $pFlying; 27 | } 28 | } 29 | ?> -------------------------------------------------------------------------------- /src/BlockHunt/Managers/ConfigX.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 15 | $this->filename = $filename; 16 | } 17 | 18 | public static function init(){ 19 | if (!file_exists($this->plugin->dataDir . $this->filename.".yml")) { 20 | $this->plugin->getLogger()->info(TextFormat::RED ."Can't find ".$this->filename." creating new one !"); 21 | $d = new Config($this->plugin->dataDir . $this->filename . ".yml", Config::YAML, array()); 22 | 23 | $d->save(); 24 | return $d; 25 | } 26 | return new Config($this->plugin->dataDir . $this->filename . ".yml", Config::YAML, array()); 27 | } 28 | } -------------------------------------------------------------------------------- /src/BlockHunt/Listeners/OnSignChangeEvent.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 17 | } 18 | 19 | public function onSignChangeEvent(SignChangeEvent $event, Player $sender) 20 | { 21 | $lines = $event->getLines(); 22 | if ($lines[0] != null) { 23 | if ((strtolower($lines[0]) === "[" + strtolower($this->plugin->getName()) + "]" ) && $sender->hasPermission("blockhunt.moderator.signcreate")) { 24 | SignsHandler::createSign($event, $lines, new Position($event->getBlock()->getX(), $event->getBlock()->getY(), $event->getBlock()->getZ(), $event->getBlock()->getLevel())); 25 | } 26 | } 27 | } 28 | } 29 | ?> -------------------------------------------------------------------------------- /src/BlockHunt/Storage.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 30 | $this->messages = new ConfigM($this->plugin, "messages"); 31 | $this->arenas = new ConfigM($this->plugin, "arenas"); 32 | $this->signs = new ConfigM($this->plugin, "signs"); 33 | $this->shop = new ConfigM($this->plugin, "shop"); 34 | } 35 | } -------------------------------------------------------------------------------- /src/BlockHunt/Managers/CommandM.php: -------------------------------------------------------------------------------- 1 | 19 | public $CMD; // DeFaultCMD 20 | public $usage; // String 21 | 22 | public function __construct(BlockHunt $plugin, $name, $label, $args, $argsalias, $permission, $help, $enabled, $mainTRBlist, $CMD, $usage) // [String name, String label, String args, String argsalias, PermissionsC.Permissions permission, ConFigC 23 | { 24 | $me = new self(); 25 | $me->plugin = $plugin; 26 | $me->name = $name; 27 | $me->label = $label; 28 | $me->args = $args; 29 | $me->argsalias = $argsalias; 30 | $me->permission = $permission; 31 | $me->help = $help; 32 | $me->enabled = $enabled->booleanValue(); 33 | $me->mainTRBlist = $mainTRBlist; 34 | $me->CMD = $CMD; 35 | $me->usage = $usage; 36 | $this->plugin->commands->add($me); 37 | } 38 | } 39 | ?> -------------------------------------------------------------------------------- /src/BlockHunt/Managers/CommandX.php: -------------------------------------------------------------------------------- 1 | 18 | public $CMD; // DeFaultCMD 19 | public $usage; // String 20 | 21 | private function __init() { // deFault class members 22 | public static function __staticinit() // static class members 23 | } 24 | 25 | public static function __construct($name, $label, $args, $argsalias, $permission, $help, $enabled, $mainTRBlist, $CMD, $usage) // [String name, String label, String args, String argsalias, PermissionsC.Permissions permission, ConFigC 26 | { 27 | $me = new self(); 28 | $me->__init(): 29 | $me->name = $name; 30 | $me->label = $label; 31 | $me->args = $args; 32 | $me->argsalias = $argsalias; 33 | $me->permission = $permission; 34 | $me->help = $help; 35 | $me->enabled = $enabled->booleanValue(); 36 | $me->mainTRBlist = $mainTRBlist; 37 | $me->CMD = $CMD; 38 | $me->usage = $usage; 39 | W::$commands->add($me); 40 | return $me; 41 | } 42 | } 43 | CommandM::__staticinit(); // initialize static vars For this class on load 44 | ?> -------------------------------------------------------------------------------- /src/BlockHunt/Entities/Enum.php: -------------------------------------------------------------------------------- 1 | value = $value; 30 | } 31 | 32 | /** 33 | * @return mixed 34 | */ 35 | public function getValue() 36 | { 37 | return $this->value; 38 | } 39 | 40 | /** 41 | * @return string 42 | */ 43 | public function __toString() 44 | { 45 | return (string) $this->value; 46 | } 47 | 48 | /** 49 | * Returns all possible values as an array 50 | * @return array Constant name in key, constant value in value 51 | */ 52 | public static function toArray() 53 | { 54 | $calledClass = get_called_class(); 55 | if(!array_key_exists($calledClass, self::$constantsCache)) { 56 | $reflection = new \ReflectionClass($calledClass); 57 | self::$constantsCache[$calledClass] = $reflection->getConstants(); 58 | } 59 | return self::$constantsCache[$calledClass]; 60 | } 61 | 62 | /** 63 | * Returns a value when called statically like so: MyEnum::SOME_VALUE() given SOME_VALUE is a class constant 64 | * @param string $name 65 | * @param array $arguments 66 | * @return static 67 | * @throws \BadMethodCallException 68 | */ 69 | public static function __callStatic($name, $arguments) 70 | { 71 | if (defined("static::$name")) { 72 | return new static(constant("static::$name")); 73 | } 74 | throw new \BadMethodCallException("No static method or enum constant '$name' in class " . get_called_class()); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /resources/config.yml: -------------------------------------------------------------------------------- 1 | chat: 2 | tag: '[BlockHunt] ' 3 | normal: '&b' 4 | warning: '&c' 5 | error: '&c' 6 | arg: '&e' 7 | header: '&9' 8 | headerhigh: '%H_______.[ %A%header%%H ]._______' 9 | commandEnabled: 10 | info: true 11 | help: true 12 | reload: true 13 | join: true 14 | leave: true 15 | list: true 16 | shop: true 17 | start: true 18 | wand: true 19 | create: true 20 | set: true 21 | setwarp: true 22 | remove: true 23 | tokens: true 24 | autoUpdateCheck: true 25 | autoDownloadUpdate: false 26 | vaultSupport: false 27 | wandIDname: STICK 28 | wandName: '%A&lBlockHunt%N''s selection wand' 29 | wandDescription: 30 | - '%NUse this item to select an arena for your arena.' 31 | - '%ALeft-Click%N to select point #1.' 32 | - '%ARight-Click%N to select point #2.' 33 | - '%NUse the create command to define your arena.' 34 | - '%A/BlockHunt ' 35 | shop: 36 | title: '%H&lBlockHunt %NShop' 37 | price: '%NPrice: %A%amount% %Ntokens.' 38 | blockChooserv1Enabled: true 39 | blockChooserv1IDname: BOOK 40 | blockChooserv1Price: 3000 41 | blockChooserv1Name: '%H&lBlock Chooser' 42 | blockChooserv1Description: 43 | - '%NUse this item before the arena starts.' 44 | - '%ARight-Click%N in the lobby and choose' 45 | - '%Nthe block you want to be!' 46 | - '&6Unlimited uses.' 47 | BlockHuntPassv2Enabled: true 48 | BlockHuntPassv2IDName: NAME_TAG 49 | BlockHuntPassv2Price: 150 50 | BlockHuntPassv2Name: '%H&lBlockHunt Pass' 51 | BlockHuntPassv2Description: 52 | - '%NUse this item before the arena starts.' 53 | - '%ARight-Click%N in the lobby and choose' 54 | - '%Nif you want to be a Hider or a Seeker!' 55 | - '&61 time use.' 56 | sign: 57 | LEAVE: 58 | - '%H[BlockHunt%H]' 59 | - '&4LEAVE' 60 | - '&8Right-Click' 61 | - '&8To leave.' 62 | SHOP: 63 | - '%H[BlockHunt%H]' 64 | - '&4SHOP' 65 | - '&8Right-Click' 66 | - '&8To shop.' 67 | WAITING: 68 | - '%H[BlockHunt%H]' 69 | - '%A%arenaname%' 70 | - '%A%players%%N/%A%maxplayers%' 71 | - '&8Waiting...' 72 | STARTING: 73 | - '%H[BlockHunt%H]' 74 | - '%A%arenaname%' 75 | - '%A%players%%N/%A%maxplayers%' 76 | - '&2Start: %A%timeleft%' 77 | INGAME: 78 | - '%H[BlockHunt%H]' 79 | - '%A%arenaname%' 80 | - '%A%players%%N/%A%maxplayers%' 81 | - '%EIngame: %A%timeleft%' 82 | scoreboard: 83 | enabled: true 84 | title: '%H[BlockHunt]' 85 | timeleft: '%ATime left:' 86 | seekers: '%NSeekers:' 87 | hiders: '%NHiders:' 88 | vaultBank: '%NBank:' 89 | tokenAmount: '%NTokens:' 90 | requireInventoryClearOnJoin: false -------------------------------------------------------------------------------- /src/BlockHunt/Managers/ConfigM.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 19 | $this->filename = $filename; 20 | $this->location = $location; 21 | $this->checkFile(); 22 | $this->fileC = new Config($this->plugin->dataDir . $this->filename . ".yml", Config::YAML, array()); 23 | } 24 | 25 | public function checkFile(){ 26 | if (!file_exists($this->plugin->dataDir . $this->filename.".yml")) { 27 | $this->plugin->getLogger()->info(TextFormat::RED ."Can't find ".$this->filename." creating new one !"); 28 | $this->fileC = new Config($this->plugin->dataDir . $this->filename . ".yml", Config::YAML, array()); 29 | $this->fileC->save(); 30 | if($this->location != ""){ 31 | $this->plugin->storage->newFiles[] = $this->location . $this->filename . ".yml"; 32 | } else { 33 | $this->plugin->storage->newFiles[] = $this->plugin->dataDir . $this->filename . ".yml"; 34 | } 35 | } 36 | } 37 | 38 | public static function newFiles() { 39 | $this->setDefaults(); 40 | foreach($this->plugin->storage->newFiles as $fileName) { 41 | MessageM.sendMessage(null, "%TAG%WCouldn't find '%A%fileName%.yml%W' creating new one.", "fileName-" . $fileName); 42 | } 43 | 44 | $this->plugin->storage->newFiles = []; 45 | } 46 | 47 | public static function setDefaults() { 48 | foreach(ConfigC::values() as $value) { 49 | $value->config->load(); 50 | if ($value->config->get($value->location) == null) { 51 | $value->config->set($value->location, $value->value); 52 | $value->config->save(); 53 | } 54 | } 55 | } 56 | 57 | 58 | public function load(){ 59 | $this->checkFile(); 60 | if (file_exists($this->plugin->dataDir . $this->filename.".yml")) { 61 | try { 62 | $this->fileC->load($this->plugin->dataDir . $this->filename.".yml"); 63 | } catch (Exception $e) { 64 | $this->plugin->getLogger()->info('Caught exception: ', $e->getMessage(), "\n"); 65 | } 66 | } 67 | } 68 | 69 | public function get($params){ 70 | return $this->fileC->get($params); 71 | } 72 | 73 | public function getAll(){ 74 | return $this->fileC->getAll(); 75 | } 76 | 77 | public function set($params, $val){ 78 | return $this->fileC->set($params, $val); 79 | } 80 | 81 | public function save(){ 82 | return $this->fileC->save(); 83 | } 84 | 85 | public function reload(){ 86 | return $this->fileC->reload(); 87 | } 88 | } -------------------------------------------------------------------------------- /src/BlockHunt/Managers/MessageM.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 14 | } 15 | 16 | public static function sendMessage(Player $player, $message, $vars) 17 | { 18 | if (player == null) { 19 | $this->getLogger()->info(replaceAll(str_replace("%player%", "Console", $message), $vars)); 20 | } else { 21 | player.sendMessage(replaceAll(str_replace("%player%", player.getName(), $message), $vars)); 22 | } 23 | } 24 | 25 | public static function sendFMessage(Player $player, ConfigC $location, $vars) 26 | { 27 | if ($player == null) { 28 | Bukkit.getConsoleSender().sendMessage(replaceAll(str_replace("%player%", "Console", $location->config->get($location->location)), vars)); 29 | } else { 30 | player.sendMessage(replaceAll( 31 | location.config.getFile().get(location.location).toString() 32 | .replaceAll("%player%", player.getName()), vars)); 33 | } 34 | } 35 | 36 | public static function broadcastMessage(String message, String... vars) 37 | { 38 | for (Player player : Bukkit.getServer().getOnlinePlayers()) { 39 | player.sendMessage(replaceAll( 40 | message.replaceAll("%player%", player.getName()), vars)); 41 | } 42 | Bukkit.getConsoleSender().sendMessage( 43 | replaceAll(message.replaceAll("%player%", "Console"), 44 | vars)); 45 | } 46 | 47 | public static function broadcastFMessage(ConfigC location, String... vars) 48 | { 49 | for (Player player : Bukkit.getServer().getOnlinePlayers()) { 50 | player.sendMessage(replaceAll( 51 | location.config.getFile().get(location.location).toString() 52 | .replaceAll("%player%", player.getName()), vars)); 53 | } 54 | $this->plugin->getServer()->dispatchCommand(new ConsoleCommandSender(), replaceAll(location.config.getFile().get(location.location).toString().replaceAll("%player%", "Console"), vars)); 55 | } 56 | 57 | public static String replaceAll($message, $vars) 58 | { 59 | return replaceColours(replaceColourVars( 60 | replaceVars(message, vars))); 61 | } 62 | 63 | public static String replaceColours($message) 64 | { 65 | return message.replaceAll("(&([a-fk-or0-9]))", "§$2"); 66 | } 67 | 68 | public static String replaceColourVars($message) 69 | { 70 | message = message.replaceAll("%N", CType.NORMAL()); 71 | message = message.replaceAll("%W", CType.WARNING()); 72 | message = message.replaceAll("%E", CType.ERROR()); 73 | message = message.replaceAll("%A", CType.ARG()); 74 | message = message.replaceAll("%H", CType.HEADER()); 75 | message = message.replaceAll("%TAG", CType.TAG()); 76 | return message; 77 | } 78 | 79 | public static String replaceVars(String message, String... vars) 80 | { 81 | for (String var : vars) 82 | { 83 | String[] split = var.split("-"); 84 | message = message.replaceAll("%" + split[0] + "%", split[1]); 85 | } 86 | return message; 87 | } 88 | 89 | public static class CType 90 | { 91 | public static String NORMAL() 92 | { 93 | return (String)W.config.get(ConfigC.chat_normal); 94 | } 95 | 96 | public static String WARNING() 97 | { 98 | return (String)W.config.get(ConfigC.chat_warning); 99 | } 100 | 101 | public static String ERROR() 102 | { 103 | return (String)W.config.get(ConfigC.chat_error); 104 | } 105 | 106 | public static String ARG() 107 | { 108 | return (String)W.config.get(ConfigC.chat_arg); 109 | } 110 | 111 | public static String HEADER() 112 | { 113 | return (String)W.config.get(ConfigC.chat_header); 114 | } 115 | 116 | public static String TAG() 117 | { 118 | return 119 | 120 | (String)W.config.get(ConfigC.chat_header) + (String)W.config.get(ConfigC.chat_tag) + (String)W.config.get(ConfigC.chat_normal); 121 | } 122 | } 123 | } 124 | ?> -------------------------------------------------------------------------------- /src/BlockHunt/Entities/Arena.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 40 | $this->arenaName = $arenaName; 41 | $this->pos1 = $pos1; 42 | $this->pos2 = $pos2; 43 | $this->maxPlayers = $maxPlayers; 44 | $this->minPlayers = $minPlayers; 45 | $this->amountSeekersOnStart = $amountSeekersOnStart; 46 | $this->timeInLobbyUntilStart = $timeInLobbyUntilStart; 47 | $this->waitingTimeSeeker = $waitingTimeSeeker; 48 | $this->gameTime = $gameTime; 49 | $this->timeUntilHidersSword = $timeUntilHidersSword; 50 | $this->disguiseBlocks = $disguiseBlocks; 51 | $this->lobbyWarp = $lobbyWarp; 52 | $this->hidersWarp = $hidersWarp; 53 | $this->seekersWarp = $seekersWarp; 54 | $this->spawnWarp = $spawnWarp; 55 | $this->seekersWinCommands = $seekersWinCommands; 56 | $this->hidersWinCommands = $hidersWinCommands; 57 | $this->allowedCommands = $allowedCommands; 58 | $this->seekersTokenWin = $seekersTokenWin; 59 | $this->hidersTokenWin = $hidersTokenWin; 60 | $this->killTokens = $killTokens; 61 | 62 | $this->playersInArena = $playersInArena; 63 | $this->gameState = $gameState; 64 | $this->timer = $timer; 65 | $this->seekers = $seekers; 66 | } 67 | 68 | public function serialize() 69 | { 70 | $map = array(); 71 | $map["arenaName"] = $this->arenaName; 72 | $map["pos1"] = $this->pos1; 73 | $map["pos2"] = $this->pos2; 74 | $map["maxPlayers"] = $this->maxPlayers; 75 | $map["minPlayers"] = $this->minPlayers; 76 | $map["amountSeekersOnStart"] = $this->amountSeekersOnStart; 77 | $map["timeInLobbyUntilStart"] = $this->timeInLobbyUntilStart; 78 | $map["waitingTimeSeeker"] = $this->waitingTimeSeeker; 79 | $map["gameTime"] = $this->gameTime; 80 | $map["timeUntilHidersSword"] = $this->timeUntilHidersSword; 81 | $map["disguiseBlocks"] = $this->disguiseBlocks; 82 | $map["lobbyWarp"] = $this->lobbyWarp; 83 | $map["hidersWarp"] = $this->hidersWarp; 84 | $map["seekersWarp"] = $this->seekersWarp; 85 | $map["spawnWarp"] = $this->spawnWarp; 86 | $map["seekersWinCommands"] = $this->seekersWinCommands; 87 | $map["hidersWinCommands"] = $this->hidersWinCommands; 88 | $map["allowedCommands"] = $this->allowedCommands; 89 | $map["seekersTokenWin"] = $this->seekersTokenWin; 90 | $map["hidersTokenWin"] = $this->hidersTokenWin; 91 | $map["killTokens"] = $this->killTokens; 92 | return $map; 93 | } 94 | 95 | public static function deserialize($map) 96 | { 97 | return new Arena( 98 | $map["arenaName"], 99 | $map["pos1"], 100 | $map["pos2"], 101 | $map["maxPlayers"], 102 | $map["minPlayers"], 103 | $map["amountSeekersOnStart"], 104 | $map["timeInLobbyUntilStart"], 105 | $map["waitingTimeSeeker"], 106 | $map["gameTime"], 107 | $map["timeUntilHidersSword"], 108 | $map["disguiseBlocks"], 109 | $map["lobbyWarp"], 110 | $map["hidersWarp"], 111 | $map["seekersWarp"], 112 | $map["spawnWarp"], 113 | $map["seekersWinCommands"], 114 | $map["hidersWinCommands"], 115 | $map["allowedCommands"], 116 | $map["seekersTokenWin"], 117 | $map["hidersTokenWin"], 118 | $map["killTokens"]; 119 | } 120 | } 121 | 122 | ?> -------------------------------------------------------------------------------- /src/BlockHunt/Handlers/SignsHandler.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 19 | } 20 | 21 | public static function createSign(SignChangeEvent $event, $lines, $location) 22 | { 23 | if ($lines[1] != null) { 24 | if (strtolower($lines[1]) == "leave") 25 | { 26 | $saved = false; 27 | $number = 1; 28 | while (!$saved) { 29 | if ($this->plugin->storage->signs->get("leave_" . $number) == null) 30 | { 31 | $this->plugin->storage->signs->set("leave_" . $number . ".arenaName", "leave"); 32 | $this->plugin->storage->signs->set("leave_" . $number . ".location", $location); 33 | $this->plugin->storage->signs->save(); 34 | 35 | $saved = true; 36 | } 37 | else 38 | { 39 | $number++; 40 | } 41 | } 42 | } 43 | else if (strtolower($lines[1]) == "shop") 44 | { 45 | $saved = false; 46 | $number = 1; 47 | while (!$saved) { 48 | if ($this->plugin->storage->signs->get("shop_" . $number) == null) 49 | { 50 | $this->plugin->storage->signs->set("shop_" . $number . ".arenaName", 51 | "shop"); 52 | $this->plugin->storage->signs->set("shop_" . $number . ".location", 53 | location); 54 | $this->plugin->storage->signs->save(); 55 | 56 | $saved = true; 57 | } 58 | else 59 | { 60 | $number++; 61 | } 62 | } 63 | } 64 | else 65 | { 66 | $saved = false; 67 | foreach($this->plugin->storage->arenaList as $arena) { 68 | if ($lines[1] == $arena->arenaName) 69 | { 70 | $number = 1; 71 | while (!$saved) { 72 | if ($this->plugin->storage->signs->get( 73 | $arena->arenaName . "_" . $number) == null) 74 | { 75 | $this->plugin->storage->signs->set($arena->arenaName . "_" . $number . ".arenaName", $lines[1]); 76 | $this->plugin->storage->signs->set($$arena->arenaName . "_" . $number .".location", $location); 77 | $this->plugin->storage->signs->save(); 78 | 79 | $saved = true; 80 | } 81 | else 82 | { 83 | $number++; 84 | } 85 | } 86 | } 87 | } 88 | if (!$saved) { 89 | MessageM::sendFMessage($sender, $this->plugin->storage->message->get("error")["noArena"], "name-" . $lines[1] ); 90 | } 91 | } 92 | } 93 | } 94 | 95 | public static function removeSign(Position $position) 96 | { 97 | foreach($this->plugin->storage->signs->getAll() as $sign) 98 | { 99 | $signloc = $this->plugin->storage->signs->get($sign.".location"); 100 | $locx = new Position($signloc->getX() - 0.5, $signloc->getY(), $signloc->getZ() - 0.5, $signloc->getLevel()); 101 | if ($locx === $position) 102 | { 103 | $this->plugin->storage->signs->set($sign, null); 104 | } 105 | } 106 | } 107 | 108 | public static function isSign(Position $position) 109 | { 110 | foreach($this->plugin->storage->signs->getAll() as $sign) 111 | { 112 | $signloc = $this->plugin->storage->signs->get($sign.".location"); 113 | $locx = new Position($signloc->getX() - 0.5, $signloc->getY(), $signloc->getZ() - 0.5, $signloc->getLevel()); 114 | if ($locx == $position) { 115 | return true; 116 | } 117 | } 118 | return false; 119 | } 120 | 121 | public function updateSigns() 122 | { 123 | $this->plugin->storage->signs->reload(); 124 | foreach($this->plugin->storage->signs->getAll() as $sign) 125 | { 126 | $signloc = $this->plugin->storage->signs->get($sign.".location"); 127 | $locx = new Position($signloc->getX() - 0.5, $signloc->getY(), $signloc->getZ() - 0.5, $signloc->getLevel()); 128 | if (($locx->getBlock()->getID() == Item::SIGN_POST) || ($loc->getBlock()->getID() == Item::WALL_SIGN)) 129 | { 130 | $signblock = $locx->getBlock(); 131 | $lines = $signblock->getLines(); 132 | if (strpos($sign, "leave")) 133 | { 134 | $signLines = $this->plugin->config->get('sign')['LEAVE']; 135 | $linecount = 0; 136 | foreach($signLines as $line) 137 | { 138 | if ($linecount <= 3) { 139 | $signblock->setLine($linecount, MessageM::replaceAll($line)); 140 | } 141 | $linecount++; 142 | } 143 | $signblock->update(); 144 | } 145 | else 146 | { 147 | $linecount; 148 | if (strpos($sign, "shop")) 149 | { 150 | $signLines = $this->plugin->config->get('sign')['SHOP']; 151 | $linecount = 0; 152 | foreach($signLines as $line) 153 | { 154 | if ($linecount <= 3) { 155 | $signblock->setLine($linecount, MessageM::replaceAll($line)); 156 | } 157 | $linecount++; 158 | } 159 | $signblock->update(); 160 | } 161 | else 162 | { 163 | foreach($this->plugin->storage->arenaList as $arena) { 164 | if (substr($lines[1], -strlen($arena->arenaName)) === $arena->arenaName) { 165 | if ($arena::gameState == ArenaState::WAITING) 166 | { 167 | $signLines = $this->plugin->config->get('sign')['WAITING']; 168 | $linecount = 0; 169 | if ($signLines != null) { 170 | foreach($signLines as $line) 171 | { 172 | if ($linecount <= 3) { 173 | $signblock->setLine($linecount, MessageM::replaceAll( $line, ["arenaname-" . $arena->arenaName, "players-" . count($arena->playersInArena), "maxplayers-" . $arena->maxPlayers, "timeleft-" . $arena->timer])); 174 | } 175 | $linecount++; 176 | } 177 | } 178 | $signblock->update(); 179 | } 180 | else if ($arena::gameState == ArenaState::STARTING) 181 | { 182 | $signLines = $this->plugin->config->get('sign')['STARTING']; 183 | $linecount = 0; 184 | if ($signLines != null) { 185 | foreach($signLines as $line) 186 | { 187 | if (linecount <= 3) { 188 | $signblock->setLine($linecount, MessageM::replaceAll($line, ["arenaname-" . $arena->arenaName, "players-" . count($arena->playersInArena), "maxplayers-".$arena->maxPlayers, "timeleft-" . $arena->timer ])); 189 | } 190 | $linecount++; 191 | } 192 | } 193 | $signblock->update(); 194 | } 195 | else if ($arena::gameState == ArenaState::INGAME) 196 | { 197 | $signLines = $this->plugin->config->get('sign')['INGAME']; 198 | $linecount = 0; 199 | if ($signLines != null) { 200 | foreach($signLines as $line) 201 | { 202 | if ($linecount <= 3) { 203 | $signblock->setLine($linecount, MessageM::replaceAll($line, [ "arenaname-" . $arena->arenaName, "players-".count($arena->playersInArena), "maxplayers-" . $arena->maxPlayers, "timeleft-" . $arena->timer ])); 204 | } 205 | $linecount++; 206 | } 207 | } 208 | $signblock->update(); 209 | } 210 | } 211 | } 212 | } 213 | } 214 | } 215 | else 216 | { 217 | removeSign($loc); 218 | } 219 | } 220 | } 221 | } 222 | 223 | ?> -------------------------------------------------------------------------------- /src/BlockHunt/BlockHunt.php: -------------------------------------------------------------------------------- 1 | getLogger()->info(TextFormat::WHITE . "BlockHunt plugin has been loaded!"); 50 | } 51 | 52 | public function onEnable(){ 53 | @mkdir("plugins/BlockHunt"); 54 | $this->dataDir = "plugins/BlockHunt/"; 55 | 56 | $this->checkConfig(); 57 | $this->storage = new Storage($this); 58 | 59 | $this->getServer()->getPluginManager()->registerEvents($this, $this); 60 | // $this->getServer()->getPluginManager()->registerEvents(new OnBlockBreakEvent($this), $this); 61 | // $this->getServer()->getPluginManager()->registerEvents(new OnBlockPlaceEvent($this), $this); 62 | // $this->getServer()->getPluginManager()->registerEvents(new OnEntityDamageByEntityEvent(), $this); 63 | // $this->getServer()->getPluginManager()->registerEvents(new OnEntityDamageEvent($this), $this); 64 | // $this->getServer()->getPluginManager()->registerEvents(new OnFoodLevelChangeEvent($this), $this); 65 | // $this->getServer()->getPluginManager()->registerEvents(new OnInventoryClickEvent($this), $this); 66 | // $this->getServer()->getPluginManager()->registerEvents(new OnInventoryCloseEvent($this), $this); 67 | // $this->getServer()->getPluginManager()->registerEvents(new OnPlayerCommandPreprocessEvent($this), $this); 68 | // $this->getServer()->getPluginManager()->registerEvents(new OnPlayerDropItemEvent($this), $this); 69 | // $this->getServer()->getPluginManager()->registerEvents(new OnPlayerInteractEvent($this), $this); 70 | // $this->getServer()->getPluginManager()->registerEvents(new OnPlayerMoveEvent($this), $this); 71 | // $this->getServer()->getPluginManager()->registerEvents(new OnPlayerQuitEvent($this), $this); 72 | $this->getServer()->getPluginManager()->registerEvents(new OnSignChangeEvent($this), $this); 73 | 74 | 75 | //setupEconomy(); 76 | 77 | $this->signsHandler = new SignsHandler($this); 78 | 79 | $this->arenaHandler = new ArenaHandler($this); 80 | $this->arenaHandler->loadArenas(); 81 | 82 | $this->getServer()->getScheduler()->scheduleRepeatingTask(new ArenaObserverTask($this), 6000); 83 | 84 | $this->getLogger()->info(TextFormat::GREEN ."BlockHunt plugin has been enabled!"); 85 | } 86 | 87 | public function onCommand(CommandSender $sender, Command $command, $label, array $params){ 88 | $cmd = strtolower($command->getName()); 89 | 90 | if(!($sender instanceof Player)){ 91 | $sender->sendMessage(TextFormat::RED . "Please run this command in-game.\n"); 92 | return false; 93 | } 94 | 95 | if(!$sender->isOp()){ 96 | return false; 97 | } 98 | 99 | for (CommandM command : W.commands) { 100 | String[] argsSplit = null; 101 | String[] argsSplitAlias = null; 102 | 103 | if (command.args != null && command.argsalias != null) { 104 | argsSplit = command.args.split("/"); 105 | argsSplitAlias = command.argsalias.split("/"); 106 | } 107 | 108 | if (cmd.getName().equalsIgnoreCase(command.label)) { 109 | boolean equals = true; 110 | 111 | if (argsSplit == null) { 112 | if (args.length == 0) { 113 | equals = true; 114 | } else { 115 | equals = false; 116 | } 117 | } else { 118 | if (args.length >= argsSplit.length) { 119 | for (int i2 = argsSplit.length - 1; i2 >= 0; i2 = i2 - 1) { 120 | int loc = argsSplit.length - i2 - 1; 121 | if (!argsSplit[loc].equalsIgnoreCase(args[loc]) 122 | && !argsSplitAlias[loc] 123 | .equalsIgnoreCase(args[loc])) { 124 | equals = false; 125 | } 126 | } 127 | } else { 128 | equals = false; 129 | } 130 | } 131 | 132 | if (equals) { 133 | if (PermissionsM.hasPerm(player, command.permission, true)) { 134 | if (command.enabled) { 135 | command.CMD.exectue(player, cmd, label, args); 136 | } else { 137 | MessageM.sendFMessage(player, 138 | ConfigC.error_commandNotEnabled); 139 | } 140 | } 141 | 142 | return true; 143 | } 144 | } 145 | } 146 | 147 | CMDnotfound.execute(player, cmd, label, args); 148 | return true; 149 | } 150 | 151 | public function onDisable(){ 152 | if(count($this->storage->arenaList) > 0){ 153 | foreach($this->storage->arenaList as $arena) { 154 | $this->arenaHandler->stopArena($arena); 155 | } 156 | } 157 | 158 | $this->getLogger()->info(TextFormat::RED . "BlockHunt plugin has been disabled!"); 159 | } 160 | 161 | private function checkConfig(){ 162 | $this->getConfig()->save(); 163 | $this->config = $this->getConfig(); 164 | if(!$this->config->exists("chat")){ 165 | $this->config->set("chat", array( 166 | tag => "[BlockHunt] ", 167 | normal => "&b", 168 | warning => "&c", 169 | error => "&c", 170 | arg => "&e ", 171 | header => "&9", 172 | headerhigh => "%H_______.[ %A%header%%H ]._______" 173 | )); 174 | } elseif(!$this->config->exists("commandEnabled")){ 175 | $this->config->set("commandEnabled", array( 176 | info => true, 177 | help => true, 178 | reload => true, 179 | join => true, 180 | leave => true, 181 | 'list' => true, 182 | shop => true, 183 | start => true, 184 | wand => true, 185 | create => true, 186 | set => true, 187 | setwarp => true, 188 | remove => true, 189 | tokens => true 190 | )); 191 | } elseif(!$this->config->exists("wandIDname")){ 192 | $this->config->set("wandIDname", "STICK"); 193 | } elseif(!$this->config->exists("wandName")){ 194 | $this->config->set("wandName", "%A&lBlockHunt%N''s selection wand"); 195 | } elseif(!$this->config->exists("wandDescription")){ 196 | $this->config->set("wandDescription", array( 197 | "%NUse this item to select an arena for your arena.", 198 | "%ALeft-Click%N to select point #1.", 199 | "%ARight-Click%N to select point #2.", 200 | "%NUse the create command to define your arena.", 201 | "%A/BlockHunt " 202 | )); 203 | } elseif(!$this->config->exists("commandEnabled")){ 204 | $this->config->set("commandEnabled", array( 205 | title => "%H&BlockHunt %NShop", 206 | price => "%NPrice: %A%amount% %Ntokens.", 207 | blockChooserv1Enabled => true, 208 | blockChooserv1IDname => "BOOK", 209 | blockChooserv1Price => 3000, 210 | blockChooserv1Name => "%H&lBlock Chooser", 211 | blockChooserv1Description => array( 212 | "%NUse this item before the arena starts.", 213 | "%ARight-Click%N in the lobby and choose", 214 | "%Nthe block you want to be!", 215 | "&6Unlimited uses." 216 | ), 217 | BlockHuntPassv2Enabled => true, 218 | BlockHuntPassv2IDName => NAME_TAG, 219 | BlockHuntPassv2Price => 150, 220 | BlockHuntPassv2Name => "%H&lBlockHunt Pass", 221 | BlockHuntPassv2Description => array( 222 | "%NUse this item before the arena starts.", 223 | "%ARight-Click%N in the lobby and choose", 224 | "%Nif you want to be a Hider or a Seeker!", 225 | "&61 time use." 226 | ) 227 | )); 228 | } elseif(!$this->config->exists("sign")){ 229 | $this->config->set("sign", array( 230 | LEAVE => array( 231 | "%H[BlockHunt%H]", 232 | "&4LEAVE", 233 | "&8Right-Click", 234 | "&8To leave." 235 | ), 236 | SHOP => array( 237 | "%H[BlockHunt%H]", 238 | "&4SHOP", 239 | "&8Right-Click", 240 | "&8To shop." 241 | ), 242 | WAITING => array( 243 | "%H[BlockHunt%H]", 244 | "&4SHOP", 245 | "%A%players%%N/%A%maxplayers%", 246 | "&8Waiting..." 247 | ), 248 | STARTING => array( 249 | "%H[BlockHunt%H]", 250 | "%A%arenaname%", 251 | "%A%players%%N/%A%maxplayers%", 252 | "&2Start: %A%timeleft%" 253 | ), 254 | INGAME => array( 255 | "%H[BlockHunt%H]", 256 | "%A%arenaname%", 257 | "%A%players%%N/%A%maxplayers%", 258 | "%EIngame: %A%timeleft" 259 | ) 260 | )); 261 | } elseif(!$this->config->exists("scoreboard")){ 262 | $this->config->set("scoreboard", array( 263 | enabled => true, 264 | title => "%H[BlockHunt]", 265 | timeleft => "%ATime left:", 266 | seekers => "%NSeekers:", 267 | hiders => "%NHiders:", 268 | vaultBank => "%NBank:", 269 | tokenAmount => "%NTokens:" 270 | )); 271 | } elseif(!$this->config->exists("requireInventoryClearOnJoin")){ 272 | $this->config->set("requireInventoryClearOnJoin", false); 273 | } 274 | 275 | 276 | $this->config->save(); 277 | return true; 278 | } 279 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /src/BlockHunt/ConfigC.php: -------------------------------------------------------------------------------- 1 | " ], "config"); 38 | const $shop_title = array("%H&lBlockHunt %NShop", "config"); 39 | const $shop_price = array("%NPrice: %A%amount% %Ntokens.", "config"); 40 | const $shop_blockChooserv1Enabled = array(true, "config"); 41 | const $shop_blockChooserv1IDname = array("BOOK", "config"); 42 | const $shop_blockChooserv1Price = array(3000, "config"); 43 | const $shop_blockChooserv1Name = array("%H&lBlock Chooser", "config"); 44 | const $shop_blockChooserv1Description = array(["%NUse this item before the arena starts.", "%ARight-Click%N in the lobby and choose", "%Nthe block you want to be!", "&6Unlimited uses." ], "config"); 45 | const $shop_BlockHuntPassv2Enabled = array(true, "config"); 46 | const $shop_BlockHuntPassv2IDName = array("NAME_TAG", "config"); 47 | const $shop_BlockHuntPassv2Price = array(150, "config"); 48 | const $shop_BlockHuntPassv2Name = array("%H&lBlockHunt Pass", "config"); 49 | const $shop_BlockHuntPassv2Description = array(["%NUse this item before the arena starts.", "%ARight-Click%N in the lobby and choose", "%Nif you want to be a Hider or a Seeker!", "&61 time use." ], "config"); 50 | const $sign_LEAVE = array([ "%H[BlockHunt%H]", "&4LEAVE", "&8Right-Click", "&8To leave." ], "config"); 51 | const $sign_SHOP = array([ "%H[BlockHunt%H]", "&4SHOP", "&8Right-Click", "&8To shop." ], "config"); 52 | const $sign_WAITING = array([ "%H[BlockHunt%H]", "%A%arenaname%", "%A%players%%N/%A%maxplayers%", "&8Waiting..." ], "config"); 53 | const $sign_STARTING = array([ "%H[BlockHunt%H]", "%A%arenaname%", "%A%players%%N/%A%maxplayers%", "&2Start: %A%timeleft%" ], "config"); 54 | const $sign_INGAME = array([ "%H[BlockHunt%H]", "%A%arenaname%", "%A%players%%N/%A%maxplayers%", "%EIngame: %A%timeleft%" ], "config"); 55 | const $scoreboard_enabled = array(true, "config"); 56 | const $scoreboard_title = array("%H[BlockHunt]", "config"); 57 | const $scoreboard_timeleft = array("%ATime left:", "config"); 58 | const $scoreboard_seekers = array("%NSeekers:", "config"); 59 | const $scoreboard_hiders = array("%NHiders:", "config"); 60 | const $scoreboard_vaultBank = array("%NBank:", "config"); 61 | const $scoreboard_tokenAmount = array("%NTokens:", "config"); 62 | const $requireInventoryClearOnJoin = array(false, "config"); 63 | const $log_enabledPlugin = array("%TAG%N%name%&a&k + %N%version% is now Enabled. Made by %A%autors%%N.", "messages"); 64 | const $log_disabledPlugin = array("%TAG%N%name%&c&k - %N%version% is now Disabled. Made by %A%autors%%N.", "messages"); 65 | const $help_info = array("%NDisplays the plugin's info.", "messages"); 66 | const $help_help = array("%NShows a list of commands.", "messages"); 67 | const $help_reload = array("%NReloads all configs.", "messages"); 68 | const $help_join = array("%NJoins a BlockHunt game.", "messages"); 69 | const $help_leave = array("%NLeave a BlockHunt game.", "messages"); 70 | const $help_list = array("%NShows a list of available arenas.", "messages"); 71 | const $help_shop = array("%NOpens the BlockHunt shop.", "messages"); 72 | const $help_start = array("%NForces an arena to start.", "messages"); 73 | const $help_wand = array("%NGives you the wand selection tool.", "messages"); 74 | const $help_create = array("%NCreates an arena from your selection.", "messages"); 75 | const $help_set = array("%NOpens a panel to set settings.", "messages"); 76 | const $help_setwarp = array("%NSets warps for your arena.", "messages"); 77 | const $help_remove = array("%NDeletes an Arena.", "messages"); 78 | const $help_tokens = array("%NChange someones tokens.", "messages"); 79 | const $button_add = array("%NAdd %A%1%%N to %A%2%%N", "messages"); 80 | const $button_add2 = array("Add", "messages"); 81 | const $button_setting = array("%NSetting %A%1%%N is now: %A%2%%N.", "messages"); 82 | const $button_remove = array("%NRemove %A%1%%N from %A%2%%N", "messages"); 83 | const $button_remove2 = array("Remove", "messages"); 84 | const $normal_reloadedConfigs = array("%TAG&aReloaded all configs!", "messages"); 85 | const $normal_joinJoinedArena = array("%TAG%A%playername%%N joined your arena. (%A%1%%N/%A%2%%N)", "messages"); 86 | const $normal_leaveYouLeft = array("%TAG%NYou left the arena! Thanks for playing !", "messages"); 87 | const $normal_leaveLeftArena = array("%TAG%A%playername%%N left your arena. (%A%1%%N/%A%2%%N)", "messages"); 88 | const $normal_startForced = array("%TAG%NYou forced to start arena '%A%arenaname%%N'!", "messages"); 89 | const $normal_wandGaveWand = array("%TAG%NHere you go! &o(Use the %A&o%type%%N&o!)", "messages"); 90 | const $normal_wandSetPosition = array("%TAG%NSet position %A#%number%%N to location: (%A%x%%N, %A%y%%N, %A%z%%N).", "messages"); 91 | const $normal_createCreatedArena = array("%TAG%NCreated an arena with the name '%A%name%%N'.", "messages"); 92 | const $normal_lobbyArenaIsStarting = array("%TAG%NThe arena will start in %A%1%%N second(s)!", "messages"); 93 | const $normal_lobbyArenaStarted = array("%TAG%NThe arena has been started! The seeker is coming to find you in %A%secs%%N seconds!", "messages"); 94 | const $normal_ingameSeekerChoosen = array("%TAG%NPlayer %A%seeker%%N has been choosen as seeker!", "messages"); 95 | const $normal_ingameBlock = array("%TAG%NYou're disguised as a(n) '%A%block%%N' block.", "messages"); 96 | const $normal_ingameArenaEnd = array("%TAG%NThe arena will end in %A%1%%N second(s)!", "messages"); 97 | const $normal_ingameSeekerSpawned = array("%TAG%A%playername%%N has spawned as a seeker!", "messages"); 98 | const $normal_ingameGivenSword = array("%TAG%NYou were given a sword!", "messages"); 99 | const $normal_ingameHiderDied = array("%TAG%NHider %A%playername%%N died! %A%left%%N hider(s); remain...", "messages"); 100 | const $normal_ingameSeekerDied = array("%TAG%NSeeker %A%playername%%N died! He will respawn in %A%secs%%N seconds!", "messages"); 101 | const $normal_winSeekers = array("%TAG%NThe %ASEEKERS%N have won!", "messages"); 102 | const $normal_winHiders = array("%TAG%NThe %AHIDERS%N have won!", "messages"); 103 | const $normal_setwarpWarpSet = array("%TAG%NSet warp '%A%warp%%N' to your location!", "messages"); 104 | const $normal_addedToken = array("%TAG%A%amount%%N tokens were added to your account!", "messages"); 105 | const $normal_addedVaultBalance = array("%TAG%A%amount%%N was added to your bank!", "messages"); 106 | const $normal_addedVaultBalanceKill = array("%TAG%A%amount%%N has been added for killing a hider", "messages"); 107 | const $normal_removeRemovedArena = array("%TAG%NRemoved arena '%A%name%%N'!", "messages"); 108 | const $normal_tokensChanged = array("%TAG%N%option% %A%amount%%N tokens %option2% %A%playername%%N.", "messages"); 109 | const $normal_tokensChangedPerson = array("%TAG%NPlayer %A%playername%%N %N%option% %A%amount%%N %option2% your tokens.", "messages"); 110 | const $normal_ingameNowSolid = array("%TAG%NYou're now a solid '%A%block%%N' block!", "messages"); 111 | const $normal_ingameNoMoreSolid = array("%TAG%NYou're no longer a solid block!", "messages"); 112 | const $normal_shopBoughtItem = array("%TAG%NYou've bought the '%A%itemname%%N' item!", "messages"); 113 | const $normal_shopChoosenBlock = array("%TAG%NYou've choosen to be a(n) '%A%block%%N' block!", "messages"); 114 | const $normal_shopChoosenSeeker = array("%TAG%NYou've choosen to be a %Aseeker%N!", "messages"); 115 | const $normal_shopChoosenHiders = array("%TAG%NYou've choosen to be a %Ahider%N!", "messages"); 116 | const $warning_lobbyNeedAtleast = array("%TAG%WYou need atleast %A%1%%W player(s) to start the game!", "messages"); 117 | const $warning_ingameNEWSeekerChoosen = array("%TAG%WThe last seeker left and a new seeker has been choosen!", "messages"); 118 | const $warning_unableToCommand = array("%TAG%WSorry but that command is disabled in the arena.", "messages"); 119 | const $warning_ingameNoSolidPlace = array("%TAG%WThat's not a valid place to become solid!", "messages"); 120 | const $warning_arenaStopped = array("%TAG%WThe arena has been forced to stop!", "messages"); 121 | const $warning_noVault = array("%TAG%WUsing BlockHunts token system!", "messages"); 122 | const $warning_usingVault = array("%TAG%WUsing Vault support", "messages"); 123 | const $error_noPermission = array("%TAG%EYou don't have the permissions to do that!", "messages"); 124 | const $error_notANumber = array("%TAG%E'%A%1%%E' is not a number!", "messages"); 125 | const $error_commandNotEnabled = array("%TAG%EThis command has been disabled!", "messages"); 126 | const $error_commandNotFound = array("%TAG%ECouldn't find the command. Try %A/BlockHunt help %Efor more info.", "messages"); 127 | const $error_notEnoughArguments = array("%TAG%EYou're missing arguments, correct syntax: %A%syntax%", "messages"); 128 | const $error_libsDisguisesNotInstalled = array("%TAG%EThe plugin '%ALib's Disguises%E' is required to run this plugin! Intall it or it won't work!", "messages"); 129 | const $error_protocolLibNotInstalled = array("%TAG%EThe plugin '%AProtocolLib%E' is required to run this plugin! Intall it or it won't work!", "messages"); 130 | const $error_noArena = array("%TAG%ENo arena found with the name '%A%name%%E'.", "messages"); 131 | const $error_onlyIngame = array("%TAG%EThis is an only in-game command!", "messages"); 132 | const $error_joinAlreadyJoined = array("%TAG%EYou've already joined an arena!", "messages"); 133 | const $error_joinNoBlocksSet = array("%TAG%EThere are none blocks set for this arena. Notify the administrator.", "messages"); 134 | const $error_joinWarpsNotSet = array("%TAG%EThere are no warps set for this arena. Notify the administrator.", "messages"); 135 | const $error_joinArenaIngame = array("%TAG%EThis game has already started.", "messages"); 136 | const $error_joinFull = array("%TAG%EUnable to join this arena. It's full!", "messages"); 137 | const $error_joinInventoryNotEmpty = array("%TAG%EYour inventory should be empty before joining!", "messages"); 138 | const $error_leaveNotInArena = array("%TAG%EYou're not in an arena!", "messages"); 139 | const $error_createSelectionFirst = array("%TAG%EMake a selection first. Use the wand command: %A/BlockHunt %E.", "messages"); 140 | const $error_createNotSameWorld = array("%TAG%EMake your selection points in the same world!", "messages"); 141 | const $error_setTooHighNumber = array("%TAG%EThat amount is too high! Max amount is: %A%max%%E.", "messages"); 142 | const $error_setTooLowNumber = array("%TAG%EThat amount is too low! Minimal amount is: %A%min%%E.", "messages"); 143 | const $error_setNotABlock = array("%TAG%EThat is not a block!", "messages"); 144 | const $error_setwarpWarpNotFound = array("%TAG%EWarp '%A%warp%%E' is not valid!", "messages"); 145 | const $error_tokensPlayerNotOnline = array("%TAG%ENo player found with the name '%A%playername%%E'!", "messages"); 146 | const $error_tokensUnknownsetting = array("%TAG%E'%A%option%%E' is not a known option!", "messages"); 147 | const $error_shopNeedMoreTokens = array("%TAG%EYou need more tokens before you can buy this item.", "messages"); 148 | const $error_shopMaxSeekersReached = array("%TAG%ESorry, the maximum amount of seekers has been reached!", "messages"); 149 | const $error_shopMaxHidersReached = array("%TAG%ESorry, the maximum amount of hiders has been reached!", "messages"); 150 | const $error_trueVaultNull = array("%TAG%EVault has been enabled in the config.yml but cannot find the 'Vault' plugin! The plugin will not run", "messages"); 151 | 152 | private $plugin; 153 | public $value; 154 | public $config; 155 | public $location; 156 | 157 | public function __construct(Plugin $plugin, $value){ 158 | $this->plugin = $plugin; 159 | $this->config = new ConfigM($plugin, $this->${$value}[0]); 160 | $this->value = $value; 161 | $this->location = str_replace("_", "->", $value); 162 | } 163 | 164 | public function values(){ 165 | $enums = new ReflectionClass($this); 166 | return $enums->getConstants(); 167 | } 168 | } 169 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /src/BlockHunt/Handlers/ArenaHandler.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 23 | } 24 | 25 | public function loadArenas(){ 26 | unset($this->plugin->storage->arenaList); 27 | foreach($this->plugin->storage->arenas as $arenaname => $arenaval) { 28 | $this->plugin->storage->arenaList[] = $this->plugin->storage->arenas->get($arenaname); 29 | } 30 | foreach($this->plugin->storage->arenaList as $arena) { 31 | //ScoreboardHandler::createScoreboard($arena->; 32 | } 33 | } 34 | 35 | public static function sendMessage(Arena $arena, $message, $vars) 36 | { 37 | foreach($arena->playersInArena as $player) 38 | { 39 | $pMessage = str_replace(array("%player%"), $player->getName(), $message); 40 | $player->sendMessage(MessageM::replaceAll($pMessage, $vars)); 41 | } 42 | } 43 | 44 | public static function sendFMessage(Arena $arena, $location, $vars) 45 | { 46 | foreach($arena->playersInArena as $player) 47 | { 48 | $pMessage = str_replace("%player%", $player->getName(), $location->config->get($location->location)); 49 | $player->sendMessage(MessageM::replaceAll($pMessage, $vars)); 50 | } 51 | } 52 | 53 | public static function playerJoinArena(Player $player, $arenaname) 54 | { 55 | $found = false; 56 | $alreadyJoined = false; 57 | foreach($this->plugin->storage->$arena->arenaList as $arena) { 58 | if (($arena->playersInArena != null) && 59 | ($arena->playersInArena->contains($player))) { 60 | $alreadyJoined = true; 61 | } 62 | } 63 | if (!$alreadyJoined) 64 | { 65 | foreach($this->plugin->storage->$arena->arenaList as $arena) { 66 | if (strtolower($arena->arenaname) == strtolower($arenaname)) 67 | { 68 | $found = true; 69 | if ($arena->disguiseBlocks->isEmpty()) 70 | { 71 | MessageM::sendFMessage($player, $this->plugin->getConfig()->get("error")["joinNoBlocksSet"], []); 72 | } 73 | else 74 | { 75 | $inventoryempty = true; 76 | foreach($player->getInventory() as $invitem) { 77 | if (($invitem != null) && ($invitem->getID() != 0)) { 78 | $inventoryempty = false; 79 | } 80 | } 81 | $localObject; 82 | $j = count($localObject = $player->getInventory()->getArmorContents()); 83 | for ($i = 0; $i < $j; $i++) 84 | { 85 | $invitem = $localObject[$i]; 86 | if ($invitem->getID() != 0) { 87 | $inventoryempty = false; 88 | } 89 | } 90 | if ($this->plugin->getConfig()->get("requireInventoryClearOnJoin") && (!$inventoryempty)) 91 | { 92 | MessageM::sendFMessage(player, $this->plugin->getConfig()->get("error")["joinInventoryNotEmpty"]); 93 | return; 94 | } 95 | $zero = new Position(0, 0, 0, $player->getLevel()); 96 | if (($arena->lobbyWarp != null) && ($arena->hidersWarp != null) && ($arena->seekersWarp != null) && ($arena->spawnWarp != null)) 97 | { 98 | if ((!$arena->lobbyWarp == $zero) && 99 | (!$arena->hidersWarp == $zero) && 100 | (!$arena->seekersWarp == $zero) && 101 | (!$arena->spawnWarp == $zero)) 102 | { 103 | if (($arena->gameState == ArenaState::WAITING) || 104 | ($arena->gameState == ArenaState::STARTING)) 105 | { 106 | if ($arena->playersInArena.size() >= $arena->maxPlayers) { 107 | if (!$player-hasPermission('blockhunt.moderator.joinfull')) 108 | { 109 | MessageM::sendFMessage(player, $this->plugin->storage->messages->get("error")["joinFull"], []); 110 | return; 111 | } 112 | } 113 | $arena->playersInArena.add(player); 114 | 115 | $pad = new PlayerArenaData( 116 | $player->getLocation(), 117 | $player->getGameMode(), 118 | $player->getInventory()->getContents(), 119 | $player->getInventory()->getArmorContents(), 120 | $player->getExp(), 121 | $player->getLevel(), 122 | $player->getHealth(), 123 | $player->getFoodLevel(), 124 | $player->getActivePotionEffects(), 125 | $player->getAllowFlight()); 126 | 127 | $this->plugin->storage->pData[] = array($player, $pad); 128 | 129 | $player->teleport($arena->lobbyWarp); 130 | $player->setGameMode(0); 131 | 132 | // $localObject = $player->getActivePotionEffects().iterator(); 133 | // while (((Iterator)localObject).hasNext()) 134 | // { 135 | // PotionEffect pe = (PotionEffect)((Iterator)localObject).next(); 136 | // $player->removePotionEffect(pe.getType()); 137 | // } 138 | $player->setFoodLevel(20); 139 | $player->setHealth(20); 140 | $player->setLevel($arena->timer); 141 | $player->setExp(0.0); 142 | $player->getInventory()->clearAll(); 143 | $player->getInventory()->setHelmet(Item::AIR); 144 | $player->getInventory()->setChestplate(Item::AIR); 145 | $player->getInventory()->setLeggings(Item::AIR); 146 | $player->getInventory()->setBoots(Item::AIR); 147 | $player->setFlying(false); 148 | $player->setAllowFlight(false); 149 | if ($this->plugin->getConfig()->get("shop")["blockChooserv1Enabled"] && (($this->plugin->storage->shop->get($player->getName().".blockchooser") != null) || $player-hasPermission('blockhunt.admin.blockchooser'))) 150 | { 151 | $shopBlockChooser = new Item($this->plugin->getConfig()->get("shop")["blockChooserv1IDname"], 0, 1, MessageM::replaceAll($this->plugin->getConfig()->get("shop")["blockChooserv1Name"])); 152 | 153 | $player->getInventory()->addItem($shopBlockChooser); 154 | } 155 | if ($this->plugin->getConfig()->get("shop")["BlockHuntPassv2Enabled"] && ($this->plugin->storage->shop.get($player->getName().".blockhuntpass") != 0)) 156 | { 157 | $shopBlockHuntPass = new Item($this->plugin->getConfig()->get("shop")["BlockHuntPassv2IDName"], 0, 1, MessageM::replaceAll($this->plugin->getConfig()->get("shop")["BlockHuntPassv2Name"])); 158 | 159 | $player->getInventory().addItem($shopBlockHuntPass); 160 | } 161 | 162 | $player->updateInventory(); 163 | 164 | DisguiseAPI.undisguiseToAll(player); 165 | 166 | sendFMessage($arena, $this->plugin->storage->message->get("normal")["joinJoinedArena"], [ "playername-" . $player->getName(), "1-" . count($arena->playersInArena), "2-" . $arena->maxPlayers ]); 167 | if (count($arena->playersInArena) < $arena->minPlayers) { 168 | sendFMessage($arena, $this->plugin->getConfig()->get("warning")["lobbyNeedAtleast"], [ "1-" . $arena->minPlayers ]); 169 | } 170 | } 171 | else 172 | { 173 | MessageM::sendFMessage($player, $this->plugin->storage->messages->get("error")["joinArenaIngame"], []); 174 | } 175 | } 176 | else { 177 | MessageM::sendFMessage($player, $this->plugin->storage->messages->get("error")["joinWarpsNotSet"], []); 178 | } 179 | } 180 | else { 181 | MessageM::sendFMessage(player, $this->plugin->storage->messages->get("error")["joinWarpsNotSet"], []); 182 | } 183 | } 184 | } 185 | } 186 | } 187 | else 188 | { 189 | MessageM::sendFMessage(player, $this->plugin->storage->messages->get("error")['joinAlreadyJoined'], []); 190 | return; 191 | } 192 | if (!$found) { 193 | MessageM::sendFMessage(player, $this->plugin->storage->messages->get("error")["noArena"], ["name-" .$arenaname]); 194 | } 195 | 196 | SignsHandler($this->plugin)->updateSigns(); 197 | } 198 | 199 | public static function playerLeaveArena(Player $player, $message, $cleanup) 200 | { 201 | $arena = null; 202 | foreach($this->plugin->storage->arenaList as $arena2) { 203 | if (($arena->playersInArena != null) && (in_array($player, $arena->playersInArena))) { 204 | $arena = $arena2; 205 | } 206 | } 207 | if ($arena != null) 208 | { 209 | if ($cleanup) 210 | { 211 | unset($arena->playersInArena[$player]); 212 | if (in_array($player, $arena->seekers)) { 213 | unset($arena->seekers[$player]); 214 | } 215 | if (($arena->playersInArena.size() < $arena->minPlayers) && 216 | ($arena->gameState.equals(ArenaState::STARTING))) 217 | { 218 | $arena->gameState = ArenaState::WAITING; 219 | $arena->timer = 0; 220 | 221 | sendFMessage($arena, $this->plugin->storage->messages->get("warning")["lobbyNeedAtleast"], ["1-".$arena->minPlayers ]); 222 | } 223 | if (($arena->playersInArena.size() <= 2) && 224 | ($arena->gameState == ArenaState::INGAME)) { 225 | if (count($arena->seekers) >= count($arena->playersInArena)) { 226 | $this->seekersWin($arena); 227 | } else { 228 | $this->hidersWin($arena); 229 | } 230 | } 231 | if (count($arena->seekers) >= count($arena->playersInArena)) { 232 | $this->seekersWin($arena); 233 | } 234 | if ((count($arena->seekers) <= 0) && ($arena->gameState == ArenaState::INGAME)) 235 | { 236 | $seeker = $arena->playersInArena->get(mt_rand($this->plugin->storage->random, count($arena->playersInArena) - 1)); 237 | sendFMessage($arena, $this->plugin->storage->messages->get("warning")["ingameNEWSeekerChoosen"], ["seeker-" . $seeker->getName() ]); 238 | sendFMessage($arena, $this->plugin->storage->messages->get("normal")["ingameSeekerChoosen"], ["seeker-" .$seeker->getName() ]); 239 | DisguiseAPI::undisguiseToAll($seeker); 240 | foreach($this->plugin->getServer->getOnlinePlayers() as $pl) { 241 | $pl->showPlayer($seeker); 242 | } 243 | $seeker->getInventory()->clearAll(); 244 | $arena->seekers[] = $seeker; 245 | $seeker->teleport($arena->seekersWarp); 246 | $this->plugin->storage->seekertime[$seeker] = $arena->waitingTimeSeeker; 247 | } 248 | } 249 | $pad = new PlayerArenaData(null, null, null, null, null, null, null, null, null, false); 250 | if ($this->plugin->storage->pData[$player] != null) { 251 | $pad = $this->plugin->storage->pData[$player]; 252 | } 253 | $player->getInventory()->clearAll(); 254 | $player->getInventory()->setContents($pad->pInventory); 255 | $player->getInventory()->setArmorContents($pad->pArmor); 256 | $player->setExp(floatval($pad->pEXP)); 257 | $player->setLevel(intval($pad->pEXPL)); 258 | $player->setHealth(floatval($pad->pHealth)); 259 | $player->setFoodLevel(intval($pad->pFood)); 260 | $player->addPotionEffects($pad->pPotionEffects); 261 | $player->teleport($arena->spawnWarp); 262 | $player->setGameMode($pad->pGameMode); 263 | $player->setAllowFlight($pad->pFlying); 264 | if ($player->getAllowFlight()) { 265 | $player->setFlying(true); 266 | } 267 | unset($this->plugin->storage->pData[$player]); 268 | foreach($this->plugin->getServer->getOnlinePlayers() as $pl) 269 | { 270 | $pl->showPlayer($player); 271 | if (($this->plugin->storage->hiddenLoc[$player] != null) && ($this->plugin->storage->hiddenLocWater[$player] != null)) 272 | { 273 | $pBlock = ($this->plugin->storage->hiddenLoc[$player]); 274 | if ($this->plugin->storage->hiddenLocWater[$player]) { 275 | $pl->setBlock(new Vector3($pBlock->getX(), $pBlock->getY(), $pBlock->getZ()), Block::STILL_WATER, false, true); 276 | } else { 277 | $pl->setBlock(new Vector3($pBlock->getX(), $pBlock->getY(), $pBlock->getZ()), Block::AIR, false, true); 278 | } 279 | } 280 | DisguiseAPI::undisguiseToAll($player); 281 | } 282 | //ScoreboardHandler::removeScoreboard($player); 283 | 284 | MessageM::sendFMessage(player, $this->plugin->storage->messages->get("normal")["leaveYouLeft"], []); 285 | if ($message) { 286 | sendFMessage($arena, $this->plugin->storage->messages->get("normal")["leaveLeftArena"], ["playername-" . $player->getName(), "1-" . $arena->playersInArena.size(), "2-" . $arena->maxPlayers ]); 287 | } 288 | } 289 | else 290 | { 291 | if ($message) { 292 | MessageM::sendFMessage($player, $this->plugin->storage->messages->get("error")["leaveNotInArena"], []); 293 | } 294 | return; 295 | } 296 | SignsHandler($this->plugin)->updateSigns(); 297 | } 298 | 299 | public static function seekersWin(Arena $arena) 300 | { 301 | sendFMessage($arena, $this->plugin->storage->messages->get("normal")["winSeekers"], []); 302 | foreach($arena->playersInArena as $player) { 303 | if ($arena->seekersWinCommands != null) 304 | { 305 | foreach($arena->seekersWinCommands as $command) { 306 | $this->plugin->getServer()->dispatchCommand(new ConsoleCommandSender(), str_replace("%player%", $player->getName(), $command)); 307 | } 308 | if ($this->plugin->getConfig()->get("vaultSupport")) 309 | { 310 | if ($this->plugin->econ != null) 311 | { 312 | $this->plugin->econ->depositPlayer($player->getName(), $arena->seekersTokenWin); 313 | MessageM::sendFMessage($player, $this->plugin->storage->messages->get("normal")["addedVaultBalance"], ["amount-" .$arena->seekersTokenWin ]); 314 | } 315 | } 316 | else 317 | { 318 | if ($this->plugin->storage->shop->get($player->getName() . ".tokens") == null) 319 | { 320 | $this->plugin->storage->shop->set($player->getName() . ".tokens", 0); 321 | $this->plugin->storage->shop->save(); 322 | } 323 | $playerTokens = $this->plugin->storage->shop->get($player->getName() . ".tokens"); 324 | $this->plugin->storage->shop->set($player->getName() . ".tokens", intval($playerTokens . $arena->seekersTokenWin)); 325 | $this->plugin->storage->shop->save(); 326 | 327 | MessageM::sendFMessage(player, $this->plugin->storage->messages->get("normal")["addedToken"], ["amount-" . $arena->seekersTokenWin ]); 328 | } 329 | } 330 | } 331 | $arena->seekers = []; 332 | foreach($arena->playersInArena as $player) 333 | { 334 | playerLeaveArena($player, false, false); 335 | //$player->playSound($player->getLocation(), Sound.LEVEL_UP, 1.0F, 1.0F); 336 | } 337 | $arena->gameState = ArenaState::WAITING; 338 | $arena->timer = 0; 339 | $arena->playersInArena = []; 340 | } 341 | 342 | public static function hidersWin(Arena $arena) 343 | { 344 | sendFMessage($arena, $this->plugin->storage->messages->get("normal")["winHiders"], []); 345 | foreach($arena->playersInArena as $player) { 346 | if ((!in_array($player, $arena->seekers)) && ($arena->hidersWinCommands != null)) 347 | { 348 | foreach($arena->hidersWinCommands as $command) { 349 | $this->plugin->getServer()->dispatchCommand(new ConsoleCommandSender(), str_replace("%player%", $player->getName(), $command)); 350 | } 351 | if ($this->plugin->storage->config->get("vaultSupport")) 352 | { 353 | if (($this->plugin->econ != null) && (!in_array($player, $arena->seekers))) 354 | { 355 | $this->plugin->econ->depositPlayer($player->getName(), $arena->hidersTokenWin); 356 | MessageM::sendFMessage(player, $this->plugin->storage->messages->get("normal")["addedVaultBalance"], ["amount-" . $arena->hidersTokenWin ]); 357 | } 358 | } 359 | else 360 | { 361 | if ($this->plugin->storage->shop->get($player->getName() . ".tokens") == null) 362 | { 363 | $this->plugin->storage->shop->set($player->getName() . ".tokens", 0); 364 | $this->plugin->storage->shop->save(); 365 | } 366 | $playerTokens = $this->plugin->storage->shop->get($player->getName() . ".tokens"); 367 | $this->plugin->storage->shop.getFile().set($player->getName() . ".tokens", intval($playerTokens . $arena->hidersTokenWin)); 368 | $this->plugin->storage->shop->save(); 369 | 370 | MessageM::sendFMessage(player, $this->plugin->storage->messages->get("normal")["addedToken"], ["amount-" . $arena->hidersTokenWin ]); 371 | } 372 | } 373 | } 374 | $arena->seekers = []; 375 | foreach($arena->playersInArena as $player) 376 | { 377 | playerLeaveArena(player, false, false); 378 | //$player->playSound($player->getLocation(), Sound.LEVEL_UP, 1.0F, 1.0F); 379 | } 380 | $arena->gameState = ArenaState::WAITING; 381 | $arena->timer = 0; 382 | $arena->playersInArena = []; 383 | } 384 | 385 | public static function stopArena(Arena $arena) 386 | { 387 | sendFMessage($arena, $this->plugin->storage->messages->get("warning")["arenaStopped"], []); 388 | 389 | $arena->seekers = []; 390 | foreach($arena->playersInArena as $player) 391 | { 392 | $this->playerLeaveArena($player, false, false); 393 | //$player->playSound($player->getLocation(), Sound.LEVEL_UP, 1.0F, 1.0F); 394 | } 395 | $arena->gameState = ArenaState::WAITING; 396 | $arena->timer = 0; 397 | $arena->playersInArena = []; 398 | } 399 | } 400 | -------------------------------------------------------------------------------- /src/BlockHunt/Tasks/ArenaObserverTask.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 27 | } 28 | 29 | public function onRun($currentTick){ 30 | if(count($this->plugin->storage->arenaList > 0)){ 31 | foreach($this->plugin->storage->arenaList as $arena) 32 | { 33 | $loop = false; 34 | $block = false; 35 | if ($arena->gameState == ArenaState::WAITING) 36 | { 37 | if (count($arena->playersInArena) >= $arena->minPlayers) 38 | { 39 | $arena->gameState = ArenaState::STARTING; 40 | $arena->timer = $arena->timeInLobbyUntilStart; 41 | ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["lobbyArenaIsStarting"], "1-" . $arena->timeInLobbyUntilStart ); 42 | } 43 | } 44 | else if ($arena->gameState == ArenaState::STARTING) 45 | { 46 | $arena->timer -= 1; 47 | if ($arena->timer > 0) 48 | { 49 | if ($arena->timer == 60) 50 | { 51 | ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["lobbyArenaIsStarting"], "1-60" ); 52 | } 53 | else if ($arena->timer == 30) 54 | { 55 | ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["lobbyArenaIsStarting"], "1-30" ); 56 | } 57 | else if ($arena->timer == 10) 58 | { 59 | ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["lobbyArenaIsStarting"], "1-10" ); 60 | } 61 | else if ($arena->timer == 5) 62 | { 63 | // for (Player pl : $arena->playersInArena) { 64 | // pl.playSound(pl.getLocation(), Sound.ORB_PICKUP, 1, 0); 65 | // } 66 | ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["lobbyArenaIsStarting"], "1-5" ); 67 | } 68 | else if ($arena->timer == 4) 69 | { 70 | // for (Player pl : $arena->playersInArena) { 71 | // pl.playSound(pl.getLocation(), 72 | // Sound.ORB_PICKUP, 1, 0); 73 | // } 74 | ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["lobbyArenaIsStarting"], "1-4" ); 75 | } 76 | else if ($arena->timer == 3) 77 | { 78 | // for (Player pl : $arena->playersInArena) { 79 | // pl.playSound(pl.getLocation(), 80 | // Sound.ORB_PICKUP, 1, 1); 81 | // } 82 | ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["lobbyArenaIsStarting"], "1-3" ); 83 | } 84 | else if ($arena->timer == 2) 85 | { 86 | // for (Player pl : $arena->playersInArena) { 87 | // pl.playSound(pl.getLocation(), 88 | // Sound.ORB_PICKUP, 1, 1); 89 | // } 90 | ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["lobbyArenaIsStarting"], "1-2" ); 91 | } 92 | else if ($arena->timer == 1) 93 | { 94 | // for (Player pl : $arena->playersInArena) { 95 | // pl.playSound(pl.getLocation(), 96 | // Sound.ORB_PICKUP, 1, 2); 97 | // } 98 | ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["lobbyArenaIsStarting"], "1-1" ); 99 | } 100 | } 101 | else 102 | { 103 | $arena->gameState = ArenaState::INGAME; 104 | $arena->timer = $arena->gameTime; 105 | ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["lobbyArenaStarted"], "secs-" . $arena->waitingTimeSeeker); 106 | for ($i = $arena->amountSeekersOnStart; $i > 0; $i--) 107 | { 108 | $loop = true; 109 | $seeker = mt_rand(0, (count($arena->playersInArena)-1)); 110 | foreach($arena->playersInArena as $playerCheck) { 111 | if ($this->plugin->storage->choosenSeeker[$playerCheck] != null) { 112 | if ($this->plugin->storage->choosenSeeker[$playerCheck]) 113 | { 114 | $seeker = $playerCheck; 115 | unset($this->plugin->storage->choosenSeeker[$playerCheck]); 116 | } 117 | else if ($seeker == $playerCheck) 118 | { 119 | $i++; 120 | $loop = false; 121 | } 122 | } 123 | } 124 | if ($loop) { 125 | if (!in_array($seeker, $arena->seekers)) 126 | { 127 | ArenaHandler::sendFMessage($arena, "%TAG%NPlayer %A%seeker%%N has been choosen as seeker!", "seeker-" . $seeker->getName() ); 128 | $arena->seekers[] = $seeker; 129 | $seeker->teleport($arena->seekersWarp); 130 | $seeker.getInventory()->clearAll(); 131 | $this->plugin->storage->seekertime[$seeker] = $arena->waitingTimeSeeker; 132 | } 133 | else 134 | { 135 | $i++; 136 | } 137 | } 138 | } 139 | foreach($arena->playersInArena as $arenaPlayer) { 140 | if (!in_array($arenaPlayer, $arena->seekers)) 141 | { 142 | $arenaPlayer->getInventory()->clearAll(); 143 | 144 | $block = $arena->disguiseBlocks[mt_rand(0, count($arena->disguiseBlocks))]; 145 | if ($this->plugin->storage->choosenBlock[$arenaPlayer] != null) 146 | { 147 | $block = $this->plugin->storage->choosenBlock[$arenaPlayer]; 148 | unset($this->plugin->storage->choosenBlock[$arenaPlayer]); 149 | } 150 | 151 | DisguiseAPI::disguiseToAll($arenaPlayer, $block->getID()); 152 | 153 | $arenaPlayer->teleport($arena->hidersWarp); 154 | 155 | $blockCount = Item::get(5); 156 | $blockCount->setDurability($block->getMaxDurability()); 157 | $arenaPlayer.getInventory()->setItem(8, $blockCount); 158 | $arenaPlayer.getInventory()->setArmorItem(0, $block); 159 | $this->plugin->storage->pBlock[$arenaPlayer] = $block; 160 | if ($block.getDurability() != 0) { 161 | MessageM::sendFMessage($arenaPlayer,"%TAG%NYou're disguised as a(n) '%A%block%%N' block.", "block-" . block.getType()->name().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase() . ":" . block.getDurability() ); 162 | } else { 163 | MessageM.sendFMessage($arenaPlayer, $this->plugin->storage->message->get("normal")["ingameBlock"], "block-" . $block.getType()->name().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase() ); 164 | } 165 | } 166 | } 167 | } 168 | } 169 | foreach($arena->seekers as $player) 170 | { 171 | if (($player->getInventory()->getItem(0) == null) || ($player->getInventory()->getItem(0)->getID() != Item::DIAMOND_SWORD)) 172 | { 173 | $player->getInventory().setItem(0, Item::DIAMOND_SWORD); 174 | $player->getInventory().setArmorItem(0, Item::IRON_HELMET); 175 | $player->getInventory().setArmorItem(1, Item::IRON_CHESTPLATE); 176 | $player->getInventory().setArmorItem(2, Item::IRON_LEGGINGS); 177 | $player->getInventory().setArmorItem(3, Item::IRON_BOOTS); 178 | //$player->playSound(player.getLocation(), Sound.ANVIL_USE, 1, 1); 179 | } 180 | if ($this->plugin->storage->seekertime[$player] != null) 181 | { 182 | $this->plugin->storage->seekertime[$player] -= 1; 183 | if ($this->plugin->storage->seekertime[$player] <= 0) 184 | { 185 | $player->teleport($arena->hidersWarp); 186 | unset($this->plugin->storage->seekertime[$player]); 187 | ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["ingameSeekerSpawned"], "playername-" . player.getName() ); 188 | } 189 | } 190 | } 191 | if ($arena->gameState == ArenaState::INGAME) 192 | { 193 | $arena->timer -= 1; 194 | if ($arena->timer > 0) 195 | { 196 | if ($arena->timer == $arena->gameTime - $arena->timeUntilHidersSword) 197 | { 198 | $sword = Item::WOOD_SWORD; 199 | //$sword->addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); 200 | foreach($arena->playersInArena as $arenaPlayer) 201 | { 202 | if (!in_array($arenaPlayer, $arena->seekers)) 203 | { 204 | $arenaPlayer->getInventory()->addItem($sword); 205 | MessageM.sendFMessage($arenaPlayer, $this->plugin->storage->message->get("normal")["ingameGivenSword"]); 206 | } 207 | } 208 | } 209 | if ($arena->timer == 190) 210 | { 211 | ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["ingameArenaEnd"], "1-190" ); 212 | } 213 | else if ($arena->timer == 60) 214 | { 215 | ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["ingameArenaEnd"], "1-60" ); 216 | } 217 | else if ($arena->timer == 30) 218 | { 219 | ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["ingameArenaEnd"], "1-30" ); 220 | } 221 | else if ($arena->timer == 10) 222 | { 223 | ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["ingameArenaEnd"], "1-10" ); 224 | } 225 | else if ($arena->timer == 5) 226 | { 227 | //$arena->lobbyWarp.getWorld().playSound($arena->lobbyWarp, Sound.ORB_PICKUP, 1, 0); 228 | ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["ingameArenaEnd"], "1-5" ); 229 | } 230 | else if ($arena->timer == 4) 231 | { 232 | //$arena->lobbyWarp.getWorld().playSound($arena->lobbyWarp, Sound.ORB_PICKUP, 1, 0); 233 | ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["ingameArenaEnd"], "1-4" ); 234 | } 235 | else if ($arena->timer == 3) 236 | { 237 | //$arena->lobbyWarp.getWorld().playSound($arena->lobbyWarp, Sound.ORB_PICKUP, 1, 1); 238 | ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["ingameArenaEnd"], "1-3" ); 239 | } 240 | else if ($arena->timer == 2) 241 | { 242 | //$arena->lobbyWarp.getWorld().playSound($arena->lobbyWarp, Sound.ORB_PICKUP, 1, 1); 243 | ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["ingameArenaEnd"], "1-2" ); 244 | } 245 | else if ($arena->timer == 1) 246 | { 247 | $arena->lobbyWarp.getWorld().playSound($arena->lobbyWarp,Sound.ORB_PICKUP, 1, 2); 248 | ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["ingameArenaEnd"], "1-1" ); 249 | } 250 | } 251 | else 252 | { 253 | ArenaHandler::hidersWin(arena); 254 | return; 255 | } 256 | foreach($arena->playersInArena as $arenaPlayer) 257 | { 258 | if (!$arena->seekers.contains($arenaPlayer)) 259 | { 260 | $pLoc = new Position($arenaPlayer->getX() - 0.5, $arenaPlayer->getY(), $arenaPlayer->getZ() - 0.5, $arenaPlayer->getLevel()); 261 | $moveLoc = $this->plugin->storage->moveLoc[$arenaPlayer]; 262 | $block = $arenaPlayer->getInventory()->getItem(8); 263 | if (($block == null) && ($this->plugin->storage->pBlock[$arenaPlayer] != null)) 264 | { 265 | $block = $this->plugin->storage->pBlock[$arenaPlayer]; 266 | $arenaPlayer->getInventory()->setItem(8, $block); 267 | } 268 | if ($moveLoc != null) { 269 | if (($moveLoc->getX() == $pLoc->getX()) && ($moveLoc->getY() == $pLoc->getY()) && ($moveLoc->getZ() == $pLoc->getZ())) 270 | { 271 | if ($block->getSize() > 1) 272 | { 273 | $block->setAmount($block->getSize() - 1); 274 | } 275 | else 276 | { 277 | $pBlock = $player->getLocation()->getBlock(); 278 | if (($pBlock->getType()->equals(Item::AIR)) || ($pBlock->getType()->equals(Item::WATER)) || ($pBlock->getType()->equals(Block::STILL_WATER))) 279 | { 280 | if (($pBlock->getType()->equals(Item::WATER)) || ($pBlock->getType()->equals(Item::STATIONARY_WATER))) { 281 | $this->plugin->storage->hiddenLocWater.put($player, true); 282 | } else { 283 | $this->plugin->storage->hiddenLocWater.put($player, false); 284 | } 285 | $arrayOfPlayer = array(); 286 | if (DisguiseAPI.isDisguised($player)) 287 | { 288 | DisguiseAPI.undisguiseToAll(player); 289 | 290 | $j = count($arrayOfPlayer = $this->plugin->getServer()->getgetOnlinePlayers()); 291 | for ($i = 0; $i < $j; $i++) 292 | { 293 | $pl = $arrayOfPlayer[$i]; 294 | if ($pl->getID() != $player->getID()) 295 | { 296 | $pl->hidePlayer($player); 297 | $pl->sendBlockChange($pBlock->getLocation(), $block->getType(), $block->getDurability()); 298 | } 299 | } 300 | //$block->addUnsafeEnchantment(Enchantment::DURABILITY, 10); 301 | //$player->playSound($pLoc, Sound.ORB_PICKUP, 1, 1); 302 | $this->plugin->storage->hiddenLoc[$player] = $moveLoc; 303 | MessageM.sendFMessage($player, $this->plugin->storage->message->get("normal")["ingameNowSolid"], $block->toString() ); 304 | } 305 | $j = count($arrayOfPlayer = $this->plugin->getServer()->getgetOnlinePlayers()); 306 | for ($i = 0; $i < $j; $i++) 307 | { 308 | $pl = $arrayOfPlayer[$i]; 309 | if ($pl->getID() != $player->getID()) 310 | { 311 | $pl->hidePlayer($player); 312 | $pl->sendBlockChange($pBlock->getLocation(), $block->getType(), $block->getDurability()); 313 | } 314 | } 315 | } 316 | else 317 | { 318 | MessageM.sendFMessage($player, ConfigC::warning_ingameNoSolidPlace, ""); 319 | } 320 | } 321 | } 322 | else 323 | { 324 | $block->setAmount(5); 325 | if (!DisguiseAPI::isDisguised($player)) { 326 | SolidBlockHandler::makePlayerUnsolid($player); 327 | } 328 | } 329 | } 330 | } 331 | } 332 | } 333 | foreach($arena->playersInArena as $arenaPlayer) 334 | { 335 | $arenaPlayer->setLevel($arena->timer); 336 | $arenaPlayer->setGameMode(0); 337 | } 338 | //ScoreboardHandler::updateScoreboard($arena); 339 | } 340 | $this->plugin->signsHandler->updateSigns(); 341 | } 342 | } 343 | } 344 | ?> --------------------------------------------------------------------------------