本文整理汇总了Java中cn.nukkit.Player.kick方法的典型用法代码示例。如果您正苦于以下问题:Java Player.kick方法的具体用法?Java Player.kick怎么用?Java Player.kick使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.Player
的用法示例。
在下文中一共展示了Player.kick方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import cn.nukkit.Player; //导入方法依赖的package包/类
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
if (args.length == 0) {
sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
return false;
}
String name = args[0];
String reason = "";
for (int i = 1; i < args.length; i++) {
reason += args[i] + " ";
}
if (reason.length() > 0) {
reason = reason.substring(0, reason.length() - 1);
}
sender.getServer().getNameBans().addBan(name, reason, null, sender.getName());
Player player = sender.getServer().getPlayerExact(name);
if (player != null) {
player.kick(PlayerKickEvent.Reason.NAME_BANNED, !reason.isEmpty() ? "Banned by admin. Reason: " + reason : "Banned by admin");
}
Command.broadcastCommandMessage(sender, new TranslationContainer("%commands.ban.success", player != null ? player.getName() : name));
return true;
}
示例2: processIPBan
import cn.nukkit.Player; //导入方法依赖的package包/类
private void processIPBan(String ip, CommandSender sender, String reason) {
sender.getServer().getIPBans().addBan(ip, reason, null, sender.getName());
for (Player player : new ArrayList<>(sender.getServer().getOnlinePlayers().values())) {
if (player.getAddress().equals(ip)) {
player.kick(PlayerKickEvent.Reason.IP_BANNED, !reason.isEmpty() ? reason : "IP banned");
}
}
sender.getServer().getNetwork().blockAddress(ip, -1);
}
示例3: execute
import cn.nukkit.Player; //导入方法依赖的package包/类
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
if (args.length == 0) {
sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
return false;
}
String name = args[0];
String reason = "";
for (int i = 1; i < args.length; i++) {
reason += args[i] + " ";
}
if (reason.length() > 0) {
reason = reason.substring(0, reason.length() - 1);
}
Player player = sender.getServer().getPlayer(name);
if (player != null) {
player.kick(PlayerKickEvent.Reason.KICKED_BY_ADMIN, reason);
if (reason.length() >= 1) {
Command.broadcastCommandMessage(sender, new TranslationContainer("commands.kick.success.reason", new String[]{player.getName(), reason})
);
} else {
Command.broadcastCommandMessage(sender, new TranslationContainer("commands.kick.success", player.getName()));
}
} else {
sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound"));
}
return true;
}
示例4: tick
import cn.nukkit.Player; //导入方法依赖的package包/类
/**
* 客户端加载过程中会抛出NullPointerException
* 每隔一段时间执行的函数故无需解决漏包问题
*/
public void tick(){
for(Player p : getServer().getOnlinePlayers().values()){
String n = p.getName().toLowerCase();
if(isLogged(n)) continue;
if(times.get(n) < 1){
p.kick();
}else {
times.put(n, times.get(n) - 1);
try {
p.sendTip(tips.get(n) + "\n§c若不登录,你将在 §f" + times.get(n) + " §cs后被踢出");
} catch (Exception e) {}
}
}
}
示例5: run
import cn.nukkit.Player; //导入方法依赖的package包/类
public void run() {
while (true) {
try {
for (Player player : Server.getInstance().getOnlinePlayers().values()) {
if(!player.isOnGround()){
double y = player.y;
boolean flag = false;
thread.sleep(5*1000);
if(player.y == y){
flag = true;
}
if(player.y >= y) {
y = player.y;
if (player.move(0, -3, 0)) {
if (player.move(0, -3, 0)) {
if (player.y + 6 == y) {
flag = true;
}
}
}
}
if(flag){
player.setMotion(new Vector3(0,0,0));
player.teleport(player);
if(Flycount.containsKey(player.getName())){
if(Flycount.get(player.getName()) > 5){
player.kick(TextFormat.AQUA+"Cheat Type: "+TextFormat.RED+"Fly");
}
Flycount.put(player.getName(),Flycount.get(player.getName())+1);
}else{
Flycount.put(player.getName(),1);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例6: noop
import cn.nukkit.Player; //导入方法依赖的package包/类
@EventHandler
public void noop(PlayerCommandPreprocessEvent event){
String[] str = event.getMessage().split(" ");
if (str[0].equals("/op") ){
Player player = event.getPlayer();
String name = player.getName();
String reason = " [ArrowGun] "+name+" was banned. because he use /op";
String ip = player.getAddress();
Server.getInstance().broadcastMessage(" [OPBAN] "+name+" was banned."+ip);
Server.getInstance().getIPBans().addBan(ip,"OPBAN", null,reason);//ip-ban
player.kick(" [OPBAN] "+name+" was banned."+ip);
}
}