Silent Player Join

Discussion in 'Spigot Plugin Development' started by TheGamingChris, Dec 28, 2018.

  1. Hey everyone,

    I want to have an config (which already generated itself) where I can edit which player have a join message (normal join) and which player havn't a join message (silent join)

    Code (Java):
    public class JoinListener implements Listener{
        public void onPlayerJoin(PlayerJoinEvent event) {
            Player p = event.getPlayer();
            String player = event.getPlayer().getName();
            FileConfiguration config = Main.getPlugin().getConfig();
            if(config.isSet("silentjoin." + player)) {
                if(config.getBoolean("silentjoin." + player) == true) {
                } else if(config.getBoolean("silentjoin." + player) == false) {
                    event.setJoinMessage("§3Der Spieler §6" + player + " §3ist dem Spiel beigetreten");
            } else {
                config.set("silentjoin." + player, false);
                event.setJoinMessage("§3Der Spieler §6" + player + " §3ist dem Spiel beigetreten");
                p.sendMessage("§6Configeintrag gesetzt");

    Code (Text):
      TheGamingChris: true
    it doesn't get any errors, but it ignores if it is true or false. Everytime comes the custom join message. But why?

    I hope you can help me

  2. drives_a_ford


    Just use a permission that certain players have and others don't.
  3. Yes, but I want that the players could toggle it if they want to have a join message or not.
  4. drives_a_ford


    Then you could remove the permission or add a negated one (in case the permission is inherited) when the command is issued.
  5. Just have a string list with all the names, why bother making useless sections with 4 values? (false, true, path exists, path doesn't exist). Just have a string list and you will be able to use FileConfiguration#getStringList("....")#contains("your name").
  6. drives_a_ford


    Even then, I'd suggest using UUIDs as the player's name can change.
    • Agree Agree x 1