本文整理汇总了Java中org.bukkit.entity.EntityType.SHEEP属性的典型用法代码示例。如果您正苦于以下问题:Java EntityType.SHEEP属性的具体用法?Java EntityType.SHEEP怎么用?Java EntityType.SHEEP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.entity.EntityType
的用法示例。
在下文中一共展示了EntityType.SHEEP属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setColor
public void setColor(DyeColor color) {
if (type != EntityType.SHEEP)
return;
this.color = color;
if (entity != null)
((Sheep) entity).setColor(color);
Pets.getDB().update("UPDATE pets SET color='" + color.toString() + "' WHERE id=" + id);
}
示例2: execute
@Override
public boolean execute(CommandSender sender, String[] args) {
if (args.length < 2) {
Chat.player(sender, "&2[Pets] &cUsage: /pet color [pet name] [color]");
return true;
}
Player p = (Player) sender;
String username = p.getName();
for (PetInstance pet : PetInstance.getList()) {
if (pet.getName().equalsIgnoreCase(args[0])) {
if (pet.getOwner().equalsIgnoreCase(username)) {
if (pet.getType() != EntityType.SHEEP) {
Chat.player(p, "&2[Pets] &cYou can only change the color of sheep.");
return true;
}
String[] nameArray = Arrays.copyOfRange(args, 1, args.length);
String c = Joiner.on("_").join(nameArray);
DyeColor color = null;
try {
color = DyeColor.valueOf(c.toUpperCase());
}
catch (IllegalArgumentException e) {
Chat.player(p, "&2[Pets] &cUnknown color: " + c + "!");
Chat.player(p, "&cColors: &7&o" + Joiner.on(", ").join(DyeColor.values()).toLowerCase().replace("_", " "));
return true;
}
Chat.player(p, "&2[Pets] &aYou have changed the color of &e" + pet.getName() + "&a to " + c.replace("_", " "));
pet.setColor(color);
return true;
}
}
}
Chat.player(p, "&2[Pets] &cYou do not own a pet by the name of &e" + args[0] + "\n &7&oBuy customized pets at www.mczone.co/shop");
return true;
}
示例3: onEntitySpawn
@EventHandler
public void onEntitySpawn(CreatureSpawnEvent e) {
if (e.getEntityType().isAlive() && e.getEntityType() != EntityType.PLAYER
&& e.getEntityType() != EntityType.ZOMBIE && e.getEntityType() != EntityType.ENDERMAN
&& e.getEntityType() != EntityType.PIG && e.getEntityType() != EntityType.COW
&& e.getEntityType() != EntityType.SHEEP && e.getEntityType() != EntityType.HORSE
&& e.getEntityType() != EntityType.SQUID) {
e.setCancelled(true);
e.getLocation().getWorld().spawn(e.getLocation(), Zombie.class);
}
}
示例4: getType
public EntityType getType() {
return EntityType.SHEEP;
}
示例5: isSheep
public boolean isSheep(Entity e){
return e.getType() == EntityType.SHEEP;
}