Java Code Examples for org.spongepowered.api.entity.living.player.Player#kick()
The following examples show how to use
org.spongepowered.api.entity.living.player.Player#kick() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConnectionListener.java From FlexibleLogin with MIT License | 6 votes |
private void onAccountLoaded(Player player) { Optional<Account> optAccount = plugin.getDatabase().loadAccount(player); if (optAccount.isPresent()) { Account account = optAccount.get(); if (canAutoLogin(account, player)) { //user will be auto logged in player.sendMessage(settings.getText().getIpAutoLogin()); Task.builder().execute(() -> protectionManager.unprotect(player)).submit(plugin); account.setLoggedIn(true); } } else if (!settings.getGeneral().isAllowUnregistered()) { player.kick(settings.getText().getUnregisteredKick()); return; } scheduleTimeoutTask(player); }
Example 2
Source File: KickCommand.java From UltimateCore with MIT License | 6 votes |
@Override public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException { checkPermission(sender, KickPermissions.UC_KICK_KICK_BASE); Player target = args.<Player>getOne("player").get(); Text reason = args.hasAny("reason") ? Text.of(args.<String>getOne("reason").get()) : Messages.getFormatted("kick.command.kick.defaultreason"); if (sender.equals(target)) { throw new ErrorMessageException(Messages.getFormatted(sender, "kick.command.kick.self")); } if ((KickPermissions.UC_KICK_EXEMPTPOWER.getIntFor(target) > KickPermissions.UC_KICK_POWER.getIntFor(sender)) && sender instanceof Player) { throw new ErrorMessageException(Messages.getFormatted(sender, "kick.command.kick.exempt", "%player%", target)); } Sponge.getServer().getBroadcastChannel().send(Messages.getFormatted("kick.command.kick.broadcast", "%kicker%", sender, "%kicked%", target, "%reason%", reason)); target.kick(Messages.getFormatted("kick.command.kick.message", "%kicker%", sender, "%kicked%", target, "%reason%", reason)); return CommandResult.success(); }
Example 3
Source File: KickExecutor.java From EssentialCmds with MIT License | 5 votes |
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException { Game game = EssentialCmds.getEssentialCmds().getGame(); Server server = game.getServer(); Player player = ctx.<Player> getOne("player").get(); Optional<String> reason = ctx.<String> getOne("reason"); if (server.getPlayer(player.getUniqueId()).isPresent()) { Text finalKickMessage = Text.of(TextColors.GOLD, src.getName() + " kicked " + player.getName()); if (reason.isPresent()) { Text reas = TextSerializers.formattingCode('&').deserialize(reason.get()); Text kickMessage = Text.of(TextColors.GOLD, src.getName() + " kicked " + player.getName() + " for ", TextColors.RED); finalKickMessage = Text.builder().append(kickMessage).append(reas).build(); player.kick(reas); } else { player.kick(); } MessageChannel.TO_ALL.send(finalKickMessage); src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Player kicked.")); } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Player doesn't appear to be online!")); } return CommandResult.success(); }
Example 4
Source File: KickAllExecutor.java From EssentialCmds with MIT License | 5 votes |
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException { String reason = ctx.<String> getOne("reason").get(); Text reas = TextSerializers.formattingCode('&').deserialize(reason); for(Player player : Sponge.getServer().getOnlinePlayers()) { if(!src.equals(player)) player.kick(reas); } src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Kicked all players.")); return CommandResult.success(); }
Example 5
Source File: AfkTitleTask.java From UltimateCore with MIT License | 5 votes |
@Override public void run() { CommentedConfigurationNode config = Modules.AFK.get().getConfig().get().get(); for (Player player : Sponge.getServer().getOnlinePlayers()) { UltimateUser user = UltimateCore.get().getUserService().getUser(player); if (user.get(AfkKeys.IS_AFK).get()) { Text title = Messages.getFormatted("afk.title.title"); Text subtitle; long timediff = (config.getNode("time", "kicktime").getInt() * 1000) - (System.currentTimeMillis() - user.get(AfkKeys.AFK_TIME).get()); if (config.getNode("time", "kicktime").getInt() != -1 && timediff <= 0 && !player.hasPermission(AfkPermissions.UC_AFK_EXEMPT.get())) { player.kick(Messages.getFormatted("afk.kick.reason")); } if (player.hasPermission(AfkPermissions.UC_AFK_EXEMPT.get()) || config.getNode("time", "kicktime").getInt() == -1) { subtitle = Messages.getFormatted("afk.title.subtitle.exempt"); } else if (config.getNode("title", "subtitle-show-seconds").getBoolean(true)) { subtitle = Messages.getFormatted("afk.title.subtitle.kick", "%time%", TimeUtil.format(timediff, 3, null)); } else { subtitle = Messages.getFormatted("afk.title.subtitle.kick", "%time%", TimeUtil.format(timediff, 3, 11)); } if (config.getNode("title", "subtitle").getBoolean(false) && (!player.hasPermission(AfkPermissions.UC_AFK_EXEMPT.get()) || config.getNode("title", "subtitle-exempt").getBoolean(false))) { //Show subtitle player.sendTitle(Title.builder().title(title).subtitle(subtitle).fadeIn(0).fadeOut(20).stay(config.getNode("title", "subtitle-refresh").getInt()).build()); } else { //Don't show subtitle //TODO refresh? player.sendTitle(Title.builder().title(title).fadeIn(0).fadeOut(20).stay(config.getNode("title", "subtitle-refresh").getInt()).build()); } } } }
Example 6
Source File: KickallCommand.java From UltimateCore with MIT License | 5 votes |
@Override public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException { checkPermission(sender, KickPermissions.UC_KICK_KICKALL_BASE); Text reason = args.hasAny("reason") ? Text.of(args.getOne("reason")) : Messages.getFormatted(sender, "kick.command.kickall.defaultreason"); for (Player p : Sponge.getServer().getOnlinePlayers()) { if (p.equals(sender)) { continue; } p.kick(Messages.getFormatted("kick.command.kickall.message", "%kicker%", sender, "%reason%", reason)); } Messages.send(sender, "kick.command.kickall.success"); return CommandResult.success(); }