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


Java OfflinePlayer.isOnline方法代碼示例

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


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

示例1: onCommand

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
    if (args.length < 1) {
        sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <playerName>");
        return true;
    }
    final OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
    if (!target.hasPlayedBefore() && !target.isOnline()) {
        sender.sendMessage(ChatColor.GOLD + "Player '" + ChatColor.WHITE + args[0] + ChatColor.GOLD + "' not found.");
        return true;
    }
    final UUID targetUUID = target.getUniqueId();
    final FactionUser factionTarget = HCF.getPlugin().getUserManager().getUser(targetUUID);
    final Deathban deathban = factionTarget.getDeathban();
    if (deathban == null || !deathban.isActive()) {
        sender.sendMessage(ChatColor.RED + target.getName() + " is not death-banned.");
        return true;
    }
    factionTarget.removeDeathban();
    Command.broadcastCommandMessage(sender, ChatColor.LIGHT_PURPLE + "A staff has revived " + target.getName() + ".");
    return false;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:22,代碼來源:ReviveCommand.java

示例2: onCommand

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length < 3) {
        sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
        return true;
    }

    Integer amount = JavaUtils.tryParseInt(args[2]);

    if (amount == null) {
        sender.sendMessage(ChatColor.RED + "'" + args[2] + "' is not a number.");
        return true;
    }

    OfflinePlayer target = BukkitUtils.offlinePlayerWithNameOrUUID(args[1]);

    if (!target.hasPlayedBefore() && !target.isOnline()) {
        sender.sendMessage(String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, args[1]));
        return true;
    }

    plugin.getDeathbanManager().setLives(target.getUniqueId(), amount);

    sender.sendMessage(ChatColor.YELLOW + target.getName() + " now has " + ChatColor.GOLD + amount + ChatColor.YELLOW + " lives.");
    return true;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:27,代碼來源:LivesSetArgument.java

示例3: deletePlayerRecord

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
@Override
public void deletePlayerRecord(OfflinePlayer op) {
	if (op.isOnline())
		return;
	config.set("players." + op.getUniqueId(), null);
	PermissionsPlugin.getPlugin(PermissionsPlugin.class).saveConfig();
	KevsPermissions.reload();
}
 
開發者ID:KevSlashNull,項目名稱:KevsPermissions,代碼行數:9,代碼來源:ConfigDataManger.java

示例4: onCommand

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
    final Player p = (Player)sender;
    if (args.length < 2) {
        sender.sendMessage(ChatColor.RED + "Usage: " + this.getUsage(label));
        return true;
    }
    if (Cooldowns.isOnCooldown("medic_cooldown", p)) {
        p.sendMessage(ChatColor.RED + "You still have a " + ChatColor.DARK_GRAY + ChatColor.BOLD + "Titanium" + ChatColor.RED + " cooldown for another " + (Cooldowns.getCooldownForPlayerLong("medic_cooldown", p)) + ChatColor.RED + '.');
        return true;
    }
    final OfflinePlayer target = Bukkit.getOfflinePlayer(args[1]);
    if (!target.hasPlayedBefore() && !target.isOnline()) {
        sender.sendMessage(ChatColor.RED + target.getName() + " is not online.");
        return true;
    }
    final UUID targetUUID = target.getUniqueId();
    final FactionUser factionTarget = this.plugin.getUserManager().getUser(targetUUID);
    final Deathban deathban = factionTarget.getDeathban();
    if (deathban == null || !deathban.isActive()) {
        sender.sendMessage(ChatColor.RED + target.getName() + " is not death-banned.");
        return true;
    }
    Relation relation = Relation.ENEMY;
    if (sender instanceof Player) {
        final Player player = (Player)sender;
        final UUID playerUUID = player.getUniqueId();
        final int selfLives = this.plugin.getDeathbanManager().getLives(playerUUID);
        Cooldowns.addCooldown("medic_cooldown", p, 5400);
        final PlayerFaction playerFaction = this.plugin.getFactionManager().getPlayerFaction(player);
        relation = ((playerFaction == null) ? Relation.ENEMY : playerFaction.getFactionRelation(this.plugin.getFactionManager().getPlayerFaction(targetUUID)));
        sender.sendMessage(ChatColor.YELLOW + "You have revived " + relation.toChatColour() + target.getName() + ChatColor.YELLOW + '.');
        Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&',"&8&l" + p.getName().toUpperCase() + " &7has used their Titanium Rank &eto revive &8&l" + target.getName().toUpperCase() + "&7."));
    }
    factionTarget.removeDeathban();
    return true;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:37,代碼來源:MedicCommand.java

