Pre Production commit

This commit is contained in:
Kiran Hart 2018-08-14 11:38:24 -04:00
parent 0bf60cac3c
commit f2ddaad9d9
8 changed files with 186 additions and 8 deletions

View File

@ -123,6 +123,7 @@ public class AuctionAPI {
Core.getInstance().getConfig().getStringList(node + ".lore").forEach(s -> lore.add(ChatColor.translateAlternateColorCodes('&', s))); Core.getInstance().getConfig().getStringList(node + ".lore").forEach(s -> lore.add(ChatColor.translateAlternateColorCodes('&', s)));
meta.setLore(lore); meta.setLore(lore);
stack.setItemMeta(meta); stack.setItemMeta(meta);
stack = (usr == 0) ? NBTEditor.setItemTag(stack, seller, "AuctionSellerHead") : NBTEditor.setItemTag(stack, buyer, "AuctionBuyerHead");
return stack; return stack;
} }

View File

@ -86,7 +86,7 @@ public class Transaction {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("transaction.name").replace("{transaction_id}", Core.getInstance().getTransactions().getConfig().getString("transactions." + node + ".auction-id")))); meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("transaction.name").replace("{transaction_id}", Core.getInstance().getTransactions().getConfig().getString("transactions." + node + ".auction-id"))));
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
Core.getInstance().getConfig().getStringList("transaction.lore").forEach(e-> lore.add(ChatColor.translateAlternateColorCodes('&', e.replace("{buyer}", Bukkit.getOfflinePlayer(UUID.fromString(Core.getInstance().getTransactions().getConfig().getString("transactions." + node + ".buyer"))).getName()).replace("{seller}", Bukkit.getOfflinePlayer(UUID.fromString(Core.getInstance().getTransactions().getConfig().getString("transactions." + node + ".seller"))).getName())))); Core.getInstance().getConfig().getStringList("transaction.lore").forEach(e -> lore.add(ChatColor.translateAlternateColorCodes('&', e.replace("{buyer}", Bukkit.getOfflinePlayer(UUID.fromString(Core.getInstance().getTransactions().getConfig().getString("transactions." + node + ".buyer"))).getName()).replace("{seller}", Bukkit.getOfflinePlayer(UUID.fromString(Core.getInstance().getTransactions().getConfig().getString("transactions." + node + ".seller"))).getName()))));
meta.setLore(lore); meta.setLore(lore);
item.setItemMeta(meta); item.setItemMeta(meta);
item = NBTEditor.setItemTag(item, node, "AuctionTransactionID"); item = NBTEditor.setItemTag(item, node, "AuctionTransactionID");
@ -100,6 +100,18 @@ public class Transaction {
return items; return items;
} }
public static List<ItemStack> getAllRecordedTransactionsByPlayer(Player p) {
List<ItemStack> items = new ArrayList<>();
if (getTotalTransactions() == 0) return items;
if (getTotalTransactionsByPlayer(p) == 0) return items;
for (String node : Core.getInstance().getTransactions().getConfig().getConfigurationSection("transactions").getKeys(false)) {
if (Core.getInstance().getTransactions().getConfig().getString("transactions." + node + ".seller").equalsIgnoreCase(p.getUniqueId().toString()) || Core.getInstance().getTransactions().getConfig().getString("transactions." + node + ".buyer").equalsIgnoreCase(p.getUniqueId().toString())) {
items.add(getTransactionItem(node));
}
}
return items;
}
public TransactionType getTransactionType() { public TransactionType getTransactionType() {
return transactionType; return transactionType;
} }

View File

