Java Code Examples for org.bukkit.Material#equals()
The following examples show how to use
org.bukkit.Material#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CraftLivingEntity.java From Kettle with GNU General Public License v3.0 | 6 votes |
private List<Block> getLineOfSight(Set<Material> transparent, int maxDistance, int maxLength) { if (maxDistance > 120) { maxDistance = 120; } ArrayList<Block> blocks = new ArrayList<Block>(); Iterator<Block> itr = new BlockIterator(this, maxDistance); while (itr.hasNext()) { Block block = itr.next(); blocks.add(block); if (maxLength != 0 && blocks.size() > maxLength) { blocks.remove(0); } Material material = block.getType(); if (transparent == null) { if (!material.equals(Material.AIR)) { break; } } else { if (!transparent.contains(material)) { break; } } } return blocks; }
Example 2
Source File: LevelCalcByChunk.java From askyblock with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("deprecation") private void scanChunk(ChunkSnapshot chunk) { for (int x = 0; x< 16; x++) { // Check if the block coord is inside the protection zone and if not, don't count it if (chunk.getX() * 16 + x < island.getMinProtectedX() || chunk.getX() * 16 + x >= island.getMinProtectedX() + island.getProtectionSize()) { continue; } for (int z = 0; z < 16; z++) { // Check if the block coord is inside the protection zone and if not, don't count it if (chunk.getZ() * 16 + z < island.getMinProtectedZ() || chunk.getZ() * 16 + z >= island.getMinProtectedZ() + island.getProtectionSize()) { continue; } for (int y = 0; y < island.getCenter().getWorld().getMaxHeight(); y++) { Material blockType = Material.getMaterial(chunk.getBlockTypeId(x, y, z)); boolean belowSeaLevel = Settings.seaHeight > 0 && y <= Settings.seaHeight; // Air is free if (!blockType.equals(Material.AIR)) { checkBlock(blockType, chunk.getBlockData(x, y, z), belowSeaLevel); } } } } }
Example 3
Source File: BuildingCertainTaskType.java From Quests with MIT License | 6 votes |
@SuppressWarnings("deprecation") private boolean matchBlock(Task task, Block block) { Material material; Object configBlock = task.getConfigValue("block"); Object configData = task.getConfigValue("data"); Object configSimilarBlocks = task.getConfigValue("use-similar-blocks"); material = Material.getMaterial(String.valueOf(configBlock)); Material blockType = block.getType(); short blockData = block.getData(); if (blockType.equals(material)) { return configData == null || (((int) blockData) == ((int) configData)); } return false; }
Example 4
Source File: CVInventory.java From Civs with GNU General Public License v3.0 | 6 votes |
public boolean contains(Material material) { if (material == null) { return false; } if (Util.isChunkLoadedAt(this.location)) { update(); if (!this.valid) { return false; } return this.inventory.contains(material); } else { for (Map.Entry<Integer, ItemStack> entry : this.contents.entrySet()) { if (material.equals(entry.getValue().getType())) { return true; } } return false; } }
Example 5
Source File: AttackWeb.java From EliteMobs with GNU General Public License v3.0 | 6 votes |
@EventHandler public void attackWeb(EntityDamageByEntityEvent event) { EliteMobEntity eliteMobEntity = EventValidator.getEventEliteMob(this, event); if (eliteMobEntity == null) return; Player player = EntityFinder.findPlayer(event); if (PowerCooldown.isInCooldown(eliteMobEntity, cooldownList)) return; Block block = player.getLocation().getBlock(); Material originalMaterial = block.getType(); if (!originalMaterial.equals(Material.AIR)) return; block.setType(Material.WEB); new BukkitRunnable() { @Override public void run() { block.setType(originalMaterial); } }.runTaskLater(MetadataHandler.PLUGIN, 20 * 3); PowerCooldown.startCooldownTimer(eliteMobEntity, cooldownList, 3 * 20); }
Example 6
Source File: Compat18.java From RedProtect with GNU General Public License v3.0 | 6 votes |
@EventHandler(ignoreCancelled = true) public void onInteractAS(PlayerInteractEvent e) { if (e.getClickedBlock() == null) { return; } if (RedProtect.get().bukkitVersion <= 180) { return; } Player p = e.getPlayer(); Location l = e.getClickedBlock().getLocation(); Region r = RedProtect.get().rm.getTopRegion(l); Material m = p.getItemInHand().getType(); if (RedProtect.get().bukkitVersion >= 190 && e.getItem() != null) { m = e.getItem().getType(); } if (m.equals(Material.ARMOR_STAND) || m.equals(Material.END_CRYSTAL)) { if (r != null && !r.canBuild(p) && !r.canPlace(m) && !r.canBreak(m)) { e.setCancelled(true); RedProtect.get().lang.sendMessage(p, "blocklistener.region.cantbuild"); } } }
Example 7
Source File: DruidBoots.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean effect(Event event, final Player player) { Material t = player.getLocation().getBlock().getRelative(0,-1,0).getLocation().getBlock().getType(); if(t.equals(Material.GRASS) || t.equals(Material.DIRT) || t.toString().contains("LEAVES")) { player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, SpeedDuration , SpeedLevel), true); player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, RegenerationDuration , RegenerationLevel), true); } return true; }
Example 8
Source File: Compat19.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.LOW) public void onPlayerInteract(PlayerInteractEvent event) { Player p = event.getPlayer(); Block b = event.getClickedBlock(); ItemStack itemInHand = event.getItem(); Location l; if (b != null) { l = b.getLocation(); RedProtect.get().logger.debug(LogLevel.DEFAULT, "PlayerListener - Is PlayerInteractEvent event. The block is " + b.getType().name()); } else { l = p.getLocation(); } if (RedProtect.get().tpWait.contains(p.getName())) { RedProtect.get().tpWait.remove(p.getName()); RedProtect.get().lang.sendMessage(p, "cmdmanager.region.tpcancelled"); } if (itemInHand != null && (event.getAction().name().equals("RIGHT_CLICK_BLOCK") || b == null)) { Material hand = itemInHand.getType(); Region r = RedProtect.get().rm.getTopRegion(l); // Deny chorus teleport if (r != null && hand.equals(Material.CHORUS_FRUIT) && !r.canTeleport(p)) { RedProtect.get().lang.sendMessage(p, "playerlistener.region.cantuse"); event.setCancelled(true); event.setUseItemInHand(Event.Result.DENY); } // Deny glide boost if (r == null && p.isGliding() && itemInHand.getType().name().contains("FIREWORK") && !p.hasPermission("redprotect.bypass.glide") && !RedProtect.get().config.globalFlagsRoot().worlds.get(p.getWorld().getName()).player_glide.allow_boost) { event.setUseItemInHand(Event.Result.DENY); event.setCancelled(true); RedProtect.get().lang.sendMessage(p, "globallistener.elytra.cantboost"); } } }
Example 9
Source File: Game.java From BedwarsRel with GNU General Public License v3.0 | 5 votes |
private GameCheckCode checkTeams() { for (Team t : this.teams.values()) { if (t.getSpawnLocation() == null) { return GameCheckCode.TEAMS_WITHOUT_SPAWNS; } Material targetMaterial = this.getTargetMaterial(); if (targetMaterial.equals(Material.BED_BLOCK)) { if ((t.getHeadTarget() == null || t.getFeetTarget() == null) || (!Utils.isBedBlock(t.getHeadTarget()) || !Utils.isBedBlock(t.getFeetTarget()))) { return GameCheckCode.TEAM_NO_WRONG_BED; } } else { if (t.getHeadTarget() == null) { return GameCheckCode.TEAM_NO_WRONG_TARGET; } if (!t.getHeadTarget().getType().equals(targetMaterial)) { return GameCheckCode.TEAM_NO_WRONG_TARGET; } } } return GameCheckCode.OK; }
Example 10
Source File: AttackFreeze.java From EliteMobs with GNU General Public License v3.0 | 5 votes |
@EventHandler public void attackFreeze(EntityDamageByEntityEvent event) { EliteMobEntity eliteMobEntity = EventValidator.getEventEliteMob(this, event); if (eliteMobEntity == null) return; Player player = EntityFinder.findPlayer(event); if (PowerCooldown.isInCooldown(eliteMobEntity, cooldowns)) return; /* Slow player down */ player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20 * 3, 10)); player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText( ChatColorConverter.convert( ConfigValues.mobPowerConfig.getString( MobPowersConfig.FROZEN_MESSAGE)))); PowerCooldown.startCooldownTimer(eliteMobEntity, cooldowns, 20 * 15); /* Add block effect */ Block block = player.getLocation().getBlock(); Material originalMaterial = block.getType(); if (!originalMaterial.equals(Material.AIR)) return; block.setType(Material.PACKED_ICE); new BukkitRunnable() { @Override public void run() { block.setType(originalMaterial); } }.runTaskLater(MetadataHandler.PLUGIN, 20 * 3); }
Example 11
Source File: MiningCertainTaskType.java From Quests with MIT License | 5 votes |
@SuppressWarnings("deprecation") private boolean matchBlock(Task task, Block block) { Material material; Object configBlock = task.getConfigValues().containsKey("block") ? task.getConfigValue("block") : task.getConfigValue("blocks"); Object configData = task.getConfigValue("data"); Object configSimilarBlocks = task.getConfigValue("use-similar-blocks"); List<String> checkBlocks = new ArrayList<>(); if (configBlock instanceof List) { checkBlocks.addAll((List) configBlock); } else { checkBlocks.add(String.valueOf(configBlock)); } for (String materialName : checkBlocks) { // LOG:1 LOG:2 LOG should all be supported with this String[] split = materialName.split(":"); int comparableData = (int) configData; if (split.length > 1) { comparableData = Integer.parseInt(split[1]); } material = Material.getMaterial(String.valueOf(split[0])); Material blockType = block.getType(); short blockData = block.getData(); if (blockType.equals(material)) { return configData == null || ((int) blockData) == comparableData; } } return false; }
Example 12
Source File: SetTargetCommand.java From BedwarsRel with GNU General Public License v3.0 | 4 votes |
@Override public boolean execute(CommandSender sender, ArrayList<String> args) { if (!super.hasPermission(sender)) { return false; } Player player = (Player) sender; String team = args.get(1); Game game = this.getPlugin().getGameManager().getGame(args.get(0)); if (game == null) { player.sendMessage(ChatWriter.pluginMessage(ChatColor.RED + BedwarsRel ._l(player, "errors.gamenotfound", ImmutableMap.of("game", args.get(0).toString())))); return false; } if (game.getState() == GameState.RUNNING) { sender.sendMessage( ChatWriter.pluginMessage(ChatColor.RED + BedwarsRel ._l(sender, "errors.notwhilegamerunning"))); return false; } Team gameTeam = game.getTeam(team); if (gameTeam == null) { player.sendMessage( ChatWriter.pluginMessage(ChatColor.RED + BedwarsRel._l(player, "errors.teamnotfound"))); return false; } Class<?> hashsetType = Utils.getGenericTypeOfParameter(player.getClass(), "getTargetBlock", 0); Method targetBlockMethod = this.getTargetBlockMethod(player); Block targetBlock = null; if (targetBlockMethod != null) { targetBlock = this.getTargetBlock(targetBlockMethod, hashsetType, player); } Block standingBlock = player.getLocation().getBlock().getRelative(BlockFace.DOWN); if (targetBlock == null || standingBlock == null) { player.sendMessage( ChatWriter.pluginMessage(ChatColor.RED + BedwarsRel._l(player, "errors.bedtargeting"))); return false; } Material targetMaterial = game.getTargetMaterial(); if (targetBlock.getType() != targetMaterial && standingBlock.getType() != targetMaterial) { player.sendMessage( ChatWriter.pluginMessage(ChatColor.RED + BedwarsRel._l(player, "errors.bedtargeting"))); return false; } Block theBlock = null; if (targetBlock.getType() == targetMaterial) { theBlock = targetBlock; } else { theBlock = standingBlock; } if (targetMaterial.equals(Material.BED_BLOCK)) { Block neighbor = null; Bed theBed = (Bed) theBlock.getState().getData(); if (!theBed.isHeadOfBed()) { neighbor = theBlock; theBlock = Utils.getBedNeighbor(neighbor); } else { neighbor = Utils.getBedNeighbor(theBlock); } gameTeam.setTargets(theBlock, neighbor); } else { gameTeam.setTargets(theBlock, null); } player.sendMessage(ChatWriter.pluginMessage(ChatColor.GREEN + BedwarsRel ._l(player, "success.bedset", ImmutableMap .of("team", gameTeam.getChatColor() + gameTeam.getName() + ChatColor.GREEN)))); return true; }
Example 13
Source File: RescuePlatform.java From BedwarsRel with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("deprecation") public void create(Player player, Game game) { this.game = game; this.owner = player; int breakTime = BedwarsRel.getInstance() .getIntConfig("specials.rescue-platform.break-time", 10); int waitTime = BedwarsRel .getInstance().getIntConfig("specials.rescue-platform.using-wait-time", 20); boolean canBreak = BedwarsRel.getInstance().getBooleanConfig("specials.rescue-platform.can-break", false); Material configMaterial = Utils.getMaterialByConfig("specials.rescue-platform.block", Material.STAINED_GLASS); if (waitTime > 0) { ArrayList<RescuePlatform> livingPlatforms = this.getLivingPlatforms(); if (!livingPlatforms.isEmpty()) { for (RescuePlatform livingPlatform : livingPlatforms) { int waitLeft = waitTime - livingPlatform.getLivingTime(); if (waitLeft > 0) { player.sendMessage( ChatWriter.pluginMessage( BedwarsRel._l(player, "ingame.specials.rescue-platform.left", ImmutableMap.of("time", String.valueOf(waitLeft))))); return; } } } } if (player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() != Material.AIR) { player.sendMessage( ChatWriter.pluginMessage(ChatColor.RED + BedwarsRel._l(player, "errors.notinair"))); return; } Location mid = player.getLocation().clone(); mid.setY(mid.getY() - 1.0D); Team team = game.getPlayerTeam(player); ItemStack usedStack = null; if (BedwarsRel.getInstance().getCurrentVersion().startsWith("v1_8")) { usedStack = player.getInventory().getItemInHand(); usedStack.setAmount(usedStack.getAmount() - 1); player.getInventory().setItem(player.getInventory().getHeldItemSlot(), usedStack); } else { if (player.getInventory().getItemInOffHand().getType() == this.getItemMaterial()) { usedStack = player.getInventory().getItemInOffHand(); usedStack.setAmount(usedStack.getAmount() - 1); player.getInventory().setItemInOffHand(usedStack); } else if (player.getInventory().getItemInMainHand().getType() == this.getItemMaterial()) { usedStack = player.getInventory().getItemInMainHand(); usedStack.setAmount(usedStack.getAmount() - 1); player.getInventory().setItemInMainHand(usedStack); } } player.updateInventory(); for (BlockFace face : BlockFace.values()) { if (face.equals(BlockFace.DOWN) || face.equals(BlockFace.UP)) { continue; } Block placed = mid.getBlock().getRelative(face); if (placed.getType() != Material.AIR) { continue; } placed.setType(configMaterial); if (configMaterial.equals(Material.STAINED_GLASS) || configMaterial.equals(Material.WOOL) || configMaterial.equals(Material.STAINED_CLAY)) { placed.setData(team.getColor().getDyeColor().getWoolData()); } if (!canBreak) { game.getRegion().addPlacedUnbreakableBlock(placed, null); } else { game.getRegion().addPlacedBlock(placed, null); } this.addPlatformBlock(placed); } if (breakTime > 0 || waitTime > 0) { this.runTask(breakTime, waitTime); game.addSpecialItem(this); } }
Example 14
Source File: SafeSpotTeleport.java From askyblock with GNU General Public License v2.0 | 4 votes |
/** * Returns true if the location is a safe one. * @param chunk * @param x * @param y * @param z * @param worldHeight * @return true if this is a safe spot, false if this is a portal scan */ @SuppressWarnings("deprecation") private boolean checkBlock(ChunkSnapshot chunk, int x, int y, int z, int worldHeight) { World world = location.getWorld(); Material type = Material.getMaterial(chunk.getBlockTypeId(x, y, z)); if (!type.equals(Material.AIR)) { // AIR Material space1 = Material.getMaterial(chunk.getBlockTypeId(x, Math.min(y + 1, worldHeight), z)); Material space2 = Material.getMaterial(chunk.getBlockTypeId(x, Math.min(y + 2, worldHeight), z)); if ((space1.equals(Material.AIR) && space2.equals(Material.AIR)) || (space1.equals(Material.PORTAL) && space2.equals(Material.PORTAL)) && (!type.toString().contains("FENCE") && !type.toString().contains("DOOR") && !type.toString().contains("GATE") && !type.toString().contains("PLATE"))) { switch (type) { // Unsafe case ANVIL: case BARRIER: case BOAT: case CACTUS: case DOUBLE_PLANT: case ENDER_PORTAL: case FIRE: case FLOWER_POT: case LADDER: case LAVA: case LEVER: case LONG_GRASS: case PISTON_EXTENSION: case PISTON_MOVING_PIECE: case SIGN_POST: case SKULL: case STANDING_BANNER: case STATIONARY_LAVA: case STATIONARY_WATER: case STONE_BUTTON: case TORCH: case TRIPWIRE: case WATER: case WEB: case WOOD_BUTTON: //Block is dangerous break; case PORTAL: if (portal) { // A portal has been found, switch to non-portal mode now portal = false; } break; default: return safe(chunk, x, y, z, world); } } } return false; }
Example 15
Source File: AcidEffect.java From askyblock with GNU General Public License v2.0 | 4 votes |
/** * Check if player can be burned by acid * @param player * @return true if player is not safe */ private boolean isSafeFromAcid(Player player) { if (DEBUG) plugin.getLogger().info("DEBUG: safe from acid"); if (!player.getWorld().equals(ASkyBlock.getIslandWorld())) { if (DEBUG) plugin.getLogger().info("DEBUG: wrong world"); return true; } // In liquid Material bodyMat = player.getLocation().getBlock().getType(); Material headMat = player.getLocation().getBlock().getRelative(BlockFace.UP).getType(); if (bodyMat.equals(Material.STATIONARY_WATER)) bodyMat = Material.WATER; if (headMat.equals(Material.STATIONARY_WATER)) headMat = Material.WATER; if (bodyMat != Material.WATER && headMat != Material.WATER) { if (DEBUG) plugin.getLogger().info("DEBUG: not in water " + player.getLocation().getBlock().isLiquid() + " " + player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid()); return true; } // Check if player is in a boat Entity playersVehicle = player.getVehicle(); if (playersVehicle != null) { // They are in a Vehicle if (playersVehicle.getType().equals(EntityType.BOAT)) { // I'M ON A BOAT! I'M ON A BOAT! A %^&&* BOAT! if (DEBUG) plugin.getLogger().info("DEBUG: boat"); return true; } } // Check if full armor protects if (Settings.fullArmorProtection) { boolean fullArmor = true; for (ItemStack item : player.getInventory().getArmorContents()) { if (item == null || (item != null && item.getType().equals(Material.AIR))) { fullArmor = false; break; } } if (fullArmor) { if (DEBUG) plugin.getLogger().info("DEBUG: full armor"); return true; } } // Check if player has an active water potion or not Collection<PotionEffect> activePotions = player.getActivePotionEffects(); for (PotionEffect s : activePotions) { // plugin.getLogger().info("Potion is : " + // s.getType().toString()); if (s.getType().equals(PotionEffectType.WATER_BREATHING)) { // Safe! if (DEBUG) plugin.getLogger().info("DEBUG: Water breathing potion protection!"); return true; } } // Check if water above sea-level is not acid Island island = plugin.getGrid().getIslandAt(player.getLocation()); if (island != null && !island.getIgsFlag(SettingsFlag.ACID_DAMAGE) && player.getLocation().getBlockY() > Settings.seaHeight) { if (DEBUG) plugin.getLogger().info("DEBUG:no acid damage above sea level 1"); return true; } if (island == null && !Settings.defaultWorldSettings.get(SettingsFlag.ACID_DAMAGE) && player.getLocation().getBlockY() > Settings.seaHeight) { if (DEBUG) plugin.getLogger().info("DEBUG: no acid damage above sea level"); return true; } if (DEBUG) plugin.getLogger().info("DEBUG: burn in acid"); return false; }
Example 16
Source File: BlockFromToListener.java From IridiumSkyblock with GNU General Public License v2.0 | 4 votes |
@EventHandler public void onBlockFromTo(BlockFromToEvent event) { try { final Block block = event.getBlock(); final Location location = block.getLocation(); final IslandManager islandManager = IridiumSkyblock.getIslandManager(); final Island island = islandManager.getIslandViaLocation(location); if (island == null) return; final Material material = block.getType(); final Block toBlock = event.getToBlock(); final Location toLocation = toBlock.getLocation(); if (material.equals(Material.WATER) || material.equals(Material.LAVA)) { final Island toIsland = islandManager.getIslandViaLocation(toLocation); if (island != toIsland) event.setCancelled(true); } if (!IridiumSkyblock.getUpgrades().oresUpgrade.enabled) return; if (event.getFace() == BlockFace.DOWN) return; if (!isSurroundedByWater(toLocation)) return; final int oreLevel = island.getOreLevel(); final World world = location.getWorld(); if (world == null) return; final String worldName = world.getName(); final Config config = IridiumSkyblock.getConfiguration(); List<String> islandOreUpgrades; if (worldName.equals(config.worldName)) islandOreUpgrades = IridiumSkyblock.oreUpgradeCache.get(oreLevel); else if (worldName.equals(config.netherWorldName)) islandOreUpgrades = IridiumSkyblock.netherOreUpgradeCache.get(oreLevel); else return; Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () -> { final Material toMaterial = toBlock.getType(); if (!(toMaterial.equals(Material.COBBLESTONE) || toMaterial.equals(Material.STONE))) return; final Random random = new Random(); final String oreUpgrade = islandOreUpgrades.get(random.nextInt(islandOreUpgrades.size())); final XMaterial oreUpgradeXmaterial = XMaterial.valueOf(oreUpgrade); final Material oreUpgradeMaterial = oreUpgradeXmaterial.parseMaterial(true); if (oreUpgradeMaterial == null) return; toBlock.setType(oreUpgradeMaterial); final BlockState blockState = toBlock.getState(); blockState.update(true); if (Utils.isBlockValuable(toBlock)) { final XMaterial xmaterial = XMaterial.matchXMaterial(material); island.valuableBlocks.compute(xmaterial.name(), (name, original) -> { if (original == null) return 1; return original + 1; }); if (island.updating) island.tempValues.add(location); island.calculateIslandValue(); } }); } catch (Exception ex) { IridiumSkyblock.getInstance().sendErrorMessage(ex); } }
Example 17
Source File: ItemTierFinder.java From EliteMobs with GNU General Public License v3.0 | 2 votes |
public static double findWeaponTier(Player player) { List<ItemStack> itemList = new ArrayList<>(); if (player.getInventory().getItemInOffHand() != null && !player.getInventory().getItemInOffHand().getType().equals(Material.AIR)) { itemList.add(player.getInventory().getItemInOffHand()); } for (int i = 0; i < 9; i++) { if (player.getInventory().getItem(i) != null && !player.getInventory().getItem(i).getType().equals(Material.AIR)) { Material material = player.getInventory().getItem(i).getType(); if (material.equals(Material.DIAMOND_SWORD) || material.equals(Material.DIAMOND_AXE) || material.equals(Material.IRON_SWORD) || material.equals(Material.IRON_AXE) || material.equals(Material.STONE_SWORD) || material.equals(Material.STONE_AXE) || material.equals(Material.GOLD_SWORD) || material.equals(Material.GOLD_AXE) || material.equals(Material.WOOD_SWORD) || material.equals(Material.WOOD_AXE) || material.equals(Material.BOW)) { itemList.add(player.getInventory().getItem(i)); } } } double highestTier = 0; if (itemList.size() > 0) { for (ItemStack itemStack : itemList) { double currentTier = findBattleTier(itemStack); if (currentTier > highestTier) { highestTier = currentTier; } } } return highestTier; }