BossShop API

More detailed Docs cooming soon!

How to hook into BossShop?

import org.black_ixx.bossshop.BossShop;
import org.black_ixx.bossshop.api.BossShopAPI;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;

public class BossShopManager {

	
	private BossShop bs; //BossShop Plugin Instance
	
	public BossShopManager(){
		
		Plugin plugin = Bukkit.getPluginManager().getPlugin("BossShop"); //Get BossShop Plugin
		
		if(plugin==null){ //Not installed? 
			System.out.print("[BS Hook] BossShop was not found... you can download it here: http://dev.bukkit.org/bukkit-plugins/bossshop");
			return;
		}
		
		bs = (BossShop) plugin; //Detected with Success :)
		
	}
	
	
	public BossShopAPI getBossShopAPI(){
		return bs.getAPI(); //Returns BossShop API
	}
	
	

The API should be easy to understand. Here are a few examples!

Open Shop

	public boolean openShop(Player p, String shop_name){
		
		BSShop shop = bs.getAPI().getShop(shop_name);
		if(shop==null){
			p.sendMessage(ChatColor.RED+"Shop "+shop_name+" not found...");
			return false;
		}
		
		bs.getAPI().openShop(p, shop);
		
		return true;
	}

Check if an Inventory is a BossShop Inventory

		//Example: InventoryEvent
		if(bs.getAPI().isValidShop(event.getInventory())){
			//Do Shop Inventory Action
		}else{
			//Rest
		}

More advanced Coding: Adding Items to Shop

		//Create a custom BSBuy (Shop Item)
		BSBuy buy = bs.getAPI().createBSBuy(BSBuyType.Shop, BSPriceType.Free, "item_shop", null, null, 1, "OpenShop.Item_Shop");
		
		//Get a Shop
		BSShop shop = bs.getAPI().getShop("menu");
		
		//Add it to the Shop
		ItemStack menu_item = [...]
		bs.getAPI().addItemToShop(menu_item, buy, shop);

Create a Shop Item with a custom Action

//First of all, you need to define the action/s!

		//Creation of Custom Action Start
		BSCustomActions actions = new BSCustomActions() {		
			public void customAction(Player p, int action_id) {		
				//Something
				//[...]
				//Something
			}
		};
		//Creation of Custom Action End

		//Create a BSCustomLink with the actions defined in "actions". When this link is triggered, the method "customAction(<player>, 1)" is executed.
		BSCustomLink link = bs.getAPI().createBSCustomLink( actions , 1);
		
		//Create a custom BSBuy
		BSBuy buy = bs.getAPI().createBSBuyCustom(BSBuyType.Custom, BSPriceType.Money, link, 100, "Custom action executed.", 1, "CustomAction.Permission");

		//Get a Shop
		BSShop shop = bs.getAPI().getShop("menu");

		//Add it to the Shop
		ItemStack menu_item = [...];
		bs.getAPI().addItemToShop(menu_item, buy, shop);

Other (bigger) example

In this example, the Actions are defined in a new class

public class BSHCustomActions implements BSCustomActions{

	//All Actions are defined in this class!

		/*Goal:
		 * *Item1 strikes the player for money (Sense? xD)
		 *  Item2 feeds the player for money
		 *  Item3 gives a random Item for EXP
		 */

	//List of Items (Later one of them will be chosen randomly)
	private List<ItemStack> items = new ArrayList<ItemStack>();


	public BSHCustomActions(){
		
		//Adding Items to the List
		items.add(new ItemStack(Material.DIAMOND,5));
		items.add(new ItemStack(Material.DIAMOND,1));
		items.add(new ItemStack(Material.GOLD_INGOT,5));
		items.add(new ItemStack(Material.IRON_INGOT,25));
		items.add(new ItemStack(Material.IRON_INGOT,5));
		items.add(new ItemStack(Material.COAL,30));
		items.add(new ItemStack(Material.DIRT,1));
		items.add(new ItemStack(Material.DIRT,1));
		items.add(new ItemStack(Material.DIRT,1));
		items.add(new ItemStack(Material.DIRT,1));
		items.add(new ItemStack(Material.DIRT,1));
		items.add(new ItemStack(Material.DIRT,1));	
	}
	

