Censorship

Discussion in 'Plugin Development' started by Zachary_Peculier, May 15, 2014.

Thread Status:
Not open for further replies.
  1. If I'm coding a censorship thing how do I prevent the message from happening, here is my current Listener file:
    Code:java
    1. package me.Zachary_Peculier.XenonMain;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.entity.Player;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.player.PlayerChatEvent;
    8.  
    9. @SuppressWarnings("deprecation")
    10. public class MyPlayerListener implements Listener
    11. {
    12. public static core plugin;
    13. @EventHandler
    14. public void onPlayerChat(PlayerChatEvent event){
    15. Player player = event.getPlayer();
    16. if(event.getMessage().toLowerCase().contains("fuck"))
    17. {
    18. player.sendMessage(ChatColor.RED + "Please don't swear, and if you have to, censor yourself.");
    19. player.setHealth(0);
    20. }
    21. }
    22. }
    23.  
     
  2. Offline

    Gamecube762

    Have you tried canceling the event?
     
  3. Offline

    PluginStudios

    Zachary_Peculier Honestly its as easy as it sounds, just set the event to cancelled.
     
  4. @PluginsStudios that's the thing I Don't know how to.

    sorry but bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  5. Offline

    AstramG

    Use event.setCancelled(true);
     
  6. Offline

    AoH_Ruthless

    If you were sorry, you would not have bumped ... Do not bump more than once every 24 hours.
     
Thread Status:
Not open for further replies.

Share This Page