本帖最后由 Berry_so 于 2021-2-16 11:14 编辑 
如何判定自定GUI内某槽位的某个物品是否含有配置文件路径内的String,并替换为多行Lore(即集合)
如何判定自定GUI内某槽位的某个物品是否含有配置文件路径内的String,并替换为多行Lore(即集合)
 本帖最后由 dengyu 于 2021-2-16 10:37 编辑 
复制代码
看看这个不知道能不能帮你(没有实际验证)
-                         ItemMeta test = item.getItemMeta();
 
-                         List<String> l = test.getLore();
 
-                         List<String> list2 = new ArrayList<>();
 
-                         List<String> newList = Main.getConfigList("list在配置文件的地址");
 
-                         for (String string : l)
 
-                         {
 
-                                 if (string.contains("指定字符串"))
 
-                                 {
 
-                                         string.replaceAll("指定字符串", "该字符串的第一行的目标替换字符串");
 
-                                         list2.add(string);
 
-                                         for (String str : newList)
 
-                                         {
 
-                                                 list2.add(str);
 
-                                         }
 
-                                 }
 
-                                 else
 
-                                 {
 
-                                         list2.add(string);
 
-                                 }
 
-                         }
 
-                         test.setLore(list2);
 
- item.setItemMeta(test);
看看这个不知道能不能帮你(没有实际验证)
dengyu 发表于 2021-2-16 10:33
看看这个不知道能不能帮你(没有实际验证)
就是判定字符串以后,遍历集合,然后在遍历的时候替换嘛,这样的话我那我写个方法,每次要用的时候调用这个方法就好了吧