onMoveEvent help

Discussion in 'Plugin Development' started by linkkwtf, Jul 21, 2012.

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

    linkkwtf

    hey guys i need help, im creating a afk plugin, this is my first so i dont know that mutch but i wanted to make so if u stand still for about 1 min u get a broadcastmsg out, for example "player" is now afk! and when u move again it comes up "player" is back! and as u may see down in the sourcecode, it's not in the main. please help me:D

    Code:
    package me.linkkwtf.SimpleChat;
     
    import java.util.ArrayList;
     
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
     
    public class Afk implements CommandExecutor{
        private ArrayList<String> afkPlayers = new ArrayList<>();
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
            Player player = (Player) sender;
     
            if(commandLabel.equalsIgnoreCase("Afk")){
                if(player.hasPermission("SimpleChat.afk"))
                if (afkPlayers.contains(player.getName())){
                    afkPlayers.remove(player.getName());
                    player.getServer().broadcastMessage(ChatColor.DARK_GRAY + player.getName() + " is not " + ChatColor.GOLD + "afk" + ChatColor.DARK_GRAY + " anymore!");
                }else{
                    afkPlayers.add(player.getName());
                    player.getServer().broadcastMessage(ChatColor.DARK_GRAY + player.getName() + " is " + ChatColor.GOLD + "afk!");
                }else{
                    player.sendMessage(ChatColor.DARK_RED + "You do not have permission!");
                }
            }
            return false;
        }
    }
    
     
  2. go to the tresources section, look for the afk events, and add listeners for them inside your plugin(and send messages)
     
  3. Offline

    linkkwtf

    im sorry but i feel like such a noob saying this but didnt really find any part doing what i want or explaining it, just saw that part with the ticks but, dont know how to get the ticks working with onMoveEvent witch i barly get :confused:
     
  4. mayby this explains what you need to know
     
  5. Offline

    pzxc

    Essentials can auto-afk you on a specified time period (I use 15 minutes but you can set it to 1 minute). It can even autokick you after you have been afk for so long (I use 30 minutes)... this makes it so afk players aren't taking up slots
     
  6. Offline

    linkkwtf

    thanks:D
    Where did u find the source code for that?:confused:
     
Thread Status:
Not open for further replies.

Share This Page