/** * {@inheritDoc} */ public LlamaMenu(Plot plot, Llama llama) { super(plot, llama); //color ItemStack color = new ItemStack(Material.CONCRETE_POWDER, 1, (short) 1); ItemMeta colorMeta = color.getItemMeta(); colorMeta.setDisplayName(ChatColor.GREEN + "Change the color"); color.setItemMeta(colorMeta); insertItem(color, event -> { new LlamaColorSelectionMenu(llama).open((Player) event.getWhoClicked()); event.setCancelled(true); }, 0); }
@Override @Nullable protected Llama.Color[] get(Event e) { if (llama.getSingle(e) instanceof Llama) { return new Llama.Color[]{((Llama) llama.getSingle(e)).getColor()}; } return null; }
@Override public void change(Event e, Object[] delta, Changer.ChangeMode mode){ if (mode == ChangeMode.SET) { if (!(llama.getSingle(e) instanceof Llama)) { return; } ((Llama) llama.getSingle(e)).setColor((Llama.Color)delta[0]); } }
@Override public Class<?>[] acceptChange(final Changer.ChangeMode mode) { if (mode == ChangeMode.SET) { return CollectionUtils.array(Llama.Color.class); } return null; }
@Override @Nullable protected LlamaInventory[] get(Event e) { if (llama.getSingle(e) instanceof Llama) { return new LlamaInventory[]{((Llama) llama.getSingle(e)).getInventory()}; } return null; }
@Override public Class<? extends Llama.Color> getReturnType() { return Llama.Color.class; }
/** * {@inheritDoc} */ LlamaColorSelectionMenu(Llama llama) { super(null, 9, ChatColor.GREEN + "Change the llama color", 1); setStartingPoint(2); //brown ItemStack brown = new Wool(DyeColor.BROWN).toItemStack(1); ItemMeta brownMeta = brown.getItemMeta(); brownMeta.setDisplayName(ChatColor.GREEN + "Brown"); brown.setItemMeta(brownMeta); addItem(brown, event -> { llama.setColor(Llama.Color.BROWN); event.setCancelled(true); }); //creamy ItemStack creamy = new ItemStack(Material.SANDSTONE); ItemMeta creamyMeta = creamy.getItemMeta(); creamyMeta.setDisplayName(ChatColor.GREEN + "Creamy"); creamy.setItemMeta(creamyMeta); addItem(creamy, event -> { llama.setColor(Llama.Color.CREAMY); event.setCancelled(true); }); setStartingPoint(5); //gray ItemStack gray = new Wool(DyeColor.GRAY).toItemStack(1); ItemMeta grayMeta = gray.getItemMeta(); grayMeta.setDisplayName(ChatColor.GREEN + "Gray"); gray.setItemMeta(grayMeta); addItem(gray, event -> { llama.setColor(Llama.Color.GRAY); event.setCancelled(true); }); //white ItemStack white = new Wool(DyeColor.WHITE).toItemStack(1); ItemMeta whiteMeta = white.getItemMeta(); whiteMeta.setDisplayName(ChatColor.GREEN + "White"); white.setItemMeta(whiteMeta); addItem(white, event -> { llama.setColor(Llama.Color.WHITE); event.setCancelled(true); }); }
/** * Update distances and store them into server's memory until player disconnects. * * @param player */ private void validateMovementAndUpdateDistance(Player player) { String uuid = player.getUniqueId().toString(); Location previousLocation = playerLocations.get(uuid); // Update new location. playerLocations.put(uuid, player.getLocation()); // If player location not found or if player has changed world, ignore previous location. // Evaluating distance would give an exception. if (previousLocation == null || !previousLocation.getWorld().getName().equals(player.getWorld().getName())) { return; } // If player is in restricted game mode or is in a blocked world, don't update distances. if (!shouldIncreaseBeTakenIntoAccountNoPermissions(player)) { return; } int difference = getDistanceDifference(player, previousLocation); // Player has not moved. if (difference == 0L) { return; } if (player.getVehicle() instanceof Horse) { updateDistance(difference, player, NormalAchievements.DISTANCEHORSE); } else if (player.getVehicle() instanceof Pig) { updateDistance(difference, player, NormalAchievements.DISTANCEPIG); } else if (player.getVehicle() instanceof Minecart) { updateDistance(difference, player, NormalAchievements.DISTANCEMINECART); } else if (player.getVehicle() instanceof Boat) { updateDistance(difference, player, NormalAchievements.DISTANCEBOAT); } else if (plugin.getServerVersion() >= 11 && player.getVehicle() instanceof Llama) { updateDistance(difference, player, NormalAchievements.DISTANCELLAMA); } else if (!player.isFlying() && (plugin.getServerVersion() < 9 || !player.isGliding())) { updateDistance(difference, player, NormalAchievements.DISTANCEFOOT); } else if (plugin.getServerVersion() >= 9 && player.isGliding()) { updateDistance(difference, player, NormalAchievements.DISTANCEGLIDING); } }
/** * Assembles an ArrayList of the properties for the specified Entity that * is to be used for a spawn egg. All instanceof checks are done internally * by the LorePackager, so no type checking is required prior to calling * this method. Null Entities will throw an IllegalArgumentException. <b>The * actual ArrayList is returned by {@link #getLore() LorePacker.getLore()}. * </b> * @param livingEntity - The Entity to assemble a lore for. * @return An ArrayList of Strings * @throws IllegalArgumentException If entity parameter is null */ public LorePacker(LivingEntity livingEntity) throws IllegalArgumentException { if (livingEntity == null) { throw new IllegalArgumentException("Can't assemble lore for a null entity!"); } lore = new ArrayList<String>(); // This needs to always be on top of an egg's lore lore.add("Identifier: SimpleEgg." + livingEntity.getType().getEntityClass().getSimpleName() + "." + Main.getSelf().getDescription().getVersion()); lore.addAll(livingEntity(livingEntity)); if (livingEntity instanceof Ageable) { lore.addAll(ageable((Ageable) livingEntity)); if (livingEntity instanceof Sheep) { lore.addAll(sheep((Sheep) livingEntity)); } else if (livingEntity instanceof Pig) { lore.addAll(pig((Pig) livingEntity)); } else if (livingEntity instanceof Rabbit) { lore.addAll(rabbit((Rabbit) livingEntity)); } else if (livingEntity instanceof Villager) { lore.addAll(villager((Villager) livingEntity)); } else if (livingEntity instanceof Tameable) { lore.addAll(tameable((Tameable) livingEntity)); if (livingEntity instanceof AbstractHorse) { lore.addAll(abstractHorse((AbstractHorse) livingEntity)); if (livingEntity instanceof Horse) { lore.addAll(horse((Horse) livingEntity)); } else if (livingEntity instanceof ChestedHorse) { lore.addAll(chestedHorse((ChestedHorse) livingEntity)); if (livingEntity instanceof Llama) { lore.addAll(llama((Llama) livingEntity)); } } } else if (livingEntity instanceof Sittable) { lore.addAll(sittable((Sittable) livingEntity)); if (livingEntity instanceof Wolf) { lore.addAll(wolf((Wolf) livingEntity)); } else if (livingEntity instanceof Ocelot) { lore.addAll(ocelot((Ocelot) livingEntity)); } else if (livingEntity instanceof Parrot) { lore.addAll(parrot((Parrot) livingEntity)); } } } } else if (livingEntity instanceof Slime) { lore.addAll(slime((Slime) livingEntity)); } else if (livingEntity instanceof Creeper) { lore.addAll(creeper((Creeper) livingEntity)); } else if (livingEntity instanceof Zombie) { lore.addAll(zombie((Zombie) livingEntity)); if (livingEntity instanceof PigZombie) { lore.addAll(pigZombie((PigZombie) livingEntity)); } else if (livingEntity instanceof ZombieVillager) { lore.addAll(zombieVillager((ZombieVillager) livingEntity)); } } else if (livingEntity instanceof Spellcaster) { lore.addAll(spellCaster((Spellcaster) livingEntity)); } else if (livingEntity instanceof IronGolem) { lore.addAll(ironGolem((IronGolem) livingEntity)); } else if (livingEntity instanceof Snowman) { lore.addAll(snowman((Snowman) livingEntity)); } }