Commands Logger

Discussion in 'Plugin Development' started by Straiker123, Nov 15, 2018.

Thread Status:
Not open for further replies.
  1. Hello I have this problem .. my plugin registers to YML commands I would like to disable but i do not know how .. authme
    otherwise something for information .. my plugin works smoothly so errory and warny are not getting any
    here is class:

    Code:
    package Loggers;
    
    import java.io.BufferedWriter;
    import java.io.FileWriter;
    import java.util.Calendar;
    import java.util.Date;
    
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerCommandPreprocessEvent;
    
    public class CommandListener implements Listener {
       
        public Main plugin;
       
        public CommandListener(Main instance) {
            plugin = instance;
        }
        @EventHandler
        public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
            String playername = event.getPlayer().getName();
            String msg = event.getMessage();
            Date time = Calendar.getInstance().getTime();
            try {
                FileWriter fw = new FileWriter(plugin.cmdLog, true);
                BufferedWriter bw = new BufferedWriter(fw);
                bw.write(playername+ " >>> "+time+" >>> "+msg);
                bw.newLine();
                fw.flush();
                bw.close();
            } catch(Exception e) {
                e.printStackTrace();
            }
        }
       
    }
    
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Eh authme registers players and protects their accounts with a password but my plugin registers to YML and authme folder .. / l [password] and / reg [helslo] [helslo] .. i need to disable but i do not know how: /
     
  4. Offline

    timtower Administrator Administrator Moderator

    @Straiker123 But why do you need it? Minecrafts authentication handles that already.
     
  5. but because it registers authme .. and I do not want to register ... here is an example from my plugin: Straiker123 >>> Thu Nov 15 21:06:17 CET 2018 >>> /reg ggh4441 ggh4441 from CommandLogger
     
  6. Offline

    timtower Administrator Administrator Moderator

    @Straiker123 Question was about authme.
    Why do you need that plugin?
     
  7. I do not even know I just enjoy it

    now I thought to try this: if player sendMessage (/ l [args [0]);
    but I do not know what to do with it .D

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 16, 2018
  8. Offline

    timtower Administrator Administrator Moderator

    Then just remove it if you don't need it.
     
  9. ok

    all I need to ignore those commands ..(message)

    well i got it right now :/

    Code:
    package Loggers;
    
    import java.io.BufferedWriter;
    import java.io.FileWriter;
    import java.util.Calendar;
    import java.util.Date;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerCommandPreprocessEvent;
    
    public class CommandListener implements Listener {
     
        public Main plugin;
     
        public CommandListener(Main instance) {
            plugin = instance;
        }
        public boolean onCommand(CommandSender s, Command command, String label,String[] args) {
            Player p = (Player) s;
            p.sendMessage ("/ l "+args[0]);
            return true;
        }
        @EventHandler
        public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
            String playername = event.getPlayer().getName();
            String msg = event.getMessage();
            Date time = Calendar.getInstance().getTime();
            try {
                FileWriter fw = new FileWriter(plugin.cmdLog, true);
                BufferedWriter bw = new BufferedWriter(fw);
                bw.write(playername+ " >>> "+time+" >>> "+msg);
                bw.newLine();
                fw.flush();
                bw.close();
            } catch(Exception e) {
                e.printStackTrace();
            }
        }
     
    }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 16, 2018
  10. Offline

    timtower Administrator Administrator Moderator

    @Straiker123 Do you need to ignore the commands when the plugin that has them is gone?
     
  11. but it's all I need to ignore another plugin named Authme Reloaded
     
  12. Offline

    timtower Administrator Administrator Moderator

    @Straiker123 Remove the plugin, minecrafts authentication already handles that stuff.
    You don't need it.
     
  13. eg a player will write a command / register [password] [password] and the event will not register .. it will ignore it

    but I do not need to make those commands my plugin ignore it's all ..

    NEED help please
     
    Last edited: Nov 18, 2018
Thread Status:
Not open for further replies.

Share This Page