org.bukkit.entity.Entity.getName()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.bukkit.entity.Entity.getName()方法的一些代码示例,展示了Entity.getName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getName()方法的具体详情如下:
包路径:org.bukkit.entity.Entity
类名称:Entity
方法名:getName

Entity.getName介绍

暂无

代码示例

代码示例来源:origin: GlowstoneMC/Glowstone

/**
 * Gets the name of an entity.
 *
 * @param entity an entity
 * @return the first of the following that exists and is non-empty: {@code
 *         entity.getCustomName()}, {@code entity.getName()}, {@code
 *         entity.getType().getName()}
 */
public static String getName(Entity entity) {
  String customName = entity.getCustomName();
  if (customName != null && !customName.isEmpty()) {
    return customName;
  }
  String name = entity.getName();
  if (name == null || name.isEmpty()) {
    name = entity.getType().getName();
  }
  return name;
}

代码示例来源:origin: GlowstoneMC/Glowstone

"Teleported " + target.getName() + " to " + targetLocation.getX() + " "
    + targetLocation.getY() + " " + targetLocation.getZ());

代码示例来源:origin: stackoverflow.com

if (entityList.isEmpty()) {
  entityList.add(entity);
}
else {
  List<Entity> tempList = new ArrayList<>();

  for (Entity e: entityList) {
    if (e.getName().equals(p.toString())) {
      e.setOccurrence(e.getOccurrence() + 1);
    }
    else {
      tempList.add(entity);
    }
  }

  entityList.addAll(tempList);
}

代码示例来源:origin: stackoverflow.com

for(int index=0; index < entityList.size(); index++){
 Entity e = entityList.get(index);
 if (e.getName().equals(p.toString())) {
    e.setOccurrence(e.getOccurrence() + 1);
  }

}

代码示例来源:origin: ProtocolSupport/ProtocolSupport

public EntityInfo(Entity entity) {
  this(entity.getType(), entity.getUniqueId(), entity.getName());
}

代码示例来源:origin: Bkm016/TabooLib

/**
 * Creates a show_entity action: when the component is hovered some entity information will be displayed
 *
 * @param entity the item to display
 * @return a new HoverAction instance
 */
static HoverAction showEntity(Entity entity) {
  return showEntity(entity.getUniqueId(), entity.getType().getName(), entity.getName());
}

代码示例来源:origin: Co0sh/BetonQuest

@Override
  public void run(String playerID) throws QuestRuntimeException {
    Location location = loc.getLocation(playerID);
    final double radius_squared = this.radius.getDouble(playerID) * this.radius.getDouble(playerID);
    location
        .getWorld()
        .getEntitiesByClass(type.getEntityClass())
        .stream()
        //get only nearby entities
        .filter(entity -> entity.getLocation().distanceSquared(location) <= radius_squared)
        //only entities with given name
        .filter(entity -> {
          if (name == null) return true;
          return name.equals(entity.getName());
        })
        //only entities marked
        .filter(entity -> {
          if (marked == null) return true;
          return entity
              .getMetadata("betonquest-marked")
              .stream()
              .anyMatch(metadataValue -> metadataValue.asString().equals(marked));
        })
        //remove them
        .forEach(Entity::remove);
  }
}

代码示例来源:origin: elBukkit/MagicPlugin

private void setTarget(Entity target) {
  if (entityData != null && !entityData.shouldFocusOnDamager()) return;
  LivingEntity li = getLivingEntity();
  if (li != null && li instanceof Creature && target instanceof LivingEntity) {
    Creature creature = ((Creature)li);
    if (creature.getTarget() != target) {
      sendDebugMessage("Now targeting " + target.getName(), 6);
    }
    creature.setTarget((LivingEntity)target);
  }
}

代码示例来源:origin: EngineHub/CommandHelper