@ -25,7 +25,7 @@ public class PlayerListener implements Listener {
public void onReceiptRightClick(PlayerInteractEvent e) { public void onReceiptRightClick(PlayerInteractEvent e) {
Player p = e.getPlayer(); Player p = e.getPlayer();
if (e.getAction() != Action.RIGHT_CLICK_AIR || e.getAction() != Action.RIGHT_CLICK_BLOCK) { if (e.getAction() != Action.RIGHT_CLICK_AIR) {
return; return;
} }

View File

@ -65,7 +65,7 @@ public class AllTransactionsGUI implements AGUI {
@Override @Override
public Inventory getInventory() { public Inventory getInventory() {
Inventory inventory = Bukkit.createInventory(this, 54, ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("gui.collection.title"))); Inventory inventory = Bukkit.createInventory(this, 54, ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("gui.alltransactions.title")));
//Bottom Row //Bottom Row
inventory.setItem(48, AuctionAPI.getInstance().createConfigItem("gui.alltransactions.items.previouspage", 0, 0)); inventory.setItem(48, AuctionAPI.getInstance().createConfigItem("gui.alltransactions.items.previouspage", 0, 0));

View File

@ -0,0 +1,98 @@
package com.shadebyte.auctionhouse.inventory.inventories;
import com.google.common.collect.Lists;
import com.shadebyte.auctionhouse.Core;
import com.shadebyte.auctionhouse.api.AuctionAPI;
import com.shadebyte.auctionhouse.auction.Transaction;
import com.shadebyte.auctionhouse.inventory.AGUI;
import com.shadebyte.auctionhouse.util.NBTEditor;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.List;
/**
* The current file has been created by Kiran Hart
* Date Created: 7/6/2018
* Time Created: 11:56 AM
* Usage of any code found within this class is prohibited unless given explicit permission otherwise.
*/
public class PlayerTransactionsGUI implements AGUI {
private Player p;
private List<List<ItemStack>> chunks;
private int page = 1;
public PlayerTransactionsGUI(Player p) {
this.p = p;
chunks = Lists.partition(Transaction.getAllRecordedTransactionsByPlayer(p), 45);
}
@Override
public void click(InventoryClickEvent e, ItemStack clicked, int slot) {
e.setCancelled(true);
try {
if (page >= 1 && slot == 48) p.openInventory(this.setPage(this.getPage() - 1).getInventory());
if (page >= 1 && slot == 50) p.openInventory(this.setPage(this.getPage() + 1).getInventory());
} catch (Exception e1) {
}
if (slot == 49) p.closeInventory();
if (slot >= 0 & slot <= 44) {
if (clicked == null || clicked.getType() == Material.AIR) {
return;
}
if (e.getClick() == ClickType.LEFT) {
String key = (String) NBTEditor.getItemTag(clicked, "AuctionTransactionID");
p.closeInventory();
p.openInventory(new SingleTransactionGUI(key).getInventory());
}
}
}
@Override
public void close(InventoryCloseEvent e) {
}
@Override
public Inventory getInventory() {
Inventory inventory = Bukkit.createInventory(this, 54, ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("gui.playertransactions.title").replace("{player}", p.getName())));
//Bottom Row
inventory.setItem(48, AuctionAPI.getInstance().createConfigItem("gui.playertransactions.items.previouspage", 0, 0));
inventory.setItem(49, AuctionAPI.getInstance().createConfigItem("gui.playertransactions.items.close", 0, 0));
inventory.setItem(50, AuctionAPI.getInstance().createConfigItem("gui.playertransactions.items.nextpage", 0, 0));
if (Transaction.getTotalTransactions() == 0) {
return inventory;
}
if (chunks.size() != 0)
chunks.get(getPage() - 1).forEach(item -> inventory.setItem(inventory.firstEmpty(), item));
return inventory;
}
public PlayerTransactionsGUI setPage(int page) {
if (page <= 0)
this.page = 1;
else
this.page = page;
return this;
}
public int getPage() {
return page;
}
}

View File

@ -2,15 +2,18 @@ package com.shadebyte.auctionhouse.inventory.inventories;
import com.shadebyte.auctionhouse.Core; import com.shadebyte.auctionhouse.Core;
import com.shadebyte.auctionhouse.api.AuctionAPI; import com.shadebyte.auctionhouse.api.AuctionAPI;
import com.shadebyte.auctionhouse.auction.Transaction;
import com.shadebyte.auctionhouse.inventory.AGUI; import com.shadebyte.auctionhouse.inventory.AGUI;
import com.shadebyte.auctionhouse.util.NBTEditor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.UUID;
/** /**
* The current file has been created by Kiran Hart * The current file has been created by Kiran Hart
* Date Created: 8/7/2018 * Date Created: 8/7/2018
@ -28,6 +31,21 @@ public class SingleTransactionGUI implements AGUI {
@Override @Override
public void click(InventoryClickEvent e, ItemStack clicked, int slot) { public void click(InventoryClickEvent e, ItemStack clicked, int slot) {
e.setCancelled(true); e.setCancelled(true);
Player p = (Player) e.getWhoClicked();
if (slot == 39) ;
if (slot == 40) p.openInventory(new PlayerTransactionsGUI(p).getInventory());
if (slot == 41) p.openInventory(new AuctionGUI(p).getInventory());
if (slot == 30 && NBTEditor.getItemTag(clicked, "AuctionSellerHead") != null) {
String id = (String) NBTEditor.getItemTag(e.getCurrentItem(), "AuctionSellerHead");
p.openInventory(new PlayerTransactionsGUI(Bukkit.getOfflinePlayer(UUID.fromString(id)).getPlayer()).getInventory());
}
if (slot == 32 && NBTEditor.getItemTag(clicked, "AuctionBuyerHead") != null) {
String id = (String) NBTEditor.getItemTag(e.getCurrentItem(), "AuctionBuyerHead");
p.openInventory(new PlayerTransactionsGUI(Bukkit.getOfflinePlayer(UUID.fromString(id)).getPlayer()).getInventory());
}
} }
@Override @Override
@ -39,7 +57,8 @@ public class SingleTransactionGUI implements AGUI {
public Inventory getInventory() { public Inventory getInventory() {
Inventory inventory = Bukkit.createInventory(this, 54, ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("gui.singletransaction.title"))); Inventory inventory = Bukkit.createInventory(this, 54, ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("gui.singletransaction.title")));
//Fill Inventory //Fill Inventory
for (int i = 0; i < inventory.getSize(); i++) inventory.setItem(i, AuctionAPI.getInstance().createConfigItem("gui.singletransaction.items.background", 0, 0)); for (int i = 0; i < inventory.getSize(); i++)
inventory.setItem(i, AuctionAPI.getInstance().createConfigItem("gui.singletransaction.items.background", 0, 0));
inventory.setItem(13, Core.getInstance().getTransactions().getConfig().getItemStack("transactions." + transactionNode + ".item")); inventory.setItem(13, Core.getInstance().getTransactions().getConfig().getItemStack("transactions." + transactionNode + ".item"));
inventory.setItem(39, AuctionAPI.getInstance().createConfigItem("gui.singletransaction.items.back", 0, 0)); inventory.setItem(39, AuctionAPI.getInstance().createConfigItem("gui.singletransaction.items.back", 0, 0));
@ -50,9 +69,9 @@ public class SingleTransactionGUI implements AGUI {
inventory.setItem(31, Core.getInstance().getTransactions().getConfig().getItemStack("transactions." + transactionNode + ".receipt")); inventory.setItem(31, Core.getInstance().getTransactions().getConfig().getItemStack("transactions." + transactionNode + ".receipt"));
inventory.setItem(32, AuctionAPI.getInstance().createUserHead("gui.singletransaction.items.buyer", "", Core.getInstance().getTransactions().getConfig().getString("transactions." + transactionNode + ".buyer"), 1)); inventory.setItem(32, AuctionAPI.getInstance().createUserHead("gui.singletransaction.items.buyer", "", Core.getInstance().getTransactions().getConfig().getString("transactions." + transactionNode + ".buyer"), 1));
inventory.setItem(48, AuctionAPI.getInstance().createTransactionConfigItem("gui.singletransaction.items.startprice", "", "", Core.getInstance().getTransactions().getConfig().getInt("transactions." + transactionNode + ".start-price"),0,0)); inventory.setItem(48, AuctionAPI.getInstance().createTransactionConfigItem("gui.singletransaction.items.startprice", "", "", Core.getInstance().getTransactions().getConfig().getInt("transactions." + transactionNode + ".start-price"), 0, 0));
inventory.setItem(49, AuctionAPI.getInstance().createTransactionConfigItem("gui.singletransaction.items.increment", "", "", 0,Core.getInstance().getTransactions().getConfig().getInt("transactions." + transactionNode + ".bid-increment"),0)); inventory.setItem(49, AuctionAPI.getInstance().createTransactionConfigItem("gui.singletransaction.items.increment", "", "", 0, Core.getInstance().getTransactions().getConfig().getInt("transactions." + transactionNode + ".bid-increment"), 0));
inventory.setItem(50, AuctionAPI.getInstance().createTransactionConfigItem("gui.singletransaction.items.buynowprice", "", "", 0,0,Core.getInstance().getTransactions().getConfig().getInt("transactions." + transactionNode + ".buy-now-price"))); inventory.setItem(50, AuctionAPI.getInstance().createTransactionConfigItem("gui.singletransaction.items.buynowprice", "", "", 0, 0, Core.getInstance().getTransactions().getConfig().getInt("transactions." + transactionNode + ".buy-now-price")));
return inventory; return inventory;
} }

View File

@ -0,0 +1,31 @@
package com.shadebyte.auctionhouse.inventory.inventories;
import com.shadebyte.auctionhouse.inventory.AGUI;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
/**
* The current file has been created by Kiran Hart
* Date Created: 8/14/2018
* Time Created: 11:37 AM
* Usage of any code found within this class is prohibited unless given explicit permission otherwise.
*/
public class TransactionSelectGUI implements AGUI {
@Override
public void click(InventoryClickEvent e, ItemStack clicked, int slot) {
}
@Override
public void close(InventoryCloseEvent e) {
}
@Override
public Inventory getInventory() {
return null;
}
}

View File

@ -55,6 +55,21 @@ transaction:
- "&7Buyer&f: &b{buyer}" - "&7Buyer&f: &b{buyer}"
gui: gui:
transaction:
title: "&E&lSelect an Option"
items:
alltransactions:
item: "BOOK:0"
name: "&e&lAll Transactions"
lore:
- "&7View all the recorded"
- "&7transactions by everyone."
playertransactions:
item: "NETHER_STAR:0"
name: "&e&lYour Transactions"
lore:
- "&7View all the recorded"
- "&7transactions you've made."
alltransactions: alltransactions:
title: "&E&lAll Transactions" title: "&E&lAll Transactions"
items: items:
@ -74,6 +89,8 @@ gui:
lore: lore:
- "&7Next Page" - "&7Next Page"
playertransactions: playertransactions:
title: "&E&l{player} Transactions"
items:
previouspage: previouspage:
item: "PAPER:0" item: "PAPER:0"
name: "&e&l<- Previous Page" name: "&e&l<- Previous Page"