Remove strings from Ban Display (using Bukkit.getBanList(..).addBan )

Discussion in 'Spigot Plugin Development' started by Bart_, May 11, 2016.

  1. Hello guys,
    I have to use the method Bukkit.getBanList(BanList.Type.NAME).addBan(target, reason, expiration, bywho) but i noticed this problem:
    [​IMG]

    As you can see in the photo, i have to remove the string "You are banned from this server" and the string "Your part will be remove..."

    The problem is, HOW?

    Thanks :)
     
  2. In the PlayerLoginEvent you can check if event.getResult() == Result.KICK_BANNED and if so use the setKickMessage method to specify your own message.
     
    • Useful Useful x 1
  3. Ok thanks, i try it :)


    ==========

    UPDATE:
    How can i get the BanEntry of a player, and the Expiration Date of this player?
    https://hub.spigotmc.org/javadocs/spigot/org/bukkit/BanEntry.html
     
    #3 Bart_, May 11, 2016
    Last edited: May 11, 2016
  4. Can't find a solution for the Expiration Date :/


    EDIT:

    I have found!
     
    #4 Bart_, May 11, 2016
    Last edited: May 11, 2016
  5. Ok guys, it seems essentials still override my method.
    How to solve? It is full working, in the console i can see the kick but it happens after the essentials ban.

    Code (Text):

        @EventHandler(priority = EventPriority.HIGH)
        public void OnPlayerJoin(PlayerLoginEvent event) {
            if (event.getResult() == Result.KICK_BANNED) {
                Player player = event.getPlayer();
                if (Bukkit.getBanList(BanList.Type.NAME).isBanned(player.getName()) == true) {
                    Date Expiration = getExpiration(player);
                    Log.info("Date: " + Expiration);
                    if (Expiration == null) {
                        player.kickPlayer(ChatColor.RED + "" + ChatColor.BOLD + "You got PERMANENT banned!" + "\n "
                                + ChatColor.GOLD + "" + ChatColor.BOLD + "By " + ChatColor.GRAY + getSource(player));
                    }
                }
            }
        }


        public Date getExpiration(Player player) {
            BanList list = Bukkit.getBanList(Type.NAME);
            Date date = new Date();
            for (BanEntry entry : list.getBanEntries()) {
                String name = entry.getTarget();
                if (name.equals(player.getName())) {
                    date = entry.getExpiration();
                }

            }
            return date;
        }
     
        public String getSource(Player player) {
            BanList list = Bukkit.getBanList(Type.NAME);
            String source = null;
            for (BanEntry entry : list.getBanEntries()) {
                String name = entry.getTarget();
                if (name.equals(player.getName())) {
                    source = entry.getSource();
                }

            }
            return source;
        }
     
    Console:

    Code (Text):

    [19:27:43] [Thread-12/INFO]: UUID of player Bart_ is c6652c54-76ea-38b8-b5e7-6e27fc96f488
    [19:27:43] [Server thread/INFO]: Disconnecting [email protected][id=c6652c54-76ea-38b8-b5e7-6e27fc96f488,name=Bart_,properties={},legacy=false] (/127.0.0.1:55865): You are banned from this server!
    Reason: §c§lYou got permanent banned!
    §6§lBy §7Bart_

    [19:27:43] [Server thread/INFO]: [email protected][id=c6652c54-76ea-38b8-b5e7-6e27fc96f488,name=Bart_,properties={},legacy=false] (/127.0.0.1:55865) lost connection: You are banned from this server!
    Reason: §c§lYou got permanent banned!
    §6§lBy §7Bart_
     
     
    #5 Bart_, May 12, 2016
    Last edited: May 12, 2016
  6. Try changing the EventHandler priority:
    Code (Java):
    @EventHandler(priority = EventPriority.HIGHEST)
     
  7. No change :(

    Maybe i will create a config and do all with it (instead of using the ban system of essentials), but i have no idea about how store information and then get it.
    Example:
    Code (Text):

    Playername
         reason: fdffd
         time: fdfd
         blabla:   fdasfdasdf
     
     
    #7 Bart_, May 12, 2016
    Last edited: May 12, 2016
  8. Ok i think to have solved.