当前位置: 首页>>代码示例>>Java>>正文


Java Player.isOnline方法代码示例

本文整理汇总了Java中org.bukkit.entity.Player.isOnline方法的典型用法代码示例。如果您正苦于以下问题:Java Player.isOnline方法的具体用法?Java Player.isOnline怎么用?Java Player.isOnline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.entity.Player的用法示例。


在下文中一共展示了Player.isOnline方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void run() {
	for (SignChangePacket packet : SignChangePacket.getList()) {
		if (packet.isReverted())
			continue;
		
		Player p = packet.getPlayer();
		if (p == null || !p.isOnline())
			continue;
		
		Date before = packet.getSentTime();
		Date now = new Date();
		int miliseconds = packet.getRevertTime() * 1000;
		
		if (now.getTime() - before.getTime() > miliseconds) {
			// Revert back to normal
			packet.revert();
		}
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:21,代码来源:SignChangePacketSchedule.java

示例2: executePlayer

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(Player p, PlayerDataRPG pd, String[] args) {
    String s = args[0];
    Player target = plugin.getServer().getPlayerExact(s);
    if (target != null && target.isOnline() && plugin.getPD(target) != null) {
        if (target.isOp()) {
            target.setOp(false);
            p.sendMessage("Deopped " + target.getName() + ".");
            target.sendMessage("You were deopped by " + p.getName() + ".");
        } else {
            p.sendMessage(target.getName() + " is not an op in the first place, lol.");
        }
    } else {
        p.sendMessage(ChatColor.RED + "Could not find online player '" + s + "'.");
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:17,代码来源:DeopCommand.java

示例3: executePlayer

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(Player p, PlayerDataRPG pd, String[] args) {
    String s = args[0];
    Player target = plugin.getServer().getPlayerExact(s);
    if (target != null && target.isOnline() && plugin.getPD(target) != null) {
        if (target.isOp()) {
            p.sendMessage(target.getName() + " is already op.");
        } else {
            target.setOp(true);
            p.sendMessage("Opped " + target.getName() + ".");
            target.sendMessage("You were given op by " + p.getName() + ".");
        }
    } else {
        p.sendMessage(ChatColor.RED + "Could not find online player '" + s + "'.");
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:17,代码来源:OpCommand.java

示例4: incrementUser

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void incrementUser(User user, String reason) {
    if(user == null) {
        System.err.println("User reported null!");
        return;
    }
    Player player = Bukkit.getPlayerExact(user.getName());
    if(player != null && user.getLevel() < MagicNumbers.MAX_WARN) {
        player.sendMessage(DynamicAC.prefix + "You've been warned for hacking!");
        if(reason.isEmpty()) {
            for (Player p : DynamicAC.instance.onlinestaff) {
                p.sendMessage(DynamicAC.prefix + player.getName() + " failed a check!");
            }
        }
        int warns = user.increment();
        user.serialize();
        DynamicAC.punishmentLog(user.getName() + " incremented to " + user.getLevel() + " at " + LocalDateTime.now()
                + ".");
        if (warns >= MagicNumbers.MAX_WARN && !player.isOnline()) {
            users.remove(user);
            user = null; // so it can be garbage collected
        }
    }
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:24,代码来源:UserManager.java

示例5: executePlayer

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(final Player p, PlayerData pd, String[] args) {
    if (args.length != 1 && args.length != 3) {
        p.sendMessage(ChatColor.RED + "Incorrect command format!");
        p.sendMessage(ChatColor.RED + ">> /tp <name> or /tp <x> <y> <z>");
        p.sendMessage(ChatColor.RED + ">> /tp Misaka");
        p.sendMessage(ChatColor.RED + ">> /tp 97 128 123");
    } else if (args.length == 1) {
        String s = args[0];
        Player target = plugin.getServer().getPlayerExact(s);
        if (target == p) {
            p.sendMessage(ChatColor.RED + "You can't teleport to yourself, silly!");
        } else {
            if (target != null && target.isOnline()) {
                if(noTP.contains(target.getName())) {
                    target.sendMessage(p.getName() + " tried to teleport to you!");
                    p.sendMessage(ChatColor.RED + "You can't teleport to that person right now!");
                } else {
                    p.teleport(target);
                }
            } else {
                p.sendMessage(ChatColor.RED + "Could not find online player '" + s + "'.");
            }
        }
    } else if (args.length == 3) {
        try {
            double x = Double.parseDouble(args[0]);
            double y = Double.parseDouble(args[1]);
            double z = Double.parseDouble(args[2]);
            Location loc = new Location(p.getWorld(), x, y, z);
            p.teleport(loc);
        } catch (Exception e) {
            p.sendMessage(ChatColor.RED + "Incorrect command format!");
            p.sendMessage(ChatColor.RED + ">> /tp <name> or /tp <x> <y> <z>");
            p.sendMessage(ChatColor.RED + ">> /tp Misaka");
            p.sendMessage(ChatColor.RED + ">> /tp 97 128 123");
        }
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaCore,代码行数:40,代码来源:TeleportCommand.java

示例6: executePlayer

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(Player p, PlayerDataRPG pd, String[] args) {
    String s = args[0];
    Player target = plugin.getServer().getPlayerExact(s);
    if (target != null && target.isOnline() && plugin.getPD(target) != null) {
        plugin.getPD(target).giveBurn(Integer.parseInt(args[1]), Integer.parseInt(args[2]));
        p.sendMessage("Gave " + target.getName() + " " + args[1] + " seconds of tier " + args[2] + " burn.");
    } else {
        p.sendMessage(ChatColor.RED + "Could not find online player '" + s + "'.");
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:12,代码来源:BurnCommand.java

示例7: executePlayer

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(Player p, PlayerDataRPG pd, String[] args) {
    Player target = plugin.getServer().getPlayerExact(args[0]);
    if (target != null && target.isOnline() && plugin.getPD(target) != null) {
        PlayerDataRPG pd2 = plugin.getPD(target);
        pd2.bank.clear();
        pd2.bank.setContents(pd.bank.getContents());
        pd.sendMessage("Set " + pd2.getName() + "'s bank to your bank.");
        pd2.sendMessage("Your bank was modified by " + pd.getName() + ".");
    } else {
        p.sendMessage(ChatColor.RED + "Could not find online player '" + args[0] + "'.");
        p.sendMessage(ChatColor.RED + "Attempting offline update...");
        String serBank = serializeBank(pd.getBankContents());
        RScheduler.scheduleAsync(plugin, () -> {
            p.sendMessage("Running query...");
            String query = "update main set bank = ? where name = ?";
            AutoCloseable[] ac_dub2 = SQLManager.prepare(query);
            PreparedStatement concat_reward = (PreparedStatement) ac_dub2[0];
            try {
                concat_reward.setString(1, serBank);
                concat_reward.setString(2, args[0]);
            } catch (Exception e) {
                e.printStackTrace();
            }
            SQLManager.execute(ac_dub2);
            SQLManager.close(ac_dub2);
            p.sendMessage("Modified " + args[0] + "'s bank");
        });
        return;
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:32,代码来源:SetBankCommand.java

示例8: quitFuture

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private ListenableFuture<?> quitFuture(Player player) {
    if(player.isOnline()) {
        final SettableFuture<?> future = SettableFuture.create();
        player.setMetadata(METADATA_KEY, new FixedMetadataValue(plugin, future));
        return future;
    } else {
        return Futures.immediateFuture(null);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:10,代码来源:PlayerServerChanger.java

示例9: openInv

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void openInv(final Player player){
    if(player == null){
        return;
    }
    if(!player.isOnline()){
        return;
    }
    executorService.execute(new Runnable() {
        @Override
        public void run() {
            HashMap<KitType,Integer> levelMap = WallSQLUtils.getKitMap(player);
            if(levelMap == null)
                return;

            Inventory inv = Bukkit.createInventory(null,54,name);
            for(KitType type : KitType.values()){
                if(!levelMap.containsKey(type) || levelMap.get(type) <= 0){
                    inv.addItem(fillInfo(type.getItem(),0, type.getMaxLevel(),type.getPrice(1), null,type.getDescription(type.getMaxLevel())));
                }else if(levelMap.get(type) >= type.getMaxLevel()){
                    inv.addItem(fillInfo(type.getItem(),levelMap.get(type), type.getMaxLevel(),-1,type.getDescription(levelMap.get(type)),type.getDescription(type.getMaxLevel())));
                }else {
                    inv.addItem(fillInfo(type.getItem(),levelMap.get(type), type.getMaxLevel(),type.getPrice(levelMap.get(type) + 1),type.getDescription(levelMap.get(type)),type.getDescription(type.getMaxLevel())));
                }
            }
            player.openInventory(inv);
        }
    });
}
 
开发者ID:JHXSMatthew,项目名称:CSGO_lobby,代码行数:29,代码来源:KitController.java

示例10: goPetToPlayer

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void goPetToPlayer(final Player player, final LivingEntity entity) {
    if (!InventoryManager.playerIsLoaded(player) || !player.isOnline() || entity.isDead()) {
        return;
    }

    Location target = player.getLocation();
    if (target.distance(entity.getLocation()) > 20) {
        PetManager.respawnPet(player);
    } else if (target.distance(entity.getLocation()) < 4) {
        return;
    }

    PetType petType = PetManager.getPetFromEntity(entity, player);
    double speedModifier = petType == null ? 1.0 : 0.4 / petType.getSpeed();

    Class<?> entityInsentientClass = MinecraftReflection.getMinecraftClass("EntityInsentient");
    Class<?> navigationAbstractClass = MinecraftReflection.getMinecraftClass("NavigationAbstract");

    try {
        Method getHandle = MinecraftReflection.getCraftEntityClass().getDeclaredMethod("getHandle");
        Object insentient = entityInsentientClass.cast(getHandle.invoke(entity));
        Object navigation = entityInsentientClass.getDeclaredMethod("getNavigation").invoke(insentient);
        navigationAbstractClass.getDeclaredMethod("a", double.class, double.class, double.class, double.class)
                .invoke(navigation, target.getX(), target.getY(), target.getZ(), speedModifier);
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
        e.printStackTrace();
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:29,代码来源:EntityUtils.java

示例11: getTeam2Players

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private List<Player> getTeam2Players() {
    List<Player> players = new ArrayList<>();

    for (UUID uuid : this.team2.keySet()) {
        Player p = Bukkit.getPlayer(uuid);

        if (p == null || !p.isOnline()) {
            continue;
        }

        players.add(p);
    }

    return players;
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:16,代码来源:TeamMatch.java

示例12: executeConsole

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executeConsole(CommandSender sender, String[] args) {
    if (args.length == 2) {
        Player p2 = plugin.getServer().getPlayer(args[0]);
        if (p2 != null && p2.isValid() && p2.isOnline()) {
            PlayerData pd2 = plugin.getPD(p2);
            pd2.setRank(args[1]);
            sender.sendMessage(ChatColor.GREEN + p2.getName() + "'s rank set to " + pd2.getChatRankPrefix().trim() + ChatColor.GREEN + ".");
            p2.sendMessage(ChatColor.GREEN + "Your rank was set to " + pd2.getChatRankPrefix().trim() + ChatColor.GREEN + ".");
        } else {
            sender.sendMessage("User is not online");
        }
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaCore,代码行数:15,代码来源:SetRankCommand.java

示例13: run

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void run(PAUser user, String label, String[] args) {
    if (args.length == 0) {
        new Helpers(user).sendToSpawn();
        return;
    }

    if(args.length == 1){
        if(!user.isOnRank(Grupo.Mod)) return;
        Player p = Bukkit.getPlayerExact(args[0]);
        if(!p.isOnline()) user.sendMessage("&4El jugador no existe o no está conectado.");
        new Helpers((PAUser) p).sendToSpawn();
        return;
    }
    user.sendMessage(Messages.getMessage(Messages.BUFF_ARGS, PAData.CORE));
}
 
开发者ID:cadox8,项目名称:PA,代码行数:16,代码来源:SpawnCMD.java

示例14: executePlayer

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(Player p, PlayerData pd, String[] args) {
    if(pd.getRank() == Rank.BUILDER)
        return;
    if (args.length < 3) {
        p.sendMessage(ChatColor.RED + "/mute <player> <time> <reason>");
        p.sendMessage(ChatColor.RED + "WARNING: Do not abuse staff privileges.");
    } else if (args.length >= 3) {
        Player p2 = plugin.getServer().getPlayer(args[0]);
        if (p2 != null && p2.isValid() && p2.isOnline()) {
            if (!executeMute(p2.getName(), p2.getUniqueId().toString(), args, p.getName(), p2)) {
                p.sendMessage(ChatColor.RED + "/mute <player> <time> <reason>");
                p.sendMessage(ChatColor.RED + "WARNING: Do not abuse staff privileges.");
            }
        } else {
            RScheduler.scheduleAsync(plugin, () -> {
                OfflinePlayer offline = plugin.getServer().getOfflinePlayer(args[0]);
                String name = offline.getName();
                String uuid = offline.getUniqueId().toString();
                RScheduler.schedule(plugin, () -> {
                    if (!executeMute(name, uuid, args, p.getName(), null) && p.isOnline()) {
                        p.sendMessage(ChatColor.RED + "/mute <player> <time> <reason>");
                        p.sendMessage(ChatColor.RED + "WARNING: Do not abuse staff privileges.");
                    }
                });
            });
            p.sendMessage("Player is not online, executing offline mute.");
        }
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaCore,代码行数:31,代码来源:MuteCommand.java

示例15: onCommand

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  	if (Rank.getRank(sender.getName()).getType().getLevel() < RankType.MOD.getLevel()) {
  		Chat.player(sender, "&cYou don't have permission to do this.");
  		return true;
  	}
      if (args.length < 3) {
      	Chat.player(sender, "&cUsage: /tempban [username] [time] [reason]");
      	return true;
      }
      
      String username = null;
      String reason = Chat.stripColor(StringUtils.join(args, " ", 2, args.length));
      
      Player p = Bukkit.getPlayerExact(args[0]);
      if (p != null)
      	username = p.getName();
      else {
      	String check = Hive.getInstance().getUsername(args[0]);
      	if (check != null)
      		username = check;
      }
      if (username == null) {
      	Chat.player(sender, "&cNo player found by the name of, " + args[0]);
      	return true;
      }
      
      int duration = parseTime(args[1]);
      if (duration == 0) {
          Chat.player(sender, "&cInvalid duration! (ex. 10m, 6h, 1d, 1w)");
          return true;
      }
      String prefix = "INSERT INTO infractions (username,staff,type,end,reason) VALUES ";
      String content = "('" + username + "','" + sender.getName() + "','tempban',DATE_ADD(now(), INTERVAL " + duration + " SECOND),'" + reason + "')";
      Hive.getInstance().getDatabase().update(prefix + content);
      Chat.player(sender, "&4[Tempban] &b" + username + " &7&ofor &c" + reason + " &7(" + getDuration(args[1]) + ")");
      
      Date expires = null;
      ResultSet r = Hive.getInstance().getDatabase().query("SELECT DATE_ADD(now(), INTERVAL " + duration + " SECOND)");
      try {
	while (r.next())
		expires = r.getTimestamp("DATE_ADD(now(), INTERVAL " + duration + " SECOND)");
} catch (SQLException e) {
	e.printStackTrace();
}
      	
      Tempban i = new Tempban(username, reason, Hive.getInstance().getServerTime(), expires);
    	if (p != null && p.isOnline())
    		p.kickPlayer(i.getKickMessage());
    	
  	return true;
  }
 
开发者ID:thekeenant,项目名称:mczone,代码行数:53,代码来源:TempbanCmd.java


注:本文中的org.bukkit.entity.Player.isOnline方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。