當前位置: 首頁>>代碼示例>>Java>>正文


Java Player.isOnline方法代碼示例

本文整理匯總了Java中cn.nukkit.Player.isOnline方法的典型用法代碼示例。如果您正苦於以下問題:Java Player.isOnline方法的具體用法?Java Player.isOnline怎麽用?Java Player.isOnline使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cn.nukkit.Player的用法示例。


在下文中一共展示了Player.isOnline方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: QueryRegenerateEvent

import cn.nukkit.Player; //導入方法依賴的package包/類
public QueryRegenerateEvent(Server server, int timeout) {
    this.timeout = timeout;
    this.serverName = server.getMotd();
    this.listPlugins = (boolean) server.getConfig("settings.query-plugins", true);
    this.plugins = server.getPluginManager().getPlugins().values().toArray(new Plugin[server.getPluginManager().getPlugins().values().size()]);
    List<Player> players = new ArrayList<>();
    for (Player player : server.getOnlinePlayers().values()) {
        if (player.isOnline()) {
            players.add(player);
        }
    }
    this.players = players.toArray(new Player[players.size()]);

    this.gameType = (server.getGamemode() & 0x01) == 0 ? "SMP" : "CMP";
    this.version = server.getVersion();
    this.server_engine = server.getName() + " " + server.getNukkitVersion();
    this.map = server.getDefaultLevel() == null ? "unknown" : server.getDefaultLevel().getName();
    this.numPlayers = this.players.length;
    this.maxPlayers = server.getMaxPlayers();
    this.whitelist = server.hasWhitelist() ? "on" : "off";
    this.port = server.getPort();
    this.ip = server.getIp();
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:24,代碼來源:QueryRegenerateEvent.java

示例2: execute

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!this.testPermission(sender)) {
        return true;
    }
    String online = "";
    int onlineCount = 0;
    for (Player player : sender.getServer().getOnlinePlayers().values()) {
        if (player.isOnline() && (!(sender instanceof Player) || ((Player) sender).canSee(player))) {
            online += player.getDisplayName() + ", ";
            ++onlineCount;
        }
    }

    if (online.length() > 0) {
        online = online.substring(0, online.length() - 2);
    }

    sender.sendMessage(new TranslationContainer("commands.players.list",
            new String[]{String.valueOf(onlineCount), String.valueOf(sender.getServer().getMaxPlayers())}));
    sender.sendMessage(online);
    return true;
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:24,代碼來源:ListCommand.java

示例3: QueryRegenerateEvent

import cn.nukkit.Player; //導入方法依賴的package包/類
public QueryRegenerateEvent(Server server, int timeout) {
    this.timeout = timeout;
    this.serverName = server.getMotd();
    this.listPlugins = (boolean) server.getConfig("settings.query-plugins", true);
    this.plugins = server.getPluginManager().getPlugins().values().toArray(new Plugin[server.getPluginManager().getPlugins().values().size()]);
    List<Player> players = new ArrayList<>();
    for (Player player : server.getOnlinePlayers().values()) {
        if (player.isOnline()) {
            players.add(player);
        }
    }
    this.players = players.toArray(new Player[players.size()]);

    this.gameType = (server.getDefaultGamemode() & 0x01) == 0 ? "SMP" : "CMP";
    this.version = server.getVersion();
    this.server_engine = server.getName() + " " + server.getNukkitVersion();
    this.map = server.getDefaultLevel() == null ? "unknown" : server.getDefaultLevel().getName();
    this.numPlayers = this.players.length;
    this.maxPlayers = server.getMaxPlayers();
    this.whitelist = server.hasWhitelist() ? "on" : "off";
    this.port = server.getPort();
    this.ip = server.getIp();
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:24,代碼來源:QueryRegenerateEvent.java

示例4: execute

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!this.testPermission(sender)) {
        return true;
    }

    String online = "";
    StringBuffer onlineBuffer = new StringBuffer();
    int onlineCount = 0;
    for (Player player : sender.getServer().getOnlinePlayers().values()) {
        if (player.isOnline() && (!(sender instanceof Player) || ((Player) sender).canSee(player))) {
            onlineBuffer.append(player.getDisplayName() + ", ");
            ++onlineCount;
        }
    }

    if (onlineBuffer.length() > 0) {
        online = onlineBuffer.substring(0, onlineBuffer.length() - 2);
    }

    sender.sendMessage(new TranslationContainer("commands.players.list",
            new String[]{String.valueOf(onlineCount), String.valueOf(sender.getServer().getMaxPlayers())}));
    sender.sendMessage(online);
    return true;
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:26,代碼來源:ListCommand.java

示例5: spawnToAll

