Chat plugin isn't doing what it should.

Discussion in 'Plugin Development' started by sunsetparkjedi, Jul 5, 2012.

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

    sunsetparkjedi

    Here is my code sorry I wasn't very specific in my last post.


    package net.sourceforge.sunsetparkjedi.AntiCurse;
    import java.util.Scanner;
    import org.bukkit.plugin.java.JavaPlugin;


    public class main extends JavaPlugin {
    public void onEnable()
    {
    getLogger().info("AntiCurse has been enabled!");
    }
    public void onDisable()
    {
    getLogger().info("AntiCurse has been disabled.");
    }
    public void anticurse()
    {
    Scanner input = new Scanner (System.in);
    String f1 = "fuck";
    String f2 = "f u c k";
    String f3 = "f.u.c.k";
    String f4 = "f-u-c-k";
    String c1 = "crap";
    String c2 = "c r a p";
    String c3 = "c.r.a.p";
    String c4 = "c-r-a-p";
    String d1 = "damn";
    String d2 = "d a m n";
    String d3 = "d.a.m.n";
    String d4 = "d-a-m-n";
    String b1 = "bitch";
    String b2 = "b i t c h";
    String b3 = "b.i.t.c.h";
    String b4 = "b-i-t-c-h";
    String b5 = "bastard";
    String b6 = "b a s t a r d";
    String b7 = "b.a.s.t.a.r.d";
    String b8 = "b-a-s-t-a-r-d";
    String s1 = "shit";
    String s2 = "s h i t";
    String s3 = "s.h.i.t";
    String s4 = "s-h-i-t";
    int x = 10;
    String line;

    while (x==10)
    {
    line = input.nextLine();
    if (line.equalsIgnoreCase(f1))
    {
    line = "***k";
    }
    else if (line.equalsIgnoreCase(f2)){
    line = "***k";
    }
    else if (line.equalsIgnoreCase(f3)){
    line = "***k";
    }
    else if (line.equalsIgnoreCase(f4)){
    line = "***k";
    }
    else if (line.equalsIgnoreCase(c1)){
    line = "***p";
    }
    else if (line.equalsIgnoreCase(c2)){
    line = "***p";
    }
    else if (line.equalsIgnoreCase(c3)){
    line = "***p";
    }
    else if (line.equalsIgnoreCase(c4)){
    line = "***p";
    }
    else if (line.equalsIgnoreCase(d1)){
    line = "***n";
    }
    else if (line.equalsIgnoreCase(d2)){
    line = "***n";
    }
    else if (line.equalsIgnoreCase(d3)){
    line = "***n";
    }
    else if (line.equalsIgnoreCase(d4)){
    line = "***n";
    }
    else if (line.equalsIgnoreCase(b1)){
    line = "****h";
    }
    else if (line.equalsIgnoreCase(b2)){
    line = "****h";
    }
    else if (line.equalsIgnoreCase(b3)){
    line = "****h";
    }
    else if (line.equalsIgnoreCase(b4)){
    line = "****h";
    }
    else if (line.equalsIgnoreCase(b5)){
    line = "******d";

    }
    else if (line.equalsIgnoreCase(b6)){
    line = "******d";
    }
    else if (line.equalsIgnoreCase(b7)){
    line = "******d";
    }
    else if (line.equalsIgnoreCase(b8)){
    line = "******d";
    }
    else if (line.equalsIgnoreCase(s1)){
    line = "***t";
    }
    else if (line.equalsIgnoreCase(s2)){
    line = "***t";
    }
    else if (line.equalsIgnoreCase(s3)){
    line = "***t";
    }
    else if (line.equalsIgnoreCase(s4)){
    line = "***t";
    }
    else{
    }
    }
    }

    }
    If anyone can tell me why this won't work can they please tell me.
     
  2. you never handling the chat events
     
  3. Offline

    McLuke500

    Read this fully
    http://wiki.bukkit.org/Plugin_Tutorial

    And also why not make it simpler
    such as



    @Override
    public void onEnable() {
    LoadConfiguration();
    System.out.println(this+" has been Disabled");
    }

    @Override
    public void onDisable() {
    System.out.println(this+" has been Disabled");
    }



    public void LoadConfiguration() {
    List<String> words = new ArrayList<String>();
    words.add("7");
    words.add("46");
    words.add("57");

    String path1 = "AntiCurse.Blocked Words";
    getConfig().addDefault(path1, words);
    getConfig().options().copyDefaults(true);
    saveConfig();
    }


    @EventHandler(priority = EventPriority.NORMAL)
    public void onPlayerChat(PlayerChatEvent event) {
    Player player = event.getPlayer();
    String msg = event.getMessage();
    if (!player.hasPermission("AntiCurse.bypass"){
    for (String m : plugin.getConfig().getStringList("AntiCurse.Blocked Words")) {
    if (msg.contains(m)) {
    msg = msg.replaceall(m, "*******")
    e.setMessage(msg)
    }}}

    Written off by heart so might be wrong but should be ok.
     
  4. its not needed to print messages ondisable/enable, as bukkitdoes this already
     
  5. Offline

    McLuke500

    Oh yeah I remember reading that on Vacoselogging thingy
     
  6. Offline

    pd9937

    Besides, the plugin won't stop anyone from flaming.
    You need to try all possible combinations by removing all points, spaces,... from the line.
    Now every player still can say "f uck", "b.itch" or "shi-t". Most players are creative enough to figure this out in a very small amount of time :)
     
    ferrybig likes this.
Thread Status:
Not open for further replies.

Share This Page