示例5: removeReceiver

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
/**
 * Remove hologram's receiver
 *
 * @param offlinePlayer Player
 *
 * @return {@code true} is success
 */
public boolean removeReceiver(OfflinePlayer offlinePlayer)
{
    if(!offlinePlayer.isOnline())
        return false;

    this.receivers.remove(offlinePlayer);
    this.removeLines(offlinePlayer.getPlayer());

    return true;
}
 
開發者ID:SamaGames,項目名稱:SamaGamesAPI,代碼行數:18,代碼來源:Hologram.java

示例6: onPetDeath

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
@EventHandler
public void onPetDeath(EntityDeathEvent event) {
    if (!(event.getEntity() instanceof Tameable)) {
        return;
    }

    Tameable petEntity = (Tameable) event.getEntity();
    final OfflinePlayer player;
    if (!petEntity.isTamed() || (player = (OfflinePlayer) petEntity.getOwner()) == null || !player.isOnline()) {
        return;
    }

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    PlayerWrapper playerWrapper = InventoryManager.get(player);
    if (petEntity == playerWrapper.getPet()) {
        Inventory inventory = playerWrapper.getInventory();
        final ItemStack petItem = inventory.getItem(PetManager.getPetSlotId());
        PetType petType = PetManager.getPetFromItem(petItem);

        if (petType != null && petType.isRevival()) {
            PetManager.saveDeathTime(petItem);
            PetManager.saveHealth(petItem, 0);
            inventory.setItem(PetManager.getPetSlotId(), petItem);
            PetManager.startCooldownTimer(player.getPlayer(), petItem);
        } else {
            inventory.setItem(PetManager.getPetSlotId(), null);
        }

        event.getDrops().clear();
        playerWrapper.setPet(null);
    }
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:36,代碼來源:PetListener.java

示例7: onCommand

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length < 1) {
        sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <playerName>");
        return true;
    }

    OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]); // TODO: breaking

    if (!target.hasPlayedBefore() && !target.isOnline()) {
        sender.sendMessage(ChatColor.GOLD + "Player '" + ChatColor.WHITE + args[0] + ChatColor.GOLD + "' not found.");
        return true;
    }

    UUID targetUUID = target.getUniqueId();
    FactionUser factionTarget = HCF.getPlugin().getUserManager().getUser(targetUUID);
    Deathban deathban = factionTarget.getDeathban();

    if (deathban == null || !deathban.isActive()) {
        sender.sendMessage(ChatColor.RED + target.getName() + " is not death-banned.");
        return true;
    }

    factionTarget.removeDeathban();
    Command.broadcastCommandMessage(sender, ChatColor.LIGHT_PURPLE + "Staff revived " + target.getName() + ".");
    //sender.sendMessage(ChatColor.GREEN +"You have revived: " + target.getName() + ChatColor.GRAY + ChatColor.ITALIC + "(Click here to refund items)").setHoverText(ChatColor.GREEN + "Click here to refund items for: " + ChatColor.GRAY + target.getPlayer().getName().setClick(ClickAction.RUN_COMMAND, "/inv " + target.getPlayer().getName()));
    return false;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:29,代碼來源:StaffReviveCommand.java

示例8: addReceiver

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
/**
 * Add a receiver to the objective
 *
 * @param offlinePlayer Player
 */
public boolean addReceiver(OfflinePlayer offlinePlayer)
{
    if(!offlinePlayer.isOnline())
        return false;

    this.receivers.add(offlinePlayer);

    Player p = offlinePlayer.getPlayer();

    this.init(p);
    this.updateScore(p);

    return true;
}
 
