本文整理汇总了Java中org.bukkit.OfflinePlayer类的典型用法代码示例。如果您正苦于以下问题:Java OfflinePlayer类的具体用法?Java OfflinePlayer怎么用?Java OfflinePlayer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OfflinePlayer类属于org.bukkit包,在下文中一共展示了OfflinePlayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clear
import org.bukkit.OfflinePlayer; //导入依赖的package包/类
public void clear(@Nonnull World world) {
// clear information about blocks in that world
Iterator<Map.Entry<Block, OfflinePlayer>> blockIt = this.placedAnvils.entrySet().iterator();
while(blockIt.hasNext()) {
Block block = blockIt.next().getKey();
if(block.getWorld().equals(world)) {
blockIt.remove();
}
}
// clear information about entitys in that world
Iterator<Map.Entry<FallingBlock, OfflinePlayer>> entityIt = this.ownedAnvils.entrySet().iterator();
while(entityIt.hasNext()) {
Entity tnt = entityIt.next().getKey();
if(tnt.getWorld().equals(world)) {
entityIt.remove();
}
}
}
示例2: onTabComplete
import org.bukkit.OfflinePlayer; //导入依赖的package包/类
public List<String> onTabComplete(final CommandSender sender, final Command command, final String label, final String[] args) {
if (args.length != 1) {
return Collections.emptyList();
}
final List<String> results = new ArrayList<String>();
for (final FactionUser factionUser : this.plugin.getUserManager().getUsers().values()) {
final Deathban deathban = factionUser.getDeathban();
if (deathban != null && deathban.isActive()) {
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(factionUser.getUserUUID());
final String name = offlinePlayer.getName();
if (name == null) {
continue;
}
results.add(name);
}
}
return BukkitUtils.getCompletions(args, results);
}
示例3: onTabComplete
import org.bukkit.OfflinePlayer; //导入依赖的package包/类
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (args.length != 2 || !(sender instanceof Player)) {
return Collections.emptyList();
}
Player player = (Player) sender;
PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
if (playerFaction == null || (playerFaction.getMember(player.getUniqueId()).getRole() != Role.LEADER)) {
return Collections.emptyList();
}
List<String> results = new ArrayList<>();
Collection<UUID> keySet = playerFaction.getMembers().keySet();
for (UUID entry : keySet) {
OfflinePlayer target = Bukkit.getOfflinePlayer(entry);
String targetName = target.getName();
if (targetName != null && playerFaction.getMember(target.getUniqueId()).getRole() == Role.CAPTAIN) {
results.add(targetName);
}
}
return results;
}
示例4: resolve
import org.bukkit.OfflinePlayer; //导入依赖的package包/类
public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
if(damageEvent instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent;
if(event.getDamager() instanceof Projectile) {
Projectile projectile = (Projectile) event.getDamager();
Location launchLocation = this.projectileDistanceTracker.getLaunchLocation(projectile);
Double projectileDistance = null;
OfflinePlayer dispenserOwner = dispenserTracker.getOwner(projectile);
if(launchLocation != null) projectileDistance = event.getEntity().getLocation().distance(launchLocation);
if(projectile.getShooter() instanceof LivingEntity) {
return new DispensedProjectileDamageInfo(projectile, (LivingEntity) projectile.getShooter(), projectileDistance, dispenserOwner);
}
}
}
return null;
}
示例5: onTabComplete
import org.bukkit.OfflinePlayer; //导入依赖的package包/类
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (args.length != 1) {
return Collections.emptyList();
}
List<String> results = new ArrayList<>();
for (FactionUser factionUser : plugin.getUserManager().getUsers().values()) {
Deathban deathban = factionUser.getDeathban();
if (deathban != null && deathban.isActive()) {
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(factionUser.getUserUUID());
String name = offlinePlayer.getName();
if (name != null) {
results.add(name);
}
}
}
return BukkitUtils.getCompletions(args, results);
}
示例6: getOfflinePlayer
import org.bukkit.OfflinePlayer; //导入依赖的package包/类
@Override
public OfflinePlayer getOfflinePlayer(UUID id) {
Validate.notNull(id, "UUID cannot be null");
OfflinePlayer result = getPlayer(id);
if (result == null) {
result = offlinePlayers.get(id);
if (result == null) {
result = new CraftOfflinePlayer(this, new GameProfile(id, null));
offlinePlayers.put(id, result);
}
} else {
offlinePlayers.remove(id);
}
return result;
}
示例7: addItems
import org.bukkit.OfflinePlayer; //导入依赖的package包/类
private ActiveGUI addItems(boolean active, Inventory inv){
List<String> lissie = new ArrayList<>(sortedList(active).keySet());
for (int i=0;i<18;i++)
inv.setItem(i, UtilItem.create(Material.STAINED_GLASS_PANE, (byte)4, " "));
int ia = 0;
for (int place : places){
if (ia<lissie.size()){
OfflinePlayer op = Bukkit.getOfflinePlayer(UUID.fromString(lissie.get(ia)));
ItemStack skull = null;
try {
skull = ActiveManager.getManager().createItem(op);
} catch (Exception e) {
e.printStackTrace();
}
inv.setItem(place, skull);
}else inv.setItem(place, UtilItem.create(Material.STAINED_GLASS_PANE, (byte)7, " "));
ia++;
}
return this;
}
示例8: onTabComplete
import org.bukkit.OfflinePlayer; //导入依赖的package包/类
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (args.length != 2) {
return Collections.emptyList();
}
List<String> results = new ArrayList<>();
for (FactionUser factionUser : plugin.getUserManager().getUsers().values()) {
Deathban deathban = factionUser.getDeathban();
if (deathban != null && deathban.isActive()) {
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(factionUser.getUserUUID());
String name = offlinePlayer.getName();
if (name != null) {
results.add(name);
}
}
}
return results;
}
示例9: onTabComplete
import org.bukkit.OfflinePlayer; //导入依赖的package包/类
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (args.length != 2) {
return Collections.emptyList();
}
List<String> results = new ArrayList<>();
Collection<FactionUser> factionUsers = plugin.getUserManager().getUsers().values();
for (FactionUser factionUser : factionUsers) {
Deathban deathban = factionUser.getDeathban();
if (deathban == null || !deathban.isActive())
continue;
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(factionUser.getUserUUID());
String offlineName = offlinePlayer.getName();
if (offlineName != null) {
results.add(offlinePlayer.getName());
}
}
return results;
}
示例10: addPlayerToTeam
import org.bukkit.OfflinePlayer; //导入依赖的package包/类
/**
* Add a given player to the given team
*
* @param p Player
* @param team Team
*
* @return {@code true} is success
*/
public boolean addPlayerToTeam(String p, VTeam team)
{
while(this.removeFromAllTeams(p)) {}
team.addPlayer(p);
for(OfflinePlayer offlinePlayer : this.receivers)
{
if(!offlinePlayer.isOnline())
continue;
RawTeam.addPlayerToTeam(offlinePlayer.getPlayer(), team, p);
}
return true;
}
示例11: 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;
}
示例12: onTabComplete
import org.bukkit.OfflinePlayer; //导入依赖的package包/类
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (args.length != 2 || !(sender instanceof Player)) {
return Collections.emptyList();
}
Player player = (Player) sender;
PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
if (playerFaction == null) {
return Collections.emptyList();
}
Role memberRole = playerFaction.getMember(player.getUniqueId()).getRole();
if (memberRole == Role.MEMBER) {
return Collections.emptyList();
}
List<String> results = new ArrayList<>();
for (UUID entry : playerFaction.getMembers().keySet()) {
Role targetRole = playerFaction.getMember(entry).getRole();
if (targetRole == Role.LEADER || (targetRole == Role.CAPTAIN && memberRole != Role.LEADER)) {
continue;
}
OfflinePlayer target = Bukkit.getOfflinePlayer(entry);
String targetName = target.getName();
if (targetName != null && !results.contains(targetName)) {
results.add(targetName);
}
}
return results;
}
示例13: applyText
import org.bukkit.OfflinePlayer; //导入依赖的package包/类
private void applyText(Team team, String text, OfflinePlayer result) {
Iterator<String> iterator = Splitter.fixedLength(16).split(text).iterator();
String prefix = iterator.next();
team.setPrefix(prefix);
if (!team.hasEntry(result.getName()))
team.addEntry(result.getName());
if (text.length() > 16) {
String prefixColor = ChatColor.getLastColors(prefix);
String suffix = iterator.next();
//TODO Change to the symbols
if (prefix.endsWith("nn")) {
prefix = prefix.substring(0, prefix.length() - 1);
team.setPrefix(prefix);
prefixColor = ChatColor.getByChar(suffix.charAt(0)).toString();
suffix = suffix.substring(1);
}
if (prefixColor == null)
prefixColor = "";
if (suffix.length() > 16) {
suffix = suffix.substring(0, (13 - prefixColor.length())); // cut off suffix, done if text is over 30 characters
}
team.setSuffix((prefixColor.equals("") ? ChatColor.RESET : prefixColor) + suffix);
}
}
示例14: onAnvilFall
import org.bukkit.OfflinePlayer; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onAnvilFall(BlockFallEvent event) {
if (!this.tracker.isEnabled(event.getEntity().getWorld())) return;
if (event.getBlock().getType() == Material.ANVIL) {
OfflinePlayer placer = tracker.getPlacer(event.getBlock());
if (placer != null) {
tracker.setOwner(event.getEntity(), tracker.getPlacer(event.getBlock()));
}
}
}
示例15: onAnvilLand
import org.bukkit.OfflinePlayer; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onAnvilLand(EntityChangeBlockEvent event) {
if (!this.tracker.isEnabled(event.getEntity().getWorld())) return;
if (event.getEntityType() == EntityType.FALLING_BLOCK && event.getTo() == Material.ANVIL) {
OfflinePlayer owner = tracker.getOwner((FallingBlock) event.getEntity());
if(owner != null) {
tracker.setPlacer(event.getBlock(), tracker.getOwner((FallingBlock) event.getEntity()));
tracker.setOwner((FallingBlock) event.getEntity(), null);
}
}
}