├── resources ├── command.yml ├── lang_en.yml ├── config.yml └── lang_tr.yml ├── plugin.yml ├── .poggit.yml ├── README.md ├── LICENSE └── src └── ayd1ndemirci └── WorldChat ├── manager └── WorldChat.php ├── Main.php ├── event └── ChatListener.php └── command └── WorldChatCommand.php /resources/command.yml: -------------------------------------------------------------------------------- 1 | command: worldchat 2 | description: "Change world chat messages" 3 | aliases: [ "wc", "format", "dunyasohbet" ] 4 | -------------------------------------------------------------------------------- /plugin.yml: -------------------------------------------------------------------------------- 1 | name: WorldChat 2 | main: ayd1ndemirci\WorldChat\Main 3 | api: 4.0.0 4 | version: 1 5 | author: ayd1ndemirci 6 | 7 | permissions: 8 | worldchat.perm: 9 | default: op -------------------------------------------------------------------------------- /.poggit.yml: -------------------------------------------------------------------------------- 1 | --- # Poggit-CI Manifest. Open the CI at https://poggit.pmmp.io/ci/ayd1ndemirci/WorldChat 2 | build-by-default: true 3 | branches: 4 | - main 5 | projects: 6 | WorldChat: 7 | path: "" 8 | ... 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WorldChat 2 | One-to-one plugin for editing world chat messages. 3 | Supports English and Turkish language 4 | 5 | To set a new world chat format /worldchat new "worldName" "worldFormat" 6 | example: /worldchat new lobby §7[§aLobby§7] 7 | 8 | "/world list" to see available world formats 9 | 10 | "/worldchat author" to get information about the producer 11 | 12 | "/worldchat delete worldName" to delete world format 13 | example: /worldchat delete lobby 14 | 15 | Set "/worldchat set worldName newFormat" to update current format 16 | example: /worldchat set lobby §7[§2L§7] 17 | -------------------------------------------------------------------------------- /resources/lang_en.yml: -------------------------------------------------------------------------------- 1 | new-world-format: "§aTo create a new message format" 2 | delete-format: "§aWorld format to be deleted" 3 | all-format: "§aTo see all formats" 4 | set-format: "§aTo change the format" 5 | world-not-found: "§cWorld not found!" 6 | already-world-used: "§cAlready world used" 7 | created-format: "§8» §aSuccesly format created!" 8 | set-format-message: "§8» §aSuccesly changed format" 9 | removed-format: "§8» §cSuccesly format removed!" 10 | format-not-found: "§cFormat not found!" 11 | see-author: "§aFor information about the plugin coder" 12 | author: "§5Author: §fayd1ndemirci\n§5Version: §f0.1\n§5Discord: §fayd1ndemirci#0001\n§5Support Server: §fdiscord.gg/WFZ4Um98D8" -------------------------------------------------------------------------------- /resources/config.yml: -------------------------------------------------------------------------------- 1 | # 2 | # _ __ _ _ _ 3 | # | /_ | | | (_) (_) 4 | # __ _ _ _ __| || |_ __ __| | ___ _ __ ___ _ _ __ ___ _ 5 | # / _` | | | |/ _` || | '_ \ / _` |/ _ \ '_ ` _ \| | '__/ __| | 6 | #| (_| | |_| | (_| || | | | | (_| | __/ | | | | | | | | (__| | 7 | # \__,_|\__, |\__,_||_|_| |_|\__,_|\___|_| |_| |_|_|_| \___|_| 8 | # __/ | 9 | # |___/ 10 | # 11 | 12 | Format: 13 | global: 14 | Format: "§8[§l§c!§r§8]" 15 | default: 16 | Format: "§8[§l§a#§r§8]" 17 | 18 | # LANGUAGE 19 | #currently supported languages; tr (Turkish, Türkçe), en (English) 20 | language: en -------------------------------------------------------------------------------- /resources/lang_tr.yml: -------------------------------------------------------------------------------- 1 | new-world-format: "§aFormat oluşturmak için!" 2 | delete-format: "§aDünya formatı silmek için" 3 | all-format: "§aTüm formatları görmek için" 4 | set-format: "§aFormatı düzenlemek için" 5 | world-not-found: "§cDünya bulunamadı!" 6 | already-world-used: "§cZaten Bu dünya için format var" 7 | created-format: "§8» §aBaşarıyla format oluşturuldu!" 8 | set-format-message: "§8» §aBaşarıyla format değiştirildi!" 9 | removed-format: "§8» §cBaşarıyla format silindi!" 10 | format-not-found: "§cFormat bulunamadı!" 11 | see-author: "§aEklenti yazarı hakkında bilgi için" 12 | author: "§5Yapımcı: §fayd1ndemirci\n§fVersiyon:§f 0.1\n§5Discord: §fayd1ndemirci#0001\n§5Destek Sunucusu: §fdiscord.gg/WFZ4Um98D8" -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Aydın Demirci 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/ayd1ndemirci/WorldChat/manager/WorldChat.php: -------------------------------------------------------------------------------- 1 | main = $main; 26 | } 27 | 28 | public function getFormats(): array 29 | { 30 | $result = []; 31 | foreach ($this->main->getData()->get("Format") as $worldName => $format) { 32 | $result[] = $worldName; 33 | } 34 | return $result; 35 | } 36 | 37 | /** 38 | * @throws JsonException 39 | */ 40 | public function newFormat(string $worldName, string $format): void 41 | { 42 | $this->main->getData()->setNested("Format." . $worldName . ".Format", $format); 43 | $this->main->getData()->save(); 44 | } 45 | 46 | public function setFormat(string $worldName, string $newFormat): void 47 | { 48 | $this->main->getData()->setNested("Format." . $worldName . ".Format", $newFormat); 49 | $this->main->getData()->save(); 50 | } 51 | 52 | public function deleteFormat(string $worldName): void 53 | { 54 | $this->main->getData()->removeNested("Format." . $worldName); 55 | $this->main->getData()->save(); 56 | } 57 | 58 | public function getFormat(string $worldName): string 59 | { 60 | return $this->main->getData()->get("Format")[$worldName]["Format"]; 61 | } 62 | } -------------------------------------------------------------------------------- /src/ayd1ndemirci/WorldChat/Main.php: -------------------------------------------------------------------------------- 1 | main = $this; 40 | $this->saveResource("config.yml"); 41 | $this->saveResource("command.yml"); 42 | $this->saveResource("lang_en.yml"); 43 | $this->saveResource("lang_tr.yml"); 44 | $this->config = new Config($this->getDataFolder() . "config.yml", 2); 45 | } 46 | 47 | /** 48 | * @throws JsonException 49 | */ 50 | public function onEnable(): void 51 | { 52 | if (!$this->getData()->exists("language")) { 53 | $this->getData()->set("language", "en"); 54 | $this->getData()->save(); 55 | } 56 | 57 | if (!in_array($this->getData()->get("language"), $this->currentLangs)) { 58 | $this->getData()->set("language", "en"); 59 | $this->getData()->save(); 60 | } 61 | 62 | $this->lang = $this->getData()->get("language"); 63 | $config = new Config($this->main->getDataFolder() . "command.yml", 2); 64 | $this->getServer()->getCommandMap()->register($config->get("command"), new WorldChatCommand($this)); 65 | $this->getServer()->getPluginManager()->registerEvents(new ChatListener($this), $this); 66 | } 67 | 68 | public function getData(): Config 69 | { 70 | return $this->config; 71 | } 72 | 73 | public function worldChatMgr(): WorldChat 74 | { 75 | return new WorldChat($this); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/ayd1ndemirci/WorldChat/event/ChatListener.php: -------------------------------------------------------------------------------- 1 | main = $main; 29 | } 30 | 31 | public function onChat(PlayerChatEvent $event): void 32 | { 33 | $player = $event->getPlayer(); 34 | $message = $event->getMessage(); 35 | $first_char = substr($message, 0, 1); 36 | $purechat = Server::getInstance()->getPluginManager()->getPlugin("PureChat"); 37 | $event->cancel(); 38 | if ($first_char !== "!") { 39 | if (!in_array($player->getWorld()->getFolderName(), $this->main->worldChatMgr()->getFormats())) { 40 | if ($purechat != null) { 41 | Server::getInstance()->broadcastMessage($this->main->worldChatMgr()->getFormat("default") . " " . $purechat->getChatFormat($player, $message), $player->getWorld()->getPlayers()); 42 | } else { 43 | Server::getInstance()->broadcastMessage($this->main->worldChatMgr()->getFormat("default") . " §r" . $player->getName() . " > " . $event->getMessage(), $player->getWorld()->getPlayers()); 44 | } 45 | } else { 46 | if ($purechat != null) { 47 | Server::getInstance()->broadcastMessage($this->main->worldChatMgr()->getFormat($player->getWorld()->getFolderName()) . " " . $purechat->getChatFormat($player, $message), $player->getWorld()->getPlayers()); 48 | } else { 49 | Server::getInstance()->broadcastMessage($this->main->worldChatMgr()->getFormat($player->getWorld()->getFolderName()) . " §r" . $player->getName() . " > " . $event->getMessage(), $player->getWorld()->getPlayers()); 50 | } 51 | } 52 | } else { 53 | $message_delete_char = substr($message, 1); 54 | Server::getInstance()->broadcastMessage($this->main->worldChatMgr()->getFormat("global") . " " . ($purechat != null ? $purechat->getChatFormat($player, $message_delete_char) : "§r" . $player->getName() . " > " . $message_delete_char)); 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /src/ayd1ndemirci/WorldChat/command/WorldChatCommand.php: -------------------------------------------------------------------------------- 1 | main = $main; 29 | $config = new Config($main->getDataFolder() . "command.yml", 2); 30 | parent::__construct($config->get("command"), $config->get("description")); 31 | $this->setAliases($config->get("aliases")); 32 | $this->setPermission("worldchat.perm"); 33 | } 34 | 35 | public function execute(CommandSender $sender, string $commandLabel, array $args) 36 | { 37 | if (!Server::getInstance()->isOp($sender->getName())) return; 38 | $lang_config = new Config($this->main->getDataFolder() . "lang_" . $this->main->lang . ".yml", 2); 39 | 40 | if (!isset($args[0])) { 41 | $sender->sendMessage("\n§a--------------- §l§8* §r§a---------------\n\n §a§lWORLD CHAT§r \n\n" . $lang_config->get("new-world-format") . ": §7/" . $this->getName() . " new worldName formatMessage\n" . $lang_config->get("set-format") . ": §/" . $this->getName() . " set worldName\n" . $lang_config->get("delete-format") . ": §7/" . $this->getName() . " delete worldName\n" . $lang_config->get("all-format") . ": §7/" . $this->getName() . " list\n" . $lang_config->get("see-author") . ": §7/" . $this->getName() . " author \n\n §a§lWORLD CHAT§r \n\n§a--------------- §l§8* §r§a---------------\n"); 42 | return; 43 | } 44 | 45 | if ($args[0] === "author") { 46 | $sender->sendMessage($lang_config->get("author")); 47 | return; 48 | } 49 | 50 | if ($args[0] === "list") { 51 | $formats = ""; 52 | foreach ($this->main->getData()->get("Format") as $worldName => $format) { 53 | $formats .= "§7" . $worldName . " §a format §7" . $this->main->getData()->get("Format")[$worldName]["Format"] . "§r\n"; 54 | } 55 | $sender->sendMessage("\n§a--------------- §l§8* §r§a---------------\n\n §a§lWORLD CHAT§r \n\n{$formats}\n §a§lWORLD CHAT§r \n\n§a--------------- §l§8* §r§a---------------\n"); 56 | return; 57 | } 58 | 59 | if ($args[0] === "new") { 60 | if (!isset($args[1], $args[2])) { 61 | $sender->sendMessage("§8» §cUsage: §7/" . $this->getName() . " new worldName formatMessage"); 62 | return; 63 | } 64 | $worldName = $args[1]; 65 | $format = $args[2]; 66 | if (!in_array($worldName, Server::getInstance()->getWorldManager()->getWorlds())) { 67 | if (!in_array($worldName, $this->main->worldChatMgr()->getFormats())) { 68 | $this->main->worldChatMgr()->newFormat($worldName, $format); 69 | $sender->sendMessage($lang_config->get("created-format")); 70 | } else $sender->sendMessage($lang_config->get("already-world-used")); 71 | } else $sender->sendMessage($lang_config->get("world-not-found")); 72 | } 73 | 74 | if ($args[0] === "set") { 75 | if (!isset($args[1], $args[2])) { 76 | $sender->sendMessage("§8» §cUsage: §/" . $this->getName() . " set worldName newFormat"); 77 | return; 78 | } 79 | $worldName = $args[1]; 80 | $newFormat = $args[2]; 81 | if (in_array($worldName, $this->main->worldChatMgr()->getFormats())) { 82 | $this->main->worldChatMgr()->setFormat($worldName, $newFormat); 83 | $sender->sendMessage($lang_config->get("set-format-message")); 84 | } else $sender->sendMessage($lang_config->get("world-not-found")); 85 | } 86 | 87 | if ($args[0] === "delete") { 88 | if (!isset($args[1])) { 89 | $sender->sendMessage("§8» §cUsage: §7/" . $this->getName() . " delete worldName"); 90 | return; 91 | } 92 | $worldName = $args[1]; 93 | if (in_array($worldName, $this->main->worldChatMgr()->getFormats())) { 94 | $this->main->worldChatMgr()->deleteFormat($worldName); 95 | $sender->sendMessage($lang_config->get("removed-format")); 96 | } else $sender->sendMessage($lang_config->get("format-not-found")); 97 | } 98 | 99 | } 100 | } --------------------------------------------------------------------------------