This commit is contained in:
Kiran Hart 2019-08-05 21:17:25 -04:00
parent c5591fe742
commit 9ea4986092
6 changed files with 155 additions and 3 deletions

View File

@ -46,6 +46,10 @@
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
@ -78,6 +82,12 @@
<version>1.14.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

10
pom.xml
View File

@ -59,6 +59,10 @@
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
@ -79,5 +83,11 @@
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -7,25 +7,123 @@ package com.kiranhart.auctionhouse.inventory.inventories;
Code within this class is not to be redistributed without proper permission.
*/
import com.google.common.collect.Lists;
import com.kiranhart.auctionhouse.Core;
import com.kiranhart.auctionhouse.api.statics.AuctionSettings;
import com.kiranhart.auctionhouse.api.version.NBTEditor;
import com.kiranhart.auctionhouse.api.version.XMaterial;
import com.kiranhart.auctionhouse.auction.AuctionItem;
import com.kiranhart.auctionhouse.inventory.AGUI;
import com.kiranhart.auctionhouse.util.Debugger;
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;
public class AuctionGUI implements AGUI {
private Player p;
private List<List<AuctionItem>> chunks;
public AuctionGUI(Player p) {
this.p = p;
chunks = Lists.partition(Core.getInstance().getAuctionItems(), 45);
}
private int page = 1;
@Override
public void click(InventoryClickEvent e, ItemStack clicked, int slot) {
e.setCancelled(true);
Player p = (Player) e.getWhoClicked();
/*
Page navigation system
*/
try {
if (page >= 1 && slot == 48) p.openInventory(setPage(this.getPage() - 1).getInventory());
if (page >= 1 && slot == 50) p.openInventory(setPage(this.getPage() + 1).getInventory());
} catch (Exception ex) {
Debugger.report(ex, false);
}
@Override
public void close(InventoryCloseEvent e) {
//Different auction inventories
//Refresh Auction GUI
if (slot == 49) {
return;
}
//Open Listings GUI
if (slot == 45) {
return;
}
//Open Expired GUI
if (slot == 46) {
return;
}
//Open Transaction Selection GUI
if (slot == 51) {
return;
}
//Clicking on active auction items.
//Check if air
if (clicked == null || clicked.getType() == XMaterial.AIR.parseMaterial()) {
return;
}
AuctionItem possibleAuctionItem = null;
/*
Perform the proper steps if the user left-clicks (not using bid system)
*/
if (e.getClick() == ClickType.LEFT) {
//Check if the bid system is set to false
if (!AuctionSettings.USE_BIDDING_SYSTEM) {
return;
}
//Get the key of the auction item
String auctionItemKey = NBTEditor.getString(clicked, "AuctionItemKey");
for (AuctionItem auctionItem : Core.getInstance().getAuctionItems()) {
if (auctionItem.getKey().equalsIgnoreCase(auctionItemKey)) possibleAuctionItem = auctionItem;
}
return;
}
}
@Override
public Inventory getInventory() {
return null;
}
@Override
public void close(InventoryCloseEvent e) {
}
public AuctionGUI setPage(int page) {
if (page <= 0)
this.page = 1;
else
this.page = page;
return this;
}
public int getPage() {
return page;
}
}

View File

@ -27,4 +27,8 @@ public class Debugger {
Bukkit.getConsoleSender().sendMessage(translateAlternateColorCodes('&', "&b================================================================"));
}
}
public static void report(Exception e, boolean show) {
if (show) report(e);
}
}

View File

@ -0,0 +1,19 @@
package com.kiranhart.auctionhouse.util.economy;
/*
The current file was created by Kiran Hart
Date: August 05 2019
Time: 9:06 PM
Code within this class is not to be redistributed without proper permission.
*/
import org.bukkit.OfflinePlayer;
public interface Economy {
boolean hasBalance(OfflinePlayer p, double cost);
boolean withdrawBalance(OfflinePlayer p, double cost);
boolean deposit(OfflinePlayer p, double amount);
}

View File

@ -0,0 +1,11 @@
package com.kiranhart.auctionhouse.util.economy;
/*
The current file was created by Kiran Hart
Date: August 05 2019
Time: 9:13 PM
Code within this class is not to be redistributed without proper permission.
*/
public class VaultEconomy {
}