[ADMN] ChatColorBlock v1.0 - Block "§" chats [1.1-R4-R5]

Discussion in 'Inactive/Unsupported Plugins' started by Smex, Feb 25, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Smex

    This plugin prevents players creating chatmessages with
    colored content using the § symbol.

    Features:
    - Blocks § formatted colored chatmessages.
    - Drag&Drop the jar into the plugins folder and done.
    - Permissions.

    Permissions:
    - 'ccb.use', player with this permissions can use the § symbol.

    Download 1.0
    Source (open)
    Code:java
    1. package TheEnd.XemsDoom;
    2. import org.bukkit.ChatColor;
    3. import org.bukkit.entity.Player;
    4. import org.bukkit.event.EventHandler;
    5. import org.bukkit.event.Listener;
    6. import org.bukkit.event.player.PlayerChatEvent;
    7. import org.bukkit.plugin.PluginDescriptionFile;
    8. import org.bukkit.plugin.PluginManager;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10.  
    11.  
    12. public class ChatColorBlock extends JavaPlugin implements Listener{
    13.  
    14. private PluginDescriptionFile desc;
    15. private PluginManager pm;
    16. private Listener listener;
    17.  
    18. @Override
    19. public void onDisable() {
    20. System.out.println(String.format("[%s] v%s is disabled", desc.getName(), desc.getVersion()));
    21. }
    22.  
    23. @Override
    24. public void onEnable() {
    25. desc = getDescription();
    26. pm = getServer().getPluginManager();
    27.  
    28. listener = new ChatColorBlock();
    29. pm.registerEvents(listener, this);
    30.  
    31. System.out.println(String.format("[%s] v%s is enabled", desc.getName(), desc.getVersion()));
    32. }
    33.  
    34. @EventHandler
    35. public static void onColorChat(PlayerChatEvent event){
    36.  
    37. Player player = event.getPlayer();
    38.  
    39. if(player.hasPermission("ccb.use"))
    40. return;
    41.  
    42. String message = event.getMessage();
    43.  
    44. if(message.contains("§")){
    45. event.setCancelled(true);
    46. player.sendMessage(ChatColor.RED + "You are not allowed to write colored");
    47. }
    48. }
    49.  
    50. }

    Changelog:
    - 1.0 : Release
     
  2. Offline

    TnT Retired Staff

    Locked per request by author.
     
Thread Status:
Not open for further replies.

Share This Page