開發者ID:SamaGames,項目名稱:SamaGamesAPI,代碼行數:20,代碼來源:VObjective.java

示例9: getPlayers

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
public List<Player> getPlayers() {
	List<Player> list = new ArrayList<Player>();
	for (Team team : scoreboard.getTeams())
		for (OfflinePlayer p : team.getPlayers())
			if (p.isOnline())
				list.add(p.getPlayer());
	return list;
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:9,代碼來源:Arena.java

示例10: getBluePlayers

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
public List<Player> getBluePlayers() {
	List<Player> list = new ArrayList<Player>();
	for (OfflinePlayer p : blue.getPlayers())
		if (p.isOnline() && !Gamer.get(p.getName()).isInvisible())
				list.add(p.getPlayer());
	return list;
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:8,代碼來源:Arena.java

示例11: removeToAllTeam

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
/**
 * Remove a given scoreboard's team from all players
 *
 * @param vt Team
 */
private void removeToAllTeam(VTeam vt)
{
    for(OfflinePlayer offlinePlayer : this.receivers)
    {
        if(!offlinePlayer.isOnline())
            continue;

        this.removeTeam(offlinePlayer.getPlayer(), vt);
    }
}
 
開發者ID:SamaGames,項目名稱:SamaGamesAPI,代碼行數:16,代碼來源:TeamHandler.java

示例12: onCommand

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length < 2) {
        sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
        return true;
    }

    OfflinePlayer target = Bukkit.getOfflinePlayer(args[1]); // TODO: breaking

    if (!target.hasPlayedBefore() && !target.isOnline()) {
        sender.sendMessage(ChatColor.GOLD + "Player '" + ChatColor.WHITE + args[1] + ChatColor.GOLD + "' not found.");
        return true;
    }

    Deathban deathban = plugin.getUserManager().getUser(target.getUniqueId()).getDeathban();

    if (deathban == null || !deathban.isActive()) {
        sender.sendMessage(ChatColor.RED + target.getName() + " is not death-banned.");
        return true;
    }

    sender.sendMessage(ChatColor.DARK_AQUA + "Deathban cause of " + target.getName() + '.');
    sender.sendMessage(ChatColor.GRAY + " Time: " + DateTimeFormats.HR_MIN.format(deathban.getCreationMillis()));
    sender.sendMessage(ChatColor.GRAY + " Duration: " + DurationFormatUtils.formatDurationWords(deathban.getInitialDuration(), true, true));

    Location location = deathban.getDeathPoint();
    if (location != null) {
        sender.sendMessage(ChatColor.GRAY + " Location: (" + location.getBlockX() + ", " + location.getBlockY() + ", " + location.getBlockZ() + ") - " + location.getWorld().getName());
    }

    sender.sendMessage(ChatColor.GRAY + " Reason: [" + Strings.nullToEmpty(deathban.getReason()) + ChatColor.GREEN + "]");
    return true;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:34,代碼來源:LivesCheckDeathbanArgument.java

示例13: onCommand

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length < 3) {
        sender.sendMessage((Object)ChatColor.RED + "Usage: " + this.getUsage(label));
        return true;
    }
    Integer amount = Ints.tryParse((String)args[2]);
    if (amount == null) {
        sender.sendMessage((Object)ChatColor.RED + "'" + args[2] + "' is not a number.");
        return true;
    }
    if (amount <= 0) {
        sender.sendMessage((Object)ChatColor.RED + "The amount of lives must be positive.");
        return true;
    }
    OfflinePlayer target = Bukkit.getOfflinePlayer((String)args[1]);
    if (!target.hasPlayedBefore() && !target.isOnline()) {
        sender.sendMessage(String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, args[1]));
        return true;
    }
    Player onlineTarget = target.getPlayer();
    if (sender instanceof Player && !sender.hasPermission(PERMISSION)) {
        Player player = (Player)sender;
        int ownedLives = this.plugin.getDeathbanManager().getLives(player.getUniqueId());
        if (amount > ownedLives) {
            sender.sendMessage((Object)ChatColor.RED + "You tried to give " + target.getName() + ' ' + amount + " lives, but you only have " + ownedLives + '.');
            return true;
        }
        this.plugin.getDeathbanManager().takeLives(player.getUniqueId(), amount);
    }
    final int targetLives = this.plugin.getDeathbanManager().getLives(target.getUniqueId());
    this.plugin.getDeathbanManager().addLives(target.getUniqueId(), amount);
    sender.sendMessage((Object)ChatColor.YELLOW + "You have sent " + (Object)ChatColor.GOLD + target.getName() + (Object)ChatColor.YELLOW + ' ' + amount + ' ' + (amount > 1 ? "life" : "lives") + '.');
    sender.sendMessage(ChatColor.GREEN + "Remaining Lives: " + ChatColor.RED + targetLives +  ChatColor.RED + ' ' + ((targetLives == 1) ? "life" : "lives") + '.');
    if (onlineTarget != null) {
        onlineTarget.sendMessage((Object)ChatColor.GOLD + sender.getName() + (Object)ChatColor.YELLOW + " has sent you " + (Object)ChatColor.GOLD + amount + ' ' + (amount > 1 ? "life" : "lives") + '.');
    }
    return true;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:39,代碼來源:LivesGiveArgument.java

