├── core ├── .gitignore ├── resources │ ├── forms │ │ ├── README.md │ │ └── forms.yml │ ├── items │ │ ├── README.md │ │ └── items.yml │ ├── messages │ │ └── messages.yml │ └── scoreboards │ │ └── scoreboards.yml ├── src │ └── jkorn │ │ └── practice │ │ ├── misc │ │ ├── ISaved.php │ │ ├── ISavedHeader.php │ │ ├── IDisplayText.php │ │ ├── AbstractManager.php │ │ ├── PracticeAsyncTask.php │ │ └── ColorIDs.php │ │ ├── forms │ │ ├── IPracticeForm.php │ │ ├── display │ │ │ ├── FormDisplayText.php │ │ │ └── FormDisplay.php │ │ ├── internal │ │ │ └── IInternalFormIDs.php │ │ └── Form.php │ │ ├── player │ │ ├── info │ │ │ ├── settings │ │ │ │ ├── ISettingsProperty.php │ │ │ │ └── properties │ │ │ │ │ ├── IntegerSettingProperty.php │ │ │ │ │ ├── FloatSettingProperty.php │ │ │ │ │ ├── StringSettingProperty.php │ │ │ │ │ └── BooleanSettingProperty.php │ │ │ ├── stats │ │ │ │ ├── IStatProperty.php │ │ │ │ ├── StatPropertyInfo.php │ │ │ │ └── properties │ │ │ │ │ ├── IntegerStatProperty.php │ │ │ │ │ └── FloatStatProperty.php │ │ │ ├── ClicksInfo.php │ │ │ └── DisguiseInfo.php │ │ ├── misc │ │ │ ├── IPlayerProperty.php │ │ │ └── PracticePlayerSessionAdapter.php │ │ └── ranks │ │ │ └── RankManager.php │ │ ├── level │ │ ├── IArea.php │ │ ├── gen │ │ │ ├── PracticeGeneratorInfo.php │ │ │ ├── PracticeGenerator.php │ │ │ └── PracticeGeneratorManager.php │ │ └── SpawnArea.php │ │ ├── messages │ │ ├── IPracticeMessages.php │ │ ├── managers │ │ │ └── PracticeMessageManager.php │ │ └── PracticeMessage.php │ │ ├── commands │ │ ├── IPracticePermissions.php │ │ ├── PracticeCommand.php │ │ ├── ManageKitsCommand.php │ │ ├── ManageArenasCommand.php │ │ └── SpectateCommand.php │ │ ├── arenas │ │ ├── SavedPracticeArena.php │ │ └── PracticeArena.php │ │ ├── games │ │ ├── misc │ │ │ ├── managers │ │ │ │ ├── ISpectatingGameManager.php │ │ │ │ ├── IAwaitingGameManager.php │ │ │ │ ├── IUpdatedGameManager.php │ │ │ │ └── awaiting │ │ │ │ │ └── IAwaitingManager.php │ │ │ ├── gametypes │ │ │ │ ├── IUpdatedGame.php │ │ │ │ ├── info │ │ │ │ │ └── IGameInfo.php │ │ │ │ ├── ITeamGame.php │ │ │ │ ├── IGame.php │ │ │ │ └── ISpectatorGame.php │ │ │ └── leaderboards │ │ │ │ └── IGameLeaderboard.php │ │ ├── player │ │ │ ├── TeamPlayer.php │ │ │ └── properties │ │ │ │ ├── IGamePlayerProperty.php │ │ │ │ └── GPPropertyInfo.php │ │ └── duels │ │ │ ├── teams │ │ │ └── DuelTeamPlayer.php │ │ │ ├── DuelPlayer.php │ │ │ └── AbstractQueue.php │ │ ├── scoreboard │ │ └── display │ │ │ ├── manager │ │ │ └── ScoreboardDisplayManager.php │ │ │ └── ScoreboardDisplayLine.php │ │ ├── data │ │ ├── PracticeDataManager.php │ │ ├── IDataProvider.php │ │ └── providers │ │ │ └── EmptyDataProvider.php │ │ ├── PracticeTask.php │ │ ├── kits │ │ └── IKit.php │ │ ├── display │ │ └── DisplayStatisticNames.php │ │ └── items │ │ └── PracticeItemManager.php └── plugin.yml ├── addons ├── ffa │ ├── .gitignore │ ├── plugin.yml │ ├── resources │ │ ├── scoreboards │ │ │ └── scoreboards.yml │ │ └── forms │ │ │ └── forms.yml │ └── src │ │ └── jkorn │ │ └── ffa │ │ ├── forms │ │ ├── internal │ │ │ ├── FFAInternalFormIDs.php │ │ │ └── FFAInternalForm.php │ │ └── FFAFormManager.php │ │ ├── statistics │ │ └── FFADisplayStatistics.php │ │ ├── scoreboards │ │ └── FFAScoreboardManager.php │ │ └── FFAAddon.php └── basicduels │ ├── .gitignore │ ├── resources │ ├── forms │ │ ├── README.md │ │ └── forms.yml │ └── scoreboards │ │ ├── README.md │ │ └── scoreboards.yml │ ├── plugin.yml │ └── src │ └── jkorn │ └── bd │ ├── BDStatsInfo.php │ ├── arenas │ └── IDuelArena.php │ ├── forms │ ├── internal │ │ ├── BasicDuelInternalFormIDs.php │ │ ├── BasicDuelInternalForm.php │ │ ├── CreateBasicDuelArena.php │ │ └── edit │ │ │ └── EditBasicDuelArenaArea.php │ └── BasicDuelsFormManager.php │ ├── player │ ├── BasicDuelPlayer.php │ ├── team │ │ └── BasicDuelTeamPlayer.php │ └── BasicDPPropertyInfo.php │ ├── messages │ ├── BasicDuelsMessageManager.php │ └── BasicDuelsMessages.php │ ├── duels │ ├── IBasicDuel.php │ ├── leaderboard │ │ └── WLRatioGroup.php │ └── types │ │ └── BasicDuelGameInfo.php │ ├── scoreboards │ └── BasicDuelsScoreboardManager.php │ ├── BasicDuels.php │ └── gen │ └── BasicDuelsGeneratorInfo.php ├── .gitignore ├── README.md ├── .DS_Store └── old ├── src └── practice │ ├── player │ ├── disguise │ │ ├── DisguiseHandler.php │ │ └── DisguiseInfo.php │ ├── permissions │ │ └── PermissionsToCfgTask.php │ ├── RespawnTask.php │ ├── PlayerSpawnTask.php │ └── gameplay │ │ ├── reports │ │ ├── ReportInfo.php │ │ ├── BugReport.php │ │ ├── HackReport.php │ │ └── StaffReport.php │ │ └── ChatHandler.php │ ├── game │ ├── inventory │ │ ├── menus │ │ │ ├── data │ │ │ │ └── PracHolderData.php │ │ │ ├── BaseMenu.php │ │ │ ├── LeaderboardMenu.php │ │ │ └── inventories │ │ │ │ └── SingleChestInv.php │ │ └── InventoryTask.php │ ├── SetTimeDayTask.php │ ├── items │ │ ├── ItemTextures.php │ │ └── PracticeItem.php │ └── effects │ │ └── PracticeEffect.php │ ├── arenas │ ├── TeleportArenaTask.php │ └── FFAArena.php │ ├── commands │ ├── parameters │ │ ├── Parameter.php │ │ └── BaseParameter.php │ ├── basic │ │ ├── KickAllCommand.php │ │ ├── ClearInventoryCommand.php │ │ ├── AcceptCommand.php │ │ ├── UnBanCommand.php │ │ ├── BanCommand.php │ │ ├── TeleportLevelCommand.php │ │ ├── FlyCommand.php │ │ ├── PlayerInfoCommand.php │ │ ├── DuelCommand.php │ │ ├── SpawnCommand.php │ │ ├── SpectateCommand.php │ │ └── PingCommand.php │ └── advanced │ │ └── DisguiseCommand.php │ ├── kits │ └── KitPvPSettings.php │ ├── duels │ ├── misc │ │ ├── DuelPlayerHit.php │ │ └── DuelSpectator.php │ └── groups │ │ ├── LoadedRequest.php │ │ ├── MatchedGroup.php │ │ └── QueuedPlayer.php │ ├── ranks │ └── Rank.php │ ├── scoreboard │ └── UpdateScoreboardTask.php │ ├── manager │ └── tasks │ │ ├── AddToDatabaseTask.php │ │ └── UpdateEloTask.php │ └── anticheat │ └── AntiCheatUtil.php └── resources ├── mysql.yml ├── config.yml └── ranks.yml /core/.gitignore: -------------------------------------------------------------------------------- 1 | /out -------------------------------------------------------------------------------- /addons/ffa/.gitignore: -------------------------------------------------------------------------------- 1 | /out -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | build.php -------------------------------------------------------------------------------- /addons/basicduels/.gitignore: -------------------------------------------------------------------------------- 1 | /out -------------------------------------------------------------------------------- /core/resources/forms/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /core/resources/items/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /addons/basicduels/resources/forms/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Practice 2 | 3 | Made by jkorn. 4 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jkorn2324/Practice/HEAD/.DS_Store -------------------------------------------------------------------------------- /addons/ffa/plugin.yml: -------------------------------------------------------------------------------- 1 | name: PracticeAddon - FFA 2 | api: ["3.0.0"] 3 | version: "1.0.0" 4 | main: jkorn\ffa\FFAAddon 5 | description: "FFA Addon for Practice - by jkorn2324" 6 | website: "https://github.com/jkorn2324" -------------------------------------------------------------------------------- /core/src/jkorn/practice/misc/ISaved.php: -------------------------------------------------------------------------------- 1 | The host for mysql 4 | host: 'localhost' 5 | 6 | # Username -> The user that has permissions for mysql (usually is root) 7 | username: 'root' 8 | 9 | # Password -> The password to access mysql 10 | # (MUST BE CHANGED TO FIT THE PASSWORD YOU CHOSE WHEN DOWNLOADED) 11 | password: 'password' 12 | 13 | # Database Name -> The name of the database that holds the server data. 14 | database-name: 'practice' 15 | 16 | # The port that the database is on. (Usually 3306) 17 | port: 3306 -------------------------------------------------------------------------------- /addons/basicduels/resources/scoreboards/README.md: -------------------------------------------------------------------------------- 1 | #### FFA Statistics: 2 | These are the statistics that are added if FFA Arenas are enabled. 3 | 4 | These statistics work for any scoreboard: 5 | - `{stat.ffa.players.playing}` - Displays the total number of players playing in FFA. 6 | 7 | These statistics ONLY work if the FFA scoreboard is currently displayed: 8 | - `{stat.ffa.arena.name}` - Displays the current ffa arena the player is playing. 9 | - `{stat.ffa.arena.players.playing}` - Displays the current number of players playing in the arena. 10 | - `{stat.ffa.arena.kit}` - Displays the ffa arena kit. -------------------------------------------------------------------------------- /core/resources/items/items.yml: -------------------------------------------------------------------------------- 1 | # The file that handles the display of the items in the server. 2 | 3 | # The item that displays the play menu. 4 | item.play.games: 5 | item.info: 6 | id: 399 7 | metadata: 0 8 | item.display: 9 | name: "Play Games" 10 | lore: "Tap on this item to open the play ffa menu!" 11 | item.slot: 0 12 | 13 | # The item that opens the player settings. 14 | item.player.settings: 15 | item.info: 16 | id: 345 17 | metadata: 0 18 | item.display: 19 | name: "Player Settings" 20 | lore: "Tap on this item to open your settings!" 21 | item.slot: 1 -------------------------------------------------------------------------------- /core/src/jkorn/practice/player/info/stats/IStatProperty.php: -------------------------------------------------------------------------------- 1 | initPermissions(); 31 | } 32 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/games/player/TeamPlayer.php: -------------------------------------------------------------------------------- 1 | eliminated; 22 | } 23 | 24 | 25 | /** 26 | * Sets the player as eliminated. 27 | */ 28 | public function setEliminated(): void 29 | { 30 | $this->eliminated = true; 31 | } 32 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/games/duels/teams/DuelTeamPlayer.php: -------------------------------------------------------------------------------- 1 | spectator; 24 | } 25 | 26 | /** 27 | * Sets the player as a spectator. 28 | */ 29 | public function setSpectator(): void 30 | { 31 | $this->spectator = true; 32 | } 33 | } -------------------------------------------------------------------------------- /old/src/practice/game/inventory/menus/data/PracHolderData.php: -------------------------------------------------------------------------------- 1 | position = $position; 22 | $this->customName = $name; 23 | } 24 | 25 | public function getPos() : Vector3 { 26 | return $this->position; 27 | } 28 | 29 | public function getCustomName() : string { 30 | return $this->customName; 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /addons/basicduels/src/jkorn/bd/arenas/IDuelArena.php: -------------------------------------------------------------------------------- 1 | player = $p; 24 | } 25 | 26 | 27 | /** 28 | * Actions to execute when run 29 | * 30 | * @param int $currentTick 31 | * 32 | * @return void 33 | */ 34 | public function onRun(int $currentTick) 35 | { 36 | PracticeUtil::respawnPlayer($this->player); 37 | } 38 | } -------------------------------------------------------------------------------- /old/resources/config.yml: -------------------------------------------------------------------------------- 1 | # Determines whether the lobby should be protected (PvP is off, and People won't be able to destroy it. 2 | lobby-protection: true 3 | 4 | # Sets the level of the lobby 5 | lobby-level: "world" 6 | 7 | # Enables tap-to-pearl for PE Players 8 | enable-tap-to-pearl: true 9 | 10 | # Enable tap-to-pot for PE Players 11 | enable-tap-to-pot: true 12 | 13 | # Enable tap-to-rod 14 | enable-tap-to-rod: true 15 | 16 | # Enable enderpearl-cooldown 17 | enable-enderpearl-cooldown: true 18 | 19 | # Enable Hub-FormWindows 20 | enable-hub-formwindows: false 21 | 22 | # Determines whether server ranks are enabled 23 | enable-ranks: false 24 | 25 | # Determines whether chat filter is enabled. 26 | enable-chat-filter: false 27 | 28 | # Determines whether mysql is enabled. 29 | enable-mysql: false -------------------------------------------------------------------------------- /core/src/jkorn/practice/games/misc/managers/IAwaitingGameManager.php: -------------------------------------------------------------------------------- 1 | getGameManager(FFAGameManager::GAME_TYPE); 24 | if($manager instanceof FFAGameManager) 25 | { 26 | return $manager; 27 | } 28 | return null; 29 | } 30 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/games/player/properties/IGamePlayerProperty.php: -------------------------------------------------------------------------------- 1 | player = $player; 24 | $this->arena = $arena; 25 | } 26 | 27 | /** 28 | * Actions to execute when run 29 | * 30 | * @param int $currentTick 31 | * 32 | * @return void 33 | */ 34 | public function onRun(int $currentTick) { 35 | $this->player->teleportToFFA($this->arena); 36 | } 37 | } -------------------------------------------------------------------------------- /old/src/practice/commands/parameters/Parameter.php: -------------------------------------------------------------------------------- 1 | getGameManager(BasicDuelsManager::NAME); 24 | if($manager instanceof BasicDuelsManager) 25 | { 26 | return $manager; 27 | } 28 | return null; 29 | } 30 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/misc/AbstractManager.php: -------------------------------------------------------------------------------- 1 | server = Server::getInstance(); 20 | 21 | $this->load($loadAsync); 22 | } 23 | 24 | /** 25 | * Loads the data needed for the manager. 26 | * 27 | * @param bool $async 28 | */ 29 | abstract protected function load(bool $async = false): void; 30 | 31 | /** 32 | * Saves the data from the manager. 33 | * 34 | * @param bool $async 35 | */ 36 | abstract public function save(bool $async = false): void; 37 | } -------------------------------------------------------------------------------- /old/src/practice/kits/KitPvPSettings.php: -------------------------------------------------------------------------------- 1 | knockback = $kb; 22 | $this->attack_delay = $attack_delay; 23 | } 24 | 25 | public function getAttackDelay() : int { 26 | return $this->attack_delay; 27 | } 28 | 29 | public function getKB() : float { 30 | return $this->knockback; 31 | } 32 | 33 | public function toMap() : array { 34 | return ["kb" => $this->getKB(), "attack-delay" => $this->attack_delay]; 35 | } 36 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/games/duels/DuelPlayer.php: -------------------------------------------------------------------------------- 1 | dead = true; 22 | } 23 | 24 | /** 25 | * @return bool 26 | * 27 | * Determines whether or not the player had already teleported to spawn, 28 | * used to prevent death glitches. 29 | */ 30 | public function isDead(): bool 31 | { 32 | return $this->dead; 33 | } 34 | } -------------------------------------------------------------------------------- /addons/basicduels/src/jkorn/bd/player/BasicDuelPlayer.php: -------------------------------------------------------------------------------- 1 | getServerID()->equals($this->getServerID()); 30 | } 31 | 32 | return false; 33 | } 34 | } -------------------------------------------------------------------------------- /old/src/practice/duels/misc/DuelPlayerHit.php: -------------------------------------------------------------------------------- 1 | tick = $tick; 22 | $this->hitter = $hitter; 23 | } 24 | 25 | public function getHitter() : string { 26 | return $this->hitter; 27 | } 28 | 29 | public function getTick() : int { 30 | return $this->tick; 31 | } 32 | 33 | public function equals($object) : bool { 34 | $result = false; 35 | if($object instanceof DuelPlayerHit) { 36 | $result = $this->tick === $object->getTick(); 37 | } 38 | return $result; 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /old/src/practice/game/SetTimeDayTask.php: -------------------------------------------------------------------------------- 1 | core = $core; 24 | } 25 | 26 | /** 27 | * Actions to execute when run 28 | * 29 | * @param int $currentTick 30 | * 31 | * @return void 32 | */ 33 | public function onRun(int $currentTick) { 34 | 35 | $levels = $this->core->getServer()->getLevels(); 36 | 37 | foreach($levels as $level) { 38 | $level->setTime(6000); 39 | $level->stopTime(); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /old/src/practice/ranks/Rank.php: -------------------------------------------------------------------------------- 1 | localizedName = $local; 23 | $this->name = $name; 24 | } 25 | 26 | public function getLocalizedName() : string { 27 | return $this->localizedName; 28 | } 29 | 30 | public function getName() : string { 31 | return $this->name; 32 | } 33 | 34 | public function equals($object) { 35 | $result = false; 36 | if($object instanceof Rank) 37 | $result = $object->getLocalizedName() === $this->localizedName; 38 | return $result; 39 | } 40 | } -------------------------------------------------------------------------------- /old/src/practice/player/PlayerSpawnTask.php: -------------------------------------------------------------------------------- 1 | player = $player; 25 | } 26 | 27 | /** 28 | * Actions to execute when run 29 | * 30 | * @param int $currentTick 31 | * 32 | * @return void 33 | */ 34 | public function onRun(int $currentTick) 35 | { 36 | PracticeCore::getItemHandler()->spawnHubItems($this->player, true); 37 | ScoreboardUtil::updateSpawnScoreboards($this->player); 38 | } 39 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/misc/PracticeAsyncTask.php: -------------------------------------------------------------------------------- 1 | getPluginManager()->getPlugin("Practice"); 23 | if($plugin instanceof PracticeCore) { 24 | $this->doComplete($server); 25 | } 26 | } 27 | 28 | /** 29 | * Called in the onCompletion function 30 | * & used for tasks running in there. 31 | * 32 | * @param Server $server 33 | */ 34 | abstract protected function doComplete(Server $server): void; 35 | 36 | } -------------------------------------------------------------------------------- /addons/basicduels/src/jkorn/bd/player/team/BasicDuelTeamPlayer.php: -------------------------------------------------------------------------------- 1 | getServerID()->equals($this->getServerID()); 33 | } 34 | 35 | return false; 36 | } 37 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/games/misc/managers/IUpdatedGameManager.php: -------------------------------------------------------------------------------- 1 | getClass(); 25 | return $defaultValue !== null ? new $class($this->getPropertyLocalizedName(), $item, $this->propertyInformation, $defaultValue) : 26 | new $class($this->getPropertyLocalizedName(), $item, $this->propertyInformation); 27 | } 28 | } -------------------------------------------------------------------------------- /addons/basicduels/src/jkorn/bd/messages/BasicDuelsMessageManager.php: -------------------------------------------------------------------------------- 1 | core = $core; 22 | 23 | parent::__construct($core->getResourcesFolder() . "messages", $core->getDataFolder() . "messages"); 24 | } 25 | 26 | /** 27 | * Called when the message manager is registered. 28 | */ 29 | public function onRegister(): void {} 30 | 31 | /** 32 | * @return string 33 | * 34 | * Gets the localized name of the abstract message manager. 35 | */ 36 | public function getLocalizedName(): string 37 | { 38 | return self::NAME; 39 | } 40 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/commands/PracticeCommand.php: -------------------------------------------------------------------------------- 1 | testPermission($sender)) 24 | { 25 | $this->onExecute($sender, $commandLabel, $args); 26 | } 27 | 28 | return true; 29 | } 30 | 31 | /** 32 | * @param CommandSender $sender 33 | * @param string $commandLabel 34 | * @param array $args 35 | * 36 | * Called when the command is executed. 37 | */ 38 | abstract protected function onExecute(CommandSender $sender, string $commandLabel, array $args): void; 39 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/player/ranks/RankManager.php: -------------------------------------------------------------------------------- 1 | ranksDirectory = $core->getDataFolder() . "ranks/"; 20 | 21 | parent::__construct($loadAsync); 22 | } 23 | 24 | /** 25 | * Loads the data needed for the manager. 26 | * 27 | * @param bool $async 28 | */ 29 | protected function load(bool $async = false): void 30 | { 31 | // TODO: Implement load() method. 32 | } 33 | 34 | /** 35 | * Saves the data from the manager. 36 | * 37 | * @param bool $async 38 | */ 39 | public function save(bool $async = false): void 40 | { 41 | // TODO: Implement save() method. 42 | } 43 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/messages/managers/PracticeMessageManager.php: -------------------------------------------------------------------------------- 1 | core = $core; 22 | parent::__construct($core->getResourcesFolder() . "messages", $core->getDataFolder() . "messages"); 23 | } 24 | 25 | /** 26 | * Called when the message manager is registered. 27 | */ 28 | public function onRegister(): void {} 29 | 30 | /** 31 | * @return string 32 | * 33 | * Gets the localized name of the abstract message manager. 34 | */ 35 | public function getLocalizedName(): string 36 | { 37 | return self::NAME; 38 | } 39 | } -------------------------------------------------------------------------------- /old/src/practice/scoreboard/UpdateScoreboardTask.php: -------------------------------------------------------------------------------- 1 | isOnline()) 30 | $this->player = $player; 31 | } 32 | 33 | /** 34 | * Actions to execute when run 35 | * @param int $currentTick; 36 | * @return void 37 | */ 38 | public function onRun(int $currentTick) { 39 | ScoreboardUtil::updateSpawnScoreboards($this->player); 40 | } 41 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/forms/display/FormDisplayText.php: -------------------------------------------------------------------------------- 1 | text = $text; 25 | } 26 | 27 | /** 28 | * @param Player $player 29 | * @param mixed|null $args 30 | * @return string 31 | * 32 | * Gets the converted text. 33 | */ 34 | public function getText(Player $player, $args = null): string 35 | { 36 | $text = $this->text; 37 | 38 | DisplayStatistic::convert($text, $player, $args); 39 | PracticeUtil::convertMessageColors($text); 40 | 41 | return $text; 42 | } 43 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/forms/display/FormDisplay.php: -------------------------------------------------------------------------------- 1 | localizedName = $localizedName; 22 | $this->initData($data); 23 | } 24 | 25 | /** 26 | * @param array $data - The input data. 27 | * Initializes the form data. 28 | */ 29 | abstract protected function initData(array &$data): void; 30 | 31 | /** 32 | * @return string 33 | * 34 | * Gets the form display's localized name. 35 | */ 36 | public function getLocalizedName(): string 37 | { 38 | return $this->localizedName; 39 | } 40 | 41 | abstract public static function decode(string $localized, array $data); 42 | 43 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/scoreboard/display/manager/ScoreboardDisplayManager.php: -------------------------------------------------------------------------------- 1 | core = $core; 21 | 22 | parent::__construct( 23 | $core->getResourcesFolder() . "scoreboards", 24 | $core->getDataFolder() . "scoreboards"); 25 | } 26 | 27 | /** 28 | * Called when the display manager is registered, 29 | * unused in this case. 30 | */ 31 | public function onRegister(): void {} 32 | 33 | /** 34 | * @return string 35 | * 36 | * Gets the localized name of the display manager, used 37 | * to distinguish from each other. 38 | */ 39 | public function getLocalized(): string 40 | { 41 | return self::NAME; 42 | } 43 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/games/misc/gametypes/info/IGameInfo.php: -------------------------------------------------------------------------------- 1 | core = $core; 24 | 25 | parent::__construct($core->getResourcesFolder() . "scoreboards/", $core->getDataFolder() . "scoreboards/"); 26 | } 27 | 28 | /** 29 | * Called when the display manager is registered. 30 | */ 31 | public function onRegister(): void {} 32 | 33 | /** 34 | * @return string 35 | * 36 | * Gets the localized name of the display manager, used 37 | * to distinguish from each other. 38 | */ 39 | public function getLocalized(): string 40 | { 41 | return self::MANAGER_NAME; 42 | } 43 | } -------------------------------------------------------------------------------- /old/src/practice/player/disguise/DisguiseInfo.php: -------------------------------------------------------------------------------- 1 | skin = $skin; 27 | else $this->skin = $this->randomSkin(); 28 | $this->name = $name; 29 | } 30 | 31 | public function getName() : string { 32 | return $this->name; 33 | } 34 | 35 | private function randomSkin() : Skin { 36 | $result = null; 37 | $size = count(Server::getInstance()->getOnlinePlayers()); 38 | if($size > 2) { 39 | foreach(Server::getInstance()->getOnlinePlayers() as $player) { 40 | $skin = $player->getSkin(); 41 | } 42 | } 43 | } 44 | 45 | public function getSkin() { 46 | return $this->skin; 47 | } 48 | } -------------------------------------------------------------------------------- /old/src/practice/player/gameplay/reports/ReportInfo.php: -------------------------------------------------------------------------------- 1 | getResourcesFolder(); 24 | $contents = file($path . "items.txt"); 25 | 26 | $this->textures = []; 27 | 28 | foreach($contents as $content) { 29 | $content = trim($content); 30 | $index = PracticeUtil::str_indexOf(': ', $content); 31 | $itemName = substr($content, 0, $index); 32 | $itemTexture = trim(substr($content, $index + 2)); 33 | $png = PracticeUtil::str_indexOf('.png', $itemTexture); 34 | $itemTexture = trim(substr($itemTexture, 0, $png)); 35 | $this->textures[$itemName] = $itemTexture; 36 | } 37 | } 38 | 39 | public function getTexture(string $item) : string { 40 | $result = "apple"; 41 | if(isset($this->textures[$item])) 42 | $result = $this->textures[$item]; 43 | return 'textures/items/' . $result; 44 | } 45 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/messages/PracticeMessage.php: -------------------------------------------------------------------------------- 1 | localizedName = $localizedName; 24 | $this->rawText = $rawText; 25 | } 26 | 27 | /** 28 | * @return string 29 | * 30 | * Gets the localized name. 31 | */ 32 | public function getLocalizedName(): string 33 | { 34 | return $this->localizedName; 35 | } 36 | 37 | /** 38 | * @param Player $player 39 | * @param mixed|null $args 40 | * @return string 41 | * 42 | * Gets the text from based on the player & arguments. 43 | */ 44 | public function getText(Player $player, $args = null): string 45 | { 46 | $output = $this->rawText; 47 | 48 | PracticeUtil::convertMessageColors($output); 49 | DisplayStatistic::convert($output, $player, $args); 50 | 51 | return $output; 52 | } 53 | } -------------------------------------------------------------------------------- /old/src/practice/duels/groups/LoadedRequest.php: -------------------------------------------------------------------------------- 1 | queue = null; 24 | 25 | $this->player = $player; 26 | 27 | $this->requested = $requested; 28 | } 29 | 30 | public function hasQueue() : bool { 31 | return !is_null($this->queue); 32 | } 33 | 34 | public function setQueue(string $queue) : void { 35 | $this->queue = $queue; 36 | } 37 | 38 | public function getRequestor() : string { 39 | return $this->player; 40 | } 41 | 42 | public function getRequested() : string { 43 | return $this->requested; 44 | } 45 | 46 | public function getQueue() : string { 47 | return $this->queue; 48 | } 49 | 50 | public function equals($object) : bool { 51 | $result = false; 52 | if($object instanceof LoadedRequest) { 53 | $result = $object->getRequested() === $this->requested and $object->getRequestor() === $this->player; 54 | } 55 | return $result; 56 | } 57 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/player/info/stats/StatPropertyInfo.php: -------------------------------------------------------------------------------- 1 | name = $name; 25 | $this->class = $class; 26 | $this->defaultValue = $defaultValue; 27 | $this->saved = $save; 28 | } 29 | 30 | /** 31 | * @return string 32 | * 33 | * Gets the name of the stat property. 34 | */ 35 | public function getName(): string 36 | { 37 | return $this->name; 38 | } 39 | 40 | /** 41 | * @return IStatProperty 42 | * 43 | * Converts the stat 44 | */ 45 | public function convertToInstance(): IStatProperty 46 | { 47 | $class = $this->class; 48 | if($this->defaultValue === null) 49 | { 50 | return new $class($this->name, $this->saved); 51 | } 52 | else 53 | { 54 | return new $class($this->name, $this->saved, $this->defaultValue); 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /old/src/practice/game/inventory/InventoryTask.php: -------------------------------------------------------------------------------- 1 | isPlayerOnline($player)) { 27 | $p = PracticeCore::getPlayerHandler()->getPlayer($player); 28 | $this->player = $p->getPlayerName(); 29 | $this->inventory = $inv; 30 | } 31 | } 32 | 33 | /** 34 | * Actions to execute when run 35 | * 36 | * @param int $tick 37 | * 38 | * @return void 39 | */ 40 | public function onRun(int $tick) { 41 | if(PracticeCore::getPlayerHandler()->isPlayerOnline($this->player)) { 42 | $p = PracticeCore::getPlayerHandler()->getPlayer($this->player); 43 | $this->inventory->onSendInvSuccess($p->getPlayer()); 44 | } else { 45 | $this->inventory->onSendInvFail(Server::getInstance()->getPlayer($this->player)); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/player/misc/PracticePlayerSessionAdapter.php: -------------------------------------------------------------------------------- 1 | server = $server; 33 | $this->player = $player; 34 | } 35 | 36 | /** 37 | * @param NetworkStackLatencyPacket $packet 38 | * @return bool 39 | * 40 | * Called if the packet received is a network stack latency packet. 41 | */ 42 | public function handleNetworkStackLatency(NetworkStackLatencyPacket $packet): bool 43 | { 44 | return $this->player->handleNetworkStackLatency($packet); 45 | } 46 | } -------------------------------------------------------------------------------- /addons/basicduels/src/jkorn/bd/duels/IBasicDuel.php: -------------------------------------------------------------------------------- 1 | core = $core; 26 | $this->server = $core->getServer(); 27 | 28 | $core->getScheduler()->scheduleRepeatingTask($this, 1); 29 | } 30 | 31 | /** 32 | * Actions to execute when run 33 | * 34 | * @param int $currentTick 35 | * @return void 36 | */ 37 | public function onRun(int $currentTick) 38 | { 39 | $this->updateGames(); 40 | 41 | $this->currentTick++; 42 | } 43 | 44 | /** 45 | * Updates all of the games. 46 | */ 47 | private function updateGames(): void 48 | { 49 | $games = PracticeCore::getBaseGameManager()->getGameManagers(); 50 | 51 | foreach($games as $game) 52 | { 53 | if($game instanceof IUpdatedGameManager) 54 | { 55 | $game->update($this->currentTick); 56 | } 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/arenas/PracticeArena.php: -------------------------------------------------------------------------------- 1 | name = $name; 28 | $this->level = $level; 29 | $this->localizedName = strtolower($name); 30 | } 31 | 32 | /** 33 | * @return string 34 | * 35 | * Gets the localized name of the arena. 36 | */ 37 | public function getLocalizedName(): string 38 | { 39 | return $this->localizedName; 40 | } 41 | 42 | /** 43 | * @return string 44 | * 45 | * Gets the name of the practice arena. 46 | */ 47 | public function getName(): string 48 | { 49 | return $this->name; 50 | } 51 | 52 | /** 53 | * @return Level 54 | * 55 | * Gets the level of the arena. 56 | */ 57 | public function getLevel(): Level 58 | { 59 | return $this->level; 60 | } 61 | 62 | abstract public function equals($arena): bool; 63 | } -------------------------------------------------------------------------------- /addons/basicduels/resources/scoreboards/scoreboards.yml: -------------------------------------------------------------------------------- 1 | # The configuration of the scoreboards for the basic duels 2 | # addon. 3 | 4 | # The spawn scoreboard if player is in a basic duel queue. 5 | scoreboard.spawn.queue: 6 | title: "Practice" 7 | lines: 8 | line-1: " Online: {stat.online.players} " 9 | line-2: "" 10 | line-3: " Ping: {stat.player.ping} " 11 | line-4: "" 12 | line-5: " Queue: " 13 | line-6: " {duels.basic.stat.type.player} {duels.basic.stat.kit.player} " 14 | line-7: "" 15 | line-8: " Github @jkorn2324 " 16 | 17 | # The duel 1vs1 scoreboard. 18 | scoreboard.duel.player.1vs1: 19 | title: "Practice" 20 | lines: 21 | line-1: " Opponent: {duels.basic.stat.player.opponent.name} " 22 | line-2: " Duration: {duels.basic.stat.duration} " 23 | line-3: "" 24 | line-4: " Github @jkorn2324 " 25 | 26 | # The team duel scoreboard. 27 | scoreboard.duel.player.teams: 28 | title: "Practice" 29 | lines: 30 | line-1: " Team: {duels.basic.stat.player.team.color} " # TODO Add Team Color Statistic 31 | line-2: " Duration: {duels.basic.stat.duration} " 32 | line-3: "" 33 | line-4: " Github @jkorn2324 " 34 | 35 | # The duel spectator scoreboard. 36 | scoreboard.duel.spectator: 37 | title: "Practice" 38 | lines: 39 | line-1: " Duration: {duels.basic.stat.duration} " 40 | line-2: " Game: {duels.basic.stat.type.player} {duels.basic.stat.kit.player} " 41 | line-3: "" 42 | line-4: " Github @jkorn2324 " -------------------------------------------------------------------------------- /core/src/jkorn/practice/games/misc/leaderboards/IGameLeaderboard.php: -------------------------------------------------------------------------------- 1 | core = $core; 27 | 28 | parent::__construct($core->getResourcesFolder() . "scoreboards/", $core->getDataFolder() . "scoreboards/"); 29 | } 30 | 31 | /** 32 | * Called when the display manager is registered, 33 | * unused here. 34 | */ 35 | public function onRegister(): void {} 36 | 37 | /** 38 | * @return string 39 | * 40 | * Gets the localized name of the display manager, used 41 | * to distinguish from each other. 42 | */ 43 | public function getLocalized(): string 44 | { 45 | return self::NAME; 46 | } 47 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/level/gen/PracticeGeneratorInfo.php: -------------------------------------------------------------------------------- 1 | class = $class; 25 | $this->generatorName = $generatorName; 26 | $this->extraData = new \stdClass(); 27 | } 28 | 29 | /** 30 | * @return string 31 | * 32 | * Gets the generator name. 33 | */ 34 | public function getName(): string 35 | { 36 | return $this->generatorName; 37 | } 38 | 39 | /** 40 | * @return string 41 | * 42 | * Gets the class of the generator information. 43 | */ 44 | public function getClass(): string 45 | { 46 | return $this->class; 47 | } 48 | 49 | 50 | /** 51 | * @return stdClass 52 | * 53 | * Gets the extra data of the generator, extracted from the generator class. 54 | */ 55 | public function getExtraData(): stdClass 56 | { 57 | return $this->extraData; 58 | } 59 | 60 | 61 | /** 62 | * Extracts the data from the generator class. 63 | */ 64 | abstract public function extract(): void; 65 | } -------------------------------------------------------------------------------- /old/src/practice/manager/tasks/AddToDatabaseTask.php: -------------------------------------------------------------------------------- 1 | player = $player; 33 | $this->sql = PracticeCore::getMysqlHandler(); 34 | $this->username = $this->sql->getUsername(); 35 | $this->host = $this->sql->getHost(); 36 | $this->pass = $this->sql->getPassword(); 37 | $this->port = $this->sql->getPort(); 38 | $this->database = $this->sql->getDatabaseName(); 39 | } 40 | 41 | /** 42 | * Actions to execute when run 43 | * 44 | * @return void 45 | */ 46 | public function onRun() 47 | { 48 | $sql = new \mysqli($this->host, $this->username, $this->pass, $this->database, $this->port); 49 | 50 | $this->sql->addPlayerToDatabase($this->player, $sql); 51 | } 52 | 53 | public function onCompletion(Server $server) 54 | { 55 | parent::onCompletion($server); 56 | } 57 | } -------------------------------------------------------------------------------- /addons/ffa/src/jkorn/ffa/FFAAddon.php: -------------------------------------------------------------------------------- 1 | registerGameManager( 27 | new FFAGameManager($this) 28 | ); 29 | } 30 | 31 | /** 32 | * @return string 33 | * 34 | * Gets the resources folder. 35 | */ 36 | public function getResourcesFolder(): string 37 | { 38 | return $this->getFile() . "resources/"; 39 | } 40 | 41 | /** 42 | * @param string...$dependencies 43 | * @return bool 44 | * 45 | * Checks the dependencies of various plugins. 46 | */ 47 | private static function checkDependencies(string...$dependencies): bool { 48 | 49 | $server = Server::getInstance(); 50 | foreach($dependencies as $dependency) { 51 | $plugin = $server->getPluginManager()->getPlugin($dependency); 52 | if($plugin === null) { 53 | return false; 54 | } 55 | } 56 | return true; 57 | } 58 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/data/providers/EmptyDataProvider.php: -------------------------------------------------------------------------------- 1 | localizedName = $name; 33 | $this->slot = $slot; 34 | $this->item = $item; 35 | $this->itemName = $item->getName(); 36 | $this->onlyExecuteInLobby = $exec; 37 | $this->texture = $texture; 38 | } 39 | 40 | public function getTexture() : string { 41 | return $this->texture; 42 | } 43 | 44 | public function setItem(Item $item) : self { 45 | $this->item = $item; 46 | $this->itemName = $item->getName(); 47 | return $this; 48 | } 49 | 50 | public function canOnlyUseInLobby() : bool { 51 | return $this->onlyExecuteInLobby; 52 | } 53 | 54 | public function getItem() : Item { 55 | return $this->item; 56 | } 57 | 58 | public function getName() : string { 59 | return $this->itemName; 60 | } 61 | 62 | public function getLocalizedName() : string { 63 | return $this->localizedName; 64 | } 65 | 66 | public function getSlot() : int { 67 | return $this->slot; 68 | } 69 | } -------------------------------------------------------------------------------- /addons/basicduels/src/jkorn/bd/duels/leaderboard/WLRatioGroup.php: -------------------------------------------------------------------------------- 1 | wins = $kills; 29 | $this->losses = $deaths; 30 | } 31 | 32 | /** 33 | * @param array $data 34 | * 35 | * Updates the group based on the data, however in this case 36 | * we don't use the data input and we instead loop through wins 37 | * and losses and update based on that. 38 | */ 39 | public function update(&$data = []): void 40 | { 41 | // TODO: See if this causes lots of memory issues, try find a more efficient way of doing this. 42 | $killsLeaderboard = $this->wins->leaderboard; 43 | 44 | foreach($killsLeaderboard as $player => $wins) 45 | { 46 | $losses = $this->losses->leaderboard[$player]; 47 | if($losses <= 0) 48 | { 49 | $losses = 1; 50 | } 51 | 52 | $this->leaderboard[$player] = (float)$wins / (float)$losses; 53 | } 54 | 55 | asort($this->leaderboard); 56 | } 57 | } -------------------------------------------------------------------------------- /old/resources/ranks.yml: -------------------------------------------------------------------------------- 1 | # Chat format for players with a rank. -> must have %formatted-ranks%, %player-name%, and %msg% 2 | chat-format: "[%formatted-ranks%] %player-name% -> %msg%" 3 | 4 | # The format for a player name tag. -> can have %formatted-ranks%, %player-name%, and %hp% 5 | nametag-format: "[%formatted-ranks%] %player-name% [%hp%]" 6 | 7 | # The formats for the ranks. 8 | format: 9 | # The guest format. 10 | guest: 11 | # The guest rank format. 12 | rank: "Guest" 13 | # The guest playerName format. 14 | p-name: "%player%" 15 | # The builder format. 16 | builder: 17 | # The builder rank format. 18 | rank: "Builder" 19 | # The builder playerName format. 20 | p-name: "%player%" 21 | # The youtube format. 22 | youtube: 23 | # The youtube rank format. 24 | rank: "YouTube" 25 | # The youtube playerName format. 26 | p-name: "%player%" 27 | # The famous format. 28 | famous: 29 | # The famous rank format. 30 | rank: "Famous" 31 | # The famous playerName format. 32 | p-name: "%player%" 33 | # The admin format. 34 | admin: 35 | # The admin rank format. 36 | rank: "Admin" 37 | # The admin playerName format. 38 | p-name: "%player%" 39 | # The moderator format. 40 | mod: 41 | # The moderator rank format. 42 | rank: "Moderator" 43 | # The moderator playerName format. 44 | p-name: "%player%" 45 | # The Developer format. 46 | dev: 47 | # The developer rank format. 48 | rank: "Dev" 49 | # The developer playerName format. 50 | p-name: "%player%" 51 | # The owner format. 52 | owner: 53 | # The owner rank format. 54 | rank: "Owner" 55 | # The owner playerName format. 56 | p-name: "%player%" -------------------------------------------------------------------------------- /core/src/jkorn/practice/display/DisplayStatisticNames.php: -------------------------------------------------------------------------------- 1 | localized = $localized; 23 | $this->value = $value; 24 | $this->display = $display; 25 | } 26 | 27 | /** 28 | * @return string 29 | * 30 | * Gets the localized name of the setting. 31 | */ 32 | public function getLocalized(): string 33 | { 34 | return $this->localized; 35 | } 36 | 37 | /** 38 | * @return int 39 | * 40 | * Gets the value of the setting. 41 | */ 42 | public function getValue() 43 | { 44 | return $this->value; 45 | } 46 | 47 | /** 48 | * @param int $value 49 | * @return bool - Determines if value was changed. 50 | * 51 | * Sets the value of the setting. 52 | */ 53 | public function setValue($value): bool 54 | { 55 | $oldValue = $this->value; 56 | $this->value = $value; 57 | return $oldValue !== $value; 58 | } 59 | 60 | /** 61 | * @return string 62 | * 63 | * Gets the display from the option. 64 | */ 65 | public function getDisplay(): string 66 | { 67 | // TODO: Implement getDisplay() method. 68 | return ""; 69 | } 70 | } -------------------------------------------------------------------------------- /old/src/practice/commands/parameters/BaseParameter.php: -------------------------------------------------------------------------------- 1 | name = $name; 33 | $this->description = $desc; 34 | if($hasPerm and $basePermission !== Parameter::NO_PERMISSION){ 35 | $this->permission = "$basePermission." . $this->getName(); 36 | } else { 37 | $this->permission = Parameter::NO_PERMISSION; 38 | } 39 | } 40 | 41 | /** 42 | * @return bool 43 | */ 44 | public function hasPermission() : bool 45 | { 46 | return $this->permission != null and $this->permission !== Parameter::NO_PERMISSION; 47 | } 48 | 49 | /** 50 | * @return |null 51 | */ 52 | public function getPermission() : string { 53 | return $this->permission; 54 | } 55 | 56 | /** 57 | * @return string 58 | */ 59 | public function getDescription() : string { 60 | return $this->description; 61 | } 62 | 63 | /** 64 | * @return string 65 | */ 66 | public function getName(): string 67 | { 68 | return $this->name; 69 | } 70 | 71 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/player/info/ClicksInfo.php: -------------------------------------------------------------------------------- 1 | clicks = []; 19 | } 20 | 21 | /** 22 | * Updates the array clicks. 23 | */ 24 | public function update(): void 25 | { 26 | $currentMillis = (int)round(microtime(true) * 1000); 27 | foreach($this->clicks as $millis => $value) 28 | { 29 | $difference = $currentMillis - $millis; 30 | // Determines if the difference is greater than 1 second. 31 | if($difference >= 1000) 32 | { 33 | unset($this->clicks[$millis]); 34 | } 35 | } 36 | } 37 | 38 | /** 39 | * @param bool $clickedBlock 40 | * 41 | * Adds a click to the clicks information based on previous actions. 42 | */ 43 | public function addClick(bool $clickedBlock): void 44 | { 45 | $currentMillis = (int)round(microtime(true) * 1000); 46 | $this->clicks[$currentMillis] = $clickedBlock; 47 | } 48 | 49 | /** 50 | * @return int 51 | * 52 | * Gets the cps of the player. 53 | */ 54 | public function getCps(): int 55 | { 56 | $this->lastCPS = count($this->clicks); 57 | $this->update(); 58 | return count($this->clicks); 59 | } 60 | 61 | /** 62 | * @return int 63 | * 64 | * Gets the last cps of the player. 65 | */ 66 | public function getLastCPS(): int 67 | { 68 | return $this->lastCPS; 69 | } 70 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/player/info/settings/properties/FloatSettingProperty.php: -------------------------------------------------------------------------------- 1 | localized = $localized; 23 | $this->value = $value; 24 | $this->display = $display; 25 | } 26 | 27 | /** 28 | * @return string 29 | * 30 | * Gets the localized name of the setting. 31 | */ 32 | public function getLocalized(): string 33 | { 34 | return $this->localized; 35 | } 36 | 37 | /** 38 | * @return float 39 | * 40 | * Gets the value of the setting. 41 | */ 42 | public function getValue() 43 | { 44 | return $this->value; 45 | } 46 | 47 | /** 48 | * @param float $value 49 | * @return bool - Determines if value was changed. 50 | * 51 | * Sets the value of the setting. 52 | */ 53 | public function setValue($value): bool 54 | { 55 | $oldValue = $this->value; 56 | $this->value = $value; 57 | return $oldValue !== $value; 58 | } 59 | 60 | /** 61 | * @return string 62 | * 63 | * Gets the display from the option. 64 | */ 65 | public function getDisplay(): string 66 | { 67 | // TODO: Implement getDisplay() method. 68 | return ""; 69 | } 70 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/player/info/settings/properties/StringSettingProperty.php: -------------------------------------------------------------------------------- 1 | localized = $localized; 23 | $this->value = $value; 24 | $this->display = $display; 25 | } 26 | 27 | /** 28 | * @return string 29 | * 30 | * Gets the localized name of the setting. 31 | */ 32 | public function getLocalized(): string 33 | { 34 | return $this->localized; 35 | } 36 | 37 | /** 38 | * @return string 39 | * 40 | * Gets the value of the setting. 41 | */ 42 | public function getValue() 43 | { 44 | return $this->value; 45 | } 46 | 47 | /** 48 | * @param string $value 49 | * @return bool - Determines if value was changed. 50 | * 51 | * Sets the value of the setting. 52 | */ 53 | public function setValue($value): bool 54 | { 55 | $oldValue = $this->value; 56 | $this->value = $oldValue; 57 | return $oldValue !== $value; 58 | } 59 | 60 | /** 61 | * @return string 62 | * 63 | * Gets the display from the option. 64 | */ 65 | public function getDisplay(): string 66 | { 67 | // TODO: Implement getDisplay() method. 68 | return ""; 69 | } 70 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/games/duels/AbstractQueue.php: -------------------------------------------------------------------------------- 1 | kit = $kit instanceof IKit ? $kit : null; 29 | $this->player = $player; 30 | } 31 | 32 | /** 33 | * @return bool - Return true if the queue is a valid 34 | * queue, false otherwise. 35 | * 36 | * Determines whether the queue information is 37 | * valid, helps determines whether or not we should 38 | * remove the player. 39 | */ 40 | abstract public function validate(): bool; 41 | 42 | /** 43 | * @param AbstractQueue $queue - Address to the queue, saves memory. 44 | * @return bool 45 | * 46 | * Determines whether or not the input queue is a match. 47 | */ 48 | abstract public function isMatching(AbstractQueue &$queue): bool; 49 | 50 | /** 51 | * @return IKit|null 52 | * 53 | * Gets the kit of the queue. 54 | */ 55 | public function getKit(): ?IKit 56 | { 57 | return $this->kit; 58 | } 59 | 60 | /** 61 | * @return PracticePlayer 62 | * 63 | * Gets the player from the queue. 64 | */ 65 | public function getPlayer(): PracticePlayer 66 | { 67 | return $this->player; 68 | } 69 | } -------------------------------------------------------------------------------- /addons/basicduels/src/jkorn/bd/messages/BasicDuelsMessages.php: -------------------------------------------------------------------------------- 1 | winner = $winner; 37 | $this->loser = $loser; 38 | $this->winnerElo = $winnerElo; 39 | $this->loserElo = $loserElo; 40 | 41 | $this->queue = $queue; 42 | 43 | $this->sql = PracticeCore::getMysqlHandler(); 44 | $this->username = $this->sql->getUsername(); 45 | $this->host = $this->sql->getHost(); 46 | $this->pass = $this->sql->getPassword(); 47 | $this->port = $this->sql->getPort(); 48 | $this->database = $this->sql->getDatabaseName(); 49 | } 50 | 51 | 52 | /** 53 | * Actions to execute when run 54 | * 55 | * @return void 56 | */ 57 | public function onRun() 58 | { 59 | 60 | $sql = new \mysqli($this->host, $this->username, $this->pass, $this->database, $this->port); 61 | 62 | $this->sql->setElo($sql, $this->winner, $this->queue, $this->winnerElo); 63 | $this->sql->setElo($sql, $this->loser, $this->queue, $this->loserElo); 64 | } 65 | } -------------------------------------------------------------------------------- /old/src/practice/game/inventory/menus/BaseMenu.php: -------------------------------------------------------------------------------- 1 | inv = $inv; 29 | $this->edit = true; 30 | $this->name = $inv->getName(); 31 | } 32 | 33 | public function getInventory() : PracBaseInv { 34 | return $this->inv; 35 | } 36 | 37 | public function setName(string $name) : BaseMenu { 38 | $this->name = $name; 39 | return $this; 40 | } 41 | 42 | public function getName() : string { 43 | return $this->name; 44 | } 45 | 46 | public function setEdit(bool $edit) : BaseMenu { 47 | $this->edit = $edit; 48 | return $this; 49 | } 50 | 51 | public function canEdit() : bool { 52 | return $this->edit; 53 | } 54 | 55 | public function send(Player $player, ?string $customName = null) : bool { 56 | return $this->getInventory()->send($player, ($customName !== null ? $customName : $this->getName())); 57 | } 58 | 59 | abstract public function onItemMoved(PracticePlayer $p, SlotChangeAction $action) : void; 60 | 61 | abstract public function onInventoryClosed(Player $player) : void; 62 | 63 | abstract public function sendTo($player) : void; 64 | 65 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/player/info/DisguiseInfo.php: -------------------------------------------------------------------------------- 1 | name = $newName ?? ""; 31 | // TODO: Generate skin data. 32 | $this->skinData = null; 33 | 34 | $this->oldSkin = $skin; 35 | $this->oldName = $oldName; 36 | } 37 | 38 | /** 39 | * @return Skin 40 | * 41 | * Gets the skin from skin data. 42 | */ 43 | public function getSkin(): Skin 44 | { 45 | return SkinAdapterSingleton::get()->fromSkinData($this->skinData); 46 | } 47 | 48 | /** 49 | * @return string 50 | * 51 | * Gets the name of the disguise. 52 | */ 53 | public function getName(): string 54 | { 55 | return $this->name; 56 | } 57 | 58 | /** 59 | * @return string 60 | * 61 | * Gets the old name of the player. 62 | */ 63 | public function getOldName(): string 64 | { 65 | return $this->oldName; 66 | } 67 | 68 | /** 69 | * @return Skin 70 | * 71 | * Gets the old skin of the player. 72 | */ 73 | public function getOldSkin(): Skin 74 | { 75 | return $this->oldSkin; 76 | } 77 | } -------------------------------------------------------------------------------- /addons/basicduels/src/jkorn/bd/BasicDuels.php: -------------------------------------------------------------------------------- 1 | registerGameManager( 27 | new BasicDuelsManager($this) 28 | ); 29 | 30 | PracticeCore::getBaseScoreboardDisplayManager()->registerScoreboardManager( 31 | new BasicDuelsScoreboardManager($this), 32 | true 33 | ); 34 | } 35 | 36 | /** 37 | * @param string ...$dependencies 38 | * @return bool 39 | * 40 | * Checks the dependencies of various plugins. 41 | */ 42 | private static function checkDependencies(string...$dependencies): bool { 43 | 44 | $server = Server::getInstance(); 45 | foreach($dependencies as $dependency) { 46 | $plugin = $server->getPluginManager()->getPlugin($dependency); 47 | if($plugin === null) { 48 | return false; 49 | } 50 | } 51 | return true; 52 | } 53 | 54 | /** 55 | * @return string 56 | * 57 | * Gets the resources folder. 58 | */ 59 | public function getResourcesFolder(): string 60 | { 61 | return $this->getFile() . "resources/"; 62 | } 63 | } -------------------------------------------------------------------------------- /old/src/practice/game/effects/PracticeEffect.php: -------------------------------------------------------------------------------- 1 | effect = $effect; 28 | $this->duration = $duration; 29 | $this->amplifier = $amp; 30 | } 31 | 32 | public function getEffect() : Effect { 33 | return $this->effect; 34 | } 35 | 36 | public function getDuration() : int { 37 | return $this->duration; 38 | } 39 | 40 | public function getAmplifier() : int { 41 | return $this->amplifier; 42 | } 43 | 44 | public function applyTo($player) : void { 45 | if($player instanceof Player){ 46 | $effect = new EffectInstance($this->effect, $this->duration * 20, $this->amplifier); 47 | $player->addEffect($effect); 48 | } 49 | } 50 | 51 | public function toString() : string { 52 | $id = $this->effect->getId(); 53 | $str = $id . ":" . $this->amplifier . ":" . $this->duration; 54 | return $str; 55 | } 56 | 57 | public static function getEffectFrom(string $line) : PracticeEffect { 58 | $split = explode(":", $line); 59 | $id = intval($split[0]); 60 | $amp = intval($split[1]); 61 | $duration = intval($split[2]); 62 | $effect = Effect::getEffect($id); 63 | return new PracticeEffect($effect, $duration, $amp); 64 | } 65 | } -------------------------------------------------------------------------------- /old/src/practice/game/inventory/menus/LeaderboardMenu.php: -------------------------------------------------------------------------------- 1 | setName(PracticeUtil::getName('title-leaderboard-inv')); 30 | 31 | $this->setEdit(false); 32 | 33 | $items = PracticeCore::getItemHandler()->getLeaderboardItems(); 34 | 35 | foreach($items as $item) { 36 | if($item instanceof PracticeItem) { 37 | $slot = $item->getSlot(); 38 | $i = $item->getItem(); 39 | $this->getInventory()->setItem($slot, $i); 40 | } 41 | } 42 | } 43 | 44 | public function onItemMoved(PracticePlayer $p, SlotChangeAction $action): void {} 45 | 46 | public function onInventoryClosed(Player $player): void { 47 | PracticeCore::getPlayerHandler()->setOpenInventoryID($player); 48 | } 49 | 50 | public function sendTo($player): void { 51 | if(PracticeCore::getPlayerHandler()->isPlayerOnline($player)) { 52 | $p = PracticeCore::getPlayerHandler()->getPlayer($player); 53 | $pl = $p->getPlayer(); 54 | $this->send($pl); 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/games/misc/gametypes/IGame.php: -------------------------------------------------------------------------------- 1 | type = $type; 29 | } 30 | 31 | /** 32 | * @return string 33 | * 34 | * Gets the type of duel this generator is for. 35 | */ 36 | public function getType(): string 37 | { 38 | return $this->type; 39 | } 40 | 41 | /** 42 | * Extracts the data from the generator class. 43 | */ 44 | public function extract(): void 45 | { 46 | try { 47 | 48 | $reflectionClass = new \ReflectionClass($this->class); 49 | $method = $reflectionClass->getMethod("extractData"); 50 | $extraData = $method->invokeArgs(null, []); 51 | if($extraData instanceof \stdClass) 52 | { 53 | $this->extraData = $extraData; 54 | 55 | // Saves the generator name to the info. 56 | if(isset($this->extraData->generatorName)) 57 | { 58 | $this->generatorName = $this->extraData->generatorName; 59 | } 60 | } 61 | 62 | } catch (\Exception $e) { 63 | // TODO: Print stack. 64 | return; 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/commands/ManageKitsCommand.php: -------------------------------------------------------------------------------- 1 | display($sender); 36 | } 37 | else 38 | { 39 | // TODO: Send error message. 40 | } 41 | } 42 | 43 | /** 44 | * @param CommandSender $target 45 | * @return bool 46 | * 47 | * Test the permission. 48 | */ 49 | public function testPermission(CommandSender $target): bool 50 | { 51 | if(!$target instanceof Player) 52 | { 53 | // TODO: Console message. 54 | return false; 55 | } 56 | 57 | // Checks if the player has the permission first. 58 | if(!parent::testPermission($target)) 59 | { 60 | return false; 61 | } 62 | 63 | return true; 64 | } 65 | } -------------------------------------------------------------------------------- /old/src/practice/arenas/FFAArena.php: -------------------------------------------------------------------------------- 1 | kits = [$kits]; 27 | } elseif ($kits instanceof Kit) { 28 | $this->kits = [$kits->getName()]; 29 | } 30 | } 31 | } 32 | 33 | public function toMap(): array 34 | { 35 | $result = []; 36 | 37 | $result["build"] = $this->canBuild(); 38 | $result["spawn"] = PracticeUtil::getPositionToMap($this->getSpawnPosition()); 39 | $result["level"] = $this->level->getFolderName(); 40 | 41 | $kit = null; 42 | 43 | $size = count($this->kits); 44 | 45 | if($size > 0) { 46 | $k = $this->kits[0]; 47 | if(is_string($k)){ 48 | if(PracticeCore::getKitHandler()->isKit($k)){ 49 | $kit = $k; 50 | } else { 51 | $kit = Kit::NO_KIT; 52 | } 53 | } elseif ($k instanceof Kit) { 54 | $kit = $k->getName(); 55 | } 56 | } else { 57 | $kit = Kit::NO_KIT; 58 | } 59 | 60 | if(!is_null($kit)) { 61 | $result["kit"] = $kit; 62 | } 63 | 64 | return $result; 65 | } 66 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/player/info/settings/properties/BooleanSettingProperty.php: -------------------------------------------------------------------------------- 1 | localized = $settingLocalized; 23 | $this->value = $value; 24 | $this->display = $display; 25 | } 26 | 27 | /** 28 | * @return bool 29 | * 30 | * Gets the value of the setting. 31 | */ 32 | public function getValue() 33 | { 34 | return $this->value; 35 | } 36 | 37 | /** 38 | * @param bool $value 39 | * @return bool - Determine if the value changed. 40 | * 41 | * Sets the value of the setting. 42 | */ 43 | public function setValue($value): bool 44 | { 45 | $oldValue = $this->value; 46 | $this->value = (bool)$value; 47 | return $oldValue !== $value; 48 | } 49 | 50 | /** 51 | * @return string 52 | * 53 | * Gets the localized name of the setting. 54 | */ 55 | public function getLocalized(): string 56 | { 57 | return $this->localized; 58 | } 59 | 60 | /** 61 | * @return string 62 | * 63 | * Gets the display from the option. 64 | */ 65 | public function getDisplay(): string 66 | { 67 | if($this->value) 68 | { 69 | return $this->display["disabled"]; 70 | } 71 | return $this->display["enabled"]; 72 | } 73 | } -------------------------------------------------------------------------------- /old/src/practice/commands/basic/KickAllCommand.php: -------------------------------------------------------------------------------- 1 | getPermission())) { 41 | foreach(Server::getInstance()->getOnlinePlayers() as $player) { 42 | $exec = true; 43 | if($sender instanceof Player) { 44 | if($player->getName() === $sender->getName()) { 45 | $exec = false; 46 | } 47 | } 48 | 49 | if($exec) { 50 | $player->kick(PracticeUtil::getMessage("kick-all-message")); 51 | } 52 | } 53 | } 54 | } 55 | 56 | if(!is_null($msg)) $sender->sendMessage($msg); 57 | return true; 58 | } 59 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/commands/ManageArenasCommand.php: -------------------------------------------------------------------------------- 1 | display($sender); 40 | } 41 | else 42 | { 43 | // TODO: Send error message. 44 | } 45 | } 46 | 47 | /** 48 | * @param CommandSender $target 49 | * @return bool 50 | * 51 | * Test the permission. 52 | */ 53 | public function testPermission(CommandSender $target): bool 54 | { 55 | if(!$target instanceof Player) 56 | { 57 | // TODO: Console message. 58 | return false; 59 | } 60 | 61 | // Checks if the player has the permission first. 62 | if(!parent::testPermission($target)) 63 | { 64 | return false; 65 | } 66 | 67 | return true; 68 | } 69 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/player/info/stats/properties/IntegerStatProperty.php: -------------------------------------------------------------------------------- 1 | localized = $localized; 24 | $this->value = $default; 25 | $this->saved = $saved; 26 | } 27 | 28 | /** 29 | * @return string 30 | * 31 | * Gets the localized name of the property. 32 | */ 33 | public function getLocalized(): string 34 | { 35 | return $this->localized; 36 | } 37 | 38 | /** 39 | * @return int 40 | * 41 | * Gets the value of the player property. 42 | */ 43 | public function getValue() 44 | { 45 | return $this->value; 46 | } 47 | 48 | /** 49 | * @param $value 50 | * @return bool 51 | * 52 | * Sets the value of the player property. 53 | */ 54 | public function setValue($value): bool 55 | { 56 | $oldValue = $this->value; 57 | $this->value = $value; 58 | return $oldValue !== $value; 59 | } 60 | 61 | /** 62 | * @return bool 63 | * 64 | * Determines whether or not we want to save this statistic. 65 | */ 66 | public function doSave(): bool 67 | { 68 | return $this->saved; 69 | } 70 | 71 | /** 72 | * @param bool $save 73 | * 74 | * Sets whether or not the statistic should be saved. 75 | */ 76 | public function setSave(bool $save): void 77 | { 78 | $this->saved = $save; 79 | } 80 | } -------------------------------------------------------------------------------- /old/src/practice/commands/basic/ClearInventoryCommand.php: -------------------------------------------------------------------------------- 1 | getPermission())){ 42 | $player = PracticeCore::getPlayerHandler()->getPlayer($sender->getName()); 43 | $len = count($args); 44 | if($len === 0){ 45 | $player->getPlayer()->getInventory()->clearAll(); 46 | $player->getPlayer()->getArmorInventory()->clearAll(); 47 | $msg = PracticeUtil::getMessage("general.clear-inv.success-direct"); 48 | } else { 49 | $msg = $this->getUsage(); 50 | } 51 | } 52 | } 53 | 54 | if(!is_null($msg)) $sender->sendMessage($msg); 55 | 56 | return true; 57 | } 58 | } -------------------------------------------------------------------------------- /addons/ffa/src/jkorn/ffa/forms/FFAFormManager.php: -------------------------------------------------------------------------------- 1 | core = $core; 37 | 38 | parent::__construct($core->getResourcesFolder() . "forms/", $core->getDataFolder() . "forms/"); 39 | } 40 | 41 | /** 42 | * @return string 43 | * 44 | * Gets the localized name of the form display manager. 45 | */ 46 | public function getLocalizedName(): string 47 | { 48 | return self::LOCALIZED_NAME; 49 | } 50 | 51 | /** 52 | * Initializes the internal forms to the display manager. 53 | */ 54 | protected function initInternalForms(): void 55 | { 56 | InternalForm::registerForm(new FFAArenaSelector(), true); 57 | InternalForm::registerForm(new FFAArenaMenu(), true); 58 | InternalForm::registerForm(new EditFFAArena(), true); 59 | InternalForm::registerForm(new CreateFFAArena(), true); 60 | InternalForm::registerForm(new DeleteFFAArena(), true); 61 | } 62 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/player/info/stats/properties/FloatStatProperty.php: -------------------------------------------------------------------------------- 1 | localized = $localized; 24 | $this->value = $default; 25 | $this->saved = $saved; 26 | } 27 | 28 | /** 29 | * @return string 30 | * 31 | * Gets the localized name of the property. 32 | */ 33 | public function getLocalized(): string 34 | { 35 | return $this->localized; 36 | } 37 | 38 | /** 39 | * @return mixed 40 | * 41 | * Gets the value of the player property. 42 | */ 43 | public function getValue() 44 | { 45 | return $this->value; 46 | } 47 | 48 | /** 49 | * @param float $value 50 | * @return bool 51 | * 52 | * Sets the value of the player property. 53 | */ 54 | public function setValue($value): bool 55 | { 56 | $oldValue = $this->value; 57 | $this->value = $value; 58 | return $oldValue !== $value; 59 | } 60 | 61 | /** 62 | * @return bool 63 | * 64 | * Determines whether or not we want to save this statistic. 65 | */ 66 | public function doSave(): bool 67 | { 68 | return $this->saved; 69 | } 70 | 71 | /** 72 | * @param bool $save 73 | * 74 | * Sets whether or not the statistic should be saved. 75 | */ 76 | public function setSave(bool $save): void 77 | { 78 | $this->saved = $save; 79 | } 80 | } -------------------------------------------------------------------------------- /old/src/practice/commands/basic/AcceptCommand.php: -------------------------------------------------------------------------------- 1 | getPermission())) { 45 | $p = PracticeCore::getPlayerHandler()->getPlayer($sender->getPlayer()); 46 | $count = count($args); 47 | if ($count === 1) { 48 | if (PracticeUtil::canAcceptPlayer($sender->getPlayer(), strval($args[0]))) 49 | PracticeCore::get1vs1Handler()->acceptRequest($sender->getPlayer(), strval($args[0])); 50 | } else $msg = $this->getUsage(); 51 | } 52 | } else $msg = PracticeUtil::getMessage("console-usage-command"); 53 | 54 | if (!is_null($msg)) $sender->sendMessage($msg); 55 | 56 | return true; 57 | } 58 | } -------------------------------------------------------------------------------- /addons/basicduels/src/jkorn/bd/forms/BasicDuelsFormManager.php: -------------------------------------------------------------------------------- 1 | core = $core; 33 | 34 | parent::__construct($core->getResourcesFolder() . "forms", $core->getDataFolder() . "forms"); 35 | } 36 | 37 | /** 38 | * @return string 39 | * 40 | * Gets the localized name of the form display manager. 41 | */ 42 | public function getLocalizedName(): string 43 | { 44 | return self::NAME; 45 | } 46 | 47 | /** 48 | * Initializes the internal forms to the display manager. 49 | */ 50 | protected function initInternalForms(): void 51 | { 52 | InternalForm::registerForm(new BasicDuelArenaMenu(), true); 53 | InternalForm::registerForm(new BasicDuelArenaSelector(), true); 54 | InternalForm::registerForm(new EditBasicDuelArenaMenu(), true); 55 | InternalForm::registerForm(new EditBasicDuelArenaVisibility(), true); 56 | InternalForm::registerForm(new EditBasicDuelArenaArea(), true); 57 | } 58 | } -------------------------------------------------------------------------------- /old/src/practice/commands/basic/UnBanCommand.php: -------------------------------------------------------------------------------- 1 | getPermission())) { 43 | 44 | $count = count($args); 45 | $sendUsage = true; 46 | 47 | if($count === 1) { 48 | 49 | $player = strval($args[0]); 50 | 51 | $sendUsage = false; 52 | 53 | //TODO CHECK IF PLAYER IS BANNED AND IF SO UNBAN PLAYER 54 | /*$form = FormUtil::getBanForm($player, $bool); 55 | $p->sendForm($form, ['permanently' => $bool]);*/ 56 | } 57 | 58 | if($sendUsage === true) $msg = $this->getUsage(); 59 | } 60 | 61 | if(!is_null($msg)) $sender->sendMessage($msg); 62 | 63 | return true; 64 | } 65 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/games/misc/managers/awaiting/IAwaitingManager.php: -------------------------------------------------------------------------------- 1 | getPermission())) { 41 | 42 | $p = PracticeCore::getPlayerHandler()->getPlayer($sender->getName()); 43 | 44 | $count = count($args); 45 | $sendUsage = true; 46 | 47 | if($count === 2) { 48 | 49 | $player = strval($args[0]); 50 | $bool = $args[1]; 51 | 52 | if(is_bool($bool)){ 53 | $sendUsage = false; 54 | $form = FormUtil::getBanForm($player, $bool); 55 | $p->sendForm($form, ['permanently' => $bool]); 56 | } 57 | } 58 | 59 | if($sendUsage === true) $msg = $this->getUsage(); 60 | } 61 | 62 | if(!is_null($msg)) $sender->sendMessage($msg); 63 | 64 | return true; 65 | } 66 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/level/SpawnArea.php: -------------------------------------------------------------------------------- 1 | spawnPosition = $spawnPosition; 20 | } 21 | 22 | /** 23 | * @return Vector3 24 | * 25 | * Gets the spawn position. 26 | */ 27 | public function getSpawn(): Vector3 28 | { 29 | return $this->spawnPosition; 30 | } 31 | 32 | /** 33 | * @param Vector3 $vector3 34 | * 35 | * Sets the spawn of the area. 36 | */ 37 | public function setSpawn(Vector3 $vector3): void 38 | { 39 | $this->spawnPosition = $vector3; 40 | } 41 | 42 | /** 43 | * @return array 44 | * 45 | * Exports the spawn area. 46 | */ 47 | public function export(): array 48 | { 49 | $output = parent::export(); 50 | $output["spawn"] = PracticeUtil::vec3ToArr($this->spawnPosition); 51 | return $output; 52 | } 53 | 54 | /** 55 | * @param array $data 56 | * @return SpawnArea|null 57 | * 58 | * Decodes the spawn area. 59 | */ 60 | public static function decode(array $data) 61 | { 62 | if(!isset($data["spawn"])) 63 | { 64 | return null; 65 | } 66 | 67 | $spawnPosition = PracticeUtil::arrToVec3($data["spawn"]); 68 | if($spawnPosition === null) 69 | { 70 | return null; 71 | } 72 | 73 | $area = new SpawnArea($spawnPosition); 74 | 75 | if(isset($data["vertex1"], $data["vertex2"])) 76 | { 77 | $area->vertex1 = PracticeUtil::arrToVec3($data["vertex1"]); 78 | $area->vertex2 = PracticeUtil::arrToVec3($data["vertex2"]); 79 | } 80 | 81 | return $area; 82 | } 83 | } -------------------------------------------------------------------------------- /addons/basicduels/src/jkorn/bd/duels/types/BasicDuelGameInfo.php: -------------------------------------------------------------------------------- 1 | name = $name; 24 | $this->texture = $texture; 25 | $this->numPlayers = $numPlayers; 26 | } 27 | 28 | /** 29 | * @return ButtonTexture|null 30 | * 31 | * Gets the form button texture. 32 | */ 33 | public function getFormButtonTexture(): ?ButtonTexture 34 | { 35 | return $this->texture; 36 | } 37 | 38 | /** 39 | * @return string 40 | * 41 | * Gets the localized name of the game type. 42 | */ 43 | public function getLocalizedName(): string 44 | { 45 | return strtolower($this->name); 46 | } 47 | 48 | /** 49 | * @return string 50 | * 51 | * Gets the display name of the game type. 52 | */ 53 | public function getDisplayName(): string 54 | { 55 | return $this->name; 56 | } 57 | 58 | /** 59 | * @return int 60 | * 61 | * Gets the total number of players. 62 | */ 63 | public function getNumberOfPlayers(): int 64 | { 65 | return $this->numPlayers; 66 | } 67 | 68 | /** 69 | * @param $object 70 | * @return bool 71 | * 72 | * Determines if a game type is equivalent. 73 | */ 74 | public function equals($object): bool 75 | { 76 | if($object instanceof BasicDuelGameInfo) 77 | { 78 | return $object->getLocalizedName() === $this->getLocalizedName(); 79 | } 80 | 81 | return false; 82 | } 83 | } -------------------------------------------------------------------------------- /old/src/practice/commands/basic/TeleportLevelCommand.php: -------------------------------------------------------------------------------- 1 | ", []); 25 | parent::setPermission("practice.permission.tplevel"); 26 | } 27 | 28 | /** 29 | * @param CommandSender $sender 30 | * @param string $commandLabel 31 | * @param string[] $args 32 | * 33 | * @return mixed 34 | * @throws CommandException 35 | */ 36 | public function execute(CommandSender $sender, string $commandLabel, array $args) { 37 | 38 | $msg = null; 39 | 40 | if(PracticeUtil::canExecBasicCommand($sender, false)) { 41 | 42 | if(PracticeUtil::testPermission($sender, $this->getPermission())) { 43 | $size = count($args); 44 | if ($size === 1) { 45 | $lvlName = $args[0]; 46 | $level = Server::getInstance()->getLevelByName($lvlName); 47 | if (!is_null($level)) { 48 | $p = Server::getInstance()->getPlayer($sender->getName()); 49 | $p->teleport($level->getSpawnLocation()); 50 | $lvlName = $level->getName(); 51 | $msg = "Successfully teleported to '$lvlName'!"; 52 | } else $msg = TextFormat::RED . "The level '$lvlName' does not exist!"; 53 | } else $msg = $this->getUsage(); 54 | } 55 | } 56 | 57 | if(!is_null($msg)) $sender->sendMessage($msg); 58 | return true; 59 | } 60 | } -------------------------------------------------------------------------------- /old/src/practice/game/inventory/menus/inventories/SingleChestInv.php: -------------------------------------------------------------------------------- 1 | getBlock()->setComponents($data->getPos()->x, $data->getPos()->y, $data->getPos()->z); 47 | $player->getLevel()->sendBlocks([$player], [$block]); 48 | $tag = new CompoundTag(); 49 | if(!is_null($data->getCustomName())) { 50 | $tag->setString('CustomName', $data->getCustomName()); 51 | } 52 | 53 | $this->sendTileEntity($player, $block, $tag); 54 | 55 | $this->onInventorySend($player); 56 | } 57 | 58 | function sendPublicInv(Player $player, PracHolderData $data): void { 59 | $player->getLevel()->sendBlocks([$player], [$data->getPos()]); 60 | } 61 | 62 | private function getBlock() : Block { 63 | return Block::get(Block::CHEST); 64 | } 65 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/games/player/properties/GPPropertyInfo.php: -------------------------------------------------------------------------------- 1 | localizedName = $localizedName; 24 | $this->class = $class; 25 | 26 | $this->propertyInformation = new \stdClass(); 27 | $this->addPropertyInfo("display", $propertyDisplay); 28 | } 29 | 30 | /** 31 | * @return string 32 | * 33 | * Gets the class. 34 | */ 35 | protected function getClass(): string 36 | { 37 | return $this->class; 38 | } 39 | 40 | /** 41 | * @return bool 42 | * 43 | * Determines if the Game Property Information is valid. 44 | */ 45 | public function validate(): bool 46 | { 47 | return is_subclass_of($this->class, IGamePlayerProperty::class); 48 | } 49 | 50 | /** 51 | * @param string $key 52 | * @param $value 53 | * 54 | * Adds property information. 55 | */ 56 | public function addPropertyInfo(string $key, $value): void 57 | { 58 | $this->propertyInformation->{$key} = $value; 59 | } 60 | 61 | /** 62 | * @return string 63 | * 64 | * Gets the property name as a string. 65 | */ 66 | public function getPropertyLocalizedName(): string 67 | { 68 | return $this->localizedName; 69 | } 70 | 71 | /** 72 | * @param Item $item - the input item. 73 | * @param $defaultValue - The specific value. 74 | * 75 | * @return IGamePlayerProperty 76 | * 77 | * Converts the property Info to an instance. 78 | */ 79 | abstract public function convertToInstance(Item &$item, $defaultValue = null); 80 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/level/gen/PracticeGenerator.php: -------------------------------------------------------------------------------- 1 | level = $level; 39 | $this->random = $random; 40 | } 41 | 42 | /** 43 | * @param int $chunkX 44 | * @param int $chunkZ 45 | * 46 | * Populates a chunk. 47 | */ 48 | public function populateChunk(int $chunkX, int $chunkZ): void {} 49 | 50 | /** 51 | * @return stdClass 52 | * 53 | * Extracts the data from the generator, used by the PracticeGeneratorInfo 54 | * class. 55 | */ 56 | abstract public static function extractData(): stdClass; 57 | 58 | /** 59 | * @return string 60 | * 61 | * Gets the generator name of the arena, used when data is extracted. 62 | */ 63 | abstract protected static function getGeneratorName(): string; 64 | 65 | /** 66 | * @return string 67 | * 68 | * Gets the name of the generator. 69 | */ 70 | public function getName(): string 71 | { 72 | return self::getGeneratorName(); 73 | } 74 | 75 | /** 76 | * @return array 77 | * 78 | * Gets the settings of the practice generator. 79 | */ 80 | public function getSettings(): array 81 | { 82 | return []; 83 | } 84 | } -------------------------------------------------------------------------------- /old/src/practice/player/gameplay/reports/BugReport.php: -------------------------------------------------------------------------------- 1 | occurrence = $occurrence; 21 | } 22 | 23 | public function getOccurrence() : string { 24 | return $this->occurrence; 25 | } 26 | 27 | public function toMap(): array { 28 | 29 | $timeStampArr = $this->time->toMap(); 30 | 31 | $reportedType = $this->getReportTypeToStr(); 32 | 33 | $reporter = $this->getReporter(); 34 | 35 | $occurs_when = $this->occurrence; 36 | 37 | $desc = ($this->description !== "" ? $this->description : parent::STAFF_NONE); 38 | 39 | $info = [ 40 | "occurrence" => $occurs_when, 41 | "description" => $desc 42 | ]; 43 | 44 | $result = [ 45 | "report-type" => $reportedType, 46 | "time-stamp" => $timeStampArr, 47 | "reporter" => $reporter, 48 | "info" => $info 49 | ]; 50 | 51 | return $result; 52 | } 53 | 54 | public function toMessage(bool $form = true): string { 55 | 56 | $reportType = "Bug Report"; 57 | 58 | $date = $this->time->formatDate(false); 59 | $time = $this->time->formatTime(false); 60 | 61 | $timeStamp = "$date at $time"; 62 | 63 | $desc = "."; 64 | 65 | if($this->hasDescription()) $desc = " and '" . $this->description . "'."; 66 | 67 | $addedLine = ($form === true) ? "\n" : " "; 68 | 69 | $format = "[$timeStamp]$addedLine$reportType - $this->reporter reported a bug that occurs when '$this->occurrence'$desc"; 70 | 71 | return $format; 72 | } 73 | } -------------------------------------------------------------------------------- /old/src/practice/commands/basic/FlyCommand.php: -------------------------------------------------------------------------------- 1 | getPermission())){ 43 | $len = count($args); 44 | if($len === 0) { 45 | 46 | $p = PracticeCore::getPlayerHandler()->getPlayer($sender->getName()); 47 | $isNowFlying = false; 48 | $player = $p->getPlayer(); 49 | 50 | if(PracticeUtil::canFly($player)) { 51 | PracticeUtil::setCanFly($player, false); 52 | } else { 53 | $isNowFlying = true; 54 | PracticeUtil::setCanFly($player, true); 55 | } 56 | 57 | $replaced = ($isNowFlying ? "fly" : "land"); 58 | $msg = PracticeUtil::getMessage("general.fly.success-direct-$replaced"); 59 | 60 | } else { 61 | $msg = $this->getUsage(); 62 | } 63 | } 64 | } 65 | 66 | if(!is_null($msg)) $sender->sendMessage($msg); 67 | return true; 68 | } 69 | } -------------------------------------------------------------------------------- /old/src/practice/commands/advanced/DisguiseCommand.php: -------------------------------------------------------------------------------- 1 | [ 26 | new BaseParameter("help", Parameter::NO_PERMISSION, "Lists all disguise commands.") 27 | ], 28 | 1 => [ 29 | new BaseParameter("on", $this->getPermission(), "Turns on a disguise for the user.") 30 | ], 31 | 2 => [ 32 | new BaseParameter("off", $this->getPermission(), "Turns off the user's disguise.") 33 | ] 34 | ]; 35 | $this->setParameters($parameters); 36 | } 37 | 38 | public function execute(CommandSender $sender, $commandLabel, array $args) { 39 | 40 | $msg = null; 41 | 42 | if($this->canExecute($sender, $args)) { 43 | $name = strval($args[0]); 44 | switch($name) { 45 | case "help": 46 | $msg = $this->getFullUsage(); 47 | break; 48 | case "on": 49 | $this->turnOnDisguise($sender); 50 | break; 51 | case "off": 52 | $this->turnOffDisguise($sender); 53 | break; 54 | default: 55 | $msg = $this->getFullUsage(); 56 | } 57 | } 58 | 59 | if(!is_null($msg)) $sender->sendMessage($msg); 60 | 61 | return true; 62 | } 63 | 64 | private function turnOnDisguise(CommandSender $sender) : void { 65 | 66 | } 67 | 68 | private function turnOffDisguise(CommandSender $sender) : void { 69 | 70 | } 71 | } -------------------------------------------------------------------------------- /old/src/practice/commands/basic/PlayerInfoCommand.php: -------------------------------------------------------------------------------- 1 | 0)) { 42 | 43 | if(PracticeUtil::testPermission($sender, $this->getPermission())){ 44 | 45 | if($len <= 1) { 46 | 47 | $name = ($len === 1) ? strval($args[0]) : $sender->getName(); 48 | 49 | $playerHandler = PracticeCore::getPlayerHandler(); 50 | 51 | if($playerHandler->isPlayerOnline($name)) { 52 | 53 | $p = $playerHandler->getPlayer($name); 54 | 55 | $info = $p->getDeviceInfo(); 56 | 57 | foreach($info as $message) 58 | $sender->sendMessage($message); 59 | 60 | } else { 61 | $msg = PracticeUtil::getMessage("not-online"); 62 | $msg = strval(str_replace("%player-name%", $name, $msg)); 63 | } 64 | } else $msg = $this->getUsage(); 65 | } 66 | } 67 | 68 | if(!is_null($msg)) $sender->sendMessage($msg); 69 | return true; 70 | } 71 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/commands/SpectateCommand.php: -------------------------------------------------------------------------------- 1 | getForm(PracticeFormManager::FORM_SPECTATOR_SELECTION); 33 | if($form !== null && $sender instanceof Player) { 34 | $form->display($sender); 35 | } else { 36 | // TODO: Send error message. 37 | } 38 | } 39 | 40 | /** 41 | * @param CommandSender $target 42 | * @return bool 43 | * 44 | * Used to test the permission 45 | */ 46 | public function testPermission(CommandSender $target): bool 47 | { 48 | if(!$target instanceof Player) 49 | { 50 | // TODO: Console usage command. 51 | return false; 52 | } 53 | 54 | // Checks permission before player can execute command. 55 | if(!parent::testPermission($target)) 56 | { 57 | return false; 58 | } 59 | 60 | if($target instanceof PracticePlayer) 61 | { 62 | // TODO: Send game message. 63 | if($target->isInGame()) 64 | { 65 | return false; 66 | } 67 | 68 | // TODO: Send spectator message. 69 | if($target->isSpectator()) 70 | { 71 | return false; 72 | } 73 | } 74 | 75 | return true; 76 | } 77 | } -------------------------------------------------------------------------------- /addons/basicduels/src/jkorn/bd/forms/internal/edit/EditBasicDuelArenaArea.php: -------------------------------------------------------------------------------- 1 | setTitle(TextFormat::BOLD . "Edit Basic Duel Arena"); 39 | $form->addLabel("Edit the basic duel arena area."); 40 | 41 | $form->addLabel("Command to edit the 1st Player's Spawn Position:\n" . TextFormat::BOLD . "/bdarena spawnPos1 " . $arena->getName()); 42 | $form->addLabel("Command to edit the 2nd Player's Spawn Position:\n" . TextFormat::BOLD . "/bdarena spawnPos2 " . $arena->getName()); 43 | 44 | $form->addLabel("Command to edit the 1st Bound of the Arena:\n" . TextFormat::BOLD . "/bdarena pos1 " . $arena->getName()); 45 | $form->addLabel("Command to edit the 2nd Bound of the Arena:\n" . TextFormat::BOLD . "/bdarena pos2 " . $arena->getName()); 46 | } 47 | 48 | /** 49 | * @param Player $player 50 | * @return bool 51 | * 52 | * Tests the form's permissions to see if the player can use it. 53 | */ 54 | protected function testPermission(Player $player): bool 55 | { 56 | // TODO: Implement testPermission() method. 57 | return true; 58 | } 59 | 60 | /** 61 | * @return string 62 | * 63 | * Gets the localized name of the internal form. 64 | */ 65 | public function getLocalizedName(): string 66 | { 67 | return self::EDIT_BASIC_DUEL_ARENA_AREA; 68 | } 69 | } -------------------------------------------------------------------------------- /old/src/practice/duels/groups/MatchedGroup.php: -------------------------------------------------------------------------------- 1 | playerName = $pName; 35 | if(!is_null($oName)) $this->opponentName = $oName; 36 | 37 | $this->queue = $queue; 38 | $this->ranked = $ranked; 39 | } 40 | 41 | public function isRanked() : bool { 42 | return $this->ranked; 43 | } 44 | 45 | public function getPlayerName() : string { 46 | return $this->playerName; 47 | } 48 | 49 | public function getOpponentName() : string { 50 | return $this->opponentName; 51 | } 52 | 53 | public function getPlayer() { 54 | return PracticeCore::getPlayerHandler()->getPlayer($this->playerName); 55 | } 56 | 57 | public function getOpponent() { 58 | return PracticeCore::getPlayerHandler()->getPlayer($this->opponentName); 59 | } 60 | 61 | public function isPlayerOnline() { 62 | $p = $this->getPlayer(); 63 | return !is_null($p) and $p->isOnline(); 64 | } 65 | 66 | public function isOpponentOnline() { 67 | $p = $this->getOpponent(); 68 | return !is_null($p) and $p->isOnline(); 69 | } 70 | 71 | public function getQueue() : string { 72 | return $this->queue; 73 | } 74 | 75 | public function equals($object) : bool { 76 | $result = false; 77 | if($object instanceof MatchedGroup) { 78 | if($this->getPlayerName() === $object->getPlayerName() and $this->getOpponentName() === $object->getOpponentName()) { 79 | $result = $this->getQueue() === $object->getQueue(); 80 | } 81 | } 82 | return $result; 83 | } 84 | } -------------------------------------------------------------------------------- /old/src/practice/commands/basic/DuelCommand.php: -------------------------------------------------------------------------------- 1 | getPlayer(), $this->getPermission(), true)) { 46 | $p = PracticeCore::getPlayerHandler()->getPlayer($sender->getPlayer()); 47 | $count = count($args); 48 | if($count === 1) { 49 | $requested = strval($args[0]); 50 | if(Request::canSend($p, $requested)) { 51 | if(PracticeUtil::isItemFormsEnabled()) { 52 | $form = FormUtil::getDuelsForm(); 53 | $p->sendForm($form); 54 | } else InventoryUtil::sendDuelInv($p->getPlayer()); 55 | 56 | PracticeCore::get1vs1Handler()->loadRequest($p->getPlayerName(), $requested); 57 | } 58 | } else { 59 | $msg = $this->getUsage(); 60 | } 61 | } 62 | } else { 63 | $msg = PracticeUtil::getMessage("console-usage-command"); 64 | } 65 | 66 | if(!is_null($msg)) $sender->sendMessage($msg); 67 | return true; 68 | } 69 | } -------------------------------------------------------------------------------- /old/src/practice/duels/groups/QueuedPlayer.php: -------------------------------------------------------------------------------- 1 | playerName = $name; 30 | $this->queue = $queue; 31 | $this->ranked = $ranked; 32 | $this->peOnly = $peOnly; 33 | } 34 | 35 | public function isPEOnly() : bool { 36 | return $this->peOnly; 37 | } 38 | 39 | public function getQueue() : string { 40 | return $this->queue; 41 | } 42 | 43 | public function isRanked() : bool { 44 | return $this->ranked; 45 | } 46 | 47 | public function getPlayerName() : string { 48 | return $this->playerName; 49 | } 50 | 51 | public function getPlayer() { 52 | return PracticeCore::getPlayerHandler()->getPlayer($this->playerName); 53 | } 54 | 55 | public function isPlayerOnline() : bool { 56 | return !is_null($this->getPlayer()) and $this->getPlayer()->isOnline(); 57 | } 58 | 59 | public function hasSameQueue(QueuedPlayer $player) : bool { 60 | $result = false; 61 | if($player->getQueue() === $this->queue) { 62 | $ranked = $player->isRanked(); 63 | $result = $this->ranked === $ranked; 64 | } 65 | return $result; 66 | } 67 | 68 | public function equals($object) : bool { 69 | $result = false; 70 | if($object instanceof QueuedPlayer) { 71 | if ($object->getPlayerName() === $this->playerName) { 72 | $result = true; 73 | } 74 | } 75 | return $result; 76 | } 77 | 78 | public function toString() : string { 79 | 80 | $str = PracticeUtil::getName('scoreboard.spawn.thequeue'); 81 | 82 | $ranked = ($this->ranked === true) ? 'Ranked' : 'Unranked'; 83 | 84 | return PracticeUtil::str_replace($str, ['%ranked%' => $ranked, '%queue%' => $this->queue]); 85 | } 86 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/items/PracticeItemManager.php: -------------------------------------------------------------------------------- 1 | resourcesFolder = $resourcesFolder; 27 | $this->dataFolder = $dataFolder; 28 | } 29 | 30 | /** 31 | * Loads the items in the item manager. 32 | */ 33 | public function load(): void 34 | { 35 | if(!is_dir($this->dataFolder)) 36 | { 37 | mkdir($this->dataFolder); 38 | } 39 | 40 | $this->onLoad(); 41 | $this->loaded = true; 42 | } 43 | 44 | 45 | /** 46 | * @return void 47 | * 48 | * Loads the data from the input file. 49 | */ 50 | abstract protected function onLoad(): void; 51 | 52 | /** 53 | * @param Item $item 54 | * @return PracticeItem|null - True if item is a callback item. 55 | * 56 | * Determines if the item is a callback item. 57 | */ 58 | public function getPracticeItem(Item $item): ?PracticeItem 59 | { 60 | foreach($this->practiceItems as $practiceItem) { 61 | if($practiceItem->equals($item)) { 62 | return $practiceItem; 63 | } 64 | } 65 | return null; 66 | } 67 | 68 | /** 69 | * @param string $type - The type of item we want to send. 70 | * @param Player $player - The player we are sending the item to. 71 | * @param bool $clearInventory - Determines whether we should clear inventory 72 | * or not before sending the items. 73 | * 74 | * Sends the items based on the type. 75 | */ 76 | abstract public function sendItemsFromType(string $type, Player $player, bool $clearInventory = true): void; 77 | 78 | /** 79 | * @return string 80 | * 81 | * Gets the data file of the item manager. 82 | */ 83 | protected function getItemsFile(): string 84 | { 85 | return $this->dataFolder . "/items.yml"; 86 | } 87 | } -------------------------------------------------------------------------------- /old/src/practice/player/gameplay/reports/HackReport.php: -------------------------------------------------------------------------------- 1 | reportedPlayer = (isset($reported) and !is_null(PracticeUtil::getPlayerName($reported))) ? PracticeUtil::getPlayerName($reported) : parent::STAFF_NONE; 21 | if(is_null($this->reportedPlayer)) $this->reportedPlayer = parent::STAFF_NONE; 22 | } 23 | 24 | public function isReportedPlayerValid() : bool { 25 | return $this->reportedPlayer !== self::STAFF_NONE; 26 | } 27 | 28 | public function getReportedPlayer() : string { 29 | return $this->reportedPlayer; 30 | } 31 | 32 | public function toMap(): array { 33 | 34 | $timeStampArr = $this->time->toMap(); 35 | 36 | $reportedType = $this->getReportTypeToStr(); 37 | 38 | $reporter = $this->getReporter(); 39 | $reported = $this->getReportedPlayer(); 40 | 41 | $desc = ($this->description !== "" ? $this->description : parent::STAFF_NONE); 42 | 43 | $info = [ 44 | "reporter" => $reporter, 45 | "reported" => $reported, 46 | "reason" => $desc 47 | ]; 48 | 49 | $result = [ 50 | "report-type" => $reportedType, 51 | "time-stamp" => $timeStampArr, 52 | "info" => $info 53 | ]; 54 | 55 | return $result; 56 | } 57 | 58 | public function toMessage(bool $form = true): string { 59 | 60 | $reportType = "Hacker Report"; 61 | 62 | $date = $this->time->formatDate(false); 63 | $time = $this->time->formatTime(false); 64 | 65 | $timeStamp = "$date at $time"; 66 | 67 | $desc = "!"; 68 | 69 | if($this->hasDescription()) $desc = " for '$this->description.'"; 70 | 71 | $addedLine = ($form === true) ? "\n" : " "; 72 | 73 | $format = "[$timeStamp]$addedLine$reportType - $this->reporter reported $this->reportedPlayer$desc"; 74 | 75 | return $format; 76 | } 77 | } -------------------------------------------------------------------------------- /old/src/practice/commands/basic/SpawnCommand.php: -------------------------------------------------------------------------------- 1 | isPlayerOnline($sender->getName())) { 40 | $player = PracticeCore::getPlayerHandler()->getPlayer($sender->getName()); 41 | $count = count($args); 42 | if($count === 0) { 43 | 44 | $exec = true; 45 | 46 | if($player->isInArena() and !$player->isInDuel()) { 47 | if($player->isInCombat()) { 48 | $exec = false; 49 | } 50 | } 51 | 52 | if($exec){ 53 | 54 | if(PracticeCore::getDuelHandler()->isASpectator($player->getPlayerName())) { 55 | $duel = PracticeCore::getDuelHandler()->getDuelFromSpec($player->getPlayerName()); 56 | $duel->removeSpectator($player->getPlayerName(), true); 57 | } 58 | 59 | $msg = PracticeUtil::getMessage("spawn-message"); 60 | PracticeUtil::resetPlayer($player->getPlayer(), true); 61 | } 62 | } else { 63 | $msg = $this->getUsage(); 64 | } 65 | } 66 | } 67 | 68 | if(!is_null($msg)) $sender->sendMessage($msg); 69 | return true; 70 | } 71 | } -------------------------------------------------------------------------------- /old/src/practice/player/gameplay/reports/StaffReport.php: -------------------------------------------------------------------------------- 1 | reportedStaff = (isset($reported) and !is_null(PracticeUtil::getPlayerName($reported))) ? PracticeUtil::getPlayerName($reported) : parent::STAFF_NONE; 22 | if(is_null($this->reportedStaff)) $this->reportedStaff = parent::STAFF_NONE; 23 | } 24 | 25 | public function hasStaff() : bool { 26 | return $this->reportedStaff !== parent::STAFF_NONE; 27 | } 28 | 29 | public function getReportedStaff() : string { 30 | return $this->reportedStaff; 31 | } 32 | 33 | public function toMap(): array { 34 | 35 | $timeStampArr = $this->time->toMap(); 36 | 37 | $reportedType = $this->getReportTypeToStr(); 38 | 39 | $reporter = $this->getReporter(); 40 | $reported = $this->getReportedStaff(); 41 | 42 | $desc = ($this->description !== "" ? $this->description : parent::STAFF_NONE); 43 | 44 | $info = [ 45 | "reporter" => $reporter, 46 | "reported" => $reported, 47 | "reason" => $desc 48 | ]; 49 | 50 | $result = [ 51 | "report-type" => $reportedType, 52 | "time-stamp" => $timeStampArr, 53 | "info" => $info 54 | ]; 55 | 56 | return $result; 57 | } 58 | 59 | public function toMessage(bool $form = true): string { 60 | 61 | $date = $this->time->formatDate(false); 62 | $time = $this->time->formatTime(false); 63 | 64 | $timeStamp = "$date at $time"; 65 | 66 | $reportType = "Staff Report"; 67 | 68 | $addedLine = ($form === true) ? "\n" : " "; 69 | 70 | $format = "[$timeStamp]$addedLine$reportType - $this->reporter reported $this->reportedStaff%rest%"; 71 | 72 | $rest = "!"; 73 | 74 | if($this->hasDescription()) $rest = " for '$this->description.'"; 75 | 76 | return PracticeUtil::str_replace($format, ["%rest%" => $rest]); 77 | } 78 | } -------------------------------------------------------------------------------- /old/src/practice/duels/misc/DuelSpectator.php: -------------------------------------------------------------------------------- 1 | name = $player->getName(); 28 | 29 | $this->boundingBox = $player->getBoundingBox(); 30 | 31 | $player->boundingBox->contract($player->width, 0, $player->height); 32 | 33 | PracticeUtil::setInSpectatorMode($player, true, true); 34 | 35 | /*if(PracticeCore::getPlayerHandler()->isPlayerOnline($player)) { 36 | $pl = PracticeCore::getPlayerHandler()->getPlayer($player); 37 | //$pl->setScoreboard(Scoreboard::SPEC_SCOREBOARD); 38 | }*/ 39 | 40 | PracticeCore::getItemHandler()->spawnSpecItems($player); 41 | } 42 | 43 | public function teleport(Position $pos) : void { 44 | 45 | if($this->isOnline()) { 46 | $p = $this->getPlayer()->getPlayer(); 47 | $pl = $p->getPlayer(); 48 | $pl->teleport($pos); 49 | } 50 | } 51 | 52 | public function resetPlayer(bool $disablePlugin = false) : void { 53 | 54 | if($this->isOnline()) { 55 | 56 | $p = $this->getPlayer()->getPlayer(); 57 | 58 | $p->boundingBox = $this->boundingBox; 59 | 60 | PracticeUtil::resetPlayer($p, true, true, $disablePlugin); 61 | } 62 | } 63 | 64 | public function sendMessage(string $msg) : void { 65 | if($this->isOnline()) { 66 | $this->getPlayer()->sendMessage($msg); 67 | } 68 | } 69 | 70 | public function update(string $duration) : void { 71 | if($this->isOnline()) { 72 | $p = $this->getPlayer(); 73 | $p->updateLineOfScoreboard(2, ' ' . $duration); 74 | } 75 | } 76 | 77 | public function getPlayer() { 78 | return PracticeCore::getPlayerHandler()->getPlayer($this->name); 79 | } 80 | 81 | public function isOnline() : bool { 82 | $p = $this->getPlayer(); 83 | return !is_null($p) and $p->isOnline(); 84 | } 85 | 86 | public function getPlayerName() : string { 87 | return $this->name; 88 | } 89 | 90 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/forms/Form.php: -------------------------------------------------------------------------------- 1 | callable = $callable; 28 | } 29 | 30 | /** 31 | * @return callable|null 32 | * 33 | * Gets the callable function used for forms. 34 | */ 35 | public function getCallable() : ?callable 36 | { 37 | return $this->callable; 38 | } 39 | 40 | /** 41 | * @param callable|null $callable 42 | * 43 | * Sets the callable function used for forms. 44 | */ 45 | public function setCallable(?callable $callable) 46 | { 47 | $this->callable = $callable; 48 | } 49 | 50 | /** 51 | * @param array $data 52 | * 53 | * Sets the extra data of the form. 54 | */ 55 | public function setExtraData(array $data): void 56 | { 57 | $this->extraData = $data; 58 | } 59 | 60 | /** 61 | * @param string $key 62 | * @param $value 63 | * 64 | * Adds an extra data to the form. 65 | */ 66 | public function addExtraData(string $key, $value): void 67 | { 68 | $this->extraData[$key] = $value; 69 | } 70 | 71 | /** 72 | * @param Player $player 73 | * @param mixed $data 74 | * 75 | * Handles when the response is given to the player. 76 | */ 77 | public function handleResponse(Player $player, $data) : void { 78 | 79 | $this->processData($data); 80 | $callable = $this->getCallable(); 81 | 82 | if($callable !== null) { 83 | $callable($player, $data, $this->extraData); 84 | } 85 | } 86 | 87 | /** 88 | * @param $data 89 | * 90 | * Processes the data. 91 | */ 92 | public function processData(&$data) : void {} 93 | 94 | /** 95 | * @return array|mixed 96 | * 97 | * Serializes the form into a json format. 98 | */ 99 | public function jsonSerialize() 100 | { 101 | return $this->data; 102 | } 103 | } -------------------------------------------------------------------------------- /old/src/practice/commands/basic/SpectateCommand.php: -------------------------------------------------------------------------------- 1 | getPlayer(), $this->getPermission())) { 41 | $count = count($args); 42 | if($count === 1) { 43 | $player = strval($args[0]); 44 | if(PracticeCore::getPlayerHandler()->isPlayerOnline($player)) { 45 | $p = PracticeCore::getPlayerHandler()->getPlayer($player); 46 | if($p->isInDuel()) { 47 | $duel = PracticeCore::getDuelHandler()->getDuel($p->getPlayerName()); 48 | $duel->addSpectator($sender->getName()); 49 | } else { 50 | $msg = PracticeUtil::getMessage("duels.misc.not-in-duel"); 51 | $msg = PracticeUtil::str_replace($msg, ["%player%" => $p->getPlayerName()]); 52 | } 53 | } else { 54 | $msg = PracticeUtil::getMessage("not-online"); 55 | $msg = strval(str_replace("%player-name%", $player, $msg)); 56 | } 57 | } else { 58 | $msg = $this->getUsage(); 59 | } 60 | } 61 | } else $msg = PracticeUtil::getMessage("console-usage-command"); 62 | 63 | if(!is_null($msg)) $sender->sendMessage($msg); 64 | return true; 65 | } 66 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/games/misc/gametypes/ISpectatorGame.php: -------------------------------------------------------------------------------- 1 | getPermission())) { 41 | $len = count($args); 42 | if($len === 0) { 43 | if($sender instanceof Player and PracticeCore::getPlayerHandler()->isPlayerOnline($sender->getName())) { 44 | $p = PracticeCore::getPlayerHandler()->getPlayer($sender->getName()); 45 | $ping = $p->getPing(); 46 | $msg = TextFormat::GRAY . "--= Your Ping" . TextFormat::WHITE . ": $ping" . "ms" . TextFormat::GRAY . " =--"; 47 | } else $msg = PracticeUtil::getMessage("console-usage-command"); 48 | } elseif ($len === 1) { 49 | $name = $args[0]; 50 | if(PracticeCore::getPlayerHandler()->isPlayerOnline($name)) { 51 | $p = PracticeCore::getPlayerHandler()->getPlayer($name); 52 | $name = $p->getPlayerName(); 53 | $ping = $p->getPing(); 54 | $msg = TextFormat::GRAY . "--= $name's Ping" . TextFormat::WHITE . ": $ping" . "ms" . TextFormat::GRAY . " =--"; 55 | } else { 56 | $msg = PracticeUtil::getMessage("not-online"); 57 | $msg = strval(str_replace("%player-name%", $name, $msg)); 58 | } 59 | } else $msg = $this->getUsage(); 60 | } 61 | 62 | if(!is_null($msg)) $sender->sendMessage($msg); 63 | return true; 64 | } 65 | } -------------------------------------------------------------------------------- /core/resources/forms/forms.yml: -------------------------------------------------------------------------------- 1 | 2 | # The form that contains the text display for 3 | # the form settings menu. 4 | form.settings.menu: 5 | class: jkorn\practice\forms\display\types\MenuSettingsForm 6 | title: "Settings Form" 7 | description: "Form to edit the player settings." 8 | buttons: 9 | settings.basic: 10 | top.text: " Basic Settings " 11 | bottom.text: "" 12 | settings.builder: 13 | top.text: " Builder Mode Settings" 14 | bottom.text: "" 15 | # TODO: Disguise Settings 16 | 17 | # The form that contains the text display for 18 | # the duels settings menu. 19 | form.settings.basic: 20 | class: jkorn\practice\forms\display\types\BasicSettingsForm 21 | title: "Basic Settings" 22 | description: "Form to edit your basic settings." 23 | 24 | # The form that contains the text display for 25 | # the builder mode menu. 26 | form.settings.builder: 27 | class: jkorn\practice\forms\display\types\BuilderSettingsForm 28 | title: "Builder Mode Settings" 29 | description: "Form to edit your builder mode settings." 30 | toggles: 31 | builder.mode: 32 | enabled: "Enable Builder Mode" 33 | disabled: "Disable Builder Mode" 34 | labels: 35 | enabled.worlds: "Select the worlds that you want to enable/disable builder mode for:" 36 | 37 | # The form that contains the text display for 38 | # the Play Games form menu. 39 | form.games.play: 40 | class: jkorn\practice\forms\display\types\PlayGamesForm 41 | title: "Play Games" 42 | description: "Select the games that you want to play." 43 | buttons: 44 | select.game.template: 45 | top.text: "Play {stat.games.type}" 46 | bottom.text: "Players: {stat.games.type.players.playing}" 47 | select.game.none: 48 | top.text: "None" 49 | bottom.text: "" 50 | 51 | # The form that contains the text display for the 52 | # game selection for the spectator form. 53 | form.spectator.game.selection: 54 | class: jkorn\practice\forms\display\types\SpectatorSelectionForm 55 | title: "Spectate Game" 56 | description: "Select the game that you want to spectate." 57 | 58 | # The form that contains the text display for the 59 | # form that determines whether spectators should join. 60 | form.spectator.game.join: 61 | class: jkorn\practice\forms\display\types\SpectatorJoinForm 62 | title: "Spectate Game" 63 | description: "Select \"Join\" if you want to spectate the game, otherwise select \"Cancel\"." 64 | buttons: 65 | selection.join: 66 | top.text: "Yes" 67 | bottom.text: "" 68 | selection.cancel: 69 | top.text: "Cancel" 70 | bottom.text: "" -------------------------------------------------------------------------------- /old/src/practice/player/gameplay/ChatHandler.php: -------------------------------------------------------------------------------- 1 | contents[$content] = true; 27 | } 28 | } 29 | 30 | 31 | /** 32 | * @param string $msg 33 | * @return array|string[] 34 | */ 35 | public function getCensoredWordsIn(string $msg) : array { 36 | 37 | $result = []; 38 | 39 | $lowerCaseMsg = strtolower($msg); 40 | 41 | $words = explode(" ", $lowerCaseMsg); 42 | 43 | foreach($words as $word) { 44 | 45 | $word = strval($word); 46 | 47 | $lowerCaseWord = strtolower($word); 48 | 49 | if(isset($this->contents[$lowerCaseWord])) { 50 | 51 | $len = strlen($lowerCaseWord); 52 | 53 | $indexes = PracticeUtil::str_indexes($lowerCaseWord, $lowerCaseMsg); 54 | 55 | foreach($indexes as $index) { 56 | 57 | $str = substr($msg, $index, $len); 58 | 59 | if(!PracticeUtil::arr_contains_value($str, $result)) 60 | $result[] = $str; 61 | } 62 | } 63 | } 64 | 65 | return $result; 66 | } 67 | 68 | public function hasCensoredWords(string $msg) : bool { 69 | $censoredWords = $this->getCensoredWordsIn($msg); 70 | $count = count($censoredWords); 71 | return $count > 0; 72 | } 73 | 74 | public function getUncensoredMessage(string $msg) : string { 75 | 76 | $result = $msg; 77 | 78 | if($this->hasCensoredWords($msg)){ 79 | 80 | $words = $this->getCensoredWordsIn($msg); 81 | 82 | $replacedWords = []; 83 | 84 | foreach($words as $word){ 85 | 86 | $key = strval($word); 87 | 88 | $val = mb_substr($key, 0, 1) . "\u{FEFF}" . mb_substr($key, 1); 89 | 90 | $replacedWords[$key] = $val; 91 | } 92 | 93 | $result = PracticeUtil::str_replace($result, $replacedWords); 94 | } 95 | return $result; 96 | } 97 | 98 | } -------------------------------------------------------------------------------- /old/src/practice/anticheat/AntiCheatUtil.php: -------------------------------------------------------------------------------- 1 | isPlayerOnline($player)) { 35 | $p = PracticeCore::getPlayerHandler()->getPlayer($player); 36 | if($p->canHitPlayer()) 37 | $result = $p->getNoDamageTicks() <= 0; 38 | } 39 | return $result; 40 | } 41 | 42 | /** 43 | * @param Player $entity 44 | * @param Player $damager 45 | */ 46 | public static function checkForReach(Player $entity, Player $damager): void { 47 | if(!self::checkPing($damager) or $damager->getGamemode() === Player::CREATIVE) { 48 | return; 49 | } 50 | 51 | $distance = $damager->distance($entity); 52 | if($distance > self::BLOCKS_AIR_LIMIT) { 53 | self::sendReachLog($damager, $distance); 54 | } 55 | } 56 | 57 | /** 58 | * @param Player $player 59 | * @return bool 60 | */ 61 | private static function checkPing(Player $player): bool { 62 | return $player->getPing() < self::MAX_PING; 63 | } 64 | 65 | /** 66 | * @param Player $player 67 | * @param float $distance 68 | */ 69 | private static function sendReachLog(Player $player, float $distance): void { 70 | self::sendLog( 71 | "§7{$player->getName()} might be reaching! Distance: \n" . "§c" . 72 | round($distance, 1) . " §7(" . $player->getPing() . " ms)" 73 | ); 74 | } 75 | 76 | /** 77 | * @param string $message 78 | */ 79 | private static function sendLog(string $message): void { 80 | 81 | foreach(Server::getInstance()->getOnlinePlayers() as $player) { 82 | if(!PracticeCore::getPlayerHandler()->isStaffMember($player->getName())) { 83 | continue; 84 | } 85 | 86 | $player->sendTip("§8[§eAntiCheat§8] " . $message); 87 | } 88 | } 89 | 90 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/scoreboard/display/ScoreboardDisplayLine.php: -------------------------------------------------------------------------------- 1 | text = $text; 26 | $this->statistics = []; 27 | } 28 | 29 | /** 30 | * @param Player $player -> The text based on the display line. 31 | * @param mixed $args -> The arguments for the text. 32 | * @return string 33 | * 34 | * Gets the text from the scoreboard. 35 | */ 36 | public function getText(Player $player, $args = null): string 37 | { 38 | $output = $this->text; 39 | PracticeUtil::convertMessageColors($output); 40 | DisplayStatistic::convert($output, $player, $args); 41 | return $output; 42 | } 43 | 44 | /** 45 | * @param string ...$lines - The lines of the scoreboard. 46 | * @return string 47 | * 48 | * Gets the text for the line element. ONLY USED IF THE 49 | * SCOREBOARD DISPLAY LINE IS IN FACT A LINE. 50 | */ 51 | public function getTextForLine(string...$lines): string 52 | { 53 | if(!$this->isLine()) 54 | { 55 | return $this->text; 56 | } 57 | 58 | $maxCharacters = 0; 59 | foreach($lines as $line) { 60 | $cleaned = trim(TextFormat::clean($line)); 61 | if(strlen($cleaned) >= $maxCharacters) { 62 | $maxCharacters = strlen($cleaned); 63 | } 64 | } 65 | 66 | $outputText = str_replace("{LINE}", str_repeat("-", $maxCharacters), $this->text); 67 | PracticeUtil::convertMessageColors($outputText); 68 | 69 | return $outputText; 70 | } 71 | 72 | /** 73 | * @return bool 74 | * 75 | * Determines if the scoreboard display line is a line element. 76 | */ 77 | public function isLine(): bool 78 | { 79 | return strpos($this->text, "{LINE}") !== false; 80 | } 81 | 82 | /** 83 | * @return bool 84 | * 85 | * Determines whether or not to update the line. 86 | */ 87 | public function containsStatistics(): bool 88 | { 89 | return DisplayStatistic::containsStatistics($this->text, true); 90 | } 91 | 92 | } -------------------------------------------------------------------------------- /core/src/jkorn/practice/level/gen/PracticeGeneratorManager.php: -------------------------------------------------------------------------------- 1 | The information of the generator. 21 | * 22 | * Registers the generator to the default generator list. 23 | */ 24 | public static function registerGenerator(PracticeGeneratorInfo $info): void 25 | { 26 | if(!is_subclass_of($clazz = $info->getClass(), PracticeGenerator::class)) 27 | { 28 | return; 29 | } 30 | $info->extract(); 31 | self::$generators[$info->getName()] = $info; 32 | GeneratorManager::addGenerator($clazz, $info->getName(), true); 33 | } 34 | 35 | /** 36 | * @param string $name 37 | * @return PracticeGenerator|null 38 | * 39 | * Gets the generator information. 40 | */ 41 | public static function getGeneratorInfo(string $name) 42 | { 43 | if(isset(self::$generators[$name])) 44 | { 45 | return self::$generators[$name]; 46 | } 47 | return null; 48 | } 49 | 50 | /** 51 | * @param callable|null $function - Determines whether or not we want 52 | * to filter them. Accepts a PracticeGeneratorInfo parameter and should 53 | * return a boolean: 54 | * EX: getGenerators(function(PracticeGeneratorInfo $info) { return true; }); 55 | * @return array|PracticeGenerator[] 56 | * 57 | * Gets a list of generator information. 58 | */ 59 | public static function getGenerators(?callable $function = null) 60 | { 61 | if($function !== null) 62 | { 63 | return array_filter(self::$generators, $function); 64 | } 65 | return self::$generators; 66 | } 67 | 68 | /** 69 | * @param callable|null $function 70 | * @return PracticeGeneratorInfo|null 71 | * 72 | * Gets the random generator from the generator list. 73 | */ 74 | public static function randomGenerator(?callable $function = null): ?PracticeGeneratorInfo 75 | { 76 | $generators = self::getGenerators($function); 77 | if(count($generators) <= 0) 78 | { 79 | return null; 80 | } 81 | $keys = array_keys($generators); 82 | return $generators[$keys[mt_rand(0, count($keys) - 1)]]; 83 | } 84 | } --------------------------------------------------------------------------------