mirror of
https://github.com/kiranhart/Auction-House.git
synced 2025-01-21 15:01:19 +01:00
Update 1.0.3
This commit is contained in:
parent
28961b4dae
commit
34fb35e5e2
@ -4,7 +4,7 @@
|
||||
<groupId>com.shadebyte</groupId>
|
||||
<artifactId>auctionhouse</artifactId>
|
||||
<name>AuctionHouse</name>
|
||||
<version>1.0.1</version>
|
||||
<version>1.0.3</version>
|
||||
<description>A premium auction house plugin</description>
|
||||
<url>https://www.shadebyte.com</url>
|
||||
<build>
|
||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.shadebyte</groupId>
|
||||
<artifactId>auctionhouse</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>1.0.3</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>AuctionHouse</name>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.shadebyte.auctionhouse;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.massivestats.MassiveStats;
|
||||
import com.shadebyte.auctionhouse.api.AuctionAPI;
|
||||
import com.shadebyte.auctionhouse.api.enums.Lang;
|
||||
@ -7,13 +8,13 @@ import com.shadebyte.auctionhouse.api.event.AuctionEndEvent;
|
||||
import com.shadebyte.auctionhouse.api.event.AuctionStartEvent;
|
||||
import com.shadebyte.auctionhouse.api.event.TransactionCompleteEvent;
|
||||
import com.shadebyte.auctionhouse.auction.AuctionItem;
|
||||
import com.shadebyte.auctionhouse.auction.AuctionPlayer;
|
||||
import com.shadebyte.auctionhouse.auction.Transaction;
|
||||
import com.shadebyte.auctionhouse.cmds.CommandManager;
|
||||
import com.shadebyte.auctionhouse.events.AGUIListener;
|
||||
import com.shadebyte.auctionhouse.events.PlayerListener;
|
||||
import com.shadebyte.auctionhouse.events.TransactionListener;
|
||||
import com.shadebyte.auctionhouse.inventory.AGUI;
|
||||
import com.shadebyte.auctionhouse.inventory.inventories.AuctionGUI;
|
||||
import com.shadebyte.auctionhouse.util.Debugger;
|
||||
import com.shadebyte.auctionhouse.util.Locale;
|
||||
import com.shadebyte.auctionhouse.util.storage.ConfigWrapper;
|
||||
@ -225,8 +226,17 @@ public final class Core extends JavaPlugin {
|
||||
if (getConfig().getBoolean("settings.auto-refresh-auction-page")) {
|
||||
Bukkit.getOnlinePlayers().forEach(p -> {
|
||||
if (p.getOpenInventory().getTopInventory().getTitle().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("gui.auction.title")))) {
|
||||
p.closeInventory();
|
||||
p.openInventory(new AuctionGUI(p).getInventory());
|
||||
p.getOpenInventory().getTopInventory().clear();
|
||||
p.getOpenInventory().getTopInventory().setItem(45, AuctionAPI.getInstance().createConfigItem("gui.auction.items.yourauctions", new AuctionPlayer(p).getTotalActiveAuctions(), 0));
|
||||
p.getOpenInventory().getTopInventory().setItem(46, AuctionAPI.getInstance().createConfigItem("gui.auction.items.collectionbin", 0, new AuctionPlayer(p).getTotalExpiredAuctions()));
|
||||
p.getOpenInventory().getTopInventory().setItem(48, AuctionAPI.getInstance().createConfigItem("gui.auction.items.previouspage", 0, 0));
|
||||
p.getOpenInventory().getTopInventory().setItem(49, AuctionAPI.getInstance().createConfigItem("gui.auction.items.refresh", 0, 0));
|
||||
p.getOpenInventory().getTopInventory().setItem(50, AuctionAPI.getInstance().createConfigItem("gui.auction.items.nextpage", 0, 0));
|
||||
p.getOpenInventory().getTopInventory().setItem(52, AuctionAPI.getInstance().createConfigItem("gui.auction.items.howtosell", 0, 0));
|
||||
p.getOpenInventory().getTopInventory().setItem(53, AuctionAPI.getInstance().createConfigItem("gui.auction.items.guide", 0, 0));
|
||||
|
||||
List<List<AuctionItem>> chunks = Lists.partition(Core.getInstance().auctionItems, 45);
|
||||
chunks.get(0).forEach(item -> p.getOpenInventory().getTopInventory().setItem(p.getOpenInventory().getTopInventory().firstEmpty(), item.auctionStack()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ public enum Lang {
|
||||
CANNOT_BUY_OWN("cantbuyown"),
|
||||
CANNOT_BID_OWN("cantbidonown"),
|
||||
AIR("air"),
|
||||
INVALID_TRANSACTION("invalidtransaction"),
|
||||
|
||||
AUCTION_LISTED("auction.listed"),
|
||||
AUCTION_BUY("auction.buy"),
|
||||
|
@ -0,0 +1,96 @@
|
||||
package com.shadebyte.auctionhouse.auction;
|
||||
|
||||
import com.shadebyte.auctionhouse.Core;
|
||||
import com.shadebyte.auctionhouse.api.AuctionAPI;
|
||||
import com.shadebyte.auctionhouse.api.discordwebhook.embed.FieldEmbed;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* The current file has been created by Kiran Hart
|
||||
* Date Created: 9/17/2018
|
||||
* Time Created: 2:28 PM
|
||||
* Usage of any code found within this class is prohibited unless given explicit permission otherwise.
|
||||
*/
|
||||
public class DiscordMessageWrapper {
|
||||
|
||||
private String configLocation;
|
||||
private AuctionItem auctionItem;
|
||||
|
||||
public DiscordMessageWrapper(String configLocation, AuctionItem auctionItem) {
|
||||
this.configLocation = configLocation;
|
||||
this.auctionItem = auctionItem;
|
||||
}
|
||||
|
||||
public FieldEmbed getFieldEmbed() {
|
||||
String name = configLocation;
|
||||
return FieldEmbed.builder()
|
||||
.name(name.substring(name.lastIndexOf(".")).replace("_", " ").replace(".", ""))
|
||||
.value(Core.getInstance().getConfig().getString(configLocation + ".data").replace("{seller}", Bukkit.getOfflinePlayer(UUID.fromString(auctionItem.getOwner())).getName())
|
||||
.replace("{bid_start}", AuctionAPI.getInstance().friendlyNumber(auctionItem.getStartPrice()))
|
||||
.replace("{bid_increment}", AuctionAPI.getInstance().friendlyNumber(auctionItem.getBidIncrement()))
|
||||
.replace("{buy_now}", AuctionAPI.getInstance().friendlyNumber(auctionItem.getBuyNowPrice()))
|
||||
.replace("{item_type}", auctionItem.getItem().getType().name())
|
||||
.replace("{item_name}", getDisplayName())
|
||||
.replace("{item_enchants}", getEnchantments())
|
||||
.replace("{item_lore}", getLore())
|
||||
).inline(Core.getInstance().getConfig().getBoolean(configLocation + ".inline")).build();
|
||||
}
|
||||
|
||||
|
||||
public String getDisplayName() {
|
||||
String name;
|
||||
if (auctionItem.getItem().hasItemMeta()) {
|
||||
if (auctionItem.getItem().getItemMeta().hasDisplayName())
|
||||
name = ChatColor.stripColor(auctionItem.getItem().getItemMeta().getDisplayName());
|
||||
else
|
||||
name = StringUtils.capitalize(ChatColor.stripColor(auctionItem.getItem().getType().name().toLowerCase().replace("_", " ")));
|
||||
} else {
|
||||
name = StringUtils.capitalize(ChatColor.stripColor(auctionItem.getItem().getType().name().toLowerCase().replace("_", " ")));
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getEnchantments() {
|
||||
String lore = "";
|
||||
if (auctionItem.getItem().hasItemMeta()) {
|
||||
if (!auctionItem.getItem().getItemMeta().hasEnchants()) {
|
||||
lore = "No Enchantments";
|
||||
} else {
|
||||
for (Enchantment enchantment : auctionItem.getItem().getItemMeta().getEnchants().keySet()) {
|
||||
String name = enchantment.getName().replace("_", " ").toLowerCase();
|
||||
String level = AuctionAPI.getInstance().toRoman(auctionItem.getItem().getItemMeta().getEnchantLevel(enchantment));
|
||||
String e = StringUtils.capitalize(name) + " " + level;
|
||||
lore += e + ", ";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lore = "No Enchantments";
|
||||
}
|
||||
return lore;
|
||||
}
|
||||
|
||||
public String getLore() {
|
||||
String lore = "";
|
||||
if (auctionItem.getItem().hasItemMeta()) {
|
||||
if (!auctionItem.getItem().getItemMeta().hasLore()) {
|
||||
lore = "No Lore";
|
||||
} else {
|
||||
for (String s : auctionItem.getItem().getItemMeta().getLore()) {
|
||||
lore += ChatColor.stripColor(s) + ", ";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lore = "No Lore";
|
||||
}
|
||||
return lore;
|
||||
}
|
||||
|
||||
public String getConfigLocation() {
|
||||
return configLocation;
|
||||
}
|
||||
}
|
@ -11,12 +11,15 @@ import com.shadebyte.auctionhouse.api.enums.Permissions;
|
||||
import com.shadebyte.auctionhouse.api.event.AuctionStartEvent;
|
||||
import com.shadebyte.auctionhouse.auction.AuctionItem;
|
||||
import com.shadebyte.auctionhouse.auction.AuctionPlayer;
|
||||
import com.shadebyte.auctionhouse.auction.DiscordMessageWrapper;
|
||||
import com.shadebyte.auctionhouse.cmds.SubCommand;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The current file has been created by Kiran Hart
|
||||
@ -65,6 +68,11 @@ public class SellCommand extends SubCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (AuctionAPI.getItemInHand(p) == null || AuctionAPI.getItemInHand(p).getType() == Material.AIR) {
|
||||
p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.AIR.getNode()));
|
||||
return;
|
||||
}
|
||||
|
||||
AuctionItem auctionItem = new AuctionItem(p.getUniqueId().toString(), AuctionAPI.getItemInHand(p), Core.getInstance().getConfig().getInt("settings.default-auction-time"), buyNow, 0, buyNow);
|
||||
AuctionStartEvent auctionStartEvent = new AuctionStartEvent(auctionItem);
|
||||
Core.getInstance().getServer().getPluginManager().callEvent(auctionStartEvent);
|
||||
@ -73,25 +81,32 @@ public class SellCommand extends SubCommand {
|
||||
Core.getInstance().auctionItems.add(0, auctionItem);
|
||||
p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.AUCTION_LISTED.getNode()).replace("{itemname}", auctionItem.getDisplayName()).replace("{price}", AuctionAPI.getInstance().friendlyNumber(buyNow)));
|
||||
|
||||
AuctionAPI.setItemInHand(p, null);
|
||||
p.updateInventory();
|
||||
|
||||
//Discord Hook
|
||||
if (Core.getInstance().getConfig().getBoolean("discord.enabled")) {
|
||||
DiscordHook discordHook = new DiscordHook(Core.getInstance().getConfig().getString("discord.webhook"));
|
||||
DiscordEmbed de = DiscordEmbed.builder()
|
||||
.title(Core.getInstance().getConfig().getString("discord.title"))
|
||||
.description(Core.getInstance().getConfig().getString("discord.description"))
|
||||
.color(1)
|
||||
.fields(Arrays.asList(
|
||||
FieldEmbed.builder().name("Seller").value(p.getName()).inline(true).build(),
|
||||
FieldEmbed.builder().name("Buy Now").value(AuctionAPI.getInstance().friendlyNumber(buyNow)).build(),
|
||||
FieldEmbed.builder().name("Item").value(auctionItem.getItem().getType().name() + ":" + auctionItem.getItem().getDurability()).build()
|
||||
))
|
||||
.build();
|
||||
|
||||
DiscordMessage dm = DiscordMessage.builder().username(Core.getInstance().getConfig().getString("discord.username")).content("").avatarUrl(Core.getInstance().getConfig().getString("discord.profilepicture")).embeds(Arrays.asList(de)).build();
|
||||
discordHook.send(dm);
|
||||
//Discord Hook
|
||||
if (Core.getInstance().getConfig().getBoolean("discord.enabled")) {
|
||||
DiscordHook discordHook = new DiscordHook(Core.getInstance().getConfig().getString("discord.webhook"));
|
||||
|
||||
|
||||
List<FieldEmbed> embeds = new ArrayList<>();
|
||||
for (String s : Core.getInstance().getConfig().getConfigurationSection("discord.add").getKeys(false)) {
|
||||
embeds.add(new DiscordMessageWrapper("discord.add." + s, auctionItem).getFieldEmbed());
|
||||
}
|
||||
|
||||
DiscordEmbed de = DiscordEmbed.builder()
|
||||
.title(Core.getInstance().getConfig().getString("discord.title"))
|
||||
.color(1)
|
||||
.fields(embeds)
|
||||
.build();
|
||||
|
||||
DiscordMessage dm = DiscordMessage.builder().username(Core.getInstance().getConfig().getString("discord.username")).content("").avatarUrl(Core.getInstance().getConfig().getString("discord.profilepicture")).embeds(Arrays.asList(de)).build();
|
||||
discordHook.send(dm);
|
||||
}
|
||||
}
|
||||
|
||||
AuctionAPI.setItemInHand(p, null);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -168,22 +183,26 @@ public class SellCommand extends SubCommand {
|
||||
|
||||
//Discord Hook
|
||||
if (Core.getInstance().getConfig().getBoolean("discord.enabled")) {
|
||||
DiscordHook discordHook = new DiscordHook(Core.getInstance().getConfig().getString("discord.webhook"));
|
||||
DiscordEmbed de = DiscordEmbed.builder()
|
||||
.title(Core.getInstance().getConfig().getString("discord.title"))
|
||||
.description(Core.getInstance().getConfig().getString("discord.description"))
|
||||
.color(1)
|
||||
.fields(Arrays.asList(
|
||||
FieldEmbed.builder().name("Seller").value(p.getName()).inline(true).build(),
|
||||
FieldEmbed.builder().name("Start Price").value(AuctionAPI.getInstance().friendlyNumber(startPrice)).build(),
|
||||
FieldEmbed.builder().name("Increment").value(AuctionAPI.getInstance().friendlyNumber(increment)).build(),
|
||||
FieldEmbed.builder().name("Buy Now").value(AuctionAPI.getInstance().friendlyNumber(buyNow)).build(),
|
||||
FieldEmbed.builder().name("Item").value(auctionItem.getItem().getType().name() + ":" + auctionItem.getItem().getDurability()).build()
|
||||
))
|
||||
.build();
|
||||
|
||||
DiscordMessage dm = DiscordMessage.builder().username(Core.getInstance().getConfig().getString("discord.username")).content("").avatarUrl(Core.getInstance().getConfig().getString("discord.profilepicture")).embeds(Arrays.asList(de)).build();
|
||||
discordHook.send(dm);
|
||||
//Discord Hook
|
||||
if (Core.getInstance().getConfig().getBoolean("discord.enabled")) {
|
||||
DiscordHook discordHook = new DiscordHook(Core.getInstance().getConfig().getString("discord.webhook"));
|
||||
|
||||
|
||||
List<FieldEmbed> embeds = new ArrayList<>();
|
||||
for (String s : Core.getInstance().getConfig().getConfigurationSection("discord.add").getKeys(false)) {
|
||||
embeds.add(new DiscordMessageWrapper("discord.add." + s, auctionItem).getFieldEmbed());
|
||||
}
|
||||
|
||||
DiscordEmbed de = DiscordEmbed.builder()
|
||||
.title(Core.getInstance().getConfig().getString("discord.title"))
|
||||
.color(1)
|
||||
.fields(embeds)
|
||||
.build();
|
||||
|
||||
DiscordMessage dm = DiscordMessage.builder().username(Core.getInstance().getConfig().getString("discord.username")).content("").avatarUrl(Core.getInstance().getConfig().getString("discord.profilepicture")).embeds(Arrays.asList(de)).build();
|
||||
discordHook.send(dm);
|
||||
}
|
||||
}
|
||||
|
||||
AuctionAPI.setItemInHand(p, null);
|
||||
|
@ -43,6 +43,12 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
String node = (String) NBTEditor.getItemTag(AuctionAPI.getItemInHand(p), "AuctionReceipt");
|
||||
|
||||
if (!Core.getInstance().getTransactions().getConfig().contains("transactions." + node)) {
|
||||
p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.INVALID_TRANSACTION.getNode()));
|
||||
return;
|
||||
}
|
||||
|
||||
p.openInventory(new SingleTransactionGUI(node).getInventory());
|
||||
}
|
||||
}
|
||||
|
@ -33,10 +33,38 @@ discord:
|
||||
enabled: false
|
||||
webhook: ""
|
||||
title: "Auction House"
|
||||
description: "A new item has been listed!"
|
||||
description-complete: "A transaction has been completed!"
|
||||
username: "Auction House"
|
||||
profilepicture: ""
|
||||
username: "Auction House"
|
||||
add:
|
||||
description:
|
||||
inline: false
|
||||
data: "A new item has been listed!"
|
||||
seller:
|
||||
inline: false
|
||||
data: "{seller}"
|
||||
bid_start:
|
||||
inline: false
|
||||
data: "{bid_start}"
|
||||
bid_increment:
|
||||
inline: false
|
||||
data: "{bid_increment}"
|
||||
buy_now:
|
||||
inline: false
|
||||
data: "{buy_now}"
|
||||
item_type:
|
||||
inline: false
|
||||
data: "{item_type}"
|
||||
item_name:
|
||||
inline: false
|
||||
data: "{item_name}"
|
||||
item_enchants:
|
||||
inline: false
|
||||
data: "{item_enchants}"
|
||||
item_lore:
|
||||
inline: false
|
||||
data: "{item_lore}"
|
||||
|
||||
|
||||
|
||||
receipt:
|
||||
give-on-transaction: true
|
||||
|
@ -19,6 +19,7 @@ notenoughmoney = "&CYou do not have enough money!"
|
||||
cantbidonown = "&cYou cannot bid on your own item!"
|
||||
cantbuyown = "&cYou cannot buy your own item!"
|
||||
air = "&CCome on, really tryna auction air?"
|
||||
invalidtransaction = "&cThat transaction ID could not be found."
|
||||
|
||||
price.max.start = "&cPlease start auction with a lower price."
|
||||
price.max.auction = "&cPlease start with a lower bid price."
|
||||
|
@ -1,13 +1,7 @@
|
||||
package com.shadebyte.server;
|
||||
|
||||
import com.shadebyte.auctionhouse.Core;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
/**
|
||||
* The current file has been created by Kiran Hart
|
||||
* Date Created: 7/23/2018
|
||||
@ -19,24 +13,11 @@ public class ServerTest {
|
||||
private HikariDataSource hikari;
|
||||
|
||||
public ServerTest() {
|
||||
hikari = new HikariDataSource();
|
||||
hikari.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
|
||||
hikari.addDataSourceProperty("serverName", "localhost");
|
||||
hikari.addDataSourceProperty("port", 3306);
|
||||
hikari.addDataSourceProperty("databaseName", "auctionhouse");
|
||||
hikari.addDataSourceProperty("user", "root");
|
||||
hikari.addDataSourceProperty("password", "");
|
||||
if (!hikari.isClosed()) {
|
||||
System.out.println("Connected to the database");
|
||||
}
|
||||
|
||||
try {
|
||||
Connection connection = hikari.getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("");
|
||||
statement.execute();
|
||||
} catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
String x = "discord.add.description";
|
||||
|
||||
|
||||
System.out.println(x.substring(x.lastIndexOf(".")).replace(".", ""));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
Loading…
Reference in New Issue
Block a user