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 {
|
2011-07-23 21:00:47 +02:00
|
|
|
public static void buy(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!");
|
2011-07-23 21:00:47 +02:00
|
|
|
return;
|
2011-06-19 23:52:36 +02:00
|
|
|
}
|
2011-07-23 21:00:47 +02:00
|
|
|
Shop shop = new Shop(chestMc != null ? new MinecraftChest(chestMc) : null, true, sign, item);
|
|
|
|
shop.buy(player);
|
2011-05-21 19:55:55 +02:00
|
|
|
}
|
|
|
|
|
2011-07-23 21:00:47 +02:00
|
|
|
public static void sell(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!");
|
2011-07-23 21:00:47 +02:00
|
|
|
return;
|
2011-06-19 23:52:36 +02:00
|
|
|
}
|
2011-07-23 21:00:47 +02:00
|
|
|
Shop shop = new Shop(chestMc != null ? new MinecraftChest(chestMc) : null, false, sign, item);
|
|
|
|
shop.sell(player);
|
2011-05-21 19:55:55 +02:00
|
|
|
}
|
|
|
|
}
|