mirror of
https://github.com/CarmJos/MineConfiguration.git
synced 2026-06-04 21:58:16 +08:00
fix(item): 修复上下空行错误
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mineconfiguration-parent</artifactId>
|
<artifactId>mineconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>2.8.3</version>
|
<version>2.8.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mineconfiguration-parent</artifactId>
|
<artifactId>mineconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>2.8.3</version>
|
<version>2.8.4</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
public class ConfiguredItem extends ConfiguredSection<ItemStack> {
|
public class ConfiguredItem extends ConfiguredSection<ItemStack> {
|
||||||
|
|
||||||
public static final @NotNull Pattern LORE_INSERT_PATTERN = Pattern.compile("^#(.*)#(\\{\\w+})?$");
|
public static final @NotNull Pattern LORE_INSERT_PATTERN = Pattern.compile("^#(.*)#(\\{.*})?$");
|
||||||
public static final @NotNull Pattern LORE_OFFSET_PATTERN = Pattern.compile("\\{(-?\\d+)(?:,(-?\\d+))?}");
|
public static final @NotNull Pattern LORE_OFFSET_PATTERN = Pattern.compile("\\{(-?\\d+)(?:,(-?\\d+))?}");
|
||||||
|
|
||||||
public static ItemConfigBuilder create() {
|
public static ItemConfigBuilder create() {
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredItem;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
|
public class LoreInsertTest {
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void insert() {
|
||||||
|
List<String> original = Arrays.asList(
|
||||||
|
"测试lore的第一行",
|
||||||
|
"测试lore的第二行",
|
||||||
|
"#click-lore#{1,2}",
|
||||||
|
"测试lore的倒数第二行",
|
||||||
|
"测试lore的倒数第一行"
|
||||||
|
);
|
||||||
|
|
||||||
|
List<String> replace = Arrays.asList("> 插入的点击行1", "> 插入的点击行2");
|
||||||
|
Map<String, List<String>> inserted = new HashMap<>();
|
||||||
|
inserted.put("click-lore", replace);
|
||||||
|
|
||||||
|
System.out.println(ConfiguredItem.insertLore(original, inserted));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void parse() {
|
||||||
|
System.out.println(parse("#click-lore#{1,0}"));
|
||||||
|
System.out.println(parse("#click-lore#{1,2}"));
|
||||||
|
System.out.println(parse("#click-lore#{1}"));
|
||||||
|
System.out.println(parse("#click-lore#{我}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String parse(String line) {
|
||||||
|
Matcher matcher = ConfiguredItem.LORE_INSERT_PATTERN.matcher(line);
|
||||||
|
if (!matcher.matches()) {
|
||||||
|
return line;
|
||||||
|
} else {
|
||||||
|
String path = matcher.group(1);
|
||||||
|
String offset = matcher.group(2);
|
||||||
|
return "Path -> " + path + " Offset-> " + offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void offset() {
|
||||||
|
|
||||||
|
System.out.println(ConfiguredItem.addLoreOffset(Arrays.asList("测试lore", "第二行"), "{1,-5}"));
|
||||||
|
System.out.println(ConfiguredItem.addLoreOffset(Arrays.asList("测试lore", "第二行"), "{1,2}"));
|
||||||
|
System.out.println(ConfiguredItem.addLoreOffset(Arrays.asList("测试lore", "第二行"), "{1,0}"));
|
||||||
|
System.out.println(ConfiguredItem.addLoreOffset(Arrays.asList("测试lore", "第二行"), "{2}"));
|
||||||
|
System.out.println(ConfiguredItem.addLoreOffset(Arrays.asList("测试lore", "第二行"), "{我}"));
|
||||||
|
System.out.println(ConfiguredItem.addLoreOffset(Arrays.asList("测试lore", "第二行"), "{我,爱你}"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredItem;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class LoreOffsetTest {
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void lore() {
|
|
||||||
|
|
||||||
System.out.println(ConfiguredItem.addLoreOffset(Arrays.asList("测试lore", "第二行"), "{1,-5}"));
|
|
||||||
System.out.println(ConfiguredItem.addLoreOffset(Arrays.asList("测试lore", "第二行"), "{1,2}"));
|
|
||||||
System.out.println(ConfiguredItem.addLoreOffset(Arrays.asList("测试lore", "第二行"), "{1,0}"));
|
|
||||||
System.out.println(ConfiguredItem.addLoreOffset(Arrays.asList("测试lore", "第二行"), "{2}"));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mineconfiguration-parent</artifactId>
|
<artifactId>mineconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>2.8.3</version>
|
<version>2.8.4</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>mineconfiguration-parent</artifactId>
|
<artifactId>mineconfiguration-parent</artifactId>
|
||||||
<version>2.8.3</version>
|
<version>2.8.4</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<modules>
|
<modules>
|
||||||
<module>common</module>
|
<module>common</module>
|
||||||
|
|||||||
Reference in New Issue
Block a user