mirror of
https://github.com/Flowsqy/ShopChest.git
synced 2024-11-13 23:05:21 +01:00
Add the draft of the transaction structure
This commit is contained in:
parent
1d136933a7
commit
a91e9c1661
17
plugin/src/main/java/de/epiceric/shopchest/shop/Product.java
Normal file
17
plugin/src/main/java/de/epiceric/shopchest/shop/Product.java
Normal file
@ -0,0 +1,17 @@
|
||||
package de.epiceric.shopchest.shop;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Product {
|
||||
|
||||
private final ItemStack itemStack;
|
||||
private final ProductValue productValue;
|
||||
|
||||
public Product(ItemStack itemStack, ProductValue productValue) {
|
||||
this.itemStack = itemStack;
|
||||
this.productValue = productValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package de.epiceric.shopchest.shop;
|
||||
|
||||
public class ProductValue {
|
||||
|
||||
private final int amount;
|
||||
private final double price;
|
||||
|
||||
}
|
18
plugin/src/main/java/de/epiceric/shopchest/shop/Shop_.java
Normal file
18
plugin/src/main/java/de/epiceric/shopchest/shop/Shop_.java
Normal file
@ -0,0 +1,18 @@
|
||||
package de.epiceric.shopchest.shop;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Shop_ {
|
||||
|
||||
private final ItemStack itemStack;
|
||||
private final ProductValue buyValue, sellValue;
|
||||
|
||||
public Product getBuyProduct() {
|
||||
return new Product(itemStack, buyValue);
|
||||
}
|
||||
|
||||
public Product getSellProduct() {
|
||||
return new Product(itemStack, sellValue);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package de.epiceric.shopchest.transaction;
|
||||
|
||||
public interface Actor {
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package de.epiceric.shopchest.transaction;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Transaction {
|
||||
|
||||
private final Actor buyer, seller;
|
||||
private final ItemStack itemStack;
|
||||
private int amount;
|
||||
private final double buyPrice, sellPrice;
|
||||
|
||||
public void apply() {
|
||||
if(!check()) {
|
||||
return;
|
||||
}
|
||||
|
||||
transferItems();
|
||||
|
||||
transferMoney();
|
||||
|
||||
inform();
|
||||
|
||||
// log
|
||||
}
|
||||
|
||||
private boolean check() {
|
||||
// Check buyer money
|
||||
|
||||
// Check seller item quantity
|
||||
|
||||
// Check buyer inventory space
|
||||
}
|
||||
|
||||
private void transferItems() {
|
||||
// Remove items from seller inventory
|
||||
|
||||
// Add items in buyer inventory
|
||||
}
|
||||
|
||||
private void transferMoney() {
|
||||
// Remove buyer money
|
||||
|
||||
// Add seller money
|
||||
}
|
||||
|
||||
private void inform() {
|
||||
// Inform buyer
|
||||
|
||||
// Inform seller
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package de.epiceric.shopchest.transaction;
|
||||
|
||||
import de.epiceric.shopchest.shop.Product;
|
||||
|
||||
public class TransactionRequest {
|
||||
|
||||
private final Actor buyer, seller;
|
||||
private final Product product;
|
||||
private final int amount;
|
||||
|
||||
public Transaction prepare() {
|
||||
// Calculate price
|
||||
|
||||
// Apply taxes
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user