2 things need help coding

Discussion in 'Plugin Development' started by H1DD3NxN1NJA, Nov 21, 2017.

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

    H1DD3NxN1NJA

    Hello, i was wondering, how could i code it so when a player does something like curses in chat for an anti-swear plugin, a command is executed from console, and the player can choose what command they want executed through the config.yml.
    ass is a curse word, the player that owns the plugin put the command as

    #Command thats executed when a player curses in chat
    CommandEnabled: true
    command: /lightning

    when the player curses the /lightning takes effect and smites the player, how would i code that?

    also, when the player curses in chat, how could i make it so they get an potion effect that the player chooses in the config.yml?
    like the player says "ass" and the command is executed as well as the potion effect

    #Potion effect the player will receive when he curses in chat
    EffectsEnabled: true
    Effect: CONFUSION
     
  2. Offline

    Blares

    well it isn't that hard :/
    Code:
    @EventHandler
    public void onChat(AsyncPlayerChatEvent e) {
    
         Player p = e.getPlayer();
         if (e.getMessage().contains("ass") {
    
          e.setCancelled(true);
    
         
         World w = p.getWorld();
    
         w.strikeLightning(p.getLocation());
    
             }
    
        }
    }
    
    
    if you want to make it multiple words you do

    Code:
    
    @EventHandler
    public void onChat(AsyncPlayerChatEvent e) {
    
         Player p = e.getPlayer();
         if (e.getMessage().contains("ass") {
    
            e.setCancelled(true);
         World w = p.getWorld();
    
         w.strikeLightning(p.getLocation());
    
             }else if (e.getMessage().contains("ez") {
    
            e.setCancelled(true);
         World w = p.getWorld();
    
         w.strikeLightning(p.getLocation());
    
          }else (do it all over again);
    
        }
    }
    
    just keep on doing else if and you should have a whole list of filters. Another good idea is to just get a list from config.yml but I think i've spoonfed you enough today. peace

    Blares();
     
  3. Offline

    MightyOne

    @Blares a good coder can give you an example, a better one can explain to you it without code xD
     
    Last edited: Nov 22, 2017
  4. Offline

    Blares

    hm thanks for advice il fix up l8r
     
  5. Offline

    H1DD3NxN1NJA

    well, i want it to the player can choose what command they want executed in the config when they say any of the words in the banned list config
    and how about the potion effect they can get in the config?
    Code:
    if (bw.getStringList("Banned-Words").contains(word)) {
               e.setCancelled(true);
    
     
  6. Offline

    Blares

    Are you serious?

    Code:
    
    config:
    
    badwordcommand:
        command: /kill
    
    
    class:

    Code:
    
    if get Message is bad word then {
      
      String command = mainClass.getPlugin().getConfig("path");
      Player p = e.getPlayer();
       p.chat(command);
    
    }
     
  7. Make an array inside your config, along with a string for the command to run. On the player chat event if the player says a word that is inside the config, get the Bukkit console sender and send the command, or in your case check if the boolean is true in the config and add the potion effects.

    --

    Also, most custom anti-swear plugins don't work and are easily bypassed. Even some of the biggest Minecraft servers get easily bypassed with dashes or spaces, etc...
     
Thread Status:
Not open for further replies.

Share This Page