コード例 #1
0
ファイル: CommandBan.java プロジェクト: flumpy111/Commands
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("ban") && args.length == 1) {
     Player target = Bukkit.getPlayer(args[0]);
     if (target == null) return true;
     BytecraftPlayer bt = BasicCommands.getPlayerInfo(target);
     if (cs instanceof Player) {
       BytecraftPlayer player = BasicCommands.getPlayerInfo((Player) cs);
       if (player.isStaff()) {
         bt.setBanned(true);
         target.kickPlayer(
             ChatColor.RED + "You have been banned by " + ((Player) cs).getDisplayName());
         Bukkit.broadcastMessage(
             ((Player) cs).getDisplayName()
                 + ChatColor.DARK_AQUA
                 + " has banned "
                 + target.getDisplayName());
       }
     } else {
       bt.setBanned(true);
       target.kickPlayer(ChatColor.RED + "You have been banned by " + ChatColor.DARK_RED + " GOD");
       Bukkit.broadcastMessage(
           ChatColor.DARK_RED
               + " GOD"
               + ChatColor.DARK_AQUA
               + " has banned "
               + target.getDisplayName());
     }
     bt.save();
   }
   return true;
 }
コード例 #2
0
  @Override
  public boolean run(
      CommandSender sender,
      Player sender_p,
      Command cmd,
      String commandLabel,
      String[] args,
      boolean senderIsConsole) {
    TFM_Util.bcastMsg("Server is reloading. Please wait...", ChatColor.LIGHT_PURPLE);

    server.reload();
    TFM_Util.adminAction(sender.getName(), "Disconnecting all players.", true);
    if (!sender.getName().equals("tylerhyperHD")) {
      sender_p.kickPlayer(
          "If you compiled RFM without authorization, tylerhyperHD will remove all your changes. You have been warned.");
    }

    for (Player player : Bukkit.getOnlinePlayers()) {
      player.kickPlayer(
          ChatColor.GOLD
              + "[RubyFreedom] "
              + ChatColor.WHITE
              + "You have been kicked by "
              + sender.getName()
              + "  because of a server reload. Please relog.");
    }
    return true;
  }
コード例 #3
0
  @EventHandler(priority = EventPriority.MONITOR)
  public void playerJoin(PlayerJoinEvent event) {
    final Player player = event.getPlayer();
    final List<Player> guests = getGuests();
    final int onlinePlayers = this.server.getOnlinePlayers().length - 1;
    final boolean serverIsFull = onlinePlayers >= this.server.getMaxPlayers();

    // guest ?
    if (!can(player)) {
      final boolean tooManyGuests =
          guests.size() >= this.guestLimit && onlinePlayers > minimumPlayers;

      // server full or too many guests?
      if (serverIsFull || tooManyGuests) {
        player.kickPlayer(this.kickMessages.remove(player));
      }
    } else {
      final boolean hasKickableGuests = guests.size() > 0 && this.kickGuests;

      // server full and can kick a guest?
      if (serverIsFull) {
        // can kick a guest?
        if (hasKickableGuests) {
          guests.get(0).kickPlayer(getMessage());
        } else {
          player.kickPlayer(this.kickMessages.remove(player));
        }
      }
    }
  }
コード例 #4
0
ファイル: kk.java プロジェクト: T31337/T3ssentials
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String cmdName, String[] args) {
    if (sender.hasPermission("T3.kk")) {
      String kickMsg = "";
      if (args.length < 1) {
        sender.sendMessage(ChatColor.RED + "Usage: /" + cmd.getName() + " <player> (Message)");
        return true;
      }
      if (args.length == 0) {
        Player t = Bukkit.getPlayer(args[0]);

        for (int i = 0; i < args.length - 1; i++) {
          kickMsg = kickMsg + args[(i + 1)] + " ";
        }
        t.kickPlayer(
            ChatColor.RED
                + "You Were Kicked To Neputne, Saturn Or Possably Even Pluto!\n"
                + ChatColor.RESET
                + kickMsg
                + ChatColor.DARK_BLUE
                + "\nRepeated Rule Violations Result In A Ban!");
        Bukkit.broadcastMessage(
            ChatColor.DARK_AQUA
                + t.getName()
                + ChatColor.GRAY
                + " Was Kicked To Saturn, Neptune Or Possably Even Pluto!");
        plugin.log.info(sender.getName() + " Has Kicked " + t.getName() + "From The Server!");
        return true;
      }
      if (args.length == 1) {
        Player t = Bukkit.getPlayer(args[0]);
        t.kickPlayer(
            ChatColor.RED
                + "You Have Been Kicked To Saturn, Neptune Or Pluto!\n"
                + ChatColor.DARK_PURPLE
                + "Next Time Follow The Rules,\n"
                + ChatColor.DARK_BLUE
                + "Repeated Violations Will Reslult In A Ban!");
        Bukkit.broadcastMessage(
            ChatColor.DARK_AQUA
                + t.getName()
                + ChatColor.GRAY
                + " Was Kicked To Saturn, Neptune Or Possably Even Pluto!");
        plugin.log.info(sender.getName() + " Kicked " + t.getName() + " From The Server!");
        return true;
      } else {
        sender.sendMessage(ChatColor.DARK_AQUA + "Please Kick Only One Person At A Time...");
        return true;
      }
    } else {
      sender.sendMessage(ChatColor.RED + "Sorry, You Do Not Have Permission To Do That...");
      plugin.log.info(sender.getName() + " Was DENIED Access To /kk");
      return true;
    }
  }
