[HELP NOW] Hello Command To Chat?

Discussion in 'Spigot Plugin Development' started by ItzRez, Jul 9, 2015.

  1. Use events PlayerAsyncChatEvent and check if the message gg is

    @MrARC oops didn't saw your post
  2. Can You Give Me An Example Not To Sure Where To Put #event.getMessage().contains("gg");
  3. In a EventHandler with the event AsyncPlayerChatEvent
  4. you have skype? so you can help me more?
  5. JustThiemo

    JustThiemo Previously TrinityDEV

    Well, learn how to use events, there are a lot of tutorials out there, go watch them and then try something.
    • Agree Agree x 1
  6. What you are looking for here, is, like our colleagues @MrARC , and @DaanSander have already stated, an AsyncPlayerChatEvent. I have no intention of spoon feeding you the code for your plugin, seeing as it would get you nowhere in the field of programming. I will however show you how to use it. For instance;

    Code (Text):
    public void onPlayerSpeak(AsyncPlayerChatEvent e)
    Player p = e.getPlayer();
    // Do whatever you wish to do.
    HINT: Don't forget to implement the Listener in the class you're using the code in, aswell as registering it in your Main class.
  7. Or you can do it like this.

    Code (Text):

        public void onEnable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + "Has Been Enabled");
            getServer().getPluginManager().registerEvents(this, this);
        public void onDisable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info(pdfFile.getName() + "Has Been Disabled");

        public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String[] args) {

            final Player pl = (Player) sender;




    Remember than your plugin.yml shuld look like this, or it wont work:

    Code (Text):
    name: PluginName
    main: me.rez.karma.main
    version: 1.0
    description: >
                 hello command
        description: Sends a hello message
  8. He said he didn't want it as a command..
  9. I don't think he wanted it to be a command.
  10. I just want to comment on your title, what makes this so important that it needs [HELP NOW] as appose to just posting a normal title?

    Listen for the chat event then check if the message is what ever you're looking for.
    • Like Like x 1
  11. Why in fucks name are you spoon feeding him? He is clearly inexperienced in Java, and spoon feeding him code won't help.
  12. With all due respect, I haven't fed him anything. I simply showed him how to approach that method, I didn't write his code.
  13. You gave him a listener with code, all he'll do is copy it and then ask for what goes in the if statement, he learns nothing from it
  14. Chill dude.
  15. Split the player message in words (Using String.split(" ")) instead of checking if the message contains "gg" to avoid giving Karma to people who says something like "This server is lagging"