本文整理匯總了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);
}
}