本文整理匯總了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;
}