if(((EntityEvent) e).getEntity() instanceof Player) {
  Entity entity = ((EntityEvent) e).getEntity();
  map.put("player", new CString(entity.getName(), Target.UNKNOWN));

代码示例来源:origin: sgtcaze/NametagEdit

@EventHandler
public void onDisguiseEvent(final DisguiseEvent event) {
  if (event.getEntity() instanceof Player) {
    plugin.getHandler().getNametagManager().reset(event.getEntity().getName());
    new BukkitRunnable() {
      @Override
      public void run() {
        plugin.getHandler().applyTagToPlayer((Player) event.getEntity(), false);
      }
    }.runTaskLater(plugin, 3);
  }
}

代码示例来源:origin: elBukkit/MagicPlugin

if (command.contains("@killer")) {
  if (killer == null) continue;
  command = command.replace("@killer", killer.getName());
  command = command.replace("@damager", topDamager.getName());
    String damagerCommand = command.replace("@damagers", damager.getName());
    mage.getController().getPlugin().getServer().dispatchCommand(Bukkit.getConsoleSender(), damagerCommand);

代码示例来源:origin: elBukkit/MagicPlugin

ownerName = entity.getName();

代码示例来源:origin: libraryaddict/LibsDisguises

DisguiseAPI.undisguiseToAll(p);
  sender.sendMessage(LibsMsg.UNDISG_PLAYER
      .get(p instanceof Player ? p.getName() : DisguiseType.getType(p).toReadable()));
} else {
  sender.sendMessage(LibsMsg.UNDISG_PLAYER_FAIL
      .get(p instanceof Player ? p.getName() : DisguiseType.getType(p).toReadable()));

代码示例来源:origin: libraryaddict/LibsDisguises

disguise.getEntity().getName().equalsIgnoreCase(player)) {
removeSelfDisguise((Player) disguise.getEntity());

代码示例来源:origin: bitquest/bitquest

public boolean run(
   CommandSender sender, Command cmd, String label, String[] args, Player player) {
  Chunk c = player.getLocation().getChunk();
  for (World w : Bukkit.getWorlds()) {
   List<Entity> entities = w.getEntities();
   int killed = 0;
   for (Entity entity : entities) {
    if (entity instanceof Player) {

    } else if (entity.getLocation().getChunk().getX() == c.getX()
      && entity.getLocation().getChunk().getZ() == c.getZ()) {
     killed = killed + 1;
     entity.remove();
     System.out.println("[butcher] removed " + entity.getName());
    }
   }
   player.sendMessage(ChatColor.GREEN + "Killed " + killed + " entities on " + w.getName());
  }
  return false;
 }
}

代码示例来源:origin: bitquest/bitquest

bitQuest.sendDiscordMessage(player.getDisplayName()+" killed "+damage.getEntity().getName()+" !!! A reward was paid: "+money/bitQuest.DENOMINATION_FACTOR+" "+bitQuest.DENOMINATION_NAME);
bitQuest.announce(
  ChatColor.GREEN

代码示例来源:origin: libraryaddict/LibsDisguises

.get(entity instanceof Player ? entity.getName() : DisguiseType.getType(entity).toReadable(),
          disguise.getType().toReadable()));
} else {
  sender.sendMessage(LibsMsg.DISG_PLAYER_AS_DISG_FAIL
      .get(entity instanceof Player ? entity.getName() : DisguiseType.getType(entity).toReadable(),
          disguise.getType().toReadable()));

代码示例来源:origin: DRE2N/DungeonsXL

killer = damager.getName();

代码示例来源:origin: eccentricdevotion/TARDIS

String name = (e instanceof Player) ? e.getName() : "";
NPC npc = registry.createNPC(e.getType(), name);

代码示例来源:origin: ProjectKorra/ProjectKorra

Bukkit.getServer().getPluginManager().callEvent(damageEvent);
if (entity instanceof LivingEntity) {
  if (entity instanceof Player && Commands.invincible.contains(entity.getName())) {
    damageEvent.setCancelled(true);

相关文章

微信公众号

最新文章

更多