Skip to content

Commit

Permalink
Fix message still displayed with Deluxechat
Browse files Browse the repository at this point in the history
  • Loading branch information
EpiCanard committed Jun 27, 2023
1 parent d01950e commit e858400
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fr.freebuild</groupId>
<artifactId>shutup</artifactId>
<version>0.3</version>
<version>0.4</version>
<name>ShutUp</name>
<description>Plugin to prevent player to speak in chat</description>

Expand Down
21 changes: 11 additions & 10 deletions src/main/java/fr/freebuild/shutup/ShutUp.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ public void onEnable() {
this.logger.setDebug(getConfig().getBoolean("debug", false));

getCommand("shutup").setExecutor(this);

Bukkit.getServer().getPluginManager().registerEvents(this, this);
}

public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
this.logger.debug("Execute command /shutup reload");

if (sender.isOp()) {
this.logger.debug("Player is op");

if (args.length > 0 && args[0].equals("reload")){
this.logger.info("Reloading the config...", sender);
this.reloadConfig();
Expand All @@ -44,18 +44,19 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
this.logger.debug("Player is NOT op");
sender.sendMessage("You don't have permission to do that !");
}

return false;
}
@EventHandler(priority=EventPriority.HIGHEST)
public void onPlayerSendChatMessage(final AsyncPlayerChatEvent apce) {

@EventHandler(priority=EventPriority.LOW)
public void onPlayerSendChatMessage(final AsyncPlayerChatEvent event) {
this.logger.debug("Player trying to send message in chat");
final Player player = apce.getPlayer();
final Player player = event.getPlayer();

if (player != null && player.hasPermission("shutup") && !player.isOp()) {
this.logger.debug("The player is not allowed to send message in chat");
apce.setCancelled(true);
event.setMessage(null);
event.setCancelled(true);
player.sendMessage(ChatColor.RED + this.getConfig().getString("message", "Not allowed"));
}
}
Expand Down

0 comments on commit e858400

Please sign in to comment.