当前位置: 首页>>代码示例>>Java>>正文


Java Horse.setCarryingChest方法代码示例

本文整理汇总了Java中org.bukkit.entity.Horse.setCarryingChest方法的典型用法代码示例。如果您正苦于以下问题:Java Horse.setCarryingChest方法的具体用法?Java Horse.setCarryingChest怎么用?Java Horse.setCarryingChest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.entity.Horse的用法示例。


在下文中一共展示了Horse.setCarryingChest方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import org.bukkit.entity.Horse; //导入方法依赖的package包/类
@Override
public boolean apply(Entity entity) {
    PreCon.notNull(entity);
    PreCon.isValid(entity instanceof Horse, "org.bukkit.entity.Horse expected.");

    Horse horse = (Horse) entity;

    horse.setColor(_color);
    horse.setVariant(_variant);
    horse.setStyle(_style);
    horse.setMaxDomestication(_maxDomestication);
    horse.setDomestication(_domestication);
    horse.setCarryingChest(_hasChest);
    horse.setJumpStrength(_jumpStrength);
    return true;
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:17,代码来源:HorseAnimal.java

示例2: spawnHorse

import org.bukkit.entity.Horse; //导入方法依赖的package包/类
@Override
public LivingEntity spawnHorse(Location loc, HorseType type, Color color, Style style, boolean tame, boolean chest)
{
	Horse horse = (Horse) loc.getWorld().spawnEntity(loc, EntityType.HORSE);
	horse.setVariant(type.getVariant());
	horse.setColor(color);
	horse.setStyle(style);
	horse.setTamed(tame);
	horse.setCarryingChest(chest);
	return horse;
}
 
开发者ID:dmulloy2,项目名称:SwornAPI,代码行数:12,代码来源:SpecialEntities.java

示例3: horseEnter

import org.bukkit.entity.Horse; //导入方法依赖的package包/类
@EventHandler
	public void horseEnter(VehicleEnterEvent event){

	if(event.getVehicle() instanceof Horse){

      EntityType entered = (EntityType)event.getEntered().getType();
      if(entered == EntityType.PLAYER){ //Playercheck
    	  
    	  Player p = (Player)event.getEntered();
    	  String playername = p.getName();
    	  @SuppressWarnings("unused")
		Server server = p.getServer(); //Not used for now
          Horse h = (Horse)event.getVehicle();
          AnimalTamer owner = h.getOwner();
          HashMap<String, ArrayList<Block>> map = ECHorses.hashmap; //Getting hashmap from main class
          if(map.containsKey(playername)){ //If player has done /horseunclaim, then when the player left click the horse, unclaim the horse.
        	  if(owner == null){
        		  p.sendMessage(ChatColor.AQUA + "[ECHorses]" + ChatColor.GREEN + " Nobody owns this horse!");

        		  return;
        	  }
        	  if(!(owner == null)){
        		  if(p.isOp() || p.hasPermission("echorse.override")){
        			  p.sendMessage("You are overriding horse protection!");
        			  h.setOwner(null); //Removing horse claim (untame horse)
        			  map.remove(playername); //Remove the player from hashmap.
        			  return;
        		  }
        		 if(h.getOwner().getName() == p.getName()){ //Owner check
        			Location loc = h.getLocation().clone();
        			Inventory inv = h.getInventory();
        			for (ItemStack item : inv.getContents()){ //Checking if the horse has saddle & armor & or something its inventory (Donkey)
        				if(item!= null){
        					loc.getWorld().dropItemNaturally(loc, item.clone()); //Drops all the inventory contents on the horse location ground.
        				}
        			}
        			inv.clear(); //Clears the inventory of the horse.
        			if(h.isCarryingChest()){ //If the horse is carrying a chest (Donkey)
        				h.setCarryingChest(false); //if true then remove the chest.
        			}
        			 h.setOwner(null); //Remove horse claim (untame horse.)
        			 p.sendMessage(ChatColor.AQUA + "[ECHorses]" + ChatColor.GOLD + " Successfully removed horse protection. (Horse is not tamed anymore)");
        			 map.remove(playername); //Remove the player from hashmap.
        			 event.setCancelled(true);
        			 return;
        		 }		  
        	  }
          }    
          //Horse stealing protection (Entering the horse)
          if(!(owner == null)){
        	  
        	  if(p.isOp() || p.hasPermission("echorse.override")){ //Overriding the protection if player is OP
        		  return;
        	  }
        	  if(h.getOwner().getName() == p.getName()){ //Checking if entering player is the owner
        	  return;
        	  }
        	  else {
        		  p.sendMessage(ChatColor.AQUA + "[ECHorses]" + ChatColor.RED + " This horse is owned by " + h.getOwner().getName());
        		  Bukkit.getLogger().info("[ECHorses] " + playername + " tried entering someone elses horse");
        		  event.setCancelled(true);
        		  return;
        	  }
          } 
       p.sendMessage(ChatColor.AQUA + "[ECHorses]" + ChatColor.GREEN + " This horse is untamed!"); 
      }		
	}
}
 
开发者ID:ekiminatorn,项目名称:ECHorses,代码行数:69,代码来源:ECHorsesListeners.java


注:本文中的org.bukkit.entity.Horse.setCarryingChest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。