當前位置: 首頁>>代碼示例>>Java>>正文


Java Entity.getCustomName方法代碼示例

本文整理匯總了Java中org.bukkit.entity.Entity.getCustomName方法的典型用法代碼示例。如果您正苦於以下問題:Java Entity.getCustomName方法的具體用法?Java Entity.getCustomName怎麽用?Java Entity.getCustomName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.entity.Entity的用法示例。


在下文中一共展示了Entity.getCustomName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkChair

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
private List<ArmorStand> checkChair(ArmorStand drop)
{
	List<ArmorStand> drops = new ArrayList<ArmorStand>();
	
	// Check for already existing chair items.
	for(Entity e : drop.getNearbyEntities(0.5, 0.5, 0.5))
	{
		if(e != null && e instanceof ArmorStand && e.getCustomName() == "Chair")
		{
			if(e.getPassengers().isEmpty())
				e.remove();
			else
				drops.add(drop);
		}
	}
	
	if(!drops.isEmpty())
		return drops;
	
	return null;
}
 
開發者ID:FattyMieo,項目名稱:SurvivalPlus,代碼行數:22,代碼來源:Chairs.java

示例2: removeBlock

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
@Override
public void removeBlock(BlockBreakEvent e) {
		if (e.getPlayer() == null) {return;}
		for (Entity en : e.getPlayer().getNearbyEntities(10, 10, 10)) {
			System.out.println("Removal has Begun");
			if (en.getCustomName() != null && en.getCustomName().equals(getName()) && /*en.getLocation().add(-0.5, 0, -0.5).equals(e.getBlock().getLocation())*/ en.getLocation().distance(e.getBlock().getLocation()) < 2) {
				for (Entity ent : en.getNearbyEntities(0.5, 0.5, 0.5)) {
					if (ent.getCustomName().equals("CustomBlock")) {
						ent.remove();
						break;
					}
				}
				en.remove();
				//en.getWorld().getBlockAt(en.getLocation().add(-0.5, 0, -0.5)).setType(Material.AIR);
				if (e.getPlayer() != null && e.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
					e.getPlayer().getInventory().addItem(getItem());
				} else {
					e.getBlock().getWorld().dropItemNaturally(en.getLocation().add(-0.5, 0, -0.5), getItem());
				}
				
				return;
			}
		}
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:25,代碼來源:CustomTexturedBlock.java

示例3: getArmorStand

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public static ArmorStand getArmorStand(Block hopper)
{
    Location l = new Location(hopper.getWorld(), (double)hopper.getX() + 0.5D, hopper.getY(), (double)hopper.getZ() + 0.5D);
    Entity aentity[];
    int j = (aentity = l.getChunk().getEntities()).length;
    for(int i = 0; i < j; i++)
    {
        Entity n = aentity[i];
        if((n instanceof ArmorStand) && n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.40000000000000002D)
            return (ArmorStand)n;
    }

    ArmorStand hologram = ArmorStandFactory.createHidden(l);
    hologram.setCustomNameVisible(false);
    hologram.setCustomName(null);
    return hologram;
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:18,代碼來源:AutoBreeder.java

示例4: onBlockBreak

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event)
{
	if(event.isCancelled()) return;
	if(Survival.allowedBlocks.contains(event.getBlock().getType()))
	{
		ArmorStand drop = dropSeat(event.getBlock(), (Stairs)event.getBlock().getState().getData());
		
		for(Entity e : drop.getNearbyEntities(0.5, 0.5, 0.5))
		{
			if(e != null && e instanceof ArmorStand && e.getCustomName() == "Chair")
				e.remove();
		}
		
		drop.remove();
	}
}
 
開發者ID:FattyMieo,項目名稱:SurvivalPlus,代碼行數:18,代碼來源:Chairs.java

示例5: getArmorStand

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public static ArmorStand getArmorStand(Block hopper, boolean createIfNoneFound) {
	Location l = new Location(hopper.getWorld(), hopper.getX() + 0.5, hopper.getY() + offset, hopper.getZ() + 0.5);
	
	for (Entity n: l.getChunk().getEntities()) {
		if (n instanceof ArmorStand) {
			if (n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n;
		}
	}

	if (!createIfNoneFound) {
		return null;
	}
	
	ArmorStand hologram = ArmorStandFactory.createHidden(l);
	hologram.setCustomNameVisible(false);
	hologram.setCustomName(null);
	return hologram;
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:19,代碼來源:InfusedHopper.java

示例6: onPlayerMoveEvent

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
@EventHandler
public void onPlayerMoveEvent(PlayerMoveEvent e) {
	for (Entity en : e.getPlayer().getWorld().getEntities()) {
		if (en.getCustomName() != null && en.getCustomName().equals(getName()) && en.getLocation().distance(e.getTo()) <= 1) {
			Location l = en.getLocation();
			//e.getPlayer().sendMessage(getPlayerDirection(e.getPlayer()));
			if (getPlayerDirection(e.getPlayer()).equals("north")) {
				l.add(-1.2, 0, 0);	
			}
			else if (getPlayerDirection(e.getPlayer()).equals("south")) {
				l.add(1.2, 0, 0);	
			}
			else if (getPlayerDirection(e.getPlayer()).equals("east")) {
				l.add(0, 0, -1.2);	
			}
			else if (getPlayerDirection(e.getPlayer()).equals("west")) {
				l.add(0, 0, 1.2);	
			}
			else {
				l = e.getPlayer().getLocation();
			}
			l.setDirection(e.getPlayer().getLocation().getDirection());
			e.setTo(l);
		}
	}
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:27,代碼來源:GhostBlock.java

示例7: onCommand

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
	if (command.getName().equalsIgnoreCase("hbike")) {
		Player player = (Player) sender;
		if (args[0].equals("create")) {
			create(player.getLocation()).setPassenger(player);
		}
		else if (args[0].equals("destroy")) {
			for (Entity ent : player.getNearbyEntities(0.2, 0.2, 0.2)) {
				if (ent.getCustomName() != null && ent.getCustomName().equals("HoverBike")) {
					ent.remove();
					return true;
				}
			}
		}
			
		return true;
	}
	
	return false;
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:22,代碼來源:HoverBike.java

示例8: getBlockByName

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public static ArrayList<Entity> getBlockByName(String name, Entity e) {
	ArrayList<Entity> r = new ArrayList<Entity>();
	
	for (Entity en : e.getWorld().getEntities()) {
		if (en.getCustomName() != null && en.getCustomName().equals(name)) {
			r.add(en);
		}
	}
	
	return r;
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:12,代碼來源:CustomBlock.java

示例9: isDeadBall

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
private boolean isDeadBall(Entity entity) {
    if (!this.isBall(entity)) {
        if (entity instanceof ArmorStand) {
            final ArmorStand stand = (ArmorStand) entity;
            final int xidentifier = (int) stand.getBodyPose().getZ();
            final int identifier = (int) stand.getRightArmPose().getX();
            if (xidentifier == 2777 && identifier == 2777) {
                return true;
            }
        } else if (entity instanceof Rabbit && entity.getCustomName() != null && entity.getCustomName().equals("MyBallsIdentifier")) {
            return true;
        }
    }
    return false;
}
 
開發者ID:Shynixn,項目名稱:BlockBall,代碼行數:16,代碼來源:BallListener.java

示例10: EntityInfo

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public EntityInfo(Entity entity, @Nullable ParticipantState owner) {
    super(owner);
    this.entityType = entity.getType();
    this.entityClass = entity.getClass();
    this.customName = entity.getCustomName();
    this.nameKey = NMSHacks.getTranslationKey(entity);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:8,代碼來源:EntityInfo.java

示例11: getArmorStand

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
private static ArmorStand getArmorStand(Block b)
{
    Location l = new Location(b.getWorld(), (double)b.getX() + 0.5D, (float)b.getY() - 0.7F, (double)b.getZ() + 0.5D);
    Entity aentity[];
    int j = (aentity = l.getChunk().getEntities()).length;
    for(int i = 0; i < j; i++)
    {
        Entity n = aentity[i];
        if((n instanceof ArmorStand) && n.getCustomName() != null && l.distanceSquared(n.getLocation()) < 0.40000000000000002D)
            return (ArmorStand)n;
    }

    ArmorStand hologram = ArmorStandFactory.createHidden(l);
    return hologram;
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:16,代碼來源:CargoHologram.java

示例12: findItem

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public static Item findItem(Block b) {
	for (Entity n: b.getChunk().getEntities()) {
		if (n instanceof Item) {
			if (b.getLocation().add(0.5, 1.2, 0.5).distanceSquared(n.getLocation()) < 0.5D && n.getCustomName() != null) return (Item) n;
		}
	}
	return null;
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:9,代碼來源:AncientAltarListener.java

示例13: onInteract

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
@EventHandler
public void onInteract(PlayerInteractEvent e) {
	if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
		//System.out.println("A");
		for (Entity en : e.getPlayer().getWorld().getEntities()) {
			if (en.getCustomName() != null && en.getCustomName().equals(getName()) && en.getLocation().add(-0.5, 0, -0.5).equals(e.getClickedBlock().getLocation())) {
				Location l = e.getClickedBlock().getLocation();
				l.add(0, -1, 0);
				en.getWorld().getBlockAt(l).breakNaturally();
				e.setCancelled(true);
			}
		}
	}
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:15,代碼來源:BlockBreaker.java

示例14: loop

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public void loop() {
	for (Player p : Bukkit.getOnlinePlayers()) {
		for (Entity bl : p.getNearbyEntities(0.24, 2, 0.24)) {
			if (bl.getCustomName() != null && bl.getCustomName().equals(getName())) {
				for (Entity ent : p.getNearbyEntities(0.2, 0.2, 0.2)) {
					if (ent.getCustomName() != null && ent.getCustomName().equals("HoverBike")) {
						for (String tag : ent.getScoreboardTags()) {
							if (tag.startsWith("speed:") && Integer.valueOf(tag.split(":")[1]) > 18) {
								Police.create(p.getLocation().add(-10, 2, -10), p);
								p.sendMessage("&6[Warning] Don't go past stops!".replace('&', '�'));
								p.sendMessage("&9[Police] Pull over!".replace('&', '�'));
								
								for (Entity pli : p.getNearbyEntities(50, 50, 50)) {
									if (pli.getCustomName() != null && pli.getCustomName().equals("Officer")) {
										((PigZombie) pli).setTarget(p);
									}
								}
							}
							else {
								if (!ent.getScoreboardTags().contains("stopcooldown")) {
									((Pig) ent).removePotionEffect(PotionEffectType.SPEED);
									((Pig) ent).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 255, true, false));
									((Pig) ent).setVelocity(new Vector(0, 0, 0));
								} else {
									ent.getScoreboardTags().remove("stopcooldown");
								}
							}
						}
					}
				}
			}
		}
	}
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:35,代碼來源:StopBlock.java

示例15: removeBlock

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
@Override
public void removeBlock(BlockBreakEvent e) {
		for (Entity en : e.getPlayer().getWorld().getEntities()) {
			if (en.getCustomName() != null && en.getCustomName().equals("flag") && en.getLocation().add(-0.5, 0, -0.5).equals(e.getBlock().getLocation())) {
				en.remove();
				e.getPlayer().sendMessage(ChatColor.GRAY + "Flag removed");
			}
	}
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:10,代碼來源:Flag.java


注:本文中的org.bukkit.entity.Entity.getCustomName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。