2011-05-21 19:55:55 +02:00
|
|
|
package com.Acrobot.ChestShop.Shop;
|
|
|
|
|
|
|
|
import com.Acrobot.ChestShop.Chests.MinecraftChest;
|
|
|
|
import com.Acrobot.ChestShop.Items.Items;
|
2011-07-05 19:08:55 +02:00
|
|
|
import com.Acrobot.ChestShop.Utils.uBlock;
|
2011-06-19 23:52:36 +02:00
|
|
|
import org.bukkit.ChatColor;
|
2011-05-21 19:55:55 +02:00
|
|
|
import org.bukkit.block.Chest;
|
|
|
|
import org.bukkit.block.Sign;
|
|
|
|
import org.bukkit.entity.Player;
|
2011-06-19 23:52:36 +02:00
|
|
|
import org.bukkit.inventory.ItemStack;
|
2011-05-21 19:55:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Acrobot
|
|
|
|
*/
|
|
|
|
public class ShopManagement {
|
2012-03-17 15:00:25 +01:00
|
|
|
public static boolean useOldChest = false;
|
|
|
|
|
2011-07-23 21:00:47 +02:00
|
|
|
public static void buy(Sign sign, Player player) {
|
2012-04-07 12:41:20 +02:00
|
|
|
Shop shop = getShop(sign, player);
|
|
|
|
if (shop != null) {
|
|
|
|
shop.buy(player);
|
2011-06-19 23:52:36 +02:00
|
|
|
}
|
2011-05-21 19:55:55 +02:00
|
|
|
}
|
|
|
|
|
2011-07-23 21:00:47 +02:00
|
|
|
public static void sell(Sign sign, Player player) {
|
2012-04-07 12:41:20 +02:00
|
|
|
Shop shop = getShop(sign, player);
|
|
|
|
if (shop != null) {
|
|
|
|
shop.sell(player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Shop getShop(Sign sign, Player player) {
|
2011-07-05 19:08:55 +02:00
|
|
|
Chest chestMc = uBlock.findChest(sign);
|
2011-06-19 23:52:36 +02:00
|
|
|
ItemStack item = Items.getItemStack(sign.getLine(3));
|
2011-07-02 20:34:14 +02:00
|
|
|
if (item == null) {
|
2011-06-19 23:52:36 +02:00
|
|
|
player.sendMessage(ChatColor.RED + "[Shop] The item is not recognised!");
|
2012-04-07 12:41:20 +02:00
|
|
|
return null;
|
2011-06-19 23:52:36 +02:00
|
|
|
}
|
2012-04-07 12:41:20 +02:00
|
|
|
return new Shop(chestMc != null ? new MinecraftChest(chestMc) : null, false, sign, item);
|
2012-03-17 15:00:25 +01:00
|
|
|
}
|
2011-05-21 19:55:55 +02:00
|
|
|
}
|