The following page is for developers, that like to hook into DeluxeShop, to expand their plugin with an easy to use shop.
Import DeluxeShop into your IDE library
First thing you need to do is adding the DeluxeShop.jar to your library of your IDE. Please check the manual of your IDE to know, how you can do that.
Creating a ShopHook
Simply create a new class which you will expand by the ShopHook. After that, let your IDE insert all needed methods.
import java.util.List;
import org.bukkit.entity.Player;
import de.timderspieler.deluxeshop.external.Currency;
import de.timderspieler.deluxeshop.external.ShopHook;
public class TestHook extends ShopHook{
@Override
public void removeCurrency(Player p, Currency currency, int amount) {
// TODO Auto-generated method stub
}
@Override
public void addCurrency(Player p, Currency currency, int amount) {
// TODO Auto-generated method stub
}
@Override
public void setCurrency(Player p, Currency currency, int amount) {
// TODO Auto-generated method stub
}
@Override
public boolean meetRequirement(Player p, String requirement_type, String value) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean hasEnoughCurrency(Player p, Currency currency, int amount) {
// TODO Auto-generated method stub
return false;
}
@Override
public List<String> getRequirementTypes() {
// TODO Auto-generated method stub
return null;
}
@Override
public List<Currency> getCurrencies() {
// TODO Auto-generated method stub
return null;
}
}
Here are the methods explained:
The currency class
The currency class is a simple class which contains the name of the currency and two other strings, which represent the singular and the plural name of the currency such as DOLLAR and DOLLARS
public Currency getDollarCurrency() {
return new Currency("myCurrency", "DOLLAR", "DOLLARS");
}
Register the shop hook
After you have finished writing all methods, you can register the shop hook, so that you can hook into DeluxeShop.
For this go e.g to your onEnable() method and add following code block:
public class myPlugin extends JavaPlugin {
private static myPlugin m;
public void onEnable() {
m = this;
if (!(Bukkit.getPluginManager().getPlugin("DeluxeShop") == null || !Bukkit.getPluginManager().getPlugin("DeluxeShop").isEnabled())) {
DeluxeShop.registerHook(getPlugin(), new TestHook());
}
}
public static myPlugin getPlugin() { return m; }
}
Please make sure to add DeluxeShop as a softdependency to your plugin.yml