This commit is contained in:
Super_
2020-01-08 18:00:15 -05:00
parent 24d121643e
commit 5bb489e8ba
4 changed files with 266 additions and 77 deletions

View File

@ -91,6 +91,11 @@ public class ShopData implements ConfigLoadable, ConfigSavable, Validatable
return signature;
}
public void giveRawItem(String signature)
{
items.add(signature);
}
public boolean hasItem(ShopItem item)
{
for (String i : items)
@ -125,6 +130,86 @@ public class ShopData implements ConfigLoadable, ConfigSavable, Validatable
return stack;
}
public boolean validate(ItemStack stack, String nameSegment)
{
if (!stack.hasItemMeta())
{
return false;
}
if (!stack.getItemMeta().hasDisplayName())
{
return false;
}
if (!stack.getItemMeta().getDisplayName().contains(nameSegment))
{
return false;
}
if (!stack.getItemMeta().hasLore())
{
return false;
}
boolean loreValid = false;
for (String i : items)
{
if (stack.getItemMeta().getLore().contains(ChatColor.DARK_GRAY + i))
{
loreValid = true;
}
}
if (!loreValid)
{
return false;
}
return true;
}
public boolean validate(ItemStack stack, ShopItem item)
{
if (!stack.hasItemMeta())
{
return false;
}
if (!stack.getItemMeta().hasDisplayName())
{
return false;
}
if (!stack.getItemMeta().getDisplayName().contains(item.getName()))
{
return false;
}
if (!stack.getItemMeta().hasLore())
{
return false;
}
boolean loreValid = false;
for (String i : items)
{
if (stack.getItemMeta().getLore().contains(ChatColor.DARK_GRAY + i))
{
loreValid = true;
}
}
if (!loreValid)
{
return false;
}
return true;
}
@Override
public boolean isValid()
{

View File

@ -6,7 +6,8 @@ import org.bukkit.Material;
public enum ShopItem
{
GRAPPLING_HOOK("Grappling Hook", Material.FISHING_ROD, 100, ChatColor.GREEN);
GRAPPLING_HOOK("Grappling Hook", Material.FISHING_ROD, 100, ChatColor.GREEN),
THOR_STAR("Thor's Star", Material.NETHER_STAR, 10000, ChatColor.LIGHT_PURPLE);
@Getter
private final String name;