74 lines
1.6 KiB
Java
74 lines
1.6 KiB
Java
package com.rsscripting.rswarehouse.item;
|
|
|
|
import com.rsscripting.rswarehouse.session.TransactionSession;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.inventory.ItemStack;
|
|
import com.rsscripting.rswarehouse.dao.ItemDAO;
|
|
|
|
public class TransactionConfirmHandler {
|
|
|
|
public static boolean handle(
|
|
Player player,
|
|
TransactionSession itemSession,
|
|
ItemStack item,
|
|
int amount
|
|
) {
|
|
|
|
if (amount == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (amount > 0) {
|
|
|
|
ItemStack depositItem =
|
|
item.clone();
|
|
|
|
depositItem.setAmount(
|
|
1
|
|
);
|
|
|
|
if (
|
|
TransactionUtils.removeItems(
|
|
player,
|
|
depositItem,
|
|
amount
|
|
)
|
|
) {
|
|
|
|
ItemDAO.addItem(
|
|
player.getUniqueId()
|
|
.toString(),
|
|
player.getName(),
|
|
depositItem,
|
|
amount
|
|
);
|
|
|
|
player.sendMessage(
|
|
"§aYou have deposited "
|
|
+ amount
|
|
+ " items."
|
|
);
|
|
|
|
itemSession.setAmount(
|
|
0
|
|
);
|
|
|
|
TransactionAmountMenu.open(
|
|
player,
|
|
itemSession.getWarehouseItemId(),
|
|
0
|
|
);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} |