当前位置: 首页>>代码示例>>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;未经允许,请勿转载。