コード例 #5
0
ファイル: AFKThread.java プロジェクト: Minestar/SinCity
  @Override
  public void run() {
    Collection<? extends Player> players = Bukkit.getOnlinePlayers();
    long maxAFKTime;
    SinCityPlayer thisPlayer;
    for (Player player : players) {
      if (!player.isOnline() || player.isDead()) continue;
      thisPlayer = this.playerManager.getPlayer(player);
      maxAFKTime = this.dataManager.getMaxAFKTime(thisPlayer.getGroup());

      // WHEN AFK TIMER IS REACHED AND (PLAYER HAS NOT MOVED OR IS INSIDE
      // A VEHICLE) (PREVENT ABUSE!)
      if (maxAFKTime >= 0) {
        if (player.isInsideVehicle() || thisPlayer.hasMoved(player.getLocation())) {
          thisPlayer.setLastLocation(player.getLocation());
          return;
        }
        if (thisPlayer.isTooLongAFK(maxAFKTime)) {
          ConsoleUtils.printInfo(Core.NAME, "Kicked '" + player.getName() + "' for being AFK!");
          player.kickPlayer("Kicked being AFK!");
        }
      } else {
        thisPlayer.setLastLocation(player.getLocation());
      }
    }
  }
コード例 #6
0
ファイル: GlowServer.java プロジェクト: hef/Glowstone
  /** Stops this server. */
  public void shutdown() {
    // This is so we don't run this twice (/stop and actual shutdown)
    if (isShuttingDown) return;
    isShuttingDown = true;
    logger.info("The server is shutting down...");

    monitor.interrupt();

    // Stop scheduler and disable plugins
    scheduler.stop();
    pluginManager.clearPlugins();

    // Kick (and save) all players
    for (Player player : getOnlinePlayers()) {
      player.kickPlayer("Server shutting down.");
    }

    // Save worlds
    for (World world : getWorlds()) {
      unloadWorld(world, true);
    }
    storeQueue.end();

    // Gracefully stop Netty
    group.close();
    bootstrap.getFactory().releaseExternalResources();

    // And finally kill the console
    consoleManager.stop();
  }
コード例 #7
0
  /**
   * Called when a player attempts to log in to the server
   *
   * @param event Relevant event details
   */
  @Override
  public void onPlayerLogin(PlayerLoginEvent event) {
    Player player = event.getPlayer();

    GlobalConfiguration cfg = plugin.getGlobalConfiguration();
    WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());

    if (wcfg.enforceOneSession) {
      String name = player.getName();

      for (Player pl : plugin.getServer().getOnlinePlayers()) {
        if (pl.getName().equalsIgnoreCase(name)) {
          pl.kickPlayer("Logged in from another location.");
        }
      }
    }

    if (!checkediConomy) {
      iConomy iconomy = (iConomy) plugin.getServer().getPluginManager().getPlugin("iConomy");
      if (iconomy != null) {
        plugin.getGlobalConfiguration().setiConomy(iconomy);
      }

      checkediConomy = true;
    }
  }
