Skip to content

Commit

Permalink
Reload Feature: Next Feature
Browse files Browse the repository at this point in the history
  • Loading branch information
xwertxy committed Dec 6, 2023
1 parent 345b01d commit 48696d8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ command-warning-message: "&e{player_name} &cwas successfully executed command du
# You can make your own pull request for more languages.
# If you create a pull request, you need to comply with international standard ISO 639-2 language code
# List of ISO 639-2 language codes: https://www.loc.gov/standards/iso639-2/php/code_list.php
# Available languages: eng (English), vie (Vietnamese), deu (German).
# Available languages: eng (English)
lang: eng

# Max Violation
Expand Down
3 changes: 3 additions & 0 deletions resources/languages/eng.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ui-pf-manage-description: "&bYou can manage here."
ui-pf-manage-button-1: "&aView Banned Words"
ui-pf-manage-button-2: "&eToggle Protection"
ui-pf-manage-button-3: "&bAdd Banned Words"
ui-pf-manage-button-4: "&eReload"
ui-pf-manage-button-exit: "&4Exit"
ui-pf-manage-button-return: "&cReturn"
ui-pf-manage-actions-button-remove: "&4Remove"
Expand All @@ -51,4 +52,6 @@ profanity-command-added-word: "&aThe word has been added. Please restart your se
ui-pf-addform-specify: "&cPlease specify the word do you want to be added."
ui-pf-addform-description: "&7Type here the word do you want to add to the list."
ui-pf-addform-example: "Ex. nigg3r, fuck3r, etc.."
profanity-ui-reload-complete: "&eSuccessfully reloaded all configurations!"
profanity-command-reload-complete: "&aSuccessfully reloaded all configurations!"
...
11 changes: 11 additions & 0 deletions src/ReinfyTeam/ProfanityFilter/Command/DefaultCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ public function execute(CommandSender $sender, string $commandLabel, array $args
PluginUtils::addProfanityWord($args[1]);
$sender->sendMessage($this->language->translateMessage("profanity-command-added-word"));
break;
case "reload":
$this->plugin->getProfanity(true);
$this->plugin->getConfig()->reload();
$sender->sendMessage($this->language->translateMessage("profanity-command-reload-complete"));
break;
default:
$sender->sendMessage($this->language->translateMessage("profanity-command-usage-execute"));
break;
Expand Down Expand Up @@ -172,6 +177,11 @@ private function sendForm(Player $player, bool $added = false) {
case 2:
$this->addProfanityWordForm($player);
break;
case 3:
$this->plugin->getProfanity(true);
$this->plugin->getConfig()->reload();
$player->sendMessage($this->language->translateMessage("profanity-ui-reload-complete"));
break;
default:
break;
}
Expand All @@ -186,6 +196,7 @@ private function sendForm(Player $player, bool $added = false) {
$form->addButton($this->language->translateMessage("ui-pf-manage-button-1"));
$form->addButton($this->language->translateMessage("ui-pf-manage-button-2"));
$form->addButton($this->language->translateMessage("ui-pf-manage-button-3"));
$form->addButton($this->language->translateMessage("ui-pf-manage-button-4"));
$form->addButton($this->language->translateMessage("ui-pf-manage-button-exit"));
$player->sendForm($form);
}
Expand Down
10 changes: 5 additions & 5 deletions src/ReinfyTeam/ProfanityFilter/EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function onChat(PlayerChatEvent $event) : void {
$player->getServer()->getNameBans()->addBan($player->getName(), "Profanity", $this->duration[0], $player->getServer()->getName());
$player->kick(InfoAPI::render($this->plugin, PluginUtils::colorize($this->plugin->getConfig()->get("kick-message")), [
"player" => $player,
"type" => $punishType,
"type" => $punishType . "ed",
], $player));
$this->plugin->getLogger()->warning(InfoAPI::render($this->plugin, PluginUtils::colorize($this->plugin->getConfig()->get("ban-warning-message")), [
"player" => $player,
Expand All @@ -115,7 +115,7 @@ public function onChat(PlayerChatEvent $event) : void {
$this->plugin->punishment[$player->getName()] = isset($this->plugin->punishment[$player->getName()]);
$player->kick(InfoAPI::render($this->plugin, PluginUtils::colorize($this->plugin->getConfig()->get("kick-message")), [
"player" => $player,
"type" => $punishType,
"type" => $punishType . "ed", //why??
], $player));
$this->plugin->getLogger()->warning(InfoAPI::render($this->plugin, PluginUtils::colorize($this->plugin->getConfig()->get("kick-warning-message")), [
"player" => $player,
Expand All @@ -125,9 +125,9 @@ public function onChat(PlayerChatEvent $event) : void {
case "command":
$this->plugin->punishment[$player->getName()] = isset($this->plugin->punishment[$player->getName()]);
$this->plugin->getLogger()->warning(InfoAPI::render($this->plugin, PluginUtils::colorize($this->plugin->getConfig()->get("command-warning-message")), [
"player" => $player,
"player_name" => $player->getName(), // backwards compatibility
]));
"player" => $player,
"player_name" => $player->getName(), // backwards compatibility
]));
if((bool)$this->plugin->getConfig()->get("execute-as-player")){
$this->plugin->getServer()->dispatchCommand($player, $this->plugin->getConfig()->get("command"));
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/ReinfyTeam/ProfanityFilter/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ private function checkUpdate() : void {
/**
* Get Profanity List. Do not call it directly.
*/
public function getProfanity() : Config {
public function getProfanity(bool $reload = false) : Config {
if($this->profanity === null) $this->profanity = new Config($this->getDataFolder() . "profanity.yml", Config::YAML);
if($reload) $this->profanity->reload();

return $this->profanity;
}
Expand Down

0 comments on commit 48696d8

Please sign in to comment.