本文整理汇总了Java中org.bukkit.entity.Entity.getUniqueId方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.getUniqueId方法的具体用法?Java Entity.getUniqueId怎么用?Java Entity.getUniqueId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Entity
的用法示例。
在下文中一共展示了Entity.getUniqueId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUUID
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@Nonnull
private static UUID getUUID(String input, CommandSender sender) throws InputException {
try {
return UUID.fromString(input);
} catch (IllegalArgumentException ex) {
if (sender instanceof Player) {
Entity entity = getEntity(input, sender);
if (entity != null) {
return entity.getUniqueId();
}
}
throw new InputException(ex);
}
}
示例2: despawnEntities
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public static void despawnEntities(Entity[] list) {
for (Entity e : list) {
if (e == null || e.getUniqueId() == null)
continue;
if (e instanceof Player)
continue;
try {
if (MobManager.spawnedMobs != null && MobManager.spawnedMobs.containsKey(e.getUniqueId())) {
MobManager.spawnedMobs.get(e.getUniqueId()).despawn();
}
if (NPCManager.npcs != null && NPCManager.npcs.containsKey(e.getUniqueId())) {
NPCManager.npcs.remove(e.getUniqueId()).despawn();
}
if (e instanceof Item || e instanceof LivingEntity || e instanceof ArmorStand || e instanceof Projectile || e instanceof EnderCrystal) {
if (e instanceof LivingEntity)
((LivingEntity) e).setHealth(0.0);
DropManager dm = plugin.getInstance(DropManager.class);
if (dm != null) {
Entity label = dm.removeLabel(e.getUniqueId());
if (label != null)
label.remove();
e.remove();
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
示例3: get
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public static @Nullable MatchEntityState get(Entity entity) {
Match match = Matches.get(entity.getWorld());
String customName = entity instanceof Player ? null : entity.getCustomName();
return match == null ? null : new MatchEntityState(match, entity.getClass(), entity.getUniqueId(), entity.getEntityLocation(), customName);
}
示例4: handleInteraction
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@Override
public void handleInteraction(Entity who, Entity with)
{
if (who instanceof Player && with instanceof Player)
{
if (this.waitingFirstInteraction && who.getUniqueId().equals(this.player.getUniqueId()))
{
this.playerTargeted = with.getUniqueId();
this.interactWith((Player) with);
this.playerWasFlying = this.player.getAllowFlight();
this.targetWasFlying = ((Player) with).getAllowFlight();
this.player.setFlying(false);
this.player.setAllowFlight(false);
((Player) with).setFlying(false);
((Player) with).setAllowFlight(false);
this.player.sendMessage(TAG + ChatColor.GOLD + this.player.getName() + ChatColor.YELLOW + " a provoqué " + ChatColor.GOLD + with.getName() + ChatColor.YELLOW + " en duel !");
with.sendMessage(TAG + ChatColor.GOLD + this.player.getName() + ChatColor.YELLOW + " a provoqué " + ChatColor.GOLD + with.getName() + ChatColor.YELLOW + " en duel !");
this.player.playSound(with.getLocation(), Sound.ENTITY_CAT_AMBIENT, 1.0F, 1.0F);
((Player) with).playSound(with.getLocation(), Sound.ENTITY_CAT_AMBIENT, 1.0F, 1.0F);
this.waitingFirstInteraction = false;
this.waitingSecondInteraction = true;
this.waitingInteractionTask = this.hub.getServer().getScheduler().runTaskLater(this.hub, () ->
{
this.player.sendMessage(TAG + ChatColor.GOLD + this.player.getName() + ChatColor.YELLOW + " remporte le duel contre " + ChatColor.GOLD + with.getName() + ChatColor.YELLOW + " !");
with.sendMessage(TAG + ChatColor.GOLD + this.player.getName() + ChatColor.YELLOW + " remporte le duel contre " + ChatColor.GOLD + with.getName() + ChatColor.YELLOW + " !");
if (this.hub.getServer().getPlayer(this.player.getUniqueId()) != null)
{
this.player.playSound(this.player.getLocation(), Sound.ENTITY_CAT_AMBIENT, 1.0F, 1.0F);
this.player.setAllowFlight(this.playerWasFlying);
}
if (this.hub.getServer().getPlayer(with.getUniqueId()) != null)
((Player) with).setAllowFlight(this.targetWasFlying);
this.waitingSecondInteraction = false;
this.end();
}, 20L * 60);
}
else if (this.waitingSecondInteraction && who.getUniqueId().equals(this.playerTargeted))
{
this.waitingInteractionTask.cancel();
this.player.sendMessage(TAG + ChatColor.GOLD + who.getName() + ChatColor.YELLOW + " remporte le duel contre " + ChatColor.GOLD + this.player.getName() + ChatColor.YELLOW + " !");
who.sendMessage(TAG + ChatColor.GOLD + who.getName() + ChatColor.YELLOW + " remporte le duel contre " + ChatColor.GOLD + this.player.getName() + ChatColor.YELLOW + " !");
if (this.hub.getServer().getPlayer(who.getUniqueId()) != null)
{
((Player) who).playSound(who.getLocation(), Sound.ENTITY_CAT_AMBIENT, 1.0F, 1.0F);
((Player) who).setAllowFlight(this.targetWasFlying);
}
if (this.hub.getServer().getPlayer(this.player.getUniqueId()) != null)
this.player.setAllowFlight(this.playerWasFlying);
this.waitingSecondInteraction = false;
this.end();
}
}
}