Merge branch 'v1.2.4-Update'

This commit is contained in:
BadBones69 2017-08-13 22:45:19 -04:00
commit da82bc1492
16 changed files with 301 additions and 40 deletions

View File

@ -2,7 +2,7 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="/Users/Joe/Plugins/Spigot/Spigot 1.12.jar">
<classpathentry kind="lib" path="/Users/Joe/Plugins/Spigot/Spigot 1.12.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:file:/Users/Joe/Plugins/Spigot/Spigot%201.12%20JavaDoc.jar!/"/>
</attributes>

2
Notes
View File

@ -12,7 +12,7 @@ Feature Requests:
- Add an option to search for items by ID.
Reports:
- When you collect an item from the expired list with a fully inventory, the item gets lost.
-
Bug Fixes:
-

View File

@ -4,7 +4,7 @@ Settings:
Players-Current-Items: '&8Your Current Listings' #The Name of the Player Current Items GUI.
Cancelled/Expired-Items: '&8Cancelled/Expired Listings' #Name of the Cancelled/Expired GUI.
Buying-Item: '&8Purchase Item: Are You Sure?' #Name of the Buying GUI.
Bidding-On-Item: '&8You Are Bidding On This Item.' #Name of the Budding GUI.
Bidding-On-Item: '&8You Are Bidding On This Item.' #Name of the Bidding GUI.
Categories: '&8Categories' #Name of the Category GUI.
Sell-Time: 2d #The time that each item will sell for.
Bid-Time: 2m 30s #Time for each item that is biddable.

View File

@ -2,7 +2,7 @@ name: CrazyAuctions
author: BadBones69
main: me.badbones69.crazyauctions.Main
website: https://www.spigotmc.org/resources/authors/kicjow.9719/
version: 1.2.3
version: 1.2.4
depend: [Vault]
description: >
A plugin to auction off items globally.

View File

