mirror of
https://github.com/kiranhart/Auction-House.git
synced 2024-11-29 06:35:28 +01:00
Pre Production commit
This commit is contained in:
parent
0bf60cac3c
commit
f2ddaad9d9
@ -123,6 +123,7 @@ public class AuctionAPI {
|
||||
Core.getInstance().getConfig().getStringList(node + ".lore").forEach(s -> lore.add(ChatColor.translateAlternateColorCodes('&', s)));
|
||||
meta.setLore(lore);
|
||||
stack.setItemMeta(meta);
|
||||
stack = (usr == 0) ? NBTEditor.setItemTag(stack, seller, "AuctionSellerHead") : NBTEditor.setItemTag(stack, buyer, "AuctionBuyerHead");
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
@ -100,6 +100,18 @@ public class Transaction {
|
||||
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() {
|
||||
return transactionType;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class PlayerListener implements Listener {
|
||||
public void onReceiptRightClick(PlayerInteractEvent e) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class AllTransactionsGUI implements AGUI {
|
||||
|
||||
@Override
|
||||
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
|
||||
inventory.setItem(48, AuctionAPI.getInstance().createConfigItem("gui.alltransactions.items.previouspage", 0, 0));
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -2,15 +2,18 @@ package com.shadebyte.auctionhouse.inventory.inventories;
|
||||
|
||||
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.entity.Player;
|
||||
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.UUID;
|
||||
|
||||
/**
|
||||
* The current file has been created by Kiran Hart
|
||||
* Date Created: 8/7/2018
|
||||
@ -28,6 +31,21 @@ public class SingleTransactionGUI implements AGUI {
|
||||
@Override
|
||||
public void click(InventoryClickEvent e, ItemStack clicked, int slot) {
|
||||
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
|
||||
@ -39,7 +57,8 @@ public class SingleTransactionGUI implements AGUI {
|
||||
public Inventory getInventory() {
|
||||
Inventory inventory = Bukkit.createInventory(this, 54, ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("gui.singletransaction.title")));
|
||||
//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(39, AuctionAPI.getInstance().createConfigItem("gui.singletransaction.items.back", 0, 0));
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -55,6 +55,21 @@ transaction:
|
||||
- "&7Buyer&f: &b{buyer}"
|
||||
|
||||
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:
|
||||
title: "&E&lAll Transactions"
|
||||
items:
|
||||
@ -74,6 +89,8 @@ gui:
|
||||
lore:
|
||||
- "&7Next Page"
|
||||
playertransactions:
|
||||
title: "&E&l{player} Transactions"
|
||||
items:
|
||||
previouspage:
|
||||
item: "PAPER:0"
|
||||
name: "&e&l<- Previous Page"
|
||||
|
Loading…
Reference in New Issue
Block a user