Plugin not working and no errors

Discussion in 'Spigot Plugin Development' started by ZevoGaems, May 29, 2017.

  1. I am trying to make a plugin that when you join kicks you. I am doing it to troll one of my friends server, but its not working and I don't know why. Here is my code
    Code (Text):

    package pw.loopturn.virus;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
    import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result;
    import org.bukkit.plugin.java.JavaPlugin;

    public class main extends JavaPlugin implements Listener {
        @EventHandler
        public void LogOnBanned(final AsyncPlayerPreLoginEvent e) {
                e.disallow(Result.KICK_BANNED, ChatColor.WHITE + "Internal exception java.net.SocketException: connection reset");
            }
       
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if(cmd.getName().equalsIgnoreCase("happydays")) {
                for(Player p : Bukkit.getOnlinePlayers()) {
                    p.kickPlayer(ChatColor.WHITE + "Internal exception java.net.SocketException: connection reset");
                }
            }
            return true;
        }
    }

     
     
  2. Not that I support doing this or anything, but as long as he is a friend, just listen to the PlayerJoinEvent then kick the player.
     
  3. "main" should be "Main", method names should always be lowerCamelCase, and you need to register the listener...
     
  4. Just use PlayerJoinEvent. Then just use player.setKicked(true)
     
  5. Ummm Why??? This event literally exists for this reason...
     
  6. I recommend learning a little bit more before you attempt this troll. You are missing multiple components of your code that would've been known if you would have followed a tutorial or read a little bit more. Take a look here.
    https://www.spigotmc.org/wiki/spigot-plugin-development/

    Specifically,
    https://www.spigotmc.org/wiki/using-the-event-api/?noRedirect=1
    and
    https://www.spigotmc.org/wiki/create-a-simple-command/

    If you read those last two links I sent you, you'll be able to figure out your problem.