@ -17,7 +17,14 @@ import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import me.badbones69.crazyauctions.api.Category;
import me.badbones69.crazyauctions.api.CrazyAuctions;
import me.badbones69.crazyauctions.api.MCUpdate;
import me.badbones69.crazyauctions.api.SettingsManager;
import me.badbones69.crazyauctions.api.ShopType;
import me.badbones69.crazyauctions.controlers.GUI;
import me.badbones69.crazyauctions.currency.Vault;
import me.badbones69.crazyauctions.events.AuctionListEvent;
public class Main extends JavaPlugin implements Listener{
@ -67,11 +74,11 @@ public class Main extends JavaPlugin implements Listener{
Player player = (Player) sender;
if(settings.getConfig().contains("Settings.Category-Page-Opens-First")){
if(settings.getConfig().getBoolean("Settings.Category-Page-Opens-First")){
GUI.openCateories(player, Shop.SELL);
GUI.openCateories(player, ShopType.SELL);
return true;
}
}
GUI.openShop(player, Shop.SELL, Category.NONE, 1);
GUI.openShop(player, ShopType.SELL, Category.NONE, 1);
return true;
}
if(args.length >= 1){
@ -201,14 +208,26 @@ public class Main extends JavaPlugin implements Listener{
}
}
}
for(int i = 1; i < 100; i++) {
if(SellLimit < i) {
if(player.hasPermission("crazyauctions.sell." + i)) {
SellLimit = i;
}
}
if(BidLimit < i) {
if(player.hasPermission("crazyauctions.bid." + i)) {
BidLimit = i;
}
}
}
if(args[0].equalsIgnoreCase("Sell")){
if(auc.getItems(player, Shop.SELL).size() >= SellLimit){
if(auc.getItems(player, ShopType.SELL).size() >= SellLimit){
player.sendMessage(Methods.getPrefix()+Methods.color(settings.getMsg().getString("Messages.Max-Items")));
return true;
}
}
if(args[0].equalsIgnoreCase("Bid")){
if(auc.getItems(player, Shop.BID).size() >= BidLimit){
if(auc.getItems(player, ShopType.BID).size() >= BidLimit){
player.sendMessage(Methods.getPrefix()+Methods.color(settings.getMsg().getString("Messages.Max-Items")));
return true;
}
@ -244,12 +263,14 @@ public class Main extends JavaPlugin implements Listener{
settings.getData().set("Items."+num+".Full-Time", Methods.convertToMill(settings.getConfig().getString("Settings.Full-Expire-Time")));
int id = r.nextInt(999999);
// Runs 3x to check for same ID.
for(String i : settings.getData().getConfigurationSection("Items").getKeys(false))if(settings.getData().getInt("Items."+i+".StoreID")==id)id=r.nextInt(999999);
for(String i : settings.getData().getConfigurationSection("Items").getKeys(false))if(settings.getData().getInt("Items."+i+".StoreID")==id)id=r.nextInt(999999);
for(String i : settings.getData().getConfigurationSection("Items").getKeys(false))if(settings.getData().getInt("Items."+i+".StoreID")==id)id=r.nextInt(999999);
for(String i : settings.getData().getConfigurationSection("Items").getKeys(false))if(settings.getData().getInt("Items."+i+".StoreID")==id)id=r.nextInt(Integer.MAX_VALUE);
for(String i : settings.getData().getConfigurationSection("Items").getKeys(false))if(settings.getData().getInt("Items."+i+".StoreID")==id)id=r.nextInt(Integer.MAX_VALUE);
for(String i : settings.getData().getConfigurationSection("Items").getKeys(false))if(settings.getData().getInt("Items."+i+".StoreID")==id)id=r.nextInt(Integer.MAX_VALUE);
settings.getData().set("Items."+num+".StoreID", id);
ShopType type = ShopType.SELL;
if(args[0].equalsIgnoreCase("Bid")){
settings.getData().set("Items."+num+".Biddable", true);
type = ShopType.BID;
}else{
settings.getData().set("Items."+num+".Biddable", false);
}
@ -258,6 +279,7 @@ public class Main extends JavaPlugin implements Listener{
I.setAmount(amount);
settings.getData().set("Items."+num+".Item", I);
settings.saveData();
Bukkit.getPluginManager().callEvent(new AuctionListEvent(player, type, I, price));
player.sendMessage(Methods.getPrefix()+Methods.color(settings.getMsg().getString("Messages.Added-Item-To-Auction")
.replaceAll("%Price%", price+"").replaceAll("%price%", price+"")));
if(item.getAmount()<=1||(item.getAmount()-amount)<=0){

View File

@ -24,6 +24,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.Plugin;
import me.badbones69.crazyauctions.currency.CurrencyManager;
import me.badbones69.crazyauctions.events.AuctionWinBidEvent;
public class Methods {
@ -397,7 +398,9 @@ public class Methods {
if(cal.after(expireTime)){
int num = 1;
for(;data.contains("OutOfTime/Cancelled."+num);num++);
if(data.getBoolean("Items."+i+".Biddable")&&!data.getString("Items."+i+".TopBidder").equalsIgnoreCase("None")&&CurrencyManager.getMoney(Methods.getPlayer(data.getString("Items."+i+".TopBidder")))>=data.getInt("Items."+i+".Price")){
if(data.getBoolean("Items."+i+".Biddable")&&
!data.getString("Items."+i+".TopBidder").equalsIgnoreCase("None")&&
CurrencyManager.getMoney(Methods.getPlayer(data.getString("Items."+i+".TopBidder")))>=data.getInt("Items."+i+".Price")){
String winner = data.getString("Items."+i+".TopBidder");
String seller = data.getString("Items."+i+".Seller");
Long price = data.getLong("Items."+i+".Price");
@ -405,6 +408,7 @@ public class Methods {
CurrencyManager.removeMoney(Methods.getOfflinePlayer(winner), price);
if(Methods.isOnline(winner)){
Player player = Methods.getPlayer(winner);
Bukkit.getPluginManager().callEvent(new AuctionWinBidEvent(player, data.getItemStack("Items."+i+".Item"), price));
player.sendMessage(Methods.getPrefix()+Methods.color(msg.getString("Messages.Win-Bidding")
.replaceAll("%Price%", getPrice(i, false)).replaceAll("%price%", getPrice(i, false))));
}
@ -450,4 +454,4 @@ public class Methods {
return NumberFormat.getNumberInstance().format(price);
}
}
}

View File

@ -1,4 +1,4 @@
package me.badbones69.crazyauctions;
package me.badbones69.crazyauctions.api;
import java.util.ArrayList;

View File

@ -1,4 +1,4 @@
package me.badbones69.crazyauctions;
package me.badbones69.crazyauctions.api;
import java.util.ArrayList;
@ -6,6 +6,8 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import me.badbones69.crazyauctions.Main;
public class CrazyAuctions {
public static CrazyAuctions instance;
@ -30,18 +32,18 @@ public class CrazyAuctions {
return items;
}
public ArrayList<ItemStack> getItems(Player player, Shop type){
public ArrayList<ItemStack> getItems(Player player, ShopType type){
FileConfiguration data = Main.settings.getData();
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
if(data.contains("Items")){
for(String i : data.getConfigurationSection("Items").getKeys(false)){
if(data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getName())){
if(data.getBoolean("Items." + i + ".Biddable")){
if(type == Shop.BID){
if(type == ShopType.BID){
items.add(data.getItemStack("Items."+i+".Item").clone());
}
}else{
if(type == Shop.SELL){
if(type == ShopType.SELL){
items.add(data.getItemStack("Items."+i+".Item").clone());
}
}

View File

@ -1,4 +1,4 @@
package me.badbones69.crazyauctions;
package me.badbones69.crazyauctions.api;
import java.io.BufferedReader;
import java.io.IOException;

View File

@ -1,4 +1,4 @@
package me.badbones69.crazyauctions;
package me.badbones69.crazyauctions.api;
import java.io.File;
import java.io.FileOutputStream;

View File

@ -1,6 +1,6 @@
package me.badbones69.crazyauctions;
package me.badbones69.crazyauctions.api;
public enum Shop{
public enum ShopType{
SELL("Sell"), BID("Bid");
@ -9,7 +9,7 @@ public enum Shop{
/**
* @param name Name of the Shop Type.
*/
private Shop(String name){
private ShopType(String name){
this.Name=name;
}
@ -24,8 +24,8 @@ public enum Shop{
* @param name Name of the Type you want.
* @return Returns the Type as a Enum.
*/
public static Shop getFromName(String name){
for(Shop type : Shop.values()){
public static ShopType getFromName(String name){
for(ShopType type : ShopType.values()){
if(type.getName().equalsIgnoreCase(name)){
return type;
}

View File

@ -1,4 +1,4 @@
package me.badbones69.crazyauctions;
package me.badbones69.crazyauctions.controlers;
import java.util.ArrayList;
import java.util.HashMap;
@ -19,20 +19,26 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import me.badbones69.crazyauctions.Main;
import me.badbones69.crazyauctions.Methods;
import me.badbones69.crazyauctions.api.Category;
import me.badbones69.crazyauctions.api.ShopType;
import me.badbones69.crazyauctions.currency.CurrencyManager;
import me.badbones69.crazyauctions.events.AuctionBuyEvent;
import me.badbones69.crazyauctions.events.AuctionNewBidEvent;
public class GUI implements Listener{
private static HashMap<Player, Integer> Bidding = new HashMap<Player, Integer>();
private static HashMap<Player, String> BiddingID = new HashMap<Player, String>();
private static HashMap<Player, Shop> Type = new HashMap<Player, Shop>(); // Shop Type
private static HashMap<Player, ShopType> Type = new HashMap<Player, ShopType>(); // Shop Type
private static HashMap<Player, Category> Cat = new HashMap<Player, Category>(); // Category Type
private static HashMap<Player, List<Integer>> List = new HashMap<Player, List<Integer>>();
private static HashMap<Player, String> IDs = new HashMap<Player, String>();
public static Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("CrazyAuctions");
public static void openShop(Player player, Shop sell, Category cat, int page){
public static void openShop(Player player, ShopType sell, Category cat, int page){
Methods.updateAuction();
FileConfiguration config = Main.settings.getConfig();
FileConfiguration data = Main.settings.getData();
@ -53,7 +59,7 @@ public class GUI implements Listener{
List<String> lore = new ArrayList<String>();
if(cat.getItems().contains(data.getItemStack("Items."+i+".Item").getType()) || cat == Category.NONE){
if(data.getBoolean("Items."+i+".Biddable")){
if(sell==Shop.BID){
if(sell==ShopType.BID){
String seller = data.getString("Items."+i+".Seller");
String topbidder = data.getString("Items."+i+".TopBidder");
for(String l : config.getStringList("Settings.GUISettings.Bidding")){
@ -66,7 +72,7 @@ public class GUI implements Listener{
ID.add(data.getInt("Items."+i+".StoreID"));
}
}else{
if(sell==Shop.SELL){
if(sell==ShopType.SELL){
for(String l : config.getStringList("Settings.GUISettings.SellingItemLore")){
lore.add(l.replaceAll("%Price%", Methods.getPrice(i, false)).replaceAll("%price%", Methods.getPrice(i, false))
.replaceAll("%Seller%", data.getString("Items."+i+".Seller")).replaceAll("%seller%", data.getString("Items."+i+".Seller")));
@ -85,13 +91,13 @@ public class GUI implements Listener{
options.add("SellingItems");options.add("Cancelled/ExpiredItems");
options.add("PreviousPage");options.add("Refesh");options.add("NextPage");
options.add("Category1");options.add("Category2");
if(sell==Shop.SELL){
Type.put(player, Shop.SELL);
if(sell==ShopType.SELL){
Type.put(player, ShopType.SELL);
options.add("Bidding/Selling.Selling");
options.add("WhatIsThis.SellingShop");
}
if(sell==Shop.BID){
Type.put(player, Shop.BID);
if(sell==ShopType.BID){
Type.put(player, ShopType.BID);
options.add("Bidding/Selling.Bidding");
options.add("WhatIsThis.BiddingShop");
}
@ -126,7 +132,7 @@ public class GUI implements Listener{
player.openInventory(inv);
}
public static void openCateories(Player player, Shop shop){
public static void openCateories(Player player, ShopType shop){
Methods.updateAuction();
FileConfiguration config = Main.settings.getConfig();
Inventory inv = Bukkit.createInventory(null, 54, Methods.color(config.getString("Settings.Categories")));
@ -263,7 +269,7 @@ public class GUI implements Listener{
FileConfiguration data = Main.settings.getData();
FileConfiguration msg = Main.settings.getMsg();
if(!data.contains("Items."+ID)){
openShop(player, Shop.SELL, Cat.get(player), 1);
openShop(player, ShopType.SELL, Cat.get(player), 1);
player.sendMessage(Methods.getPrefix()+Methods.color(msg.getString("Messages.Item-Doesnt-Exist")));
return;
}
@ -309,7 +315,7 @@ public class GUI implements Listener{
FileConfiguration data = Main.settings.getData();
FileConfiguration msg = Main.settings.getMsg();
if(!data.contains("Items."+ID)){
openShop(player, Shop.BID, Cat.get(player), 1);
openShop(player, ShopType.BID, Cat.get(player), 1);
player.sendMessage(Methods.getPrefix()+Methods.color(msg.getString("Messages.Item-Doesnt-Exist")));
return;
}
@ -506,6 +512,7 @@ public class GUI implements Listener{
player.sendMessage(Methods.getPrefix()+Methods.color(msg.getString("Messages.Bid-More-Money")));
return;
}
Bukkit.getPluginManager().callEvent(new AuctionNewBidEvent(player, data.getItemStack("Items."+ID+".Item"), bid));
data.set("Items."+ID+".Price", bid);
data.set("Items."+ID+".TopBidder", player.getName());
player.sendMessage(Methods.getPrefix()+Methods.color(msg.getString("Messages.Bid-Msg")
@ -616,12 +623,12 @@ public class GUI implements Listener{
return;
}
if(item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Bidding/Selling.Selling.Name")))){
openShop(player, Shop.BID, Cat.get(player), 1);
openShop(player, ShopType.BID, Cat.get(player), 1);
playClick(player);
return;
}
if(item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Bidding/Selling.Bidding.Name")))){
openShop(player, Shop.SELL, Cat.get(player), 1);
openShop(player, ShopType.SELL, Cat.get(player), 1);
playClick(player);
return;
}
@ -797,6 +804,8 @@ public class GUI implements Listener{
.replaceAll("%Money_Needed%", (cost-CurrencyManager.getMoney(player))+"").replaceAll("%money_needed%", (cost-CurrencyManager.getMoney(player))+"")));
return;
}
ItemStack i = data.getItemStack("Items."+ID+".Item");
Bukkit.getPluginManager().callEvent(new AuctionBuyEvent(player, i, cost));
CurrencyManager.removeMoney(player, cost);
CurrencyManager.addMoney(Methods.getOfflinePlayer(seller), cost);
player.sendMessage(Methods.getPrefix()+Methods.color(msg.getString("Messages.Bought-Item")
@ -807,7 +816,6 @@ public class GUI implements Listener{
.replaceAll("%Price%", Methods.getPrice(ID, false)).replaceAll("%price%", Methods.getPrice(ID, false))
.replaceAll("%Player%", player.getName()).replaceAll("%player%", player.getName())));
}
ItemStack i = data.getItemStack("Items."+ID+".Item");
player.getInventory().addItem(i);
data.set("Items."+ID, null);
Main.settings.saveData();

View File

@ -0,0 +1,54 @@
package me.badbones69.crazyauctions.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
/**
*
* @author BadBones69
*
* This event is fired when a player buys something from the selling auction house.
*
*/
public class AuctionBuyEvent extends Event{
private Player player;
private long price;
private ItemStack item;
private static final HandlerList handlers = new HandlerList();
/**
*
* @param player
* @param item
* @param price
*/
public AuctionBuyEvent(Player player, ItemStack item, long price) {
this.player = player;
this.item = item;
this.price = price;
}
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public Player getPlayer() {
return player;
}
public ItemStack getItem() {
return item;
}
public long getPrice() {
return price;
}
}

View File

@ -0,0 +1,63 @@
package me.badbones69.crazyauctions.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import me.badbones69.crazyauctions.api.ShopType;
/**
*
* @author BadBones69
*
* This event is fired when a new item is listed onto the auction house.
*
*/
public class AuctionListEvent extends Event{
private Player player;
private long price;
private ShopType shop;
private ItemStack item;
private static final HandlerList handlers = new HandlerList();
/**
*
* @param player
* @param shop
* @param item
* @param price
*/
public AuctionListEvent(Player player, ShopType shop, ItemStack item, long price) {
this.player = player;
this.shop = shop;
this.item = item;
this.price = price;
}
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public Player getPlayer() {
return player;
}
public ShopType getShopType() {
return shop;
}
public ItemStack getItem() {
return item;
}
public long getPrice() {
return price;
}
}

View File

@ -0,0 +1,54 @@
package me.badbones69.crazyauctions.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
/**
*
* @author BadBones69
*
* This event is fired when a player places a new bid onto an item in the auction house.
*
*/
public class AuctionNewBidEvent extends Event{
private Player player;
private long bid;
private ItemStack item;
private static final HandlerList handlers = new HandlerList();
/**
*
* @param player
* @param item
* @param bid
*/
public AuctionNewBidEvent(Player player, ItemStack item, long bid) {
this.player = player;
this.item = item;
this.bid = bid;
}
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public Player getPlayer() {
return player;
}
public ItemStack getItem() {
return item;
}
public long getBid() {
return bid;
}
}

View File

@ -0,0 +1,54 @@
package me.badbones69.crazyauctions.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
/**
*
* @author BadBones69
*
* This event is fired when a bidding item's time has run out and so a player wins the item.
*
*/
public class AuctionWinBidEvent extends Event{
private Player player;
private long bid;
private ItemStack item;
private static final HandlerList handlers = new HandlerList();
/**
*
* @param player
* @param item
* @param bid
*/
public AuctionWinBidEvent(Player player, ItemStack item, long bid) {
this.player = player;
this.item = item;
this.bid = bid;
}
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public Player getPlayer() {
return player;
}
public ItemStack getItem() {
return item;
}
public long getBid() {
return bid;
}
}