# ShopUtils (ShopChest 1.12 API)
Date: 2017-06-08

de.epiceric.shopchest.utils

## Class ShopUtils

- java.lang.Object
- - de.epiceric.shopchest.utils.ShopUtils

    public class ShopUtils
    extends Object

### Constructor Summary

Constructors
Constructor and Description
`ShopUtils(ShopChest plugin)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addShop(Shop shop, boolean addToDatabase)` Add a shop
`void` `addShop(Shop shop, boolean addToDatabase, Callback callback)` Add a shop
`Shop` `getShop(org.bukkit.Location location)` Get the shop at a given location
`int` `getShopAmount(org.bukkit.OfflinePlayer p)` Get the amount of shops of a player
`int` `getShopLimit(org.bukkit.entity.Player p)` Get the shop limits of a player
`Shop[]` `getShops()` Get all Shops
`boolean` `isShop(org.bukkit.Location location)` Checks whether there is a shop at a given location
`void` `reloadShops(boolean reloadConfig, boolean showConsoleMessages, Callback callback)` Reload the shops
`void` `removeShop(Shop shop, boolean removeFromDatabase)` Remove a shop
`void` `removeShop(Shop shop, boolean removeFromDatabase, Callback callback)` Remove a shop
`void` `updateShop(Shop shop, org.bukkit.entity.Player player)` Update hologram and item of the shop for a player based on their distance to each other
`void` `updateShops(org.bukkit.entity.Player player)` Update hologram and item of all shops for a player
`void` `updateShops(org.bukkit.entity.Player player, boolean force)` Update hologram and item of all shops for a player

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### ShopUtils

    public ShopUtils(ShopChest plugin)

### Method Detail

#### getShop

    public Shop getShop(org.bukkit.Location location)

Get the shop at a given location

Parameters:
  `location` - Location of the shop
Returns:
  Shop at the given location or null if no shop is found there

#### isShop

    public boolean isShop(org.bukkit.Location location)

Checks whether there is a shop at a given location

Parameters:
  `location` - Location to check
Returns:
  Whether there is a shop at the given location

#### getShops

    public Shop[] getShops()

Get all Shops

Returns:
  Array of all Shops

#### addShop

    public void addShop(Shop shop,
                        boolean addToDatabase,
                        Callback callback)

Add a shop

Parameters:
  `shop` - Shop to add
  `addToDatabase` - Whether the shop should also be added to the database
  `callback` - Callback that - if succeeded - returns the ID the shop had or was given (as `int`)

#### addShop

    public void addShop(Shop shop,
                        boolean addToDatabase)

Add a shop

Parameters:
  `shop` - Shop to add
  `addToDatabase` - Whether the shop should also be added to the database

#### removeShop

    public void removeShop(Shop shop,
                           boolean removeFromDatabase,
                           Callback callback)

Remove a shop

Parameters:
  `shop` - Shop to remove
  `removeFromDatabase` - Whether the shop should also be removed from the database
  `callback` - Callback that - if succeeded - returns null

#### removeShop

    public void removeShop(Shop shop,
                           boolean removeFromDatabase)

Remove a shop

Parameters:
  `shop` - Shop to remove
  `removeFromDatabase` - Whether the shop should also be removed from the database

#### getShopLimit

    public int getShopLimit(org.bukkit.entity.Player p)

Get the shop limits of a player

Parameters:
  `p` - Player, whose shop limits should be returned
Returns:
  The shop limits of the given player

#### getShopAmount

    public int getShopAmount(org.bukkit.OfflinePlayer p)

Get the amount of shops of a player

Parameters:
  `p` - Player, whose shops should be counted
Returns:
  The amount of a shops a player has (if `Config.exclude_admin_shops` is true, admin shops won't be counted)

#### reloadShops

    public void reloadShops(boolean reloadConfig,
                            boolean showConsoleMessages,
                            Callback callback)

Reload the shops

Parameters:
  `reloadConfig` - Whether the configuration should also be reloaded
  `showConsoleMessages` - Whether messages about the language file should be shown in the console
  `callback` - Callback that - if succeeded - returns the amount of shops that were reloaded (as `int`)

#### updateShops

    public void updateShops(org.bukkit.entity.Player player)

Update hologram and item of all shops for a player

Parameters:
  `player` - Player to show the updates

#### updateShops

    public void updateShops(org.bukkit.entity.Player player,
                            boolean force)

Update hologram and item of all shops for a player

Parameters:
  `player` - Player to show the updates
  `force` - Whether update should be forced even if player has not moved

#### updateShop

    public void updateShop(Shop shop,
                           org.bukkit.entity.Player player)

Update hologram and item of the shop for a player based on their distance to each other

Parameters:
  `shop` - Shop to update
  `player` - Player to show the update