當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。