No idea what to put here

This commit is contained in:
Kiran Hart 2018-08-07 16:56:45 -04:00
parent b042037dec
commit a4e013d35c
14 changed files with 493 additions and 12 deletions

View File

@ -1,9 +1,9 @@
<component name="ArtifactManager">
<artifact type="jar" name="AuctionHouse:jar">
<output-path />
<root id="archive" name="auctionhouse.jar">
<element id="module-output" name="auctionhouse" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/github/kevinsawicki/http-request/6.0/http-request-6.0.jar" path-in-jar="/" />
<element id="library" level="project" name="Maven: com.zaxxer:HikariCP:3.2.0" />
</root>
</artifact>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.zaxxer:HikariCP:3.2.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/zaxxer/HikariCP/3.2.0/HikariCP-3.2.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/zaxxer/HikariCP/3.2.0/HikariCP-3.2.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/zaxxer/HikariCP/3.2.0/HikariCP-3.2.0-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.slf4j:slf4j-api:1.7.25">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -37,5 +37,7 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.persistence:persistence-api:1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.16.12" level="project" />
<orderEntry type="library" name="Maven: com.github.kevinsawicki:http-request:6.0" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.2.0" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
</component>
</module>

114
dependency-reduced-pom.xml Normal file
View File

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.shadebyte</groupId>
<artifactId>auctionhouse</artifactId>
<name>AuctionHouse</name>
<version>1.0-SNAPSHOT</version>
<description>A premium auction house plugin</description>
<url>https://www.shadebyte.com</url>
<build>
<defaultGoal>clean package</defaultGoal>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>true</minimizeJar>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>commons-lang</artifactId>
<groupId>commons-lang</groupId>
</exclusion>
<exclusion>
<artifactId>json-simple</artifactId>
<groupId>com.googlecode.json-simple</groupId>
</exclusion>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
<exclusion>
<artifactId>gson</artifactId>
<groupId>com.google.code.gson</groupId>
</exclusion>
<exclusion>
<artifactId>snakeyaml</artifactId>
<groupId>org.yaml</groupId>
</exclusion>
<exclusion>
<artifactId>bungeecord-chat</artifactId>
<groupId>net.md-5</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.6</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>bukkit</artifactId>
<groupId>org.bukkit</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.12</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@ -11,6 +11,7 @@ import com.shadebyte.auctionhouse.auction.Transaction;
import com.shadebyte.auctionhouse.cmds.CommandManager;
import com.shadebyte.auctionhouse.events.AGUIListener;
import com.shadebyte.auctionhouse.events.TransactionListener;
import com.shadebyte.auctionhouse.inventory.AGUI;
import com.shadebyte.auctionhouse.util.Debugger;
import com.shadebyte.auctionhouse.util.Locale;
import com.shadebyte.auctionhouse.util.storage.ConfigWrapper;
@ -113,12 +114,17 @@ public final class Core extends JavaPlugin {
}
loadAuctions();
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&bFound a total of &6" + Transaction.getTotalTransactions() + " &brecorded transactions"));
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&bAuction House finished loading, took " + (System.currentTimeMillis() - startTime) + " ms"));
tickAuctions();
}
@Override
public void onDisable() {
Bukkit.getOnlinePlayers().forEach(p -> {
if(p.getOpenInventory().getTopInventory().getHolder() instanceof AGUI) p.closeInventory();
});
saveAuctions();
if (hikari != null)
hikari.close();

View File

@ -149,9 +149,7 @@ public class AuctionAPI {
}
public String getDate(long milli) {
Date date = new Date(milli);
SimpleDateFormat df2 = new SimpleDateFormat("dd/MM/yy");
return df2.format(date);
return new SimpleDateFormat("MMMM dd yyyy").format(new Date(milli));
}
public String friendlyNumber(double value) {

View File

@ -13,6 +13,7 @@ public enum Permissions {
HELP_CMD(BASE.getNode() + ".cmd.help"),
SELL_CMD(BASE.getNode() + ".cmd.sell"),
EXPIRED_CMD(BASE.getNode() + ".cmd.expired"),
TRANSACTIONS_CMD(BASE.getNode() + ".cmd.transactions"),
LISTINGS_CMD(BASE.getNode() + ".cmd.listings"),
MAX_AUCTIONS(BASE.getNode() + ".maxauctions"),
;

View File

@ -1,6 +1,16 @@
package com.shadebyte.auctionhouse.auction;
import com.shadebyte.auctionhouse.Core;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* The current file has been created by Kiran Hart
@ -53,6 +63,40 @@ public class Transaction {
Core.getInstance().getTransactions().saveConfig();
}
public static int getTotalTransactions() {
return (Core.getInstance().getTransactions().getConfig().getConfigurationSection("transactions") != null && Core.getInstance().getTransactions().getConfig().getConfigurationSection("transactions").getKeys(false).size() > 0) ? Core.getInstance().getTransactions().getConfig().getConfigurationSection("transactions").getKeys(false).size() : 0;
}
public static int getTotalTransactionsByPlayer(Player p) {
if (getTotalTransactions() == 0) return 0;
int total = 0;
for (String transactions : Core.getInstance().getTransactions().getConfig().getConfigurationSection("transactions").getKeys(false)) {
if (Core.getInstance().getTransactions().getConfig().getString("transactions." + transactions + ".seller").equalsIgnoreCase(p.getUniqueId().toString()) || Core.getInstance().getTransactions().getConfig().getString("transactions." + transactions + ".buyer").equalsIgnoreCase(p.getUniqueId().toString())) {
total++;
}
}
return total;
}
private static ItemStack getTransactionItem(String node) {
String[] stack = Core.getInstance().getConfig().getString("transaction.item").split(":");
ItemStack item = new ItemStack(Material.valueOf(stack[0].toUpperCase()), 1, Short.parseShort(stack[1]));
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"))));
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()))));
meta.setLore(lore);
item.setItemMeta(meta);
return item;
}
public static List<ItemStack> getAllRecordedTransactions() {
List<ItemStack> items = new ArrayList<>();
if (getTotalTransactions() == 0) return items;
Core.getInstance().getTransactions().getConfig().getConfigurationSection("transactions").getKeys(false).forEach(node -> items.add(getTransactionItem(node)));
return items;
}
public TransactionType getTransactionType() {
return transactionType;
}

