Plugin category: Simple plugin which allows a player to be kicked when they try to join the server with a custom message. Suggested name: AcerKick (Acer is the beginning on my server name). What I want: I'd wish to see a plugin which disables on joining to the server for a cause. Firstly, they would get kicked when they join the server with a custom message configurable in the config.yml. This is great to help switch server IPs, break-downs in your server and if you want to get a DESPERATE message across. I would love to see a feature implemented in the config which allows us to configure it to display a message when the player gets kicked automatically when they try to join. If this function was not there, I would be disappointed, and it would not be used in my server. Ideas for commands: /acerkick activate - Toggles kicking of players automatically /acerkick deactivate - Disables kicking of players automatically Ideas for permissions: acerkick.bypass - Can join server when plugin is activated. When I'd like it by: ASAP PLEASE!
Some code snippets for interested developers: Code: @EventHandler public void ppp (PlayerJoinEvent e) { if (e.getPlayer().hasPermission("acerkick.bypass") || !(getConfig().getBoolean("enabled")) { e.getPlayer().kickPlayer(getConfig().getString("message")); } } Code: //Disable/enable the kick mode: getConfig().set("enabled", false); getConfig().set("enabled", true); Code: //Set message StringBuilder buffer = new StringBuilder(); for(int i = 0; i < args.length; i++) { buffer.append(' ').append(args[i]); } String msg = buffer.toString(); getConfig().set("message", msg);
Unless your using whitelist, you could just use the whitelist command and activate it, kicking anyone not on the list.
Well, here it is... http://www.kodfod.us/AcerKick.jar the config is setup like this: Code: kick: msg: The server is currently not accepting players at this time. Please try again later. bypass: join: msg: $player was allowed to join with the bypass. Both join and kick allow for $player for the players name to be inserted. and here is the source: Main Class: Code:java package us.kodfod.akick; import java.io.File; import org.bukkit.Bukkit;import org.bukkit.ChatColor;import org.bukkit.command.Command;import org.bukkit.command.CommandSender;import org.bukkit.plugin.java.JavaPlugin; public class Main extends JavaPlugin { public static boolean locked; @Overridepublic void onDisable() {} @Overridepublic void onEnable() {Bukkit.getPluginManager().registerEvents(new Player(this), this);locked = false;try {File file = new File(this.getDataFolder()+"/config.yml");if (file.exists()) {return;} else {this.saveDefaultConfig();}} catch (Exception e) {this.saveDefaultConfig();}} @Overridepublic boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {if (cmd.getName().equalsIgnoreCase("akick")) {if (args.length == 1) {if (args[0].equalsIgnoreCase("on")) {if (locked) {sender.sendMessage(ChatColor.RED+"Server is already kicking players.");return true;}locked = !locked;sender.sendMessage(ChatColor.GREEN+"Server is now kicking players.");return true;}if (args[0].equalsIgnoreCase("off")) {if (locked) {sender.sendMessage(ChatColor.GREEN+"Server is now allowing players.");locked = !locked;return true;}sender.sendMessage(ChatColor.RED+"Server is not currently kicking players.");return true;}sender.sendMessage(ChatColor.RED+"Sorry try: /akick on|off");return true;} else {sender.sendMessage(ChatColor.RED+"Sorry try: /akick on|off");return true;}}return false;} } PlayerListener: Code:Java package us.kodfod.akick; import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.player.PlayerJoinEvent;import org.bukkit.event.player.PlayerQuitEvent; public class Player implements Listener { Main plugin; public Player(Main main) {plugin = main;}@EventHandlerpublic void onJoin(PlayerJoinEvent e) {if (Main.locked) {if (e.getPlayer().hasPermission("akick.bypass")) {String cmsg = plugin.getConfig().getString("bypass.join.msg");String rmsg = cmsg.replace("$player", e.getPlayer().getName());e.setJoinMessage(rmsg);return;}String cmsg = plugin.getConfig().getString("kick.msg");String rmsg = cmsg.replace("$player", e.getPlayer().getName());e.getPlayer().kickPlayer(rmsg);e.setJoinMessage("");}return;}@EventHandlerpublic void onQuit(PlayerQuitEvent e) {if (Main.locked) {e.setQuitMessage("");}return;}}
Kodfod Thank you very much for the plugin. I will test it out after school. I appreciate all comments and in-put into this. I am grateful.
I was just wondering since this was a kick plugin that is it possible to kick/ban someone with multiple lines of text for the kick message.
good question... *goes to test* yeah it no work....(at least this plugin and bukkit's kick....) However, I could easily add this
Kodfod, A bit of a problem. I've tested the plugin, loving the /akick onff command. However, when I type /akick on, it does work, but when a player tries to join the server, it says the DEFAULT message for kicking players, instead of my custom message. Also, does this kick support colours with the § symbol? Thank you. Ahh, it does not support the § symbol for colour kicks. Do not worry, I am fine without colours. Thanks for a great, functional plugin! EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Well, the only thing you could use the Color symbols for is the join message.... the kick message wouldn't allow that. edit: So it does work?
Kodfod, IF there is a way, is it possible for you to add a default onff option in the config? I restart my server a lot, and the plugin is always automatically deactivated when on server restart. Is there a way to make it on by default of a server restart? Thanks! Kodfod, Just discovered a bug. The permission acerkick.bypass needs to be added. If that permission has been added, can you default it to the OP group please? Thanks! EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Kodfod, Is it possible to turn on AcerKick on default when server starts? I don't really want to go into the server and type /akick on everytime.
There we have it. http://www.kodfod.us/AcerKick.jar Download it and it delete you config or just add at the bottom: Code: StartLocked: true EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Kodfod, This plugin is working terrifically well. Thanks! However, I was wondering on something, possibly a bug. When I start my server and the plugin is activated..it seems to deactivate AFTER A WHILE. This can get frustrating because I would have to reactivate it every time. P.S, do you have Skype? If so, add me: suprise.suprise (I am interested in you making custom plugins for me), if you want to. Thank you.
Mineacer I'm sorry but i will take a look into why it may be deactivating it self.... and i can do some developing for you as long as i have time (the holiday season is really busy for me).