How do I edit chat messages.

Discussion in 'Plugin Development' started by Mike111177, May 19, 2012.

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

    Mike111177

    I really need help finding out how to censor bad words.
    here is what i have so far
    Code:
    package net.othercraft.steelsecurity.listeners;
     
    import java.util.List;
    
    import net.othercraft.steelsecurity.Config;
    import net.othercraft.steelsecurity.Main;
    
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.*;
     
    public class PlayerChatListener implements Listener {
    	
    public Main plugin;
    	
    	public PlayerChatListener(Main instance) {	
    		plugin = instance;
    	}	
    
    	@EventHandler
        public void onPlayerchat(PlayerChatEvent event) {
    		String Listpath = "AntiSpam.Censoring.Enabled";
    		 List<?> list = new Config(plugin).getConfigurationList(Listpath);
    	}
    }
    
    and
    Code:
    package net.othercraft.steelsecurity;
    
    import java.util.Arrays;
    import java.util.List;
    
    public class Config {
    	
    	public Main plugin;
    	
    	public Config(Main instance) {	
    		plugin = instance;
    	}	
    	
    	public void loadConfiguration() {
    		plugin.getConfig().addDefault("AntiSpam.Censoring.Enabled", false );
    		plugin.getConfig().addDefault("AntiSpam.Censoring.Block_Words", Arrays.asList("Nodus", "Avo", "ICHG"));
    		plugin.getConfig().options().copyDefaults(true); // NOTE: You do not have to use "plugin." if the class extends the java plugin
    		plugin.saveConfig();
    	}	
    	public List<?> getConfigurationList(String Listpath) {
    		List<?> list = plugin.getConfig().getList(Listpath);
    		return list;
    	}
    	public void getConfigurationString(String Stringpath){
    		plugin.getConfig().getString(Stringpath);
    	}
    	public void getConfigurationBoolean(String Booleanpath) {
    		plugin.getConfig().getBoolean(Booleanpath);
    	}
    	public void getConfigurationInt(String Intpath) {
    		plugin.getConfig().getInt(Intpath);
    	}
    }
    
    How do i get this too work?
     
  2. Offline

    Lolmewn

    But.. But..
    there already are loads of plugins that do this!
     
  3. Offline

    Mike111177

    yeah im making my own that does that and more

    Bump*

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  4. Offline

    SirTyler

    [​IMG]
    Nijikokun Made this post a long time ago yet no one seems to learn.
     
    charries96, Iron_Crystal and Technius like this.
  5. Offline

    Mike111177

    fuck off
     
  6. Offline

    SirTyler

    [​IMG]



    Seriously though, we don't need every Tom, Dick, and Harry to make the same plugin over and over again with minor changes. Its fine for a learning experience but we don't need them filling up the forums and BukkitDev.
     
    Technius and Iron_Crystal like this.
  7. Offline

    Mike111177

    This is different got to http://dev.bukkit.org/server-mods/steel-security/
     
  8. Offline

    SirTyler

    From the looks of it your just taking all the current security tools and putting them into one plugin. That being said I am not saying you shouldn't do it, but something where you are just replacing messages as a plugin in of itself you shouldn't make a new one as there are too many already. (Also it will never be 100% secure)
     
  9. Offline

    r0306

    Mike111177
    Code:
    String message = event.getMessage().replaceAll("bad word here", "word to replace with");
    event.setMessage(message);
     
  10. Offline

    Mike111177

    I can try my best :)
    Thank you for some real help illsee if that works.
     
Thread Status:
Not open for further replies.

Share This Page