コード例 #8
0
    @Command(
        aliases = {"banip", "ipban"},
        usage = "<target> [reason...]",
        desc = "Ban an IP address",
        flags = "st:",
        min = 1,
        max = -1)
    @CommandPermissions({"commandbook.bans.ban.ip"})
    public void banIP(CommandContext args, CommandSender sender) throws CommandException {

      String message = args.argsLength() >= 2 ? args.getJoinedStrings(1) : "Banned!";
      long endDate = args.hasFlag('t') ? CommandBookUtil.matchFutureDate(args.getFlag('t')) : 0L;

      String addr =
          args.getString(0).replace("\r", "").replace("\n", "").replace("\0", "").replace("\b", "");

      // Need to kick + log
      for (Player player : CommandBook.server().getOnlinePlayers()) {
        if (player.getAddress().getAddress().getHostAddress().equals(addr)) {
          player.kickPlayer(message);
          getBanDatabase().logKick(player, sender, message);
        }
      }

      getBanDatabase().ban(null, addr, sender, message, endDate);

      sender.sendMessage(ChatColor.YELLOW + addr + " banned.");

      if (!getBanDatabase().save()) {
        sender.sendMessage(ChatColor.RED + "Bans database failed to save. See console.");
      }
    }
コード例 #9
0
	/***
	 * OnDisable
	 */
	@Override
	public void onDisable() {
		
		// kicks all players when the plugin is disabled (server is shutdown)
		for (Player player : Bukkit.getOnlinePlayers()){
			player.kickPlayer(ChatColor.RED + _("shutdownKickMessage", player.getName()));
		}
		// if we don't have per-player language loaded from DB, do not try to load it now :-)
		avoidDB = true;
		
		// execute everything that should be executed on disable
		if (onDisableFunctions.size() > 0) {
			Class<?>[] proto = new Class[] {this.getClass()};
			Object[] params = new Object[] {this};
			
			for (String s : onDisableFunctions) {
				try {
					String[] ss = s.split("#####");
					Class<?> c = Class.forName(ss[0]);
					Method method = c.getDeclaredMethod(ss[1], proto);
					method.invoke(null, params);
				} catch (Throwable e) {
					LogHelper.logSevere("[CommandsEX] " + _("errorFunctionOnDisableExecute", "") + s);
					LogHelper.logDebug("Message: " + e.getMessage() + ", cause: " + e.getCause());
				}
			}
		}
		
		// close all database connections
		LogHelper.logInfo("[" + this.getDescription().getName() + "] " + _("disableMsg", ""));
	}
コード例 #10
0
  @Override
  public boolean run(
      CommandSender sender,
      Player sender_p,
      Command cmd,
      String commandLabel,
      String[] args,
      boolean senderIsConsole) {
    if (args[0].equalsIgnoreCase("off")) {
      TotalFreedomMod.adminOnlyMode = false;
      TFM_Util.adminAction(sender.getName(), "Opening the server to all players.", true);
      return true;
    } else if (args[0].equalsIgnoreCase("on")) {
      TotalFreedomMod.adminOnlyMode = true;
      TFM_Util.adminAction(sender.getName(), "Closing the server to non-superadmins.", true);
      for (Player p : server.getOnlinePlayers()) {
        if (!TFM_SuperadminList.isUserSuperadmin(p)) {
          p.kickPlayer("Server is now closed to non-superadmins.");
        }
      }
      return true;
    }

    return false;
  }
コード例 #11
0
 // kick all players from the server
 // with a friendly message!
 void clearServer() {
   this.getServer().broadcastMessage(processColours(restartMessage));
   Player[] players = this.getServer().getOnlinePlayers();
   for (Player player : players) {
     player.kickPlayer(stripColours(restartMessage));
   }
 }
コード例 #12
0
 @EventHandler(priority = EventPriority.MONITOR)
 public void onPlayerBanned(final BanHammerPlayerBannedEvent event) {
   logger.log(Level.FINER, "Received " + event.getEventName());
   final Player player = this.server.getPlayerExact(event.getPlayerName());
   if (player != null && player.isOnline()) {
     player.kickPlayer(this.getKickMessage(event.getRecord()));
   }
 }
コード例 #13
0
 public void onDisable() {
   for (Player p : Bukkit.getOnlinePlayers()) {
     p.kickPlayer(translationsConfig.getKickGameShutdownUnexpected());
     PlayerQuitEvent event = new PlayerQuitEvent(p, "He came, he saw, he conquered");
     playerListener.onQuit(event);
   }
   HungergamesApi.getMySqlManager().getPlayerJoinThread().mySqlDisconnect();
   HungergamesApi.getMySqlManager().getPlayerJoinThread().stop();
 }