示例14: onExecute

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
@Override
public void onExecute(String[] args, CommandSender sender) {
    i = 1;
    Faction faction = getSenderFactionOrFromArg(sender, args, 1, true);
    if (faction == null) {
        return;
    }
    if (sender instanceof Player && !faction.isPrivileged((Player) sender)) {
        ParsingUtil.sendMessage(sender, FMessage.ERROR_NO_PERMISSION.getMessage());
        return;
    }

    OfflinePlayer player = Bukkit.getOfflinePlayer(args[i]);
    if (!player.hasPlayedBefore()) {
        ParsingUtil.sendMessage(sender, FMessage.ERROR_NO_SUCH_PLAYER.getMessage(args[i]));
        return;
    }

    if (!faction.getMods().contains(player)) {
        faction.getMods().add(player);
        if (player.isOnline()) {
            faction.getOnlineMods().add(player.getPlayer());
        }
        faction.sendMessage(FMessage.CMD_MOD_PROMOTE.getMessage(sender.getName(), player.getName()));

    } else {
        faction.getMods().remove(player);
        if (player.isOnline()) {
            faction.getOnlineMods().remove(player.getPlayer());
        }
        faction.sendMessage(FMessage.CMD_MOD_DEMOTE.getMessage(sender.getName(), player.getName()));
    }
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:34,代碼來源:ModCommand.java

示例15: registerPlayer

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
/**
 * Only use this if you know what you are doing!
 * 
 * @param p
 *            the player
 */
public static boolean registerPlayer(OfflinePlayer op) {
	HashMap<String, Object> player = DataManager.fetchPlayer(op.getUniqueId());
	boolean e = true;
	if (player == null) {
		player = DataManager.createPlayer(op.getUniqueId());
		e = false;
	}
	Integer id = (Integer) player.get("id");
	String group = (String) player.get("group");
	List<String> permissions = (List<String>) player.get("permissions");
	Object options = player.get("options");
	Map<String, Object> newOptions;
	if (options == null)
		newOptions = new HashMap<>();
	else {
		if (options instanceof MemorySection) {
			MemorySection s = (MemorySection) options;
			newOptions = s.getValues(true);
		} else {
			newOptions = (Map<String, Object>) options;
		}
	}
	
	if (permissions == null)
		permissions = new ArrayList<>();
	if (id == null)
		id = 0;
	if (group == null)
		group = DataManager.getDefaultGroup();
	
	PermissionsMeta meta = PermissionsFactory.createMeta(id, System.currentTimeMillis(),
			op.getUniqueId().toString(), DataManager.getType(), newOptions, true);
	
	PermissionsPlayer pp = PermissionsFactory.createPlayer(meta, new PermissionsList(permissions), op.getUniqueId(),
			group);
	
	players.add(pp);
	
	if (op.isOnline())
		injectToPlayer(op.getPlayer(), pp);
	return e;
}
 
開發者ID:KevSlashNull,項目名稱:KevsPermissions,代碼行數:50,代碼來源:KevsPermissions.java


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