mirror of
https://github.com/CarmJos/EasyPlugin.git
synced 2024-09-19 19:25:45 +00:00
chore(gui): 修改 GUIItemConfiguration 的读取与初始化方式
This commit is contained in:
parent
77c035c2cb
commit
b5382a1cb3
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.4.9</version>
|
<version>1.4.10</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.4.9</version>
|
<version>1.4.10</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -16,6 +16,7 @@ import java.util.stream.Collectors;
|
|||||||
public class GUIItemConfiguration {
|
public class GUIItemConfiguration {
|
||||||
|
|
||||||
@NotNull Material type;
|
@NotNull Material type;
|
||||||
|
int amount;
|
||||||
int data;
|
int data;
|
||||||
@Nullable String name;
|
@Nullable String name;
|
||||||
@NotNull List<String> lore;
|
@NotNull List<String> lore;
|
||||||
@ -23,11 +24,12 @@ public class GUIItemConfiguration {
|
|||||||
@NotNull List<Integer> slots;
|
@NotNull List<Integer> slots;
|
||||||
@NotNull List<GUIActionConfiguration> actions;
|
@NotNull List<GUIActionConfiguration> actions;
|
||||||
|
|
||||||
public GUIItemConfiguration(@NotNull Material type, int data,
|
public GUIItemConfiguration(@NotNull Material type, int amount, int data,
|
||||||
@Nullable String name, @NotNull List<String> lore,
|
@Nullable String name, @NotNull List<String> lore,
|
||||||
@NotNull List<GUIActionConfiguration> actions,
|
@NotNull List<GUIActionConfiguration> actions,
|
||||||
@NotNull List<Integer> slots) {
|
@NotNull List<Integer> slots) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
this.amount = amount;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.lore = lore;
|
this.lore = lore;
|
||||||
@ -36,8 +38,7 @@ public class GUIItemConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setupItems(Player player, GUI gui) {
|
public void setupItems(Player player, GUI gui) {
|
||||||
ItemStackFactory icon = new ItemStackFactory(this.type);
|
ItemStackFactory icon = new ItemStackFactory(this.type, this.amount, this.data);
|
||||||
icon.setDurability(this.data);
|
|
||||||
if (this.name != null) icon.setDisplayName(this.name);
|
if (this.name != null) icon.setDisplayName(this.name);
|
||||||
icon.setLore(MessageUtils.setPlaceholders(player, this.lore));
|
icon.setLore(MessageUtils.setPlaceholders(player, this.lore));
|
||||||
|
|
||||||
@ -51,6 +52,7 @@ public class GUIItemConfiguration {
|
|||||||
|
|
||||||
map.put("type", this.type.name());
|
map.put("type", this.type.name());
|
||||||
if (this.name != null) map.put("name", this.name);
|
if (this.name != null) map.put("name", this.name);
|
||||||
|
if (this.amount != 1) map.put("amount", this.amount);
|
||||||
if (this.data != 0) map.put("data", this.data);
|
if (this.data != 0) map.put("data", this.data);
|
||||||
if (!this.lore.isEmpty()) map.put("lore", this.lore);
|
if (!this.lore.isEmpty()) map.put("lore", this.lore);
|
||||||
if (this.slots.size() > 1) {
|
if (this.slots.size() > 1) {
|
||||||
@ -70,6 +72,7 @@ public class GUIItemConfiguration {
|
|||||||
String material = Optional.ofNullable(itemSection.getString("type")).orElse("STONE");
|
String material = Optional.ofNullable(itemSection.getString("type")).orElse("STONE");
|
||||||
Material type = Optional.ofNullable(Material.matchMaterial(material)).orElse(Material.STONE);
|
Material type = Optional.ofNullable(Material.matchMaterial(material)).orElse(Material.STONE);
|
||||||
int data = itemSection.getInt("data", 0);
|
int data = itemSection.getInt("data", 0);
|
||||||
|
int amount = itemSection.getInt("amount", 1);
|
||||||
String name = itemSection.getString("name");
|
String name = itemSection.getString("name");
|
||||||
List<String> lore = itemSection.getStringList("lore");
|
List<String> lore = itemSection.getStringList("lore");
|
||||||
|
|
||||||
@ -85,10 +88,9 @@ public class GUIItemConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new GUIItemConfiguration(
|
return new GUIItemConfiguration(
|
||||||
type, data, name, lore, actions,
|
type, amount, data, name, lore, actions,
|
||||||
slots.size() > 0 ? slots : Collections.singletonList(slot)
|
slots.size() > 0 ? slots : Collections.singletonList(slot)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.4.9</version>
|
<version>1.4.10</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.4.9</version>
|
<version>1.4.10</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.4.9</version>
|
<version>1.4.10</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.4.9</version>
|
<version>1.4.10</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.4.9</version>
|
<version>1.4.10</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.4.9</version>
|
<version>1.4.10</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.4.9</version>
|
<version>1.4.10</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.4.9</version>
|
<version>1.4.10</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<!--suppress VulnerableLibrariesLocal -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.MilkBowl</groupId>
|
<groupId>com.github.MilkBowl</groupId>
|
||||||
<artifactId>VaultAPI</artifactId>
|
<artifactId>VaultAPI</artifactId>
|
||||||
|
2
pom.xml
2
pom.xml
@ -15,7 +15,7 @@
|
|||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>1.4.9</version>
|
<version>1.4.10</version>
|
||||||
<modules>
|
<modules>
|
||||||
|
|
||||||
<module>base/main</module>
|
<module>base/main</module>
|
||||||
|
Loading…
Reference in New Issue
Block a user