Whitelist.

Discussion in 'Spigot Plugin Development' started by ProJoosh, May 27, 2015.

  1. How would i live Enable / Disable the whitelist, ive tried Bukkit.getServer().setWhitelist(false); but it dosnt seem to be working.
     
  2. No errors
     
  3. Are you sure the method is being called? The code should look like this:

    Code (Text):
    public void onEnable(){
       Bukkit.getServer().setWhitelist(false);
    }
     
  4. its not in the on enable, does it have to be.
     
  5. No... As long as the method is being called. You are using the default whitelist right?
     
  6. You can call Bukkit.setWhitelist() instead of Bukkit.getServer().setWhitelist().
     
  7. True... Is there a posibility that the method is located within the Server rules... I don't think so...

    Also make sure that the whitelist isn't already disabled.
    -- If you could post some code we better assist you @ProJoosh
     
  8. Code (Text):
        //Start Game
        protected void startGame() {
            int playerSize = Bukkit.getOnlinePlayers().size();
            int actualSize = playerSize - 1;
            for (Player player : Bukkit.getOnlinePlayers()) {
                players.add(player.getUniqueId());
                points.put(player.getUniqueId(), pointsStart);
                setup(player);
                sendTitle(player, ChatColor.GOLD + "GO! GO! GO!", ChatColor.GOLD + "The game has started!", 2,2,1);
                player.playSound(player.getLocation(), Sound.LEVEL_UP, 30, 30);
                player.setLevel(0);
                randomSpawn(player);
            }
            Bukkit.broadcastMessage(ChatColor.GOLD + "The games have started. Go Go Go!");
            playersOn = actualSize + 1;
            setState(GameState.IN_GAME);
            updateScoreboard();
            Bukkit.getServer().setWhitelist(true);
        }
     
  9. Code (Text):
        boolean started = false;
        //Start Game
        protected void startGame() {
            int playerSize = Bukkit.getOnlinePlayers().size();
            int actualSize = playerSize - 1;
            for (Player player : Bukkit.getOnlinePlayers()) {
                players.add(player.getUniqueId());
                points.put(player.getUniqueId(), pointsStart);
                setup(player);
                sendTitle(player, ChatColor.GOLD + "GO! GO! GO!", ChatColor.GOLD + "The game has started!", 2,2,1);
                player.playSound(player.getLocation(), Sound.LEVEL_UP, 30, 30);
                player.setLevel(0);
                randomSpawn(player);
            }
            Bukkit.broadcastMessage(ChatColor.GOLD + "The games have started. Go Go Go!");
            playersOn = actualSize + 1;
            setState(GameState.IN_GAME);
            updateScoreboard();
            started = true;
        }
        @EventHandler
        public void playerLoginEvent(PlayerLoginEvent e){
            if(started)e.disallow(Result.KICK_OTHER, "Game in progress.");
        }
     
    • Winner Winner x 1
  10. ^ You're setting the WhiteList to true here.

    ^ Use this, it'll work and let you customize the Kick message (Preferred choice)
     
  11. what am i ment to import for "Result."
     
  12. import org.bukkit.event.player.PlayerLoginEvent.Result;
     
  13. Code (Text):
        //Disalow players joining if ingame
        @EventHandler
        public void playerLoginEvent(PlayerLoginEvent e){
            if(getState() == GameState.IN_GAME)e.disallow(Result.KICK_OTHER, ChatColor.RED + "Sorry!" + ChatColor.GOLD + " A Game in progress.");
        }
     
  14. Yeah thats it!
     
    • Like Like x 1
    • Agree Agree x 1