Skip to content

Commit

Permalink
Reload messages on /gpreload (#1266)
Browse files Browse the repository at this point in the history
* Reload messages on /gpreload

* Reset regex pattern on reload

* Protected, formatting fixes
  • Loading branch information
budi1200 authored Mar 9, 2023
1 parent 7bd9696 commit b953e50
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@ else if (player.hasPermission("griefprevention.adjustclaimblocks"))
}
}

private void loadMessages()
protected void loadMessages()
{
Messages[] messageIDs = Messages.values();
this.messages = new String[Messages.values().length];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public class GriefPrevention extends JavaPlugin
//log entry manager for GP's custom log files
CustomLogger customLogger;

// Player event handler
PlayerEventHandler playerEventHandler;
//configuration variables, loaded/saved from a config.yml

//claim mode for each world
Expand Down Expand Up @@ -358,7 +360,7 @@ public void onEnable()
PluginManager pluginManager = this.getServer().getPluginManager();

//player events
PlayerEventHandler playerEventHandler = new PlayerEventHandler(this.dataStore, this);
playerEventHandler = new PlayerEventHandler(this.dataStore, this);
pluginManager.registerEvents(playerEventHandler, this);

//block events
Expand Down Expand Up @@ -2654,6 +2656,8 @@ else if (cmd.getName().equalsIgnoreCase("softmute"))
else if (cmd.getName().equalsIgnoreCase("gpreload"))
{
this.loadConfig();
this.dataStore.loadMessages();
playerEventHandler.resetPattern();
if (player != null)
{
GriefPrevention.sendMessage(player, TextMode.Success, "Configuration updated. If you have updated your Grief Prevention JAR, you still need to /reload or reboot your server.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ class PlayerEventHandler implements Listener
bannedWordFinder = new WordFinder(instance.dataStore.loadBannedWords());
}

protected void resetPattern()
{
this.howToClaimPattern = null;
}

//when a player chats, monitor for spam
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
synchronized void onPlayerChat(AsyncPlayerChatEvent event)
Expand Down

0 comments on commit b953e50

Please sign in to comment.