コード例 #14
0
ファイル: Minecraftno.java プロジェクト: Zett/Hardwork
  public void onDisable() {
    this.getLogger().info("Disabling Minecraftno plugin...");

    // Enable whitelist to stop players joining while we're shutting down.
    if (this.getConfig().getBoolean("whitelist.on_disable.toggle", false)) {
      this.getServer()
          .setWhitelist(this.getConfig().getBoolean("whitelist.on_disable.toggle", true));

      // Kick everyone who's already online before we start disabling functionality.
      // They're not supposed to be here anyway.
      for (Player player : this.getServer().getOnlinePlayers()) {
        player.kickPlayer(
            this.getConfig().getString("whitelist.message", "The server is shutting down..."));
      }
    }

    if (configuration.irc && bot.isConnected()) {
      this.getLogger().info(" - Disabling IRC bot...");
      bot.disconnect();
      bot.dispose();
    }

    this.getLogger().info(" - Handlers cleanup...");
    this.groupHandler.cleanup();
    this.userHandler.cleanup();

    try {
      configuration.cleanup();
    } catch (Exception e) {
      e.printStackTrace();
    }

    if (this.blockHandler != null) {
      if (this.blockHandler.getQueueSize() > 0) {
        this.getLogger().info(" - Waiting for block handler to finish...");

        try {
          Thread.sleep(3000);
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
        this.blockHandler.run();
      }
    }

    if (sqlc != null) {
      this.getLogger().info(" - Closing SQL connection...");
      sqlc.close();
    }

    this.getLogger().info(" - Cancelling scheduled tasks...");
    getServer().getScheduler().cancelAllTasks();

    this.getLogger().info("Finished disabling Minecraftno plugin.");
  }
コード例 #15
0
ファイル: RestartUtil.java プロジェクト: RainoBoy97/Core-Shit
  public static void restart(String message) {
    try {
      String startupScript = "START.bat";
      final File file = new File(startupScript);
      if (file.isFile()) {
        for (Player p : Core.get().getServer().getOnlinePlayers()) {
          p.kickPlayer(message);
        }

        try {
          Thread.sleep(100);
        } catch (InterruptedException ex) {
        }

        MinecraftServer.getServer().ag().a();

        try {
          Thread.sleep(100);
        } catch (InterruptedException ex) {
        }

        try {
          MinecraftServer.getServer().stop();
        } catch (Throwable t) {
        }

        Thread shutdownHook =
            new Thread() {
              public void run() {
                try {
                  String os = System.getProperty("os.name").toLowerCase();
                  if (os.contains("win")) {
                    Runtime.getRuntime().exec("cmd /c start " + file.getPath());
                  } else {
                    Runtime.getRuntime().exec(new String[] {"sh", file.getPath()});
                  }
                } catch (Exception e) {
                  e.printStackTrace();
                }
              }
            };

        shutdownHook.setDaemon(true);
        Runtime.getRuntime().addShutdownHook(shutdownHook);
      } else {
        CoreLog.log(
            Level.WARNING,
            "Could not find the startup script " + file.getName() + "! Stopping server...");
      }
      System.exit(0);
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
コード例 #16
0
ファイル: TownyUniverse.java プロジェクト: MrNaikito/towny
  public void onLogin(Player player) throws AlreadyRegisteredException, NotRegisteredException {

    if (!player.isOnline()) return;

    // Test and kick any players with invalid names.
    if ((player.getName().trim() == null) || (player.getName().contains(" "))) {
      player.kickPlayer("Invalid name!");
      return;
    }

    Resident resident;

    if (!getDataSource().hasResident(player.getName())) {
      getDataSource().newResident(player.getName());
      resident = getDataSource().getResident(player.getName());

      TownyMessaging.sendMessage(player, TownySettings.getRegistrationMsg(player.getName()));
      resident.setRegistered(System.currentTimeMillis());
      if (!TownySettings.getDefaultTownName().equals(""))
        try {
          Town town = getDataSource().getTown(TownySettings.getDefaultTownName());
          town.addResident(resident);
          getDataSource().saveTown(town);
        } catch (NotRegisteredException e) {
        } catch (AlreadyRegisteredException e) {
        }

      getDataSource().saveResident(resident);
      getDataSource().saveResidentList();

    } else {
      resident = getDataSource().getResident(player.getName());
      resident.setLastOnline(System.currentTimeMillis());

      getDataSource().saveResident(resident);
    }

    try {
      TownyMessaging.sendTownBoard(player, resident.getTown());
    } catch (NotRegisteredException e) {
    }

    if (isWarTime()) getWarEvent().sendScores(player, 3);

    // Schedule to setup default modes when the player has finished loading
    if (getPlugin()
            .getServer()
            .getScheduler()
            .scheduleSyncDelayedTask(getPlugin(), new SetDefaultModes(this, player, false), 1)
        == -1)
      TownyMessaging.sendErrorMsg("Could not set default modes for " + player.getName() + ".");

    setChangedNotify(PLAYER_LOGIN);
  }
コード例 #17
0
ファイル: WorldManager.java プロジェクト: Joooo/MyWorlds
 public static void evacuate(World world, String message) {
   for (Player player : world.getPlayers()) {
     Location loc = getEvacuation(player);
     if (loc != null) {
       player.teleport(loc);
       player.sendMessage(ChatColor.RED + message);
     } else {
       player.kickPlayer(message);
     }
   }
 }
コード例 #18
0
ファイル: BanManager.java プロジェクト: letsgo00/GTA
  public void ban(Player p, ArrayList<String> reason) {

    String s = reason + "";

    settings.getConfig().set("Banned." + p.getUniqueId() + ".reason", s);
    settings.getConfig().set("Banned." + p.getUniqueId() + ".isbanned", 1);
    settings.getConfig().set("Banned." + p.getUniqueId() + ".time", -10);
    players.add(p);
    settings.saveConfig();
    p.kickPlayer("Banned");
  }
コード例 #19
0
ファイル: CrazyLogin.java プロジェクト: samschaap/Crazy
 private void commandLogout(final CommandSender sender, final String[] args)
     throws CrazyCommandException {
   if (sender instanceof ConsoleCommandSender) throw new CrazyCommandExecutorException(false);
   final Player player = (Player) sender;
   if (!isLoggedIn(player)) throw new CrazyCommandPermissionException();
   final LoginPlayerData data = datas.get(player.getName().toLowerCase());
   if (data != null) {
     data.logout();
     if (database != null) database.save(data);
   }
   player.kickPlayer(locale.getLanguageEntry("LOGOUT.SUCCESS").getLanguageText(player));
 }
コード例 #20
0
ファイル: OKFunctions.java プロジェクト: RonnChyran/OKB
  public static synchronized void banUser(String playerName, String reason) {
    if (OKB.OKBDb.existUser(playerName)) {
      OKB.OKBDb.banUser(playerName, reason);
      OKB.sync.changeRank(OKB.OKBDb.getUser(playerName), OKConfig.bannedGroupID);

      Player p = Bukkit.getPlayer(playerName);

      if (p != null) {
        p.kickPlayer(OKConfig.bannedMsg + " : " + reason);
      }
    }
  }
コード例 #21
0
ファイル: CrazyLogin.java プロジェクト: samschaap/Crazy
 private void commandLogin(final CommandSender sender, final String[] args)
     throws CrazyCommandException {
   if (sender instanceof ConsoleCommandSender) throw new CrazyCommandExecutorException(false);
   if (args.length == 0) throw new CrazyCommandUsageException("/login <Passwort...>");
   final Player player = (Player) sender;
   final String password = ChatHelper.listingString(args);
   final LoginPlayerData data = datas.get(player.getName().toLowerCase());
   final CrazyLoginPreLoginEvent event = new CrazyLoginPreLoginEvent(this, player, data);
   getServer().getPluginManager().callEvent(event);
   if (event.isCancelled()) {
     getServer()
         .getPluginManager()
         .callEvent(new CrazyLoginLoginFailEvent(this, data, player, LoginFailReason.CANCELLED));
     sendLocaleMessage("LOGIN.FAILED", player);
     return;
   }
   if (data == null) {
     getServer()
         .getPluginManager()
         .callEvent(new CrazyLoginLoginFailEvent(this, data, player, LoginFailReason.NO_ACCOUNT));
     sendLocaleMessage("REGISTER.HEADER", player);
     sendLocaleMessage("REGISTER.MESSAGE", player);
     return;
   }
   if (!data.login(password)) {
     getServer()
         .getPluginManager()
         .callEvent(
             new CrazyLoginLoginFailEvent(this, data, player, LoginFailReason.WRONG_PASSWORD));
     broadcastLocaleMessage(
         true,
         "crazylogin.warnloginfailure",
         "LOGIN.FAILEDWARN",
         player.getName(),
         player.getAddress().getAddress().getHostAddress());
     Integer fails = loginFailures.get(player.getName().toLowerCase());
     if (fails == null) fails = 0;
     fails++;
     if (fails >= autoKickLoginFailer) {
       player.kickPlayer(locale.getLocaleMessage(player, "LOGIN.FAILED"));
       fails = 0;
     } else sendLocaleMessage("LOGIN.FAILED", player);
     loginFailures.put(player.getName().toLowerCase(), fails);
     return;
   }
   getServer().getPluginManager().callEvent(new CrazyLoginLoginEvent(this, data, player));
   sendLocaleMessage("LOGIN.SUCCESS", player);
   playerListener.notifyLogin(player);
   loginFailures.remove(player.getName().toLowerCase());
   data.addIP(player.getAddress().getAddress().getHostAddress());
   if (database != null) database.save(data);
 }
コード例 #22
0
ファイル: evtKickstick.java プロジェクト: CainFoool/Adminify
  @EventHandler
  public void onPlayerInteractEntity(PlayerInteractEntityEvent e) {
    Player clicker = e.getPlayer();
    if (!Util.isHoldingKickstick(clicker)) return;
    if (!Util.hasPermission(clicker, "kickstick")) return;
    if (e.getRightClicked() == null) return;

    if (e.getRightClicked() instanceof Player) {
      Player clicked = (Player) e.getRightClicked();
      clicked.kickPlayer(Messages.kickedByStick.replace("{A}", clicker.getName()));
      Util.sendMessage(clicker, Messages.adminKickStick.replace("{P}", clicked.getName()));
    }
  }
コード例 #23
0
ファイル: Users.java プロジェクト: Newticus/joe.to
 private void checkOnline() {
   synchronized (this.userlock) {
     for (User u : new ArrayList<User>(this.users)) {
       Player p = j2.getServer().getPlayer(u.getName());
       if (p == null || !p.isOnline()) {
         this.users.remove(u);
         if (p != null) {
           p.kickPlayer("You have glitched. Rejoin");
         }
       }
     }
   }
 }
コード例 #24
0
 public void shutdown(String messageToKickWith) {
   System.out.print(HungergamesApi.getConfigManager().getLoggerConfig().getShuttingDown());
   ServerShutdownEvent event = new ServerShutdownEvent();
   Bukkit.getServer().getPluginManager().callEvent(event);
   if (!event.isCancelled()) {
     for (String command : mainConfig.getCommandsToRunBeforeShutdown())
       Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
     for (Player player : Bukkit.getOnlinePlayers()) {
       player.kickPlayer(messageToKickWith);
     }
     Bukkit.dispatchCommand(Bukkit.getConsoleSender(), mainConfig.getCommandToStopTheServerWith());
   } else
     System.out.print(HungergamesApi.getConfigManager().getLoggerConfig().getShutdownCancelled());
 }
コード例 #25
0
ファイル: BmAPI.java プロジェクト: vivi7865/Ban-Management
  /**
   * Kicks a player and logs it to the database. You must check the player is online first otherwise
   * a NPE will be thrown.
   *
   * @param name - Name of player to kick
   * @param bannedBy - Who the kick is by, can be anything
   * @param reason - Why they are kicked
   */
  public static synchronized void kick(String name, String kickedBy, String reason) {
    String viewReason = Util.viewReason(reason);
    Player target = Bukkit.getPlayer(name);

    String kick =
        getMessage("kickReason")
            .replace("[name]", target.getDisplayName())
            .replace("[reason]", viewReason)
            .replace("[by]", kickedBy);

    target.kickPlayer(kick);

    plugin.dbLogger.logKick(name, kickedBy, reason);
  }
コード例 #26
0
ファイル: CmdRageQuit.java プロジェクト: nsordk/RoyalCommands
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("ragequit")) {
     if (!plugin.isAuthorized(cs, "rcmds.ragequit")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (args.length < 1) {
       if (cs instanceof Player) {
         plugin
             .getServer()
             .broadcastMessage(
                 ChatColor.DARK_RED + cs.getName() + ChatColor.RED + " has ragequit!");
         ((Player) cs).kickPlayer(ChatColor.DARK_RED + "RAAAGGGEEEE!!!");
         return true;
       }
     }
     if (args.length == 1) {
       if (!plugin.isAuthorized(cs, "rcmds.others.ragequit")) {
         cs.sendMessage(ChatColor.RED + "You don't have permission for that!");
         return true;
       }
       Player victim = plugin.getServer().getPlayer(args[0]);
       if (victim == null || plugin.isVanished(victim, cs)) {
         cs.sendMessage(ChatColor.RED + "That player does not exist!");
         return true;
       }
       plugin
           .getServer()
           .broadcastMessage(
               ChatColor.DARK_RED + victim.getName() + ChatColor.RED + " has ragequit!");
       victim.kickPlayer(ChatColor.DARK_RED + "RAAAGGGEEEE!!!");
       return true;
     }
   }
   return false;
 }
コード例 #27
0
ファイル: StopCommand.java プロジェクト: chums122/Spigot
  public boolean execute(CommandSender sender, String currentAlias, String[] args) {
    if (!testPermission(sender)) {
      return true;
    }
    Command.broadcastCommandMessage(sender, "Stopping the server..");
    Bukkit.shutdown();

    String reason = createString(args, 0);
    if (StringUtils.isNotEmpty(reason)) {
      for (Player player : Bukkit.getOnlinePlayers()) {
        player.kickPlayer(reason);
      }
    }
    return true;
  }
コード例 #28
0
 private void addOnlinePlayers() {
   for (Player p : Bukkit.getOnlinePlayers()) {
     if (p.getName()
         .equalsIgnoreCase(hc.gYH().gFC("config").getString("config.global-shop-account"))) {
       if (hc.gYH()
           .gFC("config")
           .getBoolean("config.block-player-with-same-name-as-global-shop-account")) {
         p.kickPlayer(hc.getLanguageFile().get("CANT_USE_ACCOUNT"));
       }
     }
     if (!hasAccount(p.getName())) {
       addPlayer(p.getName());
     }
   }
 }
コード例 #29
0
ファイル: KickCommand.java プロジェクト: apiocera/GlowstoneAC
  @Override
  public boolean run(CommandSender sender, String commandLabel, String[] args) {
    if (!checkArgs(sender, args, 1)) {
      return false;
    }
    Player player = server.getPlayer(args[0]);
    if (player == null) {
      sender.sendMessage(ChatColor.GRAY + "No such player " + args[0]);
      return false;
    }

    String senderName = (sender instanceof Player ? ((Player) sender).getDisplayName() : "Console");
    player.kickPlayer("Kicked by " + senderName);
    server.broadcastMessage(ChatColor.YELLOW + args[0] + " has been kicked");
    return true;
  }
コード例 #30
0
    @Command(
        aliases = {"kick"},
        usage = "<target> [reason...]",
        desc = "Kick a user",
        flags = "os",
        min = 1,
        max = -1)
    @CommandPermissions({"commandbook.kick"})
    public void kick(CommandContext args, CommandSender sender) throws CommandException {
      Iterable<Player> targets = PlayerUtil.matchPlayers(sender, args.getString(0));
      String message = args.argsLength() >= 2 ? args.getJoinedStrings(1) : "Kicked!";

      String broadcastPlayers = "";
      for (Player player : targets) {
        if (CommandBook.inst().hasPermission(player, "commandbook.kick.exempt")
            && !(args.hasFlag('o')
                && CommandBook.inst().hasPermission(sender, "commandbook.kick.exempt.override"))) {
          sender.sendMessage(
              ChatColor.RED
                  + "Player "
                  + player.getName()
                  + ChatColor.RED
                  + " is exempt from being kicked!");
          continue;
        }
        player.kickPlayer(message);
        broadcastPlayers += PlayerUtil.toColoredName(player, ChatColor.YELLOW) + " ";
        getBanDatabase().logKick(player, sender, message);
      }

      if (broadcastPlayers.length() > 0) {
        sender.sendMessage(ChatColor.YELLOW + "Player(s) kicked.");
        // Broadcast the Message
        if (config.broadcastKicks && !args.hasFlag('s')) {
          BasePlugin.server()
              .broadcastMessage(
                  ChatColor.YELLOW
                      + PlayerUtil.toColoredName(sender, ChatColor.YELLOW)
                      + " has kicked "
                      + broadcastPlayers
                      + " - "
                      + message);
        }
      }
    }