Compare commits
No commits in common. "master" and "v1.0" have entirely different histories.
5 changed files with 49 additions and 86 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -1,4 +1,2 @@
|
||||||
.idea
|
# Project exclude paths
|
||||||
*.iml
|
/target/
|
||||||
target/
|
|
||||||
.flattened-pom.xml
|
|
12
menuapi.iml
12
menuapi.iml
|
@ -1,12 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module version="4">
|
|
||||||
<component name="FacetManager">
|
|
||||||
<facet type="minecraft" name="Minecraft">
|
|
||||||
<configuration>
|
|
||||||
<autoDetectTypes>
|
|
||||||
<platformType>SPIGOT</platformType>
|
|
||||||
</autoDetectTypes>
|
|
||||||
</configuration>
|
|
||||||
</facet>
|
|
||||||
</component>
|
|
||||||
</module>
|
|
15
pom.xml
15
pom.xml
|
@ -5,26 +5,19 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<groupId>nl.iobyte</groupId>
|
<groupId>nl.iobyte</groupId>
|
||||||
<artifactId>menuapi</artifactId>
|
<artifactId>menuapi</artifactId>
|
||||||
<version>1.1</version>
|
<version>1.0</version>
|
||||||
|
|
||||||
<distributionManagement>
|
|
||||||
<repository>
|
|
||||||
<id>sbdevelopment-repo</id>
|
|
||||||
<url>https://repo.sbdevelopment.tech/releases</url>
|
|
||||||
</repository>
|
|
||||||
</distributionManagement>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.20.2-R0.1-SNAPSHOT</version>
|
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
|
|
||||||
}
|
|
|
@ -1,10 +1,16 @@
|
||||||
package nl.iobyte.menuapi.item;
|
package nl.iobyte.menuapi.item;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
public class ItemBuilder {
|
public class ItemBuilder {
|
||||||
|
|
||||||
|
@ -22,9 +28,8 @@ public class ItemBuilder {
|
||||||
item = new ItemStack(material, amount);
|
item = new ItemStack(material, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemBuilder(Material material, int amount, int data) {
|
public ItemBuilder(Material material, int amount, short data) {
|
||||||
this(material, amount);
|
item = new ItemStack(material, amount, data);
|
||||||
setCustomModelData(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
|
@ -39,19 +44,10 @@ public class ItemBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemBuilder setCustomModelData(int i) {
|
|
||||||
Optional.ofNullable(item.getItemMeta()).ifPresent(meta -> {
|
|
||||||
meta.setCustomModelData(i);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
});
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemBuilder setUnbreakable(boolean b) {
|
public ItemBuilder setUnbreakable(boolean b) {
|
||||||
Optional.ofNullable(item.getItemMeta()).ifPresent(meta -> {
|
ItemMeta meta = item.getItemMeta();
|
||||||
meta.setUnbreakable(b);
|
meta.setUnbreakable(b);
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
});
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,10 +55,9 @@ public class ItemBuilder {
|
||||||
if(name == null)
|
if(name == null)
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
Optional.ofNullable(item.getItemMeta()).ifPresent(meta -> {
|
ItemMeta meta = item.getItemMeta();
|
||||||
meta.setDisplayName(Color.parse(name));
|
meta.setDisplayName(Color.parse(name));
|
||||||
this.item.setItemMeta(meta);
|
this.item.setItemMeta(meta);
|
||||||
});
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,13 +65,12 @@ public class ItemBuilder {
|
||||||
if(lore == null)
|
if(lore == null)
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
Optional.ofNullable(item.getItemMeta()).ifPresent(meta -> {
|
ItemMeta meta = item.getItemMeta();
|
||||||
for (String string : lore)
|
for(String string : lore)
|
||||||
lore.set(lore.indexOf(string), Color.parse(string));
|
lore.set(lore.indexOf(string), Color.parse(string));
|
||||||
|
|
||||||
meta.setLore(lore);
|
meta.setLore(lore);
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
});
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,59 +82,52 @@ public class ItemBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemBuilder addLore(String lore) {
|
public ItemBuilder addLore(String lore) {
|
||||||
Optional.ofNullable(item.getItemMeta()).ifPresent(meta -> {
|
List<String> list = item.getItemMeta().getLore();
|
||||||
List<String> list = meta.hasLore() ? meta.getLore() : new ArrayList<>();
|
|
||||||
list.add(lore);
|
list.add(lore);
|
||||||
setLore(list);
|
setLore(list);
|
||||||
});
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemBuilder setEnchantment(HashMap<Enchantment, Integer> enchantments) {
|
public ItemBuilder setEnchantment(HashMap<Enchantment, Integer> enchantments) {
|
||||||
Optional.ofNullable(item.getItemMeta()).ifPresent(meta -> {
|
ItemMeta meta = item.getItemMeta();
|
||||||
if (!meta.getEnchants().isEmpty())
|
if(!meta.getEnchants().isEmpty())
|
||||||
meta.getEnchants().clear();
|
meta.getEnchants().clear();
|
||||||
|
|
||||||
for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet())
|
for(Map.Entry<Enchantment, Integer> entry : enchantments.entrySet())
|
||||||
meta.addEnchant(entry.getKey(), entry.getValue(), true);
|
meta.addEnchant(entry.getKey(), entry.getValue(), true);
|
||||||
|
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
});
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemBuilder setEnchantment(Enchantment enchantment, int i) {
|
public ItemBuilder setEnchantment(Enchantment enchantment, int i) {
|
||||||
Optional.ofNullable(item.getItemMeta()).ifPresent(meta -> {
|
ItemMeta meta = item.getItemMeta();
|
||||||
if (!meta.getEnchants().isEmpty())
|
if (!meta.getEnchants().isEmpty())
|
||||||
meta.getEnchants().clear();
|
meta.getEnchants().clear();
|
||||||
|
|
||||||
meta.addEnchant(enchantment, i, true);
|
meta.addEnchant(enchantment, i, true);
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
});
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemBuilder addEnchantment(Enchantment enchantment, int i) {
|
public ItemBuilder addEnchantment(Enchantment enchantment, int i) {
|
||||||
Optional.ofNullable(item.getItemMeta()).ifPresent(meta -> {
|
ItemMeta meta = item.getItemMeta();
|
||||||
meta.addEnchant(enchantment, i, true);
|
meta.addEnchant(enchantment, i, true);
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
});
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemBuilder addFlag(ItemFlag flag) {
|
public ItemBuilder addFlag(ItemFlag flag) {
|
||||||
Optional.ofNullable(item.getItemMeta()).ifPresent(meta -> {
|
ItemMeta meta = item.getItemMeta();
|
||||||
meta.addItemFlags(flag);
|
meta.addItemFlags(flag);
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
});
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemBuilder addFlags(ItemFlag... flags) {
|
public ItemBuilder addFlags(ItemFlag... flags) {
|
||||||
Optional.ofNullable(item.getItemMeta()).ifPresent(meta -> {
|
ItemMeta meta = item.getItemMeta();
|
||||||
meta.addItemFlags(flags);
|
meta.addItemFlags(flags);
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
});
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue