Custom ban message?

Discussion in 'Plugin Development' started by MrGriefer_HGTech, Jan 18, 2015.

Thread Status:
Not open for further replies.
  1. Hi!

    I wanna know how to make a custom ban message, Basically i ban player using my plugin but i want to set the banned message for them. How? Also i wanna know how to make so it tell that there is 1 minute left or 1 hour left!

    Anyone?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
  2. Offline

    Plugers11

    @MrGriefer_HGTech
    U can use dates and PlayerLoginEvent
    for banning u can do :
    p.setBanned(true);
    p.kickPlayer("Me");
     
  3. @Plugers11 How can i make so it tell them that 1 hour left?
     
  4. Offline

    Plugers11

  5. Offline

    nopvpgamer

    Code:
    @EventHandler
    public void onLogin(PlayerLoginEvent e){
    Player p = e.getPlayer();
    if(p.isBanned()){
    e.setCancelled(true);
    p.kickPlayer("Line 1 of Custom Ban Message\n"
    +"Line 2 of Custom Ban Massage\n"
    +"Line 3 of ....");
    }
    
    }
     
  6. When you ban a player save the hour and date, and when the player join the server do something like
    Code:java
    1.  
    2. banhour-actualhour
    3.  
     
  7. @MrGriefer_HGTech You can also make it so it's a command.
    Code:
        public boolean onCommand(CommandSender sender, Command cmd,
                String commandLabel, String[] args) {
            if (sender instanceof Player) {
                Player player = (Player) sender;
                if (cmd.getName().equalsIgnoreCase("ban")) {
                    if (player.hasPermission("plugin.ban")) {
                        if (args.length == 0) {
                            sender.sendMessage(ChatColor.RED
                                    + "/ban <player> <reason>");
                        } else if (args.length == 1) {
                            sender.sendMessage(ChatColor.RED
                                    + "/ban <player> <reason>");
                        } else if (args.length == 2) {
                            // Code for banning goes here. :)
                        }
                    } else {
                        sender.sendMessage(ChatColor.RED + "You do not have permission to perform this command.");
                    }
                }
            } else {
                sender.sendMessage(ChatColor.DARK_RED
                        + "Only ingame players are allowed to do this command.");
            }
            return true;
        }
    }
    Hope this helped a little. :)
     
Thread Status:
Not open for further replies.

Share This Page