	//Main Method
	public void customAction(Player p, int action_id) {		

		switch(action_id){

		case 1:
			//Strikes the player with lightning
			p.getWorld().strikeLightning(p.getLocation()); 
			return;

		case 2:
			//Feeds the player
			p.setFoodLevel(20);
			return;

		case 3:
			//Gets a random Item of the list
			ItemStack item = items.get((int)(Math.random()*items.size()));
			//Adds copy of the chosen Item to the players Inventory
			p.getInventory().addItem(item.clone());
			return;


		}
	}


}
		/*Goal:
		 * *Item1 strikes the player for money (Sense? xD)
		 *  Item2 feeds the player for money
		 *  Item3 gives a random Item for EXP
		 */

		BSCustomActions actions = new BSHCustomActions(); //Create Actions

		//Create BSCustomLink with the actions defined in "actions".
		BSCustomLink link1 = bs.getAPI().createBSCustomLink( actions , 1);
		BSCustomLink link2 = bs.getAPI().createBSCustomLink( actions , 2);
		BSCustomLink link3 = bs.getAPI().createBSCustomLink( actions , 3);
		
		//Create BSBuys
		BSBuy buy1 = bs.getAPI().createBSBuyCustom(BSBuyType.Custom, BSPriceType.Money, link1, 1, "&6Striked! Are you dumb?!", 1, "Permission.Item1");
		BSBuy buy2 = bs.getAPI().createBSBuyCustom(BSBuyType.Custom, BSPriceType.Money, link2, 50, "&6*Feeding*", 2, "Permission.Item2");
		BSBuy buy3 = bs.getAPI().createBSBuyCustom(BSBuyType.Custom, BSPriceType.Exp, link3, 20, "&6You got a random Item...", 3, "Permission.Item3");

		//Get a Shop
		BSShop shop = bs.getAPI().getShop("menu");

		//Add them to the shop
		ItemStack menu_item1 = [...];
		ItemStack menu_item2 = [...];
		ItemStack menu_item3 = [...];
		bs.getAPI().addItemToShop(menu_item1, buy1, shop);
		bs.getAPI().addItemToShop(menu_item2, buy2, shop);
		bs.getAPI().addItemToShop(menu_item3, buy3, shop);
		

Create a BossShop Addon

Instead of extending "JavaPlugin", extend BossShopAddon here!

package org.black_ixx.bossshophook;

import org.black_ixx.bossshop.api.BossShopAddon;
import org.bukkit.command.CommandSender;


public class CoolAddon extends BossShopAddon {

	@Override
	public void bossShopReloaded(CommandSender sender) {
	
		//Reload your Plugin here (Optional)
		
	}

	@Override
	public void disableAddon() {
		
		//Addon disable code
		
	}

	@Override
	public void enableAddon() {
		
		//Addon enable code
		
	}

	@Override
	public String getAddonName() {
		return "CoolAddon"; //Return the exact name of your plugin here! (The one which is in the plugin.yml)
	}

	@Override
	public String getRequiredBossShopVersion() {
		return "1.9.0"; //Return the required BossShop Version here. The new API was added in 1.9.0 btw!
	}
	
	
	//Just a test
	public void testMethod(){
		
		//That method allows you to get the BossShop Plugin Instance
		this.getBossShop();
		
		//That way you can access the BossShop API
		this.getBossShop().getAPI();
				
	}	
	
	

}

Register a custom points plugin

Your plugin first needs to load before BossShop

plugin.yml:

loadbefore: [BossShop]

Extend the IPointsAPI class like so: https://github.com/BossShop/BossShop/blob/master/src/main/java/org/black_ixx/bossshop/points/CommandPointsAPI.java

Then within your onEnable, instantiate your class, and call the register method:

new Points().register();

Events

public class BossShopListener implements Listener{

	@EventHandler
	public void onPurchaseEvent(BSPlayerPurchaseEvent e){
		//Triggered before the transaction is finished and before the price is paid!
	}
	
	@EventHandler
	public void onPurchasedEvent(BSPlayerPurchasedEvent e){
		//Triggered after the transaction is finished, the price is paid and the reward is given!
	}
	
	@EventHandler
	public void onItemDisplayEvent(BSDisplayItemEvent e){
		//Here you can prevent an item from being displayed in the shop:
		if(something){
		e.setCancelled(true);
		}
	}
	

}

Maven

<repositories>
	<repository>
		<id>confuser-repo</id>
		<url>http://ci.frostcast.net/plugin/repository/everything/</url>
	</repository>
</repositories>
<dependencies>
	<dependency>
		<groupId>org.black_ixx</groupId>
		<artifactId>BossShop</artifactId>
		<version>2.1.0</version>
		<scope>provided</scope>
	</dependency>
</dependencies>

Comments

Posts Quoted:
Reply
Clear All Quotes