本文整理汇总了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;
}
示例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;
}
示例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!");
}
}
}