本文整理匯總了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();
}
}
}