本文整理汇总了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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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()));
}
}
示例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;
}