I'm searching a way to continue a for-loop until a string matches.
@SuppressWarnings("deprecation")
public ItemStack[] loadSecoundtLaserInventory(){
ItemStack pan = new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.BLACK.getWoolData());
ItemMeta panmeta = pan.getItemMeta();
panmeta.setDisplayName("");
pan.setItemMeta(panmeta);
List<ItemStack> content = new ArrayList<ItemStack>();
content.add(pan);
//
for(String str : getConfig().getConfigurationSection("lasers").getKeys(false)){
if(!str.startsWith("2")){
}
String[] amounts = getConfig().getString("lasers." + str + "amount").split(";");
ItemStack is1 = new ItemStack(getConfig().getInt("lasers." + str + ".block-id"));
ItemMeta ismeta1 = is1.getItemMeta();
ismeta1.setLore(Arrays.asList(HiddenStringUtil.encodeString(str)));
ismeta1.setDisplayName(ChatColor.translateAlternateColorCodes('&', getConfig().getString("lasers." + str + ".dname-amount").replace("{amount}", amounts[0])));
ItemStack is2 = new ItemStack(getConfig().getInt("lasers." + str + ".block-id"));
ItemMeta ismeta2 = is2.getItemMeta();
ismeta2.setLore(Arrays.asList(HiddenStringUtil.encodeString(str)));
ismeta2.setDisplayName(ChatColor.translateAlternateColorCodes('&', getConfig().getString("lasers." + str + ".dname-amount").replace("{amount}", amounts[1])));
ItemStack is3 = new ItemStack(getConfig().getInt("lasers." + str + ".block-id"));
ItemMeta ismeta3 = is3.getItemMeta();
ismeta3.setLore(Arrays.asList(HiddenStringUtil.encodeString(str)));
ismeta3.setDisplayName(ChatColor.translateAlternateColorCodes('&', getConfig().getString("lasers." + str + ".dname-amount").replace("{amount}", amounts[2])));
is2.setItemMeta(ismeta2);
if(!content.contains(is1)){
content.add(is1);
}
if(content.size() == 2){
content.add(pan);
content.add(pan);
}
if(!content.contains(is2)){
content.add(is2);
}
if(content.size() == 5){
content.add(pan);
content.add(pan);
}
if(!content.contains(is3)){
content.add(is3);
}
if(content.size() == 8){
content.add(pan);
return content.stream().toArray(ItemStack[]::new);
}
}
return null;
}
Basically the Strings i loop over is something like
1panda,2boom,3tnt.
The problem is when the string doesn't starts with 2, i want to continue to the next String. I cannot use the return statement, because it would stop the loop. Any other ideas?