Search in sources :

Example 1 with ShopBreakEvent

use of com.robomwm.prettysimpleshop.event.ShopBreakEvent in project PrettySimpleShop by MLG-Fortress.

the class ShopListener method onBreakShop.

@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
private void onBreakShop(BlockBreakEvent event) {
    Block block = event.getBlock();
    if (!config.isShopBlock(block.getType()))
        return;
    Container container = (Container) block.getState();
    if (!shopAPI.isShop(container))
        return;
    instance.getServer().getPluginManager().callEvent(new ShopBreakEvent(event.getPlayer(), new ShopInfo(shopAPI.getLocation(container), shopAPI.getItemStack(container), shopAPI.getPrice(container)), event));
    double deposit = shopAPI.getRevenue(container, true);
    if (deposit <= 0)
        return;
    Player player = event.getPlayer();
    economy.depositPlayer(player, deposit);
    config.sendMessage(player, "collectRevenue", economy.format(deposit));
}
Also used : Container(org.bukkit.block.Container) Player(org.bukkit.entity.Player) Block(org.bukkit.block.Block) ShopBreakEvent(com.robomwm.prettysimpleshop.event.ShopBreakEvent) EventHandler(org.bukkit.event.EventHandler)

Aggregations

ShopBreakEvent (com.robomwm.prettysimpleshop.event.ShopBreakEvent)1 Block (org.bukkit.block.Block)1 Container (org.bukkit.block.Container)1 Player (org.bukkit.entity.Player)1 EventHandler (org.bukkit.event.EventHandler)1