check for a players number to do something

Discussion in 'Plugin Development' started by xKing_MC, Feb 29, 2016.

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


    Hello , I'm really new in developing and I really need help
    so , I want to make a the plugin so if there was less than 8 players in the server it will say " Bla bla bla"

    and if there was 8 players or more it will say " Cool Bla bla bla !!"

    here's my code

    package me.test;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.GameMode;
    import org.bukkit.Location;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    public class Test1 extends JavaPlugin implements Listener {
        public void onEnable() {
            getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&aThe plugin is working !"))
            Bukkit.getServer().getPluginManager().registerEvents(this, this); }
        public void onDisable() {
            getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&cThe plugin isn't working any more"));}
        public void onPlayerJoin(final PlayerJoinEvent event) {
            event.getPlayer().teleport(new Location(Bukkit.getServer().getWorld("world"), 309, 76, 154));
            event.setJoinMessage(ChatColor.translateAlternateColorCodes('&', "&bTesting Plugin &8ยป &a" + event.getPlayer().getName() + ChatColor.GOLD + " Joind the game !"));
    thanks !
  2. Offline


    Is this actually how your code looks? @xKing_MC

    I'm jewelry judging it or anything just trying to help.
    Last edited: Feb 29, 2016
  3. Offline


    Looks like a troll to be honest.
  4. Offline


  5. Offline


    I'm talking about OP. He's seemingly made no attempt to develop the plugin he wants and has just thrown a load of random methods calls into his event listener.
  6. Offline


    You need to get how many players online the server has, then compare if it is less than 8,

    Bukkit.getServer().getOnlinePlayers().size() < 8

    otherwise send cool blabla bla message
Thread Status:
Not open for further replies.

Share This Page