mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-03-01 15:51:03 +01:00
!Fixed and cleaned up recipe edition + more comments
This commit is contained in:
parent
f54fc0636e
commit
fc208567de
@ -486,15 +486,11 @@ public class MMOItems extends JavaPlugin {
|
||||
* External API's
|
||||
*/
|
||||
public boolean hasPermissions() {
|
||||
if (vaultSupport == null)
|
||||
return false;
|
||||
return vaultSupport.getPermissions() != null;
|
||||
return vaultSupport != null && vaultSupport.getPermissions() != null;
|
||||
}
|
||||
|
||||
public boolean hasEconomy() {
|
||||
if (vaultSupport == null)
|
||||
return false;
|
||||
return vaultSupport.getEconomy() != null;
|
||||
return vaultSupport != null && vaultSupport.getEconomy() != null;
|
||||
}
|
||||
|
||||
public VaultSupport getVault() {
|
||||
@ -529,6 +525,12 @@ public class MMOItems extends JavaPlugin {
|
||||
return templateManager.getTemplate(type, id).newBuilder(player.getRPG()).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Generates an item given an item template. The item level will
|
||||
* scale according to the player RPG level if the template has the
|
||||
* 'level-item' option. The item will pick a random tier if the
|
||||
* template has the 'tiered' option
|
||||
*/
|
||||
public ItemStack getItem(Type type, String id, PlayerData player) {
|
||||
return getMMOItem(type, id, player).newBuilder().build();
|
||||
}
|
||||
@ -543,6 +545,12 @@ public class MMOItems extends JavaPlugin {
|
||||
return templateManager.getTemplate(type, id).newBuilder(itemLevel, itemTier).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param itemLevel The desired item level
|
||||
* @param itemTier The desired item tier, can be null
|
||||
* @return Generates an item given an item template with a
|
||||
* specific item level and item tier
|
||||
*/
|
||||
public ItemStack getItem(Type type, String id, int itemLevel, @Nullable ItemTier itemTier) {
|
||||
return getMMOItem(type, id, itemLevel, itemTier).newBuilder().build();
|
||||
}
|
||||
@ -556,6 +564,11 @@ public class MMOItems extends JavaPlugin {
|
||||
return templateManager.getTemplate(type, id).newBuilder(0, null).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Generates an item given an item template. The item level will be
|
||||
* 0 and the item will have no item tier unless one is specified in
|
||||
* the base item data.
|
||||
*/
|
||||
public ItemStack getItem(Type type, String id) {
|
||||
return getMMOItem(type, id).newBuilder().build();
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
package net.Indyuce.mmoitems.gui.edition;
|
||||
package net.Indyuce.mmoitems.gui.edition.recipe;
|
||||
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.edition.StatEdition;
|
||||
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
|
||||
import net.Indyuce.mmoitems.api.recipe.workbench.ingredients.WorkbenchIngredient;
|
||||
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
import net.mmogroup.mmolib.api.util.AltChar;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
@ -1,13 +1,8 @@
|
||||
package net.Indyuce.mmoitems.gui.edition;
|
||||
package net.Indyuce.mmoitems.gui.edition.recipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.edition.StatEdition;
|
||||
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
|
||||
import net.Indyuce.mmoitems.api.recipe.CraftingType;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.util.AltChar;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -18,40 +13,43 @@ import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.edition.StatEdition;
|
||||
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
|
||||
import net.Indyuce.mmoitems.api.recipe.CraftingType;
|
||||
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
import net.mmogroup.mmolib.api.util.AltChar;
|
||||
|
||||
public class CraftingEdition extends EditionInventory {
|
||||
public CraftingEdition(Player player, MMOItemTemplate template) {
|
||||
public class RecipeListEdition extends EditionInventory {
|
||||
public RecipeListEdition(Player player, MMOItemTemplate template) {
|
||||
super(player, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
Inventory inv = Bukkit.createInventory(this, MMOLib.plugin.getVersion().isStrictlyHigher(1, 14) ? 45 : 36,
|
||||
"Crafting Recipes: " + template.getId());
|
||||
Inventory inv = Bukkit.createInventory(this, 54, "Crafting Recipes: " + template.getId());
|
||||
|
||||
for (CraftingType ctype : CraftingType.values()) {
|
||||
if (!ctype.shouldAdd())
|
||||
continue;
|
||||
ItemStack craftingEvent = ctype.getItem();
|
||||
ItemMeta craftingEventItem = craftingEvent.getItemMeta();
|
||||
craftingEventItem.addItemFlags(ItemFlag.values());
|
||||
craftingEventItem.setDisplayName(ChatColor.GREEN + ctype.getName());
|
||||
List<String> eventLore = new ArrayList<>();
|
||||
eventLore.add(ChatColor.GRAY + ctype.getLore());
|
||||
if (!getEditedSection().contains("crafting." + ctype.name().toLowerCase())) {
|
||||
for (CraftingType ctype : CraftingType.values())
|
||||
if (ctype.shouldAdd()) {
|
||||
ItemStack craftingEvent = ctype.getItem();
|
||||
ItemMeta craftingEventItem = craftingEvent.getItemMeta();
|
||||
craftingEventItem.addItemFlags(ItemFlag.values());
|
||||
craftingEventItem.setDisplayName(ChatColor.GREEN + ctype.getName());
|
||||
List<String> eventLore = new ArrayList<>();
|
||||
eventLore.add(ChatColor.GRAY + ctype.getLore());
|
||||
eventLore.add("");
|
||||
eventLore.add(ChatColor.RED + "No recipes found.");
|
||||
}
|
||||
eventLore.add("");
|
||||
eventLore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this recipe.");
|
||||
eventLore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to remove recipe.");
|
||||
craftingEventItem.setLore(eventLore);
|
||||
craftingEvent.setItemMeta(craftingEventItem);
|
||||
eventLore.add(getEditedSection().contains("crafting." + ctype.name().toLowerCase()) ? ChatColor.GREEN + "Found one or more recipe(s)."
|
||||
: ChatColor.RED + "No recipes found.");
|
||||
eventLore.add("");
|
||||
eventLore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this recipe.");
|
||||
eventLore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to remove recipe.");
|
||||
craftingEventItem.setLore(eventLore);
|
||||
craftingEvent.setItemMeta(craftingEventItem);
|
||||
|
||||
inv.setItem(ctype.getSlot(), craftingEvent);
|
||||
}
|
||||
inv.setItem(ctype.getSlot(), craftingEvent);
|
||||
}
|
||||
|
||||
addEditionInventoryItems(inv, true);
|
||||
|
||||
@ -72,11 +70,10 @@ public class CraftingEdition extends EditionInventory {
|
||||
|
||||
if (event.getAction() == InventoryAction.PICKUP_ALL) {
|
||||
if (corresponding == CraftingType.SHAPELESS || corresponding == CraftingType.SHAPED)
|
||||
new RecipeEdition(player, template, corresponding == CraftingType.SHAPELESS).open(getPreviousPage());
|
||||
else if(corresponding == CraftingType.SMITHING)
|
||||
new StatEdition(this, ItemStats.CRAFTING, "smithing").enable(
|
||||
"Write in the chat the items required to craft this.", "Format: '[ITEM] [ITEM]'",
|
||||
"[ITEM] = '[MATERIAL]' or '[MATERIAL]:[DURABILITY]' or '[TYPE].[ID]'");
|
||||
new RecipeEdition(player, template, corresponding == CraftingType.SHAPELESS).open(getPreviousPage());
|
||||
else if (corresponding == CraftingType.SMITHING)
|
||||
new StatEdition(this, ItemStats.CRAFTING, "smithing").enable("Write in the chat the items required to craft this.",
|
||||
"Format: '[ITEM] [ITEM]'", "[ITEM] = '[MATERIAL]' or '[MATERIAL]:[DURABILITY]' or '[TYPE].[ID]'");
|
||||
else
|
||||
new StatEdition(this, ItemStats.CRAFTING, "item", corresponding.name().toLowerCase()).enable(
|
||||
"Write in the chat the item, tickspeed and exp you want.", "Format: '[ITEM] [TICKS] [EXP]'",
|
@ -12,10 +12,10 @@ import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
|
||||
import net.Indyuce.mmoitems.gui.ItemBrowser;
|
||||
import net.Indyuce.mmoitems.gui.PluginInventory;
|
||||
import net.Indyuce.mmoitems.gui.edition.CraftingEdition;
|
||||
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
import net.Indyuce.mmoitems.gui.edition.ItemEdition;
|
||||
import net.Indyuce.mmoitems.gui.edition.RecipeEdition;
|
||||
import net.Indyuce.mmoitems.gui.edition.recipe.RecipeListEdition;
|
||||
import net.Indyuce.mmoitems.gui.edition.recipe.RecipeEdition;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
import net.mmogroup.mmolib.api.util.AltChar;
|
||||
|
||||
@ -65,7 +65,7 @@ public class GuiListener implements Listener {
|
||||
if (inventory instanceof ItemEdition)
|
||||
new ItemBrowser(player, template.getType()).open();
|
||||
else if (inventory instanceof RecipeEdition)
|
||||
new CraftingEdition(player, template).open(((EditionInventory) inventory).getPreviousPage());
|
||||
new RecipeListEdition(player, template).open(((EditionInventory) inventory).getPreviousPage());
|
||||
else
|
||||
new ItemEdition(player, template).onPage(((EditionInventory) inventory).getPreviousPage()).open();
|
||||
}
|
||||
|
@ -16,12 +16,10 @@ import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
*/
|
||||
public class ItemManager {
|
||||
/**
|
||||
* @param type
|
||||
* The item type
|
||||
* @param id
|
||||
* The item id
|
||||
* @return The corresponding MMOItem
|
||||
* @deprecated Use MMOItems.plugin.getMMOItem(Type, String) instead
|
||||
* @param type The item type
|
||||
* @param id The item id
|
||||
* @return The corresponding MMOItem
|
||||
* @deprecated Use MMOItems.plugin.getMMOItem(Type, String) instead
|
||||
*/
|
||||
@Deprecated
|
||||
public MMOItem getMMOItem(Type type, String id) {
|
||||
@ -29,12 +27,10 @@ public class ItemManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* The item type
|
||||
* @param id
|
||||
* The item id
|
||||
* @return Generates an ItemStack using an MMOItem
|
||||
* @deprecated Use MMOItems.plugin.getItem(Type, String) instead
|
||||
* @param type The item type
|
||||
* @param id The item id
|
||||
* @return Generates an ItemStack using an MMOItem
|
||||
* @deprecated Use MMOItems.plugin.getItem(Type, String) instead
|
||||
*/
|
||||
@Deprecated
|
||||
public ItemStack getItem(Type type, String id) {
|
||||
|
@ -1,34 +1,25 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||
import net.Indyuce.mmoitems.gui.edition.CraftingEdition;
|
||||
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
import net.Indyuce.mmoitems.gui.edition.recipe.RecipeListEdition;
|
||||
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.mmogroup.mmolib.api.util.AltChar;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TODO Needs some cleanup
|
||||
*
|
||||
* @author cympe
|
||||
*/
|
||||
public class Crafting extends ItemStat {
|
||||
// @Deprecated
|
||||
// why was this deprecated??
|
||||
public Crafting() {
|
||||
super("CRAFTING", VersionMaterial.CRAFTING_TABLE.toMaterial(), "Crafting",
|
||||
new String[] { "The crafting recipes of your item.", "Changing a recipe requires &o/mi reload recipes&7." }, new String[] { "all" });
|
||||
@ -37,15 +28,14 @@ public class Crafting extends ItemStat {
|
||||
@Override
|
||||
public void whenClicked(EditionInventory inv, InventoryClickEvent event) {
|
||||
if (event.getAction() == InventoryAction.PICKUP_ALL)
|
||||
new CraftingEdition(inv.getPlayer(), inv.getEdited()).open(inv.getPage());
|
||||
else if (event.getAction() == InventoryAction.PICKUP_HALF) {
|
||||
if (inv.getEditedSection().contains("crafting")) {
|
||||
inv.getEditedSection().set("crafting", null);
|
||||
inv.registerTemplateEdition();
|
||||
inv.getPlayer()
|
||||
.sendMessage(MMOItems.plugin.getPrefix() + "Crafting recipes successfully removed. Make sure you reload active recipes using "
|
||||
+ ChatColor.RED + "/mi reload recipes" + ChatColor.GRAY + ".");
|
||||
}
|
||||
new RecipeListEdition(inv.getPlayer(), inv.getEdited()).open(inv.getPage());
|
||||
|
||||
else if (event.getAction() == InventoryAction.PICKUP_HALF && inv.getEditedSection().contains("crafting")) {
|
||||
inv.getEditedSection().set("crafting", null);
|
||||
inv.registerTemplateEdition();
|
||||
inv.getPlayer()
|
||||
.sendMessage(MMOItems.plugin.getPrefix() + "Crafting recipes successfully removed. Make sure you reload active recipes using "
|
||||
+ ChatColor.RED + "/mi reload recipes" + ChatColor.GRAY + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,63 +50,84 @@ public class Crafting extends ItemStat {
|
||||
String type = (String) info[0];
|
||||
|
||||
switch (type) {
|
||||
case "recipe":
|
||||
int slot = (int) info[2];
|
||||
|
||||
if (validate(inv.getPlayer(), message)) {
|
||||
if ((info[1]).equals("shaped")) {
|
||||
List<String> newList = inv.getEditedSection().getStringList("crafting.shaped.1");
|
||||
String[] newArray = newList.get(slot / 3).split(" ");
|
||||
newArray[slot % 3] = message;
|
||||
newList.set(slot / 3, (newArray[0] + " " + newArray[1] + " " + newArray[2]));
|
||||
/*
|
||||
* Handles shaped and shapeless crafting recipes
|
||||
*/
|
||||
case "recipe":
|
||||
int slot = (int) info[2];
|
||||
Validate.notNull(MMOItems.plugin.getRecipes().getWorkbenchIngredient(message), "Invalid ingredient");
|
||||
|
||||
for (String s : newList) {
|
||||
if (s.equals("AIR AIR AIR"))
|
||||
continue;
|
||||
inv.getEditedSection().set("crafting.shaped.1", newList);
|
||||
inv.registerTemplateEdition();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
List<String> newList = inv.getEditedSection().getStringList("crafting.shapeless.1");
|
||||
newList.set(slot, message);
|
||||
/*
|
||||
* Handles shaped crafting recipes
|
||||
*/
|
||||
if ((info[1]).equals("shaped")) {
|
||||
List<String> newList = inv.getEditedSection().getStringList("crafting.shaped.1");
|
||||
String[] newArray = newList.get(slot / 3).split(" ");
|
||||
newArray[slot % 3] = message;
|
||||
newList.set(slot / 3, (newArray[0] + " " + newArray[1] + " " + newArray[2]));
|
||||
|
||||
for (String s : newList) {
|
||||
if (s.equals("AIR"))
|
||||
continue;
|
||||
inv.getEditedSection().set("crafting.shapeless.1", newList);
|
||||
inv.registerTemplateEdition();
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (String s : newList) {
|
||||
if (s.equals("AIR AIR AIR"))
|
||||
continue;
|
||||
|
||||
inv.getEditedSection().set("crafting.shaped.1", newList);
|
||||
inv.registerTemplateEdition();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "item": {
|
||||
String[] args = message.split(" ");
|
||||
Validate.isTrue(args.length == 3, "Invalid format");
|
||||
Validate.isTrue(validate(inv.getPlayer(), args[0]));
|
||||
int time = Integer.parseInt(args[1]);
|
||||
double exp = MMOUtils.parseDouble(args[2]);
|
||||
|
||||
inv.getEditedSection().set("crafting." + info[1] + ".1.item", args[0]);
|
||||
inv.getEditedSection().set("crafting." + info[1] + ".1.time", time);
|
||||
inv.getEditedSection().set("crafting." + info[1] + ".1.experience", exp);
|
||||
inv.registerTemplateEdition();
|
||||
break;
|
||||
}
|
||||
case "smithing": {
|
||||
String[] args = message.split(" ");
|
||||
Validate.isTrue(args.length == 2, "Invalid format");
|
||||
Validate.isTrue(validate(inv.getPlayer(), args[0]) && validate(inv.getPlayer(), args[1]));
|
||||
/*
|
||||
* Handles shapeless crafting recipes
|
||||
*/
|
||||
} else {
|
||||
List<String> newList = inv.getEditedSection().getStringList("crafting.shapeless.1");
|
||||
newList.set(slot, message);
|
||||
|
||||
inv.getEditedSection().set("crafting.smithing.1.input1", args[0]);
|
||||
inv.getEditedSection().set("crafting.smithing.1.input2", args[1]);
|
||||
inv.registerTemplateEdition();
|
||||
break;
|
||||
for (String s : newList) {
|
||||
if (s.equals("AIR"))
|
||||
continue;
|
||||
inv.getEditedSection().set("crafting.shapeless.1", newList);
|
||||
inv.registerTemplateEdition();
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
MMOItems.plugin.getLogger().warning("Something went wrong!");
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
/*
|
||||
* Handles burning recipes ie furnace, campfire, smoker and blast
|
||||
* furnace recipes
|
||||
*/
|
||||
case "item": {
|
||||
String[] args = message.split(" ");
|
||||
Validate.isTrue(args.length == 3, "Invalid format");
|
||||
Validate.notNull(MMOItems.plugin.getRecipes().getWorkbenchIngredient(args[0]), "Invalid ingredient");
|
||||
int time = Integer.parseInt(args[1]);
|
||||
double exp = MMOUtils.parseDouble(args[2]);
|
||||
|
||||
inv.getEditedSection().set("crafting." + info[1] + ".1.item", args[0]);
|
||||
inv.getEditedSection().set("crafting." + info[1] + ".1.time", time);
|
||||
inv.getEditedSection().set("crafting." + info[1] + ".1.experience", exp);
|
||||
inv.registerTemplateEdition();
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles smithing recipes
|
||||
*/
|
||||
case "smithing": {
|
||||
String[] args = message.split(" ");
|
||||
Validate.isTrue(args.length == 2, "Invalid format");
|
||||
Validate.notNull(MMOItems.plugin.getRecipes().getWorkbenchIngredient(args[0]), "Invalid first ingredient");
|
||||
Validate.notNull(MMOItems.plugin.getRecipes().getWorkbenchIngredient(args[1]), "Invalid second ingredient");
|
||||
|
||||
inv.getEditedSection().set("crafting.smithing.1.input1", args[0]);
|
||||
inv.getEditedSection().set("crafting.smithing.1.input2", args[1]);
|
||||
inv.registerTemplateEdition();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new IllegalArgumentException("Recipe type not recognized");
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,53 +143,4 @@ public class Crafting extends ItemStat {
|
||||
@Override
|
||||
public void whenLoaded(ReadMMOItem mmoitem) {
|
||||
}
|
||||
|
||||
private boolean validate(Player player, String input) {
|
||||
if (input.contains(":")) {
|
||||
String[] count = input.split(":");
|
||||
|
||||
if (count.length != 2) {
|
||||
player.sendMessage(MMOItems.plugin.getPrefix() + "Invalid format.");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
Integer.parseInt(count[1]);
|
||||
} catch (NumberFormatException exception) {
|
||||
player.sendMessage(MMOItems.plugin.getPrefix() + "'" + count[1] + "' isn't a valid number.");
|
||||
return false;
|
||||
}
|
||||
|
||||
input = count[0];
|
||||
}
|
||||
if (input.contains(".")) {
|
||||
String[] typeid = input.split("\\.");
|
||||
if (typeid.length != 2) {
|
||||
player.sendMessage(MMOItems.plugin.getPrefix() + "Invalid format.");
|
||||
return false;
|
||||
}
|
||||
if (!Type.isValid(typeid[0].toUpperCase().replace("-", "_").replace(" ", "_"))) {
|
||||
player.sendMessage(MMOItems.plugin.getPrefix() + "'" + typeid[0].toUpperCase().replace("-", "_").replace(" ", "_")
|
||||
+ "' isn't a valid item type.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Type type = Type.get(typeid[0].toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||
if (MMOItems.plugin.getItem(type, typeid[1]) == null) {
|
||||
player.sendMessage(MMOItems.plugin.getPrefix() + "Could not find item with ID '"
|
||||
+ typeid[1].toUpperCase().replace("-", "_").replace(" ", "_") + "'.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
Material.valueOf(input.toUpperCase().replace("-", "_"));
|
||||
} catch (Exception e) {
|
||||
player.sendMessage(MMOItems.plugin.getPrefix() + "'" + input.toUpperCase().replace("-", "_") + "' isn't a valid material.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user