import cn.nukkit.Player; //導入方法依賴的package包/類
public void spawnToAll() {
    if (this.chunk == null || this.closed) {
        return;
    }

    for (Player player : this.level.getChunkPlayers(this.chunk.getX(), this.chunk.getZ()).values()) {
        if (player.isOnline()) {
            this.spawnTo(player);
        }
    }
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:12,代碼來源:Entity.java

示例6: hidePlayer

import cn.nukkit.Player; //導入方法依賴的package包/類
/**隱藏後無法重新顯示 , 放棄*/
@Deprecated
private void hidePlayer(Player p){
    for(Player pl : getServer().getOnlinePlayers().values()){
        if(pl.isOnline()){
            pl.hidePlayer(p);
        }
    }
}
 
開發者ID:azon0320,項目名稱:Nukkit-LoginFrame,代碼行數:10,代碼來源:Login.java

示例7: showPlayer

import cn.nukkit.Player; //導入方法依賴的package包/類
/** 無法顯示, 放棄 */
@Deprecated
private void showPlayer(Player p){
    for(Player pl : getServer().getOnlinePlayers().values()){
        if(pl.isOnline()){
            pl.showPlayer(p);
        }
    }
}
 
開發者ID:azon0320,項目名稱:Nukkit-LoginFrame,代碼行數:10,代碼來源:Login.java

示例8: runCommand

import cn.nukkit.Player; //導入方法依賴的package包/類
private void runCommand(Command command) {
    Player player = Server.getInstance().getPlayerExact(command.getPlayer().getName());
    if (command.isRequiredOnline() && (player == null || !player.isOnline())) {
        return;
    }

    if (command.getRequiredSlots() > 0 && (player != null && player.isOnline())) {
        if (getEmptySlots(player.getInventory()) < command.getRequiredSlots()) {
            return;
        }
    }

    if (MCMarket.getApi().setExecuted(command.getId())) {
        plugin.getServer().getScheduler().scheduleDelayedTask(plugin, new AsyncTask() {
            @Override
            public void onRun() {
                plugin.getServer().getScheduler().scheduleTask(plugin, () -> plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), command.getCommand()));
                if (command.isRepeat()) {
                    long period = command.getRepeatPeriod() > 0 ? 20 * 60 * 60 * command.getRepeatPeriod() : 1;
                    new NukkitRunnable() {
                        int executed = 0;

                        @Override
                        public void run() {
                            plugin.getServer().getScheduler().scheduleTask(plugin, () -> plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), command.getCommand()));
                            executed++;

                            if (executed >= command.getRepeatCycles()) {
                                cancel();
                            }
                        }
                    }.runTaskTimerAsynchronously(plugin, (int) period, (int) period);
                }
            }
        }, command.getDelay() > 0 ? (int) (20 * command.getDelay()) : 1, true);
    }
}
 
開發者ID:MinecraftMarket,項目名稱:MinecraftMarket-Plugin,代碼行數:38,代碼來源:PurchasesTask.java

示例9: sendArmorAll

import cn.nukkit.Player; //導入方法依賴的package包/類
public void sendArmorAll() {
       for (Player player : this.level.getChunkPlayers(this.chunk.getX(), this.chunk.getZ()).values()) {
           if (player.isOnline()) {
               this.sendArmor(player);
           }
       }
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:8,代碼來源:EntityArmorStand.java

示例10: execute

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (args.length == 0) {
        String commands = "";
        StringBuffer commandsBuffer = new StringBuffer();
        for (Player player : sender.getServer().getOnlinePlayers().values()) {
            if (player.isOnline() && (!(sender instanceof Player) || ((Player) sender).canSee(player))) {
                commandsBuffer.append(player.getDisplayName() + ", ");
            }
        }

        commands = commandsBuffer.substring(0, commandsBuffer.length() - 2);
        sender.sendMessage(commands);

        return true;
    } else if (args.length == 1) {
        if (Arrays.asList(CommandParameter.GAMERULE_LIST).contains(args[0])) {
            if (sender instanceof Player) {
                sender.sendMessage(args[0] + " = " + ((Player) sender).getLevel().getGameRules().getBoolean(args[0]));
            } else {
                sender.sendMessage(new TranslationContainer("commands.generic.ingame"));
            }
        } else {
            sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
        }
        return true;
    } else if (args.length == 2) {
        if (sender instanceof Player) {
            if (Arrays.asList(CommandParameter.GAMERULE_LIST).contains(args[0])) {
                if (args[1].equals("true") || args[1].equals("false")) {
                    ((Player) sender).getLevel().getGameRules().setGameRule(args[0], args[1]);
                    sender.sendMessage("ゲーム ルール " + args[0] + " が " + args[1] + " に更新されました");
                    return true;
                } else {
                    sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
                }
            } else {
                sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
            }
        } else {
            sender.sendMessage(new TranslationContainer("commands.generic.ingame"));
        }
        return true;
    }

    sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
    return true;
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:49,代碼來源:GameruleCommand.java


注:本文中的cn.nukkit.Player.isOnline方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。