Initial creation of VaultAPI

This commit is contained in:
Nick Minkler 2014-05-08 19:07:01 -07:00
commit b288eeb470
12 changed files with 3812 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target
/dependency-reduced-pom.xml

224
README.md Normal file
View File

@ -0,0 +1,224 @@
# Vault - Abstraction Library for Bukkit Plugin
## Installing
Installing Vault is as simple as copying the provided "Vault.jar" to your
"<bukkit-install-dir>/plugins" directory and the rest is automatic! If you
wish to perform configuration changes, this can be done via a configuration
file but should not be necessary in most cases. See the "Advanced
Configuration" section for more information.
## Why Vault?
I have no preference which library suits your plugin and development efforts
best. Really, I thought a central suite (rather...Vault) of solutions was the
the proper avenue than focusing on a single category of plugin. That's where
the idea for Vault came into play.
So, what features do I _think_ you'll like the most?
* No need to include my source code in your plugin
All of Vault is run in its own plugin, so all you need to do is obtain an
instance of it! This simplifies issues with multiple plugins using the same
namespaces. Just simply add Vault.jar to your download zip file!
* Broad range of supported plugins
I wanted an abstraction layer not only for Economic plugins but also
Permission plugins as well. The future will likely add more, but what
types, I have yet to decide, let me know!
* Choice!
That's half the fun of Bukkit, we get to choose what to use! More choice
has never hurt developers so here's to choice!
## Permissions
* vault.admin
- Determines if a player should recieve the update notices
## License
Copyright (C) 2011 Morgan Humes <morgan@lanaddict.com>
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
## Building
Vault comes with all libraries needed to build from the current branch and
also comes with an Apache Ant build file (build.xml).
## Dependencies
Because Vault provides a bridge to other plugins, their binaries will be
required to build from. To ease this, they have been included in the lib
folder and will be updated from time to time. For plugin developers, it
is not necessary to use these libraries when implementing Vault. You will
only need to compile against Vault.
## Supported Plugins
Vault provides abstraction for the following categories and plugins. If you
have your own plugin that you believe should be supported, fork Vault or create
a patch with the necessary changes. Additionally you can create an issue on
Github and we'll get to it at our convenience.
* Economy
- 3co (http://forums.bukkit.org/threads/22461/)
- AEco
- BOSEconomy 6 (http://forums.bukkit.org/threads/19025/)
- BOSEconomy 7
- CommandsEX Economy (http://dev.bukkit.org/server-mods/commandsex/)
- CraftConomy2 (http://dev.bukkit.org/server-mods/craftconomy/)
- CraftConomy3 (http://dev.bukkit.org/server-mods/craftconomy/)
- CurrencyCore (http://dev.bukkit.org/server-mods/currency/)
- Dosh
- EconXP (http://dev.bukkit.org/server-mods/econxp/)
- Essentials Economy (http://forums.bukkit.org/threads/15312/)
- eWallet (http://dev.bukkit.org/server-mods/ewallet/)
- GoldIsMoney
- GoldIsMoney2
- Gringotts
- iConomy 4 (http://forums.bukkit.org/threads/40/)
- iConomy 5 (http://forums.bukkit.org/threads/40/)
- iConomy 6 (http://forums.bukkit.org/threads/40/)
- McMoney
- Miconomy
- MineConomy (http://dev.bukkit.org/server-mods/mineconomy/)
- MineFaconomy2
- MultiCurrency
- SDFEconomy
- TAEcon
- XPBank
* Permissions
- bPermissions
- bPermissions 2 (http://dev.bukkit.org/server-mods/bpermissions/)
- DroxPerms
- Group Manager (Essentials) (http://forums.bukkit.org/threads/15312/)
- Permissions 3 (http://forums.bukkit.org/threads/18430/)
- PermissionsBukkit
- Permissions Ex (http://forums.bukkit.org/threads/18140/)
- Privileges
- rscPermissions
- SimplyPerms
- SuperPerms (Bukkit's default)
- TotalPermissions (http://dev.bukkit.org/bukkit-mods/totalpermissions)
- XPerms
- zPermissions
* Chat
- bPermissions
- Group Manager (Essentials)
- iChat
- mChat
- mChatSuite
- Permissions3
- PEX
- rscPermissions
- TotalPermissions
- zPermissions
## Implementing Vault
Implementing Vault is quite simple. It requires getting the Economy, Permission, or Chat service from the Bukkit ServiceManager. See the example below:
```java
package com.example.plugin;
import java.util.logging.Logger;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
public class ExamplePlugin extends JavaPlugin {
private static final Logger log = Logger.getLogger("Minecraft");
public static Economy econ = null;
public static Permission perms = null;
public static Chat chat = null;
@Override
public void onDisable() {
log.info(String.format("[%s] Disabled Version %s", getDescription().getName(), getDescription().getVersion()));
}
@Override
public void onEnable() {
if (!setupEconomy() ) {
log.severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
getServer().getPluginManager().disablePlugin(this);
return;
}
setupPermissions();
setupChat();
}
private boolean setupEconomy() {
if (getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
return false;
}
econ = rsp.getProvider();
return econ != null;
}
private boolean setupChat() {
RegisteredServiceProvider<Chat> rsp = getServer().getServicesManager().getRegistration(Chat.class);
chat = rsp.getProvider();
return chat != null;
}
private boolean setupPermissions() {
RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
perms = rsp.getProvider();
return perms != null;
}
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
if(!(sender instanceof Player)) {
log.info("Only players are supported for this Example Plugin, but you should not do this!!!");
return true;
}
Player player = (Player) sender;
if(command.getLabel().equals("test-economy")) {
// Lets give the player 1.05 currency (note that SOME economic plugins require rounding!)
sender.sendMessage(String.format("You have %s", econ.format(econ.getBalance(player.getName()))));
EconomyResponse r = econ.depositPlayer(player.getName(), 1.05);
if(r.transactionSuccess()) {
sender.sendMessage(String.format("You were given %s and now have %s", econ.format(r.amount), econ.format(r.balance)));
} else {
sender.sendMessage(String.format("An error occured: %s", r.errorMessage));
}
return true;
} else if(command.getLabel().equals("test-permission")) {
// Lets test if user has the node "example.plugin.awesome" to determine if they are awesome or just suck
if(perms.has(player, "example.plugin.awesome")) {
sender.sendMessage("You are awesome!");
} else {
sender.sendMessage("You suck!");
}
return true;
} else {
return false;
}
}
}
```

165
license.txt Normal file
View File

@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

94
pom.xml Normal file
View File

@ -0,0 +1,94 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.3.01</version>
<name>VaultAPI</name>
<url>http://dev.bukkit.org/server-mods/vault/</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bukkitVersion>1.7.9-R0.1-SNAPSHOT</bukkitVersion>
</properties>
<!-- Organization -->
<organization>
<name>MilkBowl</name>
<url>https://github.com/MilkBowl/Vault</url>
</organization>
<scm>
<url>https://github.com/MilkBowl/Vault</url>
<connection>scm:git:git://github.com:MilkBowl/Vault.git</connection>
<developerConnection>scm:git:git@github.com:MilkBowl/Vault.git</developerConnection>
</scm>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/MilkBowl/Vault/issues</url>
</issueManagement>
<repositories>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>${bukkitVersion}</version>
<type>jar</type>
</dependency>
<!-- Test Dependency -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<type>jar</type>
<scope>test</scope>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<defaultGoal>clean install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<show>public</show>
<windowtitle>Vault</windowtitle>
<verbose>false</verbose>
<author>true</author>
<version>true</version>
<linksource>true</linksource>
<excludePackageNames>net.milkbowl.vault.chat.plugin:net.milkbowl.vault.economy.plugin:net.milkbowl.vault.permission.plugin</excludePackageNames>
<bottom><![CDATA[<b>Milkbowl, 2014</b>]]></bottom>
</configuration>
</plugin>
</plugins>
</build>
<description>Vault is a Permissions &amp; Economy API to allow plugins to more easily hook into these systems without needing to hook each individual system themselves.
Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms, bPerms2, SimplyPerms, DroxPerms, zPermissions, rscPermissions, KPerms, Starburst, iConomy (4/5/6) BOSEconomy *6/7), EssentialsEcon, 3Co, MultiConomy, MineConomy, EconXP, eWallet, CurrencyCore, XPBank, CraftConomy, AEco, SDFEconomy, TAEcon</description>
</project>

View File

@ -0,0 +1,742 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.chat;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.World;
import org.bukkit.entity.Player;
/**
* The main Chat API - allows for Prefix/Suffix nodes along with generic Info nodes if the linked Chat system supports them
*
*/
public abstract class Chat {
private Permission perms;
public Chat(Permission perms) {
this.perms = perms;
}
/**
* Gets name of permission method
* @return Name of Permission Method
*/
abstract public String getName();
/**
* Checks if permission method is enabled.
* @return Success or Failure
*/
abstract public boolean isEnabled();
/**
* Get players prefix
* @param world World name
* @param player Player name
* @return Prefix
*/
abstract public String getPlayerPrefix(String world, String player);
/**
* Get players prefix
* @param world World Object
* @param player Player name
* @return Prefix
*/
public String getPlayerPrefix(World world, String player) {
return getPlayerPrefix(world.getName(), player);
}
/**
* Get players prefix
* @param player Player Object
* @return Prefix
*/
public String getPlayerPrefix(Player player) {
return getPlayerPrefix(player.getWorld().getName(), player.getName());
}
/**
* Set players prefix
* @param world World name
* @param player Player name
* @param prefix Prefix
*/
abstract public void setPlayerPrefix(String world, String player, String prefix);
/**
* Set players prefix
* @param world World Object
* @param player Player name
* @param prefix Prefix
*/
public void setPlayerPrefix(World world, String player, String prefix) {
setPlayerPrefix(world.getName(), player, prefix);
}
/**
* Set players prefix
* @param player Player Object
* @param prefix Prefix
*/
public void setPlayerPrefix(Player player, String prefix) {
setPlayerPrefix(player.getWorld().getName(), player.getName(), prefix);
}
/**
* Get players suffix
* @param world World name
* @param player Player name
* @return Suffix
*/
abstract public String getPlayerSuffix(String world, String player);
/**
* Get players suffix
* @param world World Object
* @param player Player name
* @return Suffix
*/
public String getPlayerSuffix(World world, String player) {
return getPlayerSuffix(world.getName(), player);
}
/**
* Get players suffix
* @param player Player Object
* @return Suffix
*/
public String getPlayerSuffix(Player player) {
return getPlayerSuffix(player.getWorld().getName(), player.getName());
}
/**
* Set players suffix
* @param world World name
* @param player Player name
* @param suffix Suffix
*/
abstract public void setPlayerSuffix(String world, String player, String suffix);
/**
* Set players suffix
* @param world World Object
* @param player Player name
* @param suffix Suffix
*/
public void setPlayerSuffix(World world, String player, String suffix) {
setPlayerSuffix(world.getName(), player, suffix);
}
/**
* Set players suffix
* @param player Player Object
* @param suffix Suffix
*/
public void setPlayerSuffix(Player player, String suffix) {
setPlayerSuffix(player.getWorld().getName(), player.getName(), suffix);
}
/**
* Get group prefix
* @param world World name
* @param group Group name
* @return Prefix
*/
abstract public String getGroupPrefix(String world, String group);
/**
* Get group prefix
* @param world World Object
* @param group Group name
* @return Prefix
*/
public String getGroupPrefix(World world, String group) {
return getGroupPrefix(world.getName(), group);
}
/**
* Set group prefix
* @param world World name
* @param group Group name
* @param prefix Prefix
*/
abstract public void setGroupPrefix(String world, String group, String prefix);
/**
* Set group prefix
* @param world World Object
* @param group Group name
* @param prefix Prefix
*/
public void setGroupPrefix(World world, String group, String prefix) {
setGroupPrefix(world.getName(), group, prefix);
}
/**
* Get group suffix
* @param world World name
* @param group Group name
* @return Suffix
*/
abstract public String getGroupSuffix(String world, String group);
/**
* Get group suffix
* @param world World Object
* @param group Group name
* @return Suffix
*/
public String getGroupSuffix(World world, String group) {
return getGroupSuffix(world.getName(), group);
}
/**
* Set group suffix
* @param world World name
* @param group Group name
* @param suffix Suffix
*/
abstract public void setGroupSuffix(String world, String group, String suffix);
/**
* Set group suffix
* @param world World Object
* @param group Group name
* @param suffix Suffix
*/
public void setGroupSuffix(World world, String group, String suffix) {
setGroupSuffix(world.getName(), group, suffix);
}
/**
* Get a players informational node (Integer) value
* @param world World name
* @param player Player name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
abstract public int getPlayerInfoInteger(String world, String player, String node, int defaultValue);
/**
* Get a players informational node (Integer) value
* @param world World Object
* @param player Player name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public int getPlayerInfoInteger(World world, String player, String node, int defaultValue) {
return getPlayerInfoInteger(world.getName(), player, node, defaultValue);
}
/**
* Get a players informational node (Integer) value
* @param player Player Object
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public int getPlayerInfoInteger(Player player, String node, int defaultValue) {
return getPlayerInfoInteger(player.getWorld().getName(), player.getName(), node, defaultValue);
}
/**
* Set a players informational node (Integer) value
* @param world World name
* @param player Player name
* @param node Permission node
* @param value Value to set
*/
abstract public void setPlayerInfoInteger(String world, String player, String node, int value);
/**
* Set a players informational node (Integer) value
* @param world World Object
* @param player Player name
* @param node Permission node
* @param value Value to set
*/
public void setPlayerInfoInteger(World world, String player, String node, int value) {
setPlayerInfoInteger(world.getName(), player, node, value);
}
/**
* Set a players informational node (Integer) value
* @param player Player Object
* @param node Permission node
* @param value Value to set
*/
public void setPlayerInfoInteger(Player player, String node, int value) {
setPlayerInfoInteger(player.getWorld().getName(), player.getName(), node, value);
}
/**
* Get a groups informational node (Integer) value
* @param world World name
* @param group Group name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
abstract public int getGroupInfoInteger(String world, String group, String node, int defaultValue);
/**
* Get a groups informational node (Integer) value
* @param world World Object
* @param group Group name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public int getGroupInfoInteger(World world, String group, String node, int defaultValue) {
return getGroupInfoInteger(world.getName(), group, node, defaultValue);
}
/**
* Set a groups informational node (Integer) value
* @param world World name
* @param group Group name
* @param node Permission node
* @param value Value to set
*/
abstract public void setGroupInfoInteger(String world, String group, String node, int value);
/**
* Set a groups informational node (Integer) value
* @param world World Object
* @param group Group name
* @param node Permission node
* @param value Value to set
*/
public void setGroupInfoInteger(World world, String group, String node, int value) {
setGroupInfoInteger(world.getName(), group, node, value);
}
/**
* Get a players informational node (Double) value
* @param world World name
* @param player Group name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
abstract public double getPlayerInfoDouble(String world, String player, String node, double defaultValue);
/**
* Get a players informational node (Double) value
* @param world World Object
* @param player Player name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public double getPlayerInfoDouble(World world, String player, String node, double defaultValue) {
return getPlayerInfoDouble(world.getName(), player, node, defaultValue);
}
/**
* Get a players informational node (Double) value
* @param player Player Object
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public double getPlayerInfoDouble(Player player, String node, double defaultValue) {
return getPlayerInfoDouble(player.getWorld().getName(), player.getName(), node, defaultValue);
}
/**
* Set a players informational node (Double) value
* @param world World name
* @param player Group name
* @param node Permission node
* @param value Value to set
*/
abstract public void setPlayerInfoDouble(String world, String player, String node, double value);
/**
* Set a players informational node (Double) value
* @param world World Object
* @param player Player name
* @param node Permission node
* @param value Value to set
*/
public void setPlayerInfoDouble(World world, String player, String node, double value) {
setPlayerInfoDouble(world.getName(), player, node, value);
}
/**
* Set a players informational node (Double) value
* @param player Player Object
* @param node Permission node
* @param value Value to set
*/
public void setPlayerInfoDouble(Player player, String node, double value) {
setPlayerInfoDouble(player.getWorld().getName(), player.getName(), node, value);
}
/**
* Get a groups informational node (Double) value
* @param world World name
* @param group Group name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
abstract public double getGroupInfoDouble(String world, String group, String node, double defaultValue);
/**
* Get a groups informational node (Double) value
* @param world World Object
* @param group Group name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public double getGroupInfoDouble(World world, String group, String node, double defaultValue) {
return getGroupInfoDouble(world.getName(), group, node, defaultValue);
}
/**
* Set a groups informational node (Double) value
* @param world World name
* @param group Group name
* @param node Permission node
* @param value Value to set
*/
abstract public void setGroupInfoDouble(String world, String group, String node, double value);
/**
* Set a groups informational node (Double) value
* @param world World Object
* @param group Group name
* @param node Permission node
* @param value Value to set
*/
public void setGroupInfoDouble(World world, String group, String node, double value) {
setGroupInfoDouble(world.getName(), group, node, value);
}
/**
* Get a players informational node (Boolean) value
* @param world World name
* @param player Player name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
abstract public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue);
/**
* Get a players informational node (Boolean) value
* @param world World Object
* @param player Player name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public boolean getPlayerInfoBoolean(World world, String player, String node, boolean defaultValue) {
return getPlayerInfoBoolean(world.getName(), player, node, defaultValue);
}
/**
* Get a players informational node (Boolean) value
* @param player Player Object
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public boolean getPlayerInfoBoolean(Player player, String node, boolean defaultValue) {
return getPlayerInfoBoolean(player.getWorld().getName(), player.getName(), node, defaultValue);
}
/**
* Set a players informational node (Boolean) value
* @param world World name
* @param player Player name
* @param node Permission node
* @param value Value to set
*/
abstract public void setPlayerInfoBoolean(String world, String player, String node, boolean value);
/**
* Set a players informational node (Boolean) value
* @param world World Object
* @param player Player name
* @param node Permission node
* @param value Value to set
*/
public void setPlayerInfoBoolean(World world, String player, String node, boolean value) {
setPlayerInfoBoolean(world.getName(), player, node, value);
}
/**
* Set a players informational node (Boolean) value
* @param player Player Object
* @param node Permission node
* @param value Value to set
*/
public void setPlayerInfoBoolean(Player player, String node, boolean value) {
setPlayerInfoBoolean(player.getWorld().getName(), player.getName(), node, value);
}
/**
* Get a groups informational node (Boolean) value
* @param world Name of World
* @param group Name of Group
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
abstract public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue);
/**
* Set a players informational node (Boolean) value
* @param world World Object
* @param group Group name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public boolean getGroupInfoBoolean(World world, String group, String node, boolean defaultValue) {
return getGroupInfoBoolean(world.getName(), group, node, defaultValue);
}
/**
* Set a groups informational node (Boolean) value
* @param world World name
* @param group Group name
* @param node Permission node
* @param value Value to set
*/
abstract public void setGroupInfoBoolean(String world, String group, String node, boolean value);
/**
* Set a players informational node (Boolean) value
* @param world World Object
* @param group Group name
* @param node Permission node
* @param value Value to set
*/
public void setGroupInfoBoolean(World world, String group, String node, boolean value) {
setGroupInfoBoolean(world.getName(), group, node, value);
}
/**
* Get a players informational node (String) value
* @param world World name
* @param player Player name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
abstract public String getPlayerInfoString(String world, String player, String node, String defaultValue);
/**
* Get a players informational node (String) value
* @param world World Object
* @param player Player name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public String getPlayerInfoString(World world, String player, String node, String defaultValue) {
return getPlayerInfoString(world.getName(), player, node, defaultValue);
}
/**
* Get a players informational node (String) value
* @param player Player Object
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public String getPlayerInfoString(Player player, String node, String defaultValue) {
return getPlayerInfoString(player.getWorld().getName(), player.getName(), node, defaultValue);
}
/**
* Set a players informational node (String) value
* @param world World name
* @param player Player name
* @param node Permission node
* @param value Value to set
*/
abstract public void setPlayerInfoString(String world, String player, String node, String value);
/**
* Set a players informational node (String) value
* @param world World name
* @param player Player name
* @param node Permission node
* @param value Value to set
*/
public void setPlayerInfoString(World world, String player, String node, String value) {
setPlayerInfoString(world.getName(), player, node, value);
}
/**
* Set a players informational node (String) value
* @param player Player Object
* @param node Permission node
* @param value Value ot set
*/
public void setPlayerInfoString(Player player, String node, String value) {
setPlayerInfoString(player.getWorld().getName(), player.getName(), node, value);
}
/**
* Get a groups informational node (String) value
* @param world Name of World
* @param group Name of Group
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
abstract public String getGroupInfoString(String world, String group, String node, String defaultValue);
/**
* Set a players informational node (String) value
* @param world World Object
* @param group Group name
* @param node Permission node
* @param defaultValue Default value
* @return Value
*/
public String getGroupInfoString(World world, String group, String node, String defaultValue) {
return getGroupInfoString(world.getName(), group, node, defaultValue);
}
/**
* Set a groups informational node (String) value
* @param world World name
* @param group Group name
* @param node Permission node
* @param value Value to set
*/
abstract public void setGroupInfoString(String world, String group, String node, String value);
/**
* Set a groups informational node (String) value
* @param world World name
* @param group Group name
* @param node Permission node
* @param value Value to set
*/
public void setGroupInfoString(World world, String group, String node, String value) {
setGroupInfoString(world.getName(), group, node, value);
}
/**
* Check if player is member of a group.
* @param world World name
* @param player Player name
* @param group Group name
* @return Success or Failure
*/
public boolean playerInGroup(String world, String player, String group) {
return perms.playerInGroup(world, player, group);
}
/**
* Check if player is member of a group.
* @param world World Object
* @param player Player name
* @param group Group name
* @return Success or Failure
*/
public boolean playerInGroup(World world, String player, String group) {
return playerInGroup(world.getName(), player, group);
}
/**
* Check if player is member of a group.
* @param player Player Object
* @param group Group name
* @return Success or Failure
*/
public boolean playerInGroup(Player player, String group) {
return playerInGroup(player.getWorld().getName(), player.getName(), group);
}
/**
* Gets the list of groups that this player has
* @param world World name
* @param player Player name
* @return Array of groups
*/
public String[] getPlayerGroups(String world, String player) {
return perms.getPlayerGroups(world, player);
}
/**
* Gets the list of groups that this player has
* @param world World Object
* @param player Player name
* @return Array of groups
*/
public String[] getPlayerGroups(World world, String player) {
return getPlayerGroups(world.getName(), player);
}
/**
* Gets the list of groups that this player has
* @param player Player Object
* @return Array of groups
*/
public String[] getPlayerGroups(Player player) {
return getPlayerGroups(player.getWorld().getName(), player.getName());
}
/**
* Gets players primary group
* @param world World name
* @param player Player name
* @return Players primary group
*/
public String getPrimaryGroup(String world, String player) {
return perms.getPrimaryGroup(world, player);
}
/**
* Gets players primary group
* @param world World Object
* @param player Player name
* @return Players primary group
*/
public String getPrimaryGroup(World world, String player) {
return getPrimaryGroup(world.getName(), player);
}
/**
* Get players primary group
* @param player Player Object
* @return Players primary group
*/
public String getPrimaryGroup(Player player) {
return getPrimaryGroup(player.getWorld().getName(), player.getName());
}
/**
* Returns a list of all known groups
* @return an Array of String of all groups
*/
public String[] getGroups() {
return perms.getGroups();
}
}

View File

@ -0,0 +1,83 @@
package net.milkbowl.vault.economy;
import org.bukkit.OfflinePlayer;
@SuppressWarnings("deprecation")
public abstract class AbstractEconomy implements Economy {
@Override
public boolean hasAccount(OfflinePlayer player) {
return hasAccount(player.getName());
}
@Override
public boolean hasAccount(OfflinePlayer player, String worldName) {
return hasAccount(player.getName(), worldName);
}
@Override
public double getBalance(OfflinePlayer player) {
return getBalance(player.getName());
}
@Override
public double getBalance(OfflinePlayer player, String world) {
return getBalance(player.getName(), world);
}
@Override
public boolean has(OfflinePlayer player, double amount) {
return has(player.getName(), amount);
}
@Override
public boolean has(OfflinePlayer player, String worldName, double amount) {
return has(player.getName(), worldName, amount);
}
@Override
public EconomyResponse withdrawPlayer(OfflinePlayer player, double amount) {
return withdrawPlayer(player.getName(), amount);
}
@Override
public EconomyResponse withdrawPlayer(OfflinePlayer player, String worldName, double amount) {
return withdrawPlayer(player.getName(), worldName, amount);
}
@Override
public EconomyResponse depositPlayer(OfflinePlayer player, double amount) {
return depositPlayer(player.getName(), amount);
}
@Override
public EconomyResponse depositPlayer(OfflinePlayer player, String worldName, double amount) {
return depositPlayer(player.getName(), worldName, amount);
}
@Override
public EconomyResponse createBank(String name, OfflinePlayer player) {
return createBank(name, player.getName());
}
@Override
public EconomyResponse isBankOwner(String name, OfflinePlayer player) {
return isBankOwner(name, player.getName());
}
@Override
public EconomyResponse isBankMember(String name, OfflinePlayer player) {
return isBankMember(name, player.getName());
}
@Override
public boolean createPlayerAccount(OfflinePlayer player) {
return createPlayerAccount(player.getName());
}
@Override
public boolean createPlayerAccount(OfflinePlayer player, String worldName) {
return createPlayerAccount(player.getName(), worldName);
}
}

View File

@ -0,0 +1,439 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy;
import java.util.List;
import org.bukkit.OfflinePlayer;
/**
* The main economy API
*
*/
public interface Economy {
/**
* Checks if economy method is enabled.
* @return Success or Failure
*/
public boolean isEnabled();
/**
* Gets name of economy method
* @return Name of Ecoomy Method
*/
public String getName();
/**
* Returns true if the given implementation supports banks.
* @return true if the implementation supports banks
*/
public boolean hasBankSupport();
/**
* Some economy plugins round off after a certain number of digits.
* This function returns the number of digits the plugin keeps
* or -1 if no rounding occurs.
* @return number of digits after the decimal point kept
*/
public int fractionalDigits();
/**
* Format amount into a human readable String This provides translation into
* economy specific formatting to improve consistency between plugins.
*
* @param amount to format
* @return Human readable string describing amount
*/
public String format(double amount);
/**
* Returns the name of the currency in plural form.
* If the economy being used does not support currency names then an empty string will be returned.
*
* @return name of the currency (plural)
*/
public String currencyNamePlural();
/**
* Returns the name of the currency in singular form.
* If the economy being used does not support currency names then an empty string will be returned.
*
* @return name of the currency (singular)
*/
public String currencyNameSingular();
/**
*
* @deprecated As of Vault 1.3.01 use {@link #hasAccount(OfflinePlayer)} instead.
*
* Checks if this player has an account on the server yet
* This will always return true if the player has joined the server at least once
* as all major economy plugins auto-generate a player account when the player joins the server
*
* @param playerName to check
* @return if the player has an account
*/
@Deprecated
public boolean hasAccount(String playerName);
/**
* Checks if this player has an account on the server yet
* This will always return true if the player has joined the server at least once
* as all major economy plugins auto-generate a player account when the player joins the server
*
* @param player to check
* @return if the player has an account
*/
public boolean hasAccount(OfflinePlayer player);
/**
* @deprecated As of Vault 1.3.01 use {@link #hasAccount(OfflinePlayer, String)} instead.
*
* Checks if this player has an account on the server yet on the given world
* This will always return true if the player has joined the server at least once
* as all major economy plugins auto-generate a player account when the player joins the server
*
* @param playerName to check in the world
* @param worldName world-specific account
* @return if the player has an account
*/
@Deprecated
public boolean hasAccount(String playerName, String worldName);
/**
* Checks if this player has an account on the server yet on the given world
* This will always return true if the player has joined the server at least once
* as all major economy plugins auto-generate a player account when the player joins the server
*
* @param player to check in the world
* @param worldName world-specific account
* @return if the player has an account
*/
public boolean hasAccount(OfflinePlayer player, String worldName);
/**
* @deprecated As of Vault 1.3.01 use {@link #getBalance(OfflinePlayer)} instead.
* Gets balance of a player
*
* @param playerName of the player
* @return Amount currently held in players account
*/
@Deprecated
public double getBalance(String playerName);
/**
* Gets balance of a player
*
* @param player of the player
* @return Amount currently held in players account
*/
public double getBalance(OfflinePlayer player);
/**
* @deprecated As of Vault 1.3.01 use {@link #getBalance(OfflinePlayer, String)} instead.
*
* Gets balance of a player on the specified world.
* IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned.
* @param playerName
* @param world name of the world
* @return Amount currently held in players account
*/
@Deprecated
public double getBalance(String playerName, String world);
/**
* Gets balance of a player on the specified world.
* IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned.
* @param player to check
* @param world name of the world
* @return Amount currently held in players account
*/
public double getBalance(OfflinePlayer player, String world);
/**
* @deprecated As of Vault 1.3.01 use {@link #has(OfflinePlayer, double)} instead.
*
* Checks if the player account has the amount - DO NOT USE NEGATIVE AMOUNTS
*
* @param playerName to check
* @param amount to check for
* @return True if <b>playerName</b> has <b>amount</b>, False else wise
*/
@Deprecated
public boolean has(String playerName, double amount);
/**
* Checks if the player account has the amount - DO NOT USE NEGATIVE AMOUNTS
*
* @param player to check
* @param amount to check for
* @return True if <b>player</b> has <b>amount</b>, False else wise
*/
public boolean has(OfflinePlayer player, double amount);
/**
* @deprecated As of Vault 1.3.01 use @{link {@link #has(OfflinePlayer, String, double)} instead.
*
* Checks if the player account has the amount in a given world - DO NOT USE NEGATIVE AMOUNTS
* IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned.
*
* @param playerName to check
* @param worldName to check with
* @param amount to check for
* @return True if <b>playerName</b> has <b>amount</b>, False else wise
*/
@Deprecated
public boolean has(String playerName, String worldName, double amount);
/**
* Checks if the player account has the amount in a given world - DO NOT USE NEGATIVE AMOUNTS
* IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned.
*
* @param player to check
* @param worldName to check with
* @param amount to check for
* @return True if <b>player</b> has <b>amount</b>, False else wise
*/
public boolean has(OfflinePlayer player, String worldName, double amount);
/**
* @deprecated As of Vault 1.3.01 use {@link #withdrawPlayer(OfflinePlayer, double)} instead.
* Withdraw an amount from a player - DO NOT USE NEGATIVE AMOUNTS
*
* @param playerName Name of player
* @param amount Amount to withdraw
* @return Detailed response of transaction
*/
@Deprecated
public EconomyResponse withdrawPlayer(String playerName, double amount);
/**
* Withdraw an amount from a player - DO NOT USE NEGATIVE AMOUNTS
*
* @param player to withdraw from
* @param amount Amount to withdraw
* @return Detailed response of transaction
*/
public EconomyResponse withdrawPlayer(OfflinePlayer player, double amount);
/**
* @deprecated As of Vault 1.3.01 use {@link #withdrawPlayer(OfflinePlayer, String, double)} instead.
*
* Withdraw an amount from a player on a given world - DO NOT USE NEGATIVE AMOUNTS
* IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned.
* @param playerName Name of player
* @param worldName - name of the world
* @param amount Amount to withdraw
* @return Detailed response of transaction
*/
@Deprecated
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount);
/**
* Withdraw an amount from a player on a given world - DO NOT USE NEGATIVE AMOUNTS
* IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned.
* @param player to withdraw from
* @param worldName - name of the world
* @param amount Amount to withdraw
* @return Detailed response of transaction
*/
public EconomyResponse withdrawPlayer(OfflinePlayer player, String worldName, double amount);
/**
* @deprecated As of Vault 1.3.01 use {@link #depositPlayer(OfflinePlayer, double)} instead.
*
* Deposit an amount to a player - DO NOT USE NEGATIVE AMOUNTS
*
* @param playerName Name of player
* @param amount Amount to deposit
* @return Detailed response of transaction
*/
@Deprecated
public EconomyResponse depositPlayer(String playerName, double amount);
/**
* Deposit an amount to a player - DO NOT USE NEGATIVE AMOUNTS
*
* @param player to deposit to
* @param amount Amount to deposit
* @return Detailed response of transaction
*/
public EconomyResponse depositPlayer(OfflinePlayer player, double amount);
/**
* @deprecated As of Vault 1.3.01 use {@link #depositPlayer(OfflinePlayer, String, double)} instead.
*
* Deposit an amount to a player - DO NOT USE NEGATIVE AMOUNTS
* IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned.
* @param playerName Name of player
* @param amount Amount to deposit
* @return Detailed response of transaction
*/
@Deprecated
public EconomyResponse depositPlayer(String playerName, String worldName, double amount);
/**
* Deposit an amount to a player - DO NOT USE NEGATIVE AMOUNTS
* IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned.
* @param player to deposit to
* @param amount Amount to deposit
* @return Detailed response of transaction
*/
public EconomyResponse depositPlayer(OfflinePlayer player, String worldName, double amount);
/**
* @deprecated As of Vault 1.3.01 use {{@link #createBank(String, OfflinePlayer)} instead.
*
* Creates a bank account with the specified name and the player as the owner
* @param name of account
* @param player the account should be linked to
* @return EconomyResponse Object
*/
@Deprecated
public EconomyResponse createBank(String name, String player);
/**
* Creates a bank account with the specified name and the player as the owner
* @param name of account
* @param player the account should be linked to
* @return EconomyResponse Object
*/
public EconomyResponse createBank(String name, OfflinePlayer player);
/**
* Deletes a bank account with the specified name.
* @param name of the back to delete
* @return if the operation completed successfully
*/
public EconomyResponse deleteBank(String name);
/**
* Returns the amount the bank has
* @param name of the account
* @return EconomyResponse Object
*/
public EconomyResponse bankBalance(String name);
/**
* Returns true or false whether the bank has the amount specified - DO NOT USE NEGATIVE AMOUNTS
*
* @param name of the account
* @param amount to check for
* @return EconomyResponse Object
*/
public EconomyResponse bankHas(String name, double amount);
/**
* Withdraw an amount from a bank account - DO NOT USE NEGATIVE AMOUNTS
*
* @param name of the account
* @param amount to withdraw
* @return EconomyResponse Object
*/
public EconomyResponse bankWithdraw(String name, double amount);
/**
* Deposit an amount into a bank account - DO NOT USE NEGATIVE AMOUNTS
*
* @param name of the account
* @param amount to deposit
* @return EconomyResponse Object
*/
public EconomyResponse bankDeposit(String name, double amount);
/**
* @deprecated As of Vault 1.3.01 use {{@link #isBankOwner(String, OfflinePlayer)} instead.
*
* Check if a player is the owner of a bank account
*
* @param name of the account
* @param playerName to check for ownership
* @return EconomyResponse Object
*/
@Deprecated
public EconomyResponse isBankOwner(String name, String playerName);
/**
* Check if a player is the owner of a bank account
*
* @param name of the account
* @param player to check for ownership
* @return EconomyResponse Object
*/
public EconomyResponse isBankOwner(String name, OfflinePlayer player);
/**
* @deprecated As of Vault 1.3.01 use {{@link #isBankMember(String, OfflinePlayer)} instead.
*
* Check if the player is a member of the bank account
*
* @param name of the account
* @param playerName to check membership
* @return EconomyResponse Object
*/
@Deprecated
public EconomyResponse isBankMember(String name, String playerName);
/**
* Check if the player is a member of the bank account
*
* @param name of the account
* @param player to check membership
* @return EconomyResponse Object
*/
public EconomyResponse isBankMember(String name, OfflinePlayer player);
/**
* Gets the list of banks
* @return the List of Banks
*/
public List<String> getBanks();
/**
* @deprecated As of Vault 1.3.01 use {{@link #createPlayerAccount(OfflinePlayer)} instead.
*
* Attempts to create a player account for the given player
* @return if the account creation was successful
*/
@Deprecated
public boolean createPlayerAccount(String playerName);
/**
* Attempts to create a player account for the given player
* @return if the account creation was successful
*/
public boolean createPlayerAccount(OfflinePlayer player);
/**
* @deprecated As of Vault 1.3.01 use {{@link #createPlayerAccount(OfflinePlayer, String)} instead.
*
* Attempts to create a player account for the given player on the specified world
* IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned.
* @return if the account creation was successful
*/
@Deprecated
public boolean createPlayerAccount(String playerName, String worldName);
/**
* Attempts to create a player account for the given player on the specified world
* IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned.
* @return if the account creation was successful
*/
public boolean createPlayerAccount(OfflinePlayer player, String worldName);
}

View File

@ -0,0 +1,89 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.economy;
/**
* Indicates a typical Return for an Economy method.
* It includes a {@link ResponseType} indicating whether the plugin currently being used for Economy actually allows
* the method, or if the operation was a success or failure.
*
*/
public class EconomyResponse {
/**
* Enum for types of Responses indicating the status of a method call.
*/
public static enum ResponseType {
SUCCESS(1),
FAILURE(2),
NOT_IMPLEMENTED(3);
private int id;
ResponseType(int id) {
this.id = id;
}
int getId() {
return id;
}
}
/**
* Amount modified by calling method
*/
public final double amount;
/**
* New balance of account
*/
public final double balance;
/**
* Success or failure of call. Using Enum of ResponseType to determine valid
* outcomes
*/
public final ResponseType type;
/**
* Error message if the variable 'type' is ResponseType.FAILURE
*/
public final String errorMessage;
/**
* Constructor for EconomyResponse
* @param amount Amount modified during operation
* @param balance New balance of account
* @param type Success or failure type of the operation
* @param errorMessage Error message if necessary (commonly null)
*/
public EconomyResponse(double amount, double balance, ResponseType type, String errorMessage) {
this.amount = amount;
this.balance = balance;
this.type = type;
this.errorMessage = errorMessage;
}
/**
* Checks if an operation was successful
* @return Value
*/
public boolean transactionSuccess() {
switch (type) {
case SUCCESS:
return true;
default:
return false;
}
}
}

View File

@ -0,0 +1,105 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.item;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public class ItemInfo {
public final Material material;
public final short subTypeId;
public final String name;
public final String[][] search;
public ItemInfo(String name, String[][] search, Material material) {
this.material = material;
this.name = name;
this.subTypeId = 0;
this.search = search.clone();
}
public ItemInfo(String name, String[][] search, Material material, short subTypeId) {
this.name = name;
this.material = material;
this.subTypeId = subTypeId;
this.search = search.clone();
}
public Material getType() {
return material;
}
public short getSubTypeId() {
return subTypeId;
}
public int getStackSize() {
return material.getMaxStackSize();
}
@Deprecated
public int getId() {
return material.getId();
}
public boolean isEdible() {
return material.isEdible();
}
public boolean isBlock() {
return material.isBlock();
}
public String getName() {
return name;
}
@Override
public int hashCode() {
int hash = 7;
hash = 17 * hash + this.getId();
hash = 17 * hash + this.subTypeId;
return hash;
}
public boolean isDurable() {
return (material.getMaxDurability() > 0);
}
public ItemStack toStack() {
return new ItemStack(this.material, 1, subTypeId);
}
@SuppressWarnings("deprecation")
@Override
public String toString() {
return String.format("%s[%d:%d]", name, material.getId(), subTypeId);
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
} else if (this == obj) {
return true;
} else if (!(obj instanceof ItemInfo)) {
return false;
} else {
return ((ItemInfo) obj).material == this.material && ((ItemInfo) obj).subTypeId == this.subTypeId;
}
}
}

View File

@ -0,0 +1,962 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.item;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public class Items {
private static final List<ItemInfo> items = new CopyOnWriteArrayList<ItemInfo>();
/**
* Returns the list of ItemInfo's registered in Vault as an UnmodifiableList.
* @return list of Items
*/
public static List<ItemInfo> getItemList() {
return Collections.unmodifiableList(items);
}
static {
items.add(new ItemInfo("Air", new String[][]{{"air"}}, Material.AIR));
items.add(new ItemInfo("Stone", new String[][]{{"ston"}, {"smoo", "sto"}}, Material.STONE));
items.add(new ItemInfo("Grass", new String[][]{{"gras"}}, Material.GRASS));
items.add(new ItemInfo("Dirt", new String[][]{{"dirt"}}, Material.DIRT));
items.add(new ItemInfo("Cobblestone", new String[][]{{"cobb", "sto"}, {"cobb"}}, Material.COBBLESTONE));
items.add(new ItemInfo("Oak Plank", new String[][]{{"wood"}, {"oak", "plank"}, {"oak", "wood"}}, Material.WOOD));
items.add(new ItemInfo("Spruce Plank", new String[][]{{"spru", "plank"}, {"spruc", "wood"}}, Material.WOOD, (short) 1));
items.add(new ItemInfo("Birch Plank", new String[][]{{"birch", "plank"}, {"birch", "wood"}}, Material.WOOD, (short) 2));
items.add(new ItemInfo("Jungle Plank", new String[][]{{"jung", "plank"}, {"jung", "wood"}}, Material.WOOD, (short) 3));
items.add(new ItemInfo("Oak Sapling", new String[][]{{"sapl"}, {"sapl", "oak"}}, Material.SAPLING));
items.add(new ItemInfo("Spruce Sapling", new String[][]{{"sapl", "spruc"}}, Material.SAPLING, (short) 1));
items.add(new ItemInfo("Birch Sapling", new String[][]{{"sapl", "birch"}}, Material.SAPLING, (short) 2));
items.add(new ItemInfo("Jungle Sapling", new String[][]{{"sapl", "jungle"}}, Material.SAPLING, (short) 3));
items.add(new ItemInfo("Bedrock", new String[][]{{"rock"}}, Material.BEDROCK));
items.add(new ItemInfo("Water", new String[][]{{"water"}}, Material.WATER));
items.add(new ItemInfo("Lava", new String[][]{{"lava"}}, Material.LAVA));
items.add(new ItemInfo("Sand", new String[][]{{"sand"}}, Material.SAND));
items.add(new ItemInfo("Gold Ore", new String[][]{{"ore", "gold"}}, Material.GOLD_ORE));
items.add(new ItemInfo("Iron Ore", new String[][]{{"ore", "iron"}}, Material.IRON_ORE));
items.add(new ItemInfo("Coal Ore", new String[][]{{"ore", "coal"}}, Material.COAL_ORE));
items.add(new ItemInfo("Gravel", new String[][]{{"grav"}}, Material.GRAVEL));
items.add(new ItemInfo("Oak Log", new String[][]{{"oak"}, {"log"}, {"oak", "log"}}, Material.LOG));
items.add(new ItemInfo("Spruce Log", new String[][]{{"spruc"}, {"spruc", "log"}}, Material.LOG, (short) 1));
items.add(new ItemInfo("Birch Log", new String[][]{{"birch"}, {"birch", "log"}}, Material.LOG, (short) 2));
items.add(new ItemInfo("Jungle Log", new String[][]{{"jung", "log"}}, Material.LOG, (short) 3));
items.add(new ItemInfo("Leaves Block", new String[][]{{"blo", "leaf"}, {"blo", "leaves"}}, Material.LEAVES));
items.add(new ItemInfo("Spruce Leaves Block", new String[][]{{"blo", "lea", "spruc"}}, Material.LEAVES, (short) 1));
items.add(new ItemInfo("Birch Leaves Block", new String[][]{{"blo", "lea", "birch"}}, Material.LEAVES, (short) 2));
items.add(new ItemInfo("Jungle Leaves Block", new String[][]{{"blo", "lea", "jung"}}, Material.LEAVES, (short) 3));
items.add(new ItemInfo("Leaves", new String[][]{{"leaf"}, {"leaves"}}, Material.LEAVES, (short) 4));
items.add(new ItemInfo("Spruce Leaves", new String[][]{{"lea", "spruce"}}, Material.LEAVES, (short) 5));
items.add(new ItemInfo("Birch Leaves", new String[][]{{"lea", "birch"}}, Material.LEAVES, (short) 6));
items.add(new ItemInfo("Jungle Leaves", new String[][]{{"lea", "jung"}}, Material.LEAVES, (short) 7));
items.add(new ItemInfo("Sponge", new String[][]{{"sponge"}}, Material.SPONGE));
items.add(new ItemInfo("Glass", new String[][]{{"glas"}, {"sili"}}, Material.GLASS));
items.add(new ItemInfo("Lapis Lazuli Ore", new String[][]{{"lap", "laz", "ore"}, {"lazul", "ore"}, {"ore", "lapiz"}}, Material.LAPIS_ORE));
items.add(new ItemInfo("Lapis Lazuli Block", new String[][]{{"lap", "laz", "bloc"}, {"lazu", "bloc"}, {"blo", "lapi"}}, Material.LAPIS_BLOCK));
items.add(new ItemInfo("Dispenser", new String[][]{{"dispen"}}, Material.DISPENSER));
items.add(new ItemInfo("Sandstone", new String[][]{{"sand", "st"}}, Material.SANDSTONE));
items.add(new ItemInfo("Chiseled Sandstone", new String[][]{{"chis", "sand", "sto"}}, Material.SANDSTONE, (short) 1));
items.add(new ItemInfo("Smooth Sandstone", new String[][]{{"smoo", "sand", "sto"}}, Material.SANDSTONE, (short) 2));
items.add(new ItemInfo("Note Block", new String[][]{{"note"}}, Material.NOTE_BLOCK));
items.add(new ItemInfo("Bed Block", new String[][]{{"block", "bed"}}, Material.BED_BLOCK));
items.add(new ItemInfo("Powered Rail", new String[][]{{"rail", "pow"}, {"trac", "pow"}, {"boost"}}, Material.POWERED_RAIL));
items.add(new ItemInfo("Detector Rail", new String[][]{{"rail", "det"}, {"trac", "det"}, {"detec"}}, Material.DETECTOR_RAIL));
items.add(new ItemInfo("Sticky Piston", new String[][]{{"stic", "pis"}}, Material.PISTON_STICKY_BASE));
items.add(new ItemInfo("Web", new String[][]{{"web"}, {"cobw"}}, Material.WEB));
items.add(new ItemInfo("Dead Shrub", new String[][]{{"dead", "shru"}, {"dese", "shru"}, {"shrub"}}, Material.LONG_GRASS, (short) 0));
items.add(new ItemInfo("Tall Grass", new String[][]{{"tall", "gras"}, {"long", "gras"}}, Material.LONG_GRASS, (short) 1));
items.add(new ItemInfo("Fern", new String[][]{{"fern"}}, Material.LONG_GRASS, (short) 2));
items.add(new ItemInfo("Piston", new String[][]{{"pisto"}}, Material.PISTON_BASE));
items.add(new ItemInfo("White Wool", new String[][]{{"wool", "whit"}, {"wool"}}, Material.WOOL));
items.add(new ItemInfo("Orange Wool", new String[][]{{"wool", "ora"}}, Material.WOOL, (short) 1));
items.add(new ItemInfo("Magenta Wool", new String[][]{{"wool", "mag"}}, Material.WOOL, (short) 2));
items.add(new ItemInfo("Light Blue Wool", new String[][]{{"wool", "lig", "blue"}}, Material.WOOL, (short) 3));
items.add(new ItemInfo("Yellow Wool", new String[][]{{"wool", "yell"}}, Material.WOOL, (short) 4));
items.add(new ItemInfo("Light Green Wool", new String[][]{{"wool", "lig", "gree"}, {"wool", "gree"}}, Material.WOOL, (short) 5));
items.add(new ItemInfo("Pink Wool", new String[][]{{"wool", "pink"}}, Material.WOOL, (short) 6));
items.add(new ItemInfo("Gray Wool", new String[][]{{"wool", "gray"}, {"wool", "grey"}}, Material.WOOL, (short) 7));
items.add(new ItemInfo("Light Gray Wool", new String[][]{{"lig", "wool", "gra"}, {"lig", "wool", "gre"}}, Material.WOOL, (short) 8));
items.add(new ItemInfo("Cyan Wool", new String[][]{{"wool", "cya"}}, Material.WOOL, (short) 9));
items.add(new ItemInfo("Purple Wool", new String[][]{{"wool", "pur"}}, Material.WOOL, (short) 10));
items.add(new ItemInfo("Blue Wool", new String[][]{{"wool", "blue"}}, Material.WOOL, (short) 11));
items.add(new ItemInfo("Brown Wool", new String[][]{{"wool", "brow"}}, Material.WOOL, (short) 12));
items.add(new ItemInfo("Dark Green Wool", new String[][]{{"wool", "dar", "gree"}, {"wool", "gree"}}, Material.WOOL, (short) 13));
items.add(new ItemInfo("Red Wool", new String[][]{{"wool", "red"}}, Material.WOOL, (short) 14));
items.add(new ItemInfo("Black Wool", new String[][]{{"wool", "bla"}}, Material.WOOL, (short) 15));
items.add(new ItemInfo("Dandelion", new String[][]{{"flow", "yell"}, {"dande"}}, Material.YELLOW_FLOWER));
items.add(new ItemInfo("Brown Mushroom", new String[][]{{"mush", "bro"}}, Material.BROWN_MUSHROOM));
items.add(new ItemInfo("Red Mushroom", new String[][]{{"mush", "red"}}, Material.RED_MUSHROOM));
items.add(new ItemInfo("Gold Block", new String[][]{{"gold", "bl"}}, Material.GOLD_BLOCK));
items.add(new ItemInfo("Iron Block", new String[][]{{"iron", "bl"}}, Material.IRON_BLOCK));
items.add(new ItemInfo("Double Stone Slab", new String[][]{{"doub", "slab"}, {"doub", "slab", "sto"}, {"doub", "step", "sto"}}, Material.DOUBLE_STEP));
items.add(new ItemInfo("Double Sandstone Slab", new String[][]{{"doub", "slab", "sand", "sto"}, {"doub", "step", "sand", "sto"}}, Material.DOUBLE_STEP, (short) 1));
items.add(new ItemInfo("Double Wooden Slab", new String[][]{{"doub", "slab", "wood"}, {"doub", "step", "wood"}}, Material.DOUBLE_STEP, (short) 2));
items.add(new ItemInfo("Double Cobblestone Slab", new String[][]{{"doub", "slab", "cob", "sto"}, {"doub", "slab", "cob"}, {"doub", "step", "cob"}}, Material.DOUBLE_STEP, (short) 3));
items.add(new ItemInfo("Double Brick Slab", new String[][]{{"doub", "slab", "bri"}}, Material.DOUBLE_STEP, (short) 4));
items.add(new ItemInfo("Double Stone Brick Slab", new String[][]{{"doub", "slab", "smoo"}, {"doub", "slab", "sto", "bri"}}, Material.DOUBLE_STEP, (short) 5));
items.add(new ItemInfo("Double Smooth Sandstone Slab", new String[][]{{"doub", "slab", "sand", "smoo"}}, Material.DOUBLE_STEP, (short) 9));
items.add(new ItemInfo("Stone Slab", new String[][]{{"slab", "sto"}, {"slab"}, {"step", "ston"}}, Material.STEP));
items.add(new ItemInfo("Sandstone Slab", new String[][]{{"slab", "sand", "sto"}, {"step", "sand", "sto"}}, Material.STEP, (short) 1));
items.add(new ItemInfo("Wooden Slab", new String[][]{{"slab", "woo"}, {"step", "woo"}}, Material.STEP, (short) 2));
items.add(new ItemInfo("Cobblestone Slab", new String[][]{{"slab", "cob", "sto"}, {"slab", "cob"}}, Material.STEP, (short) 3));
items.add(new ItemInfo("Brick Slab", new String[][]{{"slab", "bri"}}, Material.STEP, (short) 4));
items.add(new ItemInfo("Stone Brick Slab", new String[][]{{"slab", "sto", "bri"}}, Material.STEP, (short) 5));
items.add(new ItemInfo("Brick", new String[][]{{"bric"}}, Material.BRICK));
items.add(new ItemInfo("TNT", new String[][]{{"tnt"}, {"boom"}}, Material.TNT));
items.add(new ItemInfo("Bookshelf", new String[][]{{"bookshe"}, {"book", "she"}}, Material.BOOKSHELF));
items.add(new ItemInfo("Moss Stone", new String[][]{{"moss", "sto"}, {"moss"}}, Material.MOSSY_COBBLESTONE));
items.add(new ItemInfo("Obsidian", new String[][]{{"obsi"}}, Material.OBSIDIAN));
items.add(new ItemInfo("Torch", new String[][]{{"torc"}}, Material.TORCH));
items.add(new ItemInfo("Fire", new String[][]{{"fire"}}, Material.FIRE));
items.add(new ItemInfo("Monster Spawner", new String[][]{{"spawn"}}, Material.MOB_SPAWNER));
items.add(new ItemInfo("Oak Wood Stairs", new String[][]{{"stair", "wood"}, {"oak", "stair"}}, Material.WOOD_STAIRS));
items.add(new ItemInfo("Jungle Wood Stairs", new String[][]{{"jungle", "stair"}, {"jung", "stair", "woo"}}, Material.JUNGLE_WOOD_STAIRS));
items.add(new ItemInfo("Spruce Wood Stairs", new String[][]{{"spruce", "stai"}, {"spru", "stair", "woo"}}, Material.SPRUCE_WOOD_STAIRS));
items.add(new ItemInfo("Birch Wood Stairs", new String[][]{{"birch", "stair"}, {"birc", "stai", "woo"}}, Material.BIRCH_WOOD_STAIRS));
items.add(new ItemInfo("Chest", new String[][]{{"chest"}}, Material.CHEST));
items.add(new ItemInfo("Diamond Ore", new String[][]{{"ore", "diam"}}, Material.DIAMOND_ORE));
items.add(new ItemInfo("Diamond Block", new String[][]{{"diam", "bl"}}, Material.DIAMOND_BLOCK));
items.add(new ItemInfo("Crafting Table", new String[][]{{"benc"}, {"squa"}, {"craft"}}, Material.WORKBENCH));
items.add(new ItemInfo("Farmland", new String[][]{{"soil"}, {"farm"}}, Material.SOIL));
items.add(new ItemInfo("Furnace", new String[][]{{"furna"}, {"cooke"}}, Material.FURNACE));
items.add(new ItemInfo("Ladder", new String[][]{{"ladd"}}, Material.LADDER));
items.add(new ItemInfo("Rails", new String[][]{{"rail"}, {"trac"}}, Material.RAILS));
items.add(new ItemInfo("Cobblestone Stairs", new String[][]{{"stair", "cob", "sto"}, {"stair", "cob"}}, Material.COBBLESTONE_STAIRS));
items.add(new ItemInfo("Lever", new String[][]{{"lever"}, {"switc"}}, Material.LEVER));
items.add(new ItemInfo("Stone Pressure Plate", new String[][]{{"pres", "plat", "ston"}}, Material.STONE_PLATE));
items.add(new ItemInfo("Wooden Pressure Plate", new String[][]{{"pres", "plat", "wood"}}, Material.WOOD_PLATE));
items.add(new ItemInfo("Redstone Ore", new String[][]{{"redst", "ore"}}, Material.REDSTONE_ORE));
items.add(new ItemInfo("Redstone Torch", new String[][]{{"torc", "red"}, {"torc", "rs"}}, Material.REDSTONE_TORCH_ON));
items.add(new ItemInfo("Stone Button", new String[][]{{"stone", "button"}, {"button"}}, Material.STONE_BUTTON));
items.add(new ItemInfo("Snow", new String[][]{{"tile", "snow"}, {"snow", "slab"}, {"snow"}}, Material.SNOW));
items.add(new ItemInfo("Ice", new String[][]{{"ice"}}, Material.ICE));
items.add(new ItemInfo("Snow Block", new String[][]{{"blo", "snow"}}, Material.SNOW_BLOCK));
items.add(new ItemInfo("Cactus", new String[][]{{"cact"}}, Material.CACTUS));
items.add(new ItemInfo("Clay Block", new String[][]{{"clay", "blo"}}, Material.CLAY));
items.add(new ItemInfo("Jukebox", new String[][]{{"jukeb"}}, Material.JUKEBOX));
items.add(new ItemInfo("Fence", new String[][]{{"fence"}}, Material.FENCE));
items.add(new ItemInfo("Pumpkin", new String[][]{{"pump"}}, Material.PUMPKIN));
items.add(new ItemInfo("Netherrack", new String[][]{{"netherr"}, {"netherst"}, {"hellst"}}, Material.NETHERRACK));
items.add(new ItemInfo("Soul Sand", new String[][]{{"soul", "sand"}, {"soul"}, {"slowsa"}, {"nether", "mud"}, {"slow", "sand"}, {"quick", "sand"}, {"mud"}}, Material.SOUL_SAND));
items.add(new ItemInfo("Glowstone", new String[][]{{"glow", "stone"}, {"light", "stone"}}, Material.GLOWSTONE));
items.add(new ItemInfo("Portal", new String[][]{{"port"}}, Material.PORTAL));
items.add(new ItemInfo("Jack-O-Lantern", new String[][]{{"jack"}, {"lante"}}, Material.JACK_O_LANTERN));
items.add(new ItemInfo("Trapdoor", new String[][]{{"trap", "doo"}, {"hatc"}}, Material.TRAP_DOOR));
items.add(new ItemInfo("Stone Monster Egg", new String[][]{{"mons","egg"},{"sto","mons", "egg"}, {"hid", "silver"}}, Material.MONSTER_EGGS));
items.add(new ItemInfo("Stone Brick Monster Egg", new String[][]{{"sto", "bri", "mons", "egg"}, {"hid", "silver","sto","bri"}}, Material.MONSTER_EGGS, (short) 2));
items.add(new ItemInfo("Mossy Stone Brick Monster Egg", new String[][]{{"moss", "sto", "bri", "mons", "egg"}, {"hid", "silver","mos","sto","bri"}}, Material.MONSTER_EGGS, (short) 3));
items.add(new ItemInfo("Huge Brown Mushroom", new String[][]{{"bro", "huge", "mush"}}, Material.HUGE_MUSHROOM_1));
items.add(new ItemInfo("Huge Red Mushroom", new String[][]{{"red", "huge", "mush"}}, Material.HUGE_MUSHROOM_2));
items.add(new ItemInfo("Stone Brick", new String[][]{{"sto", "bric"}, {"smoo", "bric"}}, Material.SMOOTH_BRICK, (short) 0));
items.add(new ItemInfo("Iron Fence", new String[][]{{"bars", "iron"}, {"fence", "iron"}}, Material.IRON_FENCE));
items.add(new ItemInfo("Glass Pane", new String[][]{{"thin", "gla"}, {"pane"}, {"gla", "pane"}}, Material.THIN_GLASS));
items.add(new ItemInfo("Melon Block", new String[][]{{"melon"}}, Material.MELON_BLOCK));
items.add(new ItemInfo("Mossy Stone Brick", new String[][]{{"moss", "sto", "bri"}, {"moss", "smoo", "bri"}, {"moss", "smoo"}, {"moss", "sto"}}, Material.SMOOTH_BRICK, (short) 1));
items.add(new ItemInfo("Cracked Stone Brick", new String[][]{{"cra", "sto", "bri"}, {"cra", "sto"}, {"cra", "smoo", "bri"}, {"cra", "smoo"}}, Material.SMOOTH_BRICK, (short) 2));
items.add(new ItemInfo("Chiseled Stone Brick", new String[][]{{"chis", "sto", "bri"}, {"chis", "sto"}, {"chis", "smoo", "bri"}}, Material.SMOOTH_BRICK, (short) 3));
items.add(new ItemInfo("Brick Stairs", new String[][]{{"stair", "bri"}}, Material.BRICK_STAIRS));
items.add(new ItemInfo("Fence Gate", new String[][]{{"gate", "fen"}, {"gate"}}, Material.FENCE_GATE));
items.add(new ItemInfo("Vines", new String[][]{{"vine"}, {"ivy"}}, Material.VINE));
items.add(new ItemInfo("Stone Brick Stairs", new String[][]{{"stair", "sto", "bri"}, {"stair", "sto"}, {"stair", "smoo", "bri"}, {"stair", "smoo"}}, Material.SMOOTH_STAIRS));
items.add(new ItemInfo("Iron Shovel", new String[][]{{"shov", "ir"}, {"spad", "ir"}}, Material.IRON_SPADE));
items.add(new ItemInfo("Iron Pickaxe", new String[][]{{"pick", "ir"}}, Material.IRON_PICKAXE));
items.add(new ItemInfo("Iron Axe", new String[][]{{"axe", "ir"}}, Material.IRON_AXE));
items.add(new ItemInfo("Flint and Steel", new String[][]{{"steel"}, {"lighter"}, {"flin", "ste"}}, Material.FLINT_AND_STEEL));
items.add(new ItemInfo("Apple", new String[][]{{"appl"}}, Material.APPLE));
items.add(new ItemInfo("Bow", new String[][]{{"bow"}}, Material.BOW));
items.add(new ItemInfo("Arrow", new String[][]{{"arro"}}, Material.ARROW));
items.add(new ItemInfo("Coal", new String[][]{{"coal"}}, Material.COAL));
items.add(new ItemInfo("Charcoal", new String[][]{{"char", "coal"}, {"char"}}, Material.COAL, (short) 1));
items.add(new ItemInfo("Diamond", new String[][]{{"diamo"}}, Material.DIAMOND));
items.add(new ItemInfo("Iron Ingot", new String[][]{{"ingo", "ir"}, {"iron"}}, Material.IRON_INGOT));
items.add(new ItemInfo("Gold Ingot", new String[][]{{"ingo", "go"}, {"gold"}}, Material.GOLD_INGOT));
items.add(new ItemInfo("Iron Sword", new String[][]{{"swor", "ir"}}, Material.IRON_SWORD));
items.add(new ItemInfo("Wooden Sword", new String[][]{{"swor", "woo"}}, Material.WOOD_SWORD));
items.add(new ItemInfo("Wooden Shovel", new String[][]{{"shov", "wo"}, {"spad", "wo"}}, Material.WOOD_SPADE));
items.add(new ItemInfo("Wooden Pickaxe", new String[][]{{"pick", "woo"}}, Material.WOOD_PICKAXE));
items.add(new ItemInfo("Wooden Axe", new String[][]{{"axe", "woo"}}, Material.WOOD_AXE));
items.add(new ItemInfo("Stone Sword", new String[][]{{"swor", "sto"}}, Material.STONE_SWORD));
items.add(new ItemInfo("Stone Shovel", new String[][]{{"shov", "sto"}, {"spad", "sto"}}, Material.STONE_SPADE));
items.add(new ItemInfo("Stone Pickaxe", new String[][]{{"pick", "sto"}}, Material.STONE_PICKAXE));
items.add(new ItemInfo("Stone Axe", new String[][]{{"axe", "sto"}}, Material.STONE_AXE));
items.add(new ItemInfo("Diamond Sword", new String[][]{{"swor", "dia"}}, Material.DIAMOND_SWORD));
items.add(new ItemInfo("Diamond Shovel", new String[][]{{"shov", "dia"}, {"spad", "dia"}}, Material.DIAMOND_SPADE));
items.add(new ItemInfo("Diamond Pickaxe", new String[][]{{"pick", "dia"}}, Material.DIAMOND_PICKAXE));
items.add(new ItemInfo("Diamond Axe", new String[][]{{"axe", "dia"}}, Material.DIAMOND_AXE));
items.add(new ItemInfo("Stick", new String[][]{{"stic"}}, Material.STICK));
items.add(new ItemInfo("Bowl", new String[][]{{"bo", "wl"}}, Material.BOWL));
items.add(new ItemInfo("Mushroom Soup", new String[][]{{"soup"}}, Material.MUSHROOM_SOUP));
items.add(new ItemInfo("Gold Sword", new String[][]{{"swor", "gol"}}, Material.GOLD_SWORD));
items.add(new ItemInfo("Gold Shovel", new String[][]{{"shov", "gol"}, {"spad", "gol"}}, Material.GOLD_SPADE));
items.add(new ItemInfo("Gold Pickaxe", new String[][]{{"pick", "gol"}}, Material.GOLD_PICKAXE));
items.add(new ItemInfo("Gold Axe", new String[][]{{"axe", "gol"}}, Material.GOLD_AXE));
items.add(new ItemInfo("String", new String[][]{{"stri"}}, Material.STRING));
items.add(new ItemInfo("Feather", new String[][]{{"feat"}}, Material.FEATHER));
items.add(new ItemInfo("Gunpowder", new String[][]{{"gun"}, {"sulph"}}, Material.SULPHUR));
items.add(new ItemInfo("Wooden Hoe", new String[][]{{"hoe", "wo"}}, Material.WOOD_HOE));
items.add(new ItemInfo("Stone Hoe", new String[][]{{"hoe", "sto"}}, Material.STONE_HOE));
items.add(new ItemInfo("Iron Hoe", new String[][]{{"hoe", "iro"}}, Material.IRON_HOE));
items.add(new ItemInfo("Diamond Hoe", new String[][]{{"hoe", "dia"}}, Material.DIAMOND_HOE));
items.add(new ItemInfo("Gold Hoe", new String[][]{{"hoe", "go"}}, Material.GOLD_HOE));
items.add(new ItemInfo("Seeds", new String[][]{{"seed"}}, Material.SEEDS));
items.add(new ItemInfo("Wheat", new String[][]{{"whea"}}, Material.WHEAT));
items.add(new ItemInfo("Bread", new String[][]{{"brea"}}, Material.BREAD));
items.add(new ItemInfo("Leather Cap", new String[][]{{"cap", "lea"}, {"hat", "lea"}, {"helm", "lea"}}, Material.LEATHER_HELMET));
items.add(new ItemInfo("Leather Tunic", new String[][]{{"tun", "lea"}, {"ches", "lea"}}, Material.LEATHER_CHESTPLATE));
items.add(new ItemInfo("Leather Pants", new String[][]{{"pan", "lea"}, {"trou", "lea"}, {"leg", "lea"}}, Material.LEATHER_LEGGINGS));
items.add(new ItemInfo("Leather Boots", new String[][]{{"boo", "lea"}}, Material.LEATHER_BOOTS));
items.add(new ItemInfo("Chainmail Helmet", new String[][]{{"cap", "cha"}, {"hat", "cha"}, {"helm", "cha"}}, Material.CHAINMAIL_HELMET));
items.add(new ItemInfo("Chainmail Chestplate", new String[][]{{"tun", "cha"}, {"ches", "cha"}}, Material.CHAINMAIL_CHESTPLATE));
items.add(new ItemInfo("Chainmail Leggings", new String[][]{{"pan", "cha"}, {"trou", "cha"}, {"leg", "cha"}}, Material.CHAINMAIL_LEGGINGS));
items.add(new ItemInfo("Chainmail Boots", new String[][]{{"boo", "cha"}}, Material.CHAINMAIL_BOOTS));
items.add(new ItemInfo("Iron Helmet", new String[][]{{"cap", "ir"}, {"hat", "ir"}, {"helm", "ir"}}, Material.IRON_HELMET));
items.add(new ItemInfo("Iron Chestplate", new String[][]{{"tun", "ir"}, {"ches", "ir"}}, Material.IRON_CHESTPLATE));
items.add(new ItemInfo("Iron Leggings", new String[][]{{"pan", "ir"}, {"trou", "ir"}, {"leg", "ir"}}, Material.IRON_LEGGINGS));
items.add(new ItemInfo("Iron Boots", new String[][]{{"boo", "ir"}}, Material.IRON_BOOTS));
items.add(new ItemInfo("Diamond Helmet", new String[][]{{"cap", "dia"}, {"hat", "dia"}, {"helm", "dia"}}, Material.DIAMOND_HELMET));
items.add(new ItemInfo("Diamond Chestplate", new String[][]{{"tun", "dia"}, {"ches", "dia"}}, Material.DIAMOND_CHESTPLATE));
items.add(new ItemInfo("Diamond Leggings", new String[][]{{"pan", "dia"}, {"trou", "dia"}, {"leg", "dia"}}, Material.DIAMOND_LEGGINGS));
items.add(new ItemInfo("Diamond Boots", new String[][]{{"boo", "dia"}}, Material.DIAMOND_BOOTS));
items.add(new ItemInfo("Gold Helmet", new String[][]{{"cap", "go"}, {"hat", "go"}, {"helm", "go"}}, Material.GOLD_HELMET));
items.add(new ItemInfo("Gold Chestplate", new String[][]{{"tun", "go"}, {"ches", "go"}}, Material.GOLD_CHESTPLATE));
items.add(new ItemInfo("Gold Leggings", new String[][]{{"pan", "go"}, {"trou", "go"}, {"leg", "go"}}, Material.GOLD_LEGGINGS));
items.add(new ItemInfo("Gold Boots", new String[][]{{"boo", "go"}}, Material.GOLD_BOOTS));
items.add(new ItemInfo("Flint", new String[][]{{"flin"}}, Material.FLINT));
items.add(new ItemInfo("Raw Porkchop", new String[][]{{"pork"}, {"ham"}}, Material.PORK));
items.add(new ItemInfo("Cooked Porkchop", new String[][]{{"pork", "cook"}, {"baco"}}, Material.GRILLED_PORK));
items.add(new ItemInfo("Paintings", new String[][]{{"paint"}}, Material.PAINTING));
items.add(new ItemInfo("Golden Apple", new String[][]{{"appl", "go"}}, Material.GOLDEN_APPLE));
items.add(new ItemInfo("Sign", new String[][]{{"sign"}}, Material.SIGN));
items.add(new ItemInfo("Wooden Door", new String[][]{{"door", "wood"}, {"door"}}, Material.WOOD_DOOR));
items.add(new ItemInfo("Bucket", new String[][]{{"buck"}, {"bukk"}}, Material.BUCKET));
items.add(new ItemInfo("Water Bucket", new String[][]{{"water", "buck"}}, Material.WATER_BUCKET));
items.add(new ItemInfo("Lava Bucket", new String[][]{{"lava", "buck"}}, Material.LAVA_BUCKET));
items.add(new ItemInfo("Minecart", new String[][]{{"cart"}}, Material.MINECART));
items.add(new ItemInfo("Saddle", new String[][]{{"sad"}, {"pig"}}, Material.SADDLE));
items.add(new ItemInfo("Iron Door", new String[][]{{"door", "iron"}}, Material.IRON_DOOR));
items.add(new ItemInfo("Redstone Dust", new String[][]{{"red", "ston", "dust"}, {"dust", "rs"}, {"dust", "red"}, {"reds"}}, Material.REDSTONE));
items.add(new ItemInfo("Snowball", new String[][]{{"snow", "ball"}}, Material.SNOW_BALL));
items.add(new ItemInfo("Boat", new String[][]{{"boat"}}, Material.BOAT));
items.add(new ItemInfo("Leather", new String[][]{{"lea"}, {"hide"}}, Material.LEATHER));
items.add(new ItemInfo("Milk Bucket", new String[][]{{"buck", "mil"}, {"milk"}}, Material.MILK_BUCKET));
items.add(new ItemInfo("Clay Brick", new String[][]{{"bric", "cl"}, {"sin", "bric"}}, Material.CLAY_BRICK));
items.add(new ItemInfo("Clay", new String[][]{{"clay"}}, Material.CLAY_BALL));
items.add(new ItemInfo("Sugar Cane", new String[][]{{"reed"}, {"cane"}}, Material.SUGAR_CANE));
items.add(new ItemInfo("Paper", new String[][]{{"pape"}}, Material.PAPER));
items.add(new ItemInfo("Book", new String[][]{{"book"}}, Material.BOOK));
items.add(new ItemInfo("Slimeball", new String[][]{{"slime"}}, Material.SLIME_BALL));
items.add(new ItemInfo("Storage Minecart", new String[][]{{"cart", "sto"}, {"cart", "che"}, {"cargo"}}, Material.STORAGE_MINECART));
items.add(new ItemInfo("Powered Minecart", new String[][]{{"cart", "pow"}, {"engine"}}, Material.POWERED_MINECART));
items.add(new ItemInfo("Egg", new String[][]{{"egg"}}, Material.EGG));
items.add(new ItemInfo("Compass", new String[][]{{"comp"}}, Material.COMPASS));
items.add(new ItemInfo("Fishing Rod", new String[][]{{"rod"}, {"rod", "fish"}, {"pole", "fish"}}, Material.FISHING_ROD));
items.add(new ItemInfo("Clock", new String[][]{{"cloc"}, {"watc"}}, Material.WATCH));
items.add(new ItemInfo("Glowstone Dust", new String[][]{{"glow", "sto", "dus"}, {"glow", "dus"}, {"ligh", "dust"}}, Material.GLOWSTONE_DUST));
items.add(new ItemInfo("Raw Fish", new String[][]{{"fish"}, {"fish", "raw"}}, Material.RAW_FISH));
items.add(new ItemInfo("Cooked Fish", new String[][]{{"fish", "coo"}, {"kipper"}}, Material.COOKED_FISH));
items.add(new ItemInfo("Ink Sac", new String[][]{{"ink"}, {"dye", "bla"}}, Material.INK_SACK));
items.add(new ItemInfo("Red Dye", new String[][]{{"dye", "red"}, {"pain", "red"}, {"pet", "ros"}, {"pet", "red"}}, Material.INK_SACK, (short) 1));
items.add(new ItemInfo("Cactus Green", new String[][]{{"cact", "gree"}, {"dye", "gree"}, {"pain", "gree"}}, Material.INK_SACK, (short) 2));
items.add(new ItemInfo("Cocoa Beans", new String[][]{{"bean"}, {"choco"}, {"cocoa"}, {"dye", "bro"}, {"pain", "bro"}}, Material.INK_SACK, (short) 3));
items.add(new ItemInfo("Lapis Lazuli", new String[][]{{"lapi", "lazu"}, {"dye", "lapi"}, {"dye", "blu"}, {"pain", "blu"}}, Material.INK_SACK, (short) 4));
items.add(new ItemInfo("Purple Dye", new String[][]{{"dye", "pur"}, {"pain", "pur"}}, Material.INK_SACK, (short) 5));
items.add(new ItemInfo("Cyan Dye", new String[][]{{"dye", "cya"}, {"pain", "cya"}}, Material.INK_SACK, (short) 6));
items.add(new ItemInfo("Light Gray Dye", new String[][]{{"dye", "lig", "gra"}, {"dye", "lig", "grey"}, {"pain", "lig", "grey"}, {"pain", "lig", "grey"}}, Material.INK_SACK, (short) 7));
items.add(new ItemInfo("Gray Dye", new String[][]{{"dye", "gra"}, {"dye", "grey"}, {"pain", "grey"}, {"pain", "grey"}}, Material.INK_SACK, (short) 8));
items.add(new ItemInfo("Pink Dye", new String[][]{{"dye", "pin"}, {"pain", "pin"}}, Material.INK_SACK, (short) 9));
items.add(new ItemInfo("Lime Dye", new String[][]{{"dye", "lim"}, {"pain", "lim"}, {"dye", "lig", "gree"}, {"pain", "lig", "gree"}}, Material.INK_SACK, (short) 10));
items.add(new ItemInfo("Dandelion Yellow", new String[][]{{"dye", "yel"}, {"yel", "dan"}, {"pet", "dan"}, {"pet", "yel"}}, Material.INK_SACK, (short) 11));
items.add(new ItemInfo("Light Blue Dye", new String[][]{{"dye", "lig", "blu"}, {"pain", "lig", "blu"}}, Material.INK_SACK, (short) 12));
items.add(new ItemInfo("Magenta Dye", new String[][]{{"dye", "mag"}, {"pain", "mag"}}, Material.INK_SACK, (short) 13));
items.add(new ItemInfo("Orange Dye", new String[][]{{"dye", "ora"}, {"pain", "ora"}}, Material.INK_SACK, (short) 14));
items.add(new ItemInfo("Bone Meal", new String[][]{{"bonem"}, {"bone", "me"}, {"dye", "whi"}, {"pain", "whi"}}, Material.INK_SACK, (short) 15));
items.add(new ItemInfo("Bone", new String[][]{{"bone"}, {"femur"}}, Material.BONE));
items.add(new ItemInfo("Sugar", new String[][]{{"suga"}}, Material.SUGAR));
items.add(new ItemInfo("Cake", new String[][]{{"cake"}}, Material.CAKE));
items.add(new ItemInfo("Melon Slice", new String[][]{{"sli", "melo"}}, Material.MELON));
items.add(new ItemInfo("Pumpkin Seed", new String[][]{{"seed", "pump"}}, Material.PUMPKIN_SEEDS));
items.add(new ItemInfo("Melon Seed", new String[][]{{"seed", "melo"}}, Material.MELON_SEEDS));
items.add(new ItemInfo("Raw Beef", new String[][]{{"beef", "raw"}}, Material.RAW_BEEF));
items.add(new ItemInfo("Steak", new String[][]{{"steak"}, {"beef", "coo"}}, Material.COOKED_BEEF));
items.add(new ItemInfo("Raw Chicken", new String[][]{{"chi", "raw"}}, Material.RAW_CHICKEN));
items.add(new ItemInfo("Cooked Chicken", new String[][]{{"chi", "coo"}}, Material.COOKED_CHICKEN));
items.add(new ItemInfo("Rotten Flesh", new String[][]{{"flesh"}, {"rott"}}, Material.ROTTEN_FLESH));
items.add(new ItemInfo("Bed", new String[][]{{"bed"}}, Material.BED));
items.add(new ItemInfo("Redstone Repeater", new String[][]{{"repe", "reds"}, {"diod"}, {"repeat"}}, Material.DIODE));
items.add(new ItemInfo("Cookie", new String[][]{{"cooki"}}, Material.COOKIE));
items.add(new ItemInfo("Map", new String[][]{{"map"}}, Material.MAP));
items.add(new ItemInfo("Empty Map", new String[][]{{"empt", "ma"}}, Material.EMPTY_MAP));
items.add(new ItemInfo("Shears", new String[][]{{"shea"}}, Material.SHEARS));
items.add(new ItemInfo("Ender Pearl", new String[][]{{"end", "pear"}, {"pearl"}}, Material.ENDER_PEARL));
items.add(new ItemInfo("Mycelium", new String[][]{{ "myc" }}, Material.MYCEL));
items.add(new ItemInfo("Lily Pad", new String[][]{{"lil", "pad"}, {"lil", "wat"}}, Material.WATER_LILY));
items.add(new ItemInfo("Cauldron Block", new String[][]{{ "bloc", "cauld"}}, Material.CAULDRON));
items.add(new ItemInfo("Cauldron", new String[][]{{"cauld"}}, Material.CAULDRON_ITEM));
items.add(new ItemInfo("Enchantment Table", new String[][]{{"ench", "tab"}}, Material.ENCHANTMENT_TABLE));
items.add(new ItemInfo("Brewing Stand Block", new String[][] {{ "bloc", "brew", "stan" }, {"alch", "bloc"}}, Material.BREWING_STAND));
items.add(new ItemInfo("Brewing Stand", new String[][] {{"brew", "stan"}, {"alch", "stand"}, {"alch", "tab"}}, Material.BREWING_STAND_ITEM));
items.add(new ItemInfo("Nether Brick", new String[][] {{"neth", "bric"}}, Material.NETHER_BRICK));
items.add(new ItemInfo("Nether Brick Stairs", new String[][] {{"neth", "stair"}, {"neth", "stai", "bric"}}, Material.NETHER_BRICK_STAIRS));
items.add(new ItemInfo("Nether Brick Fence", new String[][]{{"neth", "fence"}, {"neth", "fence", "bric"}}, Material.NETHER_FENCE));
items.add(new ItemInfo("Netherwarts", new String[][]{{"wart"}, {"neth", "war"}}, Material.NETHER_WARTS));
items.add(new ItemInfo("Netherstalk", new String[][]{{"neth", "stalk"}}, Material.NETHER_STALK));
items.add(new ItemInfo("End Portal", new String[][] {{"end", "port"}}, Material.ENDER_PORTAL));
items.add(new ItemInfo("End Portal Frame", new String[][] {{"fram", "end", "port"}}, Material.ENDER_PORTAL_FRAME));
items.add(new ItemInfo("End Stone", new String[][] {{"end", "ston"}}, Material.ENDER_STONE));
items.add(new ItemInfo("Dragon Egg", new String[][] {{"drag", "egg"}}, Material.DRAGON_EGG));
items.add(new ItemInfo("Blaze Rod", new String[][] {{"rod", "blaz"}}, Material.BLAZE_ROD));
items.add(new ItemInfo("Ghast Tear", new String[][] {{"ghas", "tear"}}, Material.GHAST_TEAR));
items.add(new ItemInfo("Gold Nugget", new String[][] {{"nugg", "gold"}}, Material.GOLD_NUGGET));
items.add(new ItemInfo("Glass Bottle", new String[][] {{"bottl"}, {"glas", "bott"}, {"empt", "bott"}}, Material.GLASS_BOTTLE));
items.add(new ItemInfo("Potion", new String[][] {{"potio"}}, Material.POTION));
items.add(new ItemInfo("Water Bottle", new String[][] {{"wat", "bot"}}, Material.POTION, (short) 0));
items.add(new ItemInfo("Awkward Potion", new String[][] {{"poti", "awk"}}, Material.POTION, (short) 16));
items.add(new ItemInfo("Thick Potion", new String[][] {{"poti", "thic"}}, Material.POTION, (short) 32));
items.add(new ItemInfo("Mundane Potion (Extended)", new String[][] {{"poti", "mund", "ext"}}, Material.POTION, (short) 64));
items.add(new ItemInfo("Mundane Potion", new String[][] {{"poti", "mund"}}, Material.POTION, (short) 8192));
items.add(new ItemInfo("Potion of Regeneration", new String[][] {{"poti", "rege"}}, Material.POTION, (short) 8193));
items.add(new ItemInfo("Potion of Regeneration (Extended)", new String[][] {{"poti", "rege", "ext"}}, Material.POTION, (short) 8257));
items.add(new ItemInfo("Potion of Regeneration II", new String[][] {{"poti", "rege", "2"}, {"poti", "rege", "ii"}}, Material.POTION, (short) 8225));
items.add(new ItemInfo("Potion of Swiftness", new String[][] {{"poti", "swif"}, {"poti", "speed"}}, Material.POTION, (short) 8194));
items.add(new ItemInfo("Potion of Swiftness (Extended)", new String[][] {{"poti", "swif", "ext"}, {"poti", "speed", "ext"}}, Material.POTION, (short) 8258));
items.add(new ItemInfo("Potion of Swiftness II", new String[][] {{"poti", "swif", "2"}, {"poti", "swif", "ii"}, {"poti", "speed", "2"}, {"poti", "speed", "ii"}}, Material.POTION, (short) 8226));
items.add(new ItemInfo("Potion of Fire Resistance", new String[][] {{"poti", "fire"}}, Material.POTION, (short) 8195));
items.add(new ItemInfo("Potion of Fire Resistance (Extended)", new String[][] {{"poti", "fire", "ext"}}, Material.POTION, (short) 8259));
items.add(new ItemInfo("Potion of Fire Resistance (Reverted)", new String[][] {{"poti", "fire", "rev"}}, Material.POTION, (short) 8227));
items.add(new ItemInfo("Potion of Healing", new String[][] {{"poti", "heal"}}, Material.POTION, (short) 8197));
items.add(new ItemInfo("Potion of Healing (Reverted)", new String[][] {{"poti", "heal", "rev"}}, Material.POTION, (short) 8261));
items.add(new ItemInfo("Potion of Healing II", new String[][] {{"poti", "heal", "2"}, {"poti", "heal", "ii"}}, Material.POTION, (short) 8229));
items.add(new ItemInfo("Potion of Strength", new String[][] {{"poti", "str"}}, Material.POTION, (short) 8201));
items.add(new ItemInfo("Potion of Strength (Extended)", new String[][] {{"poti", "str", "ext"}}, Material.POTION, (short) 8265));
items.add(new ItemInfo("Potion of Strength II", new String[][] {{"poti", "str", "2"}, {"poti", "str", "ii"}}, Material.POTION, (short) 8233));
items.add(new ItemInfo("Potion of Poison", new String[][] {{"poti", "pois"}}, Material.POTION, (short) 8196));
items.add(new ItemInfo("Potion of Poison (Extended)", new String[][] {{"poti", "pois", "ext"}}, Material.POTION, (short) 8260));
items.add(new ItemInfo("Potion of Poison II", new String[][] {{"poti", "pois", "2"}, {"poti", "pois", "ii"}}, Material.POTION, (short) 8228));
items.add(new ItemInfo("Potion of Weakness", new String[][] {{"poti", "weak"}}, Material.POTION, (short) 8200));
items.add(new ItemInfo("Potion of Weakness (Extended)", new String[][] {{"poti", "weak", "ext"}}, Material.POTION, (short) 8264));
items.add(new ItemInfo("Potion of Weakness (Reverted)", new String[][] {{"poti", "weak", "rev"}}, Material.POTION, (short) 8232));
items.add(new ItemInfo("Potion of Slowness", new String[][] {{"poti", "slow"}}, Material.POTION, (short) 8202));
items.add(new ItemInfo("Potion of Slowness (Extended)", new String[][] {{"poti", "slow", "ext"}}, Material.POTION, (short) 8266));
items.add(new ItemInfo("Potion of Slowness (Reverted)", new String[][] {{"poti", "slow", "rev"}}, Material.POTION, (short) 8234));
items.add(new ItemInfo("Potion of Harming", new String[][] {{"poti", "harm"}}, Material.POTION, (short) 8204));
items.add(new ItemInfo("Potion of Harming (Reverted)", new String[][] {{"poti", "harm", "rev"}}, Material.POTION, (short) 8268));
items.add(new ItemInfo("Potion of Harming II", new String[][] {{"poti", "harm", "2"}, {"poti", "harm", "ii"}}, Material.POTION, (short) 8236));
items.add(new ItemInfo("Splash Mundane Potion", new String[][] {{"poti", "mund", "spl"}}, Material.POTION, (short) 16384));
items.add(new ItemInfo("Splash Potion of Regeneration", new String[][] {{"poti", "rege", "spl"}}, Material.POTION, (short) 16385));
items.add(new ItemInfo("Splash Potion of Regeneration (Extended)", new String[][] {{"poti", "rege", "spl", "ext"}}, Material.POTION, (short) 16449));
items.add(new ItemInfo("Splash Potion of Regeneration II", new String[][] {{"poti", "rege", "spl", "2"}, {"poti", "rege", "spl", "ii"}}, Material.POTION, (short) 16417));
items.add(new ItemInfo("Splash Potion of Swiftness", new String[][] {{"poti", "swif", "spl"}, {"poti", "speed", "spl"}}, Material.POTION, (short) 16386));
items.add(new ItemInfo("Splash Potion of Swiftness (Extended)", new String[][] {{"poti", "swif", "spl", "ext"}, {"poti", "speed", "spl", "ext"}}, Material.POTION, (short) 16450));
items.add(new ItemInfo("Splash Potion of Swiftness II", new String[][] {{"poti", "swif", "spl", "2"}, {"poti", "swif", "spl", "ii"}, {"poti", "speed", "spl", "2"}, {"poti", "speed", "spl", "ii"}}, Material.POTION, (short) 16418));
items.add(new ItemInfo("Splash Potion of Fire Resistance", new String[][] {{"poti", "fire", "spl"}}, Material.POTION, (short) 16387));
items.add(new ItemInfo("Splash Potion of Fire Resistance (Extended)", new String[][] {{"poti", "fire", "spl", "ext"}}, Material.POTION, (short) 16451));
items.add(new ItemInfo("Splash Potion of Fire Resistance (Reverted)", new String[][] {{"poti", "fire", "spl", "rev"}}, Material.POTION, (short) 16419));
items.add(new ItemInfo("Splash Potion of Healing", new String[][] {{"poti", "heal", "spl"}}, Material.POTION, (short) 16389));
items.add(new ItemInfo("Splash Potion of Healing (Reverted)", new String[][] {{"poti", "heal", "spl", "rev"}}, Material.POTION, (short) 16453));
items.add(new ItemInfo("Splash Potion of Healing II", new String[][] {{"poti", "heal", "spl", "2"}, {"poti", "heal", "spl", "ii"}}, Material.POTION, (short) 16421));
items.add(new ItemInfo("Splash Potion of Strength", new String[][] {{"poti", "str", "spl"}}, Material.POTION, (short) 16393));
items.add(new ItemInfo("Splash Potion of Strength (Extended)", new String[][] {{"poti", "str", "spl", "ext"}}, Material.POTION, (short) 16457));
items.add(new ItemInfo("Splash Potion of Strength II", new String[][] {{"poti", "str", "spl", "2"}, {"poti", "str", "spl", "ii"}}, Material.POTION, (short) 16425));
items.add(new ItemInfo("Splash Potion of Poison", new String[][] {{"poti", "pois", "spl"}}, Material.POTION, (short) 16388));
items.add(new ItemInfo("Splash Potion of Poison (Extended)", new String[][] {{"poti", "pois", "spl", "ext"}}, Material.POTION, (short) 16452));
items.add(new ItemInfo("Splash Potion of Poison II", new String[][] {{"poti", "pois", "spl", "2"}, {"poti", "pois", "spl", "ii"}}, Material.POTION, (short) 16420));
items.add(new ItemInfo("Splash Potion of Weakness", new String[][] {{"poti", "weak", "spl"}}, Material.POTION, (short) 16392));
items.add(new ItemInfo("Splash Potion of Weakness (Extended)", new String[][] {{"poti", "weak", "spl", "ext"}}, Material.POTION, (short) 16456));
items.add(new ItemInfo("Splash Potion of Weakness (Reverted)", new String[][] {{"poti", "weak", "spl", "rev"}}, Material.POTION, (short) 16424));
items.add(new ItemInfo("Splash Potion of Slowness", new String[][] {{"poti", "slow", "spl"}}, Material.POTION, (short) 16394));
items.add(new ItemInfo("Splash Potion of Slowness (Extended)", new String[][] {{"poti", "slow", "spl", "ext"}}, Material.POTION, (short) 16458));
items.add(new ItemInfo("Splash Potion of Slowness (Reverted)", new String[][] {{"poti", "slow", "spl", "rev"}}, Material.POTION, (short) 16426));
items.add(new ItemInfo("Splash Potion of Harming", new String[][] {{"poti", "harm", "spl"}}, Material.POTION, (short) 16396));
items.add(new ItemInfo("Splash Potion of Harming (Reverted)", new String[][] {{"poti", "harm", "spl", "rev"}}, Material.POTION, (short) 16460));
items.add(new ItemInfo("Splash Potion of Harming II", new String[][] {{"poti", "harm", "spl", "2"}, {"poti", "harm", "spl", "ii"}}, Material.POTION, (short) 16428));
items.add(new ItemInfo("Spider Eye", new String[][] {{"spid", "eye"}}, Material.SPIDER_EYE));
items.add(new ItemInfo("Fermented Spider Eye", new String[][] {{"ferm", "spid", "eye"}}, Material.FERMENTED_SPIDER_EYE));
items.add(new ItemInfo("Blaze Powder", new String[][] {{"powd", "blaz"}}, Material.BLAZE_POWDER));
items.add(new ItemInfo("Magma Cream", new String[][] {{"crea", "magm"}}, Material.MAGMA_CREAM));
items.add(new ItemInfo("Eye of Ender", new String[][] {{"end", "ey"}}, Material.EYE_OF_ENDER));
items.add(new ItemInfo("Glistering Melon", new String[][] {{"melo", "glis"}}, Material.SPECKLED_MELON));
items.add(new ItemInfo("Spawn Egg", new String[][] {{"spaw", "egg"}}, Material.MONSTER_EGG));
items.add(new ItemInfo("Creeper Spawn Egg", new String[][] {{"creep", "egg"}}, Material.MONSTER_EGG, (short) 50));
items.add(new ItemInfo("Skeleton Spawn Egg", new String[][] {{"skele", "egg"}}, Material.MONSTER_EGG, (short) 51));
items.add(new ItemInfo("Spider Spawn Egg", new String[][] {{"spider", "egg"}}, Material.MONSTER_EGG, (short) 52));
items.add(new ItemInfo("Zombie Spawn Egg", new String[][] {{"zombie", "egg"}}, Material.MONSTER_EGG, (short) 54));
items.add(new ItemInfo("Slime Spawn Egg", new String[][] {{"slime", "egg"}}, Material.MONSTER_EGG, (short) 55));
items.add(new ItemInfo("Ghast Spawn Egg", new String[][] {{"ghast", "egg"}}, Material.MONSTER_EGG, (short) 56));
items.add(new ItemInfo("Zombie Pigman Spawn Egg", new String[][] {{"zomb", "pig", "egg"}}, Material.MONSTER_EGG, (short) 57));
items.add(new ItemInfo("Enderman Spawn Egg", new String[][] {{"end", "man", "egg"}}, Material.MONSTER_EGG, (short) 58));
items.add(new ItemInfo("Cave Spider Spawn Egg", new String[][] {{"cav", "spid", "egg"}}, Material.MONSTER_EGG, (short) 59));
items.add(new ItemInfo("Silverfish Spawn Egg", new String[][] {{"silv", "fish", "egg"}}, Material.MONSTER_EGG, (short) 60));
items.add(new ItemInfo("Blaze Spawn Egg", new String[][] {{"blaze", "egg"}}, Material.MONSTER_EGG, (short) 61));
items.add(new ItemInfo("Magma Cube Spawn Egg", new String[][] {{"mag", "cub", "egg"}, {"neth", "slim", "egg"}}, Material.MONSTER_EGG, (short)62));
items.add(new ItemInfo("Pig Spawn Egg", new String[][] {{"pig", "spa", "egg"}, {"pig", "egg"}}, Material.MONSTER_EGG, (short) 90));
items.add(new ItemInfo("Sheep Spawn Egg", new String[][] {{"sheep", "egg"}}, Material.MONSTER_EGG, (short) 91));
items.add(new ItemInfo("Cow Spawn Egg", new String[][] {{"cow", "spa", "egg"}, {"cow", "egg"}}, Material.MONSTER_EGG, (short) 92));
items.add(new ItemInfo("Chicken Spawn Egg", new String[][] {{"chick", "egg"}}, Material.MONSTER_EGG, (short) 93));
items.add(new ItemInfo("Squid Spawn Egg", new String[][] {{"squi", "spa", "egg"},{"squi", "egg"}}, Material.MONSTER_EGG, (short) 94));
items.add(new ItemInfo("Wolf Spawn Egg", new String[][] {{"wolf", "spa", "egg"}, {"wolf", "egg"}}, Material.MONSTER_EGG, (short) 95));
items.add(new ItemInfo("Mooshroom Spawn Egg", new String[][] {{"moo", "room", "egg"}, {"mush", "cow", "egg"}}, Material.MONSTER_EGG, (short) 96));
items.add(new ItemInfo("Ocelot Spawn Egg", new String[][] {{"ocelo", "egg"}, {"ozelo", "egg"}}, Material.MONSTER_EGG, (short) 98));
items.add(new ItemInfo("Villager Spawn Egg", new String[][] {{"villa", "egg"}}, Material.MONSTER_EGG, (short) 120));
items.add(new ItemInfo("Bottle 'o Enchanting", new String[][] {{"bot", "ench"}, {"bot", "xp"}}, Material.EXP_BOTTLE));
items.add(new ItemInfo("Fire Charge", new String[][] {{"fir", "char"}}, Material.FIREBALL));
items.add(new ItemInfo("13 Disc", new String[][]{{"dis", "gol"}, {"rec", "gol"}, {"13", "disc"}, {"13", "reco"}}, Material.GOLD_RECORD));
items.add(new ItemInfo("cat Disc", new String[][]{{"dis", "gre"}, {"rec", "gre"}, {"cat", "disc"}, {"cat", "reco"}}, Material.GREEN_RECORD));
items.add(new ItemInfo("blocks Disc", new String[][] {{"block", "disc"}, {"block", "reco"}, {"3", "disc"}, {"3", "reco"}}, Material.RECORD_3));
items.add(new ItemInfo("chirp Disc", new String[][] {{"chirp", "disc"}, {"chirp", "reco"}, {"4", "disc"}, {"4", "reco"}}, Material.RECORD_4));
items.add(new ItemInfo("far Disc", new String[][] {{"far", "disc"}, {"far", "reco"}, {"5", "disc"}, {"5", "reco"}}, Material.RECORD_5));
items.add(new ItemInfo("mall Disc", new String[][] {{"mall", "disc"}, {"mall", "reco"}, {"6", "disc"}, {"6", "reco"}}, Material.RECORD_6));
items.add(new ItemInfo("mellohi Disc", new String[][] {{"mello", "disc"}, {"mello", "reco"}, {"7", "disc"}, {"7", "reco"}}, Material.RECORD_7));
items.add(new ItemInfo("stahl Disc", new String[][] {{"stahl", "disc"}, {"stahl", "reco"}, {"8", "disc"}, {"8", "reco"}}, Material.RECORD_8));
items.add(new ItemInfo("strad Disc", new String[][] {{"strad", "disc"}, {"strad", "reco"}, {"9", "disc"}, {"9", "reco"}}, Material.RECORD_9));
items.add(new ItemInfo("ward Disc", new String[][] {{"ward", "disc"}, {"ward", "reco"}, {"10", "disc"}, {"10", "reco"}}, Material.RECORD_10));
items.add(new ItemInfo("11 Disc", new String[][] {{"11", "disc"}, {"11", "reco"}}, Material.RECORD_11));
items.add(new ItemInfo("wait Disc", new String[][] {{"12", "disc"}, {"wait", "disc"}, {"12", "reco"}, {"wait", "reco"}}, Material.RECORD_12));
items.add(new ItemInfo("Redstone Lamp", new String[][] {{"lamp"}, {"lamp", "redst"}}, Material.REDSTONE_LAMP_OFF));
items.add(new ItemInfo("Redstone Torch Off", new String[][] {{"off", "red", "sto", "tor"}}, Material.REDSTONE_TORCH_OFF));
//1.3 Blocks & Items
items.add(new ItemInfo("Emerald Ore", new String[][]{{"emer", "ore"}}, Material.EMERALD_ORE));
items.add(new ItemInfo("Emerald", new String[][]{{"emer"}}, Material.EMERALD));
items.add(new ItemInfo("Emerald Block", new String[][]{{"emer", "blo"}}, Material.EMERALD_BLOCK));
items.add(new ItemInfo("Ender Chest", new String[][]{{"end", "ches"}}, Material.ENDER_CHEST));
items.add(new ItemInfo("Tripwire Hook", new String[][]{{"hoo", "trip"}}, Material.TRIPWIRE_HOOK));
items.add(new ItemInfo("Tripwire", new String[][]{{"trip"}}, Material.TRIPWIRE));
items.add(new ItemInfo("Sandstone Stair", new String[][]{{"stair", "sand", "sto"}, {"stair", "sand"}}, Material.SANDSTONE_STAIRS));
items.add(new ItemInfo("Double Oak Slab", new String[][]{{"doub", "slab", "oak"}, {"doub", "step", "oak"}}, Material.WOOD_DOUBLE_STEP));
items.add(new ItemInfo("Double Spruce Slab", new String[][]{{"doub", "slab", "spru"}, {"doub", "step", "spru"}}, Material.WOOD_DOUBLE_STEP, (short) 1));
items.add(new ItemInfo("Double Birch Slab", new String[][]{{"doub", "slab", "birc"}, {"doub", "step", "birc"}}, Material.WOOD_DOUBLE_STEP, (short) 2));
items.add(new ItemInfo("Double Jungle Wood Slab", new String[][]{{"doub", "slab", "jungl"}, {"doub", "step", "jung"}}, Material.WOOD_DOUBLE_STEP, (short) 3));
items.add(new ItemInfo("Oak Slab", new String[][]{{"slab", "oak"}, {"step", "oak"}}, Material.WOOD_STEP));
items.add(new ItemInfo("Spruce Slab", new String[][]{{"slab", "spru"}, {"step", "spru"}}, Material.WOOD_STEP, (short) 1));
items.add(new ItemInfo("Birch Slab", new String[][]{{"slab", "birc"}, {"step", "birc"}}, Material.WOOD_STEP, (short) 2));
items.add(new ItemInfo("Jungle Wood Slab", new String[][]{{"jung", "wood", "sla"}, {"slab", "jung"}, {"step", "jung"}}, Material.WOOD_STEP, (short) 3));
items.add(new ItemInfo("Book and Quill", new String[][]{{"qui", "book"}}, Material.BOOK_AND_QUILL));
items.add(new ItemInfo("Written Book", new String[][]{{"wri", "book"}}, Material.WRITTEN_BOOK));
items.add(new ItemInfo("Cocoa Pod", new String[][]{{"coco"}, {"coc", "pod"}}, Material.COCOA));
//1.4 Blocks & Items
items.add(new ItemInfo("Command Block", new String[][]{{"comm"}}, Material.COMMAND));
items.add(new ItemInfo("Beacon Block", new String[][]{{"beac"}}, Material.BEACON));
items.add(new ItemInfo("Anvil", new String[][]{{"anv"}}, Material.ANVIL));
items.add(new ItemInfo("Slightly Damaged Anvil", new String[][]{{"dam", "anv"}, {"sli", "anv"}}, Material.ANVIL, (short) 1));
items.add(new ItemInfo("Very Damaged Anvil", new String[][]{{"ver", "dam", "anv"}, {"ver", "anv"}}, Material.ANVIL, (short) 2));
items.add(new ItemInfo("Flower Pot Block", new String[][]{{"blo", "flow", "pot"}}, Material.FLOWER_POT));
items.add(new ItemInfo("Flower Pot", new String[][]{{"flow", "pot"}}, Material.FLOWER_POT_ITEM));
items.add(new ItemInfo("Cobblestone Wall", new String[][]{{"cobble", "wall"}}, Material.COBBLE_WALL));
items.add(new ItemInfo("Mossy Cobblestone Wall", new String[][]{{"mos", "cob", "wall"}}, Material.COBBLE_WALL, (short) 1));
items.add(new ItemInfo("Item Frame", new String[][]{{"fram"}}, Material.ITEM_FRAME));
items.add(new ItemInfo("Skeleton Skull", new String[][]{{"skel", "skul"}, {"skel", "hea"}}, Material.SKULL_ITEM));
items.add(new ItemInfo("Wither Skeleton Skull", new String[][]{{"wither", "skul"}, {"with", "hea"}}, Material.SKULL_ITEM, (short) 1));
items.add(new ItemInfo("Zombie Head", new String[][]{{"zomb", "hea"}, {"zomb", "skul"}}, Material.SKULL_ITEM, (short) 2));
items.add(new ItemInfo("Human Head", new String[][]{{"huma", "skul"}, {"huma", "hea"}}, Material.SKULL_ITEM, (short) 3));
items.add(new ItemInfo("Creeper Head", new String[][]{{"cree", "skul"}, {"cree", "hea"}}, Material.SKULL_ITEM, (short) 4));
items.add(new ItemInfo("Carrot", new String[][]{{"carro"}}, Material.CARROT_ITEM));
items.add(new ItemInfo("Golden Carrot", new String[][]{{"carr", "gol"}}, Material.GOLDEN_CARROT));
items.add(new ItemInfo("Carrot Block", new String[][]{{"blo", "carr"}}, Material.CARROT));
items.add(new ItemInfo("Carrot on a Stick", new String[][]{{"sti", "carr"}}, Material.CARROT_STICK));
items.add(new ItemInfo("Potato", new String[][]{{"pota"}}, Material.POTATO_ITEM));
items.add(new ItemInfo("Potato Block", new String[][]{{"blo", "pota"}}, Material.POTATO));
items.add(new ItemInfo("Baked Potato", new String[][]{{"pota", "bak"}}, Material.BAKED_POTATO));
items.add(new ItemInfo("Poisonous Potato", new String[][]{{"pota", "poi"}}, Material.POISONOUS_POTATO));
items.add(new ItemInfo("Wood Button", new String[][]{{"woo", "butto"}}, Material.WOOD_BUTTON));
items.add(new ItemInfo("Pumpkin Pie", new String[][]{{"pie"}, {"pumpk", "pie"}}, Material.PUMPKIN_PIE));
items.add(new ItemInfo("Potion of Invisibility", new String[][] {{"poti", "invi"}}, Material.POTION, (short) 8206));
items.add(new ItemInfo("Potion of Invisibility (Extended)", new String[][] {{"poti", "invi", "ext"}}, Material.POTION, (short) 8270));
items.add(new ItemInfo("Potion of Night Vision", new String[][] {{"poti", "nigh", "visi"}, {"poti", "visio"}}, Material.POTION, (short) 8198));
items.add(new ItemInfo("Potion of Night Vision (Extended)", new String[][] {{"poti", "nigh", "visi", "ext"}, {"poti", "visio", "ext"}}, Material.POTION, (short) 8262));
items.add(new ItemInfo("Enchanted Book", new String[][]{{"ench", "boo"}}, Material.ENCHANTED_BOOK));
items.add(new ItemInfo("Nether Star", new String[][]{{"star", "neth"}}, Material.NETHER_STAR));
items.add(new ItemInfo("Firework Star", new String[][]{{"fire", "star"}}, Material.FIREWORK_CHARGE));
items.add(new ItemInfo("Firework Rocket", new String[][]{{"rocket"}, {"firework"}}, Material.FIREWORK));
items.add(new ItemInfo("White Firework Star", new String[][]{{"whi", "fire", "star"}}, Material.FIREWORK_CHARGE, (short) 1));
items.add(new ItemInfo("Orange Firework Star", new String[][]{{"ora", "fire", "star"}}, Material.FIREWORK_CHARGE, (short) 2));
items.add(new ItemInfo("Magenta Firework Star", new String[][]{{"mag", "fire", "star"}}, Material.FIREWORK_CHARGE, (short) 3));
items.add(new ItemInfo("Light Blue Firework Star", new String[][]{{"blu", "lig", "fire", "star"}}, Material.FIREWORK_CHARGE, (short) 4));
items.add(new ItemInfo("Yellow Firework Star", new String[][]{{"yell", "fire", "star"}}, Material.FIREWORK_CHARGE, (short) 5));
items.add(new ItemInfo("Lime Firework Star", new String[][]{{"lim", "fire", "star"}}, Material.FIREWORK_CHARGE, (short) 6));
items.add(new ItemInfo("Pink Firework Star", new String[][]{{"pin", "fire", "star"}}, Material.FIREWORK_CHARGE, (short) 7));
items.add(new ItemInfo("Gray Firework Star", new String[][]{{"gra", "fire", "star"}}, Material.FIREWORK_CHARGE, (short) 8));
items.add(new ItemInfo("Light Gray Firework Star", new String[][]{{"lig", "gra", "fire", "star"}}, Material.FIREWORK_CHARGE, (short) 9));
items.add(new ItemInfo("Cyan Firework Star", new String[][]{{"cya", "fire", "star"}}, Material.FIREWORK_CHARGE, (short) 10));
items.add(new ItemInfo("Purple Firework Star", new String[][]{{"pur", "fire", "star"}}, Material.FIREWORK_CHARGE, (short) 11));
items.add(new ItemInfo("Blue Firework Star", new String[][]{{"blue", "fire", "star"}}, Material.FIREWORK_CHARGE, (short) 12));
items.add(new ItemInfo("Brown Firework Star", new String[][]{{"bro", "fire", "star"}}, Material.FIREWORK_CHARGE, (short) 13));
items.add(new ItemInfo("Green Firework Star", new String[][]{{"gre", "fire", "star"}}, Material.FIREWORK_CHARGE, (short) 14));
items.add(new ItemInfo("Red Firework Star", new String[][]{{"red", "fire", "star"}}, Material.FIREWORK_CHARGE, (short) 15));
items.add(new ItemInfo("Black Firework Star", new String[][]{{"bla", "fire", "star"}}, Material.FIREWORK_CHARGE, (short) 16));
items.add(new ItemInfo("Dead Bush", new String[][]{{"dea", "bush"}}, Material.DEAD_BUSH));
items.add(new ItemInfo("Nether Brick Slab", new String[][]{{"sla", "net", "bri"}, {"step", "net", "bri"}}, Material.STEP, (short) 6));
//1.5 Blocks & Items
items.add(new ItemInfo("Activator Rail", new String[][]{{"rail", "acti"}, {"trac", "acti"}, {"activ"}}, Material.ACTIVATOR_RAIL));
items.add(new ItemInfo("Block of Redstone", new String[][]{{"block", "red"}, {"block", "rs"}}, Material.REDSTONE_BLOCK));
items.add(new ItemInfo("Daylight Sensor", new String[][]{{"day", "sen"}, {"ligh", "sen"}}, Material.DAYLIGHT_DETECTOR));
items.add(new ItemInfo("Dropper", new String[][]{{"drop"}}, Material.DROPPER));
items.add(new ItemInfo("Hopper", new String[][]{{"hop", "item"}, {"hop"}}, Material.HOPPER));
items.add(new ItemInfo("Explosive Minecart", new String[][]{{"cart", "tnt"}, {"cart", "exp"}}, Material.EXPLOSIVE_MINECART));
items.add(new ItemInfo("Hopper Minecart", new String[][]{{"cart", "hop"}, {"hop"}}, Material.HOPPER_MINECART));
items.add(new ItemInfo("Redstone Comparator", new String[][]{{"rs", "compara"}, {"red", "comparat"}, {"comparat"}}, Material.REDSTONE_COMPARATOR));
items.add(new ItemInfo("Trapped Chest", new String[][]{{"tra", "ches"}}, Material.TRAPPED_CHEST));
items.add(new ItemInfo("Nether Brick Item", new String[][]{{"neth", "bric", "it"}}, Material.NETHER_BRICK_ITEM));
items.add(new ItemInfo("Nether Quartz", new String[][]{{"neth", "qua"}, {"qua"}}, Material.QUARTZ));
items.add(new ItemInfo("Nether Quartz Ore", new String[][]{{"neth", "qua", "ore"}, {"qua", "ore"}}, Material.QUARTZ_ORE));
items.add(new ItemInfo("Quartz Block", new String[][]{{"qua", "blo"}}, Material.QUARTZ_BLOCK));
items.add(new ItemInfo("Quartz Slab", new String[][]{{"qua", "slab"}, {"qua", "step"}}, Material.STEP, (short) 7));
items.add(new ItemInfo("Quartz Double Slab", new String[][]{{"qua", "dou", "sla"}, {"qua", "dou", "step"}}, Material.DOUBLE_STEP, (short) 7));
items.add(new ItemInfo("Quartz Stairs", new String[][]{{"qua", "stair"}}, Material.QUARTZ_STAIRS));
items.add(new ItemInfo("Chiseled Quartz", new String[][]{{"qua", "chis"}}, Material.QUARTZ_BLOCK, (short) 1));
items.add(new ItemInfo("Quartz Pillar", new String[][]{{"qua", "pil"}}, Material.QUARTZ_BLOCK, (short) 2));
items.add(new ItemInfo("Weighted Gold Plate", new String[][]{{"wei", "plat", "gol"}, {"pres", "plat", "gol"}}, Material.GOLD_PLATE));
items.add(new ItemInfo("Weighted Iron Plate", new String[][]{{"wei", "plat", "iro"}, {"pres", "plat", "iro"}}, Material.IRON_PLATE));
//1.6 Blocks and Items
items.add(new ItemInfo("Horse Spawn Egg", new String[][] {{"horse", "egg"}}, Material.MONSTER_EGG, (short) 100));
items.add(new ItemInfo("Diamond Horse Armor", new String[][] {{"dia", "horse", "arm"}, {"dia", "bard"}}, Material.DIAMOND_BARDING));
items.add(new ItemInfo("Gold Horse Armor", new String[][] {{"gold", "horse", "arm"}, {"gold", "bard"}}, Material.GOLD_BARDING));
items.add(new ItemInfo("Iron Horse Armor", new String[][] {{"iron", "horse", "arm"}, {"iron", "bard"}}, Material.IRON_BARDING));
items.add(new ItemInfo("Leash", new String[][] {{"leas"}, {"lead"}}, Material.LEASH));
items.add(new ItemInfo("Hay Bale", new String[][] {{"hay", "bale"}, {"hay", "block"}}, Material.HAY_BLOCK));
items.add(new ItemInfo("Name Tag", new String[][] {{"name", "tag"}}, Material.NAME_TAG));
items.add(new ItemInfo("Hardened Clay", new String[][]{{"hard", "clay"}}, Material.HARD_CLAY));
items.add(new ItemInfo("Block of Coal", new String[][]{{"coal", "block"}}, Material.COAL_BLOCK));
items.add(new ItemInfo("White Stained Clay", new String[][]{{"clay", "whit"}, {"stai", "clay"}, {"whi", "stain", "cla"}}, Material.STAINED_CLAY));
items.add(new ItemInfo("Orange Stained Clay", new String[][]{{"clay", "ora"}, {"ora", "stain", "cla"}}, Material.STAINED_CLAY, (short) 1));
items.add(new ItemInfo("Magenta Stained Clay", new String[][]{{"clay", "mag"}, {"mag", "stain", "cla"}}, Material.STAINED_CLAY, (short) 2));
items.add(new ItemInfo("Light Blue Stained Clay", new String[][]{{"clay", "lig", "blue"}, {"lig", "blu", "stain", "cla"}}, Material.STAINED_CLAY, (short) 3));
items.add(new ItemInfo("Yellow Stained Clay", new String[][]{{"clay", "yell"}, {"yell", "stain", "cla"}}, Material.STAINED_CLAY, (short) 4));
items.add(new ItemInfo("Lime Stained Clay", new String[][]{{"clay", "lig", "gree"}, {"clay", "lime"}, {"lime", "stain", "cla"}}, Material.STAINED_CLAY, (short) 5));
items.add(new ItemInfo("Pink Stained Clay", new String[][]{{"clay", "pink"}, {"pink", "stain", "cla"}}, Material.STAINED_CLAY, (short) 6));
items.add(new ItemInfo("Gray Stained Clay", new String[][]{{"clay", "gray"}, {"clay", "grey"}, {"gra", "stain", "cla"}, {"gre", "stain", "cla"}}, Material.STAINED_CLAY, (short) 7));
items.add(new ItemInfo("Light Gray Stained Clay", new String[][]{{"lig", "clay", "gra"}, {"lig", "clay", "gre"}, {"lig", "gra", "stain", "cla"}}, Material.STAINED_CLAY, (short) 8));
items.add(new ItemInfo("Cyan Stained Clay", new String[][]{{"clay", "cya"}, {"cya", "stain", "cla"}}, Material.STAINED_CLAY, (short) 9));
items.add(new ItemInfo("Purple Stained Clay", new String[][]{{"clay", "pur"}, {"pur", "stain", "cla"}}, Material.STAINED_CLAY, (short) 10));
items.add(new ItemInfo("Blue Stained Clay", new String[][]{{"clay", "blue"}, {"blue", "stain", "cla"}}, Material.STAINED_CLAY, (short) 11));
items.add(new ItemInfo("Brown Stained Clay", new String[][]{{"clay", "brown"}, {"brown", "stain", "cla"}}, Material.STAINED_CLAY, (short) 12));
items.add(new ItemInfo("Green Stained Clay", new String[][]{{"clay", "gree"}, {"gree", "stain", "cla"}}, Material.STAINED_CLAY, (short) 13));
items.add(new ItemInfo("Red Stained Clay", new String[][]{{"clay", "red"}, {"red", "stain", "cla"}}, Material.STAINED_CLAY, (short) 14));
items.add(new ItemInfo("Black Stained Clay", new String[][]{{"clay", "bla"}, {"bla", "stain", "cla"}}, Material.STAINED_CLAY, (short) 15));
items.add(new ItemInfo("White Carpet", new String[][]{{"carpet", "whit"}, {"carpet"}}, Material.CARPET));
items.add(new ItemInfo("Orange Carpet", new String[][]{{"carpet", "ora"}}, Material.CARPET, (short) 1));
items.add(new ItemInfo("Magenta Carpet", new String[][]{{"carpet", "mag"}}, Material.CARPET, (short) 2));
items.add(new ItemInfo("Light Blue Carpet", new String[][]{{"carpet", "lig", "blue"}}, Material.CARPET, (short) 3));
items.add(new ItemInfo("Yellow Carpet", new String[][]{{"carpet", "yell"}}, Material.CARPET, (short) 4));
items.add(new ItemInfo("Light Green Carpet", new String[][]{{"carpet", "lig", "gree"}, {"carpet", "gree"}}, Material.CARPET, (short) 5));
items.add(new ItemInfo("Pink Carpet", new String[][]{{"carpet", "pink"}}, Material.CARPET, (short) 6));
items.add(new ItemInfo("Gray Carpet", new String[][]{{"carpet", "gray"}, {"carpet", "grey"}}, Material.CARPET, (short) 7));
items.add(new ItemInfo("Light Gray Carpet", new String[][]{{"lig", "carpet", "gra"}, {"lig", "carpet", "gre"}}, Material.CARPET, (short) 8));
items.add(new ItemInfo("Cyan Carpet", new String[][]{{"carpet", "cya"}}, Material.CARPET, (short) 9));
items.add(new ItemInfo("Purple Carpet", new String[][]{{"carpet", "pur"}}, Material.CARPET, (short) 10));
items.add(new ItemInfo("Blue Carpet", new String[][]{{"carpet", "blue"}}, Material.CARPET, (short) 11));
items.add(new ItemInfo("Brown Carpet", new String[][]{{"carpet", "brow"}}, Material.CARPET, (short) 12));
items.add(new ItemInfo("Dark Green Carpet", new String[][]{{"carpet", "dar", "gree"}, {"carpet", "gree"}}, Material.CARPET, (short) 13));
items.add(new ItemInfo("Red Carpet", new String[][]{{"carpet", "red"}}, Material.CARPET, (short) 14));
items.add(new ItemInfo("Black Carpet", new String[][]{{"carpet", "bla"}}, Material.CARPET, (short) 15));
//1.7 Blocks and Items
items.add(new ItemInfo("Grassless Dirt", new String[][]{{"less", "dirt"}}, Material.DIRT, (short) 1));
items.add(new ItemInfo("Acacia Log", new String[][]{{"acac"}, {"log", "acac"}}, Material.LOG_2));
items.add(new ItemInfo("Dark Oak Log", new String[][]{{"oak", "dar"}, {"log", "oak", "dar"}}, Material.LOG_2, (short) 1));
items.add(new ItemInfo("Acacia Plank", new String[][]{{"acac", "plank"}, {"acac", "wood"}}, Material.WOOD, (short) 4));
items.add(new ItemInfo("Dark Oak Plank", new String[][]{{"dar", "oak", "plank"}, {"dar", "oak", "wood"}}, Material.WOOD, (short) 5));
items.add(new ItemInfo("Acacia Wood Stairs", new String[][]{{"stair", "wood", "acac"}, {"acac", "stair"}}, Material.ACACIA_STAIRS));
items.add(new ItemInfo("Dark Oak Wood Stairs", new String[][]{{"stair", "wood", "dar", "oak"}, {"dar", "oak", "stair"}}, Material.DARK_OAK_STAIRS));
items.add(new ItemInfo("Acacia Sapling", new String[][]{{"sapl", "acac"}}, Material.SAPLING, (short) 4));
items.add(new ItemInfo("Dark Oak Sapling", new String[][]{{"sapl", "oak", "dar"}}, Material.SAPLING, (short) 5));
items.add(new ItemInfo("Acacia Leaves", new String[][]{{"lea", "acac"}}, Material.LEAVES_2));
items.add(new ItemInfo("Dark Oak Leaves", new String[][]{{"lea", "oak", "dar"}}, Material.LEAVES_2, (short) 1));
items.add(new ItemInfo("Packed Ice", new String[][]{{"ice", "pac"}, {"ice", "opaq"}}, Material.PACKED_ICE));
items.add(new ItemInfo("Podzol", new String[][]{{"podz"}, {"dirt", "pod"}}, Material.DIRT, (short) 2));
items.add(new ItemInfo("Red Sand", new String[][]{{"red", "sand"}}, Material.SAND, (short) 1));
items.add(new ItemInfo("Cobblestone Monster Egg", new String[][]{{"cobb","sto","mons","egg"},{"cobb","mons", "egg"}, {"hid", "silver", "cob"}}, Material.MONSTER_EGGS, (short) 1));
items.add(new ItemInfo("Cracked Stone Brick Monster Egg", new String[][]{{"cra","sto","bri","mons", "egg"}, {"hid", "silver","cra","sto","bri"}}, Material.MONSTER_EGGS, (short) 4));
items.add(new ItemInfo("Chiseled Stone Brick Monster Egg", new String[][]{{"chi","stone","bri","mons", "egg"}, {"hid", "silver","chi","sto","bri"}}, Material.MONSTER_EGGS, (short) 5));
items.add(new ItemInfo("White Stained Glass", new String[][]{{"stai", "glas", "whit"}, {"stai", "glas"}}, Material.STAINED_GLASS));
items.add(new ItemInfo("Orange Stained Glass", new String[][]{{"stai", "glas", "ora"}}, Material.STAINED_GLASS, (short) 1));
items.add(new ItemInfo("Magenta Stained Glass", new String[][]{{"stai", "glas", "mag"}}, Material.STAINED_GLASS, (short) 2));
items.add(new ItemInfo("Light Blue Stained Glass", new String[][]{{"stai", "glas", "lig", "blue"}}, Material.STAINED_GLASS, (short) 3));
items.add(new ItemInfo("Yellow Stained Glass", new String[][]{{"stai", "glas", "yell"}}, Material.STAINED_GLASS, (short) 4));
items.add(new ItemInfo("Light Green Stained Glass", new String[][]{{"stai", "glas", "lig", "gree"}, {"stai", "glas", "gree"}}, Material.STAINED_GLASS, (short) 5));
items.add(new ItemInfo("Pink Stained Glass", new String[][]{{"stai", "glas", "pink"}}, Material.STAINED_GLASS, (short) 6));
items.add(new ItemInfo("Gray Stained Glass", new String[][]{{"stai", "glas", "gra"}, {"stai", "glas", "gre"}}, Material.STAINED_GLASS, (short) 7));
items.add(new ItemInfo("Light Gray Stained Glass", new String[][]{{"lig", "stai", "glas", "gra"}, {"lig", "stai", "glas", "gre"}}, Material.STAINED_GLASS, (short) 8));
items.add(new ItemInfo("Cyan Stained Glass", new String[][]{{"stai", "glas", "cya"}}, Material.STAINED_GLASS, (short) 9));
items.add(new ItemInfo("Purple Stained Glass", new String[][]{{"stai", "glas", "pur"}}, Material.STAINED_GLASS, (short) 10));
items.add(new ItemInfo("Blue Stained Glass", new String[][]{{"stai", "glas", "blue"}}, Material.STAINED_GLASS, (short) 11));
items.add(new ItemInfo("Brown Stained Glass", new String[][]{{"stai", "glas", "brow"}}, Material.STAINED_GLASS, (short) 12));
items.add(new ItemInfo("Dark Green Stained Glass", new String[][]{{"stai", "glas", "dar", "gree"}, {"stai", "glas", "gree"}}, Material.STAINED_GLASS, (short) 13));
items.add(new ItemInfo("Red Stained Glass", new String[][]{{"stai", "glas", "red"}}, Material.STAINED_GLASS, (short) 14));
items.add(new ItemInfo("Black Stained Glass", new String[][]{{"stai", "glas", "bla"}}, Material.STAINED_GLASS, (short) 15));
items.add(new ItemInfo("White Stained Glass Pane", new String[][]{{"stai", "glas", "pane", "whit"}, {"stai", "glas", "pane"}}, Material.STAINED_GLASS_PANE));
items.add(new ItemInfo("Orange Stained Glass Pane", new String[][]{{"stai", "glas", "pane", "ora"}}, Material.STAINED_GLASS_PANE, (short) 1));
items.add(new ItemInfo("Magenta Stained Glass Pane", new String[][]{{"stai", "glas", "pane", "mag"}}, Material.STAINED_GLASS_PANE, (short) 2));
items.add(new ItemInfo("Light Blue Stained Glass Pane", new String[][]{{"stai", "glas", "pane", "lig", "blue"}}, Material.STAINED_GLASS_PANE, (short) 3));
items.add(new ItemInfo("Yellow Stained Glass Pane", new String[][]{{"stai", "glas", "pane", "yell"}}, Material.STAINED_GLASS_PANE, (short) 4));
items.add(new ItemInfo("Light Green Stained Glass Pane", new String[][]{{"stai", "glas", "pane", "lig", "gree"}, {"stai", "glas", "pane", "gree"}}, Material.STAINED_GLASS_PANE, (short) 5));
items.add(new ItemInfo("Pink Stained Glass Pane", new String[][]{{"stai", "glas", "pane", "pink"}}, Material.STAINED_GLASS_PANE, (short) 6));
items.add(new ItemInfo("Gray Stained Glass Pane", new String[][]{{"stai", "glas", "pane", "gra"}, {"stai", "glas", "pane", "gre"}}, Material.STAINED_GLASS_PANE, (short) 7));
items.add(new ItemInfo("Light Gray Stained Glass Pane", new String[][]{{"lig", "stai", "glas", "pane", "gra"}, {"lig", "stai", "glas", "pane", "gre"}}, Material.STAINED_GLASS_PANE, (short) 8));
items.add(new ItemInfo("Cyan Stained Glass Pane", new String[][]{{"stai", "glas", "pane", "cya"}}, Material.STAINED_GLASS_PANE, (short) 9));
items.add(new ItemInfo("Purple Stained Glass Pane", new String[][]{{"stai", "glas", "pane", "pur"}}, Material.STAINED_GLASS_PANE, (short) 10));
items.add(new ItemInfo("Blue Stained Glass Pane", new String[][]{{"stai", "glas", "pane", "blue"}}, Material.STAINED_GLASS_PANE, (short) 11));
items.add(new ItemInfo("Brown Stained Glass Pane", new String[][]{{"stai", "glas", "pane", "brow"}}, Material.STAINED_GLASS_PANE, (short) 12));
items.add(new ItemInfo("Dark Green Stained Glass Pane", new String[][]{{"stai", "glas", "pane", "dar", "gree"}, {"stai", "glas", "pane", "gree"}}, Material.STAINED_GLASS_PANE, (short) 13));
items.add(new ItemInfo("Red Stained Glass Pane", new String[][]{{"stai", "glas", "pane", "red"}}, Material.STAINED_GLASS_PANE, (short) 14));
items.add(new ItemInfo("Black Stained Glass Pane", new String[][]{{"stai", "glas", "pane", "bla"}}, Material.STAINED_GLASS_PANE, (short) 15));
items.add(new ItemInfo("Poppy", new String[][]{{"flow", "red"}, {"rose"}, {"poppy"}}, Material.RED_ROSE));
items.add(new ItemInfo("Blue Orchid", new String[][]{{"flow", "blue"}, {"orch", "blue"}}, Material.RED_ROSE, (short) 1));
items.add(new ItemInfo("Allium", new String[][]{{"flow", "mag"}, {"alli"}}, Material.RED_ROSE, (short) 2));
items.add(new ItemInfo("Azure Bluet", new String[][]{{"flow", "whit"}, {"azu", "blue"}}, Material.RED_ROSE, (short) 3));
items.add(new ItemInfo("Red Tulip", new String[][]{{"tul", "red"}}, Material.RED_ROSE, (short) 4));
items.add(new ItemInfo("Orange Tulip", new String[][]{{"tul", "ora"}}, Material.RED_ROSE, (short) 5));
items.add(new ItemInfo("White Tulip", new String[][]{{"tul", "whit"}}, Material.RED_ROSE, (short) 6));
items.add(new ItemInfo("Pink Tulip", new String[][]{{"tul", "pin"}}, Material.RED_ROSE, (short) 7));
items.add(new ItemInfo("Oxeye Daisy", new String[][]{{"dais"}, {"oxe", "dais"}}, Material.RED_ROSE, (short) 8));
items.add(new ItemInfo("Sunflower", new String[][]{{"flow", "sun"}}, Material.DOUBLE_PLANT, (short) 0));
items.add(new ItemInfo("Lilac", new String[][]{{"flow", "lila"}, {"lila"}}, Material.DOUBLE_PLANT, (short) 1));
items.add(new ItemInfo("Double Tallgrass", new String[][]{{"doub", "tall", "gras"}, {"doub", "long", "gras"}}, Material.DOUBLE_PLANT, (short) 2));
items.add(new ItemInfo("Large Fern", new String[][]{{"larg", "fern"}, {"doub", "fern"}}, Material.DOUBLE_PLANT, (short) 3));
items.add(new ItemInfo("Rose Bush", new String[][]{{"bush", "rose"}}, Material.DOUBLE_PLANT, (short) 4));
items.add(new ItemInfo("Peony", new String[][]{{"flow", "peon"}, {"peon"}}, Material.DOUBLE_PLANT, (short) 5));
items.add(new ItemInfo("Command Minecart", new String[][]{{"cart", "comm"}}, Material.COMMAND_MINECART));
items.add(new ItemInfo("Potion of Water Breathing", new String[][] {{"poti", "wate", "breat"}}, Material.POTION, (short) 8205));
items.add(new ItemInfo("Potion of Water Breathing (Reverted)", new String[][] {{"poti", "wate", "breat", "rev"}}, Material.POTION, (short) 8237));
items.add(new ItemInfo("Potion of Water Breathing (Extended)", new String[][] {{"poti", "wate", "breat", "ext"}}, Material.POTION, (short) 8269));
items.add(new ItemInfo("Splash Potion of Water Breathing", new String[][] {{"poti", "wate", "breat", "spl"}}, Material.POTION, (short) 16397));
items.add(new ItemInfo("Splash Potion of Water Breathing (Reverted)", new String[][] {{"poti", "wate", "breat", "rev", "spl"}}, Material.POTION, (short) 16429));
items.add(new ItemInfo("Splash Potion of Water Breathing (Extended)", new String[][] {{"poti", "wate", "breat", "ext", "spl"}}, Material.POTION, (short) 16461));
items.add(new ItemInfo("Raw Salmon", new String[][]{{"salm"}, {"raw", "salm"}}, Material.RAW_FISH, (short) 1));
items.add(new ItemInfo("Cooked Salmon", new String[][]{{"salm", "cook"}}, Material.COOKED_FISH, (short) 1));
items.add(new ItemInfo("Clownfish", new String[][]{{"fish", "clow"}}, Material.RAW_FISH, (short) 2));
items.add(new ItemInfo("Pufferfish", new String[][]{{"fish", "puff"}, {"fish", "blo"}, {"fish", "glob"}}, Material.RAW_FISH, (short) 3));
items.add(new ItemInfo("Acacia Slab", new String[][]{{"slab", "aca"}, {"step", "aca"}}, Material.WOOD_STEP, (short) 4));
items.add(new ItemInfo("Dark Oak Slab", new String[][]{{"slab", "dar", "oak"}, {"step", "dar", "oak"}}, Material.WOOD_STEP, (short) 5));
}
@Deprecated
public static ItemInfo itemById(int typeId) {
return itemByType(Material.getMaterial(typeId), (short) 0);
}
@Deprecated
public static ItemInfo itemById(int typeId, short subType) {
return itemByType(Material.getMaterial(typeId), subType);
}
/**
* Searchs for an ItemInfo from the given ItemStack
* @param itemStack to search on
* @return ItemInfo found, or null
*/
public static ItemInfo itemByStack(ItemStack itemStack) {
if (itemStack == null) {
return null;
}
for (ItemInfo item : items) {
if (itemStack.getType().equals(item.getType()) && item.isDurable()) {
return item;
} else if (itemStack.getType().equals(item.getType()) && item.getSubTypeId() == itemStack.getDurability()) {
return item;
}
}
return null;
}
public static ItemInfo itemByItem(ItemInfo item) {
for (ItemInfo i : items) {
if (item.equals(i)) {
return i;
}
}
return null;
}
/**
* Gets a relevant ItemInfo by it's Material
* @param type of Material
* @return ItemInfo record found or null if none
*/
public static ItemInfo itemByType(Material type) {
return itemByType(type, (short) 0);
}
/**
* Searches for an ItemInfo record by Material and SubTypeID
* @param type of Material
* @param subType to check for
* @return ItemInfo record found or null if none
*/
public static ItemInfo itemByType(Material type, short subType) {
for (ItemInfo item : items) {
if (item.getType() == type && item.getSubTypeId() == subType) {
return item;
}
}
return null;
}
/**
* Search for an item from a given string, useful for user input. Uses 3 different types of reg-exp searching.
* Checks first for an ItemID.
* Checks second for ItemID:SubType
* Last, it will run a by-name item search assuming the string is the name of an item.
*
* @param string to parse
* @return ItemInfo found or null
*/
public static ItemInfo itemByString(String string) {
// int
Pattern pattern = Pattern.compile("(?i)^(\\d+)$");
Matcher matcher = pattern.matcher(string);
if (matcher.find()) {
int id = Integer.parseInt(matcher.group(1));
return itemById(id);
}
// int:int
matcher.reset();
pattern = Pattern.compile("(?i)^(\\d+):(\\d+)$");
matcher = pattern.matcher(string);
if (matcher.find()) {
int id = Integer.parseInt(matcher.group(1));
short type = Short.parseShort(matcher.group(2));
return itemById(id, type);
}
// name
matcher.reset();
pattern = Pattern.compile("(?i)^(.*)$");
matcher = pattern.matcher(string);
if (matcher.find()) {
String name = matcher.group(1);
return itemByName(name);
}
return null;
}
public static ItemInfo itemByName(ArrayList<String> search) {
String searchString = join(search, " ");
return itemByName(searchString);
}
public static ItemInfo[] itemByNames(ArrayList<String> search, boolean multi) {
String searchString = join(search, " ");
return itemsByName(searchString, multi);
}
/**
* Multi-Item return search for dumping all items with the search string to the player
*
*
* @param searchString to search for
* @param multi whether to return a list of items or just the first
* @return Array of items found
*/
public static ItemInfo[] itemsByName(String searchString, boolean multi) {
if (multi == false) {
return new ItemInfo[]{itemByName(searchString)};
}
ItemInfo[] itemList = new ItemInfo[]{};
if (searchString.matches("\\d+:\\d+")) {
// Match on integer:short to get typeId and subTypeId
// Retrieve/parse data
String[] params = searchString.split(":");
int typeId = Integer.parseInt(params[0]);
short subTypeId = Short.parseShort(params[1]);
// Iterate through Items
for (ItemInfo item : items) {
// Test for match
if (item.getId() == typeId && item.getSubTypeId() == subTypeId) {
itemList[0] = item;
break;
}
}
} else if (searchString.matches("\\d+")) {
// Retrieve/parse data
int typeId = Integer.parseInt(searchString);
// Iterate through Items
int i = 0;
for (ItemInfo item : items) {
// Test for match
if (item.getId() == typeId) {
itemList[i] = item;
i++;
}
}
} else {
// Else this must be a string that we need to identify
// Iterate through Items
int i = 0;
for (ItemInfo item : items) {
// Look through each possible match criteria
for (String[] attributes : item.search) {
boolean match = false;
// Loop through entire criteria strings
for (String attribute : attributes) {
if (searchString.toLowerCase().contains(attribute)) {
match = true;
break;
}
}
// THIS was a match
if (match) {
itemList[i] = item;
i++;
}
}
}
}
return itemList;
}
/**
* Single item search function, for when we only ever want to return 1 result
*
* @param searchString to search for
* @return ItemInfo Object
*/
public static ItemInfo itemByName(String searchString) {
ItemInfo matchedItem = null;
int matchedItemStrength = 0;
int matchedValue = 0;
if (searchString.matches("\\d+:\\d+")) {
// Match on integer:short to get typeId and subTypeId
// Retrieve/parse data
String[] params = searchString.split(":");
int typeId = Integer.parseInt(params[0]);
short subTypeId = Short.parseShort(params[1]);
// Iterate through Items
for (ItemInfo item : items) {
// Test for match
if (item.getId() == typeId && item.getSubTypeId() == subTypeId) {
matchedItem = item;
break;
}
}
} else if (searchString.matches("\\d+")) {
// Match an integer only, assume subTypeId = 0
// Retrieve/parse data
int typeId = Integer.parseInt(searchString);
short subTypeId = 0;
// Iterate through Items
for (ItemInfo item : items) {
// Test for match
if (item.getId() == typeId && item.getSubTypeId() == subTypeId) {
matchedItem = item;
break;
}
}
} else {
// Else this must be a string that we need to identify
// Iterate through Items
for (ItemInfo item : items) {
// Look through each possible match criteria
for (String[] attributes : item.search) {
int val = 0;
boolean match = false;
// Loop through entire criteria strings
for (String attribute : attributes) {
if (searchString.toLowerCase().contains(attribute)) {
val += attribute.length();
match = true;
} else {
match = false;
break;
}
}
// THIS was a match
if (match) {
if (matchedItem == null || val > matchedValue || attributes.length > matchedItemStrength) {
matchedItem = item;
matchedValue = val;
matchedItemStrength = attributes.length;
}
}
}
}
}
return matchedItem;
}
/**
* Joins elements of a String array with the glue between them into a String.
* @param array of elements to join together
* @param glue what to put between each element
* @return Concacted Array combined with glue
*/
public static String join(String[] array, String glue) {
String joined = null;
for (String element : array) {
if (joined == null) {
joined = element;
} else {
joined += glue + element;
}
}
if (joined == null) {
return "";
} else {
return joined;
}
}
/**
* Joins elements of a String array with the glue between them into a String.
* @param list of items to join together
* @param glue what to put between each element
* @return Concacted Array combined with glue
*/
public static String join(List<String> list, String glue) {
String joined = null;
for (String element : list) {
if (joined == null) {
joined = element;
} else {
joined += glue + element;
}
}
if (joined == null) {
return "";
} else {
return joined;
}
}
}

View File

@ -0,0 +1,821 @@
/* This file is part of Vault.
Vault is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Vault is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Vault. If not, see <http://www.gnu.org/licenses/>.
*/
package net.milkbowl.vault.permission;
import java.util.UUID;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin;
/**
* The main Permission API - allows for group and player based permission tests
*
*/
public abstract class Permission {
protected static final Logger log = Logger.getLogger("Minecraft");
protected Plugin plugin = null;
/**
* Gets name of permission method
* @return Name of Permission Method
*/
abstract public String getName();
/**
* Checks if permission method is enabled.
* @return Success or Failure
*/
abstract public boolean isEnabled();
/**
* Returns if the permission system is or attempts to be compatible with super-perms.
* @return True if this permission implementation works with super-perms
*/
abstract public boolean hasSuperPermsCompat();
/**
* Checks if player has a permission node. (Short for playerHas(...)
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World name
* @param player Player name
* @param permission Permission node
* @return Success or Failure
*/
public boolean has(String world, String player, String permission) {
if (world == null) {
return playerHas((String) null, player, permission);
}
return playerHas(world, player, permission);
}
/**
* Checks if player has a permission node. (Short for playerHas(...)
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World Object
* @param player Player name
* @param permission Permission node
* @return Success or Failure
*/
public boolean has(World world, String player, String permission) {
if (world == null) {
return playerHas((String) null, player, permission);
}
return playerHas(world.getName(), player, permission);
}
/**
* Checks if a CommandSender has a permission node.
* This will return the result of bukkits, generic .hasPermission() method and is identical in all cases.
* This method will explicitly fail if the registered permission system does not register permissions in bukkit.
*
* For easy checking of a commandsender
* @param sender to check permissions on
* @param permission to check for
* @return true if the sender has the permission
*/
public boolean has(CommandSender sender, String permission) {
return sender.hasPermission(permission);
}
/**
* Checks if player has a permission node. (Short for playerHas(...)
* @param player Player Object
* @param permission Permission node
* @return Success or Failure
*/
public boolean has(Player player, String permission) {
return player.hasPermission(permission);
}
/**
* Checks if player has a permission node.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World name
* @param player Player name
* @param permission Permission node
* @return Success or Failure
*/
abstract public boolean playerHas(String world, String player, String permission);
/**
* Checks if player has a permission node.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World Object
* @param player Player name
* @param permission Permission node
* @return Success or Failure
*/
public boolean playerHas(World world, String player, String permission) {
if (world == null) {
return playerHas((String) null, player, permission);
}
return playerHas(world.getName(), player, permission);
}
/**
* Checks if player has a permission node.
*
* @param world World Object
* @param playerId UUID of the player
* @param permission Permission node
* @return Success or Failure
*/
public boolean playerHas(World world, UUID playerId, String permission) {
if (world == null) {
return has((String) null, Bukkit.getOfflinePlayer(playerId).getName(), permission);
}
return has(world.getName(), Bukkit.getOfflinePlayer(playerId).getName(), permission);
}
/**
* Checks if player has a permission node.
* @param player Player Object
* @param permission Permission node
* @return Success or Failure
*/
public boolean playerHas(Player player, String permission) {
return has(player, permission);
}
/**
* Add permission to a player.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World name
* @param player Player name
* @param permission Permission node
* @return Success or Failure
*/
abstract public boolean playerAdd(String world, String player, String permission);
/**
* Add permission to a player.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World Object
* @param player Player name
* @param permission Permission node
* @return Success or Failure
*/
public boolean playerAdd(World world, String player, String permission) {
if (world == null) {
return playerAdd((String) null, player, permission);
}
return playerAdd(world.getName(), player, permission);
}
/**
* Add permission to a player.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World Object
* @param playerId UUId of the player
* @param permission Permission node
* @return Success or Failure
*/
public boolean playerAdd(World world, UUID playerId, String permission) {
if (world == null) {
return playerAdd((String) null, Bukkit.getOfflinePlayer(playerId).getName(), permission);
}
return playerAdd(world.getName(), Bukkit.getOfflinePlayer(playerId).getName(), permission);
}
/**
* Add permission to a player ONLY for the world the player is currently on.
* This is a world-specific operation, if you want to add global permission you must explicitly use NULL for the world.
*
* @param player Player Object
* @param permission Permission node
* @return Success or Failure
*/
public boolean playerAdd(Player player, String permission) {
return playerAdd(player.getWorld().getName(), player.getName(), permission);
}
/**
* Add transient permission to a player.
* This implementation can be used by any subclass which implements a "pure" superperms plugin, i.e.
* one that only needs the built-in Bukkit API to add transient permissions to a player. Any subclass
* implementing a plugin which provides its own API for this needs to override this method.
*
* @param player Player name
* @param permission Permission node
* @return Success or Failure
*/
public boolean playerAddTransient(String player, String permission) throws UnsupportedOperationException {
Player p = plugin.getServer().getPlayer(player);
if (p == null) {
throw new UnsupportedOperationException(getName() + " does not support offline player transient permissions!");
}
return playerAddTransient(p, permission);
}
/**
* Add transient permission to a player.
* This implementation can be used by any subclass which implements a "pure" superperms plugin, i.e.
* one that only needs the built-in Bukkit API to add transient permissions to a player.
*
* @param playerId UUID
* @param permission Permission node
* @return Success or Failure
*/
public boolean playerAddTransient(UUID playerId, String permission) throws UnsupportedOperationException {
Player p = plugin.getServer().getPlayer(playerId);
if (p == null) {
throw new UnsupportedOperationException(getName() + " does not support offline player transient permissions!");
}
return playerAddTransient(p, permission);
}
/**
* Add transient permission to a player.
* This operation adds a world-unspecific permission onto the player object in bukkit via Bukkit's permission interface.
*
* @param player Player Object
* @param permission Permission node
* @return Success or Failure
*/
public boolean playerAddTransient(Player player, String permission) {
for (PermissionAttachmentInfo paInfo : player.getEffectivePermissions()) {
if (paInfo.getAttachment() != null && paInfo.getAttachment().getPlugin().equals(plugin)) {
paInfo.getAttachment().setPermission(permission, true);
return true;
}
}
PermissionAttachment attach = player.addAttachment(plugin);
attach.setPermission(permission, true);
return true;
}
/**
* Adds a world specific transient permission to the player - ONLY WORKS IN PEX/P3 - otherwise it defaults to GLOBAL!
*
* @param worldName to check on
* @param playerId UUID
* @param permission to test
* @return Success or Failure
*/
public boolean playerAddTransient(String worldName, UUID playerId, String permission) {
return playerAddTransient(playerId, permission);
}
/**
* Adds a world specific transient permission to the player - ONLY WORKS IN PEX/P3 - otherwise it defaults to GLOBAL!
* @param worldName to check on
* @param player to check
* @param permission to check for
* @return Success or Failure
*/
public boolean playerAddTransient(String worldName, Player player, String permission) {
return playerAddTransient(player, permission);
}
/**
* Adds a world specific transient permission to the player - ONLY WORKS IN PEX/P3 - otherwise it defaults to GLOBAL!
* @param worldName to check on
* @param player to check
* @param permission to check
* @return Success or Failure
*/
public boolean playerAddTransient(String worldName, String player, String permission) {
Player p = plugin.getServer().getPlayer(player);
if (p == null) {
throw new UnsupportedOperationException(getName() + " does not support offline player transient permissions!");
}
return playerAddTransient(p, permission);
}
/**
* Removes a world specific transient permission from the player - Only works in PEX/P3 - otherwise it defaults to Global!
* @param worldName to check on
* @param player to check
* @param permission to check for
* @return Success or Failure
*/
public boolean playerRemoveTransient(String worldName, String player, String permission) {
Player p = plugin.getServer().getPlayer(player);
if (p == null)
return false;
return playerRemoveTransient(p, permission);
}
/**
* Removes a world specific transient permission from the player - Only works in PEX/P3 - otherwise it defaults to Global!
* @param worldName to check on
* @param playerId UUID to check
* @param permission to check for
* @return Success or Failure
*/
public boolean playerRemoveTransient(String worldName, UUID playerId, String permission) {
return playerRemoveTransient(playerId, permission);
}
/**
* Removes a world specific transient permission from the player - Only works in PEX/P3 - otherwise it defaults to Global!
* @param worldName to check on
* @param player to check
* @param permission to check for
* @return Success or Failure
*/
public boolean playerRemoveTransient(String worldName, Player player, String permission) {
return playerRemoveTransient(player, permission);
}
/**
* Remove permission from a player.
* @param world World name
* @param player Name of Player
* @param permission Permission node
* @return Success or Failure
*/
abstract public boolean playerRemove(String world, String player, String permission);
/**
* Remove permission from a player.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World name
* @param player Player name
* @param permission Permission node
* @return Success or Failure
*/
public boolean playerRemove(World world, String player, String permission) {
if (world == null) {
return playerRemove((String) null, player, permission);
}
return playerRemove(world.getName(), player, permission);
}
/**
* Remove permission from a player.
* Will attempt to remove permission from the player on the player's current world. This is NOT a global operation.
*
* @param player Player Object
* @param permission Permission node
* @return Success or Failure
*/
public boolean playerRemove(Player player, String permission) {
return playerRemove(player.getWorld().getName(), player.getName(), permission);
}
/**
* Remove transient permission from a player.
* This implementation can be used by any subclass which implements a "pure" superperms plugin, i.e.
* one that only needs the built-in Bukkit API to remove transient permissions from a player. Any subclass
* implementing a plugin which provides its own API for this needs to override this method.
*
* @param player Player name
* @param permission Permission node
* @return Success or Failure
*/
public boolean playerRemoveTransient(String player, String permission) {
Player p = plugin.getServer().getPlayer(player);
if (p == null)
return false;
return playerRemoveTransient(p, permission);
}
/**
* Remove transient permission from a player.
*
* @param playerId UUID
* @param permission Permission node
* @return Success or Failure
*/
public boolean playerRemoveTransient(UUID playerId, String permission) {
return playerRemoveTransient(Bukkit.getPlayer(playerId), permission);
}
/**
* Remove transient permission from a player.
*
* @param player Player Object
* @param permission Permission node
* @return Success or Failure
*/
public boolean playerRemoveTransient(Player player, String permission) {
for (PermissionAttachmentInfo paInfo : player.getEffectivePermissions()) {
if (paInfo.getAttachment() != null && paInfo.getAttachment().getPlugin().equals(plugin)) {
paInfo.getAttachment().unsetPermission(permission);
return true;
}
}
return false;
}
/**
* Checks if group has a permission node.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World name
* @param group Group name
* @param permission Permission node
* @return Success or Failure
*/
abstract public boolean groupHas(String world, String group, String permission);
/**
* Checks if group has a permission node.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World Object
* @param group Group name
* @param permission Permission node
* @return Success or Failure
*/
public boolean groupHas(World world, String group, String permission) {
if (world == null) {
return groupHas((String) null, group, permission);
}
return groupHas(world.getName(), group, permission);
}
/**
* Add permission to a group.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World name
* @param group Group name
* @param permission Permission node
* @return Success or Failure
*/
abstract public boolean groupAdd(String world, String group, String permission);
/**
* Add permission to a group.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World Object
* @param group Group name
* @param permission Permission node
* @return Success or Failure
*/
public boolean groupAdd(World world, String group, String permission) {
if (world == null) {
return groupAdd((String) null, group, permission);
}
return groupAdd(world.getName(), group, permission);
}
/**
* Remove permission from a group.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World name
* @param group Group name
* @param permission Permission node
* @return Success or Failure
*/
abstract public boolean groupRemove(String world, String group, String permission);
/**
* Remove permission from a group.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World Object
* @param group Group name
* @param permission Permission node
* @return Success or Failure
*/
public boolean groupRemove(World world, String group, String permission) {
if (world == null) {
return groupRemove((String) null, group, permission);
}
return groupRemove(world.getName(), group, permission);
}
/**
* Check if player is member of a group.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* This method is known to return unexpected results depending on what permission system is being used. Different permission systems
* will store the player groups differently, It is HIGHLY suggested you test your code out first.
*
* @param world World name
* @param player Player name
* @param group Group name
* @return Success or Failure
*/
abstract public boolean playerInGroup(String world, String player, String group);
/**
* Check if player is member of a group.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World Object
* @param player Player name
* @param group Group name
* @return Success or Failure
*/
public boolean playerInGroup(World world, String player, String group) {
if (world == null) {
return playerInGroup((String) null, player, group);
}
return playerInGroup(world.getName(), player, group);
}
/**
* Check if player is member of a group.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World Object
* @param playerId UUID
* @param group Group name
* @return Success or Failure
*/
public boolean playerInGroup(World world, UUID playerId, String group) {
if (world == null) {
return playerInGroup((String) null, Bukkit.getOfflinePlayer(playerId).getName(), group);
}
return playerInGroup(world.getName(), Bukkit.getOfflinePlayer(playerId).getName(), group);
}
/**
* Check if player is member of a group.
* This method will ONLY check groups for which the player is in that are defined for the current world.
* This may result in odd return behaviour depending on what permission system has been registered.
*
* @param player Player Object
* @param group Group name
* @return Success or Failure
*/
public boolean playerInGroup(Player player, String group) {
return playerInGroup(player.getWorld().getName(), player.getName(), group);
}
/**
* Add player to a group.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World name
* @param player Player name
* @param group Group name
* @return Success or Failure
*/
abstract public boolean playerAddGroup(String world, String player, String group);
/**
* Add player to a group.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World Object
* @param player Player name
* @param group Group name
* @return Success or Failure
*/
public boolean playerAddGroup(World world, String player, String group) {
if (world == null) {
return playerAddGroup((String) null, player, group);
}
return playerAddGroup(world.getName(), player, group);
}
/**
* Add player to a group.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World Object
* @param playerId UUID
* @param group Group name
* @return Success or Failure
*/
public boolean playerAddGroup(World world, UUID playerId, String group) {
if (world == null) {
return playerAddGroup((String) null, Bukkit.getOfflinePlayer(playerId).getName(), group);
}
return playerAddGroup(world.getName(), Bukkit.getOfflinePlayer(playerId).getName(), group);
}
/**
* Add player to a group.
* This will add a player to the group on the current World. This may return odd results if the permission system
* being used on the server does not support world-specific groups, or if the group being added to is a global group.
*
* @param player Player Object
* @param group Group name
* @return Success or Failure
*/
public boolean playerAddGroup(Player player, String group) {
return playerAddGroup(player.getWorld().getName(), player.getName(), group);
}
/**
* Remove player from a group.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World name
* @param player Player name
* @param group Group name
* @return Success or Failure
*/
abstract public boolean playerRemoveGroup(String world, String player, String group);
/**
* Remove player from a group.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World Object
* @param player Player name
* @param group Group name
* @return Success or Failure
*/
public boolean playerRemoveGroup(World world, String player, String group) {
if (world == null) {
return playerRemoveGroup((String) null, player, group);
}
return playerRemoveGroup(world.getName(), player, group);
}
/**
* Remove player from a group.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World Object
* @param playerId UUID
* @param group Group name
* @return Success or Failure
*/
public boolean playerRemoveGroup(World world, UUID playerId, String group) {
if (world == null) {
return playerRemoveGroup((String) null, Bukkit.getOfflinePlayer(playerId).getName(), group);
}
return playerRemoveGroup(world.getName(), Bukkit.getOfflinePlayer(playerId).getName(), group);
}
/**
* Remove player from a group.
* This will add a player to the group on the current World. This may return odd results if the permission system
* being used on the server does not support world-specific groups, or if the group being added to is a global group.
*
* @param player Player Object
* @param group Group name
* @return Success or Failure
*/
public boolean playerRemoveGroup(Player player, String group) {
return playerRemoveGroup(player.getWorld().getName(), player.getName(), group);
}
/**
* Gets the list of groups that this player has.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World name
* @param player Player name
* @return Array of groups
*/
abstract public String[] getPlayerGroups(String world, String player);
/**
* Gets the list of groups that this player has
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World Object
* @param player Player name
* @return Array of groups
*/
public String[] getPlayerGroups(World world, String player) {
if (world == null) {
return getPlayerGroups((String) null, player);
}
return getPlayerGroups(world.getName(), player);
}
/**
* Gets the list of groups that this player has
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World Object
* @param playerId UUID
* @return Array of groups
*/
public String[] getPlayerGroups(World world, UUID playerId) {
return getPlayerGroups(world, Bukkit.getOfflinePlayer(playerId).getName());
}
/**
* Returns a list of world-specific groups that this player is currently in. May return unexpected results if
* you are looking for global groups, or if the registered permission system does not support world-specific groups.
*
* @param player Player Object
* @return Array of groups
*/
public String[] getPlayerGroups(Player player) {
return getPlayerGroups(player.getWorld().getName(), player.getName());
}
/**
* Gets players primary group
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World name
* @param player Player name
* @return Players primary group
*/
abstract public String getPrimaryGroup(String world, String player);
/**
* Gets players primary group
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World Object
* @param player Player name
* @return Players primary group
*/
public String getPrimaryGroup(World world, String player) {
if (world == null) {
return getPrimaryGroup((String) null, player);
}
return getPrimaryGroup(world.getName(), player);
}
/**
* Gets players primary group
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world World Object
* @param playerId UUID of the player
* @return Players primary group
*/
public String getPrimaryGroup(World world, UUID playerId) {
return getPrimaryGroup(world, Bukkit.getOfflinePlayer(playerId).getName());
}
/**
* Get players primary group
* @param player Player Object
* @return Players primary group
*/
public String getPrimaryGroup(Player player) {
return getPrimaryGroup(player.getWorld().getName(), player.getName());
}
/**
* Returns a list of all known groups
* @return an Array of String of all groups
*/
abstract public String[] getGroups();
/**
* Returns true if the given implementation supports groups.
* @return true if the implementation supports groups
*/
abstract public boolean hasGroupSupport();
}

View File

@ -0,0 +1,86 @@
package net.milkbowl.vault.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.EnumSet;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.junit.Test;
import net.milkbowl.vault.item.ItemInfo;
import net.milkbowl.vault.item.Items;
@SuppressWarnings("deprecation")
public class ItemTest {
// Static list of materials we shouldn't be testing for as they are now longer able to be help in inventory.
private static final Set<Material> ignoreMats = EnumSet.noneOf(Material.class);
{
ignoreMats.add(Material.STATIONARY_WATER);
ignoreMats.add(Material.STATIONARY_LAVA);
ignoreMats.add(Material.PISTON_EXTENSION);
ignoreMats.add(Material.PISTON_MOVING_PIECE);
ignoreMats.add(Material.REDSTONE_WIRE);
ignoreMats.add(Material.CROPS);
ignoreMats.add(Material.BURNING_FURNACE);
ignoreMats.add(Material.SIGN_POST);
ignoreMats.add(Material.WOODEN_DOOR);
ignoreMats.add(Material.WALL_SIGN);
ignoreMats.add(Material.IRON_DOOR_BLOCK);
ignoreMats.add(Material.GLOWING_REDSTONE_ORE);
ignoreMats.add(Material.SUGAR_CANE_BLOCK);
ignoreMats.add(Material.CAKE_BLOCK);
ignoreMats.add(Material.DIODE_BLOCK_OFF);
ignoreMats.add(Material.DIODE_BLOCK_ON);
ignoreMats.add(Material.LOCKED_CHEST);
ignoreMats.add(Material.PUMPKIN_STEM);
ignoreMats.add(Material.MELON_STEM);
ignoreMats.add(Material.REDSTONE_LAMP_ON);
ignoreMats.add(Material.SKULL);
ignoreMats.add(Material.REDSTONE_COMPARATOR_OFF);
ignoreMats.add(Material.REDSTONE_COMPARATOR_ON);
}
@Test
public void testItems() {
boolean failed = false;
for (ItemInfo item : Items.getItemList()) {
ItemInfo queriedInfo = Items.itemByString(item.getName());
try {
assertEquals(item, queriedInfo);
} catch (AssertionError e) {
e.printStackTrace();
failed = true;
}
}
assertEquals(false, failed);
}
@Test
public void testItemStacks() {
boolean failed = false;
for (ItemInfo item : Items.getItemList()) {
ItemStack stack = item.toStack();
try {
assertEquals(item, Items.itemByStack(stack));
} catch (AssertionError e) {
e.printStackTrace();
failed = true;
}
}
assertEquals(false, failed);
}
@Test
public void MissingMaterialtest() {
for (Material mat : Material.values()) {
if (ignoreMats.contains(mat)) continue;
assertNotNull("Missing " + mat.toString() + " in item search list", Items.itemByType(mat));
}
}
}