SETUP: Developer

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:

Method Name

Description

Type

removeCurrency(Player, Currency, Integer);

Method, that removes a certain amount of currency from a player

void

addCurrency(Player, Currency, Integer);

Method, that adds a certain amount of currency to a player

void

setCurrency(Player, Currency, Integer);

Method, that sets the amount of currency of a player

void

hasEnoughCurrency(Player, Currency, Integer);

Returns, if the player has enough amount of a certain currency

boolean

getCurrencies();

Returns a list of the type currency in which are all currencies listed, that the plugin has

List<Currency>

getRequirements();

Returns a list of the type string in which are all requirement types listed, that your plugin can check

List<String>

meetRequirement(Player, String requirement, String req_value);

Returns, if the player meets a certain requirement

boolean

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

Last updated