View File

@ -3,10 +3,7 @@ package com.shadebyte.auctionhouse.cmds;
import com.shadebyte.auctionhouse.Core;
import com.shadebyte.auctionhouse.api.enums.Lang;
import com.shadebyte.auctionhouse.api.enums.Permissions;
import com.shadebyte.auctionhouse.cmds.subcmds.ExpiredCommand;
import com.shadebyte.auctionhouse.cmds.subcmds.ListedCommand;
import com.shadebyte.auctionhouse.cmds.subcmds.ReloadCommand;
import com.shadebyte.auctionhouse.cmds.subcmds.SellCommand;
import com.shadebyte.auctionhouse.cmds.subcmds.*;
import com.shadebyte.auctionhouse.inventory.inventories.AuctionGUI;
import com.shadebyte.auctionhouse.inventory.inventories.ListingsGUI;
import com.shadebyte.auctionhouse.util.Debugger;
@ -40,6 +37,7 @@ public class CommandManager implements CommandExecutor {
public final String listed = "listed";
public final String reload = "reload";
public final String sell = "sell";
public final String transactions = "transactions";
public void initialize() {
Core.getInstance().getCommand(main).setExecutor(this);
@ -47,6 +45,7 @@ public class CommandManager implements CommandExecutor {
this.commands.add(new ReloadCommand());
this.commands.add(new ListedCommand());
this.commands.add(new ExpiredCommand());
this.commands.add(new TransactionsCommand());
}
@Override

View File

@ -0,0 +1,52 @@
package com.shadebyte.auctionhouse.cmds.subcmds;
import com.shadebyte.auctionhouse.Core;
import com.shadebyte.auctionhouse.api.enums.Lang;
import com.shadebyte.auctionhouse.api.enums.Permissions;
import com.shadebyte.auctionhouse.cmds.SubCommand;
import com.shadebyte.auctionhouse.inventory.inventories.AllTransactionsGUI;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
/**
* The current file has been created by Kiran Hart
* Date Created: 7/6/2018
* Time Created: 11:51 AM
* Usage of any code found within this class is prohibited unless given explicit permission otherwise.
*/
public class TransactionsCommand extends SubCommand {
@Override
public void onCommand(CommandSender sender, String[] args) {
if (!sender.hasPermission(Permissions.RELOAD_CMD.getNode())) {
sender.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.NO_PERMISSION.getNode()));
return;
}
if (!(sender instanceof Player)) {
sender.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.PLAYERS_ONLY.getNode()));
return;
}
Player p = (Player) sender;
p.openInventory(new AllTransactionsGUI(p).getInventory());
}
@Override
public String name() {
return Core.getInstance().getCommandManager().transactions;
}
@Override
public String info() {
return null;
}
@Override
public String[] aliases() {
return new String[0];
}
}

View File

