本文整理汇总了Java中org.bukkit.OfflinePlayer.hasPlayedBefore方法的典型用法代码示例。如果您正苦于以下问题:Java OfflinePlayer.hasPlayedBefore方法的具体用法?Java OfflinePlayer.hasPlayedBefore怎么用?Java OfflinePlayer.hasPlayedBefore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.OfflinePlayer
的用法示例。
在下文中一共展示了OfflinePlayer.hasPlayedBefore方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onExecute
import org.bukkit.OfflinePlayer; //导入方法依赖的package包/类
@Override
public void onExecute(String[] args, CommandSender sender) {
OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]);
if (!player.hasPlayedBefore()) {
ParsingUtil.sendMessage(sender, FMessage.ERROR_NO_SUCH_PLAYER.getMessage(), args[2]);
return;
} else if (!plugin.getFPlayerCache().getByPlayer(player).hasFaction()) {
ParsingUtil.sendMessage(sender, FMessage.ERROR_PLAYER_NOT_IN_ANY_FACTION.getMessage(), args[2]);
return;
}
Faction faction = plugin.getFactionCache().getByMember(player);
if (!faction.isPrivileged(sender)) {
ParsingUtil.sendMessage(sender, FMessage.ERROR_NO_PERMISSION.getMessage());
return;
} else if (faction.getMods().contains(player) && sender instanceof Player && !faction.isAdmin(sender)) {
ParsingUtil.sendMessage(sender, FMessage.ERROR_NO_PERMISSION.getMessage());
return;
}
faction.kick(sender, player);
}
示例2: 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 (!faction.isAdmin(sender) && !FPermission.hasPermission(sender, FPermission.BYPASS)) {
ParsingUtil.sendMessage(sender, FMessage.ERROR_NO_PERMISSION.getMessage(), args[i]);
return;
}
OfflinePlayer player = Bukkit.getOfflinePlayer(args[i]);
if (!player.hasPlayedBefore()) {
ParsingUtil.sendMessage(sender, FMessage.ERROR_NO_SUCH_PLAYER.getMessage(), args[i]);
return;
}
if (!faction.getMembers().contains(player)) {
ParsingUtil.sendMessage(sender, FMessage.ERROR_PLAYER_NOT_IN_FACTION.getMessage(), player.getName(), faction.getName());
return;
}
faction.setAdmin(player);
ParsingUtil.broadcastMessage(FMessage.CMD_ADMIN_SUCCESS.getMessage(), sender, player, faction);
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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()));
}
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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: /" + label + " <playerName> <amount>");
return true;
}
Integer amount = JavaUtils.tryParseInt(args[1]);
if (amount == null) {
sender.sendMessage(ChatColor.RED + "'" + args[1] + "' is not a valid number.");
return true;
}
if (amount <= 0) {
sender.sendMessage(ChatColor.RED + "You must send money in positive quantities.");
return true;
}
// Calculate the senders balance here.
Player senderPlayer = sender instanceof Player ? (Player) sender : null;
int senderBalance = senderPlayer != null ? plugin.getEconomyManager().getBalance(senderPlayer.getUniqueId()) : 1024;
if (senderBalance < amount) {
sender.sendMessage(ChatColor.RED + "You tried to pay " + EconomyManager.ECONOMY_SYMBOL + amount + ", but you only have " + EconomyManager.ECONOMY_SYMBOL + senderBalance
+ " in your bank account.");
return true;
}
OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]); // TODO: breaking
if (sender.equals(target)) {
sender.sendMessage(ChatColor.RED + "You cannot send money to yourself.");
return true;
}
Player targetPlayer = target.getPlayer();
if (!target.hasPlayedBefore() && targetPlayer == null) {
sender.sendMessage(ChatColor.GOLD + "Player '" + ChatColor.WHITE + args[0] + ChatColor.GOLD + "' not found.");
return true;
}
if (targetPlayer == null)
return false; // won't happen, IntelliJ compiler won't ignore
// Make the money transactions.
if (senderPlayer != null)
plugin.getEconomyManager().subtractBalance(senderPlayer.getUniqueId(), amount);
plugin.getEconomyManager().addBalance(targetPlayer.getUniqueId(), amount);
targetPlayer.sendMessage(ChatColor.YELLOW + sender.getName() + " has sent you " + ChatColor.GOLD + EconomyManager.ECONOMY_SYMBOL + amount + ChatColor.YELLOW + '.');
sender.sendMessage(ChatColor.YELLOW + "You have sent " + ChatColor.GOLD + EconomyManager.ECONOMY_SYMBOL + amount + ChatColor.YELLOW + " to " + target.getName() + '.');
return true;
}
示例11: 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;
}
UUID targetUUID = target.getUniqueId();
FactionUser factionTarget = plugin.getUserManager().getUser(targetUUID);
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) {
if (!sender.hasPermission(REVIVE_BYPASS_PERMISSION)) {
if (plugin.getEotwHandler().isEndOfTheWorld()) {
sender.sendMessage(ChatColor.RED + "You cannot revive players during EOTW.");
return true;
}
}
Player player = (Player) sender;
UUID playerUUID = player.getUniqueId();
int selfLives = plugin.getDeathbanManager().getLives(playerUUID);
if (selfLives <= 0) {
sender.sendMessage(ChatColor.RED + "You do not have any lives.");
return true;
}
plugin.getDeathbanManager().setLives(playerUUID, selfLives - 1);
PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
relation = playerFaction == null ? Relation.ENEMY : playerFaction.getFactionRelation(plugin.getFactionManager().getPlayerFaction(targetUUID));
sender.sendMessage(ChatColor.YELLOW + "You have used a life to revive " + relation.toChatColour() + target.getName() + ChatColor.YELLOW + '.');
} else {
sender.sendMessage(ChatColor.YELLOW + "You have revived " + SettingsYML.ENEMY_COLOUR + target.getName() + ChatColor.YELLOW + '.');
}
if (sender instanceof PluginMessageRecipient) {
// NOTE: This server needs at least 1 player online.
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Message");
out.writeUTF(args[1]);
String serverDisplayName = ChatColor.GREEN + "HCF"; // TODO: Non hard-coded server display name.
out.writeUTF(relation.toChatColour() + sender.getName() + ChatColor.GOLD + " has just revived you from " + serverDisplayName + ChatColor.GOLD + '.');
((PluginMessageRecipient) sender).sendPluginMessage(plugin, PROXY_CHANNEL_NAME, out.toByteArray());
}
factionTarget.removeDeathban();
return true;
}
示例12: 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;
}
if (amount <= 0) {
sender.sendMessage(ChatColor.RED + "The amount of lives must be positive.");
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;
}
Player onlineTarget = target.getPlayer();
if (sender instanceof Player) {
Player player = (Player) sender;
int ownedLives = plugin.getDeathbanManager().getLives(player.getUniqueId());
if (amount > ownedLives) {
sender.sendMessage(ChatColor.RED + "You tried to give " + target.getName() + ' ' + amount + " lives, but you only have " + ownedLives + '.');
return true;
}
plugin.getDeathbanManager().takeLives(player.getUniqueId(), amount);
}
plugin.getDeathbanManager().addLives(target.getUniqueId(), amount);
sender.sendMessage(ChatColor.YELLOW + "You have sent " + ChatColor.GOLD + target.getName() + ChatColor.YELLOW + ' ' + amount + ' ' + (amount > 1 ? "lives" : "life") + ChatColor.YELLOW + '.');
if (onlineTarget != null) {
onlineTarget
.sendMessage(ChatColor.GOLD + sender.getName() + ChatColor.YELLOW + " has sent you " + ChatColor.GOLD + amount + ' ' + (amount > 1 ? "lives" : "life") + ChatColor.YELLOW + '.');
}
return true;
}
示例13: getName
import org.bukkit.OfflinePlayer; //导入方法依赖的package包/类
/**
* Gets the name of this {@link FactionMember}.
*
* @return the name of this {@link FactionMember}
*/
public String getName() {
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uniqueID);
return offlinePlayer.hasPlayedBefore() || offlinePlayer.isOnline() ? offlinePlayer.getName() : null;
}