Java Code Examples for org.bukkit.entity.Entity#getUniqueId()
The following examples show how to use
org.bukkit.entity.Entity#getUniqueId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListenerMythicMobs.java From CombatLogX with GNU General Public License v3.0 | 6 votes |
private String getMythicMobName(Entity entity) { if(entity == null) return null; MythicMobs mythicMobs = MythicMobs.inst(); MobManager mobManager = mythicMobs.getMobManager(); UUID uuid = entity.getUniqueId(); Optional<ActiveMob> activeMobOptional = mobManager.getActiveMob(uuid); if(activeMobOptional.isPresent()) { ActiveMob activeMob = activeMobOptional.get(); MythicMob mobType = activeMob.getType(); return mobType.getInternalName(); } return null; }
Example 2
Source File: EntitySpawnListener.java From IridiumSkyblock with GNU General Public License v2.0 | 5 votes |
public void monitorEntity(Entity entity) { if (entity == null) return; if (entity.isDead()) return; final UUID uuid = entity.getUniqueId(); final Island startingIsland = IridiumSkyblock.getInstance().entities.get(uuid); if (startingIsland.isInIsland(entity.getLocation())) { //The entity is still in the island, so make a scheduler to check again Bukkit.getScheduler().scheduleSyncDelayedTask(IridiumSkyblock.getInstance(), () -> monitorEntity(entity), 20); } else { //The entity is not in the island, so remove it entity.remove(); IridiumSkyblock.getInstance().entities.remove(uuid); } }
Example 3
Source File: GDBorderClaimEvent.java From GriefDefender with MIT License | 5 votes |
public GDBorderClaimEvent(Entity entity, Claim exit, Claim enter) { super(enter); this.user = entity instanceof Player ? PermissionHolderCache.getInstance().getOrCreateUser((Player) entity) : null; this.entity = entity; this.uniqueId = entity.getUniqueId(); this.exitClaim = exit; final int defaultChatType = GriefDefenderPlugin.getGlobalConfig().getConfig().message.enterExitChatType; if (defaultChatType == 1) { this.enterChatType = ChatTypes.ACTION_BAR; this.exitChatType = ChatTypes.ACTION_BAR; } }
Example 4
Source File: HealthUtil.java From ActionHealth with MIT License | 5 votes |
public boolean matchesRequirements(Player player, Entity damaged) { if (damaged.getType().name().equals("ARMOR_STAND")) return false; if (player.getWorld() != damaged.getWorld()) return false; if (damaged instanceof Player) { if (!plugin.configStore.showPlayers && !damaged.hasMetadata("NPC")) return false; } else { if (!plugin.configStore.showMobs) return false; } if (!plugin.configStore.showNPC && damaged.hasMetadata("NPC")) return false; if (!plugin.configStore.showMiniaturePets && damaged.hasMetadata("MiniaturePet")) return false; if (plugin.healthUtil.isDisabled(player.getLocation())) return false; if (plugin.configStore.worlds.contains(player.getWorld().getName())) return false; if (plugin.configStore.usePerms && !player.hasPermission("ActionHealth.Health")) return false; if (player.getUniqueId() == damaged.getUniqueId()) return false; if (plugin.toggle.contains(player.getUniqueId())) { sendMessage(player); return false; } return true; }
Example 5
Source File: SentinelTargetingHelper.java From Sentinel with MIT License | 5 votes |
/** * Process avoid necessary avoidance. Builds a list of things we need to run away from, and then runs. */ public void processAvoidance() { avoidanceList.clear(); if (currentAvoids.isEmpty() && sentinel.allAvoids.totalTargetsCount() == 0) { // Opti return; } double range = sentinel.avoidRange + 10; for (Entity entity : getLivingEntity().getWorld().getNearbyEntities(getLivingEntity().getLocation(), range, 16, range)) { if (!(entity instanceof LivingEntity)) { continue; } tempTarget.targetID = entity.getUniqueId(); if (shouldAvoid((LivingEntity) entity)) { if (!currentAvoids.contains(tempTarget) && !canSee((LivingEntity) entity)) { continue; } avoidanceList.add((LivingEntity) entity); addAvoid(entity.getUniqueId()); } } if (avoidanceList.isEmpty()) { return; } Location runTo = findBestRunSpot(); if (runTo != null) { sentinel.pathTo(runTo); if (SentinelPlugin.debugMe) { sentinel.debug("Running from threats, movement vector: " + runTo.clone().subtract(getLivingEntity().getLocation()).toVector().toBlockVector().toString()); } } else { if (SentinelPlugin.debugMe) { sentinel.debug("I have nowhere to run!"); } } }
Example 6
Source File: DamageStatListener.java From NyaaUtils with MIT License | 5 votes |
@Override public Player getMaxDamagePlayer(Entity mobEntity) { Player p = null; double currentMax = -1; UUID mob = mobEntity.getUniqueId(); Map<UUID, Double> map = entityList.getUnchecked(mob); for (UUID playerUUID : map.keySet()) { if (plugin.getServer().getPlayer(playerUUID) != null && map.get(playerUUID) > currentMax) { p = plugin.getServer().getPlayer(playerUUID); currentMax = map.get(playerUUID); } } return p; }
Example 7
Source File: CombatManager.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
private Entity getEntityByUUID(World world, UUID uuid) { if(world == null || uuid == null) return null; List<Entity> entityList = world.getEntities(); for(Entity entity : entityList) { UUID entityId = entity.getUniqueId(); if(!uuid.equals(entityId)) continue; return entity; } return null; }
Example 8
Source File: EntityExplodeListener.java From IridiumSkyblock with GNU General Public License v2.0 | 4 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onMonitorEntityExplode(EntityExplodeEvent event) { try { final Entity entity = event.getEntity(); final Location location = entity.getLocation(); final IslandManager islandManager = IridiumSkyblock.getIslandManager(); if (!islandManager.isIslandWorld(location)) return; final UUID uuid = entity.getUniqueId(); final IridiumSkyblock plugin = IridiumSkyblock.getInstance(); final Map<UUID, Island> entities = plugin.entities; Island island = entities.get(uuid); if (island != null && island.isInIsland(location)) { event.setCancelled(true); entity.remove(); entities.remove(uuid); return; } island = islandManager.getIslandViaLocation(location); if (island == null) return; for (Block block : event.blockList()) { if (!island.isInIsland(block.getLocation())) { final BlockState state = block.getState(); IridiumSkyblock.nms.setBlockFast(block, 0, (byte) 0); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> state.update(true, true)); } if (!Utils.isBlockValuable(block)) continue; if (!(block.getState() instanceof CreatureSpawner)) { final Material material = block.getType(); final XMaterial xmaterial = XMaterial.matchXMaterial(material); island.valuableBlocks.computeIfPresent(xmaterial.name(), (name, original) -> original - 1); } if (island.updating) island.tempValues.remove(block.getLocation()); } island.calculateIslandValue(); } catch (Exception ex) { IridiumSkyblock.getInstance().sendErrorMessage(ex); } }
Example 9
Source File: MatchEntityState.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
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); }
Example 10
Source File: HoverAction.java From ProtocolSupport with GNU Affero General Public License v3.0 | 4 votes |
public EntityInfo(Entity entity) { this(entity.getType(), entity.getUniqueId(), entity.getName()); }