@ -0,0 +1,92 @@
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.AuctionPlayer;
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.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 AllTransactionsGUI implements AGUI {
private Player p;
private List<List<ItemStack>> chunks;
private int page = 1;
public AllTransactionsGUI(Player p) {
this.p = p;
chunks = Lists.partition(Transaction.getAllRecordedTransactions(), 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 >= 0 & slot <= 44) {
if (clicked == null || clicked.getType() == Material.AIR) {
return;
}
}
}
@Override
public void close(InventoryCloseEvent e) {
}
@Override
public Inventory getInventory() {
Inventory inventory = Bukkit.createInventory(this, 54, ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("gui.collection.title")));
//Bottom Row
inventory.setItem(48, AuctionAPI.getInstance().createConfigItem("gui.alltransactions.items.previouspage", 0, 0));
inventory.setItem(49, AuctionAPI.getInstance().createConfigItem("gui.alltransactions.items.close", 0, 0));
inventory.setItem(50, AuctionAPI.getInstance().createConfigItem("gui.alltransactions.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 AllTransactionsGUI setPage(int page) {
if (page <= 0)
this.page = 1;
else
this.page = page;
return this;
}
public int getPage() {
return page;
}
}

View File

@ -0,0 +1,51 @@
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 org.bukkit.Bukkit;
import org.bukkit.ChatColor;
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/7/2018
* Time Created: 4:32 PM
* Usage of any code found within this class is prohibited unless given explicit permission otherwise.
*/
public class SingleTransactionGUI implements AGUI {
private Transaction transaction;
public SingleTransactionGUI(Transaction transaction) {
this.transaction = transaction;
}
@Override
public void click(InventoryClickEvent e, ItemStack clicked, int slot) {
e.setCancelled(true);
}
@Override
public void close(InventoryCloseEvent e) {
}
@Override
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));
inventory.setItem(13, transaction.getAuctionItem().getItem());
inventory.setItem(48, AuctionAPI.getInstance().createConfigItem("gui.singletransaction.items.back", 0, 0));
inventory.setItem(49, AuctionAPI.getInstance().createConfigItem("gui.singletransaction.items.you", 0, 0));
inventory.setItem(50, AuctionAPI.getInstance().createConfigItem("gui.singletransaction.items.auctionhouse", 0, 0));
return inventory;
}
}

View File

@ -23,9 +23,9 @@ database:
enabled: true
host: 162.241.217.18
port: 3306
database: ""
username: ""
password: ""
database: "kiranhar_auctionhouse"
username: "kiranhar_admin"
password: "TweetyHart1."
discord:
enabled: true
@ -47,7 +47,103 @@ receipt:
- "&bPrice&f: &a${price}"
- "&ePurchased on&f: &a{date} &fat &A{time}"
transaction:
item: "PAPER:0"
name: "&b{transaction_id}"
lore:
- "&7Seller&f: &b{seller}"
- "&7Buyer&f: &b{buyer}"
gui:
alltransactions:
title: "&E&lAll Transactions"
items:
previouspage:
item: "PAPER:0"
name: "&e&l<- Previous Page"
lore:
- "&7Go back"
close:
item: "NETHER_STAR:0"
name: "&e&lClose"
lore:
- "&7Click to exit this window"
nextpage:
item: "PAPER:0"
name: "&e&lNext Page ->"
lore:
- "&7Next Page"
playertransactions:
previouspage:
item: "PAPER:0"
name: "&e&l<- Previous Page"
lore:
- "&7Go back"
close:
item: "NETHER_STAR:0"
name: "&e&lClose"
lore:
- "&7Click to exit this window"
nextpage:
item: "PAPER:0"
name: "&e&lNext Page ->"
lore:
- "&7Next Page"
singletransaction:
title: "&6&lViewing Transaction"
items:
background:
item: "STAINED_GLASS_PANE:15"
name: "&0*"
lore:
- "&0*"
seller:
name: "&6&lSeller"
lore:
- "&7Name&f: &b{seller}"
- ""
- "&7Click to view all the"
- "&7transactions by this player."
buyer:
name: "&6&lBuyer"
lore:
- "&7Name&f: &b{seller}"
- ""
- "&7Click to view all the"
- "&7transactions by this player."
you:
item: "DOUBLE_PLANT:0"
name: "&6&lView Your Transactions"
lore:
- "&7Click to view all the"
- "&7transactions you've done."
back:
item: "NETHER_STAR:0"
name: "&6&LGo Back"
lore:
- "&7Go back to main transactions"
- "&7window selection menu."
auctionhouse:
item: "CHEST:0"
name: "&e&lReturn to Auction House"
lore:
- "&7Click here to return to the"
- "&7auction house main menu."
startprice:
item: "STAINED_GLASS_PANE:5"
name: "&6&lStart Price"
lore:
- "&7Auction started at &a${startprice}"
increment:
item: "STAINED_GLASS_PANE:5"
name: "&6&lBid Increment"
lore:
- "&7Bid increment set at &a${bidincrement}"
buynowprice:
item: "STAINED_GLASS_PANE:5"
name: "&6&lBuy Now Price"
lore:
- "&7Buy now price set at &a${buynowprice}"
active:
title: "&7Your Current Listings"
items:
@ -64,7 +160,7 @@ gui:
- "&7Go back"
nextpage:
item: "PAPER:0"
name: "&e&lPrevious Page ->"
name: "&e&lNext Page ->"
lore:
- "&7Next Page"
tutorial: