├── icon.png ├── resources ├── skyblock.json ├── config.yml └── messages.yml ├── .poggit.yml ├── src └── RedCraftPE │ └── RedSkyBlock │ ├── Tasks │ └── AutoSaveIslands.php │ ├── Commands │ ├── SubCommands │ │ ├── Reload.php │ │ ├── UpdateZone.php │ │ ├── OnIsland.php │ │ ├── Teleport.php │ │ ├── Name.php │ │ ├── Members.php │ │ ├── Banned.php │ │ ├── CreateWorld.php │ │ ├── Fly.php │ │ ├── Leave.php │ │ ├── AddPermission.php │ │ ├── RemovePermission.php │ │ ├── Reset.php │ │ ├── DecreaseSize.php │ │ ├── SetWorld.php │ │ ├── IncreaseSize.php │ │ ├── Value.php │ │ ├── Setting.php │ │ ├── Delete.php │ │ ├── Level.php │ │ ├── SetSize.php │ │ ├── ZoneTools.php │ │ ├── Remove.php │ │ ├── Rank.php │ │ ├── Accept.php │ │ ├── TopIslands.php │ │ ├── Demote.php │ │ ├── Promote.php │ │ ├── Lock.php │ │ ├── Unlock.php │ │ ├── Settings.php │ │ ├── Invite.php │ │ ├── Rename.php │ │ ├── SetSpawn.php │ │ ├── Unban.php │ │ ├── Help.php │ │ ├── Chat.php │ │ ├── Visit.php │ │ ├── Kick.php │ │ ├── Info.php │ │ ├── Ban.php │ │ └── Create.php │ ├── SBSubCommand.php │ └── SBCommand.php │ ├── Utils │ ├── ConfigManager.php │ ├── MessageConstructor.php │ ├── ZoneManager.php │ └── IslandManager.php │ ├── SkyBlock.php │ ├── Island.php │ └── SkyblockListener.php ├── plugin.yml └── README.md /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RedCraftGH/RedSkyBlock/HEAD/icon.png -------------------------------------------------------------------------------- /resources/skyblock.json: -------------------------------------------------------------------------------- 1 | { 2 | "Version": 1, 3 | "Master World": false, 4 | "Turns": 0, 5 | "Steps": -1, 6 | "Step Checker": 1, 7 | "Last X": 0, 8 | "Last Z": 0, 9 | "Zone Spawn": [], 10 | "CSpawnVals": [], 11 | "Zone World": false, 12 | "Zone Position": [], 13 | "Zone Size": [], 14 | "SkyBlock": [], 15 | "Zone": [] 16 | } 17 | -------------------------------------------------------------------------------- /.poggit.yml: -------------------------------------------------------------------------------- 1 | --- # Poggit-CI Manifest. Open the CI at https://poggit.pmmp.io/ci/RedCraftGH/RedSkyBlock 2 | branches: 3 | - master 4 | projects: 5 | RedSkyBlock: 6 | path: "" 7 | libs: 8 | - src: CortexPE/Commando/Commando 9 | version: ^3.0.0 10 | branch: PM4 11 | - src: Muqsit/SimplePacketHandler/SimplePacketHandler 12 | version: ^0.1.0 13 | - src: Muqsit/InvMenu/InvMenu 14 | version: ^4.4.0 15 | branch: "4.0" 16 | ... 17 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Tasks/AutoSaveIslands.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 16 | } 17 | 18 | public function onRun(): void { 19 | 20 | $this->plugin->islandManager->saveAllIslands(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Reload.php: -------------------------------------------------------------------------------- 1 | setPermission("redskyblock.admin;redskyblock.reload"); 15 | } 16 | 17 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 18 | 19 | $plugin = $this->plugin; 20 | $plugin->cfg->reload(); 21 | $plugin->skyblock->reload(); 22 | $plugin->messages->reload(); 23 | 24 | $message = $this->getMShop()->construct("RELOAD"); 25 | $sender->sendMessage($message); 26 | return; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/UpdateZone.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 18 | $this->setPermission("redskyblock.admin;redskyblock.zone"); 19 | } 20 | 21 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 22 | 23 | if ($this->checkZone()) { 24 | 25 | ZoneManager::updateZone(); 26 | 27 | $message = $this->getMShop()->construct("UPDATE_ZONE"); 28 | $sender->sendMessage($message); 29 | } else { 30 | 31 | $message = $this->getMShop()->construct("NO_ZONE"); 32 | $sender->sendMessage($message); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Utils/ConfigManager.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 14 | $this->verifyConfig(); 15 | } 16 | 17 | public function verifyConfig(): void { 18 | 19 | $real = yaml_parse(file_get_contents($this->plugin->getDataFolder() . "../RedSkyBlock/config.yml")); 20 | $realKeys = array_keys($real); 21 | 22 | $reference = yaml_parse(stream_get_contents($this->plugin->getResource("config.yml"))); 23 | $referenceKeys = array_keys($reference); 24 | 25 | $compare = array_diff($referenceKeys, $realKeys); 26 | 27 | if (count($compare) > 0) { 28 | 29 | foreach ($compare as $key) { 30 | 31 | $real[$key] = $reference[$key]; 32 | } 33 | $updated = yaml_emit($real); 34 | file_put_contents($this->plugin->getDataFolder() . "../RedSkyBlock/config.yml", $updated); 35 | $this->plugin->cfg->reload(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/OnIsland.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 17 | $this->setPermission("redskyblock.island"); 18 | } 19 | 20 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 21 | 22 | if ($this->checkIsland($sender)) { 23 | 24 | $island = $this->plugin->islandManager->getIsland($sender); 25 | $playersOnIsland = $this->plugin->islandManager->getPlayersAtIsland($island); 26 | $playersOnIsland = implode(", ", $playersOnIsland); 27 | 28 | $message = $this->getMShop()->construct("PLAYERS_ON_ISLAND"); 29 | $message = str_replace("{PLAYERS}", $playersOnIsland, $message); 30 | $sender->sendMessage($message); 31 | } else { 32 | 33 | $message = $this->getMShop()->construct("NO_ISLAND"); 34 | $sender->sendMessage($message); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Teleport.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 18 | $this->setPermission("redskyblock.island"); 19 | } 20 | 21 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 22 | 23 | if ($this->checkIsland($sender)) { 24 | 25 | $island = $this->plugin->islandManager->getIsland($sender); 26 | $spawnPoint = $island->getSpawnPoint(); 27 | $masterWorld = $this->plugin->islandManager->getMasterWorld(); 28 | if ($masterWorld === null) return; 29 | $sender->teleport(new Position($spawnPoint[0], $spawnPoint[1], $spawnPoint[2], $masterWorld)); 30 | 31 | $message = $this->getMShop()->construct("GO_HOME"); 32 | $sender->sendMessage($message); 33 | } else { 34 | 35 | $message = $this->getMShop()->construct("NO_ISLAND"); 36 | $sender->sendMessage($message); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /plugin.yml: -------------------------------------------------------------------------------- 1 | name: RedSkyBlock 2 | author: RedCraftPE 3 | version: 6.0.0-ALPHA 4 | api: 4.0.0 5 | main: RedCraftPE\RedSkyBlock\SkyBlock 6 | permissions: 7 | redskyblock.admin: 8 | default: op 9 | description: With this permission players will recieve access to all RedSkyBlock Admin commands. 10 | redskyblock.bypass: 11 | default: op 12 | description: With this permission players can bypass SkyBlock boundaries. 13 | redskyblock.createworld: 14 | default: false 15 | description: With this permission players can create a world ready for SkyBlock! 16 | redskyblock.setworld: 17 | default: false 18 | description: With this permission players can select the world used for SkyBlock. 19 | redskyblock.reload: 20 | default: false 21 | description: With this permission players can reload the SkyBlock files. 22 | redskyblock.zone: 23 | default: false 24 | description: With this permission players can manage the custom island zone. 25 | redskyblock.island: 26 | default: true 27 | description: With this permission players will have access to the basic SkyBlock commands. 28 | redskyblock.members: 29 | default: false 30 | description: With this permission players can have unlimited members on their SkyBlock island. 31 | redskyblock.fly: 32 | default: false 33 | description: With this permission players can fly in the SkyBlock world. 34 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Name.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 18 | $this->setPermission("redskyblock.island"); 19 | } 20 | 21 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 22 | 23 | $island = $this->plugin->islandManager->getIslandAtPlayer($sender); 24 | if ($island instanceof Island) { 25 | 26 | $islandName = $island->getName(); 27 | 28 | $message = $this->getMShop()->construct("ISLAND_NAME"); 29 | $message = str_replace("{ISLAND_NAME}", $islandName, $message); 30 | $sender->sendTip($message); 31 | } elseif ($this->checkIsland($sender)) { 32 | 33 | $island = $this->plugin->islandManager->getIsland($sender); 34 | $islandName = $island->getName(); 35 | 36 | $message = $this->getMShop()->construct("ISLAND_NAME"); 37 | $message = str_replace("{ISLAND_NAME}", $islandName, $message); 38 | $sender->sendTip($message); 39 | } else { 40 | 41 | $message = $this->getMShop()->construct("NO_ISLAND"); 42 | $sender->sendMessage($message); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Members.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 20 | $this->setPermission("redskyblock.island"); 21 | } 22 | 23 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 24 | 25 | if ($this->checkIsland($sender)) { 26 | 27 | $island = $this->plugin->islandManager->getIsland($sender); 28 | $members = $island->getMembers(); 29 | $menu = InvMenu::create(InvMenu::TYPE_DOUBLE_CHEST); 30 | $menu->setName(TextFormat::RED . TextFormat::BOLD . $island->getName() . TextFormat::RESET . " Members"); 31 | 32 | foreach($members as $member => $rank) { 33 | 34 | $item = VanillaItems::PLAYER_HEAD(); 35 | $item->setCustomName($member); 36 | $item->setLore([$rank]); 37 | $menu->getInventory()->addItem($item); 38 | } 39 | 40 | $menu->setListener(InvMenu::readonly()); 41 | $menu->send($sender); 42 | } else { 43 | 44 | $message = $this->getMShop()->construct("NO_ISLAND"); 45 | $sender->sendMessage($message); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Banned.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 20 | $this->setPermission("redskyblock.island"); 21 | } 22 | 23 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 24 | 25 | if ($this->checkIsland($sender)) { 26 | 27 | $island = $this->plugin->islandManager->getIsland($sender); 28 | $banned = $island->getBanned(); 29 | $menu = InvMenu::create(InvMenu::TYPE_DOUBLE_CHEST); 30 | $menu->setName(TextFormat::RED . TextFormat::BOLD . $island->getName() . TextFormat::RESET . " Banned Players"); 31 | 32 | foreach($banned as $player) { 33 | 34 | $item = VanillaItems::PLAYER_HEAD(); 35 | $item->setCustomName($player); 36 | $item->setLore(["Banned From " . $island->getName()]); 37 | $menu->getInventory()->addItem($item); 38 | } 39 | 40 | $menu->setListener(InvMenu::readonly()); 41 | $menu->send($sender); 42 | } else { 43 | 44 | $message = $this->getMShop()->construct("NO_ISLAND"); 45 | $sender->sendMessage($message); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SBSubCommand.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 22 | parent::__construct($name, $description, $aliases); 23 | } 24 | 25 | //include get SB functions here + any other useful functions to be used across multiple commands 26 | 27 | public function getMShop(): MessageConstructor { 28 | 29 | return MessageConstructor::getInstance(); 30 | } 31 | 32 | public function checkZone(): bool { 33 | 34 | if (ZoneManager::getZone() !== []) { 35 | 36 | return true; 37 | } else { 38 | 39 | return false; 40 | } 41 | } 42 | 43 | public function checkMasterWorld(): bool { 44 | 45 | if ($this->plugin->skyblock->get("Master World") !== false) { 46 | 47 | return true; 48 | } else { 49 | 50 | return false; 51 | } 52 | } 53 | 54 | public function checkIsland(Player $player): bool { 55 | 56 | $playerFiles = scandir($this->plugin->getDataFolder() . "../RedSkyBlock/Players"); 57 | $playerName = $player->getName(); 58 | 59 | if (in_array($playerName . ".json", $playerFiles)) { 60 | 61 | return true; 62 | } else { 63 | 64 | return false; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/CreateWorld.php: -------------------------------------------------------------------------------- 1 | setPermission("redskyblock.admin;redskyblock.createworld"); 19 | $this->registerArgument(0, new RawStringArgument("name", false)); 20 | } 21 | 22 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 23 | 24 | if (isset($args["name"])) { 25 | 26 | $name = $args["name"]; 27 | $plugin = $this->plugin; 28 | 29 | if (!$plugin->getServer()->getWorldManager()->loadWorld($name)) { 30 | 31 | $generator = GeneratorManager::getInstance()->getGenerator("flat")->getGeneratorClass(); 32 | $worldCreator = WorldCreationOptions::create()->setGeneratorOptions("3;minecraft:air"); 33 | $worldCreator->setGeneratorClass($generator); 34 | 35 | $plugin->getServer()->getWorldManager()->generateWorld($name, $worldCreator); 36 | 37 | $message = $this->getMShop()->construct("CW"); 38 | $message = str_replace("{WORLD}", $name, $message); 39 | $sender->sendMessage($message); 40 | 41 | } else { 42 | 43 | $message = $this->getMShop()->construct("CW_EXISTS"); 44 | $message = str_replace("{WORLD}", $name, $message); 45 | $sender->sendMessage($message); 46 | return; 47 | } 48 | } else { 49 | 50 | $this->sendUsage(); 51 | return; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Fly.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 18 | $this->setPermission("redskyblock.admin;redskyblock.fly"); 19 | } 20 | 21 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 22 | 23 | $island = $this->plugin->islandManager->getIslandAtPlayer($sender); 24 | if ($island instanceof Island) { 25 | 26 | if (array_key_exists(strtolower($sender->getName()), $island->getMembers()) || $sender->getName() === $island->getCreator()) { 27 | 28 | if ($sender->getAllowFlight()) { 29 | 30 | $sender->setAllowFlight(false); 31 | $sender->setFlying(false); 32 | 33 | $message = $this->getMShop()->construct("FLIGHT_DISABLED"); 34 | $sender->sendMessage($message); 35 | } else { 36 | 37 | $sender->setAllowFlight(true); 38 | $sender->setFlying(true); 39 | 40 | $message = $this->getMShop()->construct("FLIGHT_ENABLED"); 41 | $sender->sendMessage($message); 42 | } 43 | } else { 44 | 45 | $message = $this->getMShop()->construct("NOT_A_MEMBER_SELF"); 46 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 47 | $sender->sendMessage($message); 48 | } 49 | } else { 50 | 51 | $message = $this->getMShop()->construct("NOT_ON_ISLAND"); 52 | $sender->sendMessage($message); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Leave.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 19 | $this->setPermission("redskyblock.island"); 20 | $this->registerArgument(0, new TextArgument("island", false)); 21 | } 22 | 23 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 24 | 25 | if (isset($args["island"])) { 26 | 27 | $islandName = $args["island"]; 28 | $island = $this->plugin->islandManager->getIslandByName($islandName); 29 | if ($island instanceof Island) { 30 | 31 | if ($island->removeMember($sender->getName())) { 32 | 33 | $message = $this->getMShop()->construct("REMOVED_FROM_ISLAND"); 34 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 35 | $sender->sendMessage($message); 36 | } else { 37 | 38 | $message = $this->getMShop()->construct("NOT_A_MEMBER_SELF"); 39 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 40 | $sender->sendMessage($message); 41 | } 42 | } else { 43 | 44 | $message = $this->getMShop()->construct("COULD_NOT_FIND_ISLAND"); 45 | $message = str_replace("{ISLAND_NAME}", $islandName, $message); 46 | $sender->sendMessage($message); 47 | } 48 | } else { 49 | 50 | $this->sendUsage(); 51 | return; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/AddPermission.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 19 | $this->setPermission("redskyblock.island"); 20 | $this->registerArgument(0, new RawStringArgument("rank", false)); 21 | $this->registerArgument(1, new RawStringArgument("permission", false)); 22 | } 23 | 24 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 25 | 26 | $rank = strtolower($args["rank"]); 27 | $permission = strtolower($args["permission"]); 28 | 29 | if ($this->checkIsland($sender)) { 30 | 31 | $island = $this->plugin->islandManager->getIsland($sender); 32 | if ($island->addPermission($rank, $permission)) { 33 | 34 | $message = $this->getMShop()->construct("PERMISSION_ADDED"); 35 | $message = str_replace("{PERMISSION}", $permission, $message); 36 | $message = str_replace("{RANK}", ucfirst($rank), $message); 37 | $sender->sendMessage($message); 38 | } else { 39 | 40 | $message = $this->getMShop()->construct("PERMISSION_NOT_ADDED"); 41 | $message = str_replace("{PERMISSION}", $permission, $message); 42 | $message = str_replace("{RANK}", $rank, $message); 43 | $sender->sendMessage($message); 44 | } 45 | } else { 46 | 47 | $message = $this->getMShop()->construct("NO_ISLAND"); 48 | $sender->sendMessage($message); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/RemovePermission.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 19 | $this->setPermission("redskyblock.island"); 20 | $this->registerArgument(0, new RawStringArgument("rank", false)); 21 | $this->registerArgument(1, new RawStringArgument("permission", false)); 22 | } 23 | 24 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 25 | 26 | $rank = strtolower($args["rank"]); 27 | $permission = strtolower($args["permission"]); 28 | 29 | if ($this->checkIsland($sender)) { 30 | 31 | $island = $this->plugin->islandManager->getIsland($sender); 32 | if ($island->removePermission($rank, $permission)) { 33 | 34 | $message = $this->getMShop()->construct("PERMISSION_REMOVED"); 35 | $message = str_replace("{PERMISSION}", $permission, $message); 36 | $message = str_replace("{RANK}", ucfirst($rank), $message); 37 | $sender->sendMessage($message); 38 | } else { 39 | 40 | $message = $this->getMShop()->construct("PERMISSION_NOT_REMOVED"); 41 | $message = str_replace("{PERMISSION}", $permission, $message); 42 | $message = str_replace("{RANK}", $rank, $message); 43 | $sender->sendMessage($message); 44 | } 45 | } else { 46 | 47 | $message = $this->getMShop()->construct("NO_ISLAND"); 48 | $sender->sendMessage($message); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Reset.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 17 | $this->setPermission("redskyblock.island"); 18 | } 19 | 20 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 21 | 22 | if ($this->checkIsland($sender)) { 23 | 24 | $island = $this->plugin->islandManager->getIsland($sender); 25 | $resetCooldown = $island->getResetCooldown(); 26 | 27 | if (Time() >= $resetCooldown) { 28 | 29 | $playersOnIsland = $this->plugin->islandManager->getPlayersAtIsland($island); 30 | $this->plugin->islandManager->deleteIsland($island); 31 | Create::getInstance()->onRun($sender, "create", $args); 32 | 33 | foreach ($playersOnIsland as $playerName) { 34 | 35 | $player = $this->plugin->getServer()->getPlayerExact($playerName); 36 | $message = $this->getMShop()->construct("ISLAND_ON_DELETED"); 37 | $player->sendMessage($message); 38 | $spawn = $this->plugin->getServer()->getWorldManager()->getDefaultWorld()->getSafeSpawn(); 39 | $player->teleport($spawn); 40 | } 41 | } else { 42 | 43 | $timeLeft = gmdate("H:i:s", $resetCooldown - Time()); 44 | $message = $this->getMShop()->construct("CANT_RESET_YET"); 45 | $message = str_replace("{TIME}", $timeLeft, $message); 46 | $sender->sendMessage($message); 47 | } 48 | } else { 49 | 50 | $message = $this->getMShop()->construct("NO_ISLAND"); 51 | $sender->sendMessage($message); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/DecreaseSize.php: -------------------------------------------------------------------------------- 1 | setPermission("redskyblock.admin"); 20 | $this->registerArgument(0, new IntegerArgument("amount", false)); 21 | $this->registerArgument(1, new TextArgument("name", false)); 22 | } 23 | 24 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 25 | 26 | $playerName = $args["name"]; 27 | $subAmount = $args["amount"]; 28 | $island = $this->plugin->islandManager->getIslandByCreatorName($playerName); 29 | if ($island instanceof Island) { 30 | 31 | $newSize = $island->getSize() - $subAmount; 32 | if ($newSize < 0) $newSize = 0; 33 | 34 | $island->setSize($newSize); 35 | 36 | $message = $this->getMShop()->construct("PLAYER_ISLAND_SIZE_CHANGE"); 37 | $message = str_replace("{NAME}", $island->getCreator(), $message); 38 | $message = str_replace("{SIZE}", $newSize, $message); 39 | $sender->sendMessage($message); 40 | 41 | $player = $this->plugin->getServer()->getPlayerExact($playerName); 42 | if ($player instanceof Player) { 43 | 44 | $message = $this->getMShop()->construct("ISLAND_SIZE_CHANGED"); 45 | $message = str_replace("{SIZE}", $newSize, $message); 46 | $player->sendMessage($message); 47 | } 48 | } else { 49 | 50 | $message = $this->getMShop()->construct("PLAYER_HAS_NO_ISLAND"); 51 | $message = str_replace("{NAME}", $playerName, $message); 52 | $sender->sendMessage($message); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/SetWorld.php: -------------------------------------------------------------------------------- 1 | setPermission("redskyblock.admin;redskyblock.setworld"); 20 | $this->registerArgument(0, new RawStringArgument("name", false)); 21 | } 22 | 23 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 24 | 25 | if (isset($args["name"])) { 26 | 27 | $plugin = $this->plugin; 28 | $name = $args["name"]; 29 | 30 | if ($plugin->skyblock->get("Master World") !== $name) { 31 | 32 | if ($plugin->getServer()->getWorldManager()->loadWorld($name)) { 33 | 34 | $plugin->skyblock->set("Islands", 0); //reconfigure so if master world is changed back to previous skyblock world the amount of islands already created remains 35 | $plugin->skyblock->set("Master World", $name); 36 | $plugin->skyblock->save(); 37 | 38 | $message = $this->getMShop()->construct("WORLD_SET"); 39 | $message = str_replace("{WORLD}", $name, $message); 40 | $sender->sendMessage($message); 41 | return; 42 | } else { 43 | 44 | $message = $this->getMShop()->construct("NO_WORLD"); 45 | $message = str_replace("{WORLD}", $name, $message); 46 | $sender->sendMessage($message); 47 | return; 48 | } 49 | } else { 50 | 51 | $message = $this->getMShop()->construct("NO_CHANGE"); 52 | $message = str_replace("{WORLD}", $name, $message); 53 | $sender->sendMessage($message); 54 | return; 55 | } 56 | } else { 57 | 58 | $this->sendUsage(); 59 | return; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/IncreaseSize.php: -------------------------------------------------------------------------------- 1 | setPermission("redskyblock.admin"); 20 | $this->registerArgument(0, new IntegerArgument("amount", false)); 21 | $this->registerArgument(1, new TextArgument("name", false)); 22 | } 23 | 24 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 25 | 26 | $playerName = $args["name"]; 27 | $addAmount = $args["amount"]; 28 | $island = $this->plugin->islandManager->getIslandByCreatorName($playerName); 29 | if ($island instanceof Island) { 30 | 31 | $newSize = $island->getSize() + $addAmount; 32 | $maxSize = (int) $this->plugin->cfg->get("Island Max Size"); 33 | if ($newSize > $maxSize) $newSize = $maxSize; 34 | 35 | $island->setSize($newSize); 36 | 37 | $message = $this->getMShop()->construct("PLAYER_ISLAND_SIZE_CHANGE"); 38 | $message = str_replace("{NAME}", $island->getCreator(), $message); 39 | $message = str_replace("{SIZE}", $newSize, $message); 40 | $sender->sendMessage($message); 41 | 42 | $player = $this->plugin->getServer()->getPlayerExact($playerName); 43 | if ($player instanceof Player) { 44 | 45 | $message = $this->getMShop()->construct("ISLAND_SIZE_CHANGED"); 46 | $message = str_replace("{SIZE}", $newSize, $message); 47 | $player->sendMessage($message); 48 | } 49 | } else { 50 | 51 | $message = $this->getMShop()->construct("PLAYER_HAS_NO_ISLAND"); 52 | $message = str_replace("{NAME}", $playerName, $message); 53 | $sender->sendMessage($message); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Value.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 19 | $this->setPermission("redskyblock.island"); 20 | $this->registerArgument(0, new TextArgument("island", true)); 21 | } 22 | 23 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 24 | 25 | if (isset($args["island"])) { 26 | 27 | $islandName = $args["island"]; 28 | $island = $this->plugin->islandManager->getIslandByName($islandName); 29 | if ($island instanceof Island) { 30 | 31 | $value = $island->getValue(); 32 | 33 | $message = $this->getMShop()->construct("ISLAND_VALUE_OTHER"); 34 | $message = str_replace("{VALUE}", $value, $message); 35 | $message = str_replace("{NAME}", $islandName, $message); 36 | $sender->sendMessage($message); 37 | } else { 38 | 39 | $message = $this->getMShop()->construct("COULD_NOT_FIND_ISLAND"); 40 | $message = str_replace("{ISLAND_NAME}", $islandName, $message); 41 | $sender->sendMessage($message); 42 | } 43 | } else { 44 | 45 | if ($this->checkIsland($sender)) { 46 | 47 | $island = $this->plugin->islandManager->getIsland($sender); 48 | $value = $island->getValue(); 49 | 50 | $message = $this->getMShop()->construct("ISLAND_VALUE_SELF"); 51 | $message = str_replace("{VALUE}", $value, $message); 52 | $sender->sendMessage($message); 53 | } else { 54 | 55 | $message = $this->getMShop()->construct("NO_ISLAND"); 56 | $sender->sendMessage($message); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Setting.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 19 | $this->setPermission("redskyblock.island"); 20 | $this->registerArgument(0, new RawStringArgument("setting", false)); 21 | $this->registerArgument(1, new BooleanArgument("value", false)); 22 | } 23 | 24 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 25 | 26 | if ($this->checkIsland($sender)) { 27 | 28 | $island = $this->plugin->islandManager->getIsland($sender); 29 | $defaultSettings = $island->getDefaultSettings(); 30 | $setting = $args["setting"]; 31 | if (array_key_exists($setting, $defaultSettings)) { 32 | 33 | $bias = $args["value"]; 34 | $biasStringVal = "off"; 35 | 36 | if ($bias) { 37 | 38 | $biasStringVal = "on"; 39 | } else { 40 | 41 | $biasStringVal = "off"; 42 | } 43 | 44 | $island->changeSetting($setting, $bias); 45 | 46 | $message = $this->getMShop()->construct("SETTING_CHANGED"); 47 | $message = str_replace("{SETTING}", $setting, $message); 48 | $message = str_replace("{VALUE}", $biasStringVal, $message); 49 | $sender->sendMessage($message); 50 | } else { 51 | 52 | $message = $this->getMShop()->construct("SETTING_NOT_EXIST"); 53 | $message = str_replace("{SETTING}", $setting, $message); 54 | $sender->sendMessage($message); 55 | } 56 | } else { 57 | 58 | $message = $this->getMShop()->construct("NO_ISLAND"); 59 | $sender->sendMessage($sender); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Delete.php: -------------------------------------------------------------------------------- 1 | setPermission("redskyblock.admin"); 19 | $this->registerArgument(0, new TextArgument("island", false)); 20 | } 21 | 22 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 23 | 24 | $islandName = $args["island"]; 25 | $island = $this->plugin->islandManager->getIslandByName($islandName); 26 | if ($island instanceof Island) { 27 | 28 | $playersOnIsland = $this->plugin->islandManager->getPlayersAtIsland($island); 29 | $spawn = $this->plugin->getServer()->getWorldManager()->getDefaultWorld()->getSafeSpawn(); 30 | 31 | $islandCreator = $this->plugin->getServer()->getPlayerExact($island->getCreator()); 32 | if ($islandCreator instanceof Player) { 33 | 34 | $isOnIsland = $this->plugin->islandManager->isOnIsland($islandCreator, $island); 35 | if ($isOnIsland) $islandCreator->teleport($spawn); 36 | $message = $this->getMShop()->construct("ISLAND_DELETED"); 37 | $islandCreator->sendMessage($message); 38 | } 39 | $this->plugin->islandManager->deleteIsland($island); 40 | 41 | foreach ($playersOnIsland as $playerName) { 42 | 43 | $player = $this->plugin->getServer()->getPlayerExact($playerName); 44 | $message = $this->getMShop()->construct("ISLAND_ON_DELETED"); 45 | $player->sendMessage($message); 46 | $player->teleport($spawn); 47 | } 48 | } else { 49 | 50 | $message = $this->getMShop()->construct("COULD_NOT_FIND_ISLAND"); 51 | $message = str_replace("{ISLAND_NAME}", $islandName, $message); 52 | $sender->sendMessage($message); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Level.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 18 | $this->setPermission("redskyblock.island"); 19 | } 20 | 21 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 22 | 23 | $island = $this->plugin->islandManager->getIslandAtPlayer($sender); 24 | if ($island instanceof Island) { 25 | 26 | $islandLevel = $island->calculateLevel($island->getXP()); 27 | $xpNeeded = $island->getXPNeeded($island->getXP()) + $island->getXP(); 28 | 29 | $message = $this->getMShop()->construct("ISLAND_LEVEL_OTHER"); 30 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 31 | $message = str_replace("{LEVEL}", $islandLevel, $message); 32 | $message = str_replace("{XP}", $island->getXP(), $message); 33 | $message = str_replace("{XP_NEEDED}", $xpNeeded, $message); 34 | $sender->sendTip($message); 35 | } elseif ($this->checkIsland($sender)) { 36 | 37 | $island = $this->plugin->islandManager->getIsland($sender); 38 | $islandLevel = $island->calculateLevel($island->getXP()); 39 | $xpNeeded = $island->getXPNeeded($island->getXP()) + $island->getXP(); 40 | 41 | $message = $this->getMShop()->construct("ISLAND_LEVEL_SELF"); 42 | $message = str_replace("{LEVEL}", $islandLevel, $message); 43 | $message = str_replace("{XP}", $island->getXP(), $message); 44 | $message = str_replace("{XP_NEEDED}", $xpNeeded, $message); 45 | $sender->sendTip($message); 46 | } else { 47 | 48 | $message = $this->getMShop()->construct("NO_ISLAND"); 49 | $sender->sendMessage($message); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /resources/config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # IN ORDER FOR MANUAL CHANGES IN THIS FILE TO TAKE PLACE THE COMMAND /is reload MUST BE USED ON THE SERVER OR THE SERVER MUST BE RESTARTED 3 | 4 | # Format: "block_name: %chance" %chance MUST ADD UP TO 100 5 | Generator Ores: 6 | cobblestone: 60 7 | coal_ore: 8 8 | lapis_ore: 8 9 | redstone_ore: 8 10 | iron_ore: 7 11 | gold_ore: 4 12 | diamond_ore: 3 13 | emerald_ore: 2 14 | 15 | # Format: "item_name: count" 16 | Starting Items: 17 | ice: 2 18 | lava_bucket: 1 19 | string: 12 20 | bone_meal: 2 21 | sugar_cane: 1 22 | pumpkin_seeds: 1 23 | cactus: 1 24 | melon: 1 25 | dirt: 1 26 | red_mushroom: 1 27 | 28 | # Format: "block_name: value" 29 | Valuable Blocks: 30 | emerald_block: 15 31 | diamond_block: 10 32 | gold_block: 5 33 | iron_block: 5 34 | redstone_block: 3 35 | lapis_lazuli_block: 3 36 | coal_block: 1 37 | 38 | Island Interval: 600 39 | Island Size: 100 40 | Island Max Size: 300 41 | Island Spawn Y: 26 42 | 43 | Island Hunger: true #Turn off if you do not want players to lose hunger in the SkyBlock world. 44 | Fall Damage: true #Turn off if you do not want fall damage in the SkyBlock world. 45 | 46 | Keep Inventory: false #Turn on if you do not want players to lose their inventory upon death. 47 | 48 | Island Boundaries: false #Invisible barrier that forces players to stay within island boundaries -- stability untested : working on possible optimizations? 49 | 50 | Reset Cooldown: 86400 #The time in seconds a player must wait before being able to restart their SkyBlock island again. 86400 seconds is one day. 51 | 52 | Autosave Timer: 5 # Every x minutes all islands will autosave. Default: 5 minutes. Server restart required for changes to take effect. 53 | 54 | Member Limit: 3 # The maximum amount of members a player can have on their SkyBlock island without the redskyblock.members permission 55 | 56 | Create Teleport: true # If true players will teleport to their island as soon as it is created. 57 | 58 | XP Gap: 0.07 # How quickly the xp gap between levels increases. Lower values will increase the gap faster. CANNOT BE 0 59 | LevelUp Difficulty: 2 # How hard it is to levelup. Higher values will increase difficulty. CANNOT BE 0 60 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/SetSize.php: -------------------------------------------------------------------------------- 1 | setPermission("redskyblock.admin"); 20 | $this->registerArgument(0, new IntegerArgument("size", false)); 21 | $this->registerArgument(1, new TextArgument("name", false)); 22 | } 23 | 24 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 25 | 26 | $newSize = $args["size"]; 27 | $maxSize = (int) $this->plugin->cfg->get("Island Max Size"); 28 | if ($newSize > $maxSize) $newSize = $maxSize; 29 | if ($newSize >= 0) { 30 | 31 | $playerName = $args["name"]; 32 | $island = $this->plugin->islandManager->getIslandByCreatorName($playerName); 33 | if ($island instanceof Island) { 34 | 35 | $island->setSize($newSize); 36 | 37 | $message = $this->getMShop()->construct("PLAYER_ISLAND_SIZE_CHANGE"); 38 | $message = str_replace("{NAME}", $island->getCreator(), $message); 39 | $message = str_replace("{SIZE}", $newSize, $message); 40 | $sender->sendMessage($message); 41 | 42 | $player = $this->plugin->getServer()->getPlayerExact($playerName); 43 | if ($player instanceof Player) { 44 | 45 | $message = $this->getMShop()->construct("ISLAND_SIZE_CHANGED"); 46 | $message = str_replace("{SIZE}", $newSize, $message); 47 | $player->sendMessage($message); 48 | } 49 | } else { 50 | 51 | $message = $this->getMShop()->construct("PLAYER_HAS_NO_ISLAND"); 52 | $message = str_replace("{NAME}", $playerName, $message); 53 | $sender->sendMessage($message); 54 | } 55 | } else { 56 | 57 | $message = $this->getMShop()->construct("INT_LESS_THAN_ZERO"); 58 | $message = str_replace("{VALUE}", $newSize, $message); 59 | $sender->sendMessage($message); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/ZoneTools.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 22 | $this->setPermission("redskyblock.admin;redskyblock.zone"); 23 | $this->zoneShovel = ZoneManager::getZoneShovel(); 24 | $this->spawnFeather = ZoneManager::getSpawnFeather(); 25 | } 26 | 27 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 28 | 29 | $plugin = $this->plugin; 30 | $zoneKeeper = ZoneManager::getZoneKeeper(); 31 | $senderInv = $sender->getInventory(); 32 | $senderContents = $senderInv->getContents(); 33 | $zoneShovel = clone $this->zoneShovel; 34 | $spawnFeather = clone $this->spawnFeather; 35 | 36 | if ($zoneKeeper != $sender) { 37 | 38 | if ($zoneKeeper == null) { 39 | 40 | ZoneManager::clearZoneTools($sender); 41 | $senderInv->addItem($zoneShovel); 42 | $senderInv->addItem($spawnFeather); 43 | ZoneManager::setZoneKeeper($sender); 44 | ZoneManager::setSpawnPosition(); 45 | ZoneManager::setFirstPosition(); 46 | ZoneManager::setSecondPosition(); 47 | return; 48 | } else { 49 | 50 | ZoneManager::clearZoneTools($zoneKeeper); 51 | ZoneManager::setZoneKeeper($sender); 52 | ZoneManager::setSpawnPosition(); 53 | ZoneManager::setFirstPosition(); 54 | ZoneManager::setSecondPosition(); 55 | $senderInv->addItem($zoneShovel); 56 | $senderInv->addItem($spawnFeather); 57 | return; 58 | } 59 | } elseif (!$senderInv->contains($zoneShovel) || !$senderInv->contains($spawnFeather)) { 60 | 61 | ZoneManager::clearZoneTools($sender); 62 | $senderInv->addItem($zoneShovel); 63 | $senderInv->addItem($spawnFeather); 64 | return; 65 | } 66 | 67 | return; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Remove.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 19 | $this->setPermission("redskyblock.island"); 20 | $this->registerArgument(0, new TextArgument("name", false)); 21 | } 22 | 23 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 24 | 25 | if (isset($args["name"])) { 26 | 27 | if ($this->checkIsland($sender)) { 28 | 29 | $name = $args["name"]; 30 | $island = $this->plugin->islandManager->getIsland($sender); 31 | $creator = $island->getCreator(); 32 | 33 | if (strtolower($name) !== strtolower($creator)) { 34 | 35 | if ($island->removeMember($name)) { 36 | 37 | $message = $this->getMShop()->construct("MEMBER_REMOVED"); 38 | $message = str_replace("{NAME}", $name, $message); 39 | $sender->sendMessage($message); 40 | 41 | $player = $this->plugin->getServer()->getPlayerExact($name); 42 | if ($player instanceof Player) { 43 | 44 | $message = $this->getMShop()->construct("REMOVED_FROM_ISLAND"); 45 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 46 | $player->sendMessage($message); 47 | } 48 | } else { 49 | 50 | $message = $this->getMShop()->construct("NOT_A_MEMBER_OTHER"); 51 | $message = str_replace("{NAME}", $name, $message); 52 | $sender->sendMessage($message); 53 | } 54 | } else { 55 | 56 | $message = $this->getMShop()->construct("CANT_REMOVE_SELF"); 57 | $sender->sendMessage($message); 58 | } 59 | } else { 60 | 61 | $message = $this->getMShop()->construct("NO_ISLAND"); 62 | $sender->sendMessage($message); 63 | } 64 | } else { 65 | 66 | $this->sendUsage(); 67 | return; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Rank.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 19 | $this->setPermission("redskyblock.island"); 20 | $this->registerArgument(0, new TextArgument("island", true)); 21 | } 22 | 23 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 24 | 25 | $islandCount = count($this->plugin->islandManager->getIslands()); 26 | 27 | if (isset($args["island"])) { 28 | 29 | $islandName = $args["island"]; 30 | $island = $this->plugin->islandManager->getIslandByName($islandName); 31 | if ($island instanceof Island) { 32 | 33 | $rank = $this->plugin->islandManager->getIslandRank($island); 34 | 35 | $message = $this->getMShop()->construct("ISLAND_RANK_OTHER"); 36 | $message = str_replace("{NAME}", $islandName, $message); 37 | $message = str_replace("{RANK}", $rank, $message); 38 | $message = str_replace("{TOTAL_ISLANDS}", $islandCount, $message); 39 | $sender->sendMessage($message); 40 | } else { 41 | 42 | $message = $this->getMShop()->construct("COULD_NOT_FIND_ISLAND"); 43 | $message = str_replace("{ISLAND_NAME}", $islandName, $message); 44 | $sender->sendMessage($message); 45 | } 46 | } else { 47 | 48 | if ($this->checkIsland($sender)) { 49 | 50 | $island = $this->plugin->islandManager->getIsland($sender); 51 | $rank = $this->plugin->islandManager->getIslandrank($island); 52 | 53 | $message = $this->getMShop()->construct("ISLAND_RANK_SELF"); 54 | $message = str_replace("{RANK}", $rank, $message); 55 | $message = str_replace("{TOTAL_ISLANDS}", $islandCount, $message); 56 | $sender->sendMessage($message); 57 | } else { 58 | 59 | $message = $this->getMShop()->construct("NO_ISLAND"); 60 | $sender->sendMessage($message); 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Accept.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 20 | $this->setPermission("redskyblock.island"); 21 | $this->registerArgument(0, new TextArgument("island", false)); 22 | } 23 | 24 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 25 | 26 | $islandName = $args["island"]; 27 | $island = $this->plugin->islandManager->getIslandByName($islandName); 28 | if ($island instanceof Island) { 29 | 30 | $members = $island->getMembers(); 31 | $memberCount = count($members); 32 | $memberLimit = (int) $this->plugin->cfg->get("Member Limit"); 33 | if ($memberLimit > $memberCount) { 34 | 35 | if ($island->acceptInvite($sender)) { 36 | 37 | $message = $this->getMShop()->construct("ACCEPTED_INVITE"); 38 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 39 | $sender->sendMessage($message); 40 | 41 | $islandCreator = $this->plugin->getServer()->getPlayerExact($island->getCreator()); 42 | if ($islandCreator instanceof Player) { 43 | 44 | $message = $this->getMShop()->construct("JOINED_ISLAND"); 45 | $message = str_replace("{NAME}", $sender->getName(), $message); 46 | $islandCreator->sendMessage($message); 47 | } 48 | } else { 49 | 50 | $message = $this->getMShop()->construct("NOT_INVITED"); 51 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 52 | $sender->sendMessage($message); 53 | } 54 | } else { 55 | 56 | $message = $this->getMShop()->construct("MEMBER_LIMIT_REACHED"); 57 | $sender->sendMessage($message); 58 | } 59 | } else { 60 | 61 | $message = $this->getMShop()->construct("COULD_NOT_FIND_ISLAND"); 62 | $message = str_replace("{ISLAND_NAME}", $islandName, $message); 63 | $sender->sendMessage($message); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/TopIslands.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 18 | $this->setPermission("redskyblock.island"); 19 | $this->registerArgument(0, new IntegerArgument("page #", true)); 20 | } 21 | 22 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 23 | 24 | $topIslands = $this->plugin->islandManager->getTopIslands(); 25 | $islandNames = array_keys($topIslands); 26 | $pageCount = (int) ceil(count($topIslands) / 6); 27 | if ($pageCount === 0) $pageCount = 1; 28 | 29 | if (isset($args["page #"])) { 30 | 31 | $pageNumber = (int) $args["page #"]; 32 | if ($pageNumber <= 0) $pageNumber = 1; 33 | } else { 34 | 35 | $pageNumber = 1; 36 | } 37 | 38 | if ($pageNumber > $pageCount) $pageNumber = $pageCount; 39 | $pageNumber -= 1; 40 | $index = $pageNumber * 6; 41 | $islandsOnPage = array_slice($islandNames, $index, 6); 42 | 43 | $position1 = "#" . $index + 1 . "--N/A"; 44 | $position2 = "#" . $index + 2 . "--N/A"; 45 | $position3 = "#" . $index + 3 . "--N/A"; 46 | $position4 = "#" . $index + 4 . "--N/A"; 47 | $position5 = "#" . $index + 5 . "--N/A"; 48 | $position6 = "#" . $index + 6 . "--N/A"; 49 | 50 | for($x = 0; $x < count($islandsOnPage); $x++) { 51 | 52 | $rank = $index + ($x + 1); 53 | ${"position" . $x + 1} = "#{$rank}--" . $islandsOnPage[$x] . ": " . $topIslands[$islandsOnPage[$x]] . " value"; 54 | } 55 | 56 | $message = $this->getMShop()->construct("TOP_ISLANDS"); 57 | $message = str_replace("{PAGE_NUMBER}", $pageNumber + 1, $message); 58 | $message = str_replace("{TOTAL_PAGES}", $pageCount, $message); 59 | $message = str_replace("{POSITION_ONE}", $position1, $message); 60 | $message = str_replace("{POSITION_TWO}", $position2, $message); 61 | $message = str_replace("{POSITION_THREE}", $position3, $message); 62 | $message = str_replace("{POSITION_FOUR}", $position4, $message); 63 | $message = str_replace("{POSITION_FIVE}", $position5, $message); 64 | $message = str_replace("{POSITION_SIX}", $position6, $message); 65 | 66 | $sender->sendMessage($message); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Demote.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 20 | $this->setPermission("redskyblock.island"); 21 | $this->registerArgument(0, new TextArgument("player", false)); 22 | } 23 | 24 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 25 | 26 | if ($this->checkIsland($sender)) { 27 | 28 | $playerName = strtolower($args["player"]); 29 | $island = $this->plugin->islandManager->getIsland($sender); 30 | $members = $island->getMembers(); 31 | if (array_key_exists($playerName, $members)) { 32 | 33 | $currentRank = $members[$playerName]; 34 | $possibleRanks = Island::MEMBER_RANKS; 35 | $lowestRank = $possibleRanks[0]; 36 | if ($currentRank !== $lowestRank) { 37 | 38 | $index = array_search($currentRank, $possibleRanks); 39 | $newRank = $possibleRanks[$index - 1]; 40 | $island->setRank($playerName, $newRank); 41 | 42 | $message = $this->getMShop()->construct("DEMOTED_OTHER"); 43 | $message = str_replace("{RANK}", ucfirst($newRank), $message); 44 | $message = str_replace("{NAME}", $playerName, $message); 45 | $sender->sendMessage($message); 46 | 47 | $player = $this->plugin->getServer()->getPlayerExact($playerName); 48 | if ($player instanceof Player) { 49 | 50 | $message = $this->getMShop()->construct("DEMOTED_SELF"); 51 | $message = str_replace("{RANK}", ucfirst($newRank), $message); 52 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 53 | $player->sendMessage($message); 54 | } 55 | } else { 56 | 57 | $message = $this->getMShop()->construct("CANT_DEMOTE"); 58 | $message = str_replace("{NAME}", $args["player"], $message); 59 | $sender->sendMessage($message); 60 | } 61 | } else { 62 | 63 | $message = $this->getMShop()->construct("NOT_A_MEMBER_OTHER"); 64 | $message = str_replace("{NAME}", $args["player"], $message); 65 | $sender->sendMessage($message); 66 | } 67 | } else { 68 | 69 | $message = $this->getMShop()->construct("NO_ISLAND"); 70 | $sender->sendMessage($message); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Promote.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 20 | $this->setPermission("redskyblock.island"); 21 | $this->registerArgument(0, new TextArgument("player", false)); 22 | } 23 | 24 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 25 | 26 | if ($this->checkIsland($sender)) { 27 | 28 | $playerName = strtolower($args["player"]); 29 | $island = $this->plugin->islandManager->getIsland($sender); 30 | $members = $island->getMembers(); 31 | if (array_key_exists($playerName, $members)) { 32 | 33 | $currentRank = $members[$playerName]; 34 | $possibleRanks = Island::MEMBER_RANKS; 35 | $highestRank = end($possibleRanks); 36 | if ($currentRank !== $highestRank) { 37 | 38 | $index = array_search($currentRank, $possibleRanks); 39 | $newRank = $possibleRanks[$index + 1]; 40 | $island->setRank($playerName, $newRank); 41 | 42 | $message = $this->getMShop()->construct("PROMOTED_OTHER"); 43 | $message = str_replace("{RANK}", ucfirst($newRank), $message); 44 | $message = str_replace("{NAME}", $playerName, $message); 45 | $sender->sendMessage($message); 46 | 47 | $player = $this->plugin->getServer()->getPlayerExact($playerName); 48 | if ($player instanceof Player) { 49 | 50 | $message = $this->getMShop()->construct("PROMOTED_SELF"); 51 | $message = str_replace("{RANK}", ucfirst($newRank), $message); 52 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 53 | $player->sendMessage($message); 54 | } 55 | } else { 56 | 57 | $message = $this->getMShop()->construct("CANT_PROMOTE"); 58 | $message = str_replace("{NAME}", $args["player"], $message); 59 | $sender->sendMessage($message); 60 | } 61 | } else { 62 | 63 | $message = $this->getMShop()->construct("NOT_A_MEMBER_OTHER"); 64 | $message = str_replace("{NAME}", $args["player"], $message); 65 | $sender->sendMessage($message); 66 | } 67 | } else { 68 | 69 | $message = $this->getMShop()->construct("NO_ISLAND"); 70 | $sender->sendMessage($message); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Lock.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 18 | $this->setPermission("redskyblock.island"); 19 | } 20 | 21 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 22 | 23 | $island = $this->plugin->islandManager->getIslandAtPlayer($sender); 24 | if (!($island instanceof Island)) { 25 | 26 | if ($this->checkIsland($sender)) { 27 | 28 | $island = $this->plugin->islandManager->getIsland($sender); 29 | 30 | } else { 31 | 32 | $message = $this->getMShop()->construct("NO_ISLAND"); 33 | $sender->sendMessage($message); 34 | return; 35 | } 36 | } 37 | 38 | $members = $island->getMembers(); 39 | if (array_key_exists(strtolower($sender->getName()), $members) || $sender->getName() === $island->getCreator() || $sender->hasPermission("redskyblock.admin")) { 40 | 41 | if (array_key_exists(strtolower($sender->getName()), $members) && !$sender->hasPermission("redskyblock.admin")) { 42 | 43 | $islandPermissions = $island->getPermissions(); 44 | $senderRank = $members[strtolower($sender->getName())]; 45 | 46 | if (in_array("island.lock", $islandPermissions[$senderRank])) { 47 | 48 | if ($island->lock()) { 49 | 50 | $message = $this->getMShop()->construct("LOCKED"); 51 | $sender->sendMessage($message); 52 | } else { 53 | 54 | $message = $this->getMShop()->construct("ALREADY_LOCKED"); 55 | $sender->sendMessage($message); 56 | } 57 | } else { 58 | 59 | $message = $this->getMShop()->construct("RANK_TOO_LOW"); 60 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 61 | $sender->sendMessage($message); 62 | } 63 | } else { 64 | 65 | if ($island->lock()) { 66 | 67 | $message = $this->getMShop()->construct("LOCKED"); 68 | $sender->sendMessage($message); 69 | } else { 70 | 71 | $message = $this->getMShop()->construct("ALREADY_LOCKED"); 72 | $sender->sendMessage($message); 73 | } 74 | } 75 | } else { 76 | 77 | $message = $this->getMShop()->construct("NOT_A_MEMBER_SELF"); 78 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 79 | $sender->sendMessage($message); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Unlock.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 18 | $this->setPermission("redskyblock.island"); 19 | } 20 | 21 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 22 | 23 | $island = $this->plugin->islandManager->getIslandAtPlayer($sender); 24 | if (!($island instanceof Island)) { 25 | 26 | if ($this->checkIsland($sender)) { 27 | 28 | $island = $this->plugin->islandManager->getIsland($sender); 29 | 30 | } else { 31 | 32 | $message = $this->getMShop()->construct("NO_ISLAND"); 33 | $sender->sendMessage($message); 34 | return; 35 | } 36 | } 37 | 38 | $members = $island->getMembers(); 39 | if (array_key_exists(strtolower($sender->getName()), $members) || $sender->getName() === $island->getCreator() || $sender->hasPermission("redskyblock.admin")) { 40 | 41 | if (array_key_exists(strtolower($sender->getName()), $members) && !$sender->hasPermission("redskyblock.admin")) { 42 | 43 | $islandPermissions = $island->getPermissions(); 44 | $senderRank = $members[strtolower($sender->getName())]; 45 | 46 | if (in_array("island.lock", $islandPermissions[$senderRank])) { 47 | 48 | if ($island->unlock()) { 49 | 50 | $message = $this->getMShop()->construct("UNLOCKED"); 51 | $sender->sendMessage($message); 52 | } else { 53 | 54 | $message = $this->getMShop()->construct("ALREADY_UNLOCKED"); 55 | $sender->sendMessage($message); 56 | } 57 | } else { 58 | 59 | $message = $this->getMShop()->construct("RANK_TOO_LOW"); 60 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 61 | $sender->sendMessage($message); 62 | } 63 | } else { 64 | 65 | if ($island->unlock()) { 66 | 67 | $message = $this->getMShop()->construct("UNLOCKED"); 68 | $sender->sendMessage($message); 69 | } else { 70 | 71 | $message = $this->getMShop()->construct("ALREADY_UNLOCKED"); 72 | $sender->sendMessage($message); 73 | } 74 | } 75 | } else { 76 | 77 | $message = $this->getMShop()->construct("NOT_A_MEMBER_SELF"); 78 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 79 | $sender->sendMessage($message); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![](https://poggit.pmmp.io/shield.state/RedSkyBlock)](https://poggit.pmmp.io/p/RedSkyBlock) 2 | [![](https://poggit.pmmp.io/shield.api/RedSkyBlock)](https://poggit.pmmp.io/p/RedSkyBlock) 3 | [![](https://poggit.pmmp.io/shield.dl.total/RedSkyBlock)](https://poggit.pmmp.io/p/RedSkyBlock) 4 | 5 | > __*Quick Plugin Check:*__ Plugin Stability is untested. Use at your own risk. 6 | 7 | 8 | 9 | # RedSkyBlock 10 | RedSkyBlock aims to be a feature rich, user-friendly SkyBlock plugin. RedSkyBlock includes many useful, built-in features that can be edited in the config.yml and with the use of some commands in-game. 11 | 12 | # Discord 13 | Join the [Red Development](https://discord.gg/ZZrUBkD) Discord for support and more. 14 | 15 | # Donations 16 | Donations are, of course, very appreciated! If you like RedSkyBlock please consider [donating](https://www.paypal.me/acidraincr). 17 | 18 | # Installation and Support 19 | Installing this plugin on your server is super easy to do! Just download the RedSkyBlock.phar file from poggit and plop it into your server's plugins folder. Then adjust the settings in the config.yml to your liking and start the server. 20 | 21 | If you wish to request features, or notify me about an issue, please, make an issue. I will be sure to read it and reply quickly and appropriately. If you are reporting an issue with the plugin, be sure to include as many details as possible and steps to reproduce the issue. If you wish to suggest something for the plugin PLEASE be sure to include "suggestions" or "requests" in the title of the issue; make sure to be descriptive when asking for a feature, so I can be sure to know how to implement it, if I choose to do so. 22 | 23 | # Features (completed and coming soon) 24 | - Main Features 25 | - [x] SkyBlock World Creator and Island Generator 26 | - [x] Magic SkyBlock cobblestone generator 27 | - [x] Island teleportation 28 | - [x] Island locking/unlocking 29 | - [x] Island Area Protection. 30 | - [x] Customization in config.yml (More coming soon...) 31 | - [x] Island Members 32 | - [x] Island Kick/Ban 33 | - [x] Island Top 34 | - [x] Island Limits 35 | - [x] Island generation intervals (Customizable in the config.yml) 36 | - [x] Starting SkyBlock items (Customizable in the config.yml) 37 | - [x] Completely customizable island generation! You pick how you're islands look! (Updates coming later...) 38 | - [x] SkyBlock admin commands (More coming soon...) 39 | - [x] Admin bypass permissions 40 | - [x] Personalized Islands 41 | - Additional Features 42 | - [x] Island information and stats (More coming soon...) 43 | - [x] Nether islands (many nether updates coming soon...) 44 | - [ ] Lag fighter (Coming soon...) 45 | - [x] Safe Void in SkyBlock world (Customizable in the config.yml) 46 | - [x] Keep inventory (Customizable in the config.yml) 47 | - [ ] Much more coming soon... 48 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Settings.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 22 | $this->setPermission("redskyblock.island"); 23 | } 24 | 25 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 26 | 27 | if ($this->checkIsland($sender)) { 28 | 29 | $island = $this->plugin->islandManager->getIsland($sender); 30 | $islandSettings = $island->getSettings(); 31 | 32 | $menu = InvMenu::create(InvMenu::TYPE_CHEST); 33 | $menu->setName(TextFormat::RED . TextFormat::BOLD . $island->getName() . TextFormat::RESET . " Settings"); 34 | 35 | $slotTracker = 0; 36 | 37 | foreach($islandSettings as $setting => $bias) { 38 | 39 | $itemName = implode(" ", explode("_", $setting)); 40 | 41 | if ($bias) { 42 | 43 | $item = ItemFactory::getInstance()->get(StringToItemParser::getInstance()->parse("stained_glass_pane")->getId(), 5); 44 | $biasString = "Enabled"; 45 | } else { 46 | 47 | $item = ItemFactory::getInstance()->get(StringToItemParser::getInstance()->parse("stained_glass_pane")->getId(), 14); 48 | $biasString = "Disabled"; 49 | } 50 | $item->setCustomName($itemName); 51 | $item->setLore([$biasString]); 52 | $menuInventory = $menu->getInventory(); 53 | 54 | $slot = $slotTracker; 55 | if ($slot % 2 !== 0) { 56 | 57 | $slot += 1; 58 | } 59 | 60 | $menuInventory->setItem($slot, $item); 61 | $slotTracker = $slot + 1; 62 | } 63 | 64 | $menu->setListener(InvMenu::readonly(function(DeterministicInvMenuTransaction $transaction) use ($islandSettings, $island, $sender, $aliasUsed, $args) : void { 65 | 66 | $itemClicked = $transaction->getItemClicked(); 67 | $itemName = $itemClicked->getCustomName(); 68 | $settingName = implode("_", explode(" ", $itemName)); 69 | $settingBias = $islandSettings[$settingName]; 70 | if ($settingBias) { 71 | 72 | $settingBias = false; 73 | } else { 74 | 75 | $settingBias = true; 76 | } 77 | $island->changeSetting($settingName, $settingBias); 78 | $transaction->getPlayer()->removeCurrentWindow(); 79 | $this->onRun($sender, $aliasUsed, $args); 80 | })); 81 | $menu->send($sender); 82 | } else { 83 | 84 | $message = $this->getMShop()->construct("NO_ISLAND"); 85 | $sender->sendMessage($message); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Invite.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 19 | $this->setPermission("redskyblock.island"); 20 | $this->registerArgument(0, new TextArgument("name", false)); 21 | } 22 | 23 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 24 | 25 | if (isset($args["name"])) { 26 | 27 | $name = strtolower($args["name"]); 28 | if ($this->checkIsland($sender)) { 29 | 30 | $island = $this->plugin->islandManager->getIsland($sender); 31 | $members = $island->getMembers(); 32 | $banned = $island->getBanned(); 33 | $memberLimit = (int) $this->plugin->cfg->get("Member Limit"); 34 | 35 | if ($name !== strtolower($island->getCreator())) { 36 | 37 | if ($memberLimit > count($members) || $sender->hasPermission("redskyblock.members")) { 38 | 39 | if (!in_array($name, $banned)) { 40 | 41 | if ($island->invite($name)) { 42 | 43 | $message = $this->getMShop()->construct("INVITED_PLAYER"); 44 | $message = str_replace("{NAME}", $name, $message); 45 | $sender->sendMessage($message); 46 | 47 | $player = $this->plugin->getServer()->getPlayerExact($name); 48 | if ($player instanceof Player) { 49 | 50 | $message = $this->getMShop()->construct("INVITED_TO_ISLAND"); 51 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 52 | $player->sendMessage($message); 53 | } 54 | } else { 55 | 56 | $message = $this->getMShop()->construct("ALREADY_INVITED"); 57 | $message = str_replace("{NAME}", $name, $message); 58 | $sender->sendMessage($message); 59 | } 60 | } else { 61 | 62 | $message = $this->getMShop()->construct("CANT_INVITE_BANNED"); 63 | $message = str_replace("{NAME}", $name, $message); 64 | $sender->sendMessage($message); 65 | } 66 | } else { 67 | 68 | $message = $this->getMShop()->construct("MEMBER_LIMIT_REACHED"); 69 | $sender->sendMessage($message); 70 | } 71 | } else { 72 | 73 | $message = $this->getMShop()->construct("CANT_INVITE_SELF"); 74 | $sender->sendMessage($message); 75 | } 76 | } else { 77 | 78 | $message = $this->getMShop()->construct("NO_ISLAND"); 79 | $sender->sendMessage($message); 80 | } 81 | } else { 82 | 83 | $this->sendUsage(); 84 | return; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Rename.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 19 | $this->setPermission("redskyblock.island"); 20 | $this->registerArgument(0, new TextArgument("name", false)); 21 | } 22 | 23 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 24 | 25 | $name = $args["name"]; 26 | $island = $this->plugin->islandManager->getIslandAtPlayer($sender); 27 | if (!($island instanceof Island)) { 28 | 29 | if ($this->checkIsland($sender)) { 30 | 31 | $island = $this->plugin->islandManager->getIsland($sender); 32 | 33 | } else { 34 | 35 | $message = $this->getMShop()->construct("NO_ISLAND"); 36 | $sender->sendMessage($message); 37 | return; 38 | } 39 | } 40 | 41 | $members = $island->getMembers(); 42 | if (array_key_exists(strtolower($sender->getName()), $members) || $sender->getName() === $island->getCreator() || $sender->hasPermission("redskyblock.admin")) { 43 | 44 | if (array_key_exists(strtolower($sender->getName()), $members) && !$sender->hasPermission("redskyblock.admin")) { 45 | 46 | $islandPermissions = $island->getPermissions(); 47 | $senderRank = $members[strtolower($sender->getName())]; 48 | 49 | if (in_array("island.name", $islandPermissions[$senderRank])) { 50 | 51 | if (!$this->plugin->islandManager->checkRepeatIslandName($name)) { 52 | 53 | $island->setName($name); 54 | 55 | $message = $this->getMShop()->construct("NAME_CHANGE"); 56 | $message = str_replace("{NAME}", $name, $message); 57 | $sender->sendMessage($message); 58 | } else { 59 | 60 | $message = $this->getMShop()->construct("ISLAND_NAME_EXISTS"); 61 | $message = str_replace("{ISLAND_NAME}", $name, $message); 62 | $sender->sendMessage($message); 63 | } 64 | } else { 65 | 66 | $message = $this->getMShop()->construct("RANK_TOO_LOW"); 67 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 68 | $sender->sendMessage($message); 69 | } 70 | } else { 71 | 72 | if (!$this->plugin->islandManager->checkRepeatIslandName($name)) { 73 | 74 | $island->setName($name); 75 | 76 | $message = $this->getMShop()->construct("NAME_CHANGE"); 77 | $message = str_replace("{NAME}", $name, $message); 78 | $sender->sendMessage($message); 79 | } else { 80 | 81 | $message = $this->getMShop()->construct("ISLAND_NAME_EXISTS"); 82 | $message = str_replace("{ISLAND_NAME}", $name, $message); 83 | $sender->sendMessage($message); 84 | } 85 | } 86 | } else { 87 | 88 | $message = $this->getMShop()->construct("NOT_A_MEMBER_SELF"); 89 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 90 | $sender->sendMessage($message); 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Utils/MessageConstructor.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 18 | $this->messages = $plugin->messages; 19 | self::$instance = $this; 20 | $this->updateMessages(); 21 | } 22 | 23 | public static function getInstance(): MessageConstructor { 24 | 25 | return self::$instance; 26 | } 27 | 28 | public function construct(string $identifier): string { 29 | 30 | $plugin = $this->plugin; 31 | $message = $plugin->messages->get($identifier); 32 | if ($message == null) return "Message Not Set"; 33 | 34 | $message = str_replace("{NEW_LINE}", TextFormat::EOL, $message); 35 | $message = str_replace("{BLACK}", TextFormat::BLACK, $message); 36 | $message = str_replace("{DARK_BLUE}", TextFormat::DARK_BLUE, $message); 37 | $message = str_replace("{DARK_GREEN}", TextFormat::DARK_GREEN, $message); 38 | $message = str_replace("{DARK_AQUA}", TextFormat::DARK_AQUA, $message); 39 | $message = str_replace("{DARK_RED}", TextFormat::DARK_RED, $message); 40 | $message = str_replace("{DARK_PURPLE}", TextFormat::DARK_PURPLE, $message); 41 | $message = str_replace("{ORANGE}", TextFormat::GOLD, $message); 42 | $message = str_replace("{GRAY}", TextFormat::GRAY, $message); 43 | $message = str_replace("{DARK_GRAY}", TextFormat::DARK_GRAY, $message); 44 | $message = str_replace("{BLUE}", TextFormat::BLUE, $message); 45 | $message = str_replace("{GREEN}", TextFormat::GREEN, $message); 46 | $message = str_replace("{AQUA}", TextFormat::AQUA, $message); 47 | $message = str_replace("{RED}", TextFormat::RED, $message); 48 | $message = str_replace("{LIGHT_PURPLE}", TextFormat::LIGHT_PURPLE, $message); 49 | $message = str_replace("{YELLOW}", TextFormat::YELLOW, $message); 50 | $message = str_replace("{WHITE}", TextFormat::WHITE, $message); 51 | $message = str_replace("{OBFUSCATED}", TextFormat::OBFUSCATED, $message); 52 | $message = str_replace("{BOLD}", TextFormat::BOLD, $message); 53 | $message = str_replace("{STRIKETHROUGH}", TextFormat::STRIKETHROUGH, $message); 54 | $message = str_replace("{UNDERLINE}", TextFormat::UNDERLINE, $message); 55 | $message = str_replace("{ITALIC}", TextFormat::ITALIC, $message); 56 | $message = str_replace("{RESET}", TextFormat::RESET, $message); 57 | return $message; 58 | } 59 | 60 | public function updateMessages(): void { 61 | 62 | $realString = (string) file_get_contents($this->plugin->getDataFolder() . "../RedSkyBlock/messages.yml"); 63 | $realArray = yaml_parse($realString); 64 | $realKeys = array_keys($realArray); 65 | if (substr($realString, -1) === "." || substr($realString, -1) === "-") $realString = substr($realString, 0, -3); 66 | 67 | $reference = yaml_parse(stream_get_contents($this->plugin->getResource("messages.yml"))); 68 | $referenceKeys = array_keys($reference); 69 | 70 | $compare = array_diff($referenceKeys, $realKeys); 71 | 72 | if (count($compare) > 0) { 73 | 74 | foreach ($compare as $key) { 75 | 76 | $realString .= "\n" . $key . ": " . "\"" . $reference[$key] . "\""; 77 | } 78 | $realString .= "\n\n---"; 79 | 80 | file_put_contents($this->plugin->getDataFolder() . "../RedSkyBlock/messages.yml", $realString); 81 | $this->plugin->messages->reload(); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/SetSpawn.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 18 | $this->setPermission("redskyblock.island"); 19 | } 20 | 21 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 22 | 23 | $island = $this->plugin->islandManager->getIslandAtPlayer($sender); 24 | if (!($island instanceof Island)) { 25 | 26 | if ($this->checkIsland($sender)) { 27 | 28 | $island = $this->plugin->islandManager->getIsland($sender); 29 | 30 | } else { 31 | 32 | $message = $this->getMShop()->construct("NO_ISLAND"); 33 | $sender->sendMessage($message); 34 | return; 35 | } 36 | } 37 | 38 | $members = $island->getMembers(); 39 | if (array_key_exists(strtolower($sender->getName()), $members) || $sender->getName() === $island->getCreator() || $sender->hasPermission("redskyblock.admin")) { 40 | 41 | if (array_key_exists(strtolower($sender->getName()), $members) && !$sender->hasPermission("redskyblock.admin")) { 42 | 43 | $islandPermissions = $island->getPermissions(); 44 | $senderRank = $members[strtolower($sender->getName())]; 45 | 46 | if (in_array("island.spawn", $islandPermissions[$senderRank])) { 47 | 48 | if ($this->plugin->islandManager->isOnIsland($sender, $island)) { 49 | 50 | $senderPos = $sender->getPosition(); 51 | $spawnPoint = [round($senderPos->x), round($senderPos->y), round($senderPos->z)]; 52 | $island->setSpawnPoint($spawnPoint); 53 | 54 | $message = $this->getMShop()->construct("SPAWN_CHANGED"); 55 | $message = str_replace("{X}", round($senderPos->x), $message); 56 | $message = str_replace("{Y}", round($senderPos->y), $message); 57 | $message = str_replace("{Z}", round($senderPos->z), $message); 58 | $sender->sendMessage($message); 59 | } else { 60 | 61 | $message = $this->getMShop()->construct("NOT_ON_ISLAND"); 62 | $sender->sendMessage($message); 63 | } 64 | } else { 65 | 66 | $message = $this->getMShop()->construct("RANK_TOO_LOW"); 67 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 68 | $sender->sendMessage($message); 69 | } 70 | } else { 71 | 72 | if ($this->plugin->islandManager->isOnIsland($sender, $island)) { 73 | 74 | $senderPos = $sender->getPosition(); 75 | $spawnPoint = [round($senderPos->x), round($senderPos->y), round($senderPos->z)]; 76 | $island->setSpawnPoint($spawnPoint); 77 | 78 | $message = $this->getMShop()->construct("SPAWN_CHANGED"); 79 | $message = str_replace("{X}", round($senderPos->x), $message); 80 | $message = str_replace("{Y}", round($senderPos->y), $message); 81 | $message = str_replace("{Z}", round($senderPos->z), $message); 82 | $sender->sendMessage($message); 83 | } else { 84 | 85 | $message = $this->getMShop()->construct("NOT_ON_ISLAND"); 86 | $sender->sendMessage($message); 87 | } 88 | } 89 | } else { 90 | 91 | $message = $this->getMShop()->construct("NOT_A_MEMBER_SELF"); 92 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 93 | $sender->sendMessage($message); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Unban.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 20 | $this->setPermission("redskyblock.island"); 21 | $this->registerArgument(0, new TextArgument("name", false)); 22 | } 23 | 24 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 25 | 26 | $name = $args["name"]; 27 | $island = $this->plugin->islandManager->getIslandAtPlayer($sender); 28 | if (!($island instanceof Island)) { 29 | 30 | if ($this->checkIsland($sender)) { 31 | 32 | $island = $this->plugin->islandManager->getIsland($sender); 33 | 34 | } else { 35 | 36 | $message = $this->getMShop()->construct("NO_ISLAND"); 37 | $sender->sendMessage($message); 38 | return; 39 | } 40 | } 41 | 42 | $creator = $island->getCreator(); 43 | $members = $island->getMembers(); 44 | 45 | if (array_key_exists(strtolower($sender->getName()), $members) || $sender->getName() === $island->getCreator() || $sender->hasPermission("redskyblock.admin")) { 46 | 47 | if (array_key_exists(strtolower($sender->getName()), $members) && !$sender->hasPermission("redskyblock.admin")) { 48 | 49 | $islandPermissions = $island->getPermissions(); 50 | $senderRank = $members[strtolower($sender->getName())]; 51 | 52 | if (in_array("island.ban", $islandPermissions[$senderRank])) { 53 | 54 | if ($island->unban($name)) { 55 | 56 | $message = $this->getMShop()->construct("UNBANNED"); 57 | $message = str_replace("{NAME}", $name, $message); 58 | $sender->sendMessage($message); 59 | 60 | $player = $this->plugin->getServer()->getPlayerExact($name); 61 | if ($player instanceof Player) { 62 | 63 | $message = $this->getMShop()->construct("NO_LONGER_BANNED"); 64 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 65 | $player->sendMessage($message); 66 | } 67 | } else { 68 | 69 | $message = $this->getMShop()->construct("NOT_BANNED"); 70 | $message = str_replace("{NAME}", $name, $message); 71 | $sender->sendMessage($message); 72 | } 73 | } else { 74 | 75 | $message = $this->getMShop()->construct("RANK_TOO_LOW"); 76 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 77 | $sender->sendMessage($message); 78 | } 79 | } else { 80 | 81 | if ($island->unban($name)) { 82 | 83 | $message = $this->getMShop()->construct("UNBANNED"); 84 | $message = str_replace("{NAME}", $name, $message); 85 | $sender->sendMessage($message); 86 | 87 | $player = $this->plugin->getServer()->getPlayerExact($name); 88 | if ($player instanceof Player) { 89 | 90 | $message = $this->getMShop()->construct("NO_LONGER_BANNED"); 91 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 92 | $player->sendMessage($message); 93 | } 94 | } else { 95 | 96 | $message = $this->getMShop()->construct("NOT_BANNED"); 97 | $message = str_replace("{NAME}", $name, $message); 98 | $sender->sendMessage($message); 99 | } 100 | } 101 | } else { 102 | 103 | $message = $this->getMShop()->construct("NOT_A_MEMBER_SELF"); 104 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 105 | $sender->sendMessage($message); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Help.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 19 | $this->setPermission("redskyblock.island"); 20 | $this->registerArgument(0, new IntegerArgument("page#", true)); 21 | $this->registerArgument(0, new RawStringArgument("command", true)); 22 | } 23 | 24 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 25 | 26 | $islandCommand = $this->parent; 27 | $subCommands = $islandCommand->getSubCommands(); 28 | $subCommandNames = []; 29 | foreach ($subCommands as $command) { 30 | 31 | $subCommandNames[] = $command->getName(); 32 | } 33 | $subCommandNames = array_unique($subCommandNames); 34 | $pageCount = (int) ceil(count($subCommandNames) / 6); 35 | 36 | if (isset($args["command"])) { 37 | 38 | $commandName = strtolower($args["command"]); 39 | if (in_array($commandName, $subCommandNames)) { 40 | 41 | $command = $subCommands[$commandName]; 42 | $commandDescription = $command->getDescription(); 43 | $commandUsage = $command->getUsageMessage(); 44 | $commandPermissions = implode(" or ", explode(";", $command->getPermission())); 45 | $commandAliases = $command->getAliases(); 46 | if (count($commandAliases) !== 0) { 47 | 48 | $commandAliases = implode(", ", $commandAliases); 49 | } else { 50 | 51 | $commandAliases = "N/A"; 52 | } 53 | 54 | $message = $this->getMShop()->construct("HELP_MENU_SPECIFIC"); 55 | $message = str_replace("{COMMAND}", $commandName, $message); 56 | $message = str_replace("{DESCRIPTION}", $commandDescription, $message); 57 | $message = str_replace("{USAGE}", $commandUsage, $message); 58 | $message = str_replace("{PERMISSIONS}", $commandPermissions, $message); 59 | $message = str_replace("{ALIASES}", $commandAliases, $message); 60 | $sender->sendMessage($message); 61 | } else { 62 | 63 | $message = $this->getMShop()->construct("NO_SUCH_COMMAND"); 64 | $message = str_replace("{COMMAND}", $commandName, $message); 65 | $sender->sendMessage($message); 66 | } 67 | } else { 68 | 69 | if (isset($args["page#"])) { 70 | 71 | $pageNumber = $args["page#"]; 72 | if ($pageNumber > $pageCount) $pageNumber = $pageCount; 73 | if ($pageNumber <= 0) $pageNumber = 1; 74 | } else { 75 | 76 | $pageNumber = 1; 77 | } 78 | 79 | $pageNumber -= 1; 80 | $index = $pageNumber * 6; 81 | $commandsOnPage = array_slice($subCommandNames, $index, 6); 82 | $command1 = ""; 83 | $command2 = ""; 84 | $command3 = ""; 85 | $command4 = ""; 86 | $command5 = ""; 87 | $command6 = ""; 88 | 89 | for($x = 0; $x < count($commandsOnPage); $x++) { 90 | 91 | ${"command" . $x + 1} = "/is " . $commandsOnPage[$x]; 92 | } 93 | 94 | $message = $this->getMShop()->construct("HELP_MENU"); 95 | $message = str_replace("{PAGE_NUMBER}", $pageNumber + 1, $message); 96 | $message = str_replace("{TOTAL_PAGES}", $pageCount, $message); 97 | $message = str_replace("{COMMAND_ONE}", $command1, $message); 98 | $message = str_replace("{COMMAND_TWO}", $command2, $message); 99 | $message = str_replace("{COMMAND_THREE}", $command3, $message); 100 | $message = str_replace("{COMMAND_FOUR}", $command4, $message); 101 | $message = str_replace("{COMMAND_FIVE}", $command5, $message); 102 | $message = str_replace("{COMMAND_SIX}", $command6, $message); 103 | $sender->sendMessage($message); 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Chat.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 19 | $this->setPermission("redskyblock.island"); 20 | $this->registerArgument(0, new TextArgument("island", true)); 21 | } 22 | 23 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 24 | 25 | if (isset($args["island"])) { 26 | 27 | $islandName = $args["island"]; 28 | $island = $this->plugin->islandManager->getIslandByName($islandName); 29 | if ($island instanceof Island) { 30 | 31 | if (array_key_exists(strtolower($sender->getName()), $island->getMembers()) || $sender->getName() === $island->getCreator() || $sender->hasPermission("redskyblock.admin")) { 32 | 33 | $islandChatters = $island->getChatters(); 34 | if (in_array(strtolower($sender->getName()), $islandChatters)) { 35 | 36 | //if already in island chat be removed from it 37 | $island->removeChatter($sender->getName()); 38 | 39 | $message = $this->getMShop()->construct("LEAVE_ISLAND_CHAT"); 40 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 41 | $sender->sendMessage($message); 42 | 43 | } else { 44 | 45 | //if not already in chat then check if in any other island chats. if yes be removed from them. 46 | $currentChannel = $this->plugin->islandManager->searchIslandChannels($sender); 47 | if ($currentChannel instanceof Island) { 48 | 49 | $currentChannel->removeChatter($sender->getName()); 50 | 51 | $message = $this->getMShop()->construct("LEAVE_ISLAND_CHAT"); 52 | $message = str_replace("{ISLAND_NAME}", $currentChannel->getName(), $message); 53 | $sender->sendMessage($message); 54 | } 55 | 56 | $island->addChatter($sender->getName()); 57 | 58 | $message = $this->getMShop()->construct("JOIN_ISLAND_CHAT"); 59 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 60 | $sender->sendMessage($message); 61 | } 62 | } else { 63 | 64 | $message = $this->getMShop()->construct("NOT_A_MEMBER_SELF"); 65 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 66 | $sender->sendMessage($message); 67 | } 68 | } else { 69 | 70 | $message = $this->getMShop()->construct("COULD_NOT_FIND_ISLAND"); 71 | $message = str_replace("{ISLAND_NAME}", $islandName, $message); 72 | $sender->sendMessage($message); 73 | } 74 | } else { 75 | 76 | $currentChannel = $this->plugin->islandManager->searchIslandChannels($sender->getName()); 77 | 78 | if ($currentChannel instanceof Island) { 79 | 80 | $currentChannel->removeChatter($sender->getName()); 81 | 82 | $message = $this->getMShop()->construct("LEAVE_ISLAND_CHAT"); 83 | $message = str_replace("{ISLAND_NAME}", $currentChannel->getName(), $message); 84 | $sender->sendMessage($message); 85 | } else { 86 | 87 | if ($this->checkIsland($sender)) { 88 | 89 | $island = $this->plugin->islandManager->getIsland($sender); 90 | $island->addChatter($sender->getName()); 91 | 92 | $message = $this->getMShop()->construct("JOIN_ISLAND_CHAT"); 93 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 94 | $sender->sendMessage($message); 95 | } else { 96 | 97 | $message = $this->getMShop()->construct("NO_ISLAND"); 98 | $sender->sendMessage($message); 99 | } 100 | } 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Visit.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 21 | $this->setPermission("redskyblock.island"); 22 | $this->registerArgument(0, new TextArgument("target", false)); 23 | } 24 | 25 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 26 | 27 | if (isset($args["target"])) { 28 | 29 | $name = $args["target"]; 30 | $island = $this->plugin->islandManager->getIslandByName($name); 31 | $player = $this->plugin->getServer()->getPlayerByPrefix($name); 32 | if ($island instanceof Island) { 33 | 34 | $islandName = $island->getName(); 35 | $islandCreator = $island->getCreator(); 36 | $members = $island->getMembers(); 37 | $banned = $island->getBanned(); 38 | $lockStatus = $island->getLockStatus(); 39 | 40 | if (!in_array(strtolower($sender->getName()), $banned)) { 41 | 42 | if (!$lockStatus || in_array(strtolower($sender->getName()), $members) || $sender->hasPermission("redskyblock.bypass") || $islandCreator === $sender->getName()) { 43 | 44 | $masterWorld = $this->plugin->islandManager->getMasterWorld(); 45 | $islandSpawn = $island->getSpawnPoint(); 46 | $sender->teleport(new Position($islandSpawn[0], $islandSpawn[1], $islandSpawn[2], $masterWorld)); 47 | 48 | $message = $this->getMShop()->construct("WELCOME_TO_ISLAND"); 49 | $message = str_replace("{ISLAND_NAME}", $islandName, $message); 50 | $sender->sendMessage($message); 51 | } else { 52 | 53 | $message = $this->getMShop()->construct("ISLAND_LOCKED"); 54 | $message = str_replace("{ISLAND_NAME}", $islandName, $message); 55 | $sender->sendMessage($message); 56 | } 57 | } else { 58 | 59 | $message = $this->getMShop()->construct("BANNED"); 60 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 61 | $sender->sendMessage($message); 62 | } 63 | } elseif ($player instanceof Player) { 64 | 65 | if ($this->checkIsland($player)) { 66 | 67 | $island = $this->plugin->islandManager->getIsland($player); 68 | $islandCreator = $island->getCreator(); 69 | $islandName = $island->getName(); 70 | $members = $island->getMembers(); 71 | $banned = $island->getBanned(); 72 | $lockStatus = $island->getLockStatus(); 73 | 74 | if (!in_array(strtolower($sender->getName()), $banned)) { 75 | 76 | if (!$lockStatus || in_array(strtolower($sender->getName()), $members) || $sender->hasPermission("redskyblock.bypass") || $sender->getName() === $islandCreator) { 77 | 78 | $masterWorld = $this->plugin->islandManager->getMasterWorld(); 79 | $islandSpawn = $island->getSpawnPoint(); 80 | $sender->teleport(new Position($islandSpawn[0], $islandSpawn[1], $islandSpawn[2], $masterWorld)); 81 | 82 | $message = $this->getMShop()->construct("WELCOME_TO_ISLAND"); 83 | $message = str_replace("{ISLAND_NAME}", $islandName, $message); 84 | $sender->sendMessage($message); 85 | } else { 86 | 87 | $message = $this->getMShop()->construct("ISLAND_LOCKED"); 88 | $message = str_replace("{ISLAND_NAME}", $islandName, $message); 89 | $sender->sendMessage($message); 90 | } 91 | } else { 92 | 93 | $message = $this->getMShop()->construct("BANNED"); 94 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 95 | $sender->sendMessage($message); 96 | } 97 | } else { 98 | 99 | $message = $this->getMShop()->construct("PLAYER_HAS_NO_ISLAND"); 100 | $message = str_replace("{NAME}", $player->getName(), $message); 101 | $sender->sendMessage($message); 102 | } 103 | } else { 104 | 105 | $message = $this->getMShop()->construct("TARGET_NOT_FOUND"); 106 | $message = str_replace("{NAME}", $name, $message); 107 | $sender->sendMessage($message); 108 | } 109 | } else { 110 | 111 | $this->sendUsage(); 112 | return; 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Kick.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 20 | $this->setPermission("redskyblock.island"); 21 | $this->registerArgument(0, new TextArgument("name", false)); 22 | } 23 | 24 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 25 | 26 | $name = $args["name"]; 27 | $island = $this->plugin->islandManager->getIslandAtPlayer($sender); 28 | if (!($island instanceof Island)) { 29 | 30 | if ($this->checkIsland($sender)) { 31 | 32 | $island = $this->plugin->islandManager->getIsland($sender); 33 | 34 | } else { 35 | 36 | $message = $this->getMShop()->construct("NO_ISLAND"); 37 | $sender->sendMessage($message); 38 | return; 39 | } 40 | } 41 | 42 | $members = $island->getMembers(); 43 | if (array_key_exists(strtolower($sender->getName()), $members) || $sender->getName() === $island->getCreator() || $sender->hasPermission("redskyblock.admin")) { 44 | 45 | if (array_key_exists(strtolower($sender->getName()), $members) && !$sender->hasPermission("redskyblock.admin")) { 46 | 47 | $islandPermissions = $island->getPermissions(); 48 | $senderRank = $members[strtolower($sender->getName())]; 49 | if (in_array("island.kick", $islandPermissions[$senderRank])) { 50 | 51 | if (array_key_exists(strtolower($name), $members)) { 52 | 53 | $nameRank = $members[strtolower($name)]; 54 | $memberRanks = Island::MEMBER_RANKS; 55 | $namePos = array_search($nameRank, $memberRanks); 56 | $senderPos = array_search($senderRank, $memberRanks); 57 | if ($namePos >= $senderPos) { 58 | 59 | $message = $this->getMShop()->construct("CANT_KICK"); 60 | $sender->sendMessage($message); 61 | return; 62 | } 63 | } 64 | 65 | $player = $this->plugin->getServer()->getPlayerByPrefix($name); 66 | if ($player instanceof Player) { 67 | 68 | $this->kickPlayer($island, $player, $sender); 69 | } else { 70 | 71 | $message = $this->getMShop()->construct("TARGET_NOT_FOUND"); 72 | $message = str_replace("{NAME}", $name, $message); 73 | $sender->sendMessage($message); 74 | } 75 | } else { 76 | 77 | $message = $this->getMShop()->construct("RANK_TOO_LOW"); 78 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 79 | $sender->sendMessage($message); 80 | } 81 | } else { 82 | 83 | $player = $this->plugin->getServer()->getPlayerByPrefix($name); 84 | if ($player instanceof Player) { 85 | 86 | $this->kickPlayer($island, $player, $sender); 87 | } else { 88 | 89 | $message = $this->getMShop()->construct("TARGET_NOT_FOUND"); 90 | $message = str_replace("{NAME}", $name, $message); 91 | $sender->sendMessage($message); 92 | } 93 | } 94 | } else { 95 | 96 | $message = $this->getMShop()->construct("NOT_A_MEMBER_SELF"); 97 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 98 | $sender->sendMessage($message); 99 | } 100 | } 101 | 102 | public function kickPlayer(Island $island, Player $player, CommandSender $sender): void { 103 | 104 | if ($this->plugin->islandManager->isOnIsland($player, $island)) { 105 | 106 | if ($island->getCreator() !== $player->getName()) { 107 | 108 | $message = $this->getMShop()->construct("KICKED_PLAYER"); 109 | $message = str_replace("{NAME}", $player->getName(), $message); 110 | $sender->sendMessage($message); 111 | 112 | $message = $this->getMShop()->construct("KICKED_FROM_ISLAND"); 113 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 114 | $player->sendMessage($message); 115 | 116 | $spawn = $this->plugin->getServer()->getWorldManager()->getDefaultWorld()->getSafeSpawn(); 117 | $player->teleport($spawn); 118 | } else { 119 | 120 | $message = $this->getMShop()->construct("CANT_KICK"); 121 | $sender->sendMessage($message); 122 | } 123 | } else { 124 | 125 | $message = $this->getMShop()->construct("TARGET_NOT_FOUND"); 126 | $message = str_replace("{NAME}", $player->getName(), $message); 127 | $sender->sendMessage($message); 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/SkyBlock.php: -------------------------------------------------------------------------------- 1 | getDataFolder() . "../RedSkyBlock")) { 38 | 39 | mkdir($this->getDataFolder() . "../RedSkyBlock"); 40 | } 41 | if (!file_exists($this->getDataFolder() . "../RedSkyBlock/skyblock.json")) { 42 | 43 | $this->saveResource("skyblock.json"); 44 | } 45 | if (!file_exists($this->getDataFolder() . "../RedSkyBlock/config.yml")) { 46 | 47 | $this->saveResource("config.yml"); 48 | } 49 | if (!file_exists($this->getDataFolder() . "../RedSkyBlock/messages.yml")) { 50 | 51 | $this->saveResource("messages.yml"); 52 | } 53 | if (!file_exists($this->getDataFolder() . "../RedSkyBlock/Players")) { 54 | 55 | mkdir($this->getDataFolder() . "../RedSkyBlock/Players"); 56 | } 57 | 58 | $this->skyblock = new Config($this->getDataFolder() . "../RedSkyBlock/skyblock.json", Config::JSON); 59 | $this->cfg = new Config($this->getDataFolder() . "../RedSkyBlock/config.yml", Config::YAML); 60 | $this->messages = new Config($this->getDataFolder() . "../RedSkyBlock/messages.yml", Config::YAML); 61 | $this->skyblock->reload(); 62 | $this->cfg->reload(); 63 | $this->messages->reload(); 64 | 65 | //register config manager: 66 | $this->configManager = new ConfigManager($this); 67 | //register zone manager: 68 | $this->zoneManager = new ZoneManager($this); 69 | //register island manager: 70 | $this->islandManager = new IslandManager($this); 71 | $this->islandManager->constructAllIslands(); 72 | //register message constructor: 73 | $this->mShop = new MessageConstructor($this); 74 | //register listener for RedSkyBlock: 75 | $this->listener = new SkyblockListener($this); 76 | 77 | //begin autosave 78 | $autosaveTimer = $this->cfg->get("Autosave Timer"); 79 | $ticks = round($autosaveTimer * 1200); //converts minutes to ticks 80 | $this->getScheduler()->scheduleRepeatingTask(new AutoSaveIslands($this), $ticks); 81 | 82 | //register PacketHooker: 83 | if (!PacketHooker::isRegistered()) { 84 | 85 | PacketHooker::register($this); 86 | } 87 | if(!InvMenuHandler::isRegistered()){ 88 | 89 | InvMenuHandler::register($this); 90 | } 91 | 92 | //register SB Base command: 93 | $this->getServer()->getCommandMap()->register(strtolower($this->getName()), new SBCommand( 94 | $this, 95 | "skyblock", 96 | "The base command for RedSkyBlock.", 97 | ["is", "sb", "island", "isle"] 98 | )); 99 | 100 | self::$instance = $this; 101 | 102 | //Determine if a skyblock world is being used: -- from older RedSkyBlock will probably be udpated 103 | 104 | if ($this->skyblock->get("Master World") === false) { 105 | 106 | $message = $this->mShop->construct("NO_MASTER"); 107 | $this->getLogger()->info($message); 108 | $masterWorld = false; 109 | } else { 110 | 111 | if ($this->getServer()->getWorldManager()->loadWorld($this->skyblock->get("Master World"))) { 112 | 113 | $this->getServer()->getWorldManager()->loadWorld($this->skyblock->get("Master World")); 114 | if ($this->cfg->get("Nether Islands")) { 115 | 116 | $this->getServer()->getWorldManager()->loadWorld($this->skyblock->get("Master World") . "-Nether"); 117 | } 118 | } else { 119 | 120 | $message = $this->mShop->construct("LOAD_ERROR"); 121 | $this->getLogger()->info($message); 122 | } 123 | 124 | $masterWorld = $this->getServer()->getWorldManager()->getWorldByName($this->skyblock->get("Master World")); 125 | if (!$masterWorld instanceof World) { 126 | 127 | $message = $this->mShop->construct("MASTER_FAILED"); 128 | $message = str_replace("{MWORLD}", $this->skyblock->get("Master World"), $message); 129 | $this->getLogger()->info($message); 130 | $masterWorld = null; 131 | } else { 132 | 133 | $message = $this->mShop->construct("MASTER_SUCCESS"); 134 | $message = str_replace("{MWORLD}", $masterWorld->getFolderName(), $message); 135 | $this->getLogger()->info($message); 136 | } 137 | } 138 | } 139 | 140 | public static function getInstance() { 141 | 142 | return self::$instance; 143 | } 144 | 145 | public function onDisable(): void { 146 | 147 | IslandManager::getInstance()->saveAllIslands(); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Info.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 18 | $this->setPermission("redskyblock.island"); 19 | } 20 | 21 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 22 | 23 | $island = $this->plugin->islandManager->getIslandAtPlayer($sender); 24 | if ($island instanceof Island) { 25 | 26 | if ($island->getCreator() === $sender->getName() || in_array(strtolower($sender->getName()), $island->getMembers()) || $sender->hasPermission("redskyblock.admin")) { 27 | 28 | $sender->sendMessage($this->getIslandInfoFull($island)); 29 | } else { 30 | 31 | $islandName = $island->getName(); 32 | $islandCreator = $island->getCreator(); 33 | $islandValue = $island->getValue(); 34 | $islandSpawnPoint = implode(", ", $island->getSpawnPoint()); 35 | $islandStats = $island->getStats(); 36 | $islandStatsString = ""; 37 | foreach($islandStats as $stat => $value) { 38 | 39 | $statName = str_replace("_", " ", $stat); 40 | $islandStatsString .= $statName . ": " . $value . " | "; 41 | } 42 | if ($island->getLockStatus()) { 43 | 44 | $islandLockStatus = "Locked"; 45 | } else { 46 | 47 | $islandLockStatus = "Unlocked"; 48 | } 49 | 50 | $message = $this->getMShop()->construct("ISLAND_INFO_LIMITED"); 51 | $message = str_replace("{ISLAND_NAME}", $islandName, $message); 52 | $message = str_replace("{ISLAND_CREATOR}", $islandCreator, $message); 53 | $message = str_replace("{ISLAND_VALUE}", $islandValue, $message); 54 | $message = str_replace("{LOCK_STATUS}", $islandLockStatus, $message); 55 | $message = str_replace("{SPAWN_POINT}", $islandSpawnPoint, $message); 56 | $message = str_replace("{ISLAND_STATS}", $islandStatsString, $message); 57 | $sender->sendMessage($message); 58 | } 59 | } else { 60 | 61 | if ($this->checkIsland($sender)) { 62 | 63 | $island = $this->plugin->islandManager->getIsland($sender); 64 | $sender->sendMessage($this->getIslandInfoFull($island)); 65 | } else { 66 | 67 | $message = $this->getMShop()->construct("NO_ISLAND"); 68 | $sender->sendMessage($message); 69 | } 70 | } 71 | } 72 | 73 | public function getIslandInfoFUll(Island $island): string { 74 | 75 | $islandName = $island->getName(); 76 | $islandMembers = implode(", ", array_keys($island->getMembers())); 77 | if ($islandMembers === "") $islandMembers = "N/A"; 78 | $islandBanned = implode(", ", $island->getBanned()); 79 | if ($islandBanned === "") $islandBanned = "N/A"; 80 | $islandSpawnPoint = implode(", ", $island->getSpawnPoint()); 81 | $islandSettings = $island->getSettings(); 82 | $islandSettingsString = ""; 83 | foreach($islandSettings as $setting => $status) { 84 | 85 | if ($status) { 86 | 87 | $isSettingActive = "on"; 88 | } else { 89 | 90 | $isSettingActive = "off"; 91 | } 92 | $settingName = str_replace("_", " ", $setting); 93 | $islandSettingsString .= $settingName . ": " . $isSettingActive . " | "; 94 | } 95 | $islandStats = $island->getStats(); 96 | $islandStatsString = ""; 97 | foreach($islandStats as $stat => $value) { 98 | 99 | $statName = str_replace("_", " ", $stat); 100 | $islandStatsString .= $statName . ": " . $value . " | "; 101 | } 102 | if ($island->getLockStatus()) { 103 | 104 | $islandLockStatus = "Locked"; 105 | } else { 106 | 107 | $islandLockStatus = "Unlocked"; 108 | } 109 | if (Time() >= $island->getResetCooldown()) { 110 | 111 | $islandTimeToReset = gmdate("H:i:s", Time() + 86400); 112 | } else { 113 | 114 | $islandTimeToReset = gmdate("H:i:s", $island->getResetCooldown() - Time()); 115 | } 116 | $islandSize = $island->getSize(); 117 | $islandValue = $island->getValue(); 118 | $islandCreator = $island->getCreator(); 119 | 120 | $message = $this->getMShop()->construct("ISLAND_INFO_FULL"); 121 | $message = str_replace("{ISLAND_NAME}", $islandName, $message); 122 | $message = str_replace("{ISLAND_CREATOR}", $islandCreator, $message); 123 | $message = str_replace("{ISLAND_SIZE}", $islandSize, $message); 124 | $message = str_replace("{ISLAND_VALUE}", $islandValue, $message); 125 | $message = str_replace("{RESET_COOLDOWN}", $islandTimeToReset, $message); 126 | $message = str_replace("{LOCK_STATUS}", $islandLockStatus, $message); 127 | $message = str_replace("{MEMBERS}", $islandMembers, $message); 128 | $message = str_replace("{BANNED}", $islandBanned, $message); 129 | $message = str_replace("{SPAWN_POINT}", $islandSpawnPoint, $message); 130 | $message = str_replace("{ISLAND_SETTINGS}", $islandSettingsString, $message); 131 | $message = str_replace("{ISLAND_STATS}", $islandStatsString, $message); 132 | return $message; 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Ban.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 20 | $this->setPermission("redskyblock.island"); 21 | $this->registerArgument(0, new TextArgument("name", false)); 22 | } 23 | 24 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 25 | 26 | $island = $this->plugin->islandManager->getIslandAtPlayer($sender); 27 | $name = $args["name"]; 28 | 29 | if ($island instanceof Island) { 30 | 31 | $creator = $island->getCreator(); 32 | $members = $island->getMembers(); 33 | 34 | if (array_key_exists(strtolower($sender->getName()), $members) || $sender->getName() === $island->getCreator() || $sender->hasPermission("redskyblock.admin")) { 35 | 36 | if (array_key_exists(strtolower($sender->getName()), $members) && !$sender->hasPermission("redskyblock.admin")) { 37 | 38 | $islandPermissions = $island->getPermissions(); 39 | $senderRank = $members[strtolower($sender->getName())]; 40 | 41 | if (in_array("island.ban", $islandPermissions[$senderRank])) { 42 | 43 | if (array_key_exists(strtolower($name), $members)) { 44 | 45 | $nameRank = $members[strtolower($name)]; 46 | $memberRanks = Island::MEMBER_RANKS; 47 | $namePos = array_search($nameRank, $memberRanks); 48 | $senderPos = array_search($senderRank, $memberRanks); 49 | if ($namePos >= $senderPos) { 50 | 51 | $message = $this->getMShop()->construct("CANT_BAN"); 52 | $sender->sendMessage($message); 53 | return; 54 | } 55 | } 56 | 57 | $island->removeMember($name); 58 | 59 | if (!(strtolower($name) === strtolower($creator) || strtolower($name) === strtolower($sender->getName()))) { 60 | 61 | if ($island->ban($name)) { 62 | 63 | $message = $this->getMShop()->construct("BANNED_PLAYER"); 64 | $message = str_replace("{NAME}", $name, $message); 65 | $sender->sendMessage($message); 66 | 67 | $player = $this->plugin->getServer()->getPlayerExact($name); 68 | if ($player instanceof Player && !$player->hasPermission("redskyblock.admin")) { 69 | 70 | if ($this->plugin->islandManager->isOnIsland($player, $island)) { 71 | 72 | $spawn = $this->plugin->getServer()->getWorldManager()->getDefaultWorld()->getSafeSpawn(); 73 | $player->teleport($spawn); 74 | } 75 | $message = $this->getMShop()->construct("BANNED"); 76 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 77 | $player->sendMessage($message); 78 | } 79 | } else { 80 | 81 | $message = $this->getMShop()->construct("ALREADY_BANNED"); 82 | $message = str_replace("{NAME}", $name, $message); 83 | $sender->sendMessage($message); 84 | } 85 | } else { 86 | 87 | $message = $this->getMShop()->construct("CANT_BAN"); 88 | $sender->sendMessage($message); 89 | } 90 | } else { 91 | 92 | $message = $this->getMShop()->construct("RANK_TOO_LOW"); 93 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 94 | $sender->sendMessage($message); 95 | } 96 | } else { 97 | 98 | $island->removeMember($name); 99 | 100 | if (!(strtolower($name) === strtolower($creator) || strtolower($name) === strtolower($sender->getName()))) { 101 | 102 | if ($island->ban($name)) { 103 | 104 | $message = $this->getMShop()->construct("BANNED_PLAYER"); 105 | $message = str_replace("{NAME}", $name, $message); 106 | $sender->sendMessage($message); 107 | 108 | $player = $this->plugin->getServer()->getPlayerExact($name); 109 | if ($player instanceof Player && !$player->hasPermission("redskyblock.admin")) { 110 | 111 | if ($this->plugin->islandManager->isOnIsland($player, $island)) { 112 | 113 | $spawn = $this->plugin->getServer()->getWorldManager()->getDefaultWorld()->getSafeSpawn(); 114 | $player->teleport($spawn); 115 | } 116 | $message = $this->getMShop()->construct("BANNED"); 117 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 118 | $player->sendMessage($message); 119 | } 120 | } else { 121 | 122 | $message = $this->getMShop()->construct("ALREADY_BANNED"); 123 | $message = str_replace("{NAME}", $name, $message); 124 | $sender->sendMessage($message); 125 | } 126 | } else { 127 | 128 | $message = $this->getMShop()->construct("CANT_BAN"); 129 | $sender->sendMessage($message); 130 | } 131 | } 132 | } else { 133 | 134 | $message = $this->getMShop()->construct("NOT_A_MEMBER_SELF"); 135 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 136 | $sender->sendMessage($message); 137 | } 138 | } elseif ($this->checkIsland($sender)) { 139 | 140 | $island = $this->plugin->islandManager->getIsland($sender); 141 | $creator = $island->getCreator(); 142 | $island->removeMember($name); 143 | 144 | if (strtolower($name) !== strtolower($creator)) { 145 | 146 | if ($island->ban($name)) { 147 | 148 | $message = $this->getMShop()->construct("BANNED_PLAYER"); 149 | $message = str_replace("{NAME}", $name, $message); 150 | $sender->sendMessage($message); 151 | 152 | $player = $this->plugin->getServer()->getPlayerExact($name); 153 | if ($player instanceof Player && !$player->hasPermission("redskyblock.admin")) { 154 | 155 | if ($this->plugin->islandManager->isOnIsland($player, $island)) { 156 | 157 | $spawn = $this->plugin->getServer()->getWorldManager()->getDefaultWorld()->getSafeSpawn(); 158 | $player->teleport($spawn); 159 | } 160 | $message = $this->getMShop()->construct("BANNED"); 161 | $message = str_replace("{ISLAND_NAME}", $island->getName(), $message); 162 | $player->sendMessage($message); 163 | } 164 | } else { 165 | 166 | $message = $this->getMShop()->construct("ALREADY_BANNED"); 167 | $message = str_replace("{NAME}", $name, $message); 168 | $sender->sendMessage($message); 169 | } 170 | } else { 171 | 172 | $message = $this->getMShop()->construct("CANT_BAN"); 173 | $sender->sendMessage($message); 174 | } 175 | } else { 176 | 177 | $message = $this->getMShop()->construct("NO_ISLAND"); 178 | $sender->sendMessage($message); 179 | } 180 | } 181 | } 182 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Utils/ZoneManager.php: -------------------------------------------------------------------------------- 1 | skyblock->get("Zone", []); 39 | 40 | self::$zoneStartPosition = $plugin->skyblock->get("Zone Position", []); 41 | self::$zoneSize = $plugin->skyblock->get("Zone Size", []); 42 | self::$zoneSpawn = $plugin->skyblock->get("Zone Spawn", []); 43 | 44 | $zoneWorld = $plugin->skyblock->get("Zone World"); 45 | if ($zoneWorld === false) { 46 | 47 | self::$zoneWorld = null; 48 | } else { 49 | 50 | if ($plugin->getServer()->getWorldManager()->loadWorld($zoneWorld)) { 51 | 52 | self::$zoneWorld = $plugin->getServer()->getWorldManager()->getWorldByName($zoneWorld); 53 | } else { 54 | 55 | self::$zoneWorld = false; 56 | $plugin->skyblock->set("Zone World", self::$zoneWorld); 57 | } 58 | } 59 | 60 | self::$zoneShovel = VanillaItems::WOODEN_SHOVEL(); 61 | self::$zoneShovel->getNamedTag()->setByte("redskyblock", 1); 62 | self::$zoneShovel->setCustomName(TextFormat::OBFUSCATED . "s" . TextFormat::RESET . TextFormat::RED . " Zone Shovel " . TextFormat::RESET . TextFormat::OBFUSCATED . TextFormat::WHITE . "s"); 63 | 64 | self::$spawnFeather = VanillaItems::FEATHER(); 65 | self::$spawnFeather->getNamedTag()->setByte("redskyblock", 1); 66 | self::$spawnFeather->setCustomName(TextFormat::OBFUSCATED . "s" . TextFormat::RESET . TextFormat::WHITE . " Spawn Feather " . TextFormat::RESET . TextFormat::OBFUSCATED . TextFormat::WHITE . "s"); 67 | } 68 | 69 | public static function createZone(): void { 70 | 71 | $zone = self::$zone; 72 | 73 | $pos1 = self::$pos1; 74 | $pos2 = self::$pos2; 75 | $zoneWorld = self::$zoneWorld; 76 | $spawnPosition = self::$spawnPosition; 77 | $plugin = self::$plugin; 78 | $cSpawnVals = $plugin->skyblock->get("CSpawnVals", []); 79 | 80 | $zoneX = [$pos1->x, $pos2->x]; 81 | $zoneY = [$pos1->y, $pos2->y]; 82 | $zoneZ = [$pos1->z, $pos2->z]; 83 | 84 | self::$zoneStartPosition = [min($zoneX), min($zoneY), min($zoneZ)]; 85 | self::$zoneSize = [max($zoneX) - min($zoneX), max($zoneY) - min($zoneY), max($zoneZ) - min($zoneZ)]; 86 | 87 | //calculate spawn finding values relative to the position of the selected spawn within the island zone 88 | $islandHeight = self::$zoneSize[1]; 89 | 90 | $cSpawnVals[0] = $spawnPosition->x - self::$zoneStartPosition[0]; 91 | $cSpawnVals[1] = $spawnPosition->y - self::$zoneStartPosition[1] + 2; // + 2 to account for player height 92 | $cSpawnVals[2] = $spawnPosition->z - self::$zoneStartPosition[2]; 93 | $plugin->skyblock->set("CSpawnVals", $cSpawnVals); 94 | 95 | self::updateZone(); 96 | } 97 | 98 | public static function updateZone(): void { 99 | 100 | self::clearZone(); 101 | $zone = self::$zone; 102 | $zoneWorld = self::$zoneWorld; 103 | $zoneStartPosition = self::$zoneStartPosition; 104 | $zoneSize = self::$zoneSize; 105 | 106 | for ($x = $zoneStartPosition[0]; $x <= $zoneStartPosition[0] + $zoneSize[0]; $x++) { 107 | 108 | for ($y = $zoneStartPosition[1]; $y <= $zoneStartPosition[1] + $zoneSize[1]; $y++) { 109 | 110 | for ($z = $zoneStartPosition[2]; $z <= $zoneStartPosition[2] + $zoneSize[2]; $z++) { 111 | 112 | $block = $zoneWorld->getBlockAt((int) $x, (int) $y, (int) $z, true, false); 113 | $blockName = str_replace(" ", "_", strtolower($block->getName())); 114 | $blockMeta = $block->getMeta(); 115 | $blockData = "{$blockName}:{$blockMeta}"; 116 | array_push($zone, $blockData); 117 | } 118 | } 119 | } 120 | self::$zone = $zone; 121 | self::saveZone(); 122 | } 123 | 124 | public static function getZone(): array { 125 | 126 | return self::$zone; 127 | } 128 | 129 | public static function saveZone(): void { 130 | 131 | $plugin = self::$plugin; 132 | $zone = self::$zone; 133 | if (self::$zoneSpawn === []) { 134 | 135 | $spawnPosition = self::$spawnPosition; 136 | self::$zoneSpawn = [round($spawnPosition->x), round($spawnPosition->y), round($spawnPosition->z)]; 137 | } 138 | $zoneWorld = self::$zoneWorld; 139 | $zoneStartPosition = self::$zoneStartPosition; 140 | $zoneSize = self::$zoneSize; 141 | $plugin->skyblock->set("Zone", $zone); 142 | $plugin->skyblock->set("Zone Spawn", self::$zoneSpawn); 143 | $plugin->skyblock->set("Zone World", $zoneWorld->getFolderName()); 144 | $plugin->skyblock->set("Zone Size", $zoneSize); 145 | $plugin->skyblock->set("Zone Position", $zoneStartPosition); 146 | $plugin->skyblock->save(); 147 | } 148 | 149 | public static function clearZone(): void { 150 | 151 | self::$zone = []; 152 | } 153 | 154 | public static function clearZoneTools(Player $player): void { 155 | 156 | $playerInv = $player->getInventory(); 157 | $invContents = $playerInv->getContents(); 158 | 159 | if ($playerInv->contains(self::$zoneShovel)) { 160 | 161 | $index = array_search(self::$zoneShovel, $invContents); 162 | $playerInv->setItem($index, VanillaItems::AIR()); 163 | } 164 | if ($playerInv->contains(self::$spawnFeather)) { 165 | 166 | $index = array_search(self::$spawnFeather, $invContents); 167 | $playerInv->setItem($index, VanillaItems::AIR()); 168 | } 169 | if ($playerInv->getItemInHand()->equals(self::$zoneShovel) || $playerInv->getItemInHand()->equals(self::$spawnFeather)) { 170 | 171 | $playerInv->setItemInHand(VanillaItems::AIR()); 172 | } 173 | return; 174 | } 175 | 176 | public static function getZoneKeeper(): ?Player { 177 | 178 | return self::$zoneKeeper; 179 | } 180 | 181 | public static function setZoneKeeper($zoneKeeper = null): void { 182 | 183 | self::$zoneKeeper = $zoneKeeper; 184 | } 185 | 186 | public static function getZoneWorld(): ?World { 187 | 188 | return self::$zoneWorld; 189 | } 190 | 191 | public static function setZoneWorld($world = null): void { 192 | 193 | self::$zoneWorld = $world; 194 | } 195 | 196 | public static function getFirstPosition(): ?Position { 197 | 198 | return self::$pos1; 199 | } 200 | 201 | public static function getSecondPosition(): ?Position { 202 | 203 | return self::$pos2; 204 | } 205 | 206 | public static function setFirstPosition($position = null): void { 207 | 208 | self::$pos1 = $position; 209 | } 210 | 211 | public static function setSecondPosition($position = null): void { 212 | 213 | self::$pos2 = $position; 214 | } 215 | 216 | public static function getZoneShovel(): Item { 217 | 218 | return self::$zoneShovel; 219 | } 220 | 221 | public static function getSpawnFeather(): Item { 222 | 223 | return self::$spawnFeather; 224 | } 225 | 226 | public static function getSpawnPosition(): ?Position { 227 | 228 | return self::$spawnPosition; 229 | } 230 | 231 | public static function setSpawnPosition($position = null): void { 232 | 233 | self::$spawnPosition = $position; 234 | } 235 | 236 | public static function getZoneStartPosition(): array { 237 | 238 | return self::$zoneStartPosition; 239 | } 240 | 241 | public static function getZoneSize(): array { 242 | 243 | return self::$zoneSize; 244 | } 245 | } 246 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SubCommands/Create.php: -------------------------------------------------------------------------------- 1 | addConstraint(new InGameRequiredConstraint($this)); 27 | $this->setPermission("redskyblock.island"); 28 | self::$instance = $this; 29 | } 30 | 31 | public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { 32 | 33 | if ($this->checkMasterWorld()) { 34 | 35 | if ($this->checkZone()) { 36 | 37 | $plugin = $this->plugin; 38 | $masterWorldName = $plugin->skyblock->get("Master World"); 39 | 40 | if (!$plugin->getServer()->getWorldManager()->isWorldLoaded($masterWorldName)) { 41 | 42 | if (!$plugin->getServer()->getWorldManager()->loadWorld($masterWorldName)) { 43 | 44 | $message = $this->getMShop()->construct("LOAD_ERROR"); 45 | $sender->sendMessage($message); 46 | } 47 | } else { 48 | 49 | if (!$this->checkIsland($sender)) { 50 | 51 | $interval = $plugin->cfg->get("Island Interval"); 52 | $initialSize = $plugin->cfg->get("Island Size"); 53 | $islandSpawnY = $plugin->cfg->get("Island Spawn Y"); 54 | $resetCooldown = $plugin->cfg->get("Reset Cooldown"); 55 | $startingItems = $plugin->cfg->get("Starting Items", []); 56 | $senderName = $sender->getName(); 57 | $masterWorld = $plugin->getServer()->getWorldManager()->getWorldByName($masterWorldName); 58 | 59 | $turns = $plugin->skyblock->get("Turns"); 60 | $steps = $plugin->skyblock->get("Steps"); 61 | $stepChecker = $plugin->skyblock->get("Step Checker"); 62 | $lastX = $plugin->skyblock->get("Last X"); 63 | $lastZ = $plugin->skyblock->get("Last Z"); 64 | $dir = 0; 65 | 66 | if ($steps === -1) { 67 | 68 | $lastX += $interval; 69 | $steps = 1; 70 | } else { 71 | 72 | if ($steps === $stepChecker) { 73 | 74 | $turns++; 75 | $steps = 0; 76 | if ($turns % 2 === 0) { 77 | 78 | $stepChecker++; 79 | } 80 | 81 | $dir = intval($turns - ((floor($turns/4)) * 4)); 82 | } else { 83 | 84 | $dir = intval($turns - ((floor($turns/4)) * 4)); 85 | } 86 | if ($dir === 0) { 87 | 88 | $lastX += $interval; 89 | $steps++; 90 | } elseif ($dir === 1) { 91 | 92 | $lastZ += $interval; 93 | $steps++; 94 | } elseif ($dir === 2) { 95 | 96 | $lastX -= $interval; 97 | $steps++; 98 | } elseif ($dir === 3) { 99 | 100 | $lastZ -= $interval; 101 | $steps++; 102 | } 103 | } 104 | 105 | $cSpawnVals = $plugin->skyblock->get("CSpawnVals", []); 106 | $initialSpawnPoint = [$lastX + $cSpawnVals[0], $islandSpawnY + $cSpawnVals[1], $lastZ + $cSpawnVals[2]]; 107 | 108 | $islandData = [ 109 | "creator" => $senderName, 110 | "name" => $senderName . "'s island", 111 | "size" => $initialSize, 112 | "initialspawnpoint" => $initialSpawnPoint, 113 | "spawnpoint" => $initialSpawnPoint, 114 | "resetcooldown" => Time() + $resetCooldown 115 | ]; 116 | 117 | $zone = ZoneManager::getZone(); 118 | $zoneStartPosition = ZoneManager::getZoneStartPosition(); 119 | $zoneSize = ZoneManager::getZoneSize(); 120 | 121 | $chunkX = $lastX >> Chunk::COORD_BIT_SIZE; 122 | $chunkZ = $lastZ >> Chunk::COORD_BIT_SIZE; 123 | 124 | $adjacentChunks = [[$chunkX, $chunkZ], [$chunkX + 1, $chunkZ + 1], [$chunkX, $chunkZ + 1], [$chunkX - 1, $chunkZ + 1], [$chunkX - 1, $chunkZ], [$chunkX - 1, $chunkZ - 1], [$chunkX, $chunkZ - 1], [$chunkX + 1, $chunkZ - 1], [$chunkX + 1, $chunkZ]]; 125 | 126 | foreach($adjacentChunks as $chunk) { 127 | 128 | if ($chunk === end($adjacentChunks)) { 129 | 130 | $masterWorld->orderChunkPopulation($chunk[0], $chunk[1], null)->onCompletion(function(Chunk $chunk) use ($lastX, $lastZ, $islandSpawnY, $masterWorld, $plugin, $sender, $islandData, $zone, $zoneSize, $initialSpawnPoint, $startingItems): void { 131 | 132 | $counter = 0; 133 | 134 | for ($x = $lastX; $x <= $lastX + $zoneSize[0]; $x++) { 135 | 136 | for ($y = $islandSpawnY; $y <= $islandSpawnY + $zoneSize[1]; $y++) { 137 | 138 | for ($z = $lastZ; $z <= $lastZ + $zoneSize[2]; $z++) { 139 | 140 | $blockData = explode(":", $zone[$counter]); 141 | $blockName = $blockData[0]; 142 | $blockMeta = $blockData[1]; 143 | $block = StringToItemParser::getInstance()->parse($blockName)->getBlock(); 144 | $masterWorld->setBlock(new Vector3($x, $y, $z), BlockFactory::getInstance()->get($block->getID(), $blockMeta), false); 145 | $counter++; 146 | } 147 | } 148 | } 149 | 150 | $plugin->islandManager->constructIsland($islandData, $sender->getName()); 151 | 152 | $masterWorld->setBlock(new Vector3($initialSpawnPoint[0], $initialSpawnPoint[1] - 1, $initialSpawnPoint[2] + 1), VanillaBlocks::CHEST()); 153 | $startingChest = $masterWorld->getTileAt($initialSpawnPoint[0], $initialSpawnPoint[1] - 1, $initialSpawnPoint[2] + 1); 154 | if (count($startingItems) !== 0) { 155 | 156 | foreach ($startingItems as $itemName => $count) { 157 | 158 | $item = StringToItemParser::getInstance()->parse($itemName); 159 | $item->setCount(intval($count)); 160 | $startingChest->getInventory()->addItem($item); 161 | } 162 | } 163 | 164 | $senderName = $sender->getName(); 165 | $doCreateTeleport = $plugin->cfg->get("Create Teleport"); 166 | if ($doCreateTeleport) $sender->teleport(new Position($initialSpawnPoint[0], $initialSpawnPoint[1], $initialSpawnPoint[2], $masterWorld)); 167 | 168 | if (file_put_contents($plugin->getDataFolder() . "../RedSkyBlock/Players/" . $senderName . ".json", json_encode($islandData)) !== false) { 169 | 170 | $message = $this->getMShop()->construct("ISLAND_CREATED"); 171 | $sender->sendMessage($message); 172 | } else { 173 | 174 | $message = $this->getMShop()->construct("FILE_CREATION_ERROR"); 175 | $sender->sendMessage($message); 176 | } 177 | }, static fn() => null); 178 | } else { 179 | 180 | $masterWorld->orderChunkPopulation($chunk[0], $chunk[1], null); 181 | } 182 | } 183 | 184 | $plugin->skyblock->set("Steps", $steps); 185 | $plugin->skyblock->set("Turns", $turns); 186 | $plugin->skyblock->set("Step Checker", $stepChecker); 187 | $plugin->skyblock->set("Last X", $lastX); 188 | $plugin->skyblock->set("Last Z", $lastZ); 189 | $plugin->skyblock->save(); 190 | 191 | } else { 192 | 193 | $message = $this->getMShop()->construct("ALREADY_CREATED_ISLAND"); 194 | $sender->sendMessage($message); 195 | } 196 | } 197 | } else { 198 | 199 | $message = $this->getMShop()->construct("NO_ZONE"); 200 | $sender->sendMessage($message); 201 | } 202 | } else { 203 | 204 | $message = $this->getMShop()->construct("NO_MASTER_WORLD"); 205 | $sender->sendMessage($message); 206 | } 207 | } 208 | 209 | public static function getInstance(): self { 210 | 211 | return self::$instance; 212 | } 213 | } 214 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Commands/SBCommand.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 67 | parent::__construct($plugin, $name, $description, $aliases); 68 | } 69 | 70 | protected function prepare(): void { 71 | 72 | $this->registerArgument(0, new RawStringArgument("help", true)); 73 | 74 | $this->registerSubCommand(new Accept( 75 | $this->plugin, 76 | "accept", 77 | "Accept an invite to another SkyBlock Island." 78 | )); 79 | 80 | $this->registerSubCommand(new AddPermission( 81 | $this->plugin, 82 | "addpermission", 83 | "Add a permission to an island rank on your SkyBlock Island.", 84 | ["addperm", "setpermission", "setperm"] 85 | )); 86 | 87 | $this->registerSubCommand(new Ban( 88 | $this->plugin, 89 | "ban", 90 | "Ban a player from your SkyBlock Island.", 91 | ["banish"] 92 | )); 93 | 94 | $this->registerSubCommand(new Banned( 95 | $this->plugin, 96 | "banned", 97 | "View the players banned from your SkyBlock island", 98 | ["banished"] 99 | )); 100 | 101 | $this->registerSubCommand(new Chat( 102 | $this->plugin, 103 | "chat", 104 | "Chat with the members of a SkyBlock island." 105 | )); 106 | 107 | $this->registerSubCommand(new Create( 108 | $this->plugin, 109 | "create", 110 | "Create your SkyBlock island!" 111 | )); 112 | 113 | $this->registerSubCommand(new CreateWorld( 114 | $this->plugin, 115 | "createworld", 116 | "Creates a new world ready for SkyBlock!", 117 | ["cw"] 118 | )); 119 | 120 | $this->registerSubCommand(new DecreaseSize( 121 | $this->plugin, 122 | "decreasesize", 123 | "Decrease the size of a player's SkyBlock island.", 124 | ["decrease", "subtractsize", "subtract"] 125 | )); 126 | 127 | $this->registerSubCommand(new Delete( 128 | $this->plugin, 129 | "delete", 130 | "Delete a player's SkyBlock island.", 131 | ["disband", "kill", "eridicate", "expunge", "cancel"] 132 | )); 133 | 134 | $this->registerSubCommand(new Demote( 135 | $this->plugin, 136 | "demote", 137 | "Demote a player on your SkyBlock island." 138 | )); 139 | 140 | $this->registerSubCommand(new Fly( 141 | $this->plugin, 142 | "fly", 143 | "Enable Flight in the SkyBlock world." 144 | )); 145 | 146 | $this->registerSubCommand(new Help( 147 | $this->plugin, 148 | "help", 149 | "Open the RedSkyBlock Help menu" 150 | )); 151 | 152 | $this->registerSubCommand(new IncreaseSize( 153 | $this->plugin, 154 | "increasesize", 155 | "Increase the size of a player's SkyBlock island.", 156 | ["increase", "addsize"] 157 | )); 158 | 159 | $this->registerSubCommand(new Info( 160 | $this->plugin, 161 | "info", 162 | "See detailed info about the SkyBlock Island you're on." 163 | )); 164 | 165 | $this->registerSubCommand(new Invite( 166 | $this->plugin, 167 | "invite", 168 | "Invite a player to join your SkyBlock island.", 169 | ["coop", "add"] 170 | )); 171 | 172 | $this->registerSubCommand(new Kick( 173 | $this->plugin, 174 | "kick", 175 | "Kick a player off of your SkyBlock island." 176 | )); 177 | 178 | $this->registerSubCommand(new Leave( 179 | $this->plugin, 180 | "leave", 181 | "Resign from a player's SkyBlock island.", 182 | ["quit"] 183 | )); 184 | 185 | $this->registerSubCommand(new Level( 186 | $this->plugin, 187 | "level", 188 | "View a SkyBlock island's level.", 189 | ["xp"] 190 | )); 191 | 192 | $this->registerSubCommand(new Lock( 193 | $this->plugin, 194 | "lock", 195 | "Lock your SkyBlock island.", 196 | ["close"] 197 | )); 198 | 199 | $this->registerSubCommand(new Members( 200 | $this->plugin, 201 | "members", 202 | "View the members of your SkyBlock island." 203 | )); 204 | 205 | $this->registerSubCommand(new Name( 206 | $this->plugin, 207 | "name", 208 | "View the name of the SkyBlock island you are on." 209 | )); 210 | 211 | $this->registerSubCommand(new OnIsland( 212 | $this->plugin, 213 | "onisland", 214 | "View the players on your island.", 215 | ["on"] 216 | )); 217 | 218 | $this->registerSubCommand(new Promote( 219 | $this->plugin, 220 | "promote", 221 | "Promote a player on your SkyBlock island." 222 | )); 223 | 224 | $this->registerSubCommand(new Rank( 225 | $this->plugin, 226 | "rank", 227 | "View the rank of an island" 228 | )); 229 | 230 | $this->registerSubCommand(new Reload( 231 | $this->plugin, 232 | "reload", 233 | "Reloads SkyBlock data files." 234 | )); 235 | 236 | $this->registerSubCommand(new Remove( 237 | $this->plugin, 238 | "remove", 239 | "Remove a member from your SkyBlock island." 240 | )); 241 | 242 | $this->registerSubCommand(new RemovePermission( 243 | $this->plugin, 244 | "removepermission", 245 | "Remove a permission from an island rank on your SkyBlock Island.", 246 | ["removeperm", "unsetpermission", "deletepermission", "deleteperm", "unsetperm"] 247 | )); 248 | 249 | $this->registerSubCommand(new Rename( 250 | $this->plugin, 251 | "rename", 252 | "Renames your SkyBlock island." 253 | )); 254 | 255 | $this->registerSubCommand(new Reset( 256 | $this->plugin, 257 | "reset", 258 | "Reset your SkyBlock island." 259 | )); 260 | 261 | $this->registerSubCommand(new SetSize( 262 | $this->plugin, 263 | "setsize", 264 | "Set the size of a player's island.", 265 | ["size"] 266 | )); 267 | 268 | $this->registerSubCommand(new SetSpawn( 269 | $this->plugin, 270 | "setspawn", 271 | "Changes the spawnpoint on your SkyBlock island." 272 | )); 273 | 274 | $this->registerSubCommand(new Setting( 275 | $this->plugin, 276 | "setting", 277 | "Edit an Island Setting on your SkyBlock island." 278 | )); 279 | 280 | $this->registerSubCommand(new Settings( 281 | $this->plugin, 282 | "settings", 283 | "View and Change settings on your SkyBlock Island." 284 | )); 285 | 286 | $this->registerSubCommand(new SetWorld( 287 | $this->plugin, 288 | "setworld", 289 | "Select a world to use for SkyBlock.", 290 | ["sw"] 291 | )); 292 | 293 | $this->registerSubCommand(new Teleport( 294 | $this->plugin, 295 | "teleport", 296 | "Teleport to your SkyBlock island.", 297 | ["tp", "go", "spawn", "goto"] 298 | )); 299 | 300 | $this->registerSubCommand(new TopIslands( 301 | $this->plugin, 302 | "topislands", 303 | "View the top SkyBlock islands.", 304 | ["top", "leaderboard", "lb"] 305 | )); 306 | 307 | $this->registerSubCommand(new Unban( 308 | $this->plugin, 309 | "unban", 310 | "Unban a player from your SkyBlock island." 311 | )); 312 | 313 | $this->registerSubCommand(new Unlock( 314 | $this->plugin, 315 | "unlock", 316 | "Unlock your SkyBlock island.", 317 | ["open"] 318 | )); 319 | 320 | $this->registerSubCommand(new UpdateZone( 321 | $this->plugin, 322 | "updatezone", 323 | "Updates the custom island zone.", 324 | )); 325 | 326 | $this->registerSubCommand(new Value( 327 | $this->plugin, 328 | "value", 329 | "View the value of an island." 330 | )); 331 | 332 | $this->registerSubCommand(new Visit( 333 | $this->plugin, 334 | "visit", 335 | "Visit another SkyBlock Island!", 336 | ["tour"] 337 | )); 338 | 339 | $this->registerSubCommand(new ZoneTools( 340 | $this->plugin, 341 | "zonetools", 342 | "Gives Custom Island Creator Tools", 343 | ["zt", "zonetool"] 344 | )); 345 | } 346 | 347 | public function onRun(CommandSender $sender, string $aliasused, array $args): void { 348 | 349 | if (isset($args["help"])) { 350 | 351 | $sender->sendMessage("Success!"); //proof of concept 352 | return; 353 | } else { 354 | 355 | $this->sendUsage(); 356 | return; 357 | } 358 | } 359 | } 360 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Utils/IslandManager.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 23 | self::$instance = $this; 24 | } 25 | 26 | public function getIslandData(string $playerName): ?array { 27 | 28 | $playerNameLower = strtolower($playerName); 29 | 30 | if (in_array($playerNameLower . ".json", array_map('strtolower', scandir($this->plugin->getDataFolder() . "../RedSkyBlock/Players")))) { 31 | 32 | $islandData = (array) json_decode(file_get_contents($this->plugin->getDataFolder() . "../RedSkyBlock/Players/" . $playerName . ".json"), true); 33 | return $islandData; 34 | } else { 35 | 36 | return null; 37 | } 38 | } 39 | 40 | public function constructIsland(array $islandData, string $playerName): Island { 41 | 42 | $islandData = $this->verifyIslandDataIntegrity($islandData, $playerName); 43 | $island = new Island($islandData); 44 | $this->addIsland($island); 45 | $this->saveIsland($island); 46 | 47 | return $island; 48 | } 49 | 50 | public function verifyIslandDataIntegrity(array $islandData, string $playerName): array { 51 | 52 | $requiredKeys = [ 53 | "creator", 54 | "name", 55 | "size", 56 | "value", 57 | "initialspawnpoint", 58 | "spawnpoint", 59 | "members", 60 | "banned", 61 | "resetcooldown", 62 | "lockstatus", 63 | "settings", 64 | "stats", 65 | "permissions", 66 | "experience" 67 | ]; 68 | 69 | foreach ($requiredKeys as $key) { 70 | 71 | if (!isset($islandData[$key])) { 72 | 73 | $islandData[$key] = null; 74 | } 75 | } 76 | if ($islandData["creator"] !== $playerName) $islandData["creator"] = $playerName; 77 | 78 | return $islandData; 79 | } 80 | 81 | public function constructAllIslands(): void { 82 | 83 | $plugin = $this->plugin; 84 | $playerFiles = scandir($plugin->getDataFolder() . "../RedSkyBlock/Players"); 85 | 86 | foreach($playerFiles as $fileName) { 87 | 88 | $playerName = substr($fileName, 0, -5); // removes the .json from the file name 89 | if (is_file($plugin->getDataFolder() . "../RedSkyBlock/Players/" . $fileName)) { 90 | 91 | $islandData = (array) json_decode(file_get_contents($plugin->getDataFolder() . "../RedSkyBlock/Players/" . $fileName)); 92 | $this->constructIsland($islandData, $playerName); 93 | } 94 | } 95 | } 96 | 97 | public function deconstructIsland(Island $island): array { 98 | 99 | $islandData = [ 100 | "creator" => $island->getCreator(), 101 | "name" => $island->getName(), 102 | "size" => $island->getSize(), 103 | "value" => $island->getValue(), 104 | "initialspawnpoint" => $island->getInitialSpawnPoint(), 105 | "spawnpoint" => $island->getSpawnPoint(), 106 | "members" => $island->getMembers(), 107 | "banned" => $island->getBanned(), 108 | "resetcooldown" => $island->getResetCooldown(), 109 | "lockstatus" => $island->getLockStatus(), 110 | "settings" => $island->getSettings(), 111 | "stats" => $island->getStats(), 112 | "permissions" => $island->getPermissions(), 113 | "experience" => $island->getXP() 114 | ]; 115 | 116 | return $islandData; 117 | } 118 | 119 | public function saveIsland(Island $island): void { 120 | 121 | $islandData = $this->deconstructIsland($island); 122 | if (file_exists($this->plugin->getDataFolder() . "../RedSkyBlock/Players/" . $islandData["creator"] . ".json")) { 123 | 124 | file_put_contents($this->plugin->getDataFolder() . "../RedSkyBlock/Players/" . $islandData["creator"] . ".json", json_encode($islandData)); 125 | } 126 | } 127 | 128 | public function saveAllIslands(): void { 129 | 130 | foreach($this->islands as $island) { 131 | 132 | $this->saveIsland($island); 133 | } 134 | } 135 | 136 | public function getIslands(): array { 137 | 138 | return $this->islands; 139 | } 140 | 141 | public function getIsland(Player $player): ?Island { 142 | 143 | $playerName = $player->getName(); 144 | 145 | if (array_key_exists($playerName, $this->islands)) { 146 | 147 | return $this->islands[$playerName]; 148 | } else { 149 | 150 | return null; 151 | } 152 | } 153 | 154 | public function getIslandByCreatorName(string $name): ?Island { 155 | 156 | $island = null; 157 | foreach ($this->islands as $owner => $isle) { 158 | 159 | if (strtolower($isle->getCreator()) === strtolower($name)) { 160 | 161 | $island = $isle; 162 | } 163 | } 164 | return $island; 165 | } 166 | 167 | public function getIslandByName(string $islandName): ?Island { 168 | 169 | $islandName = strtolower($islandName); 170 | $islands = $this->islands; 171 | 172 | foreach ($islands as $island) { 173 | 174 | $isleName = strtolower($island->getName()); 175 | if ($islandName === $isleName) { 176 | 177 | return $island; 178 | } 179 | } 180 | return null; 181 | } 182 | 183 | public function addIsland(Island $island): void { 184 | 185 | $this->islands[$island->getCreator()] = $island; 186 | } 187 | 188 | public function removeIsland(Island $island): void { 189 | 190 | unset($this->islands[$island->getCreator()]); 191 | $this->saveIsland($island); 192 | unset($island); 193 | } 194 | 195 | public function removeAllIslands(): void { 196 | 197 | $this->islands = []; 198 | } 199 | 200 | public function deleteIsland(Island $island): void { 201 | 202 | unset($this->islands[$island->getCreator()]); 203 | 204 | 205 | $filePath = $this->plugin->getDataFolder() . "../RedSkyBlock/Players/" . $island->getCreator() . ".json"; 206 | if (file_exists($filePath)) { 207 | 208 | unlink($filePath); 209 | unset($island); 210 | } else { 211 | 212 | unset($island); 213 | } 214 | } 215 | 216 | public function getMasterWorld(): ?world { 217 | 218 | $masterWorldName = $this->plugin->skyblock->get("Master World"); 219 | $masterWorld = $this->plugin->getServer()->getWorldManager()->getWorldByName($masterWorldName); 220 | if ($masterWorld instanceof World) { 221 | 222 | if ($masterWorld->isLoaded()) { 223 | 224 | return $masterWorld; 225 | } else { 226 | 227 | if ($this->plugin->getServer()->getWorldManager()->loadWorld($masterWorldName)) { 228 | 229 | return $masterWorld; 230 | } else { 231 | 232 | return null; 233 | } 234 | } 235 | } else { 236 | 237 | return null; 238 | } 239 | } 240 | 241 | public function isOnIsland(Player $player, Island $island): bool { 242 | 243 | $playerPos = $player->getPosition(); 244 | $islandCenter = $island->getIslandCenter(); 245 | $centerX = $islandCenter[0]; 246 | $centerZ = $islandCenter[1]; 247 | $islandSize = $island->getSize(); 248 | $halfSize = $islandSize / 2; 249 | $masterWorld = $this->getMasterWorld(); 250 | $playerWorld = $player->getWorld(); 251 | 252 | if ($playerWorld === $masterWorld) { 253 | 254 | if (($playerPos->x > $centerX - $halfSize && $playerPos->z > $centerZ - $halfSize) && ($playerPos->x < $centerX + $halfSize && $playerPos->z < $centerZ + $halfSize)) { 255 | 256 | return true; 257 | } else { 258 | 259 | return false; 260 | } 261 | } else { 262 | 263 | return false; 264 | } 265 | } 266 | 267 | public function getIslandAtPlayer(Player $player): ?Island { 268 | 269 | $foundIsland = null; 270 | $playerWorld = $player->getWorld(); 271 | $masterWorld = $this->getMasterWorld(); 272 | 273 | if ($playerWorld === $masterWorld) { 274 | 275 | foreach ($this->islands as $island) { 276 | 277 | $islandSize = $island->getSize(); 278 | $halfSize = $islandSize / 2; 279 | $islandCenter = $island->getIslandCenter(); 280 | $centerX = $islandCenter[0]; 281 | $centerZ = $islandCenter[1]; 282 | 283 | $playerX = $player->getPosition()->x; 284 | $playerZ = $player->getPosition()->z; 285 | 286 | if (($playerX > $centerX - $halfSize && $playerZ > $centerZ - $halfSize) && ($playerX < $centerX + $halfSize && $playerZ < $centerZ + $halfSize)) { 287 | 288 | $foundIsland = $island; 289 | } 290 | } 291 | } 292 | return $foundIsland; 293 | } 294 | 295 | public function getIslandAtBlock(Block $block): ?Island { 296 | 297 | $foundIsland = null; 298 | $blockWorld = $block->getPosition()->world; 299 | $masterWorld = $this->getMasterWorld(); 300 | 301 | if ($masterWorld === $blockWorld) { 302 | 303 | foreach($this->islands as $island) { 304 | 305 | $islandSize = $island->getSize(); 306 | $halfSize = $islandSize / 2; 307 | $islandCenter = $island->getIslandCenter(); 308 | $centerX = $islandCenter[0]; 309 | $centerZ = $islandCenter[1]; 310 | 311 | $blockX = $block->getPosition()->x; 312 | $blockZ = $block->getPosition()->z; 313 | 314 | if (($blockX > $centerX - $halfSize && $blockZ > $centerZ - $halfSize) && ($blockX < $centerX + $halfSize && $blockZ < $centerZ + $halfSize)) { 315 | 316 | $foundIsland = $island; 317 | } 318 | } 319 | } 320 | return $foundIsland; 321 | } 322 | 323 | public function getPlayersAtIsland(Island $island): array { 324 | 325 | $onlinePlayers = $this->plugin->getServer()->getOnlinePlayers(); 326 | $playersOnIsland = []; 327 | 328 | $islandSize = $island->getSize(); 329 | $halfSize = $islandSize / 2; 330 | $islandCenter = $island->getIslandCenter(); 331 | $centerX = $islandCenter[0]; 332 | $centerZ = $islandCenter[1]; 333 | $masterWorld = $this->getMasterWorld(); 334 | 335 | foreach ($onlinePlayers as $player) { 336 | 337 | $playerX = $player->getPosition()->x; 338 | $playerZ = $player->getPosition()->z; 339 | $playerWorld = $player->getWorld(); 340 | 341 | if ($playerWorld->getFolderName() === $masterWorld->getFolderName()) { 342 | 343 | if (($playerX > $centerX - $halfSize && $playerZ > $centerZ - $halfSize) && ($playerX < $centerX + $halfSize && $playerZ < $centerZ + $halfSize)) { 344 | 345 | array_push($playersOnIsland, $player->getName()); 346 | } 347 | } 348 | } 349 | return $playersOnIsland; 350 | } 351 | 352 | public function getIslandRank(Island $island): ?int { 353 | 354 | $valueArray = []; 355 | 356 | foreach ($this->islands as $creator => $isle) { 357 | 358 | $value = $isle->getValue(); 359 | $valueArray[$creator] = $value; 360 | } 361 | 362 | arsort($valueArray); 363 | if (isset($valueArray[$island->getCreator()])) { 364 | 365 | $rank = array_search($island->getCreator(), array_keys($valueArray)) + 1; // + 1 because arrays are 0 indexed 366 | return $rank; 367 | } else { 368 | 369 | return null; 370 | } 371 | } 372 | 373 | public function getTopIslands(): array { 374 | 375 | $topIslands = []; 376 | 377 | foreach($this->islands as $island) { 378 | 379 | $value = $island->getValue(); 380 | $islandName = $island->getName(); 381 | $topIslands[$islandName] = $value; 382 | } 383 | 384 | arsort($topIslands); 385 | return $topIslands; 386 | } 387 | 388 | public function checkRepeatIslandName(string $name): bool { 389 | 390 | $name = strtolower($name); 391 | $bias = null; 392 | foreach($this->islands as $island) { 393 | 394 | if ($name === strtolower($island->getName())) { 395 | 396 | $bias = true; 397 | break; 398 | } else { 399 | 400 | $bias = false; 401 | break; 402 | } 403 | } 404 | return $bias; 405 | } 406 | 407 | public function getIslandsEmployedAt(string $playerName): array { 408 | 409 | $employedAt = []; 410 | foreach ($this->islands as $owner => $island) { 411 | 412 | if (strtolower($playerName) === strtolower($owner) || array_key_exists(strtolower($playerName), $island->getMembers())) { 413 | 414 | $employedAt[] = $island; 415 | } 416 | } 417 | return $employedAt; 418 | } 419 | 420 | public function searchIslandChannels(string $playerName): ?Island { 421 | 422 | $playerName = strtolower($playerName); 423 | $possibleChannels = $this->getIslandsEmployedAt($playerName); 424 | $tuneToChannel = null; 425 | foreach ($possibleChannels as $channel) { 426 | 427 | if (in_array($playerName, $channel->getChatters())) { 428 | 429 | $tuneToChannel = $channel; 430 | } 431 | } 432 | return $tuneToChannel; 433 | } 434 | 435 | public static function getInstance(): self { 436 | 437 | if (self::$instance === null) { 438 | 439 | self::$instance = new self(SkyBlock::getInstance()); 440 | } 441 | return self::$instance; 442 | } 443 | } 444 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/Island.php: -------------------------------------------------------------------------------- 1 | false, 32 | "safevoid" => true, 33 | "visitor_pickup" => false 34 | ); 35 | private $defaultStats = array( 36 | "blocks_broken" => 0, 37 | "blocks_placed" => 0 38 | ); 39 | private $defaultPermissions = array( 40 | "member" => ["island.place", "island.break", "island.interact"], 41 | "helper" => ["island.place", "island.break", "island.interact", "island.kick"], 42 | "moderator" => ["island.place", "island.break", "island.interact", "island.kick", "island.ban", "island.lock"], 43 | "admin" => ["island.place", "island.break", "island.interact", "island.kick", "island.ban", "island.lock", "island.spawn", "island.name"] 44 | ); 45 | 46 | private $invited = []; 47 | private $islandChat = []; 48 | 49 | public function __construct(array $islandData) { 50 | 51 | $this->creator = (string) $islandData["creator"]; 52 | $this->name = (string) $islandData["name"]; 53 | if ($this->name === "") { 54 | 55 | $this->name = $this->creator . "'s Island"; 56 | } 57 | $this->size = (int) $islandData["size"]; 58 | $this->value = (int) $islandData["value"]; 59 | $this->initialSpawnPoint = (array) $islandData["initialspawnpoint"]; 60 | if ($this->initialSpawnPoint === []) { 61 | 62 | IslandManager::getInstance()->deleteIsland($this); 63 | } 64 | $this->spawnPoint = (array) $islandData["spawnpoint"]; 65 | if ($this->spawnPoint === []) { 66 | 67 | $this->spawnPoint = $this->initialSpawnPoint; 68 | } 69 | $this->members = (array) $islandData["members"]; 70 | $this->banned = (array) $islandData["banned"]; 71 | $this->resetCooldown = (int) $islandData["resetcooldown"]; 72 | $this->lockStatus = (bool) $islandData["lockstatus"]; 73 | $this->settings = (array) $islandData["settings"]; 74 | $this->stats = (array) $islandData["stats"]; 75 | $this->permissions = (array) $islandData["permissions"]; 76 | $this->experience = (int) $islandData["experience"]; 77 | 78 | if (count($this->settings) < count($this->defaultSettings)) { 79 | 80 | $defaultSettings = array_keys($this->defaultSettings); 81 | $savedSettings = array_keys($this->settings); 82 | $compare = array_diff($defaultSettings, $savedSettings); 83 | foreach ($compare as $setting) { 84 | 85 | $this->settings[$setting] = $this->defaultSettings[$setting]; 86 | } 87 | } 88 | if (count($this->stats) < count($this->defaultStats)) { 89 | 90 | $defaultStats = array_keys($this->defaultStats); 91 | $savedStats = array_keys($this->stats); 92 | $compare = array_diff($defaultStats, $savedStats); 93 | foreach ($compare as $stat) { 94 | 95 | $this->stats[$stat] = $this->defaultStats[$stat]; 96 | } 97 | } 98 | if (count($this->permissions) < count($this->defaultPermissions)) { 99 | 100 | $defaultPermissions = array_keys($this->defaultPermissions); 101 | $savedPermissions = array_keys($this->permissions); 102 | $compare = array_diff($defaultPermissions, $savedPermissions); 103 | foreach ($compare as $permission) { 104 | 105 | $this->permissions[$permission] = $this->defaultPermissions[$permission]; 106 | } 107 | } 108 | } 109 | 110 | public function getCreator(): string { 111 | 112 | return $this->creator; 113 | } 114 | 115 | public function getName(): string { 116 | 117 | return $this->name; 118 | } 119 | 120 | public function setName(string $name): void { 121 | 122 | $this->name = $name; 123 | } 124 | 125 | public function getSize(): int { 126 | 127 | return $this->size; 128 | } 129 | 130 | public function setSize(int $size): void { 131 | 132 | $this->size = $size; 133 | } 134 | 135 | public function getValue(): int { 136 | 137 | return $this->value; 138 | } 139 | 140 | public function addValue(int $value): void { 141 | 142 | $this->value += $value; 143 | } 144 | 145 | public function removeValue(int $value): void { 146 | 147 | if ($this->value - $value < 0) { 148 | 149 | $this->value = 0; 150 | } else { 151 | 152 | $this->value -= $value; 153 | } 154 | } 155 | 156 | public function getInitialSpawnPoint(): array { 157 | 158 | return $this->initialSpawnPoint; 159 | } 160 | 161 | public function getIslandCenter(): array { //for readability 162 | 163 | $center = [$this->initialSpawnPoint[0], $this->initialSpawnPoint[2]]; 164 | return $center; 165 | } 166 | 167 | public function getSpawnPoint(): array { 168 | 169 | return $this->spawnPoint; 170 | } 171 | 172 | public function setSpawnPoint(array $spawnPoint): void { 173 | 174 | $this->spawnPoint = $spawnPoint; 175 | } 176 | 177 | public function getMembers(): array { 178 | 179 | return $this->members; 180 | } 181 | 182 | public function addMember(string $name): bool { 183 | 184 | if (!array_key_exists(strtolower($name), $this->members) && strtolower($name) !== strtolower($this->creator)) { 185 | 186 | $this->members[strtolower($name)] = "member"; //done this way for future promotion system 187 | return true; 188 | } else { 189 | 190 | return false; 191 | } 192 | } 193 | 194 | public function removeMember(string $name): bool { 195 | 196 | if (array_key_exists(strtolower($name), $this->members)) { 197 | 198 | unset($this->members[strtolower($name)]); 199 | return true; 200 | } else { 201 | 202 | return false; 203 | } 204 | } 205 | 206 | public function setRank(string $name, string $rank): void { 207 | 208 | $this->members[$name] = $rank; 209 | } 210 | 211 | public function getBanned(): array { 212 | 213 | return $this->banned; 214 | } 215 | 216 | public function ban(string $name): bool { 217 | 218 | if (!in_array(strtolower($name), $this->banned)) { 219 | 220 | array_push($this->banned, strtolower($name)); 221 | return true; 222 | } else { 223 | 224 | return false; 225 | } 226 | } 227 | 228 | public function unban(string $name): bool { 229 | 230 | if (in_array(strtolower($name), $this->banned)) { 231 | 232 | $index = array_search(strtolower($name), $this->banned); 233 | unset($this->banned[$index]); 234 | return true; 235 | } else { 236 | 237 | return false; 238 | } 239 | } 240 | 241 | public function getResetCooldown(): int { 242 | 243 | return $this->resetCooldown; 244 | } 245 | 246 | public function getLockStatus(): bool { 247 | 248 | return $this->lockStatus; 249 | } 250 | 251 | public function lock(): bool { 252 | 253 | if ($this->lockStatus === false) { 254 | 255 | $this->lockStatus = true; 256 | return true; 257 | } else { 258 | 259 | return false; 260 | } 261 | } 262 | 263 | public function unlock(): bool { 264 | 265 | if ($this->lockStatus === true) { 266 | 267 | $this->lockStatus = false; 268 | return true; 269 | } else { 270 | 271 | return false; 272 | } 273 | } 274 | 275 | public function invite(string $name): bool { 276 | 277 | $name = strtolower($name); 278 | if (!in_array($name, $this->invited)) { 279 | 280 | $this->invited[] = $name; 281 | return true; 282 | } else { 283 | 284 | return false; 285 | } 286 | } 287 | 288 | public function acceptInvite(Player $player): bool { 289 | 290 | $playerName = strtolower($player->getName()); 291 | if (in_array($playerName, $this->invited)) { 292 | 293 | $this->addMember($playerName); 294 | $index = array_search($playerName, $this->invited); 295 | unset($this->invited[$index]); 296 | return true; 297 | } else { 298 | 299 | return false; 300 | } 301 | } 302 | 303 | public function getSettings(): array { 304 | 305 | return $this->settings; 306 | } 307 | 308 | public function getDefaultSettings(): array { 309 | 310 | return $this->defaultSettings; 311 | } 312 | 313 | public function changeSetting(string $setting, bool $bias): void { 314 | 315 | $this->settings[$setting] = $bias; 316 | } 317 | 318 | public function resetSettings(): void { 319 | 320 | $this->settings = $this->defaultSettings; 321 | } 322 | 323 | public function getStats(): array { 324 | 325 | return $this->stats; 326 | } 327 | 328 | public function addToStat(string $stat, int $amount): void { 329 | 330 | $this->stats[$stat] += $amount; 331 | } 332 | 333 | public function removeFromStat(string $stat, int $amount): void { 334 | 335 | $this->stats[$stat] -= $amount; 336 | } 337 | 338 | public function getChatters(): array { 339 | 340 | return $this->islandChat; 341 | } 342 | 343 | public function addChatter(string $playerName): void { 344 | 345 | $playerName = strtolower($playerName); 346 | if (!in_array($playerName, $this->islandChat)) { 347 | 348 | $this->islandChat[] = $playerName; 349 | } 350 | } 351 | 352 | public function removeChatter(string $playerName): void { 353 | 354 | $playerName = strtolower($playerName); 355 | if (in_array($playerName, $this->islandChat)) { 356 | 357 | $index = array_search($playerName, $this->islandChat); 358 | unset($this->islandChat[$index]); 359 | } 360 | } 361 | 362 | public function getPermissions(): array { 363 | 364 | return $this->permissions; 365 | } 366 | 367 | public function removePermission(string $rank, string $permission): bool { 368 | 369 | if (in_array($permission, self::MEMBER_PERMISSIONS)) { 370 | 371 | if (array_key_exists($rank, $this->permissions)) { 372 | 373 | if (in_array($permission, $this->permissions[$rank])) { 374 | 375 | $index = array_search($permission, $this->permissions[$rank]); 376 | unset($this->permissions[$rank][$index]); 377 | return true; 378 | } else { 379 | 380 | return false; 381 | } 382 | } else { 383 | 384 | return false; 385 | } 386 | } else { 387 | 388 | return false; 389 | } 390 | } 391 | 392 | public function addPermission(string $rank, string $permission): bool { 393 | 394 | if (in_array($permission, self::MEMBER_PERMISSIONS)) { 395 | 396 | if (array_key_exists($rank, $this->permissions)) { 397 | 398 | if (!in_array($permission, $this->permissions[$rank])) { 399 | 400 | $this->permissions[$rank][] = $permission; 401 | return true; 402 | } else { 403 | 404 | return false; 405 | } 406 | } else { 407 | 408 | return false; 409 | } 410 | } else { 411 | 412 | return false; 413 | } 414 | } 415 | 416 | public function getXP(): int { 417 | 418 | return $this->experience; 419 | } 420 | 421 | public function addXP(int $amount): void { 422 | 423 | $this->experience += $amount; 424 | } 425 | 426 | public function subtractXP(int $amount): void { 427 | 428 | if ($this->experience - $amount < 0) { 429 | 430 | $this->experience = 0; 431 | } else { 432 | 433 | $this->experience -= $amount; 434 | } 435 | } 436 | 437 | public function setXP(int $amount): void { 438 | 439 | if ($amount < 0) { 440 | 441 | $this->experience = 0; 442 | } else { 443 | 444 | $this->experience = $amount; 445 | } 446 | } 447 | 448 | public function calculateLevel(int $experience): int { 449 | //formula for getting level from xp = x * ysqrt(xp) 450 | //formula for getting xp required for a level = (level/x)^y 451 | 452 | $xpGap = SkyBlock::getInstance()->cfg->get("XP Gap"); 453 | if ($xpGap <= 0) $xpGap = 0.01; 454 | $difficulty = SkyBlock::getInstance()->cfg->get("LevelUp Difficulty"); 455 | if ($difficulty <= 0) $difficulty = 0.01; 456 | 457 | $currentLevel = floor($xpGap * exp(log($experience) / $difficulty)); 458 | $unroundedLevel = (float) $xpGap * exp(log($experience) / $difficulty); 459 | if (abs($unroundedLevel - round($unroundedLevel)) < 0.0001) $currentLevel = round($unroundedLevel); 460 | 461 | return $currentLevel; 462 | } 463 | 464 | public function getXPNeeded(int $experience): int { 465 | 466 | $xpGap = SkyBlock::getInstance()->cfg->get("XP Gap"); 467 | if ($xpGap <= 0) $xpGap = 0.01; 468 | $difficulty = SkyBlock::getInstance()->cfg->get("LevelUp Difficulty"); 469 | if ($difficulty <= 0) $difficulty = 0.01; 470 | 471 | $currentLevel = $this->calculateLevel($experience); 472 | $nextLevel = $currentLevel + 1; 473 | 474 | $xpNeeded = ceil(($nextLevel/$xpGap)**$difficulty - $experience); 475 | return $xpNeeded; 476 | } 477 | } 478 | -------------------------------------------------------------------------------- /resources/messages.yml: -------------------------------------------------------------------------------- 1 | # Messages for the CreateWorld Command. Available Paramaters: {WORLD} 2 | CW: "{GREEN}The empty world {WHITE}{WORLD}{GREEN} has been created for SkyBlock." 3 | CW_NETHER: "{GREEN}The empty worlds {WHITE}{WORLD}{GREEN} and {WHITE}{WORLD}-Nether{GREEN} have been created for SkyBlock." 4 | CW_EXISTS: "{RED}The world you are trying to create already exists." 5 | 6 | # Messages for the SetWorld Command. Available Parameters: {WORLD} 7 | WORLD_SET: "{GREEN}{WORLD} has been set as the SkyBlock Master world on this server." 8 | NO_WORLD: "{RED}World {WHITE}{WORLD}{RED} not found!" 9 | NO_CHANGE: "{RED}This world is already set as the SkyBlock base world." 10 | 11 | # Message for the reload command: 12 | RELOAD: "{GREEN}All SkyBlock data has been reloaded." 13 | 14 | # Message sent to console if % chance of blocks generated in Magic Cobblestone Generator DO NOT add up to 100. 15 | GEN_FORMAT: "Generator Ores %s do not add up to 100%" 16 | 17 | # Message sent to console if a SkyBlock world has not been set: 18 | NO_MASTER: "{RED}In order for this plugin to function properly, you must set a Skyblock Master world in your server." 19 | 20 | # Message sent to console if the selected SkyBlock world could not be loaded: 21 | LOAD_ERROR: "{RED}Error: Unable to load the Skyblock Master world." 22 | 23 | # Message sent to console if the selected SkyBlock world does not exist: 24 | MASTER_FAILED: "{RED}The world currently set as the SkyBlock Master world does not exist." 25 | 26 | # Message sent to console if the selected SkyBlock world has been loaded and is ready. Available Paramaters: {MWORLD} 27 | MASTER_SUCCESS: "{GREEN}SkyBlock is running on the Master world {MWORLD}." 28 | 29 | # Messages sent upon using the zone tools: Available Parameters: {ZWORLD}, {X}, {Y}, {Z} 30 | SET_POS1: "{GREEN}Zone Position 1 set at {X}, {Y}, {Z} in world: {ZWORLD}" 31 | SET_POS2: "{GREEN}Zone Position 2 set at {X}, {Y}, {Z} in world: {ZWORLD}" 32 | SET_CUSTOM_SPAWN: "{GREEN}Custom Island Spawn set!" 33 | SPAWN_FEATHER_NOT_READY: "{RED}You must set Zone Position 1 and 2 before using this tool!" # Parameters not available for this message! 34 | WRONG_WORLD: "{RED}You did not set your Zone Positions in this world." # Parameters not available for this message! 35 | 36 | # Messages for the update zone command: 37 | UPDATE_ZONE: "{GREEN}Your custom island zone has been updated!" 38 | NO_ZONE: "{RED}You have not created a custom island zone yet!" 39 | 40 | # Message sent if an island command is used before a SkyBlock world is set. 41 | NO_MASTER_WORLD: "{RED}A SkyBlock world must be selected before this command may be used." 42 | 43 | # Message sent if a player tries to create an island but already has one: 44 | ALREADY_CREATED_ISLAND: "{RED}You have already created a SkyBlock island." 45 | 46 | # Message sent upon a player creating a new island: 47 | ISLAND_CREATED: "{GREEN}Your island has been created!" 48 | 49 | # Message sent upon using an island command without an island: 50 | NO_ISLAND: "{RED}You have not created a SkyBlock island yet!" 51 | 52 | # Message sent if there is an error with generating data files: 53 | FILE_CREATION_ERROR: "{RED}Error creating files required for this task." 54 | 55 | # Message sent upon teleporting to your own island: 56 | GO_HOME: "{GREEN}You have been teleported to your island." 57 | 58 | # Message sent upon changing island name: Available Parameters: {NAME} 59 | NAME_CHANGE: "{GREEN}Your island has been renamed {WHITE}{NAME}." 60 | # Message sent if a player attempts to rename their island but the name is already taken: Available Paramaters: {ISLAND_NAME} 61 | ISLAND_NAME_EXISTS: "{RED}The name {WHITE}{ISLAND_NAME}{RED} is already in use." 62 | 63 | # Message sent if a player is not on their island but a command requires them to be: 64 | NOT_ON_OWN_ISLAND: "{RED}You must be on your island to use this command!" 65 | # Message sent if a player is not on their island or an island they are a member of but a command requires them to be: 66 | NOT_ON_ISLAND: "{RED}You must be on an island you are a part of to use this command!" 67 | 68 | # Message sent if a player changes their island spawnpoint: Available Parameters: {X}, {Y}, {Z} 69 | SPAWN_CHANGED: "{GREEN}Your island spawn has been changed to {X}, {Y}, {Z}." 70 | 71 | # Message sent when a player checks the rank of their own island: Available Parameters: {RANK}, {TOTAL_ISLANDS} 72 | ISLAND_RANK_SELF: "{GREEN}Your island is ranked {WHITE}#{RANK} {GREEN}out of {TOTAL_ISLANDS} islands." 73 | # Message sent when a player checks the rank of another player's island: Available Parameters: {RANK}, {TOTAL_ISLANDS}, {NAME} 74 | ISLAND_RANK_OTHER: "{WHITE}{NAME}{GREEN} is ranked {WHITE}#{RANK} {GREEN}out of {TOTAL_ISLANDS} islands." 75 | 76 | # Message sent when a player checks the value of their own island: Available Parameters: {VALUE} 77 | ISLAND_VALUE_SELF: "{GREEN}Your Island Value: {WHITE}{VALUE}" 78 | # Message sent when a player checks the rank of another player's island: Available Parameters: {NAME}, {VALUE} 79 | ISLAND_VALUE_OTHER: "{WHITE}{NAME} {GREEN}Value: {WHITE}{VALUE}" 80 | 81 | # Message sent if the island specified could not be found: Available Parameters: {NAME} 82 | COULD_NOT_FIND_ISLAND: "{RED}Could not find an island with the name {WHITE}{ISLAND_NAME}{RED}." 83 | # Message sent if the target specified could not be found: Available Parameters: {NAME} 84 | TARGET_NOT_FOUND: "{RED}Could not find {WHITE}{NAME}{RED}." 85 | 86 | # Message sent when a player checks who is on their island: 87 | PLAYERS_ON_ISLAND: "{GREEN}Players on Your Island: {WHITE}{PLAYERS}" 88 | 89 | # Messages for the lock command: 90 | LOCKED: "{GREEN}Your island is now locked." 91 | ALREADY_LOCKED: "{RED}Your island is already locked." 92 | 93 | # Messages for the unlock command: 94 | UNLOCKED: "{GREEN}Your island is now unlocked." 95 | ALREADY_UNLOCKED: "{RED}Your island is already unlocked." 96 | 97 | # Message sent if an island is locked while attempting to visit: Available Parameters: {ISLAND_NAME} 98 | ISLAND_LOCKED: "{WHITE}{ISLAND_NAME}{RED} is not accepting visitors now." 99 | # Message sent when a player visits another island: Available Paramaters: {ISLAND_NAME} 100 | WELCOME_TO_ISLAND: "{GREEN}You are now visiting {WHITE}{ISLAND_NAME}!" 101 | # Message sent if a player attemps to visit an island where they have been banned: Available Parameters: {ISLAND_NAME} 102 | 103 | BANNED: "{RED}You have been banned from {WHITE}{ISLAND_NAME}{RED}." 104 | # Message sent when unbanning a player from your island: Available Parameters: {NAME} 105 | UNBANNED: "{WHITE}{NAME}{GREEN} is no longer banned from your island." 106 | # Message sent upon banning a player from your island: Available Parameters: {NAME} 107 | BANNED_PLAYER: "{GREEN}You have banned {WHITE}{NAME}{GREEN} from your island." 108 | # Message sent to a player if they are unbanned from an island: Available Parameters: {ISLAND_NAME} 109 | NO_LONGER_BANNED: "{GREEN}You are no longer banned from {WHITE}{ISLAND_NAME}{GREEN}." 110 | # Message sent if attempting to ban a player that is already banned from your island: Available Parameters: {NAME} 111 | ALREADY_BANNED: "{WHITE}{NAME}{RED} has already been banned from your island." 112 | # Message sent if attempting to unban a player that is not banned from your island: Available Parameters: {NAME} 113 | NOT_BANNED: "{WHITE}{NAME}{RED} is not banned from your island." 114 | # Message sent if a player tries to ban themself from their island: 115 | CANT_BAN: "{RED}You cannot ban this player from this island." 116 | # Message sent when a player views the players that are banned from their island: Available Parameters: {BANNED_PLAYERS} 117 | BANNED_PLAYERS: "{GREEN}Players Banned From Your Island: {WHITE}{BANNED_PLAYERS}" 118 | 119 | # Message sent if another player has not made an island yet: Available Parameters: {NAME} 120 | PLAYER_HAS_NO_ISLAND: "{WHITE}{NAME}{RED} has not made a SkyBlock island yet." 121 | 122 | # Messages for the invite command: Available Parameters: {NAME} 123 | INVITED_PLAYER: "{GREEN}Successfully invited {WHITE}{NAME}{GREEN} to your island." 124 | ALREADY_INVITED: "{RED}You have already invited {WHITE}{NAME}{RED} to your island." 125 | 126 | # Message sent when a player views the members of their island: Available Parameters: {MEMBERS} 127 | ISLAND_MEMBERS: "{GREEN}Members of Your Island: {WHITE}{MEMBERS}" 128 | 129 | # Message sent if the island member limit is reached 130 | MEMBER_LIMIT_REACHED: "{RED}This island has reached the member limit." 131 | 132 | # Message sent if a player tries to invite themself: 133 | CANT_INVITE_SELF: "{RED}You can't invite yourself to your island." 134 | 135 | # Messages for the invite accept command: Available Paramaters: {ISLAND_NAME} 136 | ACCEPTED_INVITE: "{GREEN}You are now a member of {WHITE}{ISLAND_NAME}{GREEN}." 137 | NOT_INVITED: "{RED}You have not recieved an invite from {WHITE}{ISLAND_NAME}{RED}." 138 | 139 | # Message sent to island owner if a player accepts their invite: Available Parameters: {NAME} 140 | JOINED_ISLAND: "{WHITE}{NAME}{GREEN} has accepted your invite and is now a member of your island." 141 | 142 | # Message sent to a player if they're invited to join an island: Available Parameters: {ISLAND_NAME} 143 | INVITED_TO_ISLAND: "{GREEN}You have been invited to join {ISLAND_NAME}. To accept type /is accept {ISLAND_NAME}" 144 | 145 | # Message sent if trying to invite someone who is banned from your island: Available Parameters: {NAME} 146 | CANT_INVITE_BANNED: "{RED}You cannot invite {WHITE}{NAME}{RED} because they've been banned from your island." 147 | 148 | # Messages for the name command: Available Parameters: {ISLAND_NAME} 149 | ISLAND_NAME: "{GREEN}Island: {WHITE}{ISLAND_NAME}{GREEN}." 150 | 151 | # Message sent if a player tries to remove themself from their island. 152 | CANT_REMOVE_SELF: "{RED}You cannot remove yourself from your island." 153 | 154 | # Message sent if a player tries to remove someone from their island that is not a memebr: Available Parameters: {NAME} 155 | NOT_A_MEMBER_OTHER: "{WHITE}{NAME}{RED} is not a member of your island." 156 | # Message sent if you try leaving an island you're not a member of: Available Parameters: {ISLAND_NAME} 157 | NOT_A_MEMBER_SELF: "{RED}You are not a member of {WHITE}{ISLAND_NAME}{RED}." 158 | 159 | # Message sent when a player removes a member from their island: Available Parameters: {NAME} 160 | MEMBER_REMOVED: "{WHITE}{NAME}{GREEN} is no longer a member of your island." 161 | 162 | # Message sent when a player gets removed from another's island: Available Parameters: {ISLAND_NAME} 163 | REMOVED_FROM_ISLAND: "{GREEN}You are no longer a member of {WHITE}{ISLAND_NAME}{GREEN}." 164 | 165 | # Message sent upon enabling flight on an island: 166 | FLIGHT_ENABLED: "{GREEN}You can now fly" 167 | 168 | # Message sent upon disabling flight on an island: 169 | FLIGHT_DISABLED: "{GREEN}You have disabled flight" 170 | 171 | # Message sent when a player kicks another from their SkyBlock island: Available Parameters: {NAME} 172 | KICKED_PLAYER: "{GREEN}Kicked {WHITE}{NAME}{GREEN} off of your island." 173 | # Message sent if a player kicks you off of their island: Available Parameters: {ISLAND_NAME} 174 | KICKED_FROM_ISLAND: "{RED}You were kicked off of {WHITE}{ISLAND_NAME}{RED}." 175 | # Message sent if a player tries to kick themself off of their SkyBlock island: 176 | CANT_KICK: "{RED}You cannot kick this player off of the island." 177 | 178 | # Top Islands Display Message: 179 | # Available Parameters: {POSITION_ONE}, {POSITION_TWO}, {POSITION_THREE}, {POSITION_FOUR}, {POSITION_FIVE}, {POSITION_SIX} 180 | # Available Parameters: {PAGE_NUMBER}, {TOTAL_PAGES} 181 | TOP_ISLANDS: "{GREEN}Top Islands Page {WHITE}{PAGE_NUMBER}{GREEN} of {TOTAL_PAGES}:{NEW_LINE}{WHITE}{POSITION_ONE}{NEW_LINE}{WHITE}{POSITION_TWO}{NEW_LINE}{WHITE}{POSITION_THREE}{NEW_LINE}{WHITE}{POSITION_FOUR}{NEW_LINE}{WHITE}{POSITION_FIVE}{NEW_LINE}{WHITE}{POSITION_SIX}" 182 | 183 | # Message sent when a player changes a setting on their island: Available Paramaters: {SETTING}, {VALUE} 184 | SETTING_CHANGED: "{GREEN}Island {SETTING} is now {VALUE}" 185 | # Message sent when a player tries to change an island setting that does not exist: Available Paramaters: {SETTING} 186 | SETTING_NOT_EXIST: "{WHITE}{SETTING} {RED}is not a valid Island Setting." 187 | 188 | # Message sent if an integer argument must be >= 0 but less than 0 is given: Available Paramaters: {VALUE} 189 | INT_LESS_THAN_ZERO: "{RED}You must enter a value greater than or equal to 0: {WHITE}{VALUE}{RED} given." 190 | 191 | # Message sent when the command to change the size of a player's island is run: Available Paramaters: {NAME}, {SIZE} 192 | PLAYER_ISLAND_SIZE_CHANGE: "{GREEN}You have changed {WHITE}{NAME}'s {GREEN}island size to {WHITE}{SIZE}{GREEN}." 193 | # Message sent when a player's island size is changed: 194 | ISLAND_SIZE_CHANGED: "{GREEN}Your island size has been changed to {WHITE}{SIZE}{GREEN}." 195 | 196 | # Message sent if a player tries to reset their SkyBlock island but their island still has a reset cooldown 197 | CANT_RESET_YET: "{RED}You must wait {WHITE}{TIME}{RED} before resetting your island." 198 | 199 | # Message sent if the island a player is on has been deleted: 200 | ISLAND_ON_DELETED: "{RED}The island you were on has been deleted." 201 | # Message sent to a player if their island is deleted: 202 | ISLAND_DELETED: "{RED}Your island has been deleted by an administrator." 203 | 204 | # Message format for the RedSkyBlock Help Menu: Available Paramaters: {PAGE_NUMBER}, {TOTAL_PAGES}, {COMMAND_ONE}, {COMMAND_TWO}, {COMMAND_THREE}, {COMMAND_FOUR}, {COMMAND_FIVE}, {COMMAND_SIX} 205 | HELP_MENU: "{RED}{BOLD}RedSkyBlock{RESET}{WHITE} Help Menu Page {GREEN}{PAGE_NUMBER}{WHITE} of {GREEN}{TOTAL_PAGES}{WHITE}:{NEW_LINE}{COMMAND_ONE}{NEW_LINE}{COMMAND_TWO}{NEW_LINE}{COMMAND_THREE}{NEW_LINE}{COMMAND_FOUR}{NEW_LINE}{COMMAND_FIVE}{NEW_LINE}{COMMAND_SIX}" 206 | # Message format for the RedSkyBlock Help Menu for a specific command: Available Parameters: {COMMAND}, {DESCRIPTION}, {USAGE}, {PERMISSIONS}, {ALIASES} 207 | HELP_MENU_SPECIFIC: "{RED}{BOLD}RedSkyBlock{RESET}{WHITE} Help Menu for {GREEN}{COMMAND}{WHITE} command:{GREEN}{NEW_LINE}Aliases: {WHITE}{ALIASES}{NEW_LINE}{GREEN}Description: {WHITE}{DESCRIPTION}{NEW_LINE}{GREEN}Usage: {WHITE}/is {USAGE}{NEW_LINE}{GREEN}Permissions Required: {WHITE}{PERMISSIONS}" 208 | # Message sent if a player searches the help menu for an invalid command: Available Parameters: {COMMAND} 209 | NO_SUCH_COMMAND: "{WHITE}{COMMAND}{RED} is not a RedSkyBlock command." 210 | 211 | # Message format for the Detailed SkyBlock info command: 212 | # Available Paramaters: 213 | # {ISLAND_NAME}, {ISLAND_CREATOR}, {ISLAND_SIZE}, {SPAWN_POINT}, {ISLAND_VALUE}, {RESET_COOLDOWN}, {LOCK_STATUS}, {MEMBERS}, {BANNED}, {ISLAND_SETTINGS}, {ISLAND_STATS} 214 | ISLAND_INFO_FULL: "{RED}{BOLD}{ISLAND_NAME}'s{RESET}{WHITE} Info:{NEW_LINE}{GREEN}Created By: {WHITE}{ISLAND_CREATOR}{NEW_LINE}{GREEN}Members: {WHITE}{MEMBERS}{NEW_LINE}{GREEN}Value: {WHITE}{ISLAND_VALUE}{NEW_LINE}{GREEN}Lock Status: {WHITE}{LOCK_STATUS}{NEW_LINE}{GREEN}Island Spawn: {WHITE}{SPAWN_POINT}{NEW_LINE}{GREEN}Size: {WHITE}{ISLAND_SIZE}x{ISLAND_SIZE}{NEW_LINE}{GREEN}Banned: {WHITE}{BANNED}{NEW_LINE}{GREEN}Island Settings: {WHITE}{ISLAND_SETTINGS}{NEW_LINE}{GREEN}Island Stats: {WHITE}{ISLAND_STATS}" 215 | 216 | # Message format for the limited SkyBlock info command: 217 | # Available Parameters: 218 | # {ISLAND_NAME}, {ISLAND_CREATOR}, {SPAWN_POINT}, {ISLAND_VALUE}, {LOCK_STATUS}, {ISLAND_STATS} 219 | ISLAND_INFO_LIMITED: "{RED}{BOLD}{ISLAND_NAME}'s{RESET}{WHITE} Info:{NEW_LINE}{GREEN}Created By: {WHITE}{ISLAND_CREATOR}{NEW_LINE}{GREEN}Value: {WHITE}{ISLAND_VALUE}{NEW_LINE}{GREEN}Lock Status: {WHITE}{LOCK_STATUS}{NEW_LINE}{GREEN}Island Spawn: {WHITE}{SPAWN_POINT}{NEW_LINE}{GREEN}Island Stats: {WHITE}{ISLAND_STATS}" 220 | 221 | # Message sent upon joining an island chat channel: Available Paramaters: {ISLAND_NAME} 222 | JOIN_ISLAND_CHAT: "{GREEN}You have joined the {WHITE}{ISLAND_NAME}{GREEN} chat." 223 | # Message sent upon leaving an island chat channel: Available Paramaters: {ISLAND_NAME} 224 | LEAVE_ISLAND_CHAT: "{GREEN}You have left the {WHITE}{ISLAND_NAME}{GREEN} chat." 225 | 226 | # Message sent if trying to demote a player that is already the lowest rank on an Island: Available Paramaters: {NAME} 227 | CANT_DEMOTE: "{WHITE}{NAME}{RED} can't be demoted any further." 228 | # Message sent if trying to promote a player that is already the highest rank on an Island: Available Paramaters: {NAME} 229 | CANT_PROMOTE: "{WHITE}{NAME}{RED} can't be promoted any more." 230 | 231 | # Message sent if you promote a player on your island: Available Paramaters: {RANK}, {NAME} 232 | PROMOTED_OTHER: "{WHITE}{NAME}{GREEN} has been promoted to Island {WHITE}{RANK}{GREEN}." 233 | # Message sent if you were promoted on another island: Available Paramaters: {RANK}, {ISLAND_NAME} 234 | PROMOTED_SELF: "{GREEN}You have been promoted to Island {WHITE}{RANK}{GREEN} on {WHITE}{ISLAND_NAME}{GREEN}." 235 | 236 | # Message sent if you demote a player on your island: Available Paramaters: {RANK}, {NAME} 237 | DEMOTED_OTHER: "{WHITE}{NAME}{GREEN} has been demoted to Island {WHITE}{RANK}{GREEN}." 238 | # Message sent if you were demoted on another island: Available Paramaters: {RANK}, {ISLAND_NAME} 239 | DEMOTED_SELF: "{RED}You have been demoted to Island {WHITE}{RANK}{RED} on {WHITE}{ISLAND_NAME}{RED}." 240 | 241 | # Message sent if trying to run a command on an island but rank is too low: Available Paramaters: {ISLAND_NAME} 242 | RANK_TOO_LOW: "{RED}You are not high enough rank on {WHITE}{ISLAND_NAME}{RED} to run this command here." 243 | 244 | # Message sent upon adding a new permission to an island rank: Available Paramaters: {PERMISSION}, {RANK} 245 | PERMISSION_ADDED: "{GREEN}Added permission: {WHITE}{PERMISSION}{GREEN} to Island {WHITE}{RANK}s{GREEN}." 246 | # Message sent if unable to add a permission to an island rank: Available Paramaters: {PERMISSION}, {RANK} 247 | PERMISSION_NOT_ADDED: "{RED}Could not add permission: {WHITE}{PERMISSION}{RED} to Island {WHITE}{RANK}s{RED}." 248 | 249 | # Message sent upon removing a permission from an island rank: Available Paramaters: {PERMISSION}, {RANK} 250 | PERMISSION_REMOVED: "{GREEN}Removed permission: {WHITE}{PERMISSION}{GREEN} from Island {WHITE}{RANK}s{GREEN}." 251 | # Message sent if unable to remove a permission from an island rank: Available Paramaters: {PERMISSION}, {RANK} 252 | PERMISSION_NOT_REMOVED: "{RED}Could not remove permission: {WHITE}{PERMISSION}{RED} from Island {WHITE}{RANK}s{RED}." 253 | 254 | # Message sent if looking at the level of another player's SkyBlock island: Available Paramaters: {ISLAND_NAME}, {LEVEL}, {XP}, {XP_NEEDED} 255 | ISLAND_LEVEL_OTHER: "{WHITE}{ISLAND_NAME}{GREEN} is level {WHITE}{LEVEL}{GREEN}.{NEW_LINE}XP: {WHITE}{XP}{GREEN} / {WHITE}{XP_NEEDED}" 256 | # Message sent if looking at your own SkyBlock island's level: Available Paramaters: {LEVEL}, {XP}, {XP_NEEDED} 257 | ISLAND_LEVEL_SELF: "Your island is level {WHITE}{LEVEL}{GREEN}.{NEW_LINE}XP: {WHITE}{XP}{GREEN} / {WHITE}{XP_NEEDED}" 258 | -------------------------------------------------------------------------------- /src/RedCraftPE/RedSkyBlock/SkyblockListener.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 49 | $plugin->getServer()->getPluginManager()->registerEvents($this, $plugin); 50 | } 51 | 52 | public function onForm(BlockFormEvent $event) { 53 | 54 | $plugin = $this->plugin; 55 | $block = $event->getBlock(); 56 | $world = $block->getPosition()->getWorld()->getFolderName(); 57 | 58 | $generatorOres = $plugin->cfg->get("Generator Ores", []); 59 | $masterWorld = $plugin->skyblock->get("Master World"); 60 | 61 | if ($world === $masterWorld || $world === $masterWorld . "-Nether") { 62 | 63 | if (count($generatorOres) !== 0) { 64 | 65 | if (array_sum($generatorOres) !== 100) { 66 | 67 | $message = $plugin->mShop->construct("GEN_FORMAT"); 68 | $plugin->getLogger()->info($message); 69 | } else { 70 | 71 | $genBlock = null; 72 | $randomNumber = random_int(1, 100); 73 | $percentChance = 0; 74 | 75 | foreach ($generatorOres as $blockName => $oreChance) { 76 | 77 | $percentChance += $oreChance; 78 | 79 | if ($randomNumber <= $percentChance) { 80 | 81 | $genBlock = StringToItemParser::getInstance()->parse($blockName)->getBlock(); 82 | break; 83 | } 84 | } 85 | if ($genBlock instanceof Block) { 86 | 87 | $event->cancel(); 88 | $block->getPosition()->getWorld()->setBlock($block->getPosition(), $genBlock); 89 | } 90 | } 91 | } 92 | } 93 | } 94 | 95 | public function onJoin(PlayerJoinEvent $event) { 96 | 97 | $player = $event->getPlayer(); 98 | ZoneManager::clearZoneTools($player); 99 | } 100 | 101 | public function onQuit(PlayerQuitEvent $event) { 102 | 103 | $player = $event->getPlayer(); 104 | $zoneShovel = ZoneManager::getZoneShovel(); 105 | $spawnFeather = ZoneManager::getSpawnFeather(); 106 | 107 | if (ZoneManager::getZoneKeeper() === $player) { 108 | 109 | ZoneManager::setZoneKeeper(); 110 | ZoneManager::clearZoneTools($player); 111 | } 112 | } 113 | 114 | public function onDrop(PlayerDropItemEvent $event) { 115 | 116 | $item = $event->getItem(); 117 | $player = $event->getPlayer(); 118 | $zoneShovel = ZoneManager::getZoneShovel(); 119 | $spawnFeather = ZoneManager::getSpawnFeather(); 120 | 121 | if ($item->equals($zoneShovel) || $item->equals($spawnFeather)) { 122 | 123 | $event->cancel(); 124 | $index = array_search($item, $player->getInventory()->getContents()); 125 | $player->getInventory()->setItem($index, VanillaItems::AIR()); 126 | } 127 | } 128 | 129 | public function onInteract(PlayerInteractEvent $event) { 130 | 131 | $plugin = $this->plugin; 132 | $player = $event->getPlayer(); 133 | $block = $event->getBlock(); 134 | $item = $event->getItem(); 135 | $action = $event->getAction(); 136 | $zoneShovel = ZoneManager::getZoneShovel(); 137 | 138 | $blockPos = $block->getPosition(); 139 | $blockX = round($blockPos->x); 140 | $blockY = round($blockPos->y); 141 | $blockZ = round($blockPos->z); 142 | 143 | $zoneWorld = ZoneManager::getZoneWorld(); 144 | $blockWorld = $blockPos->world; 145 | 146 | // check if using a zonetool and take appropriate actions if true: 147 | 148 | if ($item->equals($zoneShovel)) { 149 | 150 | if ($action === PlayerInteractEvent::RIGHT_CLICK_BLOCK) { 151 | 152 | ZoneManager::setFirstPosition($blockPos); 153 | 154 | if ($zoneWorld === null || $zoneWorld != $blockWorld) { 155 | 156 | ZoneManager::setZoneWorld($blockWorld); 157 | ZoneManager::setSecondPosition(); //reset the other position because it was selected in a different world 158 | $zoneWorld = $blockWorld; 159 | } 160 | 161 | $message = $plugin->mShop->construct("SET_POS1"); 162 | $message = str_replace("{X}", $blockX, $message); 163 | $message = str_replace("{Y}", $blockY, $message); 164 | $message = str_replace("{Z}", $blockZ, $message); 165 | $message = str_replace("{ZWORLD}", $zoneWorld->getFolderName(), $message); 166 | $player->sendMessage($message); 167 | return; 168 | } 169 | } 170 | //check if interacting with a block on an island and if yes cancel if not a part of that island: 171 | 172 | $island = $plugin->islandManager->getIslandAtBlock($block); 173 | if ($island instanceof Island) { 174 | 175 | $members = $island->getMembers(); 176 | if (array_key_exists(strtolower($player->getName()), $members)) { 177 | 178 | $islandPermissions = $island->getPermissions(); 179 | $playerRank = $members[strtolower($player->getName())]; 180 | if (!in_array("island.interact", $islandPermissions[$playerRank])) { 181 | 182 | $event->cancel(); 183 | } 184 | } elseif (!($player->getName() === $island->getCreator() || $player->hasPermission("redskyblock.bypass"))) { 185 | 186 | $event->cancel(); 187 | } 188 | } 189 | } 190 | 191 | public function onBreak(BlockBreakEvent $event) { 192 | 193 | $plugin = $this->plugin; 194 | $player = $event->getPlayer(); 195 | $block = $event->getBlock(); 196 | $item = $event->getItem(); 197 | $zoneShovel = ZoneManager::getZoneShovel(); 198 | $spawnFeather = ZoneManager::getSpawnFeather(); 199 | 200 | $blockPos = $block->getPosition(); 201 | $blockX = round($blockPos->x); 202 | $blockY = round($blockPos->y); 203 | $blockZ = round($blockPos->z); 204 | 205 | $zoneWorld = ZoneManager::getZoneWorld(); 206 | $blockWorld = $blockPos->world; 207 | 208 | // check if using a zone tool and take the appropriate actions if true: 209 | 210 | if ($item->equals($zoneShovel)) { 211 | 212 | ZoneManager::setSecondPosition($blockPos); 213 | $event->cancel(); 214 | 215 | if ($zoneWorld === null || $zoneWorld != $blockWorld) { 216 | 217 | ZoneManager::setZoneWorld($blockWorld); 218 | ZoneManager::setFirstPosition(); //reset the other position because it was selected in a different world 219 | $zoneWorld = $blockWorld; 220 | } 221 | 222 | $message = $plugin->mShop->construct("SET_POS2"); 223 | $message = str_replace("{X}", $blockX, $message); 224 | $message = str_replace("{Y}", $blockY, $message); 225 | $message = str_replace("{Z}", $blockZ, $message); 226 | $message = str_replace("{ZWORLD}", $zoneWorld->getFolderName(), $message); 227 | $player->sendMessage($message); 228 | return; 229 | 230 | } elseif ($item->equals($spawnFeather)) { 231 | 232 | $event->cancel(); 233 | $zonePos1 = ZoneManager::getFirstPosition(); 234 | $zonePos2 = ZoneManager::getSecondPosition(); 235 | 236 | if ($zonePos1 !== null && $zonePos2 !== null) { 237 | 238 | if ($blockWorld === $zoneWorld) { 239 | 240 | ZoneManager::setSpawnPosition($blockPos); 241 | ZoneManager::createZone(); 242 | ZoneManager::setZoneKeeper(); 243 | ZoneManager::setFirstPosition(); 244 | ZoneManager::setSecondPosition(); 245 | ZoneManager::clearZoneTools($player); 246 | 247 | $message = $plugin->mShop->construct("SET_CUSTOM_SPAWN"); 248 | $player->sendMessage($message); 249 | return; 250 | } else { 251 | 252 | $message = $plugin->mShop->construct("WRONG_WORLD"); 253 | $player->sendMessage($message); 254 | return; 255 | } 256 | } else { 257 | 258 | $message = $plugin->mShop->construct("SPAWN_FEATHER_NOT_READY"); 259 | $player->sendMessage($message); 260 | return; 261 | } 262 | } 263 | 264 | // Check if allowed to break blocks or if island value should decrease if on an island: 265 | 266 | $island = $plugin->islandManager->getIslandAtBlock($block); 267 | if ($island instanceof Island) { 268 | 269 | $members = $island->getMembers(); 270 | $creator = $island->getCreator(); 271 | $playerName = $player->getName(); 272 | $playerNameLower = strtolower($playerName); 273 | 274 | if (array_key_exists($playerNameLower, $members) || $playerName === $creator || $player->hasPermission("redskyblock.bypass")) { 275 | 276 | if (array_key_exists($playerNameLower, $members)) { 277 | 278 | $islandPermissions = $island->getPermissions(); 279 | $playerRank = $members[$playerNameLower]; 280 | if (!in_array("island.break", $islandPermissions[$playerRank])) { 281 | 282 | $event->cancel(); 283 | return; 284 | } 285 | } 286 | $valuableArray = $plugin->cfg->get("Valuable Blocks", []); 287 | $blockName = str_replace(" ", "_", strtolower($block->getName())); 288 | if (array_key_exists($blockName, $valuableArray)) { 289 | 290 | $island->removeValue((int) $valuableArray[$blockName]); 291 | } 292 | 293 | $island->addToStat("blocks_broken", 1); 294 | } else { 295 | 296 | $event->cancel(); 297 | } 298 | 299 | } elseif (!$player->hasPermission("redskyblock.bypass")) { 300 | 301 | $event->cancel(); 302 | } 303 | } 304 | 305 | public function onPlace(BlockPlaceEvent $event) { 306 | 307 | $plugin = $this->plugin; 308 | $masterWorld = $plugin->islandManager->getMasterWorld(); 309 | $block = $event->getBlock(); 310 | $blockWorld = $block->getPosition()->world; 311 | $player = $event->getPlayer(); 312 | 313 | $island = $plugin->islandManager->getIslandAtBlock($block); 314 | if ($island instanceof Island) { 315 | 316 | $members = $island->getMembers(); 317 | $creator = $island->getCreator(); 318 | $playerName = $player->getName(); 319 | $playerNameLower = strtolower($playerName); 320 | 321 | if (array_key_exists($playerNameLower, $members) || $playerName === $creator || $player->hasPermission("redskyblock.bypass")) { 322 | 323 | if (array_key_exists($playerNameLower, $members)) { 324 | 325 | $islandPermissions = $island->getPermissions(); 326 | $playerRank = $members[$playerNameLower]; 327 | if (!in_array("island.place", $islandPermissions[$playerRank])) { 328 | 329 | $event->cancel(); 330 | return; 331 | } 332 | } 333 | 334 | $valuableArray = $plugin->cfg->get("Valuable Blocks", []); 335 | $blockName = str_replace(" ", "_", strtolower($block->getName())); 336 | if (array_key_exists($blockName, $valuableArray)) { 337 | 338 | $island->addValue((int) $valuableArray[$blockName]); 339 | } 340 | 341 | $island->addToStat("blocks_placed", 1); 342 | } else { 343 | 344 | $event->cancel(); 345 | return; 346 | } 347 | } elseif (!$player->hasPermission("redskyblock.bypass")) { 348 | 349 | $event->cancel(); 350 | return; 351 | } 352 | } 353 | 354 | public function onTeleport(EntityTeleportEvent $event) { 355 | 356 | $entity = $event->getEntity(); 357 | if ($entity instanceof Player) { 358 | 359 | $entityEndWorld = $event->getTo()->world; 360 | $masterWorld = $this->plugin->islandManager->getMasterWorld(); 361 | if ($entityEndWorld !== $masterWorld && !$entity->hasPermission("redskyblock.admin")) { 362 | 363 | if ($entity->getAllowFlight()) { 364 | 365 | $entity->setAllowFlight(false); 366 | $entity->setFlying(false); 367 | } 368 | } 369 | } 370 | } 371 | 372 | public function onDamage(EntityDamageEvent $event) { 373 | 374 | $plugin = $this->plugin; 375 | $entity = $event->getEntity(); 376 | $masterWorld = $plugin->islandManager->getMasterWorld(); 377 | if ($entity instanceof Player) { 378 | 379 | $cause = $event->getCause(); 380 | if ($cause === EntityDamageEvent::CAUSE_VOID) { 381 | 382 | $island = $plugin->islandManager->getIslandAtPlayer($entity); 383 | if ($island instanceof Island) { 384 | 385 | $islandSettings = $island->getSettings(); 386 | if ($islandSettings["safevoid"]) { 387 | 388 | $event->cancel(); 389 | 390 | $islandSpawn = $island->getSpawnPoint(); 391 | $entity->teleport(new Position($islandSpawn[0], $islandSpawn[1], $islandSpawn[2], $masterWorld)); 392 | } 393 | } 394 | } elseif ($cause === EntityDamageEvent::CAUSE_FALL) { 395 | 396 | $playerWorld = $entity->getWorld(); 397 | if ($playerWorld === $masterWorld) { 398 | 399 | if (!$plugin->cfg->get("Fall Damage")) { 400 | 401 | $event->cancel(); 402 | } 403 | } 404 | } 405 | } 406 | } 407 | 408 | public function onDamageByEntity(EntityDamageByEntityEvent $event) { 409 | 410 | $plugin = $this->plugin; 411 | $attackingEntity = $event->getDamager(); 412 | $entity = $event->getEntity(); 413 | 414 | if ($attackingEntity instanceof Player && $entity instanceof Player) { 415 | 416 | $island = $plugin->islandManager->getIslandAtPlayer($entity); 417 | if ($island instanceof Island) { 418 | 419 | $islandSettings = $island->getSettings(); 420 | if (!$islandSettings["pvp"]) { 421 | 422 | $event->cancel(); 423 | } 424 | } 425 | } 426 | } 427 | 428 | public function onExhaust(PlayerExhaustEvent $event) { 429 | 430 | $plugin = $this->plugin; 431 | $player = $event->getPlayer(); 432 | $playerWorld = $player->getWorld(); 433 | $masterWorld = $plugin->islandManager->getMasterWorld(); 434 | $doHunger = $plugin->cfg->get("Island Hunger"); 435 | 436 | if ($playerWorld === $masterWorld && !$doHunger) { 437 | 438 | $player->getHungerManager()->addFood(10); 439 | } 440 | } 441 | 442 | public function onPickup(EntityItemPickupEvent $event) { 443 | 444 | $entity = $event->getEntity(); 445 | if ($entity instanceof Player) { 446 | 447 | $island = $this->plugin->islandManager->getIslandAtPlayer($entity); 448 | if ($island instanceof Island) { 449 | 450 | $islandSettings = $island->getSettings(); 451 | $islandMembers = $island->getMembers(); 452 | $islandCreator = $island->getCreator(); 453 | 454 | if ($entity->getName() !== $islandCreator) { 455 | 456 | if (!$entity->hasPermission("redskyblock.bypass")) { 457 | 458 | if (!array_key_exists(strtolower($entity->getName()), $islandMembers)) { 459 | 460 | if (!$islandSettings["visitor_pickup"]) { 461 | 462 | $event->cancel(); 463 | } 464 | } 465 | } 466 | } 467 | } 468 | } 469 | } 470 | 471 | public function onDeath(PlayerDeathEvent $event) { 472 | 473 | $keepInventory = $this->plugin->cfg->get("Keep Inventory"); 474 | $playerWorld = $event->getPlayer()->getWorld(); 475 | $masterWorld = $this->plugin->islandManager->getMasterWorld(); 476 | 477 | if ($playerWorld === $masterWorld && $keepInventory) { 478 | 479 | $event->setKeepInventory(true); 480 | } 481 | } 482 | 483 | public function onMove(PlayerMoveEvent $event) { 484 | 485 | $player = $event->getPlayer(); 486 | $playerWorld = $player->getWorld(); 487 | $masterWorld = $this->plugin->islandManager->getMasterWorld(); 488 | 489 | if ($this->plugin->cfg->get("Island Boundaries")) { 490 | 491 | if ($playerWorld === $masterWorld) { 492 | 493 | $island = $this->plugin->islandManager->getIslandAtPlayer($player); 494 | if (!$island instanceof Island && !$player->hasPermission("redskyblock.bypass")) { 495 | 496 | $event->cancel(); 497 | } 498 | } 499 | } 500 | } 501 | 502 | public function onChat(PlayerChatEvent $event) { 503 | 504 | $player = $event->getPlayer(); 505 | $message = $event->getMessage(); 506 | $channel = $this->plugin->islandManager->searchIslandChannels($player->getName()); 507 | 508 | if ($channel instanceof Island) { 509 | 510 | $recipients = []; 511 | foreach($channel->getChatters() as $playerName) { 512 | 513 | $recipient = $this->plugin->getServer()->getPlayerExact($playerName); 514 | $recipients[] = $recipient; 515 | } 516 | 517 | $event->setMessage(TextFormat::RED . TextFormat::BOLD . $channel->getName() . TextFormat::RESET . ": " . $message); 518 | $event->setRecipients($recipients); 519 | } 520 | } 521 | 522 | public function onBucket(PlayerBucketEvent $event) { 523 | 524 | $player = $event->getPlayer(); 525 | $block = $event->getBlockClicked(); 526 | 527 | $island = $this->plugin->islandManager->getIslandAtBlock($block); 528 | if ($island instanceof Island) { 529 | 530 | $members = $island->getMembers(); 531 | if (array_key_exists(strtolower($player->getName()), $members)) { 532 | 533 | $islandPermissions = $island->getPermissions(); 534 | $playerRank = $members[strtolower($player->getName())]; 535 | if (!in_array("island.interact", $islandPermissions[$playerRank])) { 536 | 537 | $event->cancel(); 538 | } 539 | } elseif (!($player->getName() === $island->getCreator() || $player->hasPermission("redskyblock.bypass"))) { 540 | 541 | $event->cancel(); 542 | } 543 | } 544 | } 545 | } 546 | --------------